Class: Mantra::Commands::Transform

Inherits:
Mantra::Command show all
Defined in:
lib/mantra/commands/transform.rb

Instance Attribute Summary collapse

Attributes inherited from Mantra::Command

#options

Instance Method Summary collapse

Methods inherited from Mantra::Command

description, full_description, #initialize, option, option_descriptors, #parse_options, #run, usage

Methods included from Helpers::ObjectWithType

included

Constructor Details

This class inherits a constructor from Mantra::Command

Instance Attribute Details

#manifestObject

Returns the value of attribute manifest.



13
14
15
# File 'lib/mantra/commands/transform.rb', line 13

def manifest
  @manifest
end

Instance Method Details

#performObject



32
33
34
35
36
37
38
39
40
41
# File 'lib/mantra/commands/transform.rb', line 32

def perform
  transforms.each do |t|
    t.run
  end
  unless transforms.last.nil?
    puts transforms.last.result.to_ruby_object.to_yaml
  else
    puts {}.to_yaml
  end
end

#resultObject



28
29
30
# File 'lib/mantra/commands/transform.rb', line 28

def result
  @manifest ||= Manifest.new(self.manifest_path).root
end

#transform_configObject



15
16
17
# File 'lib/mantra/commands/transform.rb', line 15

def transform_config
  @transform_config ||= YAML.load_file(transform_config_path)
end

#transformsObject



19
20
21
22
23
24
25
26
# File 'lib/mantra/commands/transform.rb', line 19

def transforms
  return @transforms unless @transforms.nil?
  previous_transform = self
  @transforms = transform_config["transforms"].map do |options|
    options.merge!(previous_transform: previous_transform)
    previous_transform = Mantra::Transform.create(options)
  end
end