Class: Kiba::Extend::Registry::FileRegistryEntry

Inherits:
Object
  • Object
show all
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

Since:

  • 2.2.0

Constant Summary collapse

TYPES =

allowed types

Since:

  • 2.2.0

:file, :fileset, :enum, :lambda

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(reghash) ⇒ FileRegistryEntry

Returns a new instance of FileRegistryEntry.

Parameters:

Since:

  • 2.2.0



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

#creatorObject (readonly)

Since:

  • 2.2.0



16
17
18
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 16

def creator
  @creator
end

#descObject (readonly)

Since:

  • 2.2.0



16
17
18
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 16

def desc
  @desc
end

#dest_classObject (readonly)

Since:

  • 2.2.0



16
17
18
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 16

def dest_class
  @dest_class
end

#dest_optObject (readonly)

Since:

  • 2.2.0



16
17
18
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 16

def dest_opt
  @dest_opt
end

#dest_special_optsObject (readonly)

Since:

  • 2.2.0



16
17
18
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 16

def dest_special_opts
  @dest_special_opts
end

#errorsObject (readonly)

Since:

  • 2.2.0



16
17
18
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 16

def errors
  @errors
end

#keyObject (readonly)

Since:

  • 2.2.0



16
17
18
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 16

def key
  @key
end

#lookup_onObject (readonly)

Since:

  • 2.2.0



16
17
18
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 16

def lookup_on
  @lookup_on
end

#messageObject (readonly)

Since:

  • 2.2.0



16
17
18
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 16

def message
  @message
end

#pathObject (readonly)

Since:

  • 2.2.0



16
17
18
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 16

def path
  @path
end

#src_classObject (readonly)

Since:

  • 2.2.0



16
17
18
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 16

def src_class
  @src_class
end

#src_optObject (readonly)

Since:

  • 2.2.0



16
17
18
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 16

def src_opt
  @src_opt
end

#suppliedObject (readonly)

Since:

  • 2.2.0



16
17
18
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 16

def supplied
  @supplied
end

#tagsObject (readonly)

Since:

  • 2.2.0



16
17
18
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 16

def tags
  @tags
end

#typeObject (readonly)

Since:

  • 2.2.0



16
17
18
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 16

def type
  @type
end

#validObject (readonly)

Since:

  • 2.2.0



16
17
18
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 16

def valid
  @valid
end

#warningsObject (readonly)

Since:

  • 2.2.0



16
17
18
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 16

def warnings
  @warnings
end

Instance Method Details

#dirObject

Since:

  • 2.2.0



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

Since:

  • 2.2.0



37
38
39
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 37

def set_key(key)
  @key = key
end

#summaryObject

Printable string summarizing the Entry

Called by project applications

Since:

  • 2.2.0



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_creatorObject

Since:

  • 2.2.0



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_lineObject

Since:

  • 2.2.0



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 tags.blank?

  "#{key} -- tags: #{tags.join(", ")}"
end

#summary_paddingObject

Since:

  • 2.2.0



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

Returns:

  • (Boolean)

Since:

  • 2.2.0



74
75
76
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 74

def valid?
  valid
end