class MultiMovingsign::Cli

Command line interface to MultiMovingsign

Public Instance Methods

settings() click to toggle source
# File lib/multi_movingsign/cli.rb, line 24
def settings
  settings = Settings.load settings_path

  puts "Signs (#{settings.signs.length}): #{settings.signs.map { |s| s.path }.join(' ')}"
end
setup() click to toggle source
# File lib/multi_movingsign/cli.rb, line 14
def setup
  if signs = options[:signs]
    settings = Settings.load settings_path
    settings.sign_paths = signs

    settings.dump settings_path
  end
end
show_identity() click to toggle source
# File lib/multi_movingsign/cli.rb, line 31
def show_identity
  TestRCLoader.load(options['testrc']) if options['testrc']

  settings = Settings.load settings_path

  # validate we have signs
  raise_no_signs unless settings.signs?

  signs = Signs.new settings.signs

  signs.show_identity
end
show_page() click to toggle source
# File lib/multi_movingsign/cli.rb, line 46
def show_page
  TestRCLoader.load(options['testrc']) if options['testrc']

  settings = Settings.load settings_path
  raise_no_signs unless settings.signs?

  signs = settings.signs

  page = YAML.load(File.read(options[:page]))

  renderer = PageRenderer.new
  solution = renderer.render(page, :count => signs.length)

  threads = []
  solution['signs'].each_with_index do |hash, i|
    threads << Thread.new do
      signs[i].show_text hash['content'], :display_pause => 3
    end
  end
  threads.each { |t| t.join }
end

Private Instance Methods

raise_no_signs() click to toggle source
# File lib/multi_movingsign/cli.rb, line 77
def raise_no_signs
  raise InvalidInputError, "No signs specified.  Please run setup with the --signs option."
end
settings_path() click to toggle source
# File lib/multi_movingsign/cli.rb, line 73
def settings_path
  options[:rc] || Settings.default_settings_path
end