Class: DtkCommon::DSL::FileParser::ComponentModuleRefs::V1
- Inherits:
-
DtkCommon::DSL::FileParser::ComponentModuleRefs
- Object
- DtkCommon::DSL::FileParser
- DtkCommon::DSL::FileParser::ComponentModuleRefs
- DtkCommon::DSL::FileParser::ComponentModuleRefs::V1
- Defined in:
- lib/dsl/file_parser/file_types/component_module_refs/v1/component_module_refs.rb
Constant Summary collapse
- OutputArrayToParseHashCols =
[{:version_info => :version},:remote_namespace]
Instance Method Summary collapse
Methods inherited from DtkCommon::DSL::FileParser
generate_hash, implements_method?, #initialize, parse_content, #parse_hash_content_aux
Constructor Details
This class inherits a constructor from DtkCommon::DSL::FileParser
Instance Method Details
#generate_hash(output_array) ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/dsl/file_parser/file_types/component_module_refs/v1/component_module_refs.rb', line 33 def generate_hash(output_array) component_modules = output_array.inject(Hash.new) do |h,r| unless cmp_module = r[:component_module] raise Error.new("Missing field (:component_module)") end h.merge(cmp_module => Aux.hash_subset(r,OutputArrayToParseHashCols,:no_non_nil => true)) end {:component_modules => component_modules} end |
#parse_hash_content(input_hash) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/dsl/file_parser/file_types/component_module_refs/v1/component_module_refs.rb', line 4 def parse_hash_content(input_hash) ret = OutputArray.new component_modules = input_hash[:component_modules] if component_modules.empty? return ret end component_modules.each do |component_module,v| new_el = OutputHash.new(:component_module => component_module) parse_error = true if v.kind_of?(InputHash) and v.only_has_keys?(:version,:remote_namespace,:namespace) and not v.empty?() parse_error = false new_el.merge_non_empty!(:version_info => v[:version], :remote_namespace => v[:remote_namespace]||v[:namespace]) elsif v.kind_of?(String) parse_error = false new_el.merge_non_empty!(:version_info => v) elsif v.nil? parse_error = false end if parse_error err_msg = (parse_error.kind_of?(String) ? parse_error : "Ill-formed term (#{v.inspect})") raise ErrorUsage::DTKParse.new(err_msg) else ret << new_el end end ret end |