Class: Mantra::Transform::TemplatizeValue
Instance Method Summary
collapse
#to_regexp
description, #ensure_yml_file_exist, input, inputs, #merge_tool, #previous_transform, #raise_error_if_no_source_manifest, #run, #source_manifest, #target_manifest, #validate_inputs
included
Instance Method Details
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/mantra/transform/templatize_value.rb', line 31
def perform
raise_error_if_no_source_manifest
ensure_yml_file_exist(self.target)
raise "scope must not match value wildcard" if scope.match(value)
source_manifest.traverse do |node|
if node.content.to_s.match(value)
match = node.content.to_s.match(value)[0]
begin_index = node.content.to_s.index(match)
end_index = begin_index + match.size
final_value = merge_tool.templatize(node.content.to_s, scope, begin_index, end_index)
node.content = final_value
scope_element = Manifest::Element.element_with_selector(scope, value)
target_manifest.merge(scope_element)
end
end
source_manifest.save
target_manifest.save
end
|
#raise_if_no_source_manifest ⇒ Object
55
56
57
58
59
|
# File 'lib/mantra/transform/templatize_value.rb', line 55
def raise_if_no_source_manifest
if self.source.nil? || !File.exist?(self.source)
raise Manifest::FileNotFoundError.new("Source manifest does not exist: #{self.source.inspect}")
end
end
|