class Rollio::CLI

Public Class Methods

new(*args) click to toggle source
Calls superclass method
# File lib/rollio/cli.rb, line 12
def initialize(*args)
  super
  register!
end

Public Instance Methods

audit() click to toggle source
# File lib/rollio/cli.rb, line 34
def audit
end
list() click to toggle source
# File lib/rollio/cli.rb, line 27
def list
  help(__method__) and return if options[:help]
  $stdout.puts @registry.table_names.join(options.fetch(:delimiter, "\n"))
end
render() click to toggle source
# File lib/rollio/cli.rb, line 60
def render
  help(__method__) and return if options[:help]
  $stdout.puts @registry.render
end
roll(table) click to toggle source
# File lib/rollio/cli.rb, line 44
def roll(table)
  if options[:help]
    help(__method__)
    if table
      puts "\nSee the \"#{table}\" below\n\n"
      @registry.render(table: table)
    end
    return
  end
  args = [table]
  args << { with: options[:with] } if options.key?(:with)
  $stdout.puts @registry.roll_on(*args)
end

Private Instance Methods

register!() click to toggle source
# File lib/rollio/cli.rb, line 67
def register!
  @registry = Rollio.load
  Dir.glob("#{options[:source]}/**/*.json").each do |filename|
    tables = JSON.parse(File.read(filename))
    tables = [tables] unless tables.is_a?(Array)
    tables.each do |table|
      data = Hanami::Utils::Hash.deep_symbolize(table)
      Rollio.load_a_table(registry: @registry, data: data)
    end
  end
end