light-service 0.13.0 → 0.17.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/project-build.yml +28 -0
  3. data/.travis.yml +3 -9
  4. data/Appraisals +0 -4
  5. data/Gemfile +0 -2
  6. data/README.md +287 -51
  7. data/RELEASES.md +21 -2
  8. data/gemfiles/activesupport_5.gemfile +0 -1
  9. data/gemfiles/activesupport_6.gemfile +0 -1
  10. data/lib/generators/light_service/action_generator.rb +90 -0
  11. data/lib/generators/light_service/generator_utils.rb +45 -0
  12. data/lib/generators/light_service/organizer_generator.rb +66 -0
  13. data/lib/generators/light_service/templates/action_spec_template.erb +31 -0
  14. data/lib/generators/light_service/templates/action_template.erb +30 -0
  15. data/lib/generators/light_service/templates/organizer_spec_template.erb +20 -0
  16. data/lib/generators/light_service/templates/organizer_template.erb +22 -0
  17. data/lib/light-service/action.rb +61 -4
  18. data/lib/light-service/context/key_verifier.rb +18 -1
  19. data/lib/light-service/context.rb +5 -3
  20. data/lib/light-service/errors.rb +1 -0
  21. data/lib/light-service/organizer/reduce_if_else.rb +21 -0
  22. data/lib/light-service/organizer/with_reducer.rb +12 -7
  23. data/lib/light-service/organizer/with_reducer_factory.rb +1 -1
  24. data/lib/light-service/organizer/with_reducer_log_decorator.rb +3 -0
  25. data/lib/light-service/organizer.rb +16 -3
  26. data/lib/light-service/version.rb +1 -1
  27. data/lib/light-service.rb +1 -0
  28. data/light-service.gemspec +6 -1
  29. data/spec/acceptance/after_actions_spec.rb +17 -0
  30. data/spec/acceptance/around_each_spec.rb +15 -0
  31. data/spec/acceptance/log_from_organizer_spec.rb +1 -1
  32. data/spec/acceptance/organizer/add_to_context_spec.rb +27 -0
  33. data/spec/acceptance/organizer/execute_with_add_to_context_spec.rb +28 -0
  34. data/spec/acceptance/organizer/iterate_spec.rb +7 -0
  35. data/spec/acceptance/organizer/reduce_if_else_spec.rb +60 -0
  36. data/spec/acceptance/organizer/reduce_if_spec.rb +6 -0
  37. data/spec/acceptance/organizer/reduce_until_spec.rb +6 -0
  38. data/spec/action_optional_expected_keys_spec.rb +82 -0
  39. data/spec/action_spec.rb +8 -0
  40. data/spec/lib/generators/action_generator_advanced_spec.rb +43 -0
  41. data/spec/lib/generators/action_generator_simple_spec.rb +37 -0
  42. data/spec/lib/generators/full_generator_test_blobs.rb +193 -0
  43. data/spec/lib/generators/organizer_generator_advanced_spec.rb +37 -0
  44. data/spec/lib/generators/organizer_generator_simple_spec.rb +37 -0
  45. data/spec/organizer_spec.rb +5 -0
  46. data/spec/spec_helper.rb +5 -1
  47. data/spec/test_doubles.rb +37 -0
  48. metadata +87 -9
  49. data/gemfiles/activesupport_3.gemfile +0 -8
  50. data/gemfiles/activesupport_4.gemfile +0 -8
  51. data/resources/orchestrators_deprecated.svg +0 -10
@@ -19,6 +19,11 @@ describe LightService::Organizer do
19
19
  result = TestDoubles::AnOrganizer.call(:user => user)
20
20
  expect(result).to eq(ctx)
21
21
  end
22
+
23
+ it "sets itself as the organizer" do
24
+ result = TestDoubles::AnOrganizer.call(:user => user)
25
+ expect(result.organized_by).to eq TestDoubles::AnOrganizer
26
+ end
22
27
  end
23
28
 
24
29
  context "when #with is called with Context" do
data/spec/spec_helper.rb CHANGED
@@ -8,8 +8,10 @@ if ENV['RUN_COVERAGE_REPORT']
8
8
  add_filter 'vendor/'
9
9
  add_filter %r{^/spec/}
10
10
  end
11
-
12
11
  SimpleCov.minimum_coverage_by_file 90
12
+
13
+ require 'codecov'
14
+ SimpleCov.formatter = SimpleCov::Formatter::Codecov
13
15
  end
14
16
 
15
17
  require 'light-service'
@@ -19,5 +21,7 @@ require 'pry'
19
21
  require 'support'
20
22
  require 'test_doubles'
21
23
  require 'stringio'
24
+ require 'fileutils'
25
+ require 'generator_spec'
22
26
 
23
27
  I18n.enforce_available_locales = true
data/spec/test_doubles.rb CHANGED
@@ -74,6 +74,16 @@ module TestDoubles
74
74
  end
75
75
  end
76
76
 
77
+ class AroundEachWithReduceIfOrganizer
78
+ extend LightService::Organizer
79
+
80
+ def self.call(action_arguments)
81
+ with(action_arguments)
82
+ .around_each(AroundEachLoggerHandler)
83
+ .reduce(ReduceIfOrganizer.actions)
84
+ end
85
+ end
86
+
77
87
  class AddsTwoActionWithFetch
78
88
  extend LightService::Action
79
89
 
@@ -566,6 +576,33 @@ module TestDoubles
566
576
  end
567
577
  end
568
578
 
579
+ class AddsNumbersWithOptionalDefaults
580
+ extend LightService::Action
581
+
582
+ expects :first_number
583
+ expects :second_number, :default => ->(ctx) { ctx[:first_number] + 7 }
584
+ expects :third_number, :default => 10
585
+ promises :total
586
+
587
+ executed do |ctx|
588
+ ctx.total = ctx.first_number + ctx.second_number + ctx.third_number
589
+ end
590
+ end
591
+
592
+ class OrganizerWithActionsUsingDefaults
593
+ extend LightService::Organizer
594
+ def self.call
595
+ with(:first_number => 1, :number => 1).reduce(actions)
596
+ end
597
+
598
+ def self.actions
599
+ [
600
+ AddsNumbersWithOptionalDefaults,
601
+ AddToTotalAction
602
+ ]
603
+ end
604
+ end
605
+
569
606
  class AnOrganizerThatAddsToContext
570
607
  extend LightService::Organizer
571
608
  def self.call
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: light-service
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0
4
+ version: 0.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Attila Domokos
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-29 00:00:00.000000000 Z
11
+ date: 2021-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,14 +16,56 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 3.0.0
19
+ version: 4.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 3.0.0
26
+ version: 4.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: generator_spec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.9.4
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.9.4
41
+ - !ruby/object:Gem::Dependency
42
+ name: test-unit
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: appraisal
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.3'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.3'
27
69
  - !ruby/object:Gem::Dependency
28
70
  name: rspec
29
71
  requirement: !ruby/object:Gem::Requirement
@@ -52,6 +94,20 @@ dependencies:
52
94
  - - "~>"
53
95
  - !ruby/object:Gem::Version
54
96
  version: '0.17'
97
+ - !ruby/object:Gem::Dependency
98
+ name: codecov
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0.1'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '0.1'
55
111
  - !ruby/object:Gem::Dependency
56
112
  name: rubocop
57
113
  requirement: !ruby/object:Gem::Requirement
@@ -101,6 +157,7 @@ executables: []
101
157
  extensions: []
102
158
  extra_rdoc_files: []
103
159
  files:
160
+ - ".github/workflows/project-build.yml"
104
161
  - ".gitignore"
105
162
  - ".rspec"
106
163
  - ".rubocop.yml"
@@ -112,10 +169,15 @@ files:
112
169
  - README.md
113
170
  - RELEASES.md
114
171
  - Rakefile
115
- - gemfiles/activesupport_3.gemfile
116
- - gemfiles/activesupport_4.gemfile
117
172
  - gemfiles/activesupport_5.gemfile
118
173
  - gemfiles/activesupport_6.gemfile
174
+ - lib/generators/light_service/action_generator.rb
175
+ - lib/generators/light_service/generator_utils.rb
176
+ - lib/generators/light_service/organizer_generator.rb
177
+ - lib/generators/light_service/templates/action_spec_template.erb
178
+ - lib/generators/light_service/templates/action_template.erb
179
+ - lib/generators/light_service/templates/organizer_spec_template.erb
180
+ - lib/generators/light_service/templates/organizer_template.erb
119
181
  - lib/light-service.rb
120
182
  - lib/light-service/action.rb
121
183
  - lib/light-service/configuration.rb
@@ -128,6 +190,7 @@ files:
128
190
  - lib/light-service/organizer/execute.rb
129
191
  - lib/light-service/organizer/iterate.rb
130
192
  - lib/light-service/organizer/reduce_if.rb
193
+ - lib/light-service/organizer/reduce_if_else.rb
131
194
  - lib/light-service/organizer/reduce_until.rb
132
195
  - lib/light-service/organizer/scoped_reducable.rb
133
196
  - lib/light-service/organizer/verify_call_method_exists.rb
@@ -141,7 +204,6 @@ files:
141
204
  - light-service.gemspec
142
205
  - resources/fail_actions.png
143
206
  - resources/light-service.png
144
- - resources/orchestrators_deprecated.svg
145
207
  - resources/organizer_and_actions.png
146
208
  - resources/skip_actions.png
147
209
  - spec/acceptance/add_numbers_spec.rb
@@ -166,7 +228,9 @@ files:
166
228
  - spec/acceptance/organizer/around_each_with_reduce_if_spec.rb
167
229
  - spec/acceptance/organizer/context_failure_and_skipping_spec.rb
168
230
  - spec/acceptance/organizer/execute_spec.rb
231
+ - spec/acceptance/organizer/execute_with_add_to_context_spec.rb
169
232
  - spec/acceptance/organizer/iterate_spec.rb
233
+ - spec/acceptance/organizer/reduce_if_else_spec.rb
170
234
  - spec/acceptance/organizer/reduce_if_spec.rb
171
235
  - spec/acceptance/organizer/reduce_until_spec.rb
172
236
  - spec/acceptance/organizer/with_callback_spec.rb
@@ -175,10 +239,16 @@ files:
175
239
  - spec/acceptance/testing/context_factory_spec.rb
176
240
  - spec/action_expected_keys_spec.rb
177
241
  - spec/action_expects_and_promises_spec.rb
242
+ - spec/action_optional_expected_keys_spec.rb
178
243
  - spec/action_promised_keys_spec.rb
179
244
  - spec/action_spec.rb
180
245
  - spec/context/inspect_spec.rb
181
246
  - spec/context_spec.rb
247
+ - spec/lib/generators/action_generator_advanced_spec.rb
248
+ - spec/lib/generators/action_generator_simple_spec.rb
249
+ - spec/lib/generators/full_generator_test_blobs.rb
250
+ - spec/lib/generators/organizer_generator_advanced_spec.rb
251
+ - spec/lib/generators/organizer_generator_simple_spec.rb
182
252
  - spec/localization_adapter_spec.rb
183
253
  - spec/organizer/with_reducer_spec.rb
184
254
  - spec/organizer_key_aliases_spec.rb
@@ -211,14 +281,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
211
281
  requirements:
212
282
  - - ">="
213
283
  - !ruby/object:Gem::Version
214
- version: '0'
284
+ version: 2.5.0
215
285
  required_rubygems_version: !ruby/object:Gem::Requirement
216
286
  requirements:
217
287
  - - ">="
218
288
  - !ruby/object:Gem::Version
219
289
  version: '0'
220
290
  requirements: []
221
- rubygems_version: 3.1.2
291
+ rubygems_version: 3.1.6
222
292
  signing_key:
223
293
  specification_version: 4
224
294
  summary: A service skeleton with an emphasis on simplicity
@@ -245,7 +315,9 @@ test_files:
245
315
  - spec/acceptance/organizer/around_each_with_reduce_if_spec.rb
246
316
  - spec/acceptance/organizer/context_failure_and_skipping_spec.rb
247
317
  - spec/acceptance/organizer/execute_spec.rb
318
+ - spec/acceptance/organizer/execute_with_add_to_context_spec.rb
248
319
  - spec/acceptance/organizer/iterate_spec.rb
320
+ - spec/acceptance/organizer/reduce_if_else_spec.rb
249
321
  - spec/acceptance/organizer/reduce_if_spec.rb
250
322
  - spec/acceptance/organizer/reduce_until_spec.rb
251
323
  - spec/acceptance/organizer/with_callback_spec.rb
@@ -254,10 +326,16 @@ test_files:
254
326
  - spec/acceptance/testing/context_factory_spec.rb
255
327
  - spec/action_expected_keys_spec.rb
256
328
  - spec/action_expects_and_promises_spec.rb
329
+ - spec/action_optional_expected_keys_spec.rb
257
330
  - spec/action_promised_keys_spec.rb
258
331
  - spec/action_spec.rb
259
332
  - spec/context/inspect_spec.rb
260
333
  - spec/context_spec.rb
334
+ - spec/lib/generators/action_generator_advanced_spec.rb
335
+ - spec/lib/generators/action_generator_simple_spec.rb
336
+ - spec/lib/generators/full_generator_test_blobs.rb
337
+ - spec/lib/generators/organizer_generator_advanced_spec.rb
338
+ - spec/lib/generators/organizer_generator_simple_spec.rb
261
339
  - spec/localization_adapter_spec.rb
262
340
  - spec/organizer/with_reducer_spec.rb
263
341
  - spec/organizer_key_aliases_spec.rb
@@ -1,8 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "activesupport", "~> 3.0"
6
- gem "appraisal", "~> 2.0"
7
-
8
- gemspec :path => "../"
@@ -1,8 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "activesupport", "~> 4.0"
6
- gem "appraisal", "~> 2.0"
7
-
8
- gemspec :path => "../"
@@ -1,10 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <svg version="1.1"
3
- xmlns="http://www.w3.org/2000/svg"
4
- xmlns:xlink="http://www.w3.org/1999/xlink"
5
- width="350" height="20"
6
- >
7
- <text font-size="20" x="0" y="20" font-family="Verdana">
8
- <tspan fill="red">Orchestrators are DEPRECATED!</tspan>
9
- </text>
10
- </svg>