copperegg 0.6.0.pre → 0.6.0.pre2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +17 -0
- data/LICENSE +1 -1
- data/README.md +54 -9
- data/copperegg-0.6.0.pre2.gem +0 -0
- data/copperegg.gemspec +1 -1
- data/lib/copperegg/custom_dashboard.rb +4 -6
- data/lib/copperegg/metric_group.rb +1 -5
- data/lib/copperegg/mixins/persistence.rb +18 -17
- data/lib/copperegg/ver.rb +1 -1
- data/test/custom_dashboard_test.rb +22 -43
- data/test/metric_group_test.rb +1 -22
- data/test/metric_sample_test.rb +0 -30
- metadata +34 -51
data/CHANGELOG.md
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
## 0.6.0.pre (January 3, 2013)
|
2
|
+
|
3
|
+
Changes:
|
4
|
+
|
5
|
+
- Substantial changes to syntax. API resources now represented by Ruby classes. See README for details.
|
6
|
+
- Replaced multi_json requirement with json_pure.
|
7
|
+
|
8
|
+
Features:
|
9
|
+
|
10
|
+
- Automatic dashboard creation for metric groups.
|
11
|
+
- Metric groups and custom dashboards can be updated and deleted.
|
12
|
+
- Client-side validation added.
|
13
|
+
- Added automated test suite.
|
14
|
+
|
15
|
+
Bugfixes:
|
16
|
+
|
17
|
+
- Metric group versioning is encorporated and recognized.
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -7,7 +7,7 @@ The CopperEgg gem allows programmatic access to the CopperEgg API.
|
|
7
7
|
Via rubygems.org:
|
8
8
|
|
9
9
|
```
|
10
|
-
$ gem install copperegg
|
10
|
+
$ gem install copperegg
|
11
11
|
```
|
12
12
|
|
13
13
|
To build and install the development branch yourself from the latest source:
|
@@ -55,6 +55,43 @@ metric_group.metrics << {"type"=>"ce_gauge", "name"=>"waiting",
|
|
55
55
|
metric_group.save
|
56
56
|
```
|
57
57
|
|
58
|
+
If a metric group by the same name already exists, a new one will be created with a "versioned" name. For example:
|
59
|
+
|
60
|
+
```ruby
|
61
|
+
metric_group2 = CopperEgg::MetricGroup.new(:name => "my_new_metric_group", :label => "New Group Version 2", :frequency => 60)
|
62
|
+
metric_group2.metrics << {"type"=>"ce_gauge", "name"=>"active_connections", "unit"=>"Connections"}
|
63
|
+
metric_group2.save
|
64
|
+
|
65
|
+
metric_group2.name
|
66
|
+
# => "my_metric_group_v2"
|
67
|
+
```
|
68
|
+
|
69
|
+
### Updating a metric group:
|
70
|
+
|
71
|
+
Labels, frequency, and units can be updated and additional metrics can be added. All other changes will be ignored.
|
72
|
+
|
73
|
+
```ruby
|
74
|
+
metric_group.name = "this_will_be_ignored"
|
75
|
+
metric_group.label = "My New Metric Group"
|
76
|
+
metric_group.frequency = 5
|
77
|
+
metric_group.metrics << {"type"=>"ce_counter_f", "name"=>"new_metric"}
|
78
|
+
metric_group.save
|
79
|
+
|
80
|
+
metric_group.name
|
81
|
+
# => "my_metric_group"
|
82
|
+
metric_group.label
|
83
|
+
# => "My New Metric Group"
|
84
|
+
metric_group.frequency
|
85
|
+
# => 5
|
86
|
+
```
|
87
|
+
|
88
|
+
### Delete a metric group
|
89
|
+
|
90
|
+
```ruby
|
91
|
+
metric_group.delete
|
92
|
+
```
|
93
|
+
|
94
|
+
|
58
95
|
### Post samples for a metric group
|
59
96
|
|
60
97
|
```ruby
|
@@ -82,37 +119,45 @@ By default, the dashboard created will be named "_MetricGroupLabel_ Dashboard" a
|
|
82
119
|
|
83
120
|
```ruby
|
84
121
|
# Creates a dashboard named "My Metric Group Dashboard"
|
85
|
-
CopperEgg::CustomDashboard.create(metric_group)
|
122
|
+
dashboard = CopperEgg::CustomDashboard.create(metric_group)
|
86
123
|
```
|
87
124
|
|
88
125
|
You can pass an option to specify the name of the dashboard.
|
89
126
|
|
90
127
|
```ruby
|
91
|
-
CopperEgg::CustomDashboard.create(metric_group, :name => "Cloud Servers")
|
128
|
+
dashboard = CopperEgg::CustomDashboard.create(metric_group, :name => "Cloud Servers")
|
92
129
|
```
|
93
130
|
|
94
131
|
If a single identifier is specified, the dashboard will be created having one value widget per metric matching the single identifier.
|
95
132
|
|
96
133
|
```ruby
|
97
|
-
CopperEgg::CustomDashboard.create(metric_group, :name => "Cloud Servers", :identifiers => "custom_identifier1")
|
134
|
+
dashboard = CopperEgg::CustomDashboard.create(metric_group, :name => "Cloud Servers", :identifiers => "custom_identifier1")
|
98
135
|
```
|
99
136
|
|
100
137
|
If an array of identifiers is specified, the dashboard will be created having one timeline widget per metric matching each identifier.
|
101
138
|
|
102
139
|
```ruby
|
103
|
-
CopperEgg::CustomDashboard.create(metric_group, :name => "Cloud Servers", :identifiers => ["custom_identifier1", "custom_identifier2"])
|
140
|
+
dashboard = CopperEgg::CustomDashboard.create(metric_group, :name => "Cloud Servers", :identifiers => ["custom_identifier1", "custom_identifier2"])
|
104
141
|
```
|
105
142
|
|
106
|
-
You can limit the widgets created by
|
143
|
+
You can limit the widgets created by metric.
|
107
144
|
|
108
145
|
```ruby
|
109
|
-
CopperEgg::CustomDashboard.create(metric_group, :name => "Cloud Servers", :identifiers => ["custom_identifier1", "custom_identifier2"], :metrics => ["reading", "writing", "waiting"])
|
146
|
+
dashboard = CopperEgg::CustomDashboard.create(metric_group, :name => "Cloud Servers", :identifiers => ["custom_identifier1", "custom_identifier2"], :metrics => ["reading", "writing", "waiting"])
|
110
147
|
```
|
111
148
|
|
112
149
|
### Get a dashboard
|
113
150
|
|
114
151
|
```ruby
|
115
|
-
CopperEgg::CustomDashboard.find_by_name("My Metric Group Dashboard")
|
152
|
+
dashboard = CopperEgg::CustomDashboard.find_by_name("My Metric Group Dashboard")
|
153
|
+
```
|
154
|
+
|
155
|
+
### Delete a dashboard
|
156
|
+
|
157
|
+
Dashboards can be deleted like metric groups:
|
158
|
+
|
159
|
+
```ruby
|
160
|
+
dashboard.delete
|
116
161
|
```
|
117
162
|
|
118
163
|
## Questions / Problems?
|
@@ -122,7 +167,7 @@ There are more detailed examples in the [test classes][test_classes].
|
|
122
167
|
Full [API docs][docs] are available.
|
123
168
|
|
124
169
|
[sample_docs]:http://dev.copperegg.com/revealmetrics/samples.html
|
125
|
-
[test_classes]:https://github.com/copperegg/copperegg-ruby/tree/
|
170
|
+
[test_classes]:https://github.com/copperegg/copperegg-ruby/tree/develop/test
|
126
171
|
[docs]:http://dev.copperegg.com
|
127
172
|
|
128
173
|
## Copyright
|
File without changes
|
data/copperegg.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
|
|
9
9
|
s.description = 'Library for using the CopperEgg REST API'
|
10
10
|
s.summary = 'Library for using the CopperEgg REST API'
|
11
11
|
s.homepage = 'http://github.com/copperegg/copperegg-ruby'
|
12
|
-
s.license = '
|
12
|
+
s.license = 'MIT'
|
13
13
|
|
14
14
|
s.platform = Gem::Platform::RUBY
|
15
15
|
s.require_paths = %w[lib]
|
@@ -10,10 +10,6 @@ module CopperEgg
|
|
10
10
|
|
11
11
|
attr_accessor :name, :label, :data
|
12
12
|
|
13
|
-
def initialize(attributes={})
|
14
|
-
load_attributes(attributes)
|
15
|
-
end
|
16
|
-
|
17
13
|
def load_attributes(attributes)
|
18
14
|
@data = {"widgets" => {}, "order" => []}
|
19
15
|
attributes.each do |name, value|
|
@@ -50,8 +46,6 @@ module CopperEgg
|
|
50
46
|
@error = "Invalid widget match #{value}."
|
51
47
|
elsif key.to_s == "metric" && (!value.is_a?(Hash) || value.keys.size == 0)
|
52
48
|
@error = "Invalid widget metric. #{value}"
|
53
|
-
elsif key.to_s == "match_param" && (widget["match"] || widget[:match]) != "all" && (value.nil? || value.to_s.strip.empty?)
|
54
|
-
@error = "Missing match parameter."
|
55
49
|
else
|
56
50
|
(widget["metric"] || widget[:metric]).each do |metric_group_name, metric_group_value|
|
57
51
|
if !metric_group_value.is_a?(Array)
|
@@ -72,6 +66,10 @@ module CopperEgg
|
|
72
66
|
end
|
73
67
|
end
|
74
68
|
end
|
69
|
+
match_param = widget["match_param"] || widget[:match_param]
|
70
|
+
if (widget["match"] || widget[:match]) != "all" && (match_param.nil? || match_param.to_s.strip.empty?)
|
71
|
+
@error = "Missing match parameter."
|
72
|
+
end
|
75
73
|
break if !@error.nil?
|
76
74
|
end
|
77
75
|
end
|
@@ -6,10 +6,6 @@ module CopperEgg
|
|
6
6
|
|
7
7
|
attr_accessor :name, :label, :frequency, :metrics
|
8
8
|
|
9
|
-
def initialize(attributes={})
|
10
|
-
load_attributes(attributes)
|
11
|
-
end
|
12
|
-
|
13
9
|
def load_attributes(attributes)
|
14
10
|
@metrics = []
|
15
11
|
attributes.each do |name, value|
|
@@ -96,7 +92,7 @@ module CopperEgg
|
|
96
92
|
elsif self.type.nil? || self.type.to_s.strip.empty?
|
97
93
|
@error = "Metric type must be defined."
|
98
94
|
elsif !TYPES.include?(self.type)
|
99
|
-
|
95
|
+
@error = "Invalid metric type #{self.type}."
|
100
96
|
else
|
101
97
|
valid = true
|
102
98
|
remove_instance_variable(:@error)
|
@@ -13,9 +13,11 @@ module CopperEgg
|
|
13
13
|
id = args.first
|
14
14
|
response = request(params.merge(:request_type => "get", :id => id))
|
15
15
|
if response && response.is_a?(Array)
|
16
|
-
response.map
|
16
|
+
response.map do |resp|
|
17
|
+
new JSON.parse(resp.body)
|
18
|
+
end
|
17
19
|
elsif response
|
18
|
-
new(response)
|
20
|
+
new JSON.parse(response.body)
|
19
21
|
end
|
20
22
|
end
|
21
23
|
|
@@ -45,23 +47,13 @@ module CopperEgg
|
|
45
47
|
request.basic_auth(Api.apikey, "U")
|
46
48
|
request["Content-Type"] = "application/json"
|
47
49
|
|
48
|
-
connect_try_count = 0
|
49
|
-
response = nil
|
50
50
|
begin
|
51
51
|
response = http.request(request)
|
52
52
|
rescue Exception => e
|
53
|
-
|
54
|
-
if connect_try_count > 1
|
55
|
-
log "#{e.inspect}"
|
56
|
-
raise e
|
57
|
-
end
|
58
|
-
sleep 0.5
|
59
|
-
retry
|
53
|
+
raise e
|
60
54
|
end
|
61
55
|
|
62
|
-
|
63
|
-
|
64
|
-
JSON.parse(response.body)
|
56
|
+
response
|
65
57
|
end
|
66
58
|
|
67
59
|
private
|
@@ -73,12 +65,21 @@ module CopperEgg
|
|
73
65
|
end
|
74
66
|
end
|
75
67
|
|
76
|
-
attr_reader :id
|
68
|
+
attr_reader :id, :error
|
69
|
+
|
70
|
+
def initialize(attributes={})
|
71
|
+
load_attributes(attributes)
|
72
|
+
end
|
77
73
|
|
78
74
|
def save
|
79
75
|
if valid?
|
80
|
-
|
81
|
-
|
76
|
+
response = persisted? ? update : create
|
77
|
+
attributes = JSON.parse(response.body)
|
78
|
+
if response.code != "200"
|
79
|
+
@error = attributes.merge("code" => response.code)
|
80
|
+
else
|
81
|
+
load_attributes(attributes)
|
82
|
+
end
|
82
83
|
else
|
83
84
|
raise ValidationError.new(@error)
|
84
85
|
end
|
data/lib/copperegg/ver.rb
CHANGED
@@ -18,7 +18,7 @@ class CustomDashboardTest < Test::Unit::TestCase
|
|
18
18
|
|
19
19
|
def test_save_should_fail_for_an_invalid_widget_type
|
20
20
|
dashboard = CopperEgg::CustomDashboard.new(:name => "My Dashboard")
|
21
|
-
dashboard.data
|
21
|
+
dashboard.data["widgets"]["0"] = {:type => "foo", :style => "value", :match => "tag", :match_param => ["test"],
|
22
22
|
:metric => {"my_metric_group" => [[0, "metric1"]]}}
|
23
23
|
|
24
24
|
error = assert_raise(CopperEgg::ValidationError) { dashboard.save }
|
@@ -27,7 +27,7 @@ class CustomDashboardTest < Test::Unit::TestCase
|
|
27
27
|
|
28
28
|
def test_save_should_fail_for_an_invalid_widget_style
|
29
29
|
dashboard = CopperEgg::CustomDashboard.new(:name => "My Dashboard")
|
30
|
-
dashboard.data
|
30
|
+
dashboard.data["widgets"]["0"] = {:type => "metric", :style => "foo", :match => "tag", :match_param => ["test"],
|
31
31
|
:metric => {"my_metric_group" => [[0, "metric1"]]}}
|
32
32
|
|
33
33
|
error = assert_raise(CopperEgg::ValidationError) { dashboard.save }
|
@@ -36,7 +36,7 @@ class CustomDashboardTest < Test::Unit::TestCase
|
|
36
36
|
|
37
37
|
def test_save_should_ail_for_an_invalidvwidget_match
|
38
38
|
dashboard = CopperEgg::CustomDashboard.new(:name => "My Dashboard")
|
39
|
-
dashboard.data
|
39
|
+
dashboard.data["widgets"]["0"] = {:type => "metric", :style => "value", :match => "foo", :match_param => ["test"],
|
40
40
|
:metric => {"my_metric_group" => [[0, "metric1"]]}}
|
41
41
|
|
42
42
|
error = assert_raise(CopperEgg::ValidationError) { dashboard.save }
|
@@ -45,7 +45,7 @@ class CustomDashboardTest < Test::Unit::TestCase
|
|
45
45
|
|
46
46
|
def test_save_should_fail_for_a_missing_match_parameter
|
47
47
|
dashboard = CopperEgg::CustomDashboard.new(:name => "My Dashboard")
|
48
|
-
dashboard.data
|
48
|
+
dashboard.data["widgets"]["0"] = {:type => "metric", :style => "value", :match => "select", :metric => {"my_metric_group" => [[0, "metric1"]]}}
|
49
49
|
|
50
50
|
error = assert_raise(CopperEgg::ValidationError) { dashboard.save }
|
51
51
|
assert_equal "Missing match parameter.", error.message
|
@@ -53,87 +53,66 @@ class CustomDashboardTest < Test::Unit::TestCase
|
|
53
53
|
|
54
54
|
def test_save_should_fail_if_metric_is_not_a_hash
|
55
55
|
dashboard = CopperEgg::CustomDashboard.new(:name => "My Dashboard")
|
56
|
-
dashboard.data
|
56
|
+
dashboard.data["widgets"]["0"] = {:type => "metric", :style => "value", :match => "tag", :match_param => ["test"], :metric => ["my_metric_group", 0, "metric1"]}
|
57
57
|
|
58
58
|
error = assert_raise(CopperEgg::ValidationError) { dashboard.save }
|
59
|
-
|
59
|
+
assert_match /invalid widget metric/i, error.message
|
60
60
|
end
|
61
61
|
|
62
62
|
def test_save_should_fail_if_metric_does_not_contain_an_array
|
63
63
|
dashboard = CopperEgg::CustomDashboard.new(:name => "My Dashboard")
|
64
|
-
dashboard.data
|
64
|
+
dashboard.data["widgets"]["0"] = {:type => "metric", :style => "value", :match => "tag", :match_param => ["test"], :metric => {"my_metric_group" => "metric1"}}
|
65
65
|
|
66
66
|
error = assert_raise(CopperEgg::ValidationError) { dashboard.save }
|
67
|
-
|
67
|
+
assert_match /invalid widget metric/i, error.message
|
68
68
|
end
|
69
69
|
|
70
70
|
def test_save_should_fail_if_metric_contains_an_empty_array
|
71
71
|
dashboard = CopperEgg::CustomDashboard.new(:name => "My Dashboard")
|
72
|
-
dashboard.data
|
72
|
+
dashboard.data["widgets"]["0"] = {:type => "metric", :style => "value", :match => "tag", :match_param => ["test"], :metric => {"my_metric_group" => []}}
|
73
73
|
|
74
74
|
error = assert_raise(CopperEgg::ValidationError) { dashboard.save }
|
75
|
-
|
75
|
+
assert_match /invalid widget metric/i, error.message
|
76
76
|
end
|
77
77
|
|
78
78
|
def test_save_should_fail_if_metric_contains_an_array_with_invalid_values
|
79
79
|
dashboard = CopperEgg::CustomDashboard.new(:name => "My Dashboard")
|
80
|
-
dashboard.data
|
80
|
+
dashboard.data["widgets"]["0"] = {:type => "metric", :style => "value", :match => "tag", :match_param => ["test"], :metric => {"my_metric_group" => ["metric1"]}}
|
81
81
|
|
82
82
|
error = assert_raise(CopperEgg::ValidationError) { dashboard.save }
|
83
|
-
|
83
|
+
assert_match /invalid widget metric/i, error.message
|
84
84
|
end
|
85
85
|
|
86
86
|
def test_save_should_fail_if_metric_contains_an_array_with_an_invalid_position
|
87
87
|
dashboard = CopperEgg::CustomDashboard.new(:name => "My Dashboard")
|
88
|
-
dashboard.data
|
88
|
+
dashboard.data["widgets"]["0"] = {:type => "metric", :style => "value", :match => "tag", :match_param => ["test"], :metric => {"my_metric_group" => [["four", "metric1"]]}}
|
89
89
|
|
90
90
|
error = assert_raise(CopperEgg::ValidationError) { dashboard.save }
|
91
|
-
|
91
|
+
assert_match /invalid widget metric/i, error.message
|
92
92
|
end
|
93
93
|
|
94
94
|
def test_save_should_fail_if_metric_contains_an_array_with_no_metric_name
|
95
95
|
dashboard = CopperEgg::CustomDashboard.new(:name => "My Dashboard")
|
96
|
-
dashboard.data
|
96
|
+
dashboard.data["widgets"]["0"] = {:type => "metric", :style => "value", :match => "tag", :match_param => ["test"], :metric => {"my_metric_group" => [[0]]}}
|
97
97
|
|
98
98
|
error = assert_raise(CopperEgg::ValidationError) { dashboard.save }
|
99
|
-
|
99
|
+
assert_match /invalid widget metric/i, error.message
|
100
100
|
end
|
101
101
|
|
102
|
-
# def test_save_should_save_a_valid_dashboard
|
103
|
-
# CopperEgg::Api.apikey = "testapikey"
|
104
|
-
|
105
|
-
# request_headers = {
|
106
|
-
# 'Authorization' => "Basic #{Base64.encode64("testapikey:").gsub("\n",'')}",
|
107
|
-
# 'Content-Type' => 'application/json'
|
108
|
-
# }
|
109
|
-
|
110
|
-
# response_body = {:id => 1, :name => "My Dashboard", :data => {:widgets => [{:type => "metric", :style => "value", :match => "tag", :match_param => ["test"]}]},
|
111
|
-
# :order => ["0"]}
|
112
|
-
|
113
|
-
# ActiveResource::HttpMock.respond_to do |mock|
|
114
|
-
# mock.post "/v2/revealmetrics/dashboards.json", request_headers, {}, 200
|
115
|
-
# end
|
116
|
-
|
117
|
-
# dashboard = CopperEgg::CustomDashboard.new(:name => "My Dashboard")
|
118
|
-
# dashboard.data.widgets["0"] = {:type => "metric", :style => "value", :match => "tag", :match_param => ["test"], :metric => {"my_metric_group" => [[1, "metric1"]]}}
|
119
|
-
|
120
|
-
# assert dashboard.save
|
121
|
-
# end
|
122
|
-
|
123
102
|
def test_to_hash
|
124
103
|
dashboard = CopperEgg::CustomDashboard.new(:name => "My Dashboard")
|
125
|
-
dashboard.data
|
104
|
+
dashboard.data["widgets"]["0"] = {:type => "metric", :style => "value", :match => "tag", :match_param => ["test"], :metric => {"my_metric_group" => [[1, "metric1"]]}}
|
126
105
|
|
127
106
|
assert dashboard.valid?
|
128
107
|
|
129
108
|
hash = dashboard.to_hash
|
130
109
|
|
131
110
|
assert_equal "My Dashboard", hash["name"]
|
132
|
-
assert_equal "metric", hash["data"]["widgets"]["0"][
|
133
|
-
assert_equal "value", hash["data"]["widgets"]["0"][
|
134
|
-
assert_equal "tag", hash["data"]["widgets"]["0"][
|
135
|
-
assert_equal ["test"], hash["data"]["widgets"]["0"][
|
136
|
-
assert_equal [[1, "metric1"]], hash["data"]["widgets"]["0"][
|
111
|
+
assert_equal "metric", hash["data"]["widgets"]["0"][:type]
|
112
|
+
assert_equal "value", hash["data"]["widgets"]["0"][:style]
|
113
|
+
assert_equal "tag", hash["data"]["widgets"]["0"][:match]
|
114
|
+
assert_equal ["test"], hash["data"]["widgets"]["0"][:match_param]
|
115
|
+
assert_equal [[1, "metric1"]], hash["data"]["widgets"]["0"][:metric]["my_metric_group"]
|
137
116
|
end
|
138
117
|
|
139
118
|
end
|
data/test/metric_group_test.rb
CHANGED
@@ -30,34 +30,13 @@ class MetricGroupTest < Test::Unit::TestCase
|
|
30
30
|
assert_equal "Metric expected.", error.message
|
31
31
|
end
|
32
32
|
|
33
|
-
def
|
33
|
+
def test_save_should_fail_for_invalid_metric
|
34
34
|
metric_group = CopperEgg::MetricGroup.new(:name => "my_metric_group", :metrics => [{:name => "test", :type => "invalid"}])
|
35
35
|
|
36
36
|
error = assert_raise(CopperEgg::ValidationError) { metric_group.save }
|
37
37
|
assert_equal "Invalid metric type invalid.", error.message
|
38
38
|
end
|
39
39
|
|
40
|
-
# def test_save_should_retrieve_versioned_name_of_metric_group
|
41
|
-
# CopperEgg::Api.apikey = "testapikey"
|
42
|
-
|
43
|
-
# request_headers = {
|
44
|
-
# 'Authorization' => "Basic #{Base64.encode64("testapikey:").gsub("\n",'')}",
|
45
|
-
# 'Content-Type' => 'application/json'
|
46
|
-
# }
|
47
|
-
# response_body = {:id => "test_v2", :name => "test_v2", :label => "Test", :frequency => 5, :metrics => [{:name => "test", :type => "ce_counter", :position => 0}]}
|
48
|
-
|
49
|
-
# ActiveResource::HttpMock.respond_to do |mock|
|
50
|
-
# mock.post "/v2/revealmetrics/metric_groups.json", request_headers, response_body.to_json, 200
|
51
|
-
# end
|
52
|
-
|
53
|
-
# metric_group = CopperEgg::MetricGroup.new(:name => "test", :frequency => 5, :metrics => [{:name => "test", :type => "ce_counter"}])
|
54
|
-
|
55
|
-
# metric_group.save
|
56
|
-
|
57
|
-
# assert_equal "test_v2", metric_group.id
|
58
|
-
# assert_equal "test_v2", metric_group.name
|
59
|
-
# end
|
60
|
-
|
61
40
|
def test_to_hash
|
62
41
|
metric_group = CopperEgg::MetricGroup.new(:name => "test", :label => "Test Metric", :frequency => 5)
|
63
42
|
metric_group.metrics << {:type => "ce_counter", :name => "metric1", :label => "Metric 1", :unit => "ticks"}
|
data/test/metric_sample_test.rb
CHANGED
@@ -2,35 +2,5 @@ require "test/unit"
|
|
2
2
|
require "copperegg"
|
3
3
|
|
4
4
|
class MetricSampleTest < Test::Unit::TestCase
|
5
|
-
|
6
|
-
# def test_save_should_post_a_sample
|
7
|
-
# CopperEgg::Api.apikey = "testapikey"
|
8
|
-
# request_headers = {
|
9
|
-
# 'Authorization' => "Basic #{Base64.encode64("testapikey:").gsub("\n",'')}",
|
10
|
-
# 'Content-Type' => 'application/json'
|
11
|
-
# }
|
12
|
-
|
13
|
-
# ActiveResource::HttpMock.respond_to do |mock|
|
14
|
-
# mock.post "/v2/revealmetrics/samples//test.json", request_headers, {}, 200
|
15
|
-
# end
|
16
|
-
|
17
|
-
# CopperEgg::MetricSample.save("test", "custom_object", Time.now.to_i, :key1 => "value1", :key2 => "value2")
|
18
|
-
# end
|
19
|
-
|
20
|
-
# def test_samples_should_return_the_json_response_body_upon_success
|
21
|
-
# CopperEgg::Api.apikey = "testapikey"
|
22
|
-
# request_headers = {
|
23
|
-
# 'Authorization' => "Basic #{Base64.encode64("testapikey:").gsub("\n",'')}",
|
24
|
-
# 'Accept' => 'application/json'
|
25
|
-
# }
|
26
|
-
|
27
|
-
# ActiveResource::HttpMock.respond_to do |mock|
|
28
|
-
# queries = {"queries" => {"metric_group" => [{"metrics" => ["metric1"]}]}}.to_param
|
29
|
-
|
30
|
-
# mock.get "/v2/revealmetrics/samples.json?#{queries}", request_headers, {"_ts" => Time.now.to_i, "object_count" => 0, "values" => {"metric_group" => []}}.to_json, 200
|
31
|
-
# end
|
32
|
-
|
33
|
-
# CopperEgg::MetricSample.samples("metric_group", "metric1")
|
34
|
-
# end
|
35
5
|
|
36
6
|
end
|
metadata
CHANGED
@@ -1,48 +1,40 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: copperegg
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.6.0.pre2
|
5
5
|
prerelease: 6
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 6
|
9
|
-
- 0
|
10
|
-
- pre
|
11
|
-
version: 0.6.0.pre
|
12
6
|
platform: ruby
|
13
|
-
authors:
|
7
|
+
authors:
|
14
8
|
- Eric Anderson
|
15
9
|
autorequire:
|
16
10
|
bindir: bin
|
17
11
|
cert_chain: []
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2013-01-04 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
22
15
|
name: json_pure
|
23
|
-
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
25
17
|
none: false
|
26
|
-
requirements:
|
18
|
+
requirements:
|
27
19
|
- - ~>
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
hash: 7
|
30
|
-
segments:
|
31
|
-
- 1
|
32
|
-
- 7
|
33
|
-
- 6
|
20
|
+
- !ruby/object:Gem::Version
|
34
21
|
version: 1.7.6
|
35
22
|
type: :runtime
|
36
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.7.6
|
37
30
|
description: Library for using the CopperEgg REST API
|
38
31
|
email: anderson@copperegg.com
|
39
32
|
executables: []
|
40
|
-
|
41
33
|
extensions: []
|
42
|
-
|
43
34
|
extra_rdoc_files: []
|
44
|
-
|
45
|
-
|
35
|
+
files:
|
36
|
+
- ./CHANGELOG.md
|
37
|
+
- ./copperegg-0.6.0.pre2.gem
|
46
38
|
- ./copperegg.gemspec
|
47
39
|
- ./Gemfile
|
48
40
|
- ./Gemfile.lock
|
@@ -63,46 +55,37 @@ files:
|
|
63
55
|
- test/metric_group_test.rb
|
64
56
|
- test/metric_sample_test.rb
|
65
57
|
homepage: http://github.com/copperegg/copperegg-ruby
|
66
|
-
licenses:
|
67
|
-
-
|
58
|
+
licenses:
|
59
|
+
- MIT
|
68
60
|
post_install_message:
|
69
|
-
rdoc_options:
|
61
|
+
rdoc_options:
|
70
62
|
- --line-numbers
|
71
63
|
- --inline-source
|
72
64
|
- --title
|
73
65
|
- copperegg-ruby
|
74
66
|
- --main
|
75
67
|
- README.md
|
76
|
-
require_paths:
|
68
|
+
require_paths:
|
77
69
|
- lib
|
78
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
79
71
|
none: false
|
80
|
-
requirements:
|
81
|
-
- -
|
82
|
-
- !ruby/object:Gem::Version
|
83
|
-
|
84
|
-
|
85
|
-
- 0
|
86
|
-
version: "0"
|
87
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ! '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
77
|
none: false
|
89
|
-
requirements:
|
90
|
-
- -
|
91
|
-
- !ruby/object:Gem::Version
|
92
|
-
hash: 25
|
93
|
-
segments:
|
94
|
-
- 1
|
95
|
-
- 3
|
96
|
-
- 1
|
78
|
+
requirements:
|
79
|
+
- - ! '>'
|
80
|
+
- !ruby/object:Gem::Version
|
97
81
|
version: 1.3.1
|
98
82
|
requirements: []
|
99
|
-
|
100
83
|
rubyforge_project:
|
101
84
|
rubygems_version: 1.8.24
|
102
85
|
signing_key:
|
103
86
|
specification_version: 3
|
104
87
|
summary: Library for using the CopperEgg REST API
|
105
|
-
test_files:
|
88
|
+
test_files:
|
106
89
|
- test/custom_dashboard_test.rb
|
107
90
|
- test/metric_group_test.rb
|
108
91
|
- test/metric_sample_test.rb
|