Class: HarperClient
Instance Method Summary collapse
-
#initialize ⇒ HarperClient
constructor
A new instance of HarperClient.
- #mock(mock) ⇒ Object
- #start ⇒ Object
- #started? ⇒ Boolean
- #stop ⇒ Object
Constructor Details
#initialize ⇒ HarperClient
Returns a new instance of HarperClient.
9 10 11 |
# File 'lib/harper/client.rb', line 9 def initialize @started = false end |
Instance Method Details
#mock(mock) ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/harper/client.rb', line 30 def mock(mock) mock_body = case mock when String mock else mock.to_json end self.class.headers "Content-Type" => "application/json" self.class.post "/h/mocks", :body => mock_body end |
#start ⇒ Object
17 18 19 20 |
# File 'lib/harper/client.rb', line 17 def start Kernel.system("harper --port 4568 --bg") @started = true end |
#started? ⇒ Boolean
13 14 15 |
# File 'lib/harper/client.rb', line 13 def started? @started end |
#stop ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/harper/client.rb', line 22 def stop self.class.put "/h/control", :body => {:command => "quit"}.to_json @started = false rescue Exception => e # Ignore the error here as it's pretty common for the connection # to be killed out from under the app end |