resol 0.7.1 → 0.8.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: 5fcf57857ff7296ff6a03d749bf23b753bb7c954f35c646337bafdca35d0b421
4
- data.tar.gz: 70c0d5f63ec8bd3ee7b75b9a4857138d86ba77afa3186af778f3bae357c7922c
3
+ metadata.gz: 4eb71da351b1379daa165b6223a0bb9fd2ff2ae5fd3436642b7cfdc782413917
4
+ data.tar.gz: 62712882caa637dfcfbf9a8f25e1026afeed72cea67c677acdf93c6802ac5cb4
5
5
  SHA512:
6
- metadata.gz: f1c39188fbbfc3280db5989ad7de4f706f5a2064ebd4a55de1a9b1be16f300ffc11d0e7b40907a7273f5a26d0200af4176a9683979e1cafee1d9c47ef92a0c4b
7
- data.tar.gz: 9a7fd22c0ca24a6d8bb1470c95a840c2ab8679009eed7fd0b3f32404735e498553432d09c8f009de160b26eeec33f23f6ec8e9b46dad7be074265386f2b70838
6
+ metadata.gz: 4ae925f82e9deda9fa0c180976a446aff26822eb39e20371065d5e1c185e0473e0ae4e7811dd5f9c07cb09205bec9a3eec5b0458d0a807a81daaf1313133d09d
7
+ data.tar.gz: 5942e294f2a6e99386802e1d2848b6f754a6d8700268aa57079099058e161dd481d4aaec1000eb835dd80ab699f9e5ec2670a54038481dff4c42d324b1d803c5
@@ -16,7 +16,7 @@ jobs:
16
16
  - uses: actions/checkout@v2
17
17
  - uses: ruby/setup-ruby@v1
18
18
  with:
19
- ruby-version: 3
19
+ ruby-version: "3.1"
20
20
  bundler-cache: true
21
21
  - name: Run Linter
22
22
  run: bundle exec ci-helper RubocopLint
@@ -43,7 +43,7 @@ jobs:
43
43
  strategy:
44
44
  fail-fast: false
45
45
  matrix:
46
- ruby: [2.7]
46
+ ruby: ["2.7", "3.0"]
47
47
  experimental: [false]
48
48
  include:
49
49
  - ruby: head
data/Gemfile.lock CHANGED
@@ -1,18 +1,17 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- resol (0.7.1)
4
+ resol (0.8.0)
5
5
  smart_initializer (~> 0.7)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activesupport (6.1.4.1)
10
+ activesupport (7.0.2.2)
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
- zeitwerk (~> 2.3)
16
15
  ast (2.4.2)
17
16
  bundler-audit (0.9.0.1)
18
17
  bundler (>= 1.2.0, < 3)
@@ -24,97 +23,96 @@ GEM
24
23
  coderay (1.1.3)
25
24
  colorize (0.8.1)
26
25
  concurrent-ruby (1.1.9)
27
- diff-lcs (1.4.4)
26
+ diff-lcs (1.5.0)
28
27
  docile (1.4.0)
29
28
  dry-inflector (0.2.1)
30
- i18n (1.8.11)
29
+ i18n (1.10.0)
31
30
  concurrent-ruby (~> 1.0)
32
31
  method_source (1.0.0)
33
- minitest (5.14.4)
32
+ minitest (5.15.0)
34
33
  parallel (1.21.0)
35
- parser (3.0.3.1)
34
+ parser (3.1.1.0)
36
35
  ast (~> 2.4.1)
37
36
  pry (0.14.1)
38
37
  coderay (~> 1.1)
39
38
  method_source (~> 1.0)
40
- qonfig (0.26.0)
39
+ qonfig (0.27.0)
41
40
  rack (2.2.3)
42
- rainbow (3.0.0)
41
+ rainbow (3.1.1)
43
42
  rake (13.0.6)
44
- regexp_parser (2.2.0)
43
+ regexp_parser (2.2.1)
45
44
  rexml (3.2.5)
46
- rspec (3.10.0)
47
- rspec-core (~> 3.10.0)
48
- rspec-expectations (~> 3.10.0)
49
- rspec-mocks (~> 3.10.0)
50
- rspec-core (3.10.1)
51
- rspec-support (~> 3.10.0)
52
- rspec-expectations (3.10.1)
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)
53
52
  diff-lcs (>= 1.2.0, < 2.0)
54
- rspec-support (~> 3.10.0)
55
- rspec-mocks (3.10.2)
53
+ rspec-support (~> 3.11.0)
54
+ rspec-mocks (3.11.0)
56
55
  diff-lcs (>= 1.2.0, < 2.0)
57
- rspec-support (~> 3.10.0)
58
- rspec-support (3.10.3)
59
- rubocop (1.17.0)
56
+ rspec-support (~> 3.11.0)
57
+ rspec-support (3.11.0)
58
+ rubocop (1.25.1)
60
59
  parallel (~> 1.10)
61
- parser (>= 3.0.0.0)
60
+ parser (>= 3.1.0.0)
62
61
  rainbow (>= 2.2.2, < 4.0)
63
62
  regexp_parser (>= 1.8, < 3.0)
64
63
  rexml
65
- rubocop-ast (>= 1.7.0, < 2.0)
64
+ rubocop-ast (>= 1.15.1, < 2.0)
66
65
  ruby-progressbar (~> 1.7)
67
66
  unicode-display_width (>= 1.4.0, < 3.0)
68
- rubocop-ast (1.14.0)
69
- parser (>= 3.0.1.1)
70
- rubocop-config-umbrellio (1.17.0.53)
71
- rubocop (= 1.17.0)
72
- rubocop-performance (= 1.10.0)
73
- rubocop-rails (= 2.9.1)
74
- rubocop-rake (= 0.5.1)
75
- rubocop-rspec (= 2.2.0)
76
- rubocop-sequel (= 0.2.0)
77
- rubocop-performance (1.10.0)
78
- rubocop (>= 0.90.0, < 2.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)
73
+ rubocop-rake (~> 0.6.0)
74
+ rubocop-rspec (~> 2.7.0)
75
+ rubocop-sequel (~> 0.3.3)
76
+ rubocop-performance (1.13.2)
77
+ rubocop (>= 1.7.0, < 2.0)
79
78
  rubocop-ast (>= 0.4.0)
80
- rubocop-rails (2.9.1)
79
+ rubocop-rails (2.13.2)
81
80
  activesupport (>= 4.2.0)
82
81
  rack (>= 1.1)
83
- rubocop (>= 0.90.0, < 2.0)
84
- rubocop-rake (0.5.1)
85
- rubocop
86
- rubocop-rspec (2.2.0)
82
+ rubocop (>= 1.7.0, < 2.0)
83
+ rubocop-rake (0.6.0)
87
84
  rubocop (~> 1.0)
88
- rubocop-ast (>= 1.1.0)
89
- rubocop-sequel (0.2.0)
85
+ rubocop-rspec (2.7.0)
86
+ rubocop (~> 1.19)
87
+ rubocop-sequel (0.3.3)
90
88
  rubocop (~> 1.0)
91
89
  ruby-progressbar (1.11.0)
92
- sequel (5.51.0)
90
+ sequel (5.54.0)
93
91
  simplecov (0.21.2)
94
92
  docile (~> 1.1)
95
93
  simplecov-html (~> 0.11)
96
94
  simplecov_json_formatter (~> 0.1)
97
95
  simplecov-html (0.12.3)
98
96
  simplecov-lcov (0.8.0)
99
- simplecov_json_formatter (0.1.3)
100
- smart_engine (0.11.0)
101
- smart_initializer (0.8.0)
97
+ simplecov_json_formatter (0.1.4)
98
+ smart_engine (0.12.0)
99
+ smart_initializer (0.9.0)
102
100
  qonfig (~> 0.24)
