librato-metrics 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ## Changelog
2
2
 
3
+ ### Version 1.0.2
4
+ * Fix bug with some versions of MultiJson (Thomas Dippel)
5
+ * Use delegation for JSON handling
6
+ * Improve integration tests
7
+
3
8
  ### Version 1.0.1
4
9
  * Fix Forwardable dependency loading bug
5
10
 
@@ -1,31 +1,25 @@
1
- # wrap MultiJSON's implementation so we can use any version
1
+ require 'multi_json'
2
+
2
3
  module Librato
3
4
  module Metrics
4
5
  class SmartJSON
5
-
6
- class << self
7
-
8
- # prefer modern syntax; def once at startup
9
- if MultiJson.respond_to?(:load)
10
- def read(json)
11
- MultiJson.load(json)
12
- end
13
-
14
- def write(data)
15
- MultiJson.dump(data)
16
- end
17
- else
18
- def read(json)
19
- MultiJson.decode(json)
20
- end
21
-
22
- def write(data)
23
- MultiJson.encode(data)
24
- end
25
- end
26
-
6
+ JSON_HANDLER = MultiJson
7
+ extend SingleForwardable
8
+
9
+ # wrap MultiJSON's implementation so we can use any version
10
+ # prefer modern syntax if available; def once at startup
11
+ if JSON_HANDLER.respond_to?(:load)
12
+ def_delegator JSON_HANDLER, :load, :read
13
+ else
14
+ def_delegator JSON_HANDLER, :decode, :read
15
+ end
16
+
17
+ if JSON_HANDLER.respond_to?(:dump)
18
+ def_delegator JSON_HANDLER, :dump, :write
19
+ else
20
+ def_delegator JSON_HANDLER, :encode, :write
27
21
  end
28
22
 
29
23
  end
30
24
  end
31
- end
25
+ end
@@ -1,5 +1,5 @@
1
1
  module Librato
2
2
  module Metrics
3
- VERSION = "1.0.1"
3
+ VERSION = "1.0.2"
4
4
  end
5
5
  end
@@ -3,7 +3,6 @@ $:.unshift(File.dirname(__FILE__)) unless
3
3
 
4
4
  require 'base64'
5
5
  require 'forwardable'
6
- require 'multi_json'
7
6
 
8
7
  require 'metrics/aggregator'
9
8
  require 'metrics/annotator'
@@ -211,7 +211,7 @@ module Librato
211
211
  Metrics.submit :foo => 123
212
212
  end
213
213
 
214
- it "should upate the metric" do
214
+ it "should update the metric" do
215
215
  Metrics.update :foo, :display_name => "Foo Metric",
216
216
  :period => 15,
217
217
  :attributes => {
@@ -220,7 +220,7 @@ module Librato
220
220
  foo = Metrics.fetch :foo
221
221
  foo['display_name'].should == 'Foo Metric'
222
222
  foo['period'].should == 15
223
- foo['attributes'].should == {'display_max' => 1000}
223
+ foo['attributes']['display_max'].should == 1000
224
224
  end
225
225
  end
226
226
 
@@ -236,7 +236,7 @@ module Librato
236
236
  foo = Metrics.fetch :foo
237
237
  foo['display_name'].should == 'Foo Metric'
238
238
  foo['period'].should == 15
239
- foo['attributes'].should == {'display_max' => 1000}
239
+ foo['attributes']['display_max'].should == 1000
240
240
  end
241
241
 
242
242
  it "should raise error if no type specified" do
@@ -5,8 +5,8 @@ module Librato
5
5
  describe Aggregator do
6
6
 
7
7
  before(:all) do
8
- @time = Time.now.to_i
9
- Aggregator.stub(:epoch_time).and_return(@time)
8
+ @time = 1354720160 #Time.now.to_i
9
+ Aggregator.any_instance.stub(:epoch_time).and_return(@time)
10
10
  end
11
11
 
12
12
  describe "initialization" do
@@ -6,8 +6,8 @@ module Librato
6
6
  describe Queue do
7
7
 
8
8
  before(:each) do
9
- @time = Time.now.to_i
10
- Processor.stub(:epoch_time).and_return(@time)
9
+ @time = 1354720160 #Time.now.to_i
10
+ Queue.any_instance.stub(:epoch_time).and_return(@time)
11
11
  end
12
12
 
13
13
  describe "initialization" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: librato-metrics
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-05 00:00:00.000000000 Z
12
+ date: 2012-12-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday
@@ -218,7 +218,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
218
218
  version: '0'
219
219
  segments:
220
220
  - 0
221
- hash: -361956509088678057
221
+ hash: 2478461788804600344
222
222
  required_rubygems_version: !ruby/object:Gem::Requirement
223
223
  none: false
224
224
  requirements: