resol 0.8.0 → 0.9.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: 4eb71da351b1379daa165b6223a0bb9fd2ff2ae5fd3436642b7cfdc782413917
4
- data.tar.gz: 62712882caa637dfcfbf9a8f25e1026afeed72cea67c677acdf93c6802ac5cb4
3
+ metadata.gz: 737ecf288d9db1fc0440dda961c9e0a3a9c5072fba6f1f3a4049a67647a782bb
4
+ data.tar.gz: c50a24b67fb2a5c20c37d9a4204ba6c2293b7d597c0aa46085422ff30fbc0d9e
5
5
  SHA512:
6
- metadata.gz: 4ae925f82e9deda9fa0c180976a446aff26822eb39e20371065d5e1c185e0473e0ae4e7811dd5f9c07cb09205bec9a3eec5b0458d0a807a81daaf1313133d09d
7
- data.tar.gz: 5942e294f2a6e99386802e1d2848b6f754a6d8700268aa57079099058e161dd481d4aaec1000eb835dd80ab699f9e5ec2670a54038481dff4c42d324b1d803c5
6
+ metadata.gz: dec029e7a8b86070c7e3090d7f755415d57e88a572c8d67ef29feec935066cba996cfadd71ef3a93e7e4c502c218952bd00d299fa1473673ee4e6923367c199b
7
+ data.tar.gz: 78332a4cc2eb93b82bc1f963ae141c9b1176ec11c7fc145dcbe1219493817d465f971fe94cdbd2d6727acc7b1cb4f0c9c546f51ce3bfc0cb1c3a11680567a62b
data/Gemfile CHANGED
@@ -3,3 +3,12 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gemspec
6
+
7
+ gem "bundler-audit"
8
+ gem "ci-helper"
9
+ gem "pry"
10
+ gem "rake"
11
+ gem "rspec"
12
+ gem "rubocop-config-umbrellio"
13
+ gem "simplecov"
14
+ gem "simplecov-lcov"
data/Gemfile.lock CHANGED
@@ -1,121 +1,142 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- resol (0.8.0)
4
+ resol (0.9.0)
5
5
  smart_initializer (~> 0.7)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activesupport (7.0.2.2)
10
+ activesupport (7.1.2)
11
+ base64
12
+ bigdecimal
11
13
  concurrent-ruby (~> 1.0, >= 1.0.2)
14
+ connection_pool (>= 2.2.5)
15
+ drb
12
16
  i18n (>= 1.6, < 2)
13
17
  minitest (>= 5.1)
18
+ mutex_m
14
19
  tzinfo (~> 2.0)
15
20
  ast (2.4.2)
16
- bundler-audit (0.9.0.1)
21
+ base64 (0.2.0)
22
+ bigdecimal (3.1.4)
23
+ bundler-audit (0.9.1)
17
24
  bundler (>= 1.2.0, < 3)
18
25
  thor (~> 1.0)
19
- ci-helper (0.4.2)
26
+ ci-helper (0.5.0)
20
27
  colorize (~> 0.8)
21
28
  dry-inflector (~> 0.2)
22
29
  umbrellio-sequel-plugins (~> 0.4)
23
30
  coderay (1.1.3)
24
31
  colorize (0.8.1)
25
- concurrent-ruby (1.1.9)
32
+ concurrent-ruby (1.2.2)
33
+ connection_pool (2.4.1)
26
34
  diff-lcs (1.5.0)
27
35
  docile (1.4.0)
28
- dry-inflector (0.2.1)
29
- i18n (1.10.0)
36
+ drb (2.2.0)
37
+ ruby2_keywords
38
+ dry-inflector (0.3.0)
39
+ i18n (1.14.1)
30
40
  concurrent-ruby (~> 1.0)
41
+ json (2.6.3)
31
42
  method_source (1.0.0)
32
- minitest (5.15.0)
33
- parallel (1.21.0)
34
- parser (3.1.1.0)
43
+ minitest (5.20.0)
44
+ mutex_m (0.2.0)
45
+ parallel (1.23.0)
46
+ parser (3.2.2.4)
35
47
  ast (~> 2.4.1)
36
- pry (0.14.1)
48
+ racc
49
+ pry (0.14.2)
37
50
  coderay (~> 1.1)
38
51
  method_source (~> 1.0)
39
- qonfig (0.27.0)
40
- rack (2.2.3)
52
+ qonfig (0.28.0)
53
+ racc (1.7.3)
54
+ rack (3.0.8)
41
55
  rainbow (3.1.1)
42
- rake (13.0.6)
43
- regexp_parser (2.2.1)
44
- rexml (3.2.5)
45
- rspec (3.11.0)
46
- rspec-core (~> 3.11.0)
47
- rspec-expectations (~> 3.11.0)
48
- rspec-mocks (~> 3.11.0)
49
- rspec-core (3.11.0)
50
- rspec-support (~> 3.11.0)
51
- rspec-expectations (3.11.0)
56
+ rake (13.1.0)
57
+ regexp_parser (2.8.2)
58
+ rexml (3.2.6)
59
+ rspec (3.12.0)
60
+ rspec-core (~> 3.12.0)
61
+ rspec-expectations (~> 3.12.0)
62
+ rspec-mocks (~> 3.12.0)
63
+ rspec-core (3.12.2)
64
+ rspec-support (~> 3.12.0)
65
+ rspec-expectations (3.12.3)
52
66
  diff-lcs (>= 1.2.0, < 2.0)
53
- rspec-support (~> 3.11.0)
54
- rspec-mocks (3.11.0)
67
+ rspec-support (~> 3.12.0)
68
+ rspec-mocks (3.12.6)
55
69
  diff-lcs (>= 1.2.0, < 2.0)
56
- rspec-support (~> 3.11.0)
57
- rspec-support (3.11.0)
58
- rubocop (1.25.1)
70
+ rspec-support (~> 3.12.0)
71
+ rspec-support (3.12.1)
72
+ rubocop (1.50.2)
73
+ json (~> 2.3)
59
74
  parallel (~> 1.10)
60
- parser (>= 3.1.0.0)
75
+ parser (>= 3.2.0.0)
61
76
  rainbow (>= 2.2.2, < 4.0)
62
77
  regexp_parser (>= 1.8, < 3.0)
63
- rexml
64
- rubocop-ast (>= 1.15.1, < 2.0)
78
+ rexml (>= 3.2.5, < 4.0)
79
+ rubocop-ast (>= 1.28.0, < 2.0)
65
80
  ruby-progressbar (~> 1.7)
66
- unicode-display_width (>= 1.4.0, < 3.0)
67
- rubocop-ast (1.16.0)
68
- parser (>= 3.1.1.0)
69
- rubocop-config-umbrellio (1.25.0.61)
70
- rubocop (~> 1.25.0)
71
- rubocop-performance (~> 1.13.0)
72
- rubocop-rails (~> 2.13.0)
81
+ unicode-display_width (>= 2.4.0, < 3.0)
82
+ rubocop-ast (1.30.0)
83
+ parser (>= 3.2.1.0)
84
+ rubocop-capybara (2.19.0)
85
+ rubocop (~> 1.41)
86
+ rubocop-config-umbrellio (1.50.0.85)
87
+ rubocop (~> 1.50.0)
88
+ rubocop-performance (~> 1.17.0)
89
+ rubocop-rails (~> 2.19.0)
73
90
  rubocop-rake (~> 0.6.0)
74
- rubocop-rspec (~> 2.7.0)
91
+ rubocop-rspec (~> 2.20.0)
75
92
  rubocop-sequel (~> 0.3.3)
76
- rubocop-performance (1.13.2)
93
+ rubocop-performance (1.17.1)
77
94
  rubocop (>= 1.7.0, < 2.0)
78
95
  rubocop-ast (>= 0.4.0)
79
- rubocop-rails (2.13.2)
96
+ rubocop-rails (2.19.1)
80
97
  activesupport (>= 4.2.0)
81
98
  rack (>= 1.1)
82
- rubocop (>= 1.7.0, < 2.0)
99
+ rubocop (>= 1.33.0, < 2.0)
83
100
  rubocop-rake (0.6.0)
84
101
  rubocop (~> 1.0)
85
- rubocop-rspec (2.7.0)
86
- rubocop (~> 1.19)
87
- rubocop-sequel (0.3.3)
102
+ rubocop-rspec (2.20.0)
103
+ rubocop (~> 1.33)
104
+ rubocop-capybara (~> 2.17)
105
+ rubocop-sequel (0.3.4)
88
106
  rubocop (~> 1.0)
89
- ruby-progressbar (1.11.0)
90
- sequel (5.54.0)
91
- simplecov (0.21.2)
107
+ ruby-progressbar (1.13.0)
108
+ ruby2_keywords (0.0.5)
109
+ sequel (5.74.0)
110
+ bigdecimal
111
+ simplecov (0.22.0)
92
112
  docile (~> 1.1)
93
113
  simplecov-html (~> 0.11)
94
114
  simplecov_json_formatter (~> 0.1)
95
115
  simplecov-html (0.12.3)
96
116
  simplecov-lcov (0.8.0)
97
117
  simplecov_json_formatter (0.1.4)
98
- smart_engine (0.12.0)
99
- smart_initializer (0.9.0)
118
+ smart_engine (0.17.0)
119
+ smart_initializer (0.11.1)
100
120
  qonfig (~> 0.24)
101
- smart_engine (~> 0.11)
102
- smart_types (~> 0.4)
103
- smart_types (0.7.0)
121
+ smart_engine (~> 0.16)
122
+ smart_types (~> 0.8)
123
+ smart_types (0.8.0)
104
124
  smart_engine (~> 0.11)
105
125
  symbiont-ruby (0.7.0)
106
- thor (1.2.1)
107
- tzinfo (2.0.4)
126
+ thor (1.3.0)
127
+ tzinfo (2.0.6)
108
128
  concurrent-ruby (~> 1.0)
109
- umbrellio-sequel-plugins (0.5.1.27)
129
+ umbrellio-sequel-plugins (0.14.0.189)
110
130
  sequel
111
131
  symbiont-ruby
112
- unicode-display_width (2.1.0)
132
+ unicode-display_width (2.5.0)
113
133
 
114
134
  PLATFORMS
115
135
  arm64-darwin-21
116
136
  x86_64-darwin-19
117
137
  x86_64-darwin-20
118
138
  x86_64-darwin-21
139
+ x86_64-darwin-22
119
140
  x86_64-linux
120
141
 
121
142
  DEPENDENCIES
@@ -130,4 +151,4 @@ DEPENDENCIES
130
151
  simplecov-lcov
131
152
 
132
153
  BUNDLED WITH
133
- 2.3.8
154
+ 2.4.10
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Resol
4
+ class Configuration
5
+ DEFAULT_RETURN_ENGINE = ReturnEngine::Catch
6
+
7
+ class << self
8
+ def configure
9
+ SmartCore::Initializer::Configuration.configure do |c|
10
+ self.smartcore_config = c
11
+ yield self
12
+ self.smartcore_config = nil
13
+ end
14
+ end
15
+
16
+ def return_engine
17
+ @return_engine || DEFAULT_RETURN_ENGINE
18
+ end
19
+
20
+ def return_engine=(engine)
21
+ @return_engine = engine
22
+ end
23
+
24
+ private
25
+
26
+ attr_accessor :smartcore_config
27
+
28
+ def method_missing(meth, *args, &block)
29
+ # rubocop:disable Style/SafeNavigation
30
+ if smartcore_config && smartcore_config.respond_to?(meth)
31
+ # rubocop:enable Style/SafeNavigation
32
+ smartcore_config.__send__(meth, *args, &block)
33
+ else
34
+ super(meth, *args, &block)
35
+ end
36
+ end
37
+
38
+ def respond_to_missing?(meth, include_private)
39
+ smartcore_config.respond_to?(meth, include_private)
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Resol
4
+ module ReturnEngine
5
+ module Catch
6
+ extend self
7
+
8
+ def wrap_call(service)
9
+ catch(service) do
10
+ yield
11
+ NOT_EXITED
12
+ end
13
+ end
14
+
15
+ def uncaught_call?(return_obj)
16
+ return_obj == NOT_EXITED
17
+ end
18
+
19
+ def handle_return(service, data)
20
+ throw(service, data)
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Resol
4
+ module ReturnEngine
5
+ module Return
6
+ extend self
7
+
8
+ def wrap_call(_service)
9
+ yield
10
+ end
11
+
12
+ def uncaught_call?(return_obj)
13
+ !return_obj.is_a?(Resol::Service::Result)
14
+ end
15
+
16
+ def handle_return(_service, data)
17
+ data
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Resol
4
+ module ReturnEngine
5
+ NOT_EXITED = Object.new.freeze
6
+ DataWrapper = Struct.new(:data)
7
+ end
8
+ end
9
+
10
+ require_relative "return_engine/catch"
11
+ require_relative "return_engine/return"
data/lib/resol/service.rb CHANGED
@@ -42,14 +42,13 @@ module Resol
42
42
  def call(*args, **kwargs, &block)
43
43
  service = build(*args, **kwargs)
44
44
 
45
- result = catch(service) do
45
+ result = return_engine.wrap_call(service) do
46
46
  service.instance_variable_set(:@__performing__, true)
47
47
  __run_callbacks__(service)
48
48
  service.call(&block)
49
- :uncaught
50
49
  end
51
50
 
52
- if result == :uncaught
51
+ if return_engine.uncaught_call?(result)
53
52
  error_message = "No `#success!` or `#fail!` called in `#call` method in #{service.class}."
54
53
  raise InvalidCommandImplementation, error_message
55
54
  else
@@ -59,6 +58,10 @@ module Resol
59
58
  Resol::Failure(e)
60
59
  end
61
60
 
61
+ def return_engine
62
+ Resol::Configuration.return_engine
63
+ end
64
+
62
65
  def call!(...)
63
66
  call(...).value_or { |error| raise error }
64
67
  end
@@ -78,7 +81,7 @@ module Resol
78
81
 
79
82
  def success!(data = nil)
80
83
  check_performing do
81
- throw(self, Result.new(data))
84
+ self.class.return_engine.handle_return(self, Result.new(data))
82
85
  end
83
86
  end
84
87
 
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.8.0"
4
+ VERSION = "0.9.0"
5
5
  end
data/lib/resol.rb CHANGED
@@ -3,8 +3,9 @@
3
3
  require "smart_core/initializer"
4
4
 
5
5
  require_relative "resol/version"
6
+ require_relative "resol/return_engine"
7
+ require_relative "resol/configuration"
6
8
  require_relative "resol/service"
7
9
 
8
10
  module Resol
9
- Configuration = SmartCore::Initializer::Configuration
10
11
  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.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aleksei Bespalov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-04 00:00:00.000000000 Z
11
+ date: 2023-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: smart_initializer
@@ -24,118 +24,6 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.7'
27
- - !ruby/object:Gem::Dependency
28
- name: bundler-audit
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: ci-helper
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: pry
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: rake
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: rspec
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: rubocop-config-umbrellio
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
- - !ruby/object:Gem::Dependency
112
- name: simplecov
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - ">="
116
- - !ruby/object:Gem::Version
117
- version: '0'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- version: '0'
125
- - !ruby/object:Gem::Dependency
126
- name: simplecov-lcov
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - ">="
130
- - !ruby/object:Gem::Version
131
- version: '0'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - ">="
137
- - !ruby/object:Gem::Version
138
- version: '0'
139
27
  description: Gem for creating (any) object patterns
140
28
  email:
141
29
  - nulldefiner@gmail.com
@@ -158,7 +46,11 @@ files:
158
46
  - lib/resol.rb
159
47
  - lib/resol/builder.rb
160
48
  - lib/resol/callbacks.rb
49
+ - lib/resol/configuration.rb
161
50
  - lib/resol/result.rb
51
+ - lib/resol/return_engine.rb
52
+ - lib/resol/return_engine/catch.rb
53
+ - lib/resol/return_engine/return.rb
162
54
  - lib/resol/service.rb
163
55
  - lib/resol/version.rb
164
56
  homepage: https://github.com/umbrellio/resol
@@ -180,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
180
72
  - !ruby/object:Gem::Version
181
73
  version: '0'
182
74
  requirements: []
183
- rubygems_version: 3.3.5
75
+ rubygems_version: 3.4.21
184
76
  signing_key:
185
77
  specification_version: 4
186
78
  summary: Gem for creating (any) object patterns