103
101
  smart_engine (~> 0.11)
104
102
  smart_types (~> 0.4)
105
103
  smart_types (0.7.0)
106
104
  smart_engine (~> 0.11)
107
105
  symbiont-ruby (0.7.0)
108
- thor (1.1.0)
106
+ thor (1.2.1)
109
107
  tzinfo (2.0.4)
110
108
  concurrent-ruby (~> 1.0)
111
109
  umbrellio-sequel-plugins (0.5.1.27)
112
110
  sequel
113
111
  symbiont-ruby
114
112
  unicode-display_width (2.1.0)
115
- zeitwerk (2.5.1)
116
113
 
117
114
  PLATFORMS
115
+ arm64-darwin-21
118
116
  x86_64-darwin-19
119
117
  x86_64-darwin-20
120
118
  x86_64-darwin-21
@@ -132,4 +130,4 @@ DEPENDENCIES
132
130
  simplecov-lcov
133
131
 
134
132
  BUNDLED WITH
135
- 2.2.31
133
+ 2.3.8
data/lib/resol/service.rb CHANGED
@@ -7,6 +7,7 @@ require_relative "result"
7
7
  module Resol
8
8
  class Service
9
9
  class InvalidCommandImplementation < StandardError; end
10
+ class InvalidCommandCall < StandardError; end
10
11
 
11
12
  class Failure < StandardError
12
13
  attr_accessor :data, :code
@@ -39,16 +40,21 @@ module Resol
39
40
  end
40
41
 
41
42
  def call(*args, **kwargs, &block)
42
- command = build(*args, **kwargs)
43
- result = catch(command) do
44
- __run_callbacks__(command)
45
- command.call(&block)
46
- nil
43
+ service = build(*args, **kwargs)
44
+
45
+ result = catch(service) do
46
+ service.instance_variable_set(:@__performing__, true)
47
+ __run_callbacks__(service)
48
+ service.call(&block)
49
+ :uncaught
47
50
  end
48
- return Resol::Success(result.data) unless result.nil?
49
51
 
50
- error_message = "No success! or fail! called in the #call method in #{command.class}"
51
- raise InvalidCommandImplementation, error_message
52
+ if result == :uncaught
53
+ error_message = "No `#success!` or `#fail!` called in `#call` method in #{service.class}."
54
+ raise InvalidCommandImplementation, error_message
55
+ else
56
+ Resol::Success(result.data)
57
+ end
52
58
  rescue self::Failure => e
53
59
  Resol::Failure(e)
54
60
  end
@@ -62,12 +68,30 @@ module Resol
62
68
 
63
69
  private
64
70
 
71
+ attr_reader :__performing__
72
+
65
73
  def fail!(code, data = nil)
66
- raise self.class::Failure.new(code, data)
74
+ check_performing do
75
+ raise self.class::Failure.new(code, data)
76
+ end
67
77
  end
68
78
 
69
79
  def success!(data = nil)
70
- throw(self, Result.new(data))
80
+ check_performing do
81
+ throw(self, Result.new(data))
82
+ end
83
+ end
84
+
85
+ def check_performing
86
+ if __performing__
87
+ yield
88
+ else
89
+ error_message =
90
+ "It looks like #call instance method was called directly in #{self.class}. " \
91
+ "You must always use class-level `.call` or `.call!` method."
92
+
93
+ raise InvalidCommandCall, error_message
94
+ end
71
95
  end
72
96
  end
73
97
  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.7.1"
4
+ VERSION = "0.8.0"
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.7.1
4
+ version: 0.8.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: 2021-12-06 00:00:00.000000000 Z
11
+ date: 2022-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: smart_initializer
@@ -180,7 +180,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
180
180
  - !ruby/object:Gem::Version
181
181
  version: '0'
182
182
  requirements: []
183
- rubygems_version: 3.2.15
183
+ rubygems_version: 3.3.5
184
184
  signing_key:
185
185
  specification_version: 4
186
186
  summary: Gem for creating (any) object patterns