Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: replace calls to deprecated FileSignature#signature_from_file with .from_file #141

Open
jmartin-sul opened this issue Apr 7, 2018 · 2 comments
Labels
refactor architecture, refactoring, style, etc. tech debt

Comments

@jmartin-sul
Copy link
Member

jmartin-sul commented Apr 7, 2018

Replace FileSignature#signature_from_file with FileSignature.from_file


as @atz has pointed out, #signature_from_file is basically a method in the style of a factory method that produces new instances, except it actually sets values on the current instance and returns itself, but it's only (predominantly?) used chained after FileSignature.new, so it's being used as a de facto constructor anyway. The method comment also claims the intent is to create new instances ("Generate a FileSignature instance").

Would be nice to get rid of #signature_from_file usage in general, both in non-test moab-versioning code, and in other applications that use moab-versioning (including once in preservation_catalog), and then ultimately from moab-versioning entirely. Joe and I both grepped all our cloned DLSS projects, and the only usage we found was of the FileSignature.new.signature_from_file variety, which could easily be replaced by FileSignature.from_file.

Definitely not a high priority at the moment, but would be a helpful thing for understandability and maintenance of moab-versioning. And a pretty mechanical change.

@jmartin-sul
Copy link
Member Author

what i found:

preservation_catalog $ cd ..
software_dev_projects $ 
software_dev_projects $ 
software_dev_projects $ 
software_dev_projects $ grep -r signature_from_file .
./dor-services/lib/dor/services/digital_stacks_service.rb:        file_signature = Moab::FileSignature.new.signature_from_file(file_pathname)
./dor-services/lib/dor/services/digital_stacks_service.rb:        file_signature = Moab::FileSignature.new.signature_from_file(old_pathname)
./dor-services/lib/dor/services/digital_stacks_service.rb:        file_signature = Moab::FileSignature.new.signature_from_file(stacks_pathname)
./dor-services/spec/services/digital_stacks_service_spec.rb:      moab_signature = Moab::FileSignature.new.signature_from_file(file_pathname)
./dor-services/spec/services/digital_stacks_service_spec.rb:      moab_signature = Moab::FileSignature.new.signature_from_file(old_pathname)
./dor-services/spec/services/digital_stacks_service_spec.rb:      moab_signature = Moab::FileSignature.new.signature_from_file(workspace_pathname)
./dor-services/spec/services/digital_stacks_service_spec.rb:      moab_signature = Moab::FileSignature.new.signature_from_file(stacks_pathname)

./dor-services-v4/dor-services/lib/dor/services/digital_stacks_service.rb:        file_signature = Moab::FileSignature.new.signature_from_file(file_pathname)
./dor-services-v4/dor-services/lib/dor/services/digital_stacks_service.rb:        file_signature = Moab::FileSignature.new.signature_from_file(old_pathname)
./dor-services-v4/dor-services/lib/dor/services/digital_stacks_service.rb:        file_signature = Moab::FileSignature.new.signature_from_file(stacks_pathname)
./dor-services-v4/dor-services/spec/dor/digital_stacks_service_spec.rb:      moab_signature = Moab::FileSignature.new.signature_from_file(file_pathname)
./dor-services-v4/dor-services/spec/dor/digital_stacks_service_spec.rb:      moab_signature = Moab::FileSignature.new.signature_from_file(old_pathname)
./dor-services-v4/dor-services/spec/dor/digital_stacks_service_spec.rb:      moab_signature = Moab::FileSignature.new.signature_from_file(workspace_pathname)
./dor-services-v4/dor-services/spec/dor/digital_stacks_service_spec.rb:      moab_signature = Moab::FileSignature.new.signature_from_file(stacks_pathname)

./moab-versioning/lib/moab/bagger.rb:          signature = FileSignature.new.signature_from_file(file)
./moab-versioning/lib/moab/file_group.rb:        signature = FileSignature.new.signature_from_file(pathname)
./moab-versioning/lib/moab/file_signature.rb:    def signature_from_file(pathname)
./moab-versioning/lib/moab/file_signature.rb:      sig_from_file = FileSignature.new.signature_from_file(pathname)
./moab-versioning/spec/unit_tests/moab/file_group_spec.rb:      expect(sig1).to receive(:signature_from_file).with(pathname)
./moab-versioning/spec/unit_tests/moab/file_manifestation_spec.rb:    title_v1_signature = Moab::FileSignature.new.signature_from_file(title_v1_pathname)
./moab-versioning/spec/unit_tests/moab/file_signature_spec.rb:  let(:title_v1_signature) { Moab::FileSignature.new.signature_from_file(title_v1_pathname) }
./moab-versioning/spec/unit_tests/moab/file_signature_spec.rb:    Moab::FileSignature.new.signature_from_file(title_v2_pathname)
./moab-versioning/spec/unit_tests/moab/file_signature_spec.rb:    Moab::FileSignature.new.signature_from_file(page1_v1_pathname)
./moab-versioning/spec/unit_tests/moab/file_signature_spec.rb:    Moab::FileSignature.new.signature_from_file(page1_v2_pathname)
./moab-versioning/spec/unit_tests/moab/file_signature_spec.rb:  specify '#signature_from_file' do

./preservation_catalog/app/services/checksum_validator.rb:    Moab::FileSignature.new.signature_from_file(Pathname(file))
software_dev_projects $ 
software_dev_projects $ 

what i have cloned:

  • DeveloperPlaybook
  • SearchWorks
  • archive-catalog
  • argo
  • blacklight
  • blacklight-hierarchy
  • blacklight_advanced_search
  • common-accessioning
  • dlss-wowza
  • docker-sdr
  • dor-fetcher-service
  • dor-rights-auth
  • dor-services
  • dor-services-app
  • dor-services-v4 (an old copy of the dor-services v4 branch)
  • dor-workflow-service
  • dor_indexing_app
  • druid-tools
  • etd_model
  • exhibits
  • gis-robot-suite
  • hydra-jetty
  • hydra_etd
  • item-release
  • library_hours_rails
  • moab-versioning
  • mods
  • osullivan
  • pre-assembly
  • preservation_catalog
  • preservation_robots
  • puppet
  • purl
  • purl-fetcher
  • sdr-preservation-core
  • spotlight
  • stacks
  • stanford-mods
  • sul-embed
  • sul-requests
  • sw-indexer
  • was-registrar
  • was-thumbnail-service
  • wasapi-downloader

@ndushay ndushay changed the title replace calls to deprecated FileSignature#signature_from_file with .from_file (CV) replace calls to deprecated FileSignature#signature_from_file with .from_file Apr 9, 2018
@ndushay ndushay added ready and removed backlog labels Apr 18, 2018
@ndushay ndushay added ready and removed backlog labels May 15, 2018
@ndushay ndushay added refactor architecture, refactoring, style, etc. backlog and removed ready labels May 22, 2018
@ndushay ndushay removed the backlog label May 11, 2022
@ndushay ndushay changed the title (CV) replace calls to deprecated FileSignature#signature_from_file with .from_file refactor: replace calls to deprecated FileSignature#signature_from_file with .from_file May 11, 2022
@ndushay
Copy link
Contributor

ndushay commented Aug 15, 2022

Currently, externally to this gem, it's a couple calls for digital_stacks_service in dor-services-app: https://github.com/search?q=org%3Asul-dlss+signature_from_file&type=code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor architecture, refactoring, style, etc. tech debt
Projects
None yet
Development

No branches or pull requests

2 participants