class DTK::DSL::ServiceAndComponentInfo::TransformFrom::Parser::TopDSL::Dependencies

Constants

NAMESPACE_NAME_DELIM

Public Instance Methods

update_output_hash?() click to toggle source
# File lib/dsl/service_and_component_info/transform_from/parser/top_dsl/dependencies.rb, line 22
def update_output_hash?
  module_refs_input_hash = input_file_hash?(:module_refs) || {}
  unless module_refs_input_hash.empty?
    existing_module_refs = output_hash['dependencies'] ||= {}
    merge_in_new_module_refs!(existing_module_refs, module_refs_input_hash)
  end
end

Private Instance Methods

combined_module_form(module_ref) click to toggle source
# File lib/dsl/service_and_component_info/transform_from/parser/top_dsl/dependencies.rb, line 56
def combined_module_form(module_ref)
  { "#{module_ref.namespace}#{NAMESPACE_NAME_DELIM}#{module_ref.module_name}" => module_ref.version }
end
component_module_refs(input_module_refs_hash) click to toggle source
# File lib/dsl/service_and_component_info/transform_from/parser/top_dsl/dependencies.rb, line 40
def component_module_refs(input_module_refs_hash)
  (input_module_refs_hash['component_modules'] || {}).inject([]) do |a, (name, info)|
    a + [ModuleRef.new(info['namespace'], name, info['version'])]
  end
end
conflict_error_msg(module_ref, matching_module_ref) click to toggle source
# File lib/dsl/service_and_component_info/transform_from/parser/top_dsl/dependencies.rb, line 67
def conflict_error_msg(module_ref, matching_module_ref)
  "Conflicting versions of module '#{module_ref.module_name}': '#{module_ref.print_form}' vs '#{matching_module_ref.print_form}'"
end
merge_in_new_module_refs!(module_refs_hash, input_module_refs_hash) click to toggle source
# File lib/dsl/service_and_component_info/transform_from/parser/top_dsl/dependencies.rb, line 32
def merge_in_new_module_refs!(module_refs_hash, input_module_refs_hash)
  ndx_existing_modules = ndx_existing_modules(module_refs_hash)
  component_module_refs(input_module_refs_hash).each do |module_ref|
    raise_error_if_conflict(module_ref, ndx_existing_modules)
    module_refs_hash.merge!(combined_module_form(module_ref))
  end
end
ndx_existing_modules(module_refs_hash) click to toggle source

indexed by module_name

# File lib/dsl/service_and_component_info/transform_from/parser/top_dsl/dependencies.rb, line 49
def ndx_existing_modules(module_refs_hash)
  module_refs_hash.inject({}) do |h, (namespace_name, version)|
    namespace, name = namespace_name.split(NAMESPACE_NAME_DELIM)
    h.merge(name => ModuleRef.new(namespace, name,  version))
  end
end
raise_error_if_conflict(module_ref, ndx_existing_modules) click to toggle source
# File lib/dsl/service_and_component_info/transform_from/parser/top_dsl/dependencies.rb, line 60
def raise_error_if_conflict(module_ref, ndx_existing_modules)
  if matching_module_ref = ndx_existing_modules[@module_name]
    fail Error::Usage, conflict_error_msg(module_ref, matching_module_ref) unless module_ref.match?(matching_module_ref)
  end
end