Class: Stack::Runner
- Inherits:
-
Object
- Object
- Stack::Runner
- Defined in:
- lib/stack/runner.rb
Instance Attribute Summary collapse
-
#arguments ⇒ Object
Returns the value of attribute arguments.
-
#command ⇒ Object
Returns the value of attribute command.
-
#configuration ⇒ Object
Returns the value of attribute configuration.
-
#generator ⇒ Object
Returns the value of attribute generator.
Instance Method Summary collapse
-
#initialize(argv) ⇒ Runner
constructor
A new instance of Runner.
-
#parse! ⇒ Object
Parse options, command and arguments.
-
#run! ⇒ Object
Run stack!.
-
#run_command ⇒ Object
Runs the specified command.
Constructor Details
#initialize(argv) ⇒ Runner
Returns a new instance of Runner.
8 9 10 11 12 13 |
# File 'lib/stack/runner.rb', line 8 def initialize(argv) @argv = argv @options = { } parse! end |
Instance Attribute Details
#arguments ⇒ Object
Returns the value of attribute arguments.
5 6 7 |
# File 'lib/stack/runner.rb', line 5 def arguments @arguments end |
#command ⇒ Object
Returns the value of attribute command.
4 5 6 |
# File 'lib/stack/runner.rb', line 4 def command @command end |
#configuration ⇒ Object
Returns the value of attribute configuration.
3 4 5 |
# File 'lib/stack/runner.rb', line 3 def configuration @configuration end |
#generator ⇒ Object
Returns the value of attribute generator.
6 7 8 |
# File 'lib/stack/runner.rb', line 6 def generator @generator end |
Instance Method Details
#parse! ⇒ Object
Parse options, command and arguments
16 17 18 19 20 21 22 23 |
# File 'lib/stack/runner.rb', line 16 def parse! = Stack::parse! @argv @configuration = Stack::Configuration.new() @command = @argv.shift @arguments = @argv end |
#run! ⇒ Object
Run stack!
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/stack/runner.rb', line 26 def run! if @command.nil? @command = "generate" end if Stack::COMMANDS.include?(@command) run_command else abort "Unknown command: #{@command}. Use one of #{Stack::COMMANDS.join(", ")}." end end |
#run_command ⇒ Object
Runs the specified command
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/stack/runner.rb', line 39 def run_command @generator = Stack::Generator.new(Stack::runner.configuration.source, Stack::runner.configuration.target) case self.command when /(generate|gen)/ @generator.transform! when /(server)/ # make a watcher watcher = Stack::Watcher.new(@generator) watcher.keep_alive = false watcher.observe # and a server server = Stack::Server.new(@generator) server.observe when /(watch)/ # setup a watcher watcher = Stack::Watcher.new(@generator) watcher.observe end end |