Module: CliTool::Remote::ClassMethods
- Defined in:
- lib/cli_tool/remote.rb
Instance Method Summary collapse
- #custom!(*a, &b) ⇒ Object
- #restart! ⇒ Object
- #run!(command, *a, &b) ⇒ Object
- #run_suite!(*a, &b) ⇒ Object
- #script(options = {}, &block) ⇒ Object
- #script_plugin(object) ⇒ Object
- #shutdown! ⇒ Object
Instance Method Details
#custom!(*a, &b) ⇒ Object
314 315 316 317 |
# File 'lib/cli_tool/remote.rb', line 314 def custom!(*a, &b) Proc.new { |obj| obj.instance_exec(*a, &b) } false end |
#restart! ⇒ Object
302 303 304 |
# File 'lib/cli_tool/remote.rb', line 302 def restart! queue(Script.new.exec('shutdown -r now', :sudo)) end |
#run!(command, *a, &b) ⇒ Object
310 311 312 |
# File 'lib/cli_tool/remote.rb', line 310 def run!(command, *a, &b) run(command, *a, &b) end |
#run_suite!(*a, &b) ⇒ Object
306 307 308 |
# File 'lib/cli_tool/remote.rb', line 306 def run_suite!(*a, &b) run(:run_suite!, *a, &b) end |
#script(options = {}, &block) ⇒ Object
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 |
# File 'lib/cli_tool/remote.rb', line 265 def script( = {}, &block) script = Proc.new do run = true # Allow restricting the runs based on the tags provided if self. = ([:tags] || []).concat([[:tag]]).compact.flatten run = false if (self. & ).empty? end # Run only when the tag is provided if tag_only option is provided run = false if run && [:tag_only] == true && self..empty? if run # Do we want to run this script? build_script = Script.new build_script.__send__(:instance_exec, self, &block) if [:reboot] == true build_script.exec('shutdown -r now', :sudo) puts "\nServer will reboot upon completion of this block!\n", [:blue, :italic] elsif [:shutdown] == true build_script.exec('shutdown -h now', :sudo) puts "\nServer will shutdown upon completion of this block!\n", [:blue, :italic] end build_script else false # Don't run anything end end queue(script) end |
#script_plugin(object) ⇒ Object
261 262 263 |
# File 'lib/cli_tool/remote.rb', line 261 def script_plugin(object) Script.__send__(:include, object) end |