pulse-meter-client-backport 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/.rbenv-version CHANGED
@@ -1 +1 @@
1
- 1.9.2-p290
1
+ 1.8.7-p357
@@ -1,5 +1,3 @@
1
- $: << File.join(File.absolute_path(__FILE__), '..', 'lib')
2
-
3
1
  require 'pulse-meter'
4
2
  PulseMeter.redis = Redis.new
5
3
 
@@ -21,6 +19,27 @@ hashed_counter.event(:y => 5)
21
19
  hashed_counter.event(:y => 1)
22
20
  p hashed_counter.value
23
21
 
22
+ # alternative way
23
+
24
+ cfg = PulseMeter::Sensor::Configuration.new(
25
+ :my_counter => {:sensor_type => 'counter'},
26
+ :my_value => {:sensor_type => 'indicator'},
27
+ :my_h_counter => {:sensor_type => 'hashed_counter'}
28
+ )
29
+
30
+ cfg.my_counter(1)
31
+ cfg.my_counter(2)
32
+ puts cfg.sensor(:my_counter).value
33
+
34
+ cfg.my_value(3.14)
35
+ cfg.my_value(2.71)
36
+ puts cfg.sensor(:my_value).value
37
+
38
+ cfg.my_h_counter(:x => 1)
39
+ cfg.my_h_counter(:y => 5)
40
+ cfg.my_h_counter(:y => 1)
41
+ p cfg.sensor(:my_h_counter).value
42
+
24
43
 
25
44
  # timeline sensor examples
26
45
 
@@ -49,4 +68,4 @@ max_per_minute.event(7)
49
68
  max_per_minute.event(6)
50
69
  max_per_minute.timeline(2 * 60).each do |v|
51
70
  puts "#{v.start_time}: #{v.value}"
52
- end
71
+ end
data/lib/pulse-meter.rb CHANGED
@@ -3,6 +3,7 @@ require "pulse-meter/version"
3
3
  require "pulse-meter/mixins/dumper"
4
4
  require "pulse-meter/mixins/utils"
5
5
  require "pulse-meter/sensor"
6
+ require "pulse-meter/sensor/configuration"
6
7
 
7
8
  module PulseMeter
8
9
  @@redis = nil
@@ -88,6 +88,21 @@ module PulseMeter
88
88
  item
89
89
  end
90
90
  end
91
+
92
+ # Symbolizes hash keys
93
+ def symbolize_keys(h)
94
+ res = {}
95
+ h.each do |k, v|
96
+ new_k = if k.is_a?(String)
97
+ k.to_sym
98
+ else
99
+ k
100
+ end
101
+ res[new_k] = v
102
+ end
103
+ res
104
+ end
105
+
91
106
  end
92
107
  end
93
108
  end
@@ -1,3 +1,3 @@
1
1
  module PulseMeter
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -21,6 +21,7 @@ Gem::Specification.new do |gem|
21
21
  gem.add_runtime_dependency('json')
22
22
  gem.add_runtime_dependency('redis')
23
23
 
24
+ gem.add_development_dependency('hashie')
24
25
  gem.add_development_dependency('foreman')
25
26
  gem.add_development_dependency('mock_redis')
26
27
  gem.add_development_dependency('rack-test')
@@ -122,4 +122,10 @@ describe PulseMeter::Mixins::Utils do
122
122
  dummy.camelize_keys({ :aa_bb_cc => [ { :dd_ee => 123 }, 456 ] }).should =={ 'aaBbCc' => [ { 'ddEe' => 123 }, 456 ] }
123
123
  end
124
124
  end
125
+
126
+ describe "#symbolize_keys" do
127
+ it "should convert symbolizable keys to symbols" do
128
+ dummy.symbolize_keys({"a" => 5, 6 => 7}).should == {:a => 5, 6 => 7}
129
+ end
130
+ end
125
131
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pulse-meter-client-backport
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ilya Averyanov
@@ -16,10 +16,12 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2012-05-30 00:00:00 Z
19
+ date: 2012-06-06 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- version_requirements: &id001 !ruby/object:Gem::Requirement
22
+ name: json
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
23
25
  none: false
24
26
  requirements:
25
27
  - - ">="
@@ -28,12 +30,12 @@ dependencies:
28
30
  segments:
29
31
  - 0
30
32
  version: "0"
31
- prerelease: false
32
33
  type: :runtime
33
- name: json
34
- requirement: *id001
34
+ version_requirements: *id001
35
35
  - !ruby/object:Gem::Dependency
36
- version_requirements: &id002 !ruby/object:Gem::Requirement
36
+ name: redis
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
37
39
  none: false
38
40
  requirements:
39
41
  - - ">="
@@ -42,12 +44,12 @@ dependencies:
42
44
  segments:
43
45
  - 0
44
46
  version: "0"
45
- prerelease: false
46
47
  type: :runtime
47
- name: redis
48
- requirement: *id002
48
+ version_requirements: *id002
49
49
  - !ruby/object:Gem::Dependency
50
- version_requirements: &id003 !ruby/object:Gem::Requirement
50
+ name: hashie
51
+ prerelease: false
52
+ requirement: &id003 !ruby/object:Gem::Requirement
51
53
  none: false
52
54
  requirements:
53
55
  - - ">="
@@ -56,12 +58,12 @@ dependencies:
56
58
  segments:
57
59
  - 0
58
60
  version: "0"
59
- prerelease: false
60
61
  type: :development
61
- name: foreman
62
- requirement: *id003
62
+ version_requirements: *id003
63
63
  - !ruby/object:Gem::Dependency
64
- version_requirements: &id004 !ruby/object:Gem::Requirement
64
+ name: foreman
65
+ prerelease: false
66
+ requirement: &id004 !ruby/object:Gem::Requirement
65
67
  none: false
66
68
  requirements:
67
69
  - - ">="
@@ -70,12 +72,12 @@ dependencies:
70
72
  segments:
71
73
  - 0
72
74
  version: "0"
73
- prerelease: false
74
75
  type: :development
75
- name: mock_redis
76
- requirement: *id004
76
+ version_requirements: *id004
77
77
  - !ruby/object:Gem::Dependency
78
- version_requirements: &id005 !ruby/object:Gem::Requirement
78
+ name: mock_redis
79
+ prerelease: false
80
+ requirement: &id005 !ruby/object:Gem::Requirement
79
81
  none: false
80
82
  requirements:
81
83
  - - ">="
@@ -84,12 +86,12 @@ dependencies:
84
86
  segments:
85
87
  - 0
86
88
  version: "0"
87
- prerelease: false
88
89
  type: :development
89
- name: rack-test
90
- requirement: *id005
90
+ version_requirements: *id005
91
91
  - !ruby/object:Gem::Dependency
92
- version_requirements: &id006 !ruby/object:Gem::Requirement
92
+ name: rack-test
93
+ prerelease: false
94
+ requirement: &id006 !ruby/object:Gem::Requirement
93
95
  none: false
94
96
  requirements:
95
97
  - - ">="
@@ -98,12 +100,12 @@ dependencies:
98
100
  segments:
99
101
  - 0
100
102
  version: "0"
101
- prerelease: false
102
103
  type: :development
103
- name: rake
104
- requirement: *id006
104
+ version_requirements: *id006
105
105
  - !ruby/object:Gem::Dependency
106
- version_requirements: &id007 !ruby/object:Gem::Requirement
106
+ name: rake
107
+ prerelease: false
108
+ requirement: &id007 !ruby/object:Gem::Requirement
107
109
  none: false
108
110
  requirements:
109
111
  - - ">="
@@ -112,12 +114,12 @@ dependencies:
112
114
  segments:
113
115
  - 0
114
116
  version: "0"
115
- prerelease: false
116
117
  type: :development
117
- name: redcarpet
118
- requirement: *id007
118
+ version_requirements: *id007
119
119
  - !ruby/object:Gem::Dependency
120
- version_requirements: &id008 !ruby/object:Gem::Requirement
120
+ name: redcarpet
121
+ prerelease: false
122
+ requirement: &id008 !ruby/object:Gem::Requirement
121
123
  none: false
122
124
  requirements:
123
125
  - - ">="
@@ -126,12 +128,12 @@ dependencies:
126
128
  segments:
127
129
  - 0
128
130
  version: "0"
129
- prerelease: false
130
131
  type: :development
131
- name: rspec
132
- requirement: *id008
132
+ version_requirements: *id008
133
133
  - !ruby/object:Gem::Dependency
134
- version_requirements: &id009 !ruby/object:Gem::Requirement
134
+ name: rspec
135
+ prerelease: false
136
+ requirement: &id009 !ruby/object:Gem::Requirement
135
137
  none: false
136
138
  requirements:
137
139
  - - ">="
@@ -140,12 +142,12 @@ dependencies:
140
142
  segments:
141
143
  - 0
142
144
  version: "0"
143
- prerelease: false
144
145
  type: :development
145
- name: timecop
146
- requirement: *id009
146
+ version_requirements: *id009
147
147
  - !ruby/object:Gem::Dependency
148
- version_requirements: &id010 !ruby/object:Gem::Requirement
148
+ name: timecop
149
+ prerelease: false
150
+ requirement: &id010 !ruby/object:Gem::Requirement
149
151
  none: false
150
152
  requirements:
151
153
  - - ">="
@@ -154,10 +156,22 @@ dependencies:
154
156
  segments:
155
157
  - 0
156
158
  version: "0"
157
- prerelease: false
158
159
  type: :development
160
+ version_requirements: *id010
161
+ - !ruby/object:Gem::Dependency
159
162
  name: yard
160
- requirement: *id010
163
+ prerelease: false
164
+ requirement: &id011 !ruby/object:Gem::Requirement
165
+ none: false
166
+ requirements:
167
+ - - ">="
168
+ - !ruby/object:Gem::Version
169
+ hash: 3
170
+ segments:
171
+ - 0
172
+ version: "0"
173
+ type: :development
174
+ version_requirements: *id011
161
175
  description: Ruby 1.8 compatible PulseMeter client
162
176
  email:
163
177
  - av@fun-box.ru