growthforecast-client 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -6,6 +6,8 @@ testing ruby: 1.9.3; GrowthForecast: > 0.39
6
6
 
7
7
  growthforecast-client is a ruby client library for GrowthForecast API where [GrowthForecast](http://kazeburo.github.com/GrowthForecast/) is a visualization graph tool.
8
8
 
9
+ With growthforecast-client, for example, you can edit properties of a graph such as `color`, and create a complex graph.
10
+
9
11
  ## USAGE
10
12
 
11
13
  gem install growthforecast-client
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
@@ -0,0 +1,42 @@
1
+ # -*- encoding: utf-8 -*-
2
+ # An example to create complex graphs
3
+
4
+ # require anyway
5
+ require 'growthforecast-client'
6
+
7
+ # Create a GrowthForecast Client, given he base URI of GrowthForecast
8
+ client = GrowthForecast::Client.new('http://localhost:5125')
9
+
10
+ # I gonna apply for all services/sections
11
+ sections = client.list_section
12
+ sections.each do |service_name, sections|
13
+ sections.each do |section_name|
14
+ # Make a complex graph from these graphs
15
+ from_graphs= [
16
+ {"service_name" => service_name, "section_name" => section_name, "graph_name" => "<1sec_count", "gmode" => 'gauge', "stack" => true, "type" => 'AREA'},
17
+ {"service_name" => service_name, "section_name" => section_name, "graph_name" => "<2sec_count", "gmode" => 'gauge', "stack" => true, "type" => 'AREA'},
18
+ {"service_name" => service_name, "section_name" => section_name, "graph_name" => "<3sec_count", "gmode" => 'gauge', "stack" => true, "type" => 'AREA'},
19
+ {"service_name" => service_name, "section_name" => section_name, "graph_name" => "<4sec_count", "gmode" => 'gauge', "stack" => true, "type" => 'AREA'},
20
+ {"service_name" => service_name, "section_name" => section_name, "graph_name" => ">=4sec_count", "gmode" => 'gauge', "stack" => true, "type" => 'AREA'},
21
+ ]
22
+
23
+ # The propety of a complex graph to create
24
+ to_complex = {
25
+ "service_name" => service_name,
26
+ "section_name" => section_name,
27
+ "graph_name" => "response_time_count",
28
+ "description" => "response time count",
29
+ "sort" => 10,
30
+ }
31
+
32
+ # Create a complex graph!
33
+ begin
34
+ puts "Setup /#{service_name}/#{section_name}/#{to_complex['graph_name']}"
35
+ client.create_complex(from_graphs, to_complex)
36
+ rescue GrowthForecast::AlreadyExists => e
37
+ puts "\tclass:#{e.class}\t#{e.message}"
38
+ rescue GrowthForecast::NotFound => e
39
+ puts "\tclass:#{e.class}\t#{e.message}"
40
+ end
41
+ end
42
+ end
@@ -1,9 +1,11 @@
1
1
  # -*- encoding: utf-8 -*-
2
+ # An example to edit properties of graphs such as color, unit.
3
+
4
+ # require anyway
2
5
  require 'growthforecast-client'
3
6
 
4
7
  # Create a GrowthForecast Client, given he base URI of GrowthForecast
5
- uri = 'http://localhost:5125'
6
- client = GrowthForecast::Client.new(uri)
8
+ client = GrowthForecast::Client.new('http://localhost:5125')
7
9
 
8
10
  # configure colors of graphs whose names are as belows:
9
11
  graph_colors = {
@@ -13,21 +15,23 @@ graph_colors = {
13
15
  '<4sec_count' => '#cccc11',
14
16
  '>=4sec_count' => '#cc1111',
15
17
  }
16
- # Apply for all services/sections
18
+ # I gonna apply for all services/sections
17
19
  sections = client.list_section
18
20
  sections.each do |service_name, sections|
19
21
  sections.each do |section_name|
20
22
  graph_colors.keys.each do |graph_name|
21
- data = {
23
+ # Graph properties to overwrite
24
+ params = {
22
25
  'color' => graph_colors[graph_name],
23
26
  'unit' => 'count',
24
27
  'sort' => 1, # order to display, 19 is the top
25
28
  'adjust' => '/',
26
29
  'adjustval' => '1',
27
30
  }
31
+ # Edit a graph
28
32
  begin
29
33
  puts "Setup /#{service_name}/#{section_name}/#{graph_name}"
30
- client.edit_graph(service_name, section_name, graph_name, data)
34
+ client.edit_graph(service_name, section_name, graph_name, params)
31
35
  rescue GrowthForecast::NotFound => e
32
36
  puts "\tclass:#{e.class}\t#{e.message}"
33
37
  end
@@ -1,10 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe GrowthForecast::Client do
4
- id_keys = %w[id service_name section_name graph_name]
5
- graph_keys = %w[number llimit mode stype adjustval gmode color created_at ulimit description
6
- sulimit unit sort updated_at adjust type sllimit meta md5]
7
-
3
+ shared_context "setup_growthforecast_client" do
8
4
  before(:all) { @client = GrowthForecast::Client.new('http://localhost:5125') }
9
5
 
10
6
  include_context "stub_list_graph" if ENV['MOCK'] == 'on'
@@ -23,6 +19,13 @@ describe GrowthForecast::Client do
23
19
  @client.delete_graph("app_name", "hostname", "<1sec_count") rescue nil
24
20
  @client.delete_graph("app_name", "hostname", "<2sec_count") rescue nil
25
21
  }
22
+ end
23
+
24
+ describe GrowthForecast::Client do
25
+ include_context "setup_growthforecast_client"
26
+ id_keys = %w[id service_name section_name graph_name]
27
+ graph_keys = %w[number llimit mode stype adjustval gmode color created_at ulimit description
28
+ sulimit unit sort updated_at adjust type sllimit meta md5]
26
29
 
27
30
  context "#list_graph" do
28
31
  include_context "stub_list_graph" if ENV['MOCK'] == 'on'
data/spec/support/mock.rb CHANGED
@@ -62,7 +62,34 @@ shared_context "stub_get_graph" do
62
62
  end
63
63
 
64
64
  shared_context "stub_get_graph_by_id" do
65
- include_context "stub_get_graph"
65
+ # /json/graph/:id does not return `meta` and `md5`
66
+ let(:graph_example) {
67
+ {
68
+ "number"=>0,
69
+ "llimit"=>-1000000000,
70
+ "mode"=>"gauge",
71
+ "stype"=>"AREA",
72
+ "adjustval"=>"1",
73
+ # "meta"=>"",
74
+ "service_name"=>"app_name",
75
+ "gmode"=>"gauge",
76
+ "color"=>"#cc6633",
77
+ "created_at"=>"2013/02/02 00:41:11",
78
+ "section_name"=>"hostname",
79
+ "ulimit"=>1000000000,
80
+ "id"=>1,
81
+ "graph_name"=>"<1sec_count",
82
+ "description"=>"",
83
+ "sulimit"=>100000,
84
+ "unit"=>"",
85
+ "sort"=>0,
86
+ "updated_at"=>"2013/02/02 02:32:10",
87
+ "adjust"=>"*",
88
+ "type"=>"AREA",
89
+ "sllimit"=>-100000,
90
+ # "md5"=>"3c59dc048e8850243be8079a5c74d079"
91
+ }
92
+ }
66
93
 
67
94
  proc = Proc.new do
68
95
  stub_request(:get, "#{base_uri}/json/graph/#{graph['id']}").
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: growthforecast-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-20 00:00:00.000000000 Z
12
+ date: 2013-02-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httpclient
@@ -155,7 +155,7 @@ files:
155
155
  - README.md
156
156
  - Rakefile
157
157
  - VERSION
158
- - examples/complex_graph.rb
158
+ - examples/create_complex.rb
159
159
  - examples/edit_graph.rb
160
160
  - growthforecast-client.gemspec
161
161
  - lib/growthforecast-client.rb
@@ -177,7 +177,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
177
177
  version: '0'
178
178
  segments:
179
179
  - 0
180
- hash: -2138731048266880490
180
+ hash: 503186860326361050
181
181
  required_rubygems_version: !ruby/object:Gem::Requirement
182
182
  none: false
183
183
  requirements:
@@ -186,7 +186,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
186
186
  version: '0'
187
187
  segments:
188
188
  - 0
189
- hash: -2138731048266880490
189
+ hash: 503186860326361050
190
190
  requirements: []
191
191
  rubyforge_project:
192
192
  rubygems_version: 1.8.23
@@ -1,37 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- require 'growthforecast-client'
3
-
4
- # Create a GrowthForecast Client, given he base URI of GrowthForecast
5
- uri = 'http://localhost:5125'
6
- client = GrowthForecast::Client.new(uri)
7
-
8
- # Apply for all services/sections
9
- sections = client.list_section
10
- sections.each do |service_name, sections|
11
- sections.each do |section_name|
12
- # Make a complex graph from these graphs
13
- from_graphs= [
14
- {:path => "#{service_name}/#{section_name}/<1sec_count", :gmode => 'gauge', :stack => true, :type => 'AREA'},
15
- {:path => "#{service_name}/#{section_name}/<2sec_count", :gmode => 'gauge', :stack => true, :type => 'AREA'},
16
- {:path => "#{service_name}/#{section_name}/<3sec_count", :gmode => 'gauge', :stack => true, :type => 'AREA'},
17
- {:path => "#{service_name}/#{section_name}/<4sec_count", :gmode => 'gauge', :stack => true, :type => 'AREA'},
18
- {:path => "#{service_name}/#{section_name}/>=4sec_count", :gmode => 'gauge', :stack => true, :type => 'AREA'},
19
- ]
20
-
21
- # The propety of a complex graph to create, e.g., path
22
- to_complex = {
23
- :path => "#{service_name}/#{section_name}/response_count",
24
- :description => 'response time count',
25
- :sort => 10,
26
- }
27
-
28
- begin
29
- puts "Setup #{to_complex[:path]}"
30
- client.create_complex(from_graphs, to_complex)
31
- rescue GrowthForecast::AlreadyExists => e
32
- puts "\tclass:#{e.class}\t#{e.message}"
33
- rescue GrowthForecast::NotFound => e
34
- puts "\tclass:#{e.class}\t#{e.message}"
35
- end
36
- end
37
- end