class Kojo::Commands::FileCmd

Handle calls to the +kojo file+ command

Attributes

import_base[R]
infile[R]
opts[R]
outfile[R]

Public Instance Methods

run() click to toggle source
# File lib/kojo/commands/file.rb, line 28
def run
  @opts = args['ARGS'].args_to_hash
  @outfile = args['--save']
  @infile = args['INFILE']
  @import_base = args['--imports']
  argfile = args['--args']

  if argfile
    fileopts = YAML.load_file(argfile).symbolize_keys
    @opts = fileopts.merge opts
  end

  run!
end

Private Instance Methods

run!() click to toggle source
# File lib/kojo/commands/file.rb, line 45
def run!
  template = Kojo::Template.new infile
  template.import_base = import_base if import_base
  output = template.render(opts)

  if outfile
    save outfile, output
  else
    puts output
  end
end