scientist-softserv / adventist_knapsack

Apache License 2.0
2 stars 0 forks source link

:unicorn: SPIKE: Check that files are available via rails c #535

Closed ShanaLMoore closed 1 year ago

ShanaLMoore commented 1 year ago

Summary

go through the files in knapsack and make sure they are available from the Rails console

Workflow: Type in the module or class name in the rails console and see if it errors

Acceptance Criteria

Screenshots or Video

Testing Instructions

Notes

kirkkwang commented 1 year ago

I used a script outside of my container

require 'find'

app_directory = '/Users/kirk/Desktop/projects/adventist_knapsack/app'
output = {}

begin
  # Go through all .rb files in the app directory
  Find.find(app_directory) do |path|
    next unless path =~ /.*\.rb$/ # skip non-ruby files

    nesting_stack = []
    qualified_names = []

    # Read each file and collect lines defining class or module
    File.readlines(path).each do |line|
      match = line.match(/^(\s*)(class|module)\s+([A-Z]\w*)/)
      if match
        indentation, _type, name = match.captures
        indentation_level = indentation.length

        # Remove items from the stack if they belong to a less or equally indented scope
        nesting_stack.pop while !nesting_stack.empty? && nesting_stack.last[:indentation] >= indentation_level

        # Add the new name to the stack with its indentation level
        nesting_stack.push({ name: name, indentation: indentation_level })

        # Create the fully qualified name and add it to the results
        full_name = nesting_stack.map { |item| item[:name] }.join('::')
        qualified_names << full_name
      end
    end

    output[path] = qualified_names unless qualified_names.empty?
  end
rescue Errno::ENOENT
  nil
end

constants = []

# Display the result
output.each do |_file_path, lines|
  constants << lines
end

puts constants.flatten.uniq

Which gave me the output

Hyrax
Hyrax::Actors
Hyrax::Actors::CollectionsMembershipActor
Hyrax::Actors::ConferenceItemActor
Hyrax::Actors::CreateWithRemoteFilesActor
Hyrax::Actors::DatasetActor
Hyrax::Actors::ExamPaperActor
Hyrax::Actors::FileSetActor
Hyrax::Actors::GenericWorkActor
Hyrax::Actors::ImageActor
Hyrax::Actors::JournalArticleActor
Hyrax::Actors::PublishedWorkActor
Hyrax::Actors::ThesisActor
HykuKnapsack
HykuKnapsack::ApplicationController
Hyrax::ConferenceItemsController
Hyrax::DatasetsController
Hyrax::ExamPapersController
Hyrax::JournalArticlesController
Hyrax::PublishedWorksController
Hyrax::ThesesController
Hyrax::ConferenceItemForm
Hyrax::DatasetForm
Hyrax::ExamPaperForm
Hyrax::FormTerms
Hyrax::Forms
Hyrax::Forms::Admin
Hyrax::Forms::Admin::AppearanceDecorator
Hyrax::Forms::CollectionFormDecorator
Hyrax::JournalArticleForm
Hyrax::PublishedWorkForm
Hyrax::ThesisForm
DogBiscuitsHelper
HykuKnapsack::ApplicationHelper
AppIndexerDecorator
CollectionIndexerDecorator
ConferenceItemIndexer
DatasetIndexer
ExamPaperIndexer
Hyrax::FileSetIndexerDecorator
JournalArticleIndexer
PublishedWorkIndexer
ThesisIndexer
CreateDerivativesJobDecorator
HykuKnapsack::ApplicationJob
ImportUrlJobDecorator
IndexPlainTextFilesJob
IndexPlainTextFilesJob::One
ReloadPdfsToSplitJob
ReloadSinglePdfJob
ReloadSinglePdfJob::BulkraxEntryNotFound
RemoveAccountRelationshipsJob
RemoveAccountRelationshipsJob::ForImporterJob
HykuKnapsack::ApplicationMailer
Bulkrax
Bulkrax::ApplicationMatcherDecorator
AdventistMetadata
Bulkrax::OaiAdventistQdcEntry
Bulkrax::OaiAdventistSetEntry
SlugBug
SlugMetadata
ConferenceItem
ContentBlockDecorator
Dataset
DogBiscuits
DogBiscuits::RemoteUrl
ExamPaper
GenericWorkDecorator
HykuKnapsac
HykuKnapsac::ApplicationRecord
Hyrax::FileSetDecorator
ImageDecorator
JournalArticle
PublishedWork
SolrDocumentDecorator
Thesis
VideoEmbedViewer
Bulkrax::OaiAdventistQdcParser
Hyku
Hyku::WorkShowPresenterDecorator
Hyrax::CollectionPresenterDecorator
Hyrax::CollectionPresenterDecorator::ClassMethods <= not a perfect script, this needs to be removed
Hyrax::ConferenceItemPresenter
Hyrax::DatasetPresenter
Hyrax::ExamPaperPresenter
Hyrax::GenericWorkPresenter
Hyrax::JournalArticlePresenter
Hyrax::PublishedWorkPresenter
Hyrax::ThesisPresenter
PackageIdsRenderer
PackagedByIdsRenderer
PublicationStatusRenderer
AdvSearchBuilder
Adventist
Adventist::TextFileTextExtractionService
AuthorityService
AuthorityService::DepartmentsService
AuthorityService::EventsService
AuthorityService::GroupsService
AuthorityService::PeopleService
AuthorityService::PlacesService
AuthorityService::OrganisationsService
AuthorityService::ProjectsService
AuthorityService::ConceptsService
AuthorityService::ContentVersionsService
AuthorityService::LicensesService
AuthorityService::PublicationStatusesService
AuthorityService::QualificationLevelsService
AuthorityService::QualificationNamesService
AuthorityService::ResourceTypeGeneralsService
AuthorityService::ResourceTypesService
AuthorityService::RightsStatementsService
AuthorityService::TableBasedAuthorityService
FileAuthorityConcern
LocalAuthorityConcern
DailySolrContentCheckService
Hyrax::IndexesThumbnailsDecorator
Hyrax::WorkThumbnailPathServiceDecorator
LocalFormMetadataService
UploadedCollectionThumbnailPathService

Then I just copy and pasted that into rails console and only observed these errors: