lenjador 1.3.0 → 1.4.0

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: 10e0eaa5dd3548c6bfc7ff8c980e7e500ee4d297
4
- data.tar.gz: c2dd081c02374b3144f3a7c77494c3f19b7ef464
3
+ metadata.gz: ecb260502893758ca056faa11a5e4b5347d450c1
4
+ data.tar.gz: f3dab9f737b556ae47c9d2095b07076963ee31b6
5
5
  SHA512:
6
- metadata.gz: d3766944053913a9345b4a8415f9de802c93de119affebd85fe43fe8696047ee656e586d84c6e0bf45cacdbcb376fafd443bea60c92728265f53c5bfa457daaa
7
- data.tar.gz: e87536d2ccc0abf5176f474f782458877832b47335c30ae0d6f714bae688b10e934627446dc9d1a879a488c5e023585db1ba928575502ce2c962e9d19832c8cb
6
+ metadata.gz: 19d983bb91596e4e4c2da6c88d98ba765c3d3e5dceb579b9fb6598868935ca0392c18293b3ac4cc5fb7a018acb19761cf00352f76f8c1c3fda066a04be66cb8a
7
+ data.tar.gz: 9dabc7e541b8f41bc03e0ec9cf899771bd2d625ea22733d986aed483fe0be89cb6195a5b94f593ae141df1f9f9e452368b4ad3581b343470ffeb42157947aeeb
data/lenjador.gemspec CHANGED
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
 
6
6
  Gem::Specification.new do |gem|
7
7
  gem.name = RUBY_PLATFORM =~ /java/ ? 'lenjador-jruby' : 'lenjador'
8
- gem.version = '1.3.0'
8
+ gem.version = '1.4.0'
9
9
  gem.authors = ['Salemove']
10
10
  gem.email = ['support@salemove.com']
11
11
  gem.description = "It's lenjadoric"
@@ -22,7 +22,7 @@ Gem::Specification.new do |gem|
22
22
  if RUBY_PLATFORM =~ /java/
23
23
  gem.add_dependency 'jrjackson'
24
24
  else
25
- gem.add_dependency 'oj'
25
+ gem.add_dependency 'oj', '~> 3.6'
26
26
  gem.add_development_dependency 'ruby-prof'
27
27
  end
28
28
 
@@ -38,27 +38,11 @@ class Lenjador
38
38
 
39
39
  def self.overwritable_params
40
40
  {
41
- :@timestamp => Time.now.utc.iso8601(DECIMAL_FRACTION_OF_SECOND)
41
+ :@timestamp => Time.now
42
42
  }
43
43
  end
44
44
  private_class_method :overwritable_params
45
45
 
46
- def self.serialize_time_objects!(object)
47
- if object.is_a?(Hash)
48
- object.each do |key, value|
49
- object[key] = serialize_time_objects!(value)
50
- end
51
- elsif object.is_a?(Array)
52
- object.each_index do |index|
53
- object[index] = serialize_time_objects!(object[index])
54
- end
55
- elsif object.is_a?(Time) || object.is_a?(Date)
56
- object.iso8601
57
- else
58
- object
59
- end
60
- end
61
-
62
46
  if RUBY_PLATFORM =~ /java/
63
47
  require 'jrjackson'
64
48
 
@@ -72,11 +56,13 @@ class Lenjador
72
56
  end
73
57
  else
74
58
  require 'oj'
75
- DUMP_OPTIONS = {mode: :compat, time_format: :ruby}.freeze
59
+ DUMP_OPTIONS = {
60
+ mode: :custom,
61
+ time_format: :xmlschema,
62
+ second_precision: 3
63
+ }.freeze
76
64
 
77
65
  def self.generate_json(obj)
78
- serialize_time_objects!(obj)
79
-
80
66
  Oj.dump(obj, DUMP_OPTIONS)
81
67
  end
82
68
  end
@@ -25,7 +25,7 @@ describe Lenjador::Utils do
25
25
  end
26
26
 
27
27
  it 'includes timestamp' do
28
- expect(event[:@timestamp]).to eq('2015-10-11T23:10:21.123Z')
28
+ expect(event[:@timestamp]).to eq(now)
29
29
  end
30
30
 
31
31
  context 'when @timestamp provided' do
@@ -89,40 +89,11 @@ describe Lenjador::Utils do
89
89
  end
90
90
  end
91
91
 
92
- describe '.serialize_time_objects!' do
93
- let(:object) do
94
- {
95
- time: Time.now,
96
- hash: {
97
- time: Time.now
98
- },
99
- array: [
100
- Time.now,
101
- {
102
- time: Time.now
103
- }
104
- ]
105
- }
106
- end
107
-
108
- let(:serialized_time) { now.iso8601 }
109
-
110
- it 'recursively serializes time objects to iso8601' do
111
- o = object.dup
112
- described_class.serialize_time_objects!(o)
113
-
114
- expect(o).to eq(
115
- time: serialized_time,
116
- hash: {
117
- time: serialized_time
118
- },
119
- array: [
120
- serialized_time,
121
- {
122
- time: serialized_time
123
- }
124
- ]
125
- )
92
+ describe '.generate_json' do
93
+ it 'serializes time objects to iso8601' do
94
+ serialized_time = now.iso8601(3)
95
+ json = described_class.generate_json(time: now)
96
+ expect(json).to eq(%({"time":"#{serialized_time}"}))
126
97
  end
127
98
  end
128
99
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lenjador
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Salemove
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-06 00:00:00.000000000 Z
11
+ date: 2018-09-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lru_redux
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: oj
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '3.6'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: '3.6'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: ruby-prof
43
43
  requirement: !ruby/object:Gem::Requirement