strum-service 0.1.0 → 0.2.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: 170761cebb33448b6582a6b19fc488bcb4f77cbf1b437f48b59c36364bb52392
4
- data.tar.gz: 0bf2e44f8b63758ab08c6d56cbfcfcecd51164fd74b8daddc5b33fb2e77e380a
3
+ metadata.gz: b710112b00697a5e9ffa85d91dd191518863157d9d1ad9c7263bbfb8ec37cf07
4
+ data.tar.gz: 73e87d006e34ed66f4930f12682d1a1eba0be9ec4a47e5634c76d149eda1a27f
5
5
  SHA512:
6
- metadata.gz: cc9213ae6a6df339a195e81dbc9d7a8f6ecc98fe6072f5f824dd54bdd8659cf92d1bf932fcf42041ee04e6d99fa658f70116bbbf052daade3d83635c4b5a8613
7
- data.tar.gz: ab000b0cc5c59a24b46ef81e7f24cb27b78c6be6b826f597e132d03356f3524e37338c311596e22b6690942b618dcb0ff5f207fa762f5b622ec3d8ff3267058d
6
+ metadata.gz: 51db6798a851873b819e433e014cc0addfc7bd45c8dab3e40c2a18d3eea8263db919f0eb82f8efd6d1d82781bf406446c4c64959cc7849a4ab95a2485f77d6f6
7
+ data.tar.gz: 3ebec9e9088617fb0c66702bd7f8514dbd2e399d646e37225002cd3de865ff084463f82367fda5e70f3cb525b456bdf1acc06c897eba205ce64967a54a9895e1
data/.gitignore CHANGED
@@ -6,6 +6,9 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ /.rbenv-gemsets
10
+ /.ruby-version
11
+ spec/examples.txt
9
12
 
10
13
  # rspec failure tracking
11
14
  .rspec_status
data/Gemfile.lock CHANGED
@@ -1,51 +1,51 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- strum-service (0.1.0)
4
+ strum-service (0.2.1)
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.2.0)
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.18.4)
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.8.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.8.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
@@ -25,25 +25,28 @@ module Strum
25
25
 
26
26
  # Internal: Interactor class methods.
27
27
  module ClassMethods
28
- def call(main_input, **args, &block)
29
- new(main_input, args).execute(&block)
28
+ def call(main_input, args = {}, &block)
29
+ raise ArgumentError, "Only Hash are allowed for args" unless args.is_a?(Hash)
30
+
31
+ new(main_input, **args).execute(&block)
30
32
  end
31
33
  end
32
34
 
33
35
  # Instance methods
34
- def initialize(main_input, **args)
36
+ def initialize(main_input, args = {})
35
37
  self.strum_errors = {}
36
38
  self.service_handlers = { on: {}, success: {}, failure: {} }
37
39
  self.outputs = {}
38
- main_input.default_proc = proc { |h, k| h.key?(k.to_s) ? h[k.to_s] : nil }
39
40
  self.inputs = args.merge(default: main_input)
40
41
  self._inputs = inputs.dup.freeze
42
+ setup_default_proc
43
+ setup_input_default_proc
41
44
  end
42
45
 
43
- def execute(&block)
46
+ def execute
44
47
  catch(:exit) do
45
48
  audit
46
- instance_exec(self, &block) if block_given?
49
+ yield(self) if block_given?
47
50
  call if valid?
48
51
  end
49
52
  valid? ? valid_result : invalid_result
@@ -74,9 +77,11 @@ module Strum
74
77
  end
75
78
 
76
79
  def method_missing(method_name, *args, &_block)
77
- super unless input.is_a?(Hash) && input[method_name.to_sym]
78
-
79
- args.count.positive? ? public_send(input[method_name.to_sym], args) : input[method_name.to_sym]
80
+ if args.count.zero? && (input.is_a?(Hash) && input.keys.include?(method_name.to_sym))
81
+ input[method_name.to_sym]
82
+ else
83
+ inputs[method_name.to_sym] || super
84
+ end
80
85
  end
81
86
 
82
87
  def respond_to_missing?(method_name, include_private = false)
@@ -182,6 +187,14 @@ module Strum
182
187
 
183
188
  private
184
189
 
190
+ def setup_default_proc
191
+ inputs.default_proc = proc { |h, k| h.key?(k.to_s) ? h[k.to_s] : nil }
192
+ end
193
+
194
+ def setup_input_default_proc
195
+ input.default_proc = proc { |h, k| h.key?(k.to_s) ? h[k.to_s] : nil } if input.is_a?(Hash)
196
+ end
197
+
185
198
  def key_to_sym(key)
186
199
  key.to_sym
187
200
  rescue StandardError
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Strum
4
4
  module Service
5
- VERSION = "0.1.0"
5
+ VERSION = "0.2.1"
6
6
  end
7
7
  end
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
24
24
  # Specify which files should be added to the gem when it is released.
25
25
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
26
26
  spec.files = Dir.chdir(File.expand_path(__dir__)) do
27
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
27
+ `git ls-files -z`.split("\x0").reject { |f| f.match(/^(test|spec|features|\.ruby-version)/) }
28
28
  end
29
29
  spec.bindir = "exe"
30
30
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
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.1.0
4
+ version: 0.2.1
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-05-10 00:00:00.000000000 Z
11
+ date: 2021-08-17 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Strum Service
14
14
  email: