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(key, reghash) ⇒ FileRegistryEntry

Returns a new instance of FileRegistryEntry.

Parameters:

Since:

  • 2.2.0



25
26
27
28
29
30
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 25

def initialize(key, reghash)
  @key = key
  set_defaults
  assign_values_from(reghash)
  validate
end

Instance Attribute Details

#creatorObject (readonly)

Since:

  • 2.2.0



14
15
16
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 14

def creator
  @creator
end

#descObject (readonly)

Since:

  • 2.2.0



14
15
16
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 14

def desc
  @desc
end

#dest_classObject (readonly)

Since:

  • 2.2.0



14
15
16
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 14

def dest_class
  @dest_class
end

#dest_optObject (readonly)

Since:

  • 2.2.0



14
15
16
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 14

def dest_opt
  @dest_opt
end

#dest_special_optsObject (readonly)

Since:

  • 2.2.0



14
15
16
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 14

def dest_special_opts
  @dest_special_opts
end

#errorsObject (readonly)

Since:

  • 2.2.0



14
15
16
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 14

def errors
  @errors
end

#keyObject (readonly)

Since:

  • 2.2.0



14
15
16
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 14

def key
  @key
end

#lookup_onObject (readonly)

Since:

  • 2.2.0



14
15
16
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 14

def lookup_on
  @lookup_on
end

#messageObject (readonly)

Since:

  • 2.2.0



14
15
16
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 14

def message
  @message
end

#pathObject (readonly)

Since:

  • 2.2.0



14
15
16
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 14

def path
  @path
end

#src_classObject (readonly)

Since:

  • 2.2.0



14
15
16
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 14

def src_class
  @src_class
end

#src_optObject (readonly)

Since:

  • 2.2.0



14
15
16
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 14

def src_opt
  @src_opt
end

#suppliedObject (readonly)

Since:

  • 2.2.0



14
15
16
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 14

def supplied
  @supplied
end

#tagsObject (readonly)

Since:

  • 2.2.0



14
15
16
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 14

def tags
  @tags
end

#typeObject (readonly)

Since:

  • 2.2.0



14
15
16
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 14

def type
  @type
end

#validObject (readonly)

Since:

  • 2.2.0



14
15
16
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 14

def valid
  @valid
end

#warningsObject (readonly)

Since:

  • 2.2.0



14
15
16
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 14

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

#summaryObject

Printable string summarizing the Entry, called by project applications

Since:

  • 2.2.0



37
38
39
40
41
42
43
44
45
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 37

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



53
54
55
56
57
58
59
60
61
62
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 53

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



47
48
49
50
51
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 47

def summary_first_line
  return key.to_s if tags.blank?

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

#summary_paddingObject

Since:

  • 2.2.0



64
65
66
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 64

def summary_padding
  "    "
end

#valid?Boolean

Whether the Entry is valid

Returns:

  • (Boolean)

Since:

  • 2.2.0



70
71
72
# File 'lib/kiba/extend/registry/file_registry_entry.rb', line 70

def valid?
  valid
end