class Nchosts::Command
Public Instance Methods
collect()
click to toggle source
# File lib/nchosts/command.rb, line 11 def collect instances = [] json = JSON.parse File.read(options[: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 options[:output_path], instances.to_json end
generate()
click to toggle source
# 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
template(name)
click to toggle source
# File lib/nchosts/command.rb, line 45 def template(name) File.read File.join(File.dirname(__FILE__), "templates/#{name}.erb") end
version()
click to toggle source
# File lib/nchosts/command.rb, line 4 def version puts "v#{Nchosts::VERSION}" end