Module: CuffUp
- Defined in:
- lib/cuffup.rb
Class Method Summary collapse
- .dump(args, input, output) ⇒ Object
- .parameters(io) ⇒ Object
- .parse_cli_args(argv) ⇒ Object
- .run(args, input, output) ⇒ Object
Class Method Details
.dump(args, input, output) ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/cuffup.rb', line 31 def self.dump(args, input, output) result = { 'Format' => 'v1', } result['Parameters'] = input if input.size > 0 result['Suffix'] = args[:selector].join('-') if args.include?(:selector) YAML.dump(result, output) end |
.parameters(io) ⇒ Object
26 27 28 29 |
# File 'lib/cuffup.rb', line 26 def self.parameters(io) CuffBase.defaults_from_template(io) .map {|k, v| {'Name' => k, 'Value' => v} } end |
.parse_cli_args(argv) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/cuffup.rb', line 5 def self.parse_cli_args(argv) args = { :output => '/dev/stdout' } parser = OptionParser.new do |opts| opts. = 'Output CuffSert-formatted metadata defaults based on a stack template.' opts.separator('') opts.separator('Usage: cuffup <template.json>') opts.on('--output metadata', '-o metadata', 'File to write metadata file to; defaults to stdout') do |f| args[:output] = f end opts.on('--selector selector', '-s selector', 'Set as sufflx in the generated output') do |selector| args[:selector] = selector.split(/[-,\/]/) end end args[:template] = parser.parse(argv) args end |
.run(args, input, output) ⇒ Object
40 41 42 |
# File 'lib/cuffup.rb', line 40 def self.run(args, input, output) self.dump(args, self.parameters(input), output) end |