class DTK::Client::ServiceAndComponentInfo::TransformFrom::Info
Attributes
input_file_paths[R]
Public Class Methods
create(info_type, content_dir, dtk_dsl_parse_helper)
click to toggle source
# File lib/client/service_and_component_info/transform_from/info.rb, line 36 def self.create(info_type, content_dir, dtk_dsl_parse_helper) case info_type when :service_info then Service.new(content_dir, dtk_dsl_parse_helper) when :component_info then Component.new(content_dir, dtk_dsl_parse_helper) else fail Error, "Unexpected info_type '#{info_type}'" end end
new(content_dir, dtk_dsl_parse_helper)
click to toggle source
# File lib/client/service_and_component_info/transform_from/info.rb, line 26 def initialize(content_dir, dtk_dsl_parse_helper) @content_dir = content_dir @dtk_dsl_info_processor = dtk_dsl_parse_helper.info_processor(info_type) # dynamically computed @input_file_paths = [] @directory_file_paths = nil # this will be all paths in module end
Private Instance Methods
add_content!(input_files_processor, path)
click to toggle source
# File lib/client/service_and_component_info/transform_from/info.rb, line 47 def add_content!(input_files_processor, path) @input_file_paths << path input_files_processor.add_content!(path, get_raw_content?(path)) end
directory_file_paths()
click to toggle source
# File lib/client/service_and_component_info/transform_from/info.rb, line 84 def directory_file_paths @directory_file_paths ||= Dir.glob("#{@content_dir}/**/*") end
dsl_file_matches(&block)
click to toggle source
# File lib/client/service_and_component_info/transform_from/info.rb, line 62 def dsl_file_matches(&block) # TODO: maybe better to solve by restricting directory_file_paths to be least_nested_pos of 2 matches = directory_file_paths.select { |path| block.call(path) } if matches.size > 1 least_nested_pos = matches.map { |match| match.split('/').size }.min matches.reject! { |match| match.split('/').size != least_nested_pos } end matches end
get_raw_content?(file_path)
click to toggle source
# File lib/client/service_and_component_info/transform_from/info.rb, line 76 def get_raw_content?(file_path) File.open(file_path).read if file_path and File.exists?(file_path) end
input_files_processor(type)
click to toggle source
# File lib/client/service_and_component_info/transform_from/info.rb, line 52 def input_files_processor(type) @dtk_dsl_info_processor.indexed_input_files[type] || raise_missing_type_error(type) end
module_ref_input_files_processor()
click to toggle source
# File lib/client/service_and_component_info/transform_from/info.rb, line 72 def module_ref_input_files_processor @module_ref_input_files_processor ||= input_files_processor(:module_refs) end
module_refs_path()
click to toggle source
# File lib/client/service_and_component_info/transform_from/info.rb, line 56 def module_refs_path matches = dsl_file_matches { |path| module_ref_input_files_processor.match?(path) } raise Error, "Unexpected that multiple module ref files" if matches.size > 1 matches.first end
raise_missing_type_error(type)
click to toggle source
# File lib/client/service_and_component_info/transform_from/info.rb, line 80 def raise_missing_type_error(type) raise Error, "Unexpected that no indexed_input_files of type '#{type}'" end