Class: Nchosts::Command

Inherits:
Thor
  • Object
show all
Defined in:
lib/nchosts/command.rb

Instance Method Summary collapse

Instance Method Details

#collectObject



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/nchosts/command.rb', line 11

def collect
  instances = []
  json = JSON.parse File.read(options[:config])
  json['accounts'].each do ||
    collector = Nchosts::Collector.new()
    collector.collect do |region, instance|
      instance['region'] = region
      instance['account'] = 
      instances << instance
    end
  end
  File.write options[:output_path], instances.to_json
end

#generateObject



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/nchosts/command.rb', line 32

def generate
  if options[:format]
    template = template(options[:format])
  elsif options[:template]
    template = File.read(options[:template])
  else
    abort "Please specify :format or :template"
  end
  instances = JSON.parse File.read options[:input_path]
  puts Erubis::Eruby.new(template).result(:instances => instances)
end

#versionObject



4
5
6
# File 'lib/nchosts/command.rb', line 4

def version
  puts "v#{Nchosts::VERSION}"
end