Module: Guard::Jasmine::Server
- Defined in:
- lib/guard/jasmine/server.rb
Overview
Start and stop a Jasmine test server for requesting the specs from PhantomJS.
Class Attribute Summary collapse
-
.cmd ⇒ Object
Returns the value of attribute cmd.
-
.process ⇒ Object
Returns the value of attribute process.
Class Method Summary collapse
-
.choose_server_port(options) ⇒ Integer
A port was not specified, therefore we attempt to detect the best port to use.
-
.detect_server(spec_dir) ⇒ Symbol
Detect the server to use.
-
.start(options) ⇒ Object
Start the internal test server for getting the Jasmine runner.
-
.stop ⇒ Object
Stop the server thread.
Class Attribute Details
.cmd ⇒ Object
Returns the value of attribute cmd.
17 18 19 |
# File 'lib/guard/jasmine/server.rb', line 17 def cmd @cmd end |
.process ⇒ Object
Returns the value of attribute process.
17 18 19 |
# File 'lib/guard/jasmine/server.rb', line 17 def process @process end |
Class Method Details
.choose_server_port(options) ⇒ Integer
A port was not specified, therefore we attempt to detect the best port to use
58 59 60 61 62 63 64 |
# File 'lib/guard/jasmine/server.rb', line 58 def choose_server_port() if [:server] == :jasmine_gem ::Jasmine.config.port(:server) else ::Guard::Jasmine.find_free_server_port end end |
.detect_server(spec_dir) ⇒ Symbol
Detect the server to use
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/guard/jasmine/server.rb', line 71 def detect_server(spec_dir) if spec_dir && File.exist?(File.join(spec_dir, 'support', 'jasmine.yml')) :jasmine_gem elsif File.exist?('config.ru') %w(unicorn thin mongrel puma).each do |server| begin require server return server.to_sym rescue LoadError # Ignore missing server and try next end end :webrick else :none end end |
.start(options) ⇒ Object
Start the internal test server for getting the Jasmine runner.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/guard/jasmine/server.rb', line 28 def start() port = [:port] case [:server] when :webrick, :mongrel, :thin, :puma start_rack_server([:server], port, ) when :unicorn start_unicorn_server(port, ) when :jasmine_gem start_rake_server(port, 'jasmine', ) when :none # noop else start_rake_server(port, [:server], ) end wait_for_server(port, [:server_timeout]) unless [:server] == :none end |
.stop ⇒ Object
Stop the server thread.
48 49 50 51 52 |
# File 'lib/guard/jasmine/server.rb', line 48 def stop return unless process Compat::UI.info 'Guard::Jasmine stops server.' process.stop(5) end |