tabs 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5925ee887e482c08b4ae405b4463162a90b41494
4
- data.tar.gz: 878be73e42a4c32a58853c61385f71460bbafa60
3
+ metadata.gz: b55f352f352f83192698497faa68edf9d4980c48
4
+ data.tar.gz: 21b5c2b6425a43cc4920bc1d8f53a6caf2439c33
5
5
  SHA512:
6
- metadata.gz: 531f0554860cb6143ee9d8cb29d7362d2111c63324a52ca5cc773f1767a80da58e2bae4680479abf791b024c185275334cc9b07fa7014dd459099af49e2cb4cd
7
- data.tar.gz: 62bc646ae94b276fa7a089fe7e88824473b65e9080244be8a54a5ea0f5b064114226d06e82cbf918320c748bbedbfecc545280156c7b0542d2f3f4466f8c7be7
6
+ metadata.gz: a90941983c522edb2c1b6ba57a36b503e4b91d9ab16967bbfa659f10e279d890345f6c7f5e953efcfbbf7d2cd963f999cad6d84bb8fd6eb1c04238557d597968
7
+ data.tar.gz: 3929b6792a6d14299826c377f2cf4977e2938297b659ee3131cbe238544a8cab9636f10f361cf11cae1ca868d8b80afe1ebc700f9f13d5e402df42361293af75
data/README.md CHANGED
@@ -216,7 +216,7 @@ module SecondResolution
216
216
  def name
217
217
  :seconds
218
218
  end
219
-
219
+
220
220
  def serialize(timestamp)
221
221
  timestamp.strftime(PATTERN)
222
222
  end
@@ -229,7 +229,7 @@ module SecondResolution
229
229
  def from_seconds(s)
230
230
  s / 1
231
231
  end
232
-
232
+
233
233
  def to_seconds
234
234
  1
235
235
  end
@@ -337,11 +337,11 @@ You can use the expiration features to age out old metrics that may no longer be
337
337
 
338
338
  ```ruby
339
339
  Tabs.configure do |config|
340
- config.set_expirations(minute: 1.day, day: 1.week)
340
+ config.set_expirations(minute: 1.day, day: 1.week)
341
341
  end
342
342
  ```
343
343
 
344
- The expiration date will start counting at the beginning at the end of the given resolution. Meaning that for a month resolution the given expiration time would start at the end of a given month. A month resolution metric recorded in January with an expiration of 2 weeks would expire after the 2nd week of February.
344
+ The expiration date will start counting at the beginning of the end of the given resolution. Meaning that for a month resolution the given expiration time would start at the end of a given month. A month resolution metric recorded in January with an expiration of 2 weeks would expire after the 2nd week of February.
345
345
 
346
346
  *NOTE: You cannot expire task metrics at this time, only counter and
347
347
  values.*
@@ -358,7 +358,7 @@ Tabs.configure do |config|
358
358
 
359
359
  # pass a config hash that will be passed to Redis.new
360
360
  config.redis = { :host => 'localhost', :port => 6379 }
361
-
361
+
362
362
  # pass a prefix that will be used in addition to the "tabs" prefix with Redis keys
363
363
  # Example: "tabs:my_app:metric_name"
364
364
  config.prefix = "my_app"
@@ -372,7 +372,7 @@ Tabs.configure do |config|
372
372
 
373
373
  # unregisters any resolution
374
374
  config.unregister_resolutions(:minute, :hour)
375
-
375
+
376
376
  # sets TTL for redis keys of specific resolutions
377
377
  config.set_expirations({ minute: 1.hour, hour: 1.day })
378
378
 
@@ -431,8 +431,8 @@ continue to use v0.8.1 or lower if that is an issue.
431
431
  _WARNING: Version 1.0.0 is not compatible with previous versions of
432
432
  Tabs_
433
433
 
434
- We have made a number of changes related to hour metric keys are stored
435
- in Redis. At this point we'll be following semantec versioning and will
434
+ We have made a number of changes related to how our metric keys are stored
435
+ in Redis. At this point we'll be following semantic versioning and will
436
436
  support backwards compatability between major versions. In this release
437
437
  we've added a number of major features:
438
438
 
@@ -59,7 +59,13 @@ module Tabs
59
59
  end
60
60
 
61
61
  def counter_total(key)
62
- raise UnknownMetricError.new("Unknown metric: #{key}") unless metric_exists?(key)
62
+ unless metric_exists?(key)
63
+ if block_given?
64
+ return yield
65
+ else
66
+ raise UnknownMetricError.new("Unknown metric: #{key}")
67
+ end
68
+ end
63
69
  raise MetricTypeMismatchError.new("Only counter metrics can be incremented") unless metric_type(key) == "counter"
64
70
  get_metric(key).total
65
71
  end
@@ -1,3 +1,3 @@
1
1
  module Tabs
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -33,6 +33,23 @@ describe Tabs do
33
33
 
34
34
  end
35
35
 
36
+ describe ".counter_total" do
37
+
38
+ it "returns the total for a counter metric" do
39
+ Tabs.increment_counter("foo")
40
+ expect(Tabs.counter_total("foo")).to eq 1
41
+ end
42
+
43
+ it "returns the value of the block if given and the metric doesn't exist" do
44
+ expect(Tabs.counter_total("foo") { 42 }).to eq 42
45
+ end
46
+
47
+ it "raises an UnknownMetricError if no block is given and the metric does not exist" do
48
+ expect { Tabs.counter_total("foo") }.to raise_error Tabs::UnknownMetricError
49
+ end
50
+
51
+ end
52
+
36
53
  describe ".get_metric" do
37
54
 
38
55
  it "returns the expected metric object" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tabs
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - JC Grubbs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-23 00:00:00.000000000 Z
11
+ date: 2014-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport