Class: LMK::Runner
- Inherits:
-
Object
- Object
- LMK::Runner
- Defined in:
- lib/lmk/runner.rb
Defined Under Namespace
Classes: Configuration
Class Method Summary collapse
- .configuration ⇒ Object
- .configure {|self.configuration| ... } ⇒ Object
- .run(command, options) ⇒ Object
Instance Method Summary collapse
- #console(message) ⇒ Object
-
#initialize(configuration = Runner.configuration) ⇒ Runner
constructor
A new instance of Runner.
- #post_to_web(command) ⇒ Object
- #run(command, options) ⇒ Object
- #shell(command) ⇒ Object
- #sms(command) ⇒ Object
- #validate! ⇒ Object
Constructor Details
#initialize(configuration = Runner.configuration) ⇒ Runner
Returns a new instance of Runner.
26 27 28 |
# File 'lib/lmk/runner.rb', line 26 def initialize(configuration = Runner.configuration) @configuration = configuration end |
Class Method Details
.configuration ⇒ Object
18 19 20 |
# File 'lib/lmk/runner.rb', line 18 def self.configuration @@default_configuration ||= Configuration.new end |
.configure {|self.configuration| ... } ⇒ Object
14 15 16 |
# File 'lib/lmk/runner.rb', line 14 def self.configure yield self.configuration end |
.run(command, options) ⇒ Object
22 23 24 |
# File 'lib/lmk/runner.rb', line 22 def self.run(command, ) new.run(command, ) end |
Instance Method Details
#console(message) ⇒ Object
30 31 32 |
# File 'lib/lmk/runner.rb', line 30 def console() @configuration.console_service.puts() end |
#post_to_web(command) ⇒ Object
42 43 44 |
# File 'lib/lmk/runner.rb', line 42 def post_to_web(command) @configuration.gist_service.send(command) end |
#run(command, options) ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'lib/lmk/runner.rb', line 46 def run(command, ) return unless validate! console("running command `#{command}`") result = shell(command) result = post_to_web(result) result = sms(result) console(result.output) end |
#shell(command) ⇒ Object
34 35 36 |
# File 'lib/lmk/runner.rb', line 34 def shell(command) @configuration.shell_service.exec(command) end |
#sms(command) ⇒ Object
38 39 40 |
# File 'lib/lmk/runner.rb', line 38 def sms(command) @configuration.sms_service.send(command) end |
#validate! ⇒ Object
55 56 57 58 59 60 61 62 |
# File 'lib/lmk/runner.rb', line 55 def validate! unless @configuration.sms_service.runnable? console("Configuration invalid. Run `lmk config` for more info") false else true end end |