hoodoo 1.16.1 → 1.17.0
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 +4 -4
- data/lib/hoodoo/logger/flattener_mixin.rb +1 -1
- data/lib/hoodoo/presenters/base.rb +1 -1
- data/lib/hoodoo/services/middleware/middleware.rb +1 -1
- data/lib/hoodoo/services/services/session.rb +1 -1
- data/lib/hoodoo/utilities/utilities.rb +10 -0
- data/lib/hoodoo/version.rb +1 -1
- data/spec/active/active_record/secure_spec.rb +3 -3
- data/spec/client/client_spec.rb +3 -3
- data/spec/data/resources/caller_spec.rb +2 -2
- data/spec/presenters/base_spec.rb +5 -5
- data/spec/presenters/types/array_spec.rb +1 -1
- data/spec/services/services/session_spec.rb +8 -8
- data/spec/utilities/utilities_spec.rb +32 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a11d0bed3dc977f5aab127f4ed139e715a9f2431
|
4
|
+
data.tar.gz: 42706658a33e920162e734ad3f0891a8e703e845
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3f795bff6b580fe090f46a624461fac52939941e18564074e68c37e5d3fc757c5da9a34efbbad6ce3c435e0701c021e07c8a157f77f0e268541bbe78180c1f9
|
7
|
+
data.tar.gz: f3fec8a2305e6c815d309c0442724f4fee7a6541606058421a1e473797f50e666dbe40b7540cc34cbb12baa1e8af2cdaa2052c13601e69b182a303feca31bc7e
|
@@ -29,7 +29,7 @@ module Hoodoo
|
|
29
29
|
# return a single line string representing the "flattened" log data.
|
30
30
|
#
|
31
31
|
def flatten( log_level, component, code, data )
|
32
|
-
"#{ log_level.to_s.upcase } [#{ Time.now
|
32
|
+
"#{ log_level.to_s.upcase } [#{ Hoodoo::Utilities.standard_datetime( Time.now ) }] #{ component } - #{ code }: #{ data.inspect }"
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
@@ -114,7 +114,7 @@ module Hoodoo
|
|
114
114
|
target.merge!( {
|
115
115
|
'id' => uuid,
|
116
116
|
'kind' => kind,
|
117
|
-
'created_at' =>
|
117
|
+
'created_at' => Hoodoo::Utilities.standard_datetime( created_at.to_datetime )
|
118
118
|
} )
|
119
119
|
|
120
120
|
target[ 'language' ] = language if self.is_internationalised?()
|
@@ -160,7 +160,7 @@ module Hoodoo; module Services
|
|
160
160
|
#
|
161
161
|
DEFAULT_TEST_SESSION.from_h!( {
|
162
162
|
'session_id' => '01234567890123456789012345678901',
|
163
|
-
'expires_at' => ( Time.now + 172800 )
|
163
|
+
'expires_at' => Hoodoo::Utilities.standard_datetime( Time.now + 172800 ),
|
164
164
|
'caller_version' => 1,
|
165
165
|
'caller_id' => 'c5ea12fb7f414a46850e73ee1bf6d95e',
|
166
166
|
'caller_identity_name' => 'c5ea12fb7f414a46850e73ee1bf6d95e',
|
@@ -340,6 +340,16 @@ module Hoodoo
|
|
340
340
|
return value.is_a?( ::Date ) && value
|
341
341
|
end
|
342
342
|
|
343
|
+
# Returns an ISO 8601 String equivalent of the given Time, Date or
|
344
|
+
# DateTime instance as a full date-time with UTC timezone, with
|
345
|
+
# "standard high precision" (for rendeirng consistency), subject to
|
346
|
+
# Ruby port / OS support abilities. At the time of writing, 6 decimal
|
347
|
+
# places are included.
|
348
|
+
#
|
349
|
+
def self.standard_datetime( date_or_time_or_date_time )
|
350
|
+
date_or_time_or_date_time.to_time.utc.iso8601( 6 )
|
351
|
+
end
|
352
|
+
|
343
353
|
# Returns an ISO 8601 String equivalent of the given Time or DateTime
|
344
354
|
# instance, with nanosecond precision (subject to Ruby port / OS support).
|
345
355
|
# This is nothing more than a standardised central interface on calling
|
data/lib/hoodoo/version.rb
CHANGED
@@ -382,7 +382,7 @@ describe Hoodoo::ActiveRecord::Secure do
|
|
382
382
|
expect(TestPresenterSecure.render_in(@context, data, options)).to eq({
|
383
383
|
'id' => u,
|
384
384
|
'kind' => 'TestPresenterSecure',
|
385
|
-
'created_at' => t
|
385
|
+
'created_at' => Hoodoo::Utilities.standard_datetime( t ),
|
386
386
|
'language' => 'en-nz',
|
387
387
|
'three' => 'default_three',
|
388
388
|
'secured_with' => {
|
@@ -403,7 +403,7 @@ describe Hoodoo::ActiveRecord::Secure do
|
|
403
403
|
expect(TestPresenterSecure.render_in(@context, data, options)).to eq({
|
404
404
|
'id' => u,
|
405
405
|
'kind' => 'TestPresenterSecure',
|
406
|
-
'created_at' => t
|
406
|
+
'created_at' => Hoodoo::Utilities.standard_datetime( t ),
|
407
407
|
'language' => 'en-nz',
|
408
408
|
'three' => 'default_three',
|
409
409
|
'secured_with' => {
|
@@ -423,7 +423,7 @@ describe Hoodoo::ActiveRecord::Secure do
|
|
423
423
|
expect(TestPresenterSecure.render_in(@context, data, options)).to eq({
|
424
424
|
'id' => u,
|
425
425
|
'kind' => 'TestPresenterSecure',
|
426
|
-
'created_at' => t
|
426
|
+
'created_at' => Hoodoo::Utilities.standard_datetime( t ),
|
427
427
|
'language' => 'en-nz',
|
428
428
|
'three' => 'default_three',
|
429
429
|
'secured_with' => {
|
data/spec/client/client_spec.rb
CHANGED
@@ -28,10 +28,10 @@ class RSpecClientTestSessionImplementation < Hoodoo::Services::Implementation
|
|
28
28
|
#
|
29
29
|
context.response.set_resource(
|
30
30
|
'id' => session_id,
|
31
|
-
'created_at' => Time.now
|
31
|
+
'created_at' => Hoodoo::Utilities.standard_datetime( Time.now ),
|
32
32
|
'kind' => 'RSpecClientTestSession',
|
33
33
|
'caller_id' => context.request.body[ 'caller_id' ],
|
34
|
-
'expires_at' => ( Time.now
|
34
|
+
'expires_at' => Hoodoo::Utilities.standard_datetime( Time.now + 24 * 60 * 60 )
|
35
35
|
)
|
36
36
|
end
|
37
37
|
end
|
@@ -153,7 +153,7 @@ class RSpecClientTestTargetImplementation < Hoodoo::Services::Implementation
|
|
153
153
|
context.request.body.try( :[], 'id' ) ||
|
154
154
|
Hoodoo::UUID.generate(),
|
155
155
|
|
156
|
-
'created_at' => Time.now
|
156
|
+
'created_at' => Hoodoo::Utilities.standard_datetime( Time.now ),
|
157
157
|
'kind' => 'RSpecClientTestTarget',
|
158
158
|
'language' => context.request.locale,
|
159
159
|
|
@@ -95,7 +95,7 @@ describe Hoodoo::Data::Resources::Caller do
|
|
95
95
|
expect(json).to eq(
|
96
96
|
{
|
97
97
|
'id' => id,
|
98
|
-
'created_at' => created_at
|
98
|
+
'created_at' => Hoodoo::Utilities.standard_datetime( created_at ),
|
99
99
|
'kind' => 'Caller',
|
100
100
|
"name" => "Test Caller",
|
101
101
|
"identity" => {
|
@@ -144,7 +144,7 @@ describe Hoodoo::Data::Resources::Caller do
|
|
144
144
|
expect(json).to eq(
|
145
145
|
{
|
146
146
|
'id' => id,
|
147
|
-
'created_at' => created_at
|
147
|
+
'created_at' => Hoodoo::Utilities.standard_datetime( created_at ),
|
148
148
|
'kind' => 'Caller',
|
149
149
|
"identity" => {},
|
150
150
|
"permissions" => { "resources" => {} },
|
@@ -681,7 +681,7 @@ describe '#schema' do
|
|
681
681
|
)).to eq({
|
682
682
|
'id' => uuid,
|
683
683
|
'kind' => 'World',
|
684
|
-
'created_at' => time
|
684
|
+
'created_at' => Hoodoo::Utilities.standard_datetime( time ),
|
685
685
|
'language' => 'en-gb',
|
686
686
|
'errors_id' => data['errors_id'],
|
687
687
|
'test_tags' => 'foo,bar,baz',
|
@@ -797,7 +797,7 @@ describe '#schema' do
|
|
797
797
|
expect(TestPresenter5.render_in(@con, data, options)).to eq({
|
798
798
|
'id' => u,
|
799
799
|
'kind' => 'TestPresenter5',
|
800
|
-
'created_at' => t
|
800
|
+
'created_at' => Hoodoo::Utilities.standard_datetime( t ),
|
801
801
|
'language' => 'de',
|
802
802
|
'three' => 'default_three'
|
803
803
|
})
|
@@ -811,7 +811,7 @@ describe '#schema' do
|
|
811
811
|
expect(TestPresenter5.render_in(@con, data, options)).to eq({
|
812
812
|
'id' => u,
|
813
813
|
'kind' => 'TestPresenter5',
|
814
|
-
'created_at' => t
|
814
|
+
'created_at' => Hoodoo::Utilities.standard_datetime( t ),
|
815
815
|
'language' => 'fr',
|
816
816
|
'three' => 'default_three'
|
817
817
|
})
|
@@ -830,7 +830,7 @@ describe '#schema' do
|
|
830
830
|
expect(TestPresenter5.render_in(@con, data, options)).to eq({
|
831
831
|
'id' => u,
|
832
832
|
'kind' => 'TestPresenter5',
|
833
|
-
'created_at' => t
|
833
|
+
'created_at' => Hoodoo::Utilities.standard_datetime( t ),
|
834
834
|
'language' => 'de',
|
835
835
|
'three' => 'default_three',
|
836
836
|
'_embed' => {
|
@@ -853,7 +853,7 @@ describe '#schema' do
|
|
853
853
|
expect(TestPresenter5.render_in(@con, data, options)).to eq({
|
854
854
|
'id' => u,
|
855
855
|
'kind' => 'TestPresenter5',
|
856
|
-
'created_at' => t
|
856
|
+
'created_at' => Hoodoo::Utilities.standard_datetime( t ),
|
857
857
|
'language' => 'de',
|
858
858
|
'three' => 'default_three',
|
859
859
|
'_reference' => {
|
@@ -63,7 +63,7 @@ describe Hoodoo::Services::Session do
|
|
63
63
|
'caller_id' => '0987',
|
64
64
|
'caller_version' => 2,
|
65
65
|
|
66
|
-
'created_at' => s.created_at
|
66
|
+
'created_at' => Hoodoo::Utilities.standard_datetime( s.created_at ),
|
67
67
|
|
68
68
|
'identity' => { 'foo' => 'foo', 'bar' => 'bar' },
|
69
69
|
'scoping' => { 'baz' => [ 'foo', 'bar', 'baz' ] },
|
@@ -81,8 +81,8 @@ describe Hoodoo::Services::Session do
|
|
81
81
|
'caller_id' => '0987',
|
82
82
|
'caller_version' => 2,
|
83
83
|
|
84
|
-
'created_at' => c
|
85
|
-
'expires_at' => e
|
84
|
+
'created_at' => Hoodoo::Utilities.standard_datetime( c ),
|
85
|
+
'expires_at' => Hoodoo::Utilities.standard_datetime( e ),
|
86
86
|
|
87
87
|
'identity' => { 'foo' => 'foo', 'bar' => 'bar' },
|
88
88
|
'scoping' => { 'baz' => [ 'foo', 'bar', 'baz' ] },
|
@@ -94,8 +94,8 @@ describe Hoodoo::Services::Session do
|
|
94
94
|
expect( s.session_id ).to eq( '1234' )
|
95
95
|
expect( s.caller_id ).to eq( '0987' )
|
96
96
|
expect( s.caller_version ).to eq( 2 )
|
97
|
-
expect( s.created_at ).to eq( Time.parse(
|
98
|
-
expect( s.expires_at ).to eq( Time.parse(
|
97
|
+
expect( s.created_at ).to eq( Time.parse( Hoodoo::Utilities.standard_datetime( c ) ) )
|
98
|
+
expect( s.expires_at ).to eq( Time.parse( Hoodoo::Utilities.standard_datetime( e ) ) )
|
99
99
|
expect( s.identity.foo ).to eq( 'foo' )
|
100
100
|
expect( s.identity.bar ).to eq( 'bar' )
|
101
101
|
expect( s.scoping.baz ).to eq( [ 'foo', 'bar', 'baz' ] )
|
@@ -131,8 +131,8 @@ describe Hoodoo::Services::Session do
|
|
131
131
|
s2 = described_class.new
|
132
132
|
expect( s2.load_from_store!( s1.session_id ) ).to eq( :ok )
|
133
133
|
|
134
|
-
expect( s2.created_at ).to eq( Time.parse( s1.created_at
|
135
|
-
expect( s2.expires_at ).to eq( Time.parse( s1.expires_at
|
134
|
+
expect( s2.created_at ).to eq( Time.parse( Hoodoo::Utilities.standard_datetime( s1.created_at ) ) )
|
135
|
+
expect( s2.expires_at ).to eq( Time.parse( Hoodoo::Utilities.standard_datetime( s1.expires_at ) ) )
|
136
136
|
expect( s2.session_id ).to eq( s1.session_id )
|
137
137
|
expect( s2.memcached_host ).to be_nil
|
138
138
|
expect( s2.caller_id ).to eq( s1.caller_id )
|
@@ -321,7 +321,7 @@ describe Hoodoo::Services::Session do
|
|
321
321
|
|
322
322
|
expect( s ).to receive( :to_h ).and_wrap_original do | obj, args |
|
323
323
|
h = obj.call( *args )
|
324
|
-
h[ 'expires_at' ] = ( Time.now - 1 )
|
324
|
+
h[ 'expires_at' ] = Hoodoo::Utilities.standard_datetime( Time.now - 1 )
|
325
325
|
h
|
326
326
|
end
|
327
327
|
|
@@ -485,6 +485,38 @@ describe Hoodoo::Utilities do
|
|
485
485
|
end
|
486
486
|
end
|
487
487
|
|
488
|
+
describe '#standard_iso8601' do
|
489
|
+
before :each do
|
490
|
+
@old_tz = ENV[ 'TZ' ]
|
491
|
+
ENV[ 'TZ' ] = 'EST'
|
492
|
+
end
|
493
|
+
|
494
|
+
after :each do
|
495
|
+
@old_tz.blank? ? ENV.delete( 'TZ' ) : ENV[ 'TZ' ] = @old_tz
|
496
|
+
end
|
497
|
+
|
498
|
+
it 'accepts a non-UTC Time and renders a UTC date-time' do
|
499
|
+
now = Time.new( 2017, 7, 28, 8, 41, 15 ) + 0.123456789
|
500
|
+
iso = now.utc.iso8601( 6 )
|
501
|
+
|
502
|
+
expect( Hoodoo::Utilities.standard_datetime( now ) ).to eq( iso )
|
503
|
+
end
|
504
|
+
|
505
|
+
it 'accepts a non-UTC Date and renders a UTC date-time' do
|
506
|
+
now = Date.new( 2017, 7, 28 )
|
507
|
+
iso = now.to_time.utc.iso8601( 6 )
|
508
|
+
|
509
|
+
expect( Hoodoo::Utilities.standard_datetime( now ) ).to eq( iso )
|
510
|
+
end
|
511
|
+
|
512
|
+
it 'accepts a non-UTC DateTime and renders a UTC date-time' do
|
513
|
+
now = DateTime.new( 2017, 7, 28, 8, 41, 15 ) + 0.123456789
|
514
|
+
iso = now.to_time.utc.iso8601( 6 )
|
515
|
+
|
516
|
+
expect( Hoodoo::Utilities.standard_datetime( now ) ).to eq( iso )
|
517
|
+
end
|
518
|
+
end
|
519
|
+
|
488
520
|
describe '#nanosecond_iso8601' do
|
489
521
|
it 'should convert DateTime to a nanosecond precision String' do
|
490
522
|
now = DateTime.now()
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hoodoo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.17.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Loyalty New Zealand
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dalli
|