growthforecast-client 0.80.2 → 0.82.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 389f477ae239f1c04bc4da5d4c666f8cd2c3caba
4
- data.tar.gz: dbc01e7a72b731632b05b1b217e00ac1b2c1cf04
3
+ metadata.gz: 148a2f0792e825f45d2fd455208d21eff0fcb406
4
+ data.tar.gz: a2edd60c2e63cbcef3052400a2de88511ba81a31
5
5
  SHA512:
6
- metadata.gz: cdfe3688ec02a66270f5e62001feb72d662180944b5e4db6e9599f11e357783ced44c776b565055820a262c0ff409ba9e66a4a995d90abd5a7ac8c8893af0589
7
- data.tar.gz: 02bf8f6e2845a8b13fe7656fd125733925e3a8992fbb9ed4a4b967c0530cbb0aa6ed2b4beaf2bae7e1b7b9964f8e70e2ab25218aa4af3d6dc866f82357ad9c0f
6
+ metadata.gz: 50f2f7bdb5ba1b8e414626162788af7c28cec322a421f79614f4c5ca3a02ecb15991820238df277558ff91ff29f10fe0f7a29c3614887511016609652b03ea64
7
+ data.tar.gz: e145c5e28616bf9471403b22adcafd972d733c2469224b386e6f049d9e95438869c0be101aaeec6a717a208834fcb54f4075cfb774f43217b99a562e7bdd9aa4
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ # 0.82.1 (2014/03/26)
2
+
3
+ Changes:
4
+
5
+ - Changed the argument order of #post_vrule
6
+
7
+ # 0.82.0 (2014/03/26)
8
+
9
+ Enhancement:
10
+
11
+ - Support newly created `vrule` api
12
+
1
13
  # 0.80.2 (2014/03/06)
2
14
 
3
15
  Fixes:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.80.2
1
+ 0.82.1
@@ -415,6 +415,61 @@ module GrowthForecast
415
415
  post_query("/delete_complex/#{complex_id}")
416
416
  end
417
417
 
418
+ # Post parameters to a vrule, POST /vrule/api/:service_name/:section_name/:graph_name
419
+ # @param [String] service_name
420
+ # @param [String] section_name
421
+ # @param [String] graph_name
422
+ # @param [Hash] params The POST parameters. See #get_vrule
423
+ # @return [Hash] the error code and graph property
424
+ # @example
425
+ #{"error"=>0,
426
+ #"data"=>{
427
+ # "graph_path"=>"/hoge/hoge/hoge",
428
+ # "color"=>"#FF0000",
429
+ # "time"=>1395826210,
430
+ # "id"=>1,
431
+ # "dashes"=>"2,10",
432
+ # "description"=>""}}
433
+ def post_vrule(service_name = nil, section_name = nil, graph_name = nil, params = {})
434
+ path = "/vrule/api"
435
+ path += "/#{e service_name}" if service_name
436
+ path += "/#{e section_name}" if section_name
437
+ path += "/#{e graph_name}" if graph_name
438
+ post_query(path, params)
439
+ end
440
+
441
+ # Get the data of vrules, GET /vrule/summary/:service_name/:section_name/:graph_name
442
+ # @param [String] service_name
443
+ # @param [String] section_name
444
+ # @param [String] graph_name
445
+ # @return [Hash] the data of vrules
446
+ # @example
447
+ #[
448
+ #{
449
+ # "graph_path"=>"/hoge/hoge/hoge",
450
+ # "color"=>"#FF0000",
451
+ # "time"=>1395826210,
452
+ # "id"=>1,
453
+ # "dashes"=>"",
454
+ # "description"=>""
455
+ #},
456
+ #{
457
+ # "graph_path"=>"/hoge/hoge/hoge",
458
+ # "color"=>"#FF0000",
459
+ # "time"=>1395826363,
460
+ # "id"=>2,
461
+ # "dashes"=>"2,10",
462
+ # "description"=>""
463
+ #}
464
+ #]
465
+ def get_vrule(service_name = nil, section_name = nil, graph_name = nil)
466
+ path = "/vrule/summary"
467
+ path += "/#{e service_name}" if service_name
468
+ path += "/#{e section_name}" if section_name
469
+ path += "/#{e graph_name}" if graph_name
470
+ get_json(path)
471
+ end
472
+
418
473
  private
419
474
 
420
475
  def e(str)
@@ -7,6 +7,7 @@ describe GrowthForecast::Client do
7
7
  sulimit unit sort updated_at adjust type sllimit meta md5]
8
8
  complex_keys = %w[number complex created_at service_name section_name id graph_name data sumup
9
9
  description sort updated_at]
10
+ vrule_keys = %w[graph_path color time id dashes description]
10
11
 
11
12
  context "#list_graph" do
12
13
  include_context "stub_list_graph" if ENV['MOCK'] == 'on'
@@ -176,5 +177,29 @@ describe GrowthForecast::Client do
176
177
  it { should == "http://localhost:5125/json/list/graph" }
177
178
  end
178
179
  end
180
+
181
+ context "#post_vrule" do
182
+ include_context "stub_post_vrule" if ENV['MOCK'] == 'on'
183
+ params = {
184
+ 'dashes' => '2,10'
185
+ }
186
+ subject { client.post_vrule(graph["service_name"], graph["section_name"], graph["graph_name"], params) }
187
+ it { subject["error"].should == 0 }
188
+ params.keys.each {|key| it { subject["data"][key].should == params[key] } }
189
+ end
190
+
191
+ context "#get_vrule" do
192
+ context "200 OK" do
193
+ include_context "stub_get_vrule" if ENV['MOCK'] == 'on'
194
+ subject { client.get_vrule(graph["service_name"], graph["section_name"], graph["graph_name"]).first }
195
+ vrule_keys.each {|key| it { subject.should have_key(key) } }
196
+ end
197
+
198
+ context "Not Found" do
199
+ include_context "stub_get_notfound_vrule" if ENV['MOCK'] == 'on'
200
+ subject { client.get_vrule(notfound_graph["service_name"], notfound_graph["section_name"], notfound_graph["graph_name"]) }
201
+ it { should == [] } # differ with 404 Not Found
202
+ end
203
+ end
179
204
  end
180
205
 
data/spec/support/mock.rb CHANGED
@@ -225,17 +225,53 @@ shared_context "stub_create_complex" do
225
225
  before(:each, &proc)
226
226
  end
227
227
 
228
+ def notfound_graph
229
+ {
230
+ 'service_name' => 'not found',
231
+ 'section_name' => 'not found',
232
+ 'graph_name' => 'not found',
233
+ }
234
+ end
228
235
  shared_context "stub_get_notfound_graph" do
229
- def notfound_graph
236
+ proc = Proc.new do
237
+ stub_request(:get, "#{base_uri}/api/#{e notfound_graph['service_name']}/#{e notfound_graph['section_name']}/#{e notfound_graph['graph_name']}").
238
+ to_return(:status => 404, :body => '<html><body><strong>404</strong> Not Found</body></html>')
239
+ end
240
+ before(:each, &proc)
241
+ end
242
+
243
+ shared_context "stub_post_vrule" do
244
+ include_context "stub_get_vrule"
245
+ before do
246
+ stub_request(:post, "#{base_uri}/vrule/api/#{e graph['service_name']}/#{e graph['section_name']}/#{e graph['graph_name']}").
247
+ to_return(:status => 200, :body => { "error" => 0, "data" => vrule_example }.to_json)
248
+ end
249
+ end
250
+
251
+ shared_context "stub_get_vrule" do
252
+ def vrule_example
230
253
  {
231
- 'service_name' => 'not found',
232
- 'section_name' => 'not found',
233
- 'graph_name' => 'not found',
254
+ "graph_path"=>"/#{graph['service_name']}/#{graph['section_name']}/#{graph['graph_name']}",
255
+ "color"=>"#FF0000",
256
+ "time"=>1395826210,
257
+ "id"=>1,
258
+ "dashes"=>"2,10",
259
+ "description"=>""
234
260
  }
235
261
  end
262
+
236
263
  proc = Proc.new do
237
- stub_request(:get, "#{base_uri}/api/#{e notfound_graph['service_name']}/#{e notfound_graph['section_name']}/#{e notfound_graph['graph_name']}").
238
- to_return(:status => 404, :body => '<html><body><strong>404</strong> Not Found</body></html>')
264
+ stub_request(:get, "#{base_uri}/vrule/summary/#{e graph['service_name']}/#{e graph['section_name']}/#{e graph['graph_name']}").
265
+ to_return(:status => 200, :body => [vrule_example].to_json)
239
266
  end
240
267
  before(:each, &proc)
241
268
  end
269
+
270
+ shared_context "stub_get_notfound_vrule" do
271
+ proc = Proc.new do
272
+ stub_request(:get, "#{base_uri}/vrule/summary/#{e notfound_graph['service_name']}/#{e notfound_graph['section_name']}/#{e notfound_graph['graph_name']}").
273
+ to_return(:status => 200, :body => [].to_json)
274
+ end
275
+ before(:each, &proc)
276
+ end
277
+
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.80.2
4
+ version: 0.82.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naotoshi Seo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-06 00:00:00.000000000 Z
11
+ date: 2014-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpclient