Class: MultiMovingsign::Cli

Inherits:
Thor
  • Object
show all
Defined in:
lib/multi_movingsign/cli.rb

Overview

Command line interface to MultiMovingsign

Instance Method Summary collapse

Instance Method Details

#settingsObject



24
25
26
27
28
# 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

#setupObject



14
15
16
17
18
19
20
21
# 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_identityObject



31
32
33
34
35
36
37
38
39
40
41
42
# 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_pageObject



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# 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