Class: RestDebug::Client

Inherits:
Object
  • Object
show all
Includes:
FromHash
Defined in:
lib/rest_debug/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#base_urlObject

Returns the value of attribute base_url.



4
5
6
# File 'lib/rest_debug/client.rb', line 4

def base_url
  @base_url
end

Instance Method Details

#command(cmd) ⇒ Object



22
23
24
# File 'lib/rest_debug/client.rb', line 22

def command(cmd)
  get("command",:command => cmd)
end

#get(sub, params = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/rest_debug/client.rb', line 6

def get(sub,params={})
  url = "#{base_url}/#{sub}"
  if params.size > 0
    url += "?"
    params.each do |k,v|
      url << "#{k}=#{CGI::escape(v.to_s)}&"
    end
  end

  puts url
  raw = open(url).read
  res = JSON.parse(raw)
  sleep(0.05)
  res
end

#start(code) ⇒ Object



36
37
38
# File 'lib/rest_debug/client.rb', line 36

def start(code)
  get :start, :code => code
end

#statusObject



26
27
28
29
30
31
32
33
34
# File 'lib/rest_debug/client.rb', line 26

def status
  res = get :status
  res.each do |type,data|
    puts "#{type.to_s.upcase} (#{data['open'] ? 'Open' : 'Closed'}):"
    puts data['output']
    puts "\n\n"
  end
  res
end