resol 0.4.2 → 0.6.1

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: 0dc5047622a240e207abad9020c3835060ae039eb93fa5f3741896d57871f681
4
- data.tar.gz: e608a7e82d8c8d54169d305f7b1dbc01a7e1f6088877a05815d7b95979df4da8
3
+ metadata.gz: 8f8b237f2430ac32748c491d62bdd0bc2b968731f2611e131b02e8570ede129d
4
+ data.tar.gz: e31bdb54460ce66b15ae4dd334687f1364400ddae6742e0d7981f84185fd1c39
5
5
  SHA512:
6
- metadata.gz: 9cdd9fe171f117b346c4ebc787451a9def9fc28fbc23f8023852bb2388eb030e3b898dc883864eb0c4b180683c8f4058c74ee4661e856f0d9ce8e55a33cc46e4
7
- data.tar.gz: 143cd088406f35993f522d3e2549741277eb28fee2b9f99248b86ba9dbd5302b3eee3ec4db9cefbefc8ad8992af64348272e7e09bb068c58b0407df365ce2ce8
6
+ metadata.gz: 44bc7acefa0c91e8c98c008441e1c071eff83b6a14249945d08874cf173c9e843ed4ffd6d9f9c62b76a85b386e7251cb4e1bd58599492b0b813d896df335e69b
7
+ data.tar.gz: 5126dedc456428d860e2293f2617098f63a6275d168b09050b31e8047d033805e94d55fb25358bcb67a00202f6644d579c09d0a75b9b94cab1c2cd9b65587df8
data/Gemfile.lock CHANGED
@@ -1,20 +1,20 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- resol (0.4.2)
5
- smart_initializer (~> 0.5)
4
+ resol (0.6.1)
5
+ smart_initializer (~> 0.7)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activesupport (6.1.3.2)
10
+ activesupport (6.1.4.1)
11
11
  concurrent-ruby (~> 1.0, >= 1.0.2)
12
12
  i18n (>= 1.6, < 2)
13
13
  minitest (>= 5.1)
14
14
  tzinfo (~> 2.0)
15
15
  zeitwerk (~> 2.3)
16
16
  ast (2.4.2)
17
- bundler-audit (0.8.0)
17
+ bundler-audit (0.9.0.1)
18
18
  bundler (>= 1.2.0, < 3)
19
19
  thor (~> 1.0)
20
20
  ci-helper (0.4.2)
@@ -26,21 +26,21 @@ GEM
26
26
  concurrent-ruby (1.1.9)
27
27
  diff-lcs (1.4.4)
28
28
  docile (1.4.0)
29
- dry-inflector (0.2.0)
29
+ dry-inflector (0.2.1)
30
30
  i18n (1.8.10)
31
31
  concurrent-ruby (~> 1.0)
32
32
  method_source (1.0.0)
33
33
  minitest (5.14.4)
34
- parallel (1.20.1)
35
- parser (3.0.1.1)
34
+ parallel (1.21.0)
35
+ parser (3.0.2.0)
36
36
  ast (~> 2.4.1)
37
37
  pry (0.14.1)
38
38
  coderay (~> 1.1)
39
39
  method_source (~> 1.0)
40
- qonfig (0.25.0)
40
+ qonfig (0.26.0)
41
41
  rack (2.2.3)
42
42
  rainbow (3.0.0)
43
- rake (13.0.3)
43
+ rake (13.0.6)
44
44
  regexp_parser (2.1.1)
45
45
  rexml (3.2.5)
46
46
  rspec (3.10.0)
@@ -56,19 +56,19 @@ GEM
56
56
  diff-lcs (>= 1.2.0, < 2.0)
57
57
  rspec-support (~> 3.10.0)
58
58
  rspec-support (3.10.2)
59
- rubocop (1.11.0)
59
+ rubocop (1.17.0)
60
60
  parallel (~> 1.10)
61
61
  parser (>= 3.0.0.0)
62
62
  rainbow (>= 2.2.2, < 4.0)
63
63
  regexp_parser (>= 1.8, < 3.0)
64
64
  rexml
65
- rubocop-ast (>= 1.2.0, < 2.0)
65
+ rubocop-ast (>= 1.7.0, < 2.0)
66
66
  ruby-progressbar (~> 1.7)
67
67
  unicode-display_width (>= 1.4.0, < 3.0)
68
- rubocop-ast (1.7.0)
68
+ rubocop-ast (1.11.0)
69
69
  parser (>= 3.0.1.1)
70
- rubocop-config-umbrellio (1.11.0.51)
71
- rubocop (= 1.11.0)
70
+ rubocop-config-umbrellio (1.17.0.53)
71
+ rubocop (= 1.17.0)
72
72
  rubocop-performance (= 1.10.0)
73
73
  rubocop-rails (= 2.9.1)
74
74
  rubocop-rake (= 0.5.1)
@@ -89,7 +89,7 @@ GEM
89
89
  rubocop-sequel (0.2.0)
90
90
  rubocop (~> 1.0)
91
91
  ruby-progressbar (1.11.0)
92
- sequel (5.45.0)
92
+ sequel (5.48.0)
93
93
  simplecov (0.21.2)
94
94
  docile (~> 1.1)
95
95
  simplecov-html (~> 0.11)
@@ -98,20 +98,20 @@ GEM
98
98
  simplecov-lcov (0.8.0)
99
99
  simplecov_json_formatter (0.1.3)
100
100
  smart_engine (0.11.0)
101
- smart_initializer (0.5.0)
101
+ smart_initializer (0.7.0)
102
102
  qonfig (~> 0.24)
103
103
  smart_engine (~> 0.11)
104
104
  smart_types (~> 0.4)
105
- smart_types (0.4.0)
105
+ smart_types (0.6.0)
106
106
  smart_engine (~> 0.11)
107
- symbiont-ruby (0.6.0)
107
+ symbiont-ruby (0.7.0)
108
108
  thor (1.1.0)
109
109
  tzinfo (2.0.4)
110
110
  concurrent-ruby (~> 1.0)
111
111
  umbrellio-sequel-plugins (0.5.1.27)
112
112
  sequel
113
113
  symbiont-ruby
114
- unicode-display_width (2.0.0)
114
+ unicode-display_width (2.1.0)
115
115
  zeitwerk (2.4.2)
116
116
 
117
117
  PLATFORMS
@@ -131,4 +131,4 @@ DEPENDENCIES
131
131
  simplecov-lcov
132
132
 
133
133
  BUNDLED WITH
134
- 2.2.19
134
+ 2.2.21
data/lib/resol/service.rb CHANGED
@@ -8,58 +8,47 @@ module Resol
8
8
  class Service
9
9
  class InvalidCommandImplementation < StandardError; end
10
10
 
11
- class Interruption < StandardError
12
- attr_accessor :data
11
+ class Failure < StandardError
12
+ attr_accessor :data, :code
13
13
 
14
- def initialize(data)
14
+ def initialize(code, data)
15
+ self.code = code
15
16
  self.data = data
16
- super
17
+ super(data)
17
18
  end
18
19
 
19
20
  def inspect
20
21
  "#{self.class.name}: #{message}"
21
22
  end
22
23
 
23
- def message
24
- data.inspect
25
- end
26
- end
27
-
28
- class Failure < Interruption
29
- attr_accessor :code
30
-
31
- def initialize(code, data)
32
- self.code = code
33
- super(data)
34
- end
35
-
36
24
  def message
37
25
  data ? "#{code.inspect} => #{data.inspect}" : code.inspect
38
26
  end
39
27
  end
40
28
 
41
- class Success < Interruption; end
42
-
43
29
  include SmartCore::Initializer
44
30
  include Resol::Builder
45
31
  include Resol::Callbacks
46
32
 
33
+ Result = Struct.new(:data)
34
+
47
35
  class << self
48
36
  def inherited(klass)
49
37
  klass.const_set(:Failure, Class.new(klass::Failure))
50
- klass.const_set(:Success, Class.new(klass::Success))
51
38
  super
52
39
  end
53
40
 
54
41
  def call(*args, **kwargs, &block)
55
42
  command = build(*args, **kwargs)
56
- __run_callbacks__(command)
57
- command.call(&block)
43
+ result = catch(command) do
44
+ __run_callbacks__(command)
45
+ command.call(&block)
46
+ nil
47
+ end
48
+ return Resol::Success(result.data) unless result.nil?
58
49
 
59
50
  error_message = "No success! or fail! called in the #call method in #{command.class}"
60
51
  raise InvalidCommandImplementation, error_message
61
- rescue self::Success => e
62
- Resol::Success(e.data)
63
52
  rescue self::Failure => e
64
53
  Resol::Failure(e)
65
54
  end
@@ -78,7 +67,7 @@ module Resol
78
67
  end
79
68
 
80
69
  def success!(data = nil)
81
- raise self.class::Success.new(data)
70
+ throw(self, Result.new(data))
82
71
  end
83
72
  end
84
73
  end
data/lib/resol/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Resol
4
- VERSION = "0.4.2"
4
+ VERSION = "0.6.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resol
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aleksei Bespalov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-22 00:00:00.000000000 Z
11
+ date: 2021-09-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: smart_initializer
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.5'
19
+ version: '0.7'
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: '0.5'
26
+ version: '0.7'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler-audit
29
29
  requirement: !ruby/object:Gem::Requirement