timber 1.1.2 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 711c51f2448d07c0149c2c13fe73d15b42d5314e
4
- data.tar.gz: 1cedd7c199a732958fab544e6890e9b4589071a7
3
+ metadata.gz: cfc7a63ba3d0400f2c4dd67bc0844126e5d155fe
4
+ data.tar.gz: 1ccf7ffb850c87ae7ccc51c04daaa94b1d685adf
5
5
  SHA512:
6
- metadata.gz: ca1143f0d28d2b797be5b852fd835b62bdd0fb5aeaac3ace0f680e96301b86d5df4d93ee9d8a8f40dbbf1b84a244c8bce4abe793240eeef475650afe9520331f
7
- data.tar.gz: ec709d117addb3085ac60c310c264c27ffc4f4b9c2bc1811cd2857302974131d53664c285dd11fbc798f56c49bca5d7b80a4f5afd0bdb11c753f924721994e21
6
+ metadata.gz: a207f1fccdd43e25fbb3e7c9b31809f00cd53884f09d1ca21201348330b3ac66999f422a6e9a9eb8831b807dc1cc53e2731e2c5f0f0e8e2c5bfe96e992e69f65
7
+ data.tar.gz: 29da7a68133255e47dbbb58498d120b308176d6d5a1f554a4661c3d9820b4e80043ac4a94da740ae10ccf0be2485404815e13860412376d54f8333b7c2c96af6
@@ -18,7 +18,7 @@ module Timber
18
18
  end
19
19
 
20
20
  def as_json(_options = {})
21
- {type => data}
21
+ {Timber::Object.try(type, :to_sym) => data}
22
22
  end
23
23
  end
24
24
  end
@@ -26,7 +26,7 @@ module Timber
26
26
  end
27
27
 
28
28
  def as_json(_options = {})
29
- {id: id, name: name}
29
+ {id: Timber::Object.try(id, :to_s), name: name}
30
30
  end
31
31
  end
32
32
  end
@@ -12,7 +12,7 @@ module Timber
12
12
  end
13
13
 
14
14
  def as_json(_options = {})
15
- {pid: pid}
15
+ {pid: Timber::Object.try(pid, :to_s)}
16
16
  end
17
17
  end
18
18
  end
@@ -27,7 +27,7 @@ module Timber
27
27
  end
28
28
 
29
29
  def as_json(_options = {})
30
- {id: id, name: name}
30
+ {id: Timber::Object.try(id, :to_s), name: name}
31
31
  end
32
32
  end
33
33
  end
@@ -26,7 +26,7 @@ module Timber
26
26
  end
27
27
 
28
28
  def to_hash
29
- {type => data}
29
+ {Timber::Object.try(type, :to_sym) => data}
30
30
  end
31
31
  alias to_h to_hash
32
32
 
data/lib/timber/util.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require "timber/util/active_support_log_subscriber"
2
2
  require "timber/util/hash"
3
+ require "timber/util/object"
3
4
  require "timber/util/struct"
4
5
 
5
6
  module Timber
@@ -0,0 +1,13 @@
1
+ module Timber
2
+ # @private
3
+ module Object
4
+ # @private
5
+ def self.try(object, method)
6
+ if object == nil
7
+ nil
8
+ else
9
+ object.send(method) rescue object
10
+ end
11
+ end
12
+ end
13
+ end
@@ -1,3 +1,3 @@
1
1
  module Timber
2
- VERSION = "1.1.2"
2
+ VERSION = "1.1.3"
3
3
  end
@@ -0,0 +1,11 @@
1
+ require "spec_helper"
2
+
3
+ describe Timber::Contexts::Custom, :rails_23 => true do
4
+ describe ".as_json" do
5
+ it "should coerce type into an atom" do
6
+ custom_context = described_class.new(:type => "my type", :data => {:key => "value"})
7
+ json = custom_context.as_json()
8
+ expect(json.keys.first).to eq(:"my type")
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ require "spec_helper"
2
+
3
+ describe Timber::Contexts::Organization, :rails_23 => true do
4
+ describe ".as_json" do
5
+ it "should coerce id into a string" do
6
+ user_context = described_class.new(:id => 1)
7
+ json = user_context.as_json()
8
+ expect(json[:id]).to eq("1")
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ require "spec_helper"
2
+
3
+ describe Timber::Contexts::System, :rails_23 => true do
4
+ describe ".as_json" do
5
+ it "should coerce pid into an string" do
6
+ custom_context = described_class.new(:pid => 1)
7
+ json = custom_context.as_json()
8
+ expect(json[:pid]).to eq("1")
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ require "spec_helper"
2
+
3
+ describe Timber::Contexts::User, :rails_23 => true do
4
+ describe ".as_json" do
5
+ it "should coerce id into a string" do
6
+ user_context = described_class.new(:id => 1)
7
+ json = user_context.as_json()
8
+ expect(json[:id]).to eq("1")
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ require "spec_helper"
2
+
3
+ describe Timber::Events::Custom, :rails_23 => true do
4
+ describe ".to_hash" do
5
+ it "should coerce type into an atom" do
6
+ custom_context = described_class.new(:type => "my type", :message => "hello", :data => {:key => "value"})
7
+ hash = custom_context.to_hash()
8
+ expect(hash.keys.first).to eq(:"my type")
9
+ end
10
+ end
11
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: timber
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Timber Technologies, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-22 00:00:00.000000000 Z
11
+ date: 2017-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: msgpack
@@ -95,6 +95,7 @@ files:
95
95
  - lib/timber/util.rb
96
96
  - lib/timber/util/active_support_log_subscriber.rb
97
97
  - lib/timber/util/hash.rb
98
+ - lib/timber/util/object.rb
98
99
  - lib/timber/util/struct.rb
99
100
  - lib/timber/version.rb
100
101
  - spec/README.md
@@ -111,7 +112,12 @@ files:
111
112
  - spec/support/timber.rb
112
113
  - spec/support/timecop.rb
113
114
  - spec/support/webmock.rb
115
+ - spec/timber/contexts/custom_spec.rb
116
+ - spec/timber/contexts/organization_spec.rb
117
+ - spec/timber/contexts/system_spec.rb
118
+ - spec/timber/contexts/user_spec.rb
114
119
  - spec/timber/contexts_spec.rb
120
+ - spec/timber/events/custom_spec.rb
115
121
  - spec/timber/events_spec.rb
116
122
  - spec/timber/log_devices/http_spec.rb
117
123
  - spec/timber/log_entry_spec.rb
@@ -161,7 +167,12 @@ test_files:
161
167
  - spec/support/timber.rb
162
168
  - spec/support/timecop.rb
163
169
  - spec/support/webmock.rb
170
+ - spec/timber/contexts/custom_spec.rb
171
+ - spec/timber/contexts/organization_spec.rb
172
+ - spec/timber/contexts/system_spec.rb
173
+ - spec/timber/contexts/user_spec.rb
164
174
  - spec/timber/contexts_spec.rb
175
+ - spec/timber/events/custom_spec.rb
165
176
  - spec/timber/events_spec.rb
166
177
  - spec/timber/log_devices/http_spec.rb
167
178
  - spec/timber/log_entry_spec.rb