strum-service 0.0.2 → 0.1.2

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: '0710157868640a5904ef6996d2e13f1b91cdcca1025b6a0b95b9230853ba3609'
4
- data.tar.gz: 5d8a21d6d8fb7751e780881cad8ba3f7a02556868b50a82e99455f41b98166c9
3
+ metadata.gz: d3b57fcda6fa8662e4a8aa3184e7ae87c39dd56e51cbf11e7958dd61d041e658
4
+ data.tar.gz: 46132e5ce26025e2f38ba7d538ca1d2ebcb4f11217f9b4a6c6036c3034c5e8b0
5
5
  SHA512:
6
- metadata.gz: 8af13f2c86dbea7ba37f27a32e1076d1a14f0122682dc8e5e27f1f4ead683545a2acc03fc1b4a071c5942fdadf1b8f2967a6f8f246f75f55432fca051182396a
7
- data.tar.gz: aae52d447451bdab8b023f529802af7eee7d95ee5eb6191a4e330782a4838ea0d79cdd3c04c54affad0136e0a2cc0fc8442eafc4416f6d57b221558bdab079e3
6
+ metadata.gz: e891840754a5532e7a4c2d58116694cb38e7a12dab25e51503b72578bf7303721c870dda4a0920a08e572c640e8885fa7c7abbe7fdf1d0badf633f6fe7554893
7
+ data.tar.gz: 43fadda3c343cdedab64fb4ae4d237c184f0f4847e7525d278b4a1fc4631fb5cc97572e49aa212bce96d01cfdd82343670e10152ce781fa6ab48616edd94b0bd
data/Gemfile.lock CHANGED
@@ -1,51 +1,51 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- strum-service (0.0.2)
4
+ strum-service (0.1.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- ast (2.4.1)
9
+ ast (2.4.2)
10
10
  diff-lcs (1.4.4)
11
11
  parallel (1.20.1)
12
- parser (2.7.2.0)
12
+ parser (3.0.1.1)
13
13
  ast (~> 2.4.1)
14
14
  rainbow (3.0.0)
15
15
  rake (12.3.3)
16
- regexp_parser (2.0.0)
17
- rexml (3.2.4)
16
+ regexp_parser (2.1.1)
17
+ rexml (3.2.5)
18
18
  rspec (3.10.0)
19
19
  rspec-core (~> 3.10.0)
20
20
  rspec-expectations (~> 3.10.0)
21
21
  rspec-mocks (~> 3.10.0)
22
- rspec-core (3.10.0)
22
+ rspec-core (3.10.1)
23
23
  rspec-support (~> 3.10.0)
24
- rspec-expectations (3.10.0)
24
+ rspec-expectations (3.10.1)
25
25
  diff-lcs (>= 1.2.0, < 2.0)
26
26
  rspec-support (~> 3.10.0)
27
- rspec-mocks (3.10.0)
27
+ rspec-mocks (3.10.2)
28
28
  diff-lcs (>= 1.2.0, < 2.0)
29
29
  rspec-support (~> 3.10.0)
30
- rspec-support (3.10.0)
31
- rubocop (1.5.0)
30
+ rspec-support (3.10.2)
31
+ rubocop (1.15.0)
32
32
  parallel (~> 1.10)
33
- parser (>= 2.7.1.5)
33
+ parser (>= 3.0.0.0)
34
34
  rainbow (>= 2.2.2, < 4.0)
35
- regexp_parser (>= 2.0)
35
+ regexp_parser (>= 1.8, < 3.0)
36
36
  rexml
37
- rubocop-ast (>= 1.2.0)
37
+ rubocop-ast (>= 1.5.0, < 2.0)
38
38
  ruby-progressbar (~> 1.7)
39
- unicode-display_width (>= 1.4.0, < 2.0)
40
- rubocop-ast (1.3.0)
41
- parser (>= 2.7.1.5)
39
+ unicode-display_width (>= 1.4.0, < 3.0)
40
+ rubocop-ast (1.5.0)
41
+ parser (>= 3.0.1.1)
42
42
  rubocop-rake (0.5.1)
43
43
  rubocop
44
- rubocop-rspec (2.0.0)
44
+ rubocop-rspec (2.0.1)
45
45
  rubocop (~> 1.0)
46
46
  rubocop-ast (>= 1.1.0)
47
- ruby-progressbar (1.10.1)
48
- unicode-display_width (1.7.0)
47
+ ruby-progressbar (1.11.0)
48
+ unicode-display_width (2.0.0)
49
49
 
50
50
  PLATFORMS
51
51
  ruby
@@ -60,4 +60,4 @@ DEPENDENCIES
60
60
  strum-service!
61
61
 
62
62
  BUNDLED WITH
63
- 2.1.4
63
+ 2.2.15
data/lib/strum/service.rb CHANGED
@@ -13,10 +13,20 @@ module Strum
13
13
  end
14
14
  end
15
15
 
16
+ # Define coercive methods
17
+ COERCIVE_METHODS = %i[add_error add_errors any required sliced sliced_list].freeze
18
+
19
+ COERCIVE_METHODS.each do |m|
20
+ define_method("#{m}!") do |*args, **kwargs, &block|
21
+ send(m, *args, **kwargs, &block)
22
+ throw :exit unless valid?
23
+ end
24
+ end
25
+
16
26
  # Internal: Interactor class methods.
17
27
  module ClassMethods
18
28
  def call(main_input, **args, &block)
19
- new(main_input, args).execute(&block)
29
+ new(main_input, **args).execute(&block)
20
30
  end
21
31
  end
22
32
 
@@ -27,12 +37,16 @@ module Strum
27
37
  self.outputs = {}
28
38
  self.inputs = args.merge(default: main_input)
29
39
  self._inputs = inputs.dup.freeze
40
+ setup_default_proc
41
+ setup_input_default_proc
30
42
  end
31
43
 
32
44
  def execute
33
- audit
34
- yield(self) if block_given?
35
- call if valid?
45
+ catch(:exit) do
46
+ audit
47
+ yield(self) if block_given?
48
+ call if valid?
49
+ end
36
50
  valid? ? valid_result : invalid_result
37
51
  end
38
52
 
@@ -61,9 +75,10 @@ module Strum
61
75
  end
62
76
 
63
77
  def method_missing(method_name, *args, &_block)
64
- super unless input.is_a?(Hash) && input[method_name.to_sym]
65
-
66
- args.count.positive? ? public_send(input[method_name.to_sym], args) : input[method_name.to_sym]
78
+ (args.count.zero? &&
79
+ (input.is_a?(Hash) && input[method_name.to_sym]) ||
80
+ inputs[method_name.to_sym]) ||
81
+ super
67
82
  end
68
83
 
69
84
  def respond_to_missing?(method_name, include_private = false)
@@ -120,7 +135,7 @@ module Strum
120
135
 
121
136
  def add_error(field, value)
122
137
  strum_errors[field] ||= []
123
- strum_errors[field] = strum_errors[field] + Array(value)
138
+ strum_errors[field] += Array(value)
124
139
  end
125
140
 
126
141
  def add_errors(errors)
@@ -169,6 +184,14 @@ module Strum
169
184
 
170
185
  private
171
186
 
187
+ def setup_default_proc
188
+ inputs.default_proc = proc { |h, k| h.key?(k.to_s) ? h[k.to_s] : nil }
189
+ end
190
+
191
+ def setup_input_default_proc
192
+ input.default_proc = proc { |h, k| h.key?(k.to_s) ? h[k.to_s] : nil } if input.is_a?(Hash)
193
+ end
194
+
172
195
  def key_to_sym(key)
173
196
  key.to_sym
174
197
  rescue StandardError
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Strum
4
4
  module Service
5
- VERSION = "0.0.2"
5
+ VERSION = "0.1.2"
6
6
  end
7
7
  end
@@ -10,15 +10,16 @@ Gem::Specification.new do |spec|
10
10
 
11
11
  spec.summary = "Light ruby framework"
12
12
  spec.description = "Strum Service"
13
- spec.homepage = "https://code.qpard.com/strum/strum-service"
13
+ spec.homepage = "https://gitlab.com/strum-rb/strum-service"
14
14
  spec.license = "MIT"
15
15
  spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
16
16
 
17
17
  spec.metadata["allowed_push_host"] = "https://rubygems.org"
18
18
 
19
19
  spec.metadata["homepage_uri"] = spec.homepage
20
- spec.metadata["source_code_uri"] = "https://code.qpard.com/strum/strum-service"
21
- spec.metadata["changelog_uri"] = "https://code.qpard.com/strum/strum-service/CHANGELOG.md"
20
+ spec.metadata["source_code_uri"] = "https://gitlab.com/strum-rb/strum-service"
21
+ spec.metadata["changelog_uri"] = "https://gitlab.com/strum-rb/strum-service/-/blob/master/CHANGELOG.md"
22
+ spec.metadata["bug_tracker_uri"] = "https://gitlab.com/strum-rb/strum-service/issues"
22
23
 
23
24
  # Specify which files should be added to the gem when it is released.
24
25
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: strum-service
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Serhiy Nazarov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-02-05 00:00:00.000000000 Z
11
+ date: 2021-05-26 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Strum Service
14
14
  email:
@@ -33,14 +33,15 @@ files:
33
33
  - lib/strum/service.rb
34
34
  - lib/strum/service/version.rb
35
35
  - strum-service.gemspec
36
- homepage: https://code.qpard.com/strum/strum-service
36
+ homepage: https://gitlab.com/strum-rb/strum-service
37
37
  licenses:
38
38
  - MIT
39
39
  metadata:
40
40
  allowed_push_host: https://rubygems.org
41
- homepage_uri: https://code.qpard.com/strum/strum-service
42
- source_code_uri: https://code.qpard.com/strum/strum-service
43
- changelog_uri: https://code.qpard.com/strum/strum-service/CHANGELOG.md
41
+ homepage_uri: https://gitlab.com/strum-rb/strum-service
42
+ source_code_uri: https://gitlab.com/strum-rb/strum-service
43
+ changelog_uri: https://gitlab.com/strum-rb/strum-service/-/blob/master/CHANGELOG.md
44
+ bug_tracker_uri: https://gitlab.com/strum-rb/strum-service/issues
44
45
  post_install_message:
45
46
  rdoc_options: []
46
47
  require_paths:
@@ -56,7 +57,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
56
57
  - !ruby/object:Gem::Version
57
58
  version: '0'
58
59
  requirements: []
59
- rubygems_version: 3.1.4
60
+ rubygems_version: 3.1.6
60
61
  signing_key:
61
62
  specification_version: 4
62
63
  summary: Light ruby framework