Class: Railbow::Demo::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/railbow/demo/runner.rb

Constant Summary collapse

SUBCOMMANDS =
%w[status migrate routes all].freeze

Class Method Summary collapse

Class Method Details

.run(subcommand = "status") ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/railbow/demo/runner.rb', line 11

def self.run(subcommand = "status")
  subcommand = subcommand.to_s.downcase
  unless SUBCOMMANDS.include?(subcommand)
    warn "Unknown demo: #{subcommand}"
    warn "Available: #{SUBCOMMANDS.join(", ")}"
    exit 1
  end

  Railbow.
  puts

  if subcommand == "all"
    run_all
  else
    run_one(subcommand)
  end
end

.run_allObject



43
44
45
46
47
48
# File 'lib/railbow/demo/runner.rb', line 43

def self.run_all
  %w[status migrate routes].each do |sub|
    puts "\n\e[1m\e[36m── railbow demo #{sub} ──\e[0m\n"
    run_one(sub)
  end
end

.run_one(subcommand) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/railbow/demo/runner.rb', line 29

def self.run_one(subcommand)
  case subcommand
  when "status"
    require_relative "status_demo"
    StatusDemo.run
  when "migrate"
    require_relative "migrate_demo"
    MigrateDemo.run
  when "routes"
    require_relative "routes_demo"
    RoutesDemo.run
  end
end