strum-pipe 0.0.1 → 0.0.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: 4f885d394b2784cc2201a011ed63ae06a273fbc7e25888cf9b9fb34d4c0b2f01
4
- data.tar.gz: 5fe1fbc77839c310cdb98e12a32679922818b44ca9d51d8bb29de63be8279f4a
3
+ metadata.gz: b854a2683f2d748d7299eb97e3efc072f09f6d8a6c751dd3c77996b994dd5b5b
4
+ data.tar.gz: 124e3ba0d9accb87c49cd1e62534482d88fe22ba34fbb1abff8f6639643cfd46
5
5
  SHA512:
6
- metadata.gz: cc10915b7aaa1297696bf243983ca105a9a0620389b2b3a4727d3283b52285f09c8f57abfb5039291610497f87e26f42352a4ebc815e69eec79f416a4a51fb0e
7
- data.tar.gz: 90e57ec1d620ffd3e868b2fc218e6fb744ba4c747998749ebf9a7ca3e4cc4f1ccbd2d86d2ce38d10fc171c001534189ad0a313226f9ada2bed6feba18ee24655
6
+ metadata.gz: f920dc64b6d6c97ac0354f669bdbd1fe25d54bba25f4f5fde28e121f80f742b83a399f02dafcc58e38930b09ea26c923fb8219ec86e7fa7ec8b8f50b97fd2add
7
+ data.tar.gz: 58d6622a54f73fcf041749d6aa4c9a2c48f75c8a1ab07d980a9b8f8ba0389f7133b49cf4e28da67cf1c9ddbb39bf9149006b1ddcf40a5eb3c11d874bbeb53973
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- strum-pipe (0.0.1)
5
- strum-service (~> 0.0.3)
4
+ strum-pipe (0.0.2)
5
+ strum-service (~> 0.1.1)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
@@ -10,12 +10,12 @@ GEM
10
10
  ast (2.4.2)
11
11
  diff-lcs (1.4.4)
12
12
  parallel (1.20.1)
13
- parser (3.0.0.0)
13
+ parser (3.0.1.1)
14
14
  ast (~> 2.4.1)
15
15
  rainbow (3.0.0)
16
16
  rake (12.3.3)
17
17
  regexp_parser (2.1.1)
18
- rexml (3.2.4)
18
+ rexml (3.2.5)
19
19
  rspec (3.10.0)
20
20
  rspec-core (~> 3.10.0)
21
21
  rspec-expectations (~> 3.10.0)
@@ -29,24 +29,24 @@ GEM
29
29
  diff-lcs (>= 1.2.0, < 2.0)
30
30
  rspec-support (~> 3.10.0)
31
31
  rspec-support (3.10.2)
32
- rubocop (1.11.0)
32
+ rubocop (1.14.0)
33
33
  parallel (~> 1.10)
34
34
  parser (>= 3.0.0.0)
35
35
  rainbow (>= 2.2.2, < 4.0)
36
36
  regexp_parser (>= 1.8, < 3.0)
37
37
  rexml
38
- rubocop-ast (>= 1.2.0, < 2.0)
38
+ rubocop-ast (>= 1.5.0, < 2.0)
39
39
  ruby-progressbar (~> 1.7)
40
40
  unicode-display_width (>= 1.4.0, < 3.0)
41
- rubocop-ast (1.4.1)
42
- parser (>= 2.7.1.5)
41
+ rubocop-ast (1.5.0)
42
+ parser (>= 3.0.1.1)
43
43
  rubocop-rake (0.5.1)
44
44
  rubocop
45
45
  rubocop-rspec (2.0.1)
46
46
  rubocop (~> 1.0)
47
47
  rubocop-ast (>= 1.1.0)
48
48
  ruby-progressbar (1.11.0)
49
- strum-service (0.0.3)
49
+ strum-service (0.1.1)
50
50
  unicode-display_width (2.0.0)
51
51
 
52
52
  PLATFORMS
@@ -62,4 +62,4 @@ DEPENDENCIES
62
62
  strum-pipe!
63
63
 
64
64
  BUNDLED WITH
65
- 2.2.13
65
+ 2.2.7
data/lib/strum/pipe.rb CHANGED
@@ -1,10 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "strum/pipe/version"
4
+ require "strum/service"
4
5
 
5
6
  module Strum
6
7
  # Strum Pipe
7
- module Pipe
8
+ class Pipe
9
+ include Strum::Service
8
10
  class Error < StandardError; end
9
11
 
10
12
  def self.call(*units, args: {}, input: {}, unit_input: {}, &block)
@@ -21,13 +23,14 @@ module Strum
21
23
  yield(self) if valid? && block_given?
22
24
  output(pipe_inputs)
23
25
  continue = true
26
+ pipe_context = self
24
27
  while (unit = units.shift) && valid? && continue
25
28
  service, service_params = unit
26
29
  service_params ||= {}
27
30
  raise Strum::Error, "Unit options must be a Hash" unless service_params.is_a?(Hash)
28
31
 
29
- service_options = service_params[:input] || {}
30
- result_place = service_params[:to]
32
+ service_input = service_params[:input] || {}
33
+ result_arg_key = service_params[:to]
31
34
  unit_args = case service_params[:args]
32
35
  when Hash
33
36
  service_params[:args]
@@ -38,35 +41,35 @@ module Strum
38
41
  end
39
42
  clean_output = service_params[:clean_output] || false
40
43
  unit_payload = if !clean_output &&
41
- service_options.is_a?(Hash) &&
44
+ service_input.is_a?(Hash) &&
42
45
  pipe_unit_inputs.is_a?(Hash) &&
43
46
  output_value.is_a?(Hash)
44
- pipe_unit_inputs.merge(service_options).merge(output_value)
47
+ pipe_unit_inputs.merge(service_input).merge(output_value)
45
48
  else
46
49
  output_value
47
50
  end
48
51
 
49
52
  service.public_send(:call, unit_payload, args.merge(unit_args)) do |m|
50
- service_handlers[:on].each do |key, _handler|
53
+ pipe_context.service_handlers[:on].each do |key, _handler|
51
54
  m.on(key) { |r| hook(k, r) }
52
55
  end
53
56
 
54
- service_handlers[:success].each do |key, _handler|
55
- if key
56
- m.success(key) do |result|
57
- output(key, result)
58
- continue = false
59
- end
60
- else
61
- m.success do |result|
62
- if result_place
63
- inputs[result_place] = result
64
- elsif !clean_output && result.is_a?(Hash) && output_value.is_a?(Hash)
65
- output(output_value.merge(result))
66
- elsif result
67
- output(result)
68
- end
69
- end
57
+ pipe_context.service_handlers[:success].each do |key, _handler|
58
+ next unless key
59
+
60
+ m.success(key) do |result|
61
+ output(key, result)
62
+ continue = false
63
+ end
64
+ end
65
+
66
+ m.success do |result|
67
+ if result_arg_key
68
+ pipe_context.inputs[result_arg_key] = result
69
+ elsif !clean_output && result.is_a?(Hash) && output_value.is_a?(Hash)
70
+ pipe_context.output(pipe_context.output_value.merge(result))
71
+ elsif result
72
+ pipe_context.output(result)
70
73
  end
71
74
  end
72
75
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Strum
4
- module Pipe
5
- VERSION = "0.0.1"
4
+ class Pipe
5
+ VERSION = "0.0.2"
6
6
  end
7
7
  end
data/strum-pipe.gemspec CHANGED
@@ -30,5 +30,5 @@ Gem::Specification.new do |spec|
30
30
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
31
  spec.require_paths = ["lib"]
32
32
 
33
- spec.add_dependency "strum-service", "~> 0.0.3"
33
+ spec.add_dependency "strum-service", "~> 0.1.1"
34
34
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: strum-pipe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.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-03-03 00:00:00.000000000 Z
11
+ date: 2021-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: strum-service
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.0.3
19
+ version: 0.1.1
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.0.3
26
+ version: 0.1.1
27
27
  description: Strum Pipe
28
28
  email:
29
29
  - sn@nazarov.com.ua
@@ -71,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
71
71
  - !ruby/object:Gem::Version
72
72
  version: '0'
73
73
  requirements: []
74
- rubygems_version: 3.1.4
74
+ rubygems_version: 3.1.6
75
75
  signing_key:
76
76
  specification_version: 4
77
77
  summary: Light ruby framework