Class: Mantra::Commands::Find

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

Instance Attribute Summary

Attributes inherited from Mantra::Command

#options

Instance Method Summary collapse

Methods inherited from Mantra::Command

#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 Method Details

#performObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/mantra/commands/find.rb', line 14

def perform
  m = Manifest.new(manifest)
  results = m.select(scope)

  results = results.map do |element|
    element.parent
  end if with_parent

  results = results.map do |element|
    element.to_ruby_object
  end

  case format
  when "yaml", "yml", "y", nil
    puts results.to_yaml
  when "json", "j"
    puts JSON.pretty_generate(results)
  else
    raise "unknown format"
  end
end