microphite 0.5.6 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OWE5MmFmZjE2NWJjNDM5NGY3NTZiMjJkNDQ4OTk5ZTNiMDA5ZmNiMQ==
4
+ YjRkYTQwN2E1ZTM5ZWI3YTAxZmE4MTVjM2MxYWM0M2I0M2E2ODkzYw==
5
5
  data.tar.gz: !binary |-
6
- OGQ1MDNiZGQ4ODQ5MzljMzg5ZmRmYzc5OWU4MTJjNzg3NGQ4YTdjZA==
6
+ MzNlYmU1OTk2YzZjNTgxYzdkNzQxM2M3Y2NhZTQ5MWJjNjhmMTc1Zg==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NjcyZDMzY2ZmMzI2ZWVkNDdlMjYyYjUxNzFjZjU0YTdkYzJjNGI0OTcwMTBm
10
- OTdlNTBjNDUyZGRjYjM0NjRhZjRiNTAzZjZmY2JiNDk3ZTQxZGQwMzUwOTI1
11
- YjcxY2QyZTc5OTk3MjA2YzRhYjRmNzFhYjczZDViZDA1YjRmYjc=
9
+ ODYzZjVmYjhkNzQ0ZWQ3ZjAwZmFkMzM4YjQzYjhlY2ViMGNkYWY3ZWY4ZTFk
10
+ Y2UyNmNhZDQ0YWZmNDc4MDY0MDViMzAxZWNhOTk2NGJkMGQ1NTBkZGQ0MmMz
11
+ NjE0Y2QxZTFjNGE3Y2I2ZGJlYzdkZmQxOThkYTBkYzBiM2VkZjk=
12
12
  data.tar.gz: !binary |-
13
- Njg1NTBiZGYwMDNjNWEwMDYwOWExMzViNGMwZjkxNzc0NDQ5Y2EwMzYzNDRi
14
- NWFiZDhlYmRiZjQwNmM0Mjg3YjJiMDRkZDVlN2VkNzcxYmJlZTkzYzY4YTAx
15
- MjA5MjgxNGUyYzc3ZTFmM2M0NWY5MmY2ZTcwYWNlMmRjZmQyNGU=
13
+ MWMyMDA1NDVmZTBmNjUyNTlkMjNkYjJiYTA2ZThjY2I1NDc2YjU5YzhkMjcx
14
+ MjkyZGJiYzk2OWVjOTJiNWQwOWE4M2E5NjRiMjQ1M2UzNjFiMDUxYjdmMDJk
15
+ MTA2MGY5Y2EyMTNiZGU1NGY0NGIyZjRjNWIxOTIwMTk3YTk0NTA=
data/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
1
  Microphite CHANGELOG
2
2
  ====================
3
3
 
4
+ v0.6.0
5
+ ------
6
+ - Add execute-around support to write and gather methods
7
+
4
8
  v0.5.6
5
9
  ------
6
10
  - Expose a few of Client::Base's helper methods as protected visibility
data/README.md CHANGED
@@ -52,6 +52,15 @@ Time a code block, gathering to timing.task
52
52
  task
53
53
  end
54
54
 
55
+ Execute-around for writes and gathers -- Send data unless a block throws
56
+
57
+ client.write(accurate_data: 42) do
58
+ something_that_may_throw()
59
+ end
60
+ client.gather(accurate_data: 42) do
61
+ something_else_that_throws()
62
+ end
63
+
55
64
  Easy prefixing
56
65
 
57
66
  client.prefix('p1.') do |p1|
@@ -44,14 +44,24 @@ module Microphite
44
44
  end
45
45
  end
46
46
 
47
- def write(metrics)
48
- return false unless metrics.is_a? Hash
49
- push(@write_queue, metrics)
47
+ def write(metrics, &block)
48
+ if block_given?
49
+ result = block.call
50
+ push(@write_queue, metrics) if metrics.is_a? Hash
51
+ result
52
+ else
53
+ push(@write_queue, metrics) if metrics.is_a? Hash
54
+ end
50
55
  end
51
56
 
52
- def gather(metrics)
53
- return false unless metrics.is_a? Hash
54
- push(@gather_queue, metrics)
57
+ def gather(metrics, &block)
58
+ if block_given?
59
+ result = block.call
60
+ push(@gather_queue, metrics) if metrics.is_a? Hash
61
+ result
62
+ else
63
+ push(@gather_queue, metrics) if metrics.is_a? Hash
64
+ end
55
65
  end
56
66
 
57
67
  def prefix(prefix, &block)
@@ -10,18 +10,16 @@ module Microphite
10
10
  @prefix = prefix
11
11
  end
12
12
 
13
- def write(metrics)
14
- @client.write(mutate_hash(metrics))
13
+ def write(metrics, &block)
14
+ @client.write(mutate_hash(metrics), &block)
15
15
  end
16
16
 
17
- def gather(metrics)
18
- @client.gather(mutate_hash(metrics))
17
+ def gather(metrics, &block)
18
+ @client.gather(mutate_hash(metrics), &block)
19
19
  end
20
20
 
21
21
  def time(key, &block)
22
- @client.time("#{@prefix}#{key}") do
23
- block.call
24
- end
22
+ @client.time("#{@prefix}#{key}", &block)
25
23
  end
26
24
 
27
25
  def prefix(additional, &block)
@@ -1,3 +1,3 @@
1
1
  module Microphite
2
- VERSION = '0.5.6'
2
+ VERSION = '0.6.0'
3
3
  end
@@ -25,6 +25,12 @@ shared_examples 'a microphite client' do |before, after|
25
25
  expect { @client.write(key: 0) }.not_to raise_error
26
26
  expect { @client.write(key1: 1, key2: 2.5) }.not_to raise_error
27
27
  end
28
+
29
+ describe 'when given a block' do
30
+ it 'should return the evaluated block value' do
31
+ expect(@client.write(key: 0) { 42 }).to eq 42
32
+ end
33
+ end
28
34
  end
29
35
 
30
36
  describe :gather do
@@ -32,6 +38,12 @@ shared_examples 'a microphite client' do |before, after|
32
38
  expect { @client.gather(key: 0) }.not_to raise_error
33
39
  expect { @client.gather(key1: 1, key2: 2.5) }.not_to raise_error
34
40
  end
41
+
42
+ describe 'when given a block' do
43
+ it 'should return the evaluated block value' do
44
+ expect(@client.gather(key: 0) { 42 }).to eq 42
45
+ end
46
+ end
35
47
  end
36
48
 
37
49
  describe :time do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: microphite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.6
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - BZ
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2013-11-21 00:00:00.000000000 Z
14
+ date: 2013-11-22 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  requirement: !ruby/object:Gem::Requirement