growthforecast-client 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0f08451a6391693686e7860e69d4c73e07332021
4
- data.tar.gz: 9b40c514b10a6362fbaf075a70610f36a1514c22
3
+ metadata.gz: bdff216f1774756c4c933a9b4c26691307ee8938
4
+ data.tar.gz: 9a68fc96e2166ee5f6a8128d6f77a6fa18fae9e6
5
5
  SHA512:
6
- metadata.gz: 91f7bfe0c54e4768d8a952bec31930edd5071a1ec890091f3341be6463c90f76fe4136bcff88f3cc945aef7fe91ffe78bcc65e575863abdfc83c03e6c30c0b3f
7
- data.tar.gz: 4a83edef7f730f1824ec975fc664bb67d1dccf969856d5ae8483b266cff6a86c2245c3757fcbfbf93a5eb7143cbfd170be1559d5fdbc73275997b558cf4cad38
6
+ metadata.gz: 82fd7153a8c1b6ff4b87aaca7fe6e770fe23b626bdacb1ca8271038b2333aebcfbc29324c21d4a7ef8c537c5b2ed9e123793a720bb5615385aed9bbc5bf0ae7b
7
+ data.tar.gz: 0e11150507e19a48b61b4c578522c28378ff257251e290c67f37066f9a9fdbfdb873c3bb6199667b618e4d901993268070971b70385591b5c92643d733e1a933
data/CHANGELOG.md CHANGED
@@ -1,2 +1,9 @@
1
- # v0.0.3
1
+ # 0.0.5 (2013/05/16)
2
+
3
+ Features:
4
+
5
+ - Add `#last_response` method to get HTTPClient response directory
6
+ - Add `#client=` method to replace HTTPClient object
7
+
8
+ # 0.0.3
2
9
  Add bin/growthforecast-client delete_graph
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.4
1
+ 0.0.5
@@ -11,18 +11,28 @@ module GrowthForecast
11
11
 
12
12
  class Client
13
13
  attr_accessor :debug
14
+ attr_accessor :client
15
+
14
16
  # @param [String] base_uri The base uri of GrowthForecast
15
17
  def initialize(base_uri = 'http://127.0.0.1:5125')
16
18
  @base_uri = base_uri
17
19
  end
18
20
 
21
+ def client
22
+ @client ||= HTTPClient.new
23
+ end
24
+
25
+ def last_response
26
+ @res
27
+ end
28
+
19
29
  # GET the JSON API
20
30
  # @param [String] path
21
31
  # @return [Hash] response body
22
32
  def get_json(path)
23
- res = client.get("#{@base_uri}#{path}")
24
- handle_error(res)
25
- JSON.parse(res.body)
33
+ @res = client.get("#{@base_uri}#{path}")
34
+ handle_error(@res)
35
+ JSON.parse(@res.body)
26
36
  end
27
37
 
28
38
  # POST the JSON API
@@ -32,9 +42,9 @@ module GrowthForecast
32
42
  def post_json(path, data = {})
33
43
  pp data if @debug
34
44
  json = JSON.generate(data)
35
- res = client.post("#{@base_uri}#{path}", json)
36
- handle_error(res)
37
- JSON.parse(res.body)
45
+ @res = client.post("#{@base_uri}#{path}", json)
46
+ handle_error(@res)
47
+ JSON.parse(@res.body)
38
48
  end
39
49
 
40
50
  # POST the non-JSON API
@@ -43,9 +53,9 @@ module GrowthForecast
43
53
  # @return [String] response body
44
54
  def post_query(path, data = {})
45
55
  pp data if @debug
46
- res = client.post("#{@base_uri}#{path}", data)
47
- handle_error(res)
48
- JSON.parse(res.body)
56
+ @res = client.post("#{@base_uri}#{path}", data)
57
+ handle_error(@res)
58
+ JSON.parse(@res.body)
49
59
  end
50
60
 
51
61
  # Get the list of graphs, /json/list/graph
@@ -296,10 +306,6 @@ module GrowthForecast
296
306
  URI.escape(str) if str
297
307
  end
298
308
 
299
- def client
300
- @client ||= HTTPClient.new
301
- end
302
-
303
309
  def handle_error(res)
304
310
  case res.status
305
311
  when 200
@@ -153,5 +153,18 @@ describe GrowthForecast::Client do
153
153
  after { @client.delete_complex(to_complex["service_name"], to_complex["section_name"], to_complex["graph_name"]) }
154
154
  end
155
155
  end
156
+
157
+ describe 'http://blog.64p.org/?page=1366971426' do
158
+ context "#client=" do
159
+ before { @client.client = HTTPClient.new(agent_name: 'TestAgent/0.1') }
160
+ it { @client.client.agent_name.should == 'TestAgent/0.1' }
161
+ end
162
+
163
+ context "#last_response" do
164
+ include_context "stub_list_graph" if ENV['MOCK'] == 'on'
165
+ subject { @client.last_response }
166
+ it { should be_kind_of HTTP::Message }
167
+ end
168
+ end
156
169
  end
157
170
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: growthforecast-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naotoshi Seo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-03-28 00:00:00.000000000 Z
11
+ date: 2013-05-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpclient