pulse_meter_core 0.5.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZTU4NjA3YjM4ZTZiZGQ2NmI1N2RlNTEzMmE3ZDIxZjQ1YzAyN2E0ZA==
5
+ data.tar.gz: !binary |-
6
+ NDZkMjhlYjY1MTdmNTk3YjViYmUwMWYyZDJiMTAxZTZhNGJmNDFkYQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ YmJmYzI0YjZiNzIyNTMzODA2MjNjMjU5MjYyNjRiZGNmMGI1ODU5ZTc0OGNi
10
+ NDQzODkyZDliM2JjMmM4MmYyZGQ1MjlmY2UyNzRjZWVmNDU3NjI4NGZiNTdj
11
+ ZDAzMzliZjMyNzJjNTNjMDNhOTNjYTYwODk0MzQwMmNmNDI2YWY=
12
+ data.tar.gz: !binary |-
13
+ N2IyNTFlYjk3OTMyMjMwODNhMTIyOGNiYjU1MzQxOWU1NGViMTY0ZDA3OGI0
14
+ MjA1MjcyNDg1NTU3MDQ1OGMwOTdmMGRjNGM3NjU0MjllNzE3ZWUzNzdhNDlm
15
+ ZmVmNGE4OWNjNGQ2OTJlZmQxODU4NjFkYmQyM2Q3YzYxOTVkYmQ=
@@ -33,7 +33,7 @@ module PulseMeter
33
33
  # Exception to be raised when sensor name is malformed
34
34
  class BadSensorName < SensorError
35
35
  def initialize(name, options = {})
36
- super("Bad sensor name: `#{name}', only a-z letters and _ are allowed")
36
+ super("Bad sensor name: `#{name}', only a-z letters, @ and _ are allowed")
37
37
  end
38
38
  end
39
39
 
@@ -21,7 +21,7 @@ module PulseMeter
21
21
  if options[:annotation]
22
22
  annotate(options[:annotation])
23
23
  end
24
- raise BadSensorName, @name unless @name =~ /\A\w+\z/
24
+ raise BadSensorName, @name unless @name =~ /\A[\w@]+\z/
25
25
  raise RedisNotInitialized unless PulseMeter.redis
26
26
  dump!
27
27
  end
@@ -15,7 +15,7 @@ Gem::Specification.new do |gem|
15
15
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
16
16
  gem.name = "pulse_meter_core"
17
17
  gem.require_paths = ["lib"]
18
- gem.version = "0.5.2"
18
+ gem.version = "0.5.3"
19
19
 
20
20
  gem.add_runtime_dependency('json')
21
21
  gem.add_runtime_dependency('redis')
@@ -7,8 +7,8 @@ describe PulseMeter::CommandAggregator::Sync do
7
7
  describe "#multi" do
8
8
  it "should accumulate redis command and execute in a bulk" do
9
9
  ca.multi do
10
- ca.set("xxxx", "zzzz").should == "QUEUED"
11
- ca.set("yyyy", "zzzz").should == "QUEUED"
10
+ ca.set("xxxx", "zzzz")
11
+ ca.set("yyyy", "zzzz")
12
12
  end
13
13
  redis.get("xxxx").should == "zzzz"
14
14
  redis.get("yyyy").should == "zzzz"
@@ -3,10 +3,10 @@ require 'spec_helper'
3
3
  describe PulseMeter::CommandAggregator::UDP do
4
4
  let(:host){'127.0.0.1'}
5
5
  let(:port){33333}
6
- let(:udp_sock){mock(:socket)}
7
- before do
8
- UDPSocket.stub!(:new).and_return(udp_sock)
9
- udp_sock.stub!(:fcntl).and_return(nil)
6
+ let(:udp_sock){double(:socket)}
7
+ before do
8
+ UDPSocket.stub(:new).and_return(udp_sock)
9
+ udp_sock.stub(:fcntl).and_return(nil)
10
10
  @ca = described_class.new([[host, port]])
11
11
  end
12
12
 
@@ -54,7 +54,7 @@ describe PulseMeter::Mixins::Dumper do
54
54
 
55
55
  context "when class follows dump contract" do
56
56
  it "should not raise dump exception" do
57
- expect {good_obj.dump!}.not_to raise_exception(PulseMeter::DumpError)
57
+ expect {good_obj.dump!}.not_to raise_exception
58
58
  end
59
59
 
60
60
  it "should save dump to redis" do
@@ -70,7 +70,7 @@ describe PulseMeter::Observer do
70
70
 
71
71
  it "keeps observed methods' errors" do
72
72
  create_observer(:error)
73
- lambda {dummy.error}.should raise_error(RuntimeError)
73
+ lambda {dummy.error}.should raise_error
74
74
  sensor.value.should == 1
75
75
  end
76
76
 
@@ -172,7 +172,7 @@ describe PulseMeter::Observer do
172
172
 
173
173
  it "keeps observed methods' errors" do
174
174
  create_observer(:error)
175
- lambda {dummy.error}.should raise_error(RuntimeError)
175
+ lambda {dummy.error}.should raise_error
176
176
  sensor.value.should == 1
177
177
  end
178
178
 
@@ -26,7 +26,7 @@ describe PulseMeter::Sensor::Base do
26
26
 
27
27
  context 'when passed sensor name is valid' do
28
28
  it "should successfully create object" do
29
- described_class.new(:foo).should_not be_nil
29
+ described_class.new("foo_@").should_not be_nil
30
30
  end
31
31
 
32
32
  it "should initialize attributes #redis and #name" do
@@ -91,14 +91,14 @@ describe PulseMeter::Sensor::Base do
91
91
  describe "#event" do
92
92
  context "when everything is ok" do
93
93
  it "should do nothing and return true" do
94
- sensor.event(nil).should be_true
94
+ sensor.event(nil).should be
95
95
  end
96
96
  end
97
97
 
98
98
  context "when an error occures while processing event" do
99
99
  it "should catch StandardErrors and return false" do
100
100
  sensor.stub(:process_event) {raise StandardError}
101
- sensor.event(nil).should be_false
101
+ sensor.event(nil).should_not be
102
102
  end
103
103
  end
104
104
  end
@@ -16,9 +16,9 @@ describe PulseMeter::Sensor::Configuration do
16
16
  let(:cfg) {described_class.new}
17
17
 
18
18
  it "should create sensor available under passed name" do
19
- cfg.has_sensor?(:foo).should be_false
19
+ cfg.has_sensor?(:foo).should_not be
20
20
  cfg.add_sensor(:foo, sensor_type: 'counter')
21
- cfg.has_sensor?(:foo).should_not be_true
21
+ cfg.has_sensor?(:foo).should_not be
22
22
  end
23
23
 
24
24
  it "should have event shortcut for the sensor" do
@@ -129,7 +129,7 @@ describe PulseMeter::Sensor::Multi do
129
129
  it "does not yields block" do
130
130
  yielded = false
131
131
  sensor.sensor_for_factors([:foo], [:bar]){ yielded = true }
132
- yielded.should be_false
132
+ yielded.should_not be
133
133
  end
134
134
  end
135
135
  end
@@ -43,7 +43,7 @@ describe PulseMeter::Sensor::Timeline do
43
43
  it "should not raise exception if #{value.inspect} is not defined" do
44
44
  values = good_init_values
45
45
  values.delete(value)
46
- expect {described_class.new(name, good_init_values)}.not_to raise_exception(ArgumentError)
46
+ expect {described_class.new(name, good_init_values)}.not_to raise_error
47
47
  end
48
48
 
49
49
  it "should assign default value to #{value.inspect} if it is not defined" do
@@ -9,13 +9,13 @@ describe PulseMeter::Sensor::Timelined::MultiPercentile do
9
9
  let(:name) {"percentile"}
10
10
 
11
11
  it "should raise exception when extra parameter is not array of percentiles" do
12
- expect {described_class.new(name, init_values.merge({:p => :bad}))}.to raise_exception(ArgumentError)
12
+ expect {described_class.new(name, init_values.merge({:p => :bad}))}.to raise_exception(ArgumentError)
13
13
  end
14
14
 
15
15
  it "should raise exception when one of percentiles is not between 0 and 1" do
16
- expect {described_class.new(name, init_values.merge({:p => [0.5, -1]}))}.to raise_exception(ArgumentError)
17
- expect {described_class.new(name, init_values.merge({:p => [0.5, 1.1]}))}.to raise_exception(ArgumentError)
18
- expect {described_class.new(name, init_values.merge({:p => [0.5, 0.1]}))}.not_to raise_exception(ArgumentError)
16
+ expect {described_class.new(name, init_values.merge({:p => [0.5, -1]}))}.to raise_exception(ArgumentError)
17
+ expect {described_class.new(name, init_values.merge({:p => [0.5, 1.1]}))}.to raise_exception(ArgumentError)
18
+ expect {described_class.new(name, init_values.merge({:p => [0.5, 0.1]}))}.not_to raise_exception
19
19
  end
20
20
 
21
21
  end
@@ -4,14 +4,14 @@ describe PulseMeter::Sensor::Timelined::Percentile do
4
4
  it_should_behave_like "timeline sensor", {:p => 0.8}
5
5
  it_should_behave_like "timelined subclass", [5, 4, 2, 2, 2, 2, 2, 2, 2, 1], 2, {:p => 0.8}
6
6
  it_should_behave_like "timelined subclass", [1], 1, {:p => 0.8}
7
-
7
+
8
8
  let(:init_values) {{:ttl => 1, :raw_data_ttl => 1, :interval => 1, :reduce_delay => 1}}
9
9
  let(:name) {"percentile"}
10
10
 
11
11
  it "should raise exception when percentile is not between 0 and 1" do
12
- expect {described_class.new(name, init_values.merge({:p => -1}))}.to raise_exception(ArgumentError)
13
- expect {described_class.new(name, init_values.merge({:p => 1.1}))}.to raise_exception(ArgumentError)
14
- expect {described_class.new(name, init_values.merge({:p => 0.1}))}.not_to raise_exception(ArgumentError)
12
+ expect {described_class.new(name, init_values.merge({:p => -1}))}.to raise_exception(ArgumentError)
13
+ expect {described_class.new(name, init_values.merge({:p => 1.1}))}.to raise_exception(ArgumentError)
14
+ expect {described_class.new(name, init_values.merge({:p => 0.1}))}.not_to raise_exception
15
15
  end
16
16
 
17
17
  end
@@ -3,9 +3,9 @@ require 'spec_helper'
3
3
  describe PulseMeter::UDPServer do
4
4
  let(:host){'127.0.0.1'}
5
5
  let(:port){33333}
6
- let(:udp_sock){mock(:socket)}
6
+ let(:udp_sock){double(:socket)}
7
7
  let(:redis){PulseMeter.redis}
8
- before do
8
+ before do
9
9
  UDPSocket.should_receive(:new).and_return(udp_sock)
10
10
  udp_sock.should_receive(:bind).with(host, port).and_return(nil)
11
11
  udp_sock.should_receive("do_not_reverse_lookup=").with(true).and_return(nil)
@@ -87,12 +87,12 @@ shared_examples_for "timeline sensor" do |extra_init_values, default_event|
87
87
  end
88
88
 
89
89
  it "returns true if event processed correctly" do
90
- sensor.event(sample_event).should be_true
90
+ sensor.event(sample_event).should be
91
91
  end
92
92
 
93
93
  it "catches StandardErrors and returns false" do
94
94
  sensor.stub(:aggregate_event) {raise StandardError}
95
- sensor.event(sample_event).should be_false
95
+ sensor.event(sample_event).should_not be
96
96
  end
97
97
  end
98
98
 
@@ -1,12 +1,13 @@
1
1
  require 'rubygems'
2
- require 'bundler/setup'
2
+ require 'simplecov'
3
+ SimpleCov.start
4
+
3
5
  $:.unshift File.expand_path('../../lib/', __FILE__)
4
6
 
5
7
  ROOT = File.expand_path('../..', __FILE__)
6
8
 
7
9
  Bundler.require(:default, :test, :development)
8
10
 
9
- SimpleCov.start
10
11
 
11
12
  require 'pulse_meter_core'
12
13
  PulseMeter.redis = MockRedis.new
@@ -17,7 +18,7 @@ Dir['spec/shared_examples/**/*.rb'].each{|f| require File.join(ROOT,f)}
17
18
 
18
19
  require 'aquarium'
19
20
  include Aquarium::Aspects
20
-
21
+
21
22
  Aspect.new :after, :calls_to => [:event, :event_at], :for_types => [PulseMeter::Sensor::Base, PulseMeter::Sensor::Timeline] do |jp, obj, *args|
22
23
  PulseMeter.command_aggregator.wait_for_pending_events
23
24
  end
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pulse_meter_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
5
- prerelease:
4
+ version: 0.5.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - Ilya Averyanov
@@ -10,12 +9,11 @@ authors:
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2014-02-09 00:00:00.000000000 Z
12
+ date: 2015-01-22 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: json
17
16
  requirement: !ruby/object:Gem::Requirement
18
- none: false
19
17
  requirements:
20
18
  - - ! '>='
21
19
  - !ruby/object:Gem::Version
@@ -23,7 +21,6 @@ dependencies:
23
21
  type: :runtime
24
22
  prerelease: false
25
23
  version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
24
  requirements:
28
25
  - - ! '>='
29
26
  - !ruby/object:Gem::Version
@@ -31,7 +28,6 @@ dependencies:
31
28
  - !ruby/object:Gem::Dependency
32
29
  name: redis
33
30
  requirement: !ruby/object:Gem::Requirement
34
- none: false
35
31
  requirements:
36
32
  - - ! '>='
37
33
  - !ruby/object:Gem::Version
@@ -39,7 +35,6 @@ dependencies:
39
35
  type: :runtime
40
36
  prerelease: false
41
37
  version_requirements: !ruby/object:Gem::Requirement
42
- none: false
43
38
  requirements:
44
39
  - - ! '>='
45
40
  - !ruby/object:Gem::Version
@@ -47,7 +42,6 @@ dependencies:
47
42
  - !ruby/object:Gem::Dependency
48
43
  name: tzinfo
49
44
  requirement: !ruby/object:Gem::Requirement
50
- none: false
51
45
  requirements:
52
46
  - - ! '>='
53
47
  - !ruby/object:Gem::Version
@@ -55,7 +49,6 @@ dependencies:
55
49
  type: :runtime
56
50
  prerelease: false
57
51
  version_requirements: !ruby/object:Gem::Requirement
58
- none: false
59
52
  requirements:
60
53
  - - ! '>='
61
54
  - !ruby/object:Gem::Version
@@ -63,7 +56,6 @@ dependencies:
63
56
  - !ruby/object:Gem::Dependency
64
57
  name: aquarium
65
58
  requirement: !ruby/object:Gem::Requirement
66
- none: false
67
59
  requirements:
68
60
  - - ! '>='
69
61
  - !ruby/object:Gem::Version
@@ -71,7 +63,6 @@ dependencies:
71
63
  type: :development
72
64
  prerelease: false
73
65
  version_requirements: !ruby/object:Gem::Requirement
74
- none: false
75
66
  requirements:
76
67
  - - ! '>='
77
68
  - !ruby/object:Gem::Version
@@ -79,7 +70,6 @@ dependencies:
79
70
  - !ruby/object:Gem::Dependency
80
71
  name: hashie
81
72
  requirement: !ruby/object:Gem::Requirement
82
- none: false
83
73
  requirements:
84
74
  - - ! '>='
85
75
  - !ruby/object:Gem::Version
@@ -87,7 +77,6 @@ dependencies:
87
77
  type: :development
88
78
  prerelease: false
89
79
  version_requirements: !ruby/object:Gem::Requirement
90
- none: false
91
80
  requirements:
92
81
  - - ! '>='
93
82
  - !ruby/object:Gem::Version
@@ -95,7 +84,6 @@ dependencies:
95
84
  - !ruby/object:Gem::Dependency
96
85
  name: mock_redis
97
86
  requirement: !ruby/object:Gem::Requirement
98
- none: false
99
87
  requirements:
100
88
  - - ! '>='
101
89
  - !ruby/object:Gem::Version
@@ -103,7 +91,6 @@ dependencies:
103
91
  type: :development
104
92
  prerelease: false
105
93
  version_requirements: !ruby/object:Gem::Requirement
106
- none: false
107
94
  requirements:
108
95
  - - ! '>='
109
96
  - !ruby/object:Gem::Version
@@ -111,7 +98,6 @@ dependencies:
111
98
  - !ruby/object:Gem::Dependency
112
99
  name: rake
113
100
  requirement: !ruby/object:Gem::Requirement
114
- none: false
115
101
  requirements:
116
102
  - - ! '>='
117
103
  - !ruby/object:Gem::Version
@@ -119,7 +105,6 @@ dependencies:
119
105
  type: :development
120
106
  prerelease: false
121
107
  version_requirements: !ruby/object:Gem::Requirement
122
- none: false
123
108
  requirements:
124
109
  - - ! '>='
125
110
  - !ruby/object:Gem::Version
@@ -127,7 +112,6 @@ dependencies:
127
112
  - !ruby/object:Gem::Dependency
128
113
  name: redcarpet
129
114
  requirement: !ruby/object:Gem::Requirement
130
- none: false
131
115
  requirements:
132
116
  - - ! '>='
133
117
  - !ruby/object:Gem::Version
@@ -135,7 +119,6 @@ dependencies:
135
119
  type: :development
136
120
  prerelease: false
137
121
  version_requirements: !ruby/object:Gem::Requirement
138
- none: false
139
122
  requirements:
140
123
  - - ! '>='
141
124
  - !ruby/object:Gem::Version
@@ -143,7 +126,6 @@ dependencies:
143
126
  - !ruby/object:Gem::Dependency
144
127
  name: rspec
145
128
  requirement: !ruby/object:Gem::Requirement
146
- none: false
147
129
  requirements:
148
130
  - - ! '>='
149
131
  - !ruby/object:Gem::Version
@@ -151,7 +133,6 @@ dependencies:
151
133
  type: :development
152
134
  prerelease: false
153
135
  version_requirements: !ruby/object:Gem::Requirement
154
- none: false
155
136
  requirements:
156
137
  - - ! '>='
157
138
  - !ruby/object:Gem::Version
@@ -159,7 +140,6 @@ dependencies:
159
140
  - !ruby/object:Gem::Dependency
160
141
  name: simplecov
161
142
  requirement: !ruby/object:Gem::Requirement
162
- none: false
163
143
  requirements:
164
144
  - - ! '>='
165
145
  - !ruby/object:Gem::Version
@@ -167,7 +147,6 @@ dependencies:
167
147
  type: :development
168
148
  prerelease: false
169
149
  version_requirements: !ruby/object:Gem::Requirement
170
- none: false
171
150
  requirements:
172
151
  - - ! '>='
173
152
  - !ruby/object:Gem::Version
@@ -175,7 +154,6 @@ dependencies:
175
154
  - !ruby/object:Gem::Dependency
176
155
  name: timecop
177
156
  requirement: !ruby/object:Gem::Requirement
178
- none: false
179
157
  requirements:
180
158
  - - ! '>='
181
159
  - !ruby/object:Gem::Version
@@ -183,7 +161,6 @@ dependencies:
183
161
  type: :development
184
162
  prerelease: false
185
163
  version_requirements: !ruby/object:Gem::Requirement
186
- none: false
187
164
  requirements:
188
165
  - - ! '>='
189
166
  - !ruby/object:Gem::Version
@@ -191,7 +168,6 @@ dependencies:
191
168
  - !ruby/object:Gem::Dependency
192
169
  name: yard
193
170
  requirement: !ruby/object:Gem::Requirement
194
- none: false
195
171
  requirements:
196
172
  - - ! '>='
197
173
  - !ruby/object:Gem::Version
@@ -199,7 +175,6 @@ dependencies:
199
175
  type: :development
200
176
  prerelease: false
201
177
  version_requirements: !ruby/object:Gem::Requirement
202
- none: false
203
178
  requirements:
204
179
  - - ! '>='
205
180
  - !ruby/object:Gem::Version
@@ -295,27 +270,26 @@ files:
295
270
  - spec/support/observered.rb
296
271
  homepage: https://github.com/savonarola/pulse_meter_core
297
272
  licenses: []
273
+ metadata: {}
298
274
  post_install_message:
299
275
  rdoc_options: []
300
276
  require_paths:
301
277
  - lib
302
278
  required_ruby_version: !ruby/object:Gem::Requirement
303
- none: false
304
279
  requirements:
305
280
  - - ! '>='
306
281
  - !ruby/object:Gem::Version
307
282
  version: 1.9.2
308
283
  required_rubygems_version: !ruby/object:Gem::Requirement
309
- none: false
310
284
  requirements:
311
285
  - - ! '>='
312
286
  - !ruby/object:Gem::Version
313
287
  version: '0'
314
288
  requirements: []
315
289
  rubyforge_project:
316
- rubygems_version: 1.8.23
290
+ rubygems_version: 2.4.1
317
291
  signing_key:
318
- specification_version: 3
292
+ specification_version: 4
319
293
  summary: Lightweight Redis-based metrics aggregator and processor with simple CLI
320
294
  interface
321
295
  test_files: