the_help 3.2.0 → 3.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
  SHA256:
3
- metadata.gz: 42d6ef0b180ed2f150956e8c1bac70fde46e1f6ef221e797e79dbefc0fbb39d7
4
- data.tar.gz: 8656a86feb9ed3054f3a48ba59441e104cfe2db9969443dfe25e1ee568946e19
3
+ metadata.gz: 8430824b2d2a5a8b4fdf1925b234a81c9377f5916e352c967f15b084ba546386
4
+ data.tar.gz: 75a481c9cd39173aafd183ba79ee217bbce2474bcd5b1c3a7daee851cce813ba
5
5
  SHA512:
6
- metadata.gz: d044c6844fc1a052afc36f05f255384eb6234b86b2de566a71779f48c2f5769cae6802c329a2cc3f238b3e6587b868056e5b96cb05c9d2cecc51b41a77e913ab
7
- data.tar.gz: 7ee92bcb59848b90883e5e62d0899c2dcca9b881e7898a186ef629c841923386191d541a2850ed4a0a05bfcb2c4f87bdfd8df1c12f9cdb24bb2dd57e41739326
6
+ metadata.gz: 9398f9ade624bf4f8ff0e843c69226ea652b39f7e713722f2559bb77daaf181593a99e0f0d28f12bfcd7e0d7cf9198a8ae69383e325a03328b81ae2992a0b49f
7
+ data.tar.gz: b050a8e67894e4fd5572c56cd76e0faf29269a847662ac06ca50da8d69ba1404b7793e84fe431a4fa91948edd389478d1349cde32eea6d933fd802b27918d91a
@@ -0,0 +1,17 @@
1
+ # TheHelp Changelog #
2
+
3
+ ## 3.4.0 ##
4
+
5
+ * added `TheHelp::Service#delegate_to_service` method that can be used inside a service definition
6
+ in order to have the current service delegate to another service and use the other service's
7
+ result as its own.
8
+
9
+ ## 3.3.0 ##
10
+
11
+ * Calling `#stop!` with no arguments in a service definition will now check that a result was set
12
+ with either `#result.success` or `#result.error` and raise `TheHelp::NoResultError` if no result
13
+ was set.
14
+
15
+ * You can now call `#stop!` with both a `type:` and `value:` argument. `type:` can be either
16
+ `:error` (the default) or `:success`, and `value:` can be any object. Calling in this manner
17
+ will set the service result to the specified type and value.
@@ -1,50 +1,55 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- the_help (3.2.0)
4
+ the_help (3.4.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- ast (2.4.0)
10
- byebug (11.0.1)
11
- diff-lcs (1.3)
12
- jaro_winkler (1.5.3)
13
- parallel (1.18.0)
14
- parser (2.6.5.0)
15
- ast (~> 2.4.0)
9
+ ast (2.4.1)
10
+ byebug (11.1.3)
11
+ diff-lcs (1.4.4)
12
+ parallel (1.19.2)
13
+ parser (2.7.2.0)
14
+ ast (~> 2.4.1)
16
15
  rainbow (3.0.0)
17
- rake (10.5.0)
16
+ rake (13.0.1)
17
+ regexp_parser (1.8.2)
18
+ rexml (3.2.4)
18
19
  rspec (3.9.0)
19
20
  rspec-core (~> 3.9.0)
20
21
  rspec-expectations (~> 3.9.0)
21
22
  rspec-mocks (~> 3.9.0)
22
- rspec-core (3.9.0)
23
- rspec-support (~> 3.9.0)
24
- rspec-expectations (3.9.0)
23
+ rspec-core (3.9.3)
24
+ rspec-support (~> 3.9.3)
25
+ rspec-expectations (3.9.3)
25
26
  diff-lcs (>= 1.2.0, < 2.0)
26
27
  rspec-support (~> 3.9.0)
27
- rspec-mocks (3.9.0)
28
+ rspec-mocks (3.9.1)
28
29
  diff-lcs (>= 1.2.0, < 2.0)
29
30
  rspec-support (~> 3.9.0)
30
- rspec-support (3.9.0)
31
- rubocop (0.75.1)
32
- jaro_winkler (~> 1.5.1)
31
+ rspec-support (3.9.4)
32
+ rubocop (0.93.1)
33
33
  parallel (~> 1.10)
34
- parser (>= 2.6)
34
+ parser (>= 2.7.1.5)
35
35
  rainbow (>= 2.2.2, < 4.0)
36
+ regexp_parser (>= 1.8)
37
+ rexml
38
+ rubocop-ast (>= 0.6.0)
36
39
  ruby-progressbar (~> 1.7)
37
- unicode-display_width (>= 1.4.0, < 1.7)
40
+ unicode-display_width (>= 1.4.0, < 2.0)
41
+ rubocop-ast (1.1.0)
42
+ parser (>= 2.7.1.5)
38
43
  ruby-progressbar (1.10.1)
39
- unicode-display_width (1.6.0)
40
- yard (0.9.20)
44
+ unicode-display_width (1.7.0)
45
+ yard (0.9.25)
41
46
 
42
47
  PLATFORMS
43
48
  ruby
44
49
 
45
50
  DEPENDENCIES
46
51
  byebug
47
- rake (~> 10.0)
52
+ rake (~> 13.0)
48
53
  rspec (~> 3.0)
49
54
  rubocop (~> 0.50)
50
55
  the_help!
@@ -263,16 +263,21 @@ module TheHelp
263
263
  # @return [TheHelp::Service::Result]
264
264
  def call
265
265
  validate_service_definition
266
+
266
267
  catch(:stop) do
267
268
  authorize
268
269
  log_service_call
269
270
  main
270
271
  check_result!
271
- self.block_result = yield result if block_given?
272
272
  end
273
+
274
+ self.block_result = yield result if block_given?
275
+
273
276
  throw :stop if stop_caller
277
+
274
278
  return block_result if block_given?
275
- return result
279
+
280
+ result
276
281
  end
277
282
 
278
283
  private
@@ -315,11 +320,20 @@ module TheHelp
315
320
  return if authorized?
316
321
  logger.warn("Unauthorized attempt to access #{self.class.name}/#{__id__} " \
317
322
  "as #{context.inspect}")
318
- run_callback(not_authorized, service: self.class, context: context)
323
+ result.error run_callback(not_authorized, service: self.class, context: context)
319
324
  stop!
320
325
  end
321
326
 
322
- def stop!
327
+ def stop!(type: :error, **opts)
328
+ value = opts.fetch(:value) { |key|
329
+ check_result!
330
+ throw :stop
331
+ }
332
+ if type == :success
333
+ result.success value
334
+ else
335
+ result.error value
336
+ end
323
337
  throw :stop
324
338
  end
325
339
 
@@ -335,5 +349,9 @@ module TheHelp
335
349
  end
336
350
  self.stop_caller ||= !continue
337
351
  end
352
+
353
+ def delegate_to_service(*args)
354
+ call_service(*args) { |result| @result = result }
355
+ end
338
356
  end
339
357
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TheHelp
4
- VERSION = '3.2.0'
4
+ VERSION = '3.4.0'
5
5
  end
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
23
23
  spec.require_paths = ['lib']
24
24
 
25
25
  spec.add_development_dependency 'byebug'
26
- spec.add_development_dependency 'rake', '~> 10.0'
26
+ spec.add_development_dependency 'rake', '~> 13.0'
27
27
  spec.add_development_dependency 'rspec', '~> 3.0'
28
28
  spec.add_development_dependency 'rubocop', '~> 0.50'
29
29
  spec.add_development_dependency 'yard'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: the_help
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0
4
+ version: 3.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Wilger
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-11-17 00:00:00.000000000 Z
11
+ date: 2020-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: byebug
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: '13.0'
34
34
  type: :development
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: '10.0'
40
+ version: '13.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -93,6 +93,7 @@ files:
93
93
  - ".rubocop.yml"
94
94
  - ".tool-versions"
95
95
  - ".travis.yml"
96
+ - CHANGELOG.md
96
97
  - CODE_OF_CONDUCT.md
97
98
  - Gemfile
98
99
  - Gemfile.lock