Class: Broker::CLI
- Inherits:
-
Thor
- Object
- Thor
- Broker::CLI
- Includes:
- Thor::Actions
- Defined in:
- lib/broker/cli.rb
Class Method Summary collapse
Instance Method Summary collapse
- #inject_initializer ⇒ Object
- #inject_secrets ⇒ Object
- #inject_tables ⇒ Object
- #install ⇒ Object
- #queue ⇒ Object
- #start ⇒ Object
- #welcome ⇒ Object
Class Method Details
.source_root ⇒ Object
7 8 9 |
# File 'lib/broker/cli.rb', line 7 def self.source_root File.dirname(__FILE__) + "/templates" end |
Instance Method Details
#inject_initializer ⇒ Object
66 67 68 69 |
# File 'lib/broker/cli.rb', line 66 def inject_initializer puts 'add initializer for broker configuration' copy_file "broker.rb", "config/initializers/broker.rb" end |
#inject_secrets ⇒ Object
72 73 74 75 |
# File 'lib/broker/cli.rb', line 72 def inject_secrets puts 'add secrets yaml for broker authentication environment variables' copy_file "secrets.yml", "config/secrets.yml" end |
#inject_tables ⇒ Object
78 79 80 81 |
# File 'lib/broker/cli.rb', line 78 def inject_tables puts 'add broker_tables for setting up table mappings' copy_file "quickbase_tables.yml", "config/quickbase_tables.yml" end |
#install ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/broker/cli.rb', line 12 def install require 'broker' unless already_installed? inject_initializer inject_secrets inject_tables welcome else say "Broker is already Installed/Setup!" end end |
#queue ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/broker/cli.rb', line 40 def queue require 'broker' empty_dir = !Dir.exists?(Broker.[:queue]) if [:create] && empty_dir FileUtils.mkdir Broker.[:queue] FileUtils.mkdir Broker.[:processed_path] say "Your Q has been created at:" puts "#{Broker.[:queue]}" end if [:update] && !empty_dir base_path = "#{Broker.[:queue]}" roots = Broker.table_keys tables = [] make_tree(base_path, roots) Broker.tables.each do |key, val| tables = val['tables'].keys make_tree("#{base_path}/#{key}", tables) end end end |
#start ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/broker/cli.rb', line 94 def start require 'broker' if [:standalone] io_read, io_write = IO.pipe %w(INT TERM USR1 USR2 TTIN).each do |sig| begin Signal.trap(sig) do io_write.puts(sig) end rescue ArgumentError puts "Signal #{sig} not valid" end end require 'broker/launcher' @launcher = Broker::Launcher.new begin puts "launched with PID #{Process.pid}" @launcher.run while readable_io = IO.select([io_read]) signal = readable_io.first[0].gets.strip catch_signal(signal) end rescue Interrupt puts "Shutting down" @launcher.stop exit(0) end elsif [:web] puts "web service not implemented yet" end end |
#welcome ⇒ Object
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/broker/cli.rb', line 135 def welcome say "" say "" say "" say "*************************************************" say "*************************************************" say "Broker Successfully Installed!" say "*************************************************" say "" say "Default Config files created for you" say "" say "You can change the config paths in:" say "config/initializers/broker.rb" say "" say "1. Enter your Quickbase credentials in:" say "/config/secrets.yml" say "" say "2. Set up your Table Mappings in:" say "/config/quickbase_tables.yml" say "" say "*************************************************" say "" say "Create your Broker Q by running:" say "" say "$ broker queue -c" say "" say "Populate your Broker Q by running:" say "" say "$ broker queue -u" say "" say "Boot Broker" say "" say "$ broker start -s" say "" end |