restful_metrics 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/restful_metrics/connection.rb +1 -1
- data/lib/restful_metrics/log_tools.rb +5 -5
- data/spec/client_spec.rb +20 -35
- metadata +17 -17
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.1.
|
1
|
+
1.1.2
|
@@ -3,20 +3,20 @@ unless defined?(Logger)
|
|
3
3
|
end
|
4
4
|
|
5
5
|
module RestfulMetrics
|
6
|
-
|
6
|
+
|
7
7
|
module LogTools
|
8
|
-
|
8
|
+
|
9
9
|
def logger(msg, level = :warn)
|
10
|
-
msg = "####
|
10
|
+
msg = "#### RESTful Metrics #### " + msg
|
11
11
|
if defined?(Rails) && defined?(Rails.logger)
|
12
12
|
log = Rails.logger
|
13
13
|
else
|
14
14
|
log = Logger.new(STDOUT)
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
level == :warn ? log.warn(msg) : log.info(msg)
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
end
|
21
21
|
|
22
22
|
end
|
data/spec/client_spec.rb
CHANGED
@@ -61,45 +61,44 @@ end
|
|
61
61
|
|
62
62
|
describe "An initialized RESTful Metrics client" do
|
63
63
|
|
64
|
+
class SampleRequest
|
65
|
+
|
66
|
+
def body
|
67
|
+
'{ "test": "success" }'
|
68
|
+
end
|
69
|
+
|
70
|
+
def code
|
71
|
+
200
|
72
|
+
end
|
73
|
+
|
74
|
+
def header
|
75
|
+
{ "one" => "test", "two" => "test" }
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
|
64
80
|
before(:each) do
|
65
81
|
@connection = RestfulMetrics::Connection
|
66
82
|
RestfulMetrics::Client.set_credentials('xyz123')
|
67
83
|
RestfulMetrics::Client.disabled = false
|
84
|
+
RestClient::Request.any_instance.stubs(:execute).returns(SampleRequest.new)
|
85
|
+
Logger.any_instance.stubs(:warn).returns("") # disable output
|
68
86
|
Delayed::Job.delete_all
|
69
87
|
end
|
70
88
|
|
71
89
|
describe "in debug mode" do
|
72
90
|
|
73
|
-
class SampleRequest
|
74
|
-
|
75
|
-
def body
|
76
|
-
'{ "test": "success" }'
|
77
|
-
end
|
78
|
-
|
79
|
-
def code
|
80
|
-
200
|
81
|
-
end
|
82
|
-
|
83
|
-
def header
|
84
|
-
{ "one" => "test", "two" => "test" }
|
85
|
-
end
|
86
|
-
|
87
|
-
end
|
88
|
-
|
89
91
|
before(:all) do
|
90
92
|
RestfulMetrics::Client.debug = true
|
91
93
|
RestfulMetrics::Client.debug?.should be_true
|
94
|
+
RestfulMetrics::Connection.any_instance.expects(:logger).at_least_once.returns("")
|
92
95
|
end
|
93
96
|
|
94
97
|
it "should send a metric to RESTful Metrics while outputting debug info" do
|
95
|
-
|
96
|
-
@connection.any_instance.expects(:send_request).once.returns(SampleRequest.new)
|
97
|
-
RestfulMetrics::Client.add_metric("foo.bar.org", "hit", 1).should == true
|
98
|
+
RestfulMetrics::Client.add_metric("foo.bar.org", "hit", 1).should be_true
|
98
99
|
end
|
99
100
|
|
100
101
|
it "should send the compound metric to RESTful Metrics while outputting debug info" do
|
101
|
-
@connection.any_instance.expects(:logger).at_least_once
|
102
|
-
@connection.any_instance.expects(:send_request).once.returns(SampleRequest.new)
|
103
102
|
RestfulMetrics::Client.add_compound_metric("foo.bar.org", "hit", [1,2,3]).should be_true
|
104
103
|
end
|
105
104
|
|
@@ -107,10 +106,6 @@ describe "An initialized RESTful Metrics client" do
|
|
107
106
|
|
108
107
|
describe "initializing the client" do
|
109
108
|
|
110
|
-
before(:each) do
|
111
|
-
@connection.any_instance.stubs(:post).returns(true)
|
112
|
-
end
|
113
|
-
|
114
109
|
it "should set the API key" do
|
115
110
|
RestfulMetrics::Client.set_credentials('4ed4ef44e44ed4').should be_true
|
116
111
|
end
|
@@ -124,22 +119,16 @@ describe "An initialized RESTful Metrics client" do
|
|
124
119
|
|
125
120
|
describe "adding metrics synchronously" do
|
126
121
|
|
127
|
-
before(:each) do
|
128
|
-
@connection.any_instance.stubs(:post).returns(true)
|
129
|
-
end
|
130
|
-
|
131
122
|
before(:all) do
|
132
123
|
RestfulMetrics::Client.async = false
|
133
124
|
RestfulMetrics::Client.async?.should be_false
|
134
125
|
end
|
135
126
|
|
136
127
|
it "should send the metric to RESTful Metrics" do
|
137
|
-
@connection.any_instance.expects(:post).at_least_once.returns({})
|
138
128
|
RestfulMetrics::Client.add_metric("foo.bar.org", "hit", 1).should be_true
|
139
129
|
end
|
140
130
|
|
141
131
|
it "should send the compound metric to RESTful Metrics" do
|
142
|
-
@connection.any_instance.expects(:post).at_least_once.returns({})
|
143
132
|
RestfulMetrics::Client.add_compound_metric("foo.bar.org", "hit", [1,2,3]).should be_true
|
144
133
|
end
|
145
134
|
|
@@ -147,10 +136,6 @@ describe "An initialized RESTful Metrics client" do
|
|
147
136
|
|
148
137
|
describe "adding metrics asynchronously" do
|
149
138
|
|
150
|
-
before(:each) do
|
151
|
-
@connection.any_instance.stubs(:post).returns(true)
|
152
|
-
end
|
153
|
-
|
154
139
|
before(:all) do
|
155
140
|
RestfulMetrics::Client.async = true
|
156
141
|
RestfulMetrics::Client.async?.should be_true
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: restful_metrics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-02-28 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: yajl-ruby
|
16
|
-
requirement: &
|
16
|
+
requirement: &70311601479860 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.8.1
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70311601479860
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rest-client
|
27
|
-
requirement: &
|
27
|
+
requirement: &70311601478840 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 1.6.0
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70311601478840
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &70311601494180 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 2.8.0
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70311601494180
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: mocha
|
49
|
-
requirement: &
|
49
|
+
requirement: &70311601493460 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 0.10.4
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70311601493460
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: actionpack
|
60
|
-
requirement: &
|
60
|
+
requirement: &70311601492840 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: 3.0.0
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70311601492840
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rack
|
71
|
-
requirement: &
|
71
|
+
requirement: &70311601492100 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: 1.2.5
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70311601492100
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: activesupport
|
82
|
-
requirement: &
|
82
|
+
requirement: &70311601491380 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ~>
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: 3.0.0
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70311601491380
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: delayed_job
|
93
|
-
requirement: &
|
93
|
+
requirement: &70311601490760 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ~>
|
@@ -98,7 +98,7 @@ dependencies:
|
|
98
98
|
version: 3.0.1
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *70311601490760
|
102
102
|
description: Ruby client for the RESTful Metrics service.
|
103
103
|
email: mauricio@restful-labs.com
|
104
104
|
executables: []
|