Class: Kiba::Extend::Registry::FileRegistry
- Inherits:
-
Object
- Object
- Kiba::Extend::Registry::FileRegistry
- Includes:
- Dry::Container::Mixin
- Defined in:
- lib/kiba/extend/registry/file_registry.rb
Overview
Transforms a file_registry hash into an object that can return source, lookup, or destination config for that file, for passing to jobs
An example of a file registry setup in a project can be found at: https://github.com/lyrasis/fwm-cspace-migration/blob/main/lib/fwm/registry_data.rb
Defined Under Namespace
Classes: KeyNotRegisteredError
Instance Method Summary collapse
-
#as_destination(filekey, for_job) ⇒ Kiba::Extend::Registry::RegisteredDestination
-
#as_lookup(filekey, for_job) ⇒ Kiba::Extend::Registry::RegisteredLookup
-
#as_source(filekey, for_job) ⇒ Kiba::Extend::Registry::RegisteredSource
-
#entries ⇒ Object
-
#finalize ⇒ Object
Convenience method combining the steps of transforming initial registry entry hashes into FileRegistryEntry objects, and then making the registry immutable for the rest of the application’s run.
-
#transform ⇒ Object
Transforms registered file hashes into FileRegistryEntry objects.
-
#valid? ⇒ Boolean
-
#warnings? ⇒ Boolean
Instance Method Details
#as_destination(filekey, for_job) ⇒ Kiba::Extend::Registry::RegisteredDestination
45 46 47 48 49 50 51 52 53 |
# File 'lib/kiba/extend/registry/file_registry.rb', line 45 def as_destination(filekey, for_job) RegisteredDestination.new( key: filekey, data: lookup(filekey), for_job: for_job ) rescue KeyNotRegisteredError => err raise KeyNotRegisteredError.new(err.key, :destination) end |
#as_lookup(filekey, for_job) ⇒ Kiba::Extend::Registry::RegisteredLookup
58 59 60 61 62 63 64 65 66 |
# File 'lib/kiba/extend/registry/file_registry.rb', line 58 def as_lookup(filekey, for_job) RegisteredLookup.new( key: filekey, data: lookup(filekey), for_job: for_job ) rescue KeyNotRegisteredError => err raise KeyNotRegisteredError.new(err.key, :lookup) end |
#as_source(filekey, for_job) ⇒ Kiba::Extend::Registry::RegisteredSource
71 72 73 74 75 76 77 78 79 |
# File 'lib/kiba/extend/registry/file_registry.rb', line 71 def as_source(filekey, for_job) RegisteredSource.new( key: filekey, data: lookup(filekey), for_job: for_job ) rescue KeyNotRegisteredError => err raise KeyNotRegisteredError.new(err.key, :source) end |
#entries ⇒ Object
82 83 84 |
# File 'lib/kiba/extend/registry/file_registry.rb', line 82 def entries @entries ||= populate_entries end |
#finalize ⇒ Object
Convenience method combining the steps of transforming
initial registry entry hashes into FileRegistryEntry
objects, and then making the registry immutable for the
rest of the application’s run. :freeze
is from
dry-container.
91 92 93 94 |
# File 'lib/kiba/extend/registry/file_registry.rb', line 91 def finalize transform freeze end |
#transform ⇒ Object
Transforms registered file hashes into Kiba::Extend::Registry::FileRegistryEntry objects
98 99 100 101 102 103 |
# File 'lib/kiba/extend/registry/file_registry.rb', line 98 def transform each { |key, val| decorate(key) { FileRegistryEntry.new(val) } } @entries = populate_entries each { |key, val| val.set_key(key) } verify_paths end |
#valid? ⇒ Boolean
105 106 107 |
# File 'lib/kiba/extend/registry/file_registry.rb', line 105 def valid? validator.valid? end |
#warnings? ⇒ Boolean
109 110 111 |
# File 'lib/kiba/extend/registry/file_registry.rb', line 109 def warnings? validator.warnings? end |