Class: Sunspot::Rails::Tester
- Inherits:
-
Object
- Object
- Sunspot::Rails::Tester
- Extended by:
- Forwardable
- Defined in:
- lib/sunspot/rails/tester.rb
Constant Summary collapse
- VERSION =
'1.0.0'
Class Attribute Summary collapse
-
.pid ⇒ Object
Returns the value of attribute pid.
-
.server ⇒ Object
Returns the value of attribute server.
-
.started ⇒ Object
Returns the value of attribute started.
Class Method Summary collapse
- .clear ⇒ Object
- .configuration ⇒ Object
- .give_feedback ⇒ Object
- .kill_at_exit ⇒ Object
- .seconds ⇒ Object
- .start_original_sunspot_session ⇒ Object
- .started? ⇒ Boolean
- .starting ⇒ Object
- .uri ⇒ Object
Class Attribute Details
.pid ⇒ Object
Returns the value of attribute pid.
12 13 14 |
# File 'lib/sunspot/rails/tester.rb', line 12 def pid @pid end |
.server ⇒ Object
Returns the value of attribute server.
12 13 14 |
# File 'lib/sunspot/rails/tester.rb', line 12 def server @server end |
.started ⇒ Object
Returns the value of attribute started.
12 13 14 |
# File 'lib/sunspot/rails/tester.rb', line 12 def started @started end |
Class Method Details
.clear ⇒ Object
63 64 65 |
# File 'lib/sunspot/rails/tester.rb', line 63 def clear self.server = nil end |
.configuration ⇒ Object
59 60 61 |
# File 'lib/sunspot/rails/tester.rb', line 59 def configuration server.send(:configuration) end |
.give_feedback ⇒ Object
36 37 38 39 |
# File 'lib/sunspot/rails/tester.rb', line 36 def give_feedback puts 'Sunspot server is starting...' while starting puts "Sunspot server took #{seconds} seconds to start" end |
.kill_at_exit ⇒ Object
32 33 34 |
# File 'lib/sunspot/rails/tester.rb', line 32 def kill_at_exit at_exit { Process.kill('TERM', pid) } end |
.seconds ⇒ Object
49 50 51 |
# File 'lib/sunspot/rails/tester.rb', line 49 def seconds '%.2f' % (Time.now - started) end |
.start_original_sunspot_session ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/sunspot/rails/tester.rb', line 14 def start_original_sunspot_session unless started? self.server = Sunspot::Rails::Server.new self.started = Time.now self.pid = fork do $stderr.reopen('/dev/null') $stdout.reopen('/dev/null') server.run end kill_at_exit give_feedback end end |
.started? ⇒ Boolean
28 29 30 |
# File 'lib/sunspot/rails/tester.rb', line 28 def started? not server.nil? end |
.starting ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/sunspot/rails/tester.rb', line 41 def starting sleep(1) Net::HTTP.get_response(URI.parse(uri)) false rescue Errno::ECONNREFUSED true end |
.uri ⇒ Object
53 54 55 |
# File 'lib/sunspot/rails/tester.rb', line 53 def uri "http://#{hostname}:#{port}#{path}" end |