fluent_pipeline 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/README.md +2 -5
- data/lib/fluent/pipeline/errors.rb +18 -0
- data/lib/fluent/pipeline/helpers.rb +9 -0
- data/lib/fluent/pipeline/version.rb +1 -1
- data/lib/fluent/pipeline.rb +12 -6
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5bbce88afc89afaf11e216073b5e9991df101a922efd36e8ff73bea5a34142b9
|
4
|
+
data.tar.gz: b803510d9aca0ea14f3609f9f378076bd4f65ab2b76d9b7757ce1caeab782e4e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 27c9d979fd7fd8b517d5f5ec4babaa446e543945fefce4307a6d6d9dcfa1e8e14dcc38b7e5a4bf5b9e9682b21552c499dd19a0d0dad4f457d9449e3a7b903152
|
7
|
+
data.tar.gz: '08c0e4aa699db6598142ad5b72aa5ac74f1ffb7fa7ed497ec4d42f68c0acecc7da56144f9e62292e296dcb00a8db8d6b7fc10745f9eda987d43d76636d42a195'
|
data/Gemfile.lock
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
fluent_pipeline (0.
|
5
|
-
rspec (~> 3.0)
|
4
|
+
fluent_pipeline (0.2.0)
|
6
5
|
|
7
6
|
GEM
|
8
7
|
remote: https://rubygems.org/
|
@@ -51,6 +50,7 @@ PLATFORMS
|
|
51
50
|
DEPENDENCIES
|
52
51
|
fluent_pipeline!
|
53
52
|
rake (~> 13.0)
|
53
|
+
rspec (~> 3.0)
|
54
54
|
rubocop (~> 1.21)
|
55
55
|
|
56
56
|
BUNDLED WITH
|
data/README.md
CHANGED
@@ -1,8 +1,5 @@
|
|
1
1
|
# FluentPipeline
|
2
|
-
|
3
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/fluent_pipeline`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
2
|
+
Pipeline pattern in Ruby. Heavily inspired by Laravel Pipelines.
|
6
3
|
|
7
4
|
## Installation
|
8
5
|
|
@@ -26,4 +23,4 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
26
23
|
|
27
24
|
## Contributing
|
28
25
|
|
29
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
26
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/okcomputer2393/fluent_pipeline.
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Fluent
|
2
|
+
class UndefinedPipeMethod < StandardError
|
3
|
+
MESSAGE_LAYOUT = 'Undefined method `%{method_name}` for pipe'
|
4
|
+
|
5
|
+
def initialize(method_name)
|
6
|
+
@method_name = method_name
|
7
|
+
super(message)
|
8
|
+
end
|
9
|
+
|
10
|
+
def message
|
11
|
+
format(MESSAGE_LAYOUT, method_name: method_name)
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
attr_reader :method_name
|
17
|
+
end
|
18
|
+
end
|
data/lib/fluent/pipeline.rb
CHANGED
@@ -1,15 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'fluent/pipeline/version'
|
4
|
+
require 'fluent/pipeline/helpers'
|
5
|
+
require 'fluent/pipeline/errors'
|
4
6
|
|
5
7
|
module Fluent
|
6
8
|
class Pipeline
|
9
|
+
include Fluent::Helpers
|
10
|
+
|
7
11
|
def self.dispatch(passable)
|
8
12
|
new(passable)
|
9
13
|
end
|
10
14
|
|
11
15
|
def through(pipes)
|
12
|
-
self.pipes
|
16
|
+
self.pipes.push(*pipes)
|
13
17
|
self
|
14
18
|
end
|
15
19
|
|
@@ -18,17 +22,21 @@ module Fluent
|
|
18
22
|
self
|
19
23
|
end
|
20
24
|
|
21
|
-
def then(callback)
|
25
|
+
def then(callback = nil)
|
22
26
|
handle_pipes
|
27
|
+
return passable unless callback
|
28
|
+
|
23
29
|
callback.call(passable)
|
24
30
|
end
|
25
31
|
|
26
32
|
private
|
27
33
|
|
28
|
-
attr_accessor :passable, :
|
34
|
+
attr_accessor :passable, :pipe_method
|
35
|
+
attr_reader :pipes
|
29
36
|
|
30
37
|
def initialize(passable)
|
31
38
|
@passable = passable
|
39
|
+
@pipes = []
|
32
40
|
end
|
33
41
|
|
34
42
|
def via_method
|
@@ -36,12 +44,10 @@ module Fluent
|
|
36
44
|
end
|
37
45
|
|
38
46
|
def handle_pipes
|
39
|
-
|
47
|
+
with_undefined_method_handle do
|
40
48
|
pipes.each do |pipe|
|
41
49
|
self.passable = pipe.send(via_method, passable)
|
42
50
|
end
|
43
|
-
else
|
44
|
-
self.passable = pipes.call(passable)
|
45
51
|
end
|
46
52
|
end
|
47
53
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent_pipeline
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Omar Juárez
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-11-
|
11
|
+
date: 2022-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -17,7 +17,7 @@ dependencies:
|
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '3.0'
|
20
|
-
type: :
|
20
|
+
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
@@ -38,6 +38,8 @@ files:
|
|
38
38
|
- README.md
|
39
39
|
- Rakefile
|
40
40
|
- lib/fluent/pipeline.rb
|
41
|
+
- lib/fluent/pipeline/errors.rb
|
42
|
+
- lib/fluent/pipeline/helpers.rb
|
41
43
|
- lib/fluent/pipeline/version.rb
|
42
44
|
- sig/fluent_pipeline.rbs
|
43
45
|
homepage: https://github.com/okcomputer93/fluent_pipeline
|