shamu 0.0.21 → 0.0.24
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/.rubocop.yml +1 -1
- data/.ruby-version +1 -1
- data/Gemfile +3 -1
- data/Gemfile.lock +70 -69
- data/app/README +1 -0
- data/config/environment.rb +1 -0
- data/lib/shamu/attributes.rb +26 -0
- data/lib/shamu/attributes/equality.rb +10 -1
- data/lib/shamu/entities/entity.rb +11 -0
- data/lib/shamu/entities/list_scope.rb +3 -0
- data/lib/shamu/entities/list_scope/sorting.rb +6 -1
- data/lib/shamu/entities/list_scope/window_paging.rb +1 -1
- data/lib/shamu/entities/null_entity.rb +18 -12
- data/lib/shamu/entities/opaque_id.rb +9 -8
- data/lib/shamu/error.rb +24 -3
- data/lib/shamu/events/active_record/migration.rb +0 -2
- data/lib/shamu/events/active_record/service.rb +3 -1
- data/lib/shamu/events/events_service.rb +2 -2
- data/lib/shamu/events/in_memory/async_service.rb +4 -2
- data/lib/shamu/events/in_memory/service.rb +3 -1
- data/lib/shamu/features/features_service.rb +3 -1
- data/lib/shamu/features/support.rb +1 -1
- data/lib/shamu/json_api/rails/controller.rb +1 -1
- data/lib/shamu/locale/en.yml +14 -2
- data/lib/shamu/security/active_record_policy.rb +2 -1
- data/lib/shamu/security/error.rb +1 -1
- data/lib/shamu/security/policy.rb +14 -4
- data/lib/shamu/security/principal.rb +22 -2
- data/lib/shamu/security/roles.rb +4 -3
- data/lib/shamu/services.rb +3 -1
- data/lib/shamu/services/active_record.rb +2 -1
- data/lib/shamu/services/active_record_crud.rb +43 -19
- data/lib/shamu/services/lazy_association.rb +50 -18
- data/lib/shamu/services/observable_support.rb +73 -0
- data/lib/shamu/services/observed_request.rb +76 -0
- data/lib/shamu/services/request.rb +12 -0
- data/lib/shamu/services/request_support.rb +24 -2
- data/lib/shamu/services/result.rb +62 -1
- data/lib/shamu/services/service.rb +58 -33
- data/lib/shamu/sessions/cookie_store.rb +3 -1
- data/lib/shamu/sessions/session_store.rb +2 -2
- data/lib/shamu/version.rb +1 -1
- data/shamu.gemspec +1 -1
- data/spec/lib/shamu/entities/entity_lookup_service_spec.rb +1 -1
- data/spec/lib/shamu/entities/list_scope/sorting_spec.rb +1 -1
- data/spec/lib/shamu/entities/null_entity_spec.rb +6 -1
- data/spec/lib/shamu/entities/opaque_id_spec.rb +13 -6
- data/spec/lib/shamu/entities/static_repository_spec.rb +2 -2
- data/spec/lib/shamu/rails/entity_spec.rb +1 -1
- data/spec/lib/shamu/rails/features_spec.rb +1 -1
- data/spec/lib/shamu/security/principal_spec.rb +25 -0
- data/spec/lib/shamu/services/active_record_crud_spec.rb +39 -4
- data/spec/lib/shamu/services/lazy_association_spec.rb +19 -6
- data/spec/lib/shamu/services/observable_support_spec.rb +55 -0
- data/spec/lib/shamu/services/observed_request_spec.rb +46 -0
- data/spec/lib/shamu/services/request_support_spec.rb +54 -3
- data/spec/lib/shamu/services/service_spec.rb +16 -27
- metadata +15 -5
@@ -8,10 +8,10 @@ module ServiceSpec
|
|
8
8
|
def process( params )
|
9
9
|
with_request( params, Request::Change ) do |request|
|
10
10
|
request_hook
|
11
|
-
next error( :base, "nope" ) if request.level < 0
|
11
|
+
next request.error( :base, "nope" ) if request.level < 0
|
12
12
|
|
13
13
|
record = OpenStruct.new( request.to_attributes )
|
14
|
-
scorpion.fetch ServiceSpec::Entity,
|
14
|
+
scorpion.fetch ServiceSpec::Entity, record: record
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -24,10 +24,11 @@ module ServiceSpec
|
|
24
24
|
public :cached_lookup
|
25
25
|
public :lookup_association
|
26
26
|
public :lazy_association
|
27
|
+
public :cache_for
|
27
28
|
|
28
29
|
def build_entities( records )
|
29
30
|
records.map do |record|
|
30
|
-
scorpion.fetch ServiceSpec::Entity,
|
31
|
+
scorpion.fetch ServiceSpec::Entity, record: record
|
31
32
|
end
|
32
33
|
end
|
33
34
|
end
|
@@ -121,7 +122,7 @@ describe Shamu::Services::Service do
|
|
121
122
|
|
122
123
|
it "matches on id by default" do
|
123
124
|
list = service.entity_lookup_list( records, [record.id], ServiceSpec::NullEntity ) do |records|
|
124
|
-
records.map { |r| scorpion.fetch ServiceSpec::Entity,
|
125
|
+
records.map { |r| scorpion.fetch ServiceSpec::Entity, record: r }
|
125
126
|
end
|
126
127
|
|
127
128
|
expect( list.first ).to be_present
|
@@ -129,7 +130,7 @@ describe Shamu::Services::Service do
|
|
129
130
|
|
130
131
|
it "matches on id with string numbers" do
|
131
132
|
list = service.entity_lookup_list( records, [record.id.to_s], ServiceSpec::NullEntity ) do |records|
|
132
|
-
records.map { |r| scorpion.fetch ServiceSpec::Entity,
|
133
|
+
records.map { |r| scorpion.fetch ServiceSpec::Entity, record: r }
|
133
134
|
end
|
134
135
|
|
135
136
|
expect( list.first ).to be_present
|
@@ -137,7 +138,7 @@ describe Shamu::Services::Service do
|
|
137
138
|
|
138
139
|
it "matches on a custom field" do
|
139
140
|
list = service.entity_lookup_list( records, [record.amount], ServiceSpec::NullEntity, match: :amount ) do |records| # rubocop:disable Metrics/LineLength
|
140
|
-
records.map { |r| scorpion.fetch ServiceSpec::Entity,
|
141
|
+
records.map { |r| scorpion.fetch ServiceSpec::Entity, record: r }
|
141
142
|
end
|
142
143
|
|
143
144
|
expect( list.first ).to be_present
|
@@ -146,7 +147,7 @@ describe Shamu::Services::Service do
|
|
146
147
|
it "matches with a custom proc" do
|
147
148
|
matcher = ->( record ) { record.amount }
|
148
149
|
list = service.entity_lookup_list( records, [record.amount], ServiceSpec::NullEntity, match: matcher ) do |records| # rubocop:disable Metrics/LineLength
|
149
|
-
records.map { |r| scorpion.fetch ServiceSpec::Entity,
|
150
|
+
records.map { |r| scorpion.fetch ServiceSpec::Entity, record: r }
|
150
151
|
end
|
151
152
|
|
152
153
|
expect( list.first ).to be_present
|
@@ -269,50 +270,38 @@ describe Shamu::Services::Service do
|
|
269
270
|
end
|
270
271
|
end
|
271
272
|
|
273
|
+
let( :cache ) { service.cache_for( entity: service ) }
|
274
|
+
|
272
275
|
it "returns nil if id is nil" do
|
273
|
-
expect( service.lookup_association( nil, service ) ).to be_nil
|
276
|
+
expect( service.lookup_association( nil, service, cache ) ).to be_nil
|
274
277
|
end
|
275
278
|
|
276
279
|
it "yields to get all association links" do
|
277
280
|
expect do |b|
|
278
|
-
service.lookup_association( 1, service, &b )
|
281
|
+
service.lookup_association( 1, service, cache, &b )
|
279
282
|
end.to yield_control
|
280
283
|
end
|
281
284
|
|
282
285
|
it "finds assocation from cache" do
|
283
|
-
service.lookup_association( 1, service ) do
|
286
|
+
service.lookup_association( 1, service, cache ) do
|
284
287
|
[ 1, 2 ]
|
285
288
|
end
|
286
289
|
|
287
290
|
expect do |b|
|
288
|
-
service.lookup_association( 1, service, &b )
|
291
|
+
service.lookup_association( 1, service, cache, &b )
|
289
292
|
end.not_to yield_control
|
290
293
|
end
|
291
294
|
|
292
295
|
it "returns the found entity with no records" do
|
293
|
-
result = service.lookup_association( 1, service )
|
296
|
+
result = service.lookup_association( 1, service, cache )
|
294
297
|
expect( result ).to be_a ServiceSpec::Entity
|
295
298
|
end
|
296
299
|
|
297
300
|
it "returns the found entity with bulk records" do
|
298
|
-
result = service.lookup_association( 1, service ) do
|
301
|
+
result = service.lookup_association( 1, service, cache ) do
|
299
302
|
[ 1, 2 ]
|
300
303
|
end
|
301
304
|
expect( result ).to be_a ServiceSpec::Entity
|
302
305
|
end
|
303
306
|
end
|
304
|
-
|
305
|
-
describe "#lazy_association" do
|
306
|
-
before( :each ) do
|
307
|
-
allow( service ).to receive( :lookup ) do |*ids|
|
308
|
-
ids.map { |id| ServiceSpec::Entity.null_entity.new( id: id ) }
|
309
|
-
end
|
310
|
-
end
|
311
|
-
|
312
|
-
it "gets a lazy association" do
|
313
|
-
expect( service.lazy_association( 1, service ) ).to be_a Shamu::Services::LazyAssociation
|
314
|
-
end
|
315
|
-
|
316
|
-
|
317
|
-
end
|
318
307
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shamu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.24
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Alexander
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 1.0.1
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 1.0.1
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: multi_json
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -215,10 +215,12 @@ files:
|
|
215
215
|
- LICENSE
|
216
216
|
- README.md
|
217
217
|
- Rakefile
|
218
|
+
- app/README
|
218
219
|
- bin/rake
|
219
220
|
- bin/rspec
|
220
221
|
- circle.yml
|
221
222
|
- config.ru
|
223
|
+
- config/environment.rb
|
222
224
|
- lib/generators/shamu.rb
|
223
225
|
- lib/generators/shamu/api_controller/api_controller_generator.rb
|
224
226
|
- lib/generators/shamu/api_controller/templates/api_controller.rb
|
@@ -359,6 +361,8 @@ files:
|
|
359
361
|
- lib/shamu/services/error.rb
|
360
362
|
- lib/shamu/services/lazy_association.rb
|
361
363
|
- lib/shamu/services/lazy_transform.rb
|
364
|
+
- lib/shamu/services/observable_support.rb
|
365
|
+
- lib/shamu/services/observed_request.rb
|
362
366
|
- lib/shamu/services/request.rb
|
363
367
|
- lib/shamu/services/request_support.rb
|
364
368
|
- lib/shamu/services/result.rb
|
@@ -451,11 +455,14 @@ files:
|
|
451
455
|
- spec/lib/shamu/security/policy_refinement_spec.rb
|
452
456
|
- spec/lib/shamu/security/policy_rule_spec.rb
|
453
457
|
- spec/lib/shamu/security/policy_spec.rb
|
458
|
+
- spec/lib/shamu/security/principal_spec.rb
|
454
459
|
- spec/lib/shamu/security/roles_spec.rb
|
455
460
|
- spec/lib/shamu/services/active_record_crud_spec.rb
|
456
461
|
- spec/lib/shamu/services/active_record_spec.rb
|
457
462
|
- spec/lib/shamu/services/lazy_association_spec.rb
|
458
463
|
- spec/lib/shamu/services/lazy_transform_spec.rb
|
464
|
+
- spec/lib/shamu/services/observable_support_spec.rb
|
465
|
+
- spec/lib/shamu/services/observed_request_spec.rb
|
459
466
|
- spec/lib/shamu/services/request_spec.rb
|
460
467
|
- spec/lib/shamu/services/request_support_spec.rb
|
461
468
|
- spec/lib/shamu/services/result_spec.rb
|
@@ -488,7 +495,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
488
495
|
version: '0'
|
489
496
|
requirements: []
|
490
497
|
rubyforge_project:
|
491
|
-
rubygems_version: 2.6.
|
498
|
+
rubygems_version: 2.6.12
|
492
499
|
signing_key:
|
493
500
|
specification_version: 4
|
494
501
|
summary: Have a whale of a good time adding Service Oriented Architecture to your
|
@@ -574,11 +581,14 @@ test_files:
|
|
574
581
|
- spec/lib/shamu/security/policy_refinement_spec.rb
|
575
582
|
- spec/lib/shamu/security/policy_rule_spec.rb
|
576
583
|
- spec/lib/shamu/security/policy_spec.rb
|
584
|
+
- spec/lib/shamu/security/principal_spec.rb
|
577
585
|
- spec/lib/shamu/security/roles_spec.rb
|
578
586
|
- spec/lib/shamu/services/active_record_crud_spec.rb
|
579
587
|
- spec/lib/shamu/services/active_record_spec.rb
|
580
588
|
- spec/lib/shamu/services/lazy_association_spec.rb
|
581
589
|
- spec/lib/shamu/services/lazy_transform_spec.rb
|
590
|
+
- spec/lib/shamu/services/observable_support_spec.rb
|
591
|
+
- spec/lib/shamu/services/observed_request_spec.rb
|
582
592
|
- spec/lib/shamu/services/request_spec.rb
|
583
593
|
- spec/lib/shamu/services/request_support_spec.rb
|
584
594
|
- spec/lib/shamu/services/result_spec.rb
|