Class: Kiba::Extend::Registry::FileRegistryEntry
- Inherits:
-
Object
- Object
- Kiba::Extend::Registry::FileRegistryEntry
- Defined in:
- lib/kiba/extend/registry/file_registry_entry.rb
Overview
Captures the data about an entry in the file registry
This is the underlying data that can be used to derive a registered source, destination, or lookup file object.
Used instead of just passing around a Hash so that it can validate itself and carry its own errors/warnings
Constant Summary collapse
- TYPES =
allowed types
:file, :fileset, :enum, :lambda
Instance Attribute Summary collapse
-
#creator ⇒ Object
readonly
-
#desc ⇒ Object
readonly
-
#dest_class ⇒ Object
readonly
-
#dest_opt ⇒ Object
readonly
-
#dest_special_opts ⇒ Object
readonly
-
#errors ⇒ Object
readonly
-
#key ⇒ Object
readonly
-
#lookup_on ⇒ Object
readonly
-
#message ⇒ Object
readonly
-
#path ⇒ Object
readonly
-
#src_class ⇒ Object
readonly
-
#src_opt ⇒ Object
readonly
-
#supplied ⇒ Object
readonly
-
#tags ⇒ Object
readonly
-
#type ⇒ Object
readonly
-
#valid ⇒ Object
readonly
-
#warnings ⇒ Object
readonly
Instance Method Summary collapse
-
#dir ⇒ Object
-
#initialize(reghash) ⇒ FileRegistryEntry
constructor
A new instance of FileRegistryEntry.
-
#set_key(key) ⇒ Object
Used by FileRegistry.transform to add the key as an instance variable to each Entry.
-
#summary ⇒ Object
Printable string summarizing the Entry.
-
#summary_creator ⇒ Object
-
#summary_first_line ⇒ Object
-
#summary_padding ⇒ Object
-
#valid? ⇒ Boolean
Whether the Entry is valid.
Constructor Details
#initialize(reghash) ⇒ FileRegistryEntry
Returns a new instance of FileRegistryEntry.
26 27 28 29 30 |
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 26 def initialize(reghash) set_defaults assign_values_from(reghash) validate end |
Instance Attribute Details
#creator ⇒ Object (readonly)
16 17 18 |
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 16 def creator @creator end |
#desc ⇒ Object (readonly)
16 17 18 |
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 16 def desc @desc end |
#dest_class ⇒ Object (readonly)
16 17 18 |
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 16 def dest_class @dest_class end |
#dest_opt ⇒ Object (readonly)
16 17 18 |
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 16 def dest_opt @dest_opt end |
#dest_special_opts ⇒ Object (readonly)
16 17 18 |
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 16 def dest_special_opts @dest_special_opts end |
#errors ⇒ Object (readonly)
16 17 18 |
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 16 def errors @errors end |
#key ⇒ Object (readonly)
16 17 18 |
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 16 def key @key end |
#lookup_on ⇒ Object (readonly)
16 17 18 |
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 16 def lookup_on @lookup_on end |
#message ⇒ Object (readonly)
16 17 18 |
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 16 def @message end |
#path ⇒ Object (readonly)
16 17 18 |
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 16 def path @path end |
#src_class ⇒ Object (readonly)
16 17 18 |
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 16 def src_class @src_class end |
#src_opt ⇒ Object (readonly)
16 17 18 |
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 16 def src_opt @src_opt end |
#supplied ⇒ Object (readonly)
16 17 18 |
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 16 def supplied @supplied end |
#tags ⇒ Object (readonly)
16 17 18 |
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 16 def @tags end |
#type ⇒ Object (readonly)
16 17 18 |
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 16 def type @type end |
#valid ⇒ Object (readonly)
16 17 18 |
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 16 def valid @valid end |
#warnings ⇒ Object (readonly)
16 17 18 |
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 16 def warnings @warnings end |
Instance Method Details
#dir ⇒ Object
32 33 34 |
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 32 def dir path.dirname end |
#set_key(key) ⇒ Object
Used by FileRegistry.transform to add the key as an instance variable to each Entry
37 38 39 |
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 37 def set_key(key) @key = key end |
#summary ⇒ Object
Printable string summarizing the Entry
Called by project applications
44 45 46 47 48 49 50 51 52 |
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 44 def summary lines = [summary_first_line] lines << "#{summary_padding}#{desc}" unless desc.blank? lines << "#{summary_padding}File path: #{path}" if path lines << summary_creator if creator lines << "#{summary_padding}Lookup on: #{lookup_on}" if lookup_on lines << "\n" lines.join("\n") end |
#summary_creator ⇒ Object
60 61 62 63 64 65 66 |
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 60 def summary_creator lines = [] arr = creator.to_s.delete_prefix("#<Method: ").delete_suffix(">").split(" ") lines << "Job method: #{arr[0]}" lines << "Job defined at: #{arr[1]}" lines.map { |line| "#{summary_padding}#{line}" }.join("\n") end |
#summary_first_line ⇒ Object
54 55 56 57 58 |
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 54 def summary_first_line return key.to_s if .blank? "#{key} -- tags: #{.join(", ")}" end |
#summary_padding ⇒ Object
68 69 70 |
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 68 def summary_padding " " end |
#valid? ⇒ Boolean
Whether the Entry is valid
74 75 76 |
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 74 def valid? valid end |