Class: HarperClient

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/harper/client.rb

Instance Method Summary collapse

Constructor Details

#initializeHarperClient

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

#startObject



17
18
19
20
# File 'lib/harper/client.rb', line 17

def start
  Kernel.system("harper --port 4568 --bg")
  @started = true
end

#started?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/harper/client.rb', line 13

def started?
  @started
end

#stopObject



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