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
26 27 28 |
# File 'lib/exhaust/runner.rb', line 26 def ember_host "http://localhost:#{ember_port}" end |
#ember_path ⇒ Object
38 39 40 |
# File 'lib/exhaust/runner.rb', line 38 def ember_path configuration.ember_path end |
#ember_port ⇒ Object
30 31 32 |
# File 'lib/exhaust/runner.rb', line 30 def ember_port configuration.ember_port.to_s end |
#ember_server ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/exhaust/runner.rb', line 46 def ember_server @ember_server ||= begin Dir.chdir(ember_path) do @ember_server = IO.popen([{"API_HOST" => "http://localhost:#{rails_port}"}, "ember", "server", "--port", ember_port, "--live-reload", "false", :err => [:child, :out]]) end end end |
#rails_path ⇒ Object
42 43 44 |
# File 'lib/exhaust/runner.rb', line 42 def rails_path configuration.rails_path end |
#rails_port ⇒ Object
34 35 36 |
# File 'lib/exhaust/runner.rb', line 34 def rails_port configuration.rails_port.to_s end |
#rails_server ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/exhaust/runner.rb', line 54 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 22 23 24 |
# File 'lib/exhaust/runner.rb', line 9 def run Timeout::timeout(30) do while running = ember_server.gets if running =~ /build successful/i break end end while running = rails_server.gets puts running if running =~ /info/i break end end end end |
#shutdown! ⇒ Object
62 63 64 |
# File 'lib/exhaust/runner.rb', line 62 def shutdown! Process.kill(9, ember_server.pid, rails_server.pid) end |