Class: Exhaust::Runner
- Inherits:
-
Object
- Object
- Exhaust::Runner
- Defined in:
- lib/exhaust/runner.rb
Instance Attribute Summary collapse
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
Instance Method Summary collapse
- #ember_host ⇒ Object
- #ember_path ⇒ Object
- #ember_port ⇒ Object
- #ember_server ⇒ Object
-
#initialize(configuration = Exhaust::Configuration.new) ⇒ Runner
constructor
A new instance of Runner.
- #rails_path ⇒ Object
- #rails_port ⇒ Object
- #rails_server ⇒ Object
- #run ⇒ Object
- #shutdown! ⇒ Object
Constructor Details
#initialize(configuration = Exhaust::Configuration.new) ⇒ Runner
Returns a new instance of Runner.
5 6 7 |
# File 'lib/exhaust/runner.rb', line 5 def initialize(configuration=Exhaust::Configuration.new) @configuration = configuration end |
Instance Attribute Details
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
4 5 6 |
# File 'lib/exhaust/runner.rb', line 4 def configuration @configuration end |
Instance Method Details
#ember_host ⇒ Object
23 24 25 |
# File 'lib/exhaust/runner.rb', line 23 def ember_host "http://localhost:#{ember_port}" end |
#ember_path ⇒ Object
35 36 37 |
# File 'lib/exhaust/runner.rb', line 35 def ember_path configuration.ember_path end |
#ember_port ⇒ Object
27 28 29 |
# File 'lib/exhaust/runner.rb', line 27 def ember_port configuration.ember_port.to_s end |
#ember_server ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/exhaust/runner.rb', line 43 def ember_server @ember_server ||= begin Dir.chdir(ember_path) do @ember_server = IO.popen([{"API_HOST" => "http://localhost:3001"}, "ember", "server", "--port", ember_port, "--live-reload", "false", :err => [:child, :out]]) end end end |
#rails_path ⇒ Object
39 40 41 |
# File 'lib/exhaust/runner.rb', line 39 def rails_path configuration.rails_path end |
#rails_port ⇒ Object
31 32 33 |
# File 'lib/exhaust/runner.rb', line 31 def rails_port configuration.rails_port.to_s end |
#rails_server ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/exhaust/runner.rb', line 51 def rails_server @rails_server ||= begin Dir.chdir(rails_path) do @rails_server = IO.popen(['rails', 'server', '--port', rails_port, '--environment', 'test', :err => [:child, :out]]) end end end |
#run ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/exhaust/runner.rb', line 9 def run while running = ember_server.gets if running =~ /build successful/i break end end while running = rails_server.gets if running =~ /info/i break end end end |
#shutdown! ⇒ Object
59 60 61 |
# File 'lib/exhaust/runner.rb', line 59 def shutdown! Process.kill(9, ember_server.pid, rails_server.pid) end |