Class: Nchosts::Command
- Inherits:
-
Thor
- Object
- Thor
- Nchosts::Command
- Defined in:
- lib/nchosts/command.rb
Instance Method Summary collapse
Instance Method Details
#collect ⇒ Object
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([:config]) json['accounts'].each do |account| collector = Nchosts::Collector.new(account) collector.collect do |region, instance| instance['region'] = region instance['account'] = account instances << instance end end File.write [:output_path], instances.to_json end |
#generate ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/nchosts/command.rb', line 32 def generate if [:format] template = template([:format]) elsif [:template] template = File.read([:template]) else abort "Please specify :format or :template" end instances = JSON.parse File.read [:input_path] puts Erubis::Eruby.new(template).result(:instances => instances) end |
#version ⇒ Object
4 5 6 |
# File 'lib/nchosts/command.rb', line 4 def version puts "v#{Nchosts::VERSION}" end |