tronprint 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/tronprint.rb +1 -1
- data/lib/tronprint/app.rb +2 -0
- data/lib/tronprint/rails.rb +1 -1
- data/lib/tronprint/traffic_monitor.rb +7 -5
- data/lib/tronprint/version.rb +1 -1
- data/spec/tronprint/traffic_monitor_spec.rb +11 -1
- metadata +25 -25
data/lib/tronprint.rb
CHANGED
@@ -100,7 +100,7 @@ module Tronprint
|
|
100
100
|
|
101
101
|
# The Tronprint::TrafficMonitor instance
|
102
102
|
def traffic_monitor
|
103
|
-
@traffic_monitor ||= TrafficMonitor.new
|
103
|
+
@traffic_monitor ||= TrafficMonitor.new application_name
|
104
104
|
end
|
105
105
|
|
106
106
|
# The Tronprint::Statistics interface
|
data/lib/tronprint/app.rb
CHANGED
data/lib/tronprint/rails.rb
CHANGED
@@ -12,7 +12,7 @@ module Tronprint
|
|
12
12
|
end
|
13
13
|
|
14
14
|
config.after_initialize do
|
15
|
-
if Tronprint.aggregator.adapter == 'active_record' && !Moneta::Adapters::ActiveRecord::Store.table_exists?
|
15
|
+
if Tronprint.aggregator && Tronprint.aggregator.adapter == 'active_record' && !Moneta::Adapters::ActiveRecord::Store.table_exists?
|
16
16
|
Tronprint.aggregator.migrate
|
17
17
|
end
|
18
18
|
Tronprint.run
|
@@ -1,17 +1,19 @@
|
|
1
1
|
module Tronprint
|
2
2
|
|
3
|
-
# Tronprint::
|
3
|
+
# Tronprint::TrafficMonitor counts app requests
|
4
4
|
class TrafficMonitor
|
5
5
|
attr_accessor :aggregator, :application_name
|
6
6
|
|
7
7
|
# Parameters:
|
8
|
-
# +aggregator+:: A Tronprint::Aggregator instance.
|
9
8
|
# +application_name+:: A unique application name.
|
10
|
-
def initialize(
|
11
|
-
self.aggregator = aggregator
|
9
|
+
def initialize(application_name)
|
12
10
|
self.application_name = application_name
|
13
11
|
end
|
14
12
|
|
13
|
+
def aggregator
|
14
|
+
Tronprint.aggregator
|
15
|
+
end
|
16
|
+
|
15
17
|
# The key used to store number of requests in the Aggregator.
|
16
18
|
def key
|
17
19
|
[application_name, 'requests'].join('/')
|
@@ -19,7 +21,7 @@ module Tronprint
|
|
19
21
|
|
20
22
|
# Increment the total number of requests
|
21
23
|
def increment
|
22
|
-
aggregator.update key, 1
|
24
|
+
aggregator.update key, 1 if aggregator
|
23
25
|
end
|
24
26
|
|
25
27
|
def requests
|
data/lib/tronprint/version.rb
CHANGED
@@ -3,7 +3,11 @@ require 'timecop'
|
|
3
3
|
|
4
4
|
describe Tronprint::TrafficMonitor do
|
5
5
|
let(:aggregator) { Tronprint::Aggregator.new :adapter => :memory }
|
6
|
-
let(:traffic_monitor) { Tronprint::TrafficMonitor.new
|
6
|
+
let(:traffic_monitor) { Tronprint::TrafficMonitor.new 'my_app' }
|
7
|
+
|
8
|
+
before :each do
|
9
|
+
traffic_monitor.stub!(:aggregator).and_return(aggregator)
|
10
|
+
end
|
7
11
|
|
8
12
|
describe '#increment' do
|
9
13
|
it 'increments the user count for each time slice' do
|
@@ -23,6 +27,12 @@ describe Tronprint::TrafficMonitor do
|
|
23
27
|
traffic_monitor.increment
|
24
28
|
traffic_monitor.requests.should == 2
|
25
29
|
end
|
30
|
+
it 'does nothing if no aggregator is available' do
|
31
|
+
traffic_monitor.stub!(:aggregator)
|
32
|
+
expect do
|
33
|
+
traffic_monitor.increment
|
34
|
+
end.should_not raise_error
|
35
|
+
end
|
26
36
|
end
|
27
37
|
|
28
38
|
describe '#requests' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tronprint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-07-20 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: actionpack
|
16
|
-
requirement: &
|
16
|
+
requirement: &2164404220 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '3'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2164404220
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: activesupport
|
27
|
-
requirement: &
|
27
|
+
requirement: &2164403720 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '3'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2164403720
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: cucumber
|
38
|
-
requirement: &
|
38
|
+
requirement: &2164403340 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2164403340
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: bueller
|
49
|
-
requirement: &
|
49
|
+
requirement: &2164402780 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 0.0.2
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2164402780
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rake
|
60
|
-
requirement: &
|
60
|
+
requirement: &2164402360 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *2164402360
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec
|
71
|
-
requirement: &
|
71
|
+
requirement: &2164401820 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '2.0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *2164401820
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: sandbox
|
82
|
-
requirement: &
|
82
|
+
requirement: &2164401400 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *2164401400
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: timecop
|
93
|
-
requirement: &
|
93
|
+
requirement: &2164400940 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ! '>='
|
@@ -98,10 +98,10 @@ dependencies:
|
|
98
98
|
version: '0'
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *2164400940
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: carbon
|
104
|
-
requirement: &
|
104
|
+
requirement: &2164400440 !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
107
|
- - ~>
|
@@ -109,10 +109,10 @@ dependencies:
|
|
109
109
|
version: 1.1.1
|
110
110
|
type: :runtime
|
111
111
|
prerelease: false
|
112
|
-
version_requirements: *
|
112
|
+
version_requirements: *2164400440
|
113
113
|
- !ruby/object:Gem::Dependency
|
114
114
|
name: i18n
|
115
|
-
requirement: &
|
115
|
+
requirement: &2164400000 !ruby/object:Gem::Requirement
|
116
116
|
none: false
|
117
117
|
requirements:
|
118
118
|
- - ! '>='
|
@@ -120,10 +120,10 @@ dependencies:
|
|
120
120
|
version: '0'
|
121
121
|
type: :runtime
|
122
122
|
prerelease: false
|
123
|
-
version_requirements: *
|
123
|
+
version_requirements: *2164400000
|
124
124
|
- !ruby/object:Gem::Dependency
|
125
125
|
name: dkastner-moneta
|
126
|
-
requirement: &
|
126
|
+
requirement: &2164399460 !ruby/object:Gem::Requirement
|
127
127
|
none: false
|
128
128
|
requirements:
|
129
129
|
- - ~>
|
@@ -131,7 +131,7 @@ dependencies:
|
|
131
131
|
version: 1.1.1
|
132
132
|
type: :runtime
|
133
133
|
prerelease: false
|
134
|
-
version_requirements: *
|
134
|
+
version_requirements: *2164399460
|
135
135
|
description: A gem for monitoring the carbon footprint of your ruby app
|
136
136
|
email: dkastner@gmail.com
|
137
137
|
executables: []
|
@@ -188,7 +188,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
188
188
|
version: '0'
|
189
189
|
segments:
|
190
190
|
- 0
|
191
|
-
hash: -
|
191
|
+
hash: -2483952378864654912
|
192
192
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
193
193
|
none: false
|
194
194
|
requirements:
|
@@ -197,7 +197,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
197
197
|
version: '0'
|
198
198
|
segments:
|
199
199
|
- 0
|
200
|
-
hash: -
|
200
|
+
hash: -2483952378864654912
|
201
201
|
requirements: []
|
202
202
|
rubyforge_project:
|
203
203
|
rubygems_version: 1.8.5
|