Class: Tbox::Add
- Inherits:
-
Thor
- Object
- Thor
- Tbox::Add
- Includes:
- Thor::Actions
- Defined in:
- lib/tb-cli/cli/add.rb
Overview
Class for adding components to your torquebox.yml
, queues.yml
or
topics.yml
file.
Instance Method Summary collapse
- #application ⇒ Object
- #auth ⇒ Object
- #environment ⇒ Object
- #help(meth = nil) ⇒ Object
- #job ⇒ Object
- #messaging ⇒ Object
- #pooling ⇒ Object
- #queue ⇒ Object
- #ruby ⇒ Object
- #service ⇒ Object
- #task ⇒ Object
- #topic ⇒ Object
- #web ⇒ Object
Instance Method Details
#application ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/tb-cli/cli/add.rb', line 20 def application y = ConfigFile.new destination_root if .root_loc || .env y.add_config('application', 'root', .root_loc) if .root_loc y.add_config('application', 'env', .env) if .env replace_yaml(y.yaml) else puts "You need to specify either --root-loc or --env" end end |
#auth ⇒ Object
210 211 212 213 214 |
# File 'lib/tb-cli/cli/add.rb', line 210 def auth y = ConfigFile.new destination_root y.add_config('auth', .auth_type, { "domain" => .domain }) replace_yaml(y.yaml) end |
#environment ⇒ Object
80 81 82 83 84 85 86 |
# File 'lib/tb-cli/cli/add.rb', line 80 def environment y = ConfigFile.new destination_root ..each_pair { |k,v| y.add_config('environment', k, v) } replace_yaml(y.yaml) end |
#help(meth = nil) ⇒ Object
240 241 242 243 |
# File 'lib/tb-cli/cli/add.rb', line 240 def help(meth=nil) puts INIT super end |
#job ⇒ Object
185 186 187 188 189 190 191 192 193 |
# File 'lib/tb-cli/cli/add.rb', line 185 def job y = ConfigFile.new destination_root opts = {} opts['job'] = .job_class opts['cron'] = .cron opts['description'] = .description if .description y.add_config('jobs', .job_name, opts) replace_yaml(y.yaml) end |
#messaging ⇒ Object
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/tb-cli/cli/add.rb', line 145 def messaging if .queue == nil && .topic == nil puts "You must specify either a topic or a queue you're configuring a handler for" else if .handler_class y = ConfigFile.new destination_root messaging = y.add_config["messaging"] || {} if .queue messaging[.queue] = .handler_class elsif .topic messaging[.topic] = .handler_class end y.add_config["messaging"] = messaging puts y.yaml replace_yaml(y.yaml) else puts "You must specify a --handler-class" end end end |
#pooling ⇒ Object
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 |
# File 'lib/tb-cli/cli/add.rb', line 222 def pooling y = ConfigFile.new destination_root thing = {} thing["pooling"] = {} if [ 'web', 'jobs', 'messaging', 'services' ].include? .subsystem if .bounded y.add_config('pooling', .subsystem, .bounded) elsif .shared y.add_config('pooling', .subsystem, 'shared') elsif .global y.add_config('pooling', .subsystem, 'global') end replace_yaml(y.yaml) else puts "subsystem must be one of: web, job, messaging, or services" end end |
#queue ⇒ Object
104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/tb-cli/cli/add.rb', line 104 def queue # TODO: Add external queues and hosts (see section 7.2.3.3 for details) file = 'queues.yml' y = ConfigFile.new destination_root, file if (.not_durable && .name) y.add_config("/queues/#{.name}", "durable: #{!.not_durable}") elsif (.name) y.add_config("/queues/#{.name}") end replace_yaml(y.yaml, file) end |
#ruby ⇒ Object
67 68 69 70 71 72 73 74 75 76 |
# File 'lib/tb-cli/cli/add.rb', line 67 def ruby y = ConfigFile.new destination_root if [ 1.8, 1.9 ].include? .version y.add_config('ruby', 'version', .version) end if [ 'jit', 'force', 'off' ].include? .compile_mode y.add_config('ruby', 'compile_mode', .compile_mode) end replace_yaml(y.yaml) end |
#service ⇒ Object
199 200 201 202 203 204 205 |
# File 'lib/tb-cli/cli/add.rb', line 199 def service y = ConfigFile.new destination_root opts = .params opts["singleton"] = true if .singleton y.add_config('services', .name, opts) replace_yaml(y.yaml) end |
#task ⇒ Object
169 170 171 172 173 174 175 176 177 |
# File 'lib/tb-cli/cli/add.rb', line 169 def task y = ConfigFile.new destination_root if .concurrency y.add_config('tasks', .name, { "concurrency" => .concurrency }) else y.add_config('tasks', .name) end replace_yaml(y.yaml) end |
#topic ⇒ Object
125 126 127 128 129 130 131 |
# File 'lib/tb-cli/cli/add.rb', line 125 def topic # TODO: Add external queues and hosts (see section 7.2.3.3 for details) file = 'topics.yml' y = ConfigFile.new destination_root, file y.add_config("/topics/#{.name}") replace_yaml(y.yaml, file) end |
#web ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'lib/tb-cli/cli/add.rb', line 48 def web y = ConfigFile.new destination_root y.add_config('web', 'rackup', .rackup) if .rackup y.add_config('web', 'host', .host) if .host y.add_config('web', 'context', .context) if .context y.add_config('web', 'static', .static) if .static replace_yaml(y.yaml) end |