Class: Dataloaderb::ProcessDefinition
- Inherits:
-
Object
- Object
- Dataloaderb::ProcessDefinition
- Defined in:
- lib/dataloaderb/process_definition.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#entries ⇒ Object
readonly
Returns the value of attribute entries.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Instance Method Summary collapse
- #get(key) ⇒ Object
-
#initialize(yaml, merge = nil) ⇒ ProcessDefinition
constructor
Create a new instance of a ConfCreator.
-
#load_yaml(yaml_file, merge = nil) ⇒ Object
Load a process definition from a Yaml file.
- #set(key, value) ⇒ Object
Constructor Details
#initialize(yaml, merge = nil) ⇒ ProcessDefinition
Create a new instance of a ConfCreator
9 10 11 12 13 14 |
# File 'lib/dataloaderb/process_definition.rb', line 9 def initialize(yaml, merge = nil) @id = '' @description = '' @entries = {} load_yaml(yaml, merge) end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
5 6 7 |
# File 'lib/dataloaderb/process_definition.rb', line 5 def description @description end |
#entries ⇒ Object (readonly)
Returns the value of attribute entries.
6 7 8 |
# File 'lib/dataloaderb/process_definition.rb', line 6 def entries @entries end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/dataloaderb/process_definition.rb', line 4 def id @id end |
Instance Method Details
#get(key) ⇒ Object
20 21 22 |
# File 'lib/dataloaderb/process_definition.rb', line 20 def get(key) @entries[key] end |
#load_yaml(yaml_file, merge = nil) ⇒ Object
Load a process definition from a Yaml file
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/dataloaderb/process_definition.rb', line 25 def load_yaml(yaml_file, merge = nil) raise ArgumentError, "Cannot find file #{yaml_file}" unless File.exist?(yaml_file) raise ArgumentError, "Cannot find file #{merge}" unless merge.nil? || File.exist?(merge) unless merge.nil? merge_data = YAML.load_file(merge) merge_data.each do |key, value| self.set(key, value) end end proc = YAML.load_file(yaml_file) @id = proc['id'] @description = proc['description'] proc['properties'].each do |key, value| self.set(key, value) end end |
#set(key, value) ⇒ Object
16 17 18 |
# File 'lib/dataloaderb/process_definition.rb', line 16 def set(key, value) @entries[key] = value end |