ruby_pipeline 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f58ba14a41f2738f813dc20a2510cba4b2d285db8f0b1dc91ad5cbec2961b58a
4
+ data.tar.gz: 96b44437c7e11c1c0675c584691148e948025473ede0cf37ec6e31325a691c38
5
+ SHA512:
6
+ metadata.gz: e109b4ef939340aaab83c9977bfc3382668b6ba9a891b2c7b02ae8989bf62b561031db0d7cb424472417d87e4b5c93ddf891d2d28d2bb8e1decbb935ae1cde4c
7
+ data.tar.gz: 8aaeb919db7af405b8be73ef8c50272018233aeee1bfa0e95aae7fed5fcef557c03dd1d717fb160979cc9cd431985d1f0858f1f4c4e55b028f6492b32980ff09
@@ -0,0 +1,31 @@
1
+ name: "Publish gem"
2
+ on:
3
+ push:
4
+ tags:
5
+ - 'v**'
6
+ workflow_dispatch:
7
+
8
+ jobs:
9
+ build:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v2
13
+ with:
14
+ fetch-depth: 0
15
+
16
+ - name: Setup ruby
17
+ uses: ruby/setup-ruby@v1
18
+ with:
19
+ bundler-cache: true
20
+
21
+ - name: Install dependencies
22
+ run: |
23
+ gem install bundler
24
+ bundle install --path vendor/bundle --jobs 4 --retry 3
25
+
26
+ - name: Publish to RubyGems Packages
27
+ env:
28
+ GEM_HOST_API_KEY: ${{secrets.GEM_HOST_API_KEY}}
29
+ run: |
30
+ gem build ruby_pipeline.gemspec
31
+ gem push ruby_pipeline-*.gem
@@ -0,0 +1,45 @@
1
+ name: "Tests"
2
+ on:
3
+ push:
4
+
5
+ jobs:
6
+ rubocop:
7
+ name: Rubocop
8
+ runs-on: ubuntu-latest
9
+ steps:
10
+ - uses: actions/checkout@v2
11
+ with:
12
+ fetch-depth: 0
13
+
14
+ - name: Setup ruby
15
+ uses: ruby/setup-ruby@v1
16
+ with:
17
+ bundler-cache: true
18
+
19
+ - name: Install dependencies
20
+ run: |
21
+ gem install bundler
22
+ bundle install --path vendor/bundle --jobs 4 --retry 3
23
+
24
+ - name: Check code
25
+ run: bundle exec rubocop
26
+
27
+ rspec:
28
+ name: RSpec
29
+ runs-on: ubuntu-latest
30
+
31
+ steps:
32
+ - uses: actions/checkout@v1
33
+
34
+ - name: Setup ruby
35
+ uses: ruby/setup-ruby@v1
36
+ with:
37
+ bundler-cache: true
38
+
39
+ - name: Install dependencies
40
+ run: |
41
+ gem install bundler
42
+ bundle install --path vendor/bundle --jobs 4 --retry 3
43
+
44
+ - name: Run units
45
+ run: bundler exec rspec
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,30 @@
1
+ require:
2
+ - rubocop-rspec
3
+
4
+ AllCops:
5
+ NewCops: enable
6
+
7
+ Style/Documentation:
8
+ Enabled: false
9
+
10
+ Metrics/BlockLength:
11
+ Exclude:
12
+ - "Guardfile"
13
+ - "ruby_pipeline.gemspec"
14
+ - "spec/**/*.rb"
15
+
16
+ Metrics/ModuleLength:
17
+ Exclude:
18
+ - "spec/**/*.rb"
19
+
20
+ RSpec/MultipleMemoizedHelpers:
21
+ Max: 8
22
+
23
+ RSpec/MultipleExpectations:
24
+ Enabled: false
25
+
26
+ RSpec/ExampleLength:
27
+ Max: 20
28
+
29
+ RSpec/Style/OpenStructUse:
30
+ Enabled: false
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.1.4
data/.tool-versions ADDED
@@ -0,0 +1 @@
1
+ ruby 3.1.4
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ ruby '>= 2.5.0'
4
+
5
+ source 'https://rubygems.org'
6
+
7
+ gem 'rspec'
8
+ gem 'rubocop'
9
+ gem 'rubocop-rspec'
data/Gemfile.lock ADDED
@@ -0,0 +1,69 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ ast (2.4.2)
5
+ base64 (0.1.1)
6
+ diff-lcs (1.5.0)
7
+ json (2.6.3)
8
+ language_server-protocol (3.17.0.3)
9
+ parallel (1.23.0)
10
+ parser (3.2.2.3)
11
+ ast (~> 2.4.1)
12
+ racc
13
+ racc (1.7.1)
14
+ rainbow (3.1.1)
15
+ regexp_parser (2.8.1)
16
+ rexml (3.2.6)
17
+ rspec (3.12.0)
18
+ rspec-core (~> 3.12.0)
19
+ rspec-expectations (~> 3.12.0)
20
+ rspec-mocks (~> 3.12.0)
21
+ rspec-core (3.12.2)
22
+ rspec-support (~> 3.12.0)
23
+ rspec-expectations (3.12.3)
24
+ diff-lcs (>= 1.2.0, < 2.0)
25
+ rspec-support (~> 3.12.0)
26
+ rspec-mocks (3.12.6)
27
+ diff-lcs (>= 1.2.0, < 2.0)
28
+ rspec-support (~> 3.12.0)
29
+ rspec-support (3.12.1)
30
+ rubocop (1.56.0)
31
+ base64 (~> 0.1.1)
32
+ json (~> 2.3)
33
+ language_server-protocol (>= 3.17.0)
34
+ parallel (~> 1.10)
35
+ parser (>= 3.2.2.3)
36
+ rainbow (>= 2.2.2, < 4.0)
37
+ regexp_parser (>= 1.8, < 3.0)
38
+ rexml (>= 3.2.5, < 4.0)
39
+ rubocop-ast (>= 1.28.1, < 2.0)
40
+ ruby-progressbar (~> 1.7)
41
+ unicode-display_width (>= 2.4.0, < 3.0)
42
+ rubocop-ast (1.29.0)
43
+ parser (>= 3.2.1.0)
44
+ rubocop-capybara (2.18.0)
45
+ rubocop (~> 1.41)
46
+ rubocop-factory_bot (2.23.1)
47
+ rubocop (~> 1.33)
48
+ rubocop-rspec (2.23.2)
49
+ rubocop (~> 1.33)
50
+ rubocop-capybara (~> 2.17)
51
+ rubocop-factory_bot (~> 2.22)
52
+ ruby-progressbar (1.13.0)
53
+ unicode-display_width (2.4.2)
54
+
55
+ PLATFORMS
56
+ arm64-darwin-21
57
+ arm64-darwin-22
58
+ x86_64-linux
59
+
60
+ DEPENDENCIES
61
+ rspec
62
+ rubocop
63
+ rubocop-rspec
64
+
65
+ RUBY VERSION
66
+ ruby 3.0.3p157
67
+
68
+ BUNDLED WITH
69
+ 2.3.16
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Rollbar, Inc.
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,99 @@
1
+ # Ruby Pipeline
2
+
3
+ Add pipelines of small ruby classes to your ruby project.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'ruby_pipeline'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ gem install ruby_pipeline
20
+
21
+ ## Usage
22
+
23
+ ### Create a pipeline
24
+
25
+ ```ruby
26
+ class MyPipeline < RubyPipeline::BasePipeline
27
+ private
28
+
29
+ def default_steps
30
+ [
31
+ PipelineSteps::Step1,
32
+ PipelineSteps::Step2
33
+ ]
34
+ end
35
+ end
36
+ ```
37
+
38
+ ### Create a step
39
+
40
+ ```ruby
41
+ class PipelineSteps::Step1 < RubyPipeline::BaseStep
42
+ def process(data)
43
+ # do something with data, what you return will be passed to the next step
44
+ data
45
+ end
46
+ end
47
+
48
+ class PipelineSteps::Step1 < RubyPipeline::BaseStep
49
+ def process(data)
50
+ # returning nil will terminate the pipeline
51
+ nil
52
+ end
53
+ end
54
+ ```
55
+
56
+ ### Run a pipeline
57
+
58
+ ```ruby
59
+ MyPipeline.new.process(data)
60
+ ```
61
+
62
+ ### Config
63
+
64
+ You can configure a success callback to be called after each step is processed:
65
+
66
+ ```ruby
67
+ RubyPipeline.configure do |config|
68
+ config.success_callback = ->(step) { my_monitoring_service.notify(step) }
69
+ config.failure_callback = ->(step) { puts "Failure in step #{step}" }
70
+ end
71
+ ```
72
+
73
+ ## Contributing
74
+
75
+ 1. Fork it
76
+ 1. Create your feature branch (git checkout -b my-new-feature).
77
+ 1. Commit your changes (git commit -am 'Added some feature')
78
+ 1. Push to the branch (git push origin my-new-feature)
79
+ 1. Create new Pull Request
80
+
81
+ We're using RSpec for testing. Run the test suite with rake spec. Tests for pull requests are appreciated but not required. (If you don't include a test, we'll write one before merging.)
82
+
83
+ ## License
84
+
85
+ `ruby-pipeine`` is free software released under the MIT License. See LICENSE for details.
86
+
87
+ ## Publishing a gem version
88
+
89
+ This gem uses Github Packages Registry to store gems, and all builds get pushed to it.
90
+
91
+ 1. Update `lib/ruby_pipeline/version.rb` with the new version
92
+ 2. Create and push a tag:
93
+
94
+ ```bash
95
+ git tag 'v0.1.0' # replace with your version
96
+ git push origin 'v0.1.0'
97
+ ```
98
+
99
+ This will automatically trigger the release workflow of GHA, after which you will be able to install a fresh version of a gem into your system.
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyPipeline
4
+ class BasePipeline
5
+ def initialize(steps = default_steps)
6
+ @steps = steps
7
+ end
8
+
9
+ def process(input = nil)
10
+ steps.inject(input) do |memo, step|
11
+ step_result = step.process(memo)
12
+
13
+ break failure(step) if step_result.nil?
14
+
15
+ success(step)
16
+ step_result
17
+ end
18
+ end
19
+
20
+ private
21
+
22
+ attr_reader :steps
23
+
24
+ def default_steps = []
25
+
26
+ def success(step) = RubyPipeline.configuration.success_callback.call(step)
27
+
28
+ def failure(step)
29
+ RubyPipeline.configuration.failure_callback.call(step)
30
+ false
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyPipeline
4
+ class Configuration
5
+ attr_accessor :success_callback, :failure_callback
6
+
7
+ def initialize
8
+ @success_callback = ->(step) {}
9
+ @failure_callback = ->(step) {}
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyPipeline
4
+ VERSION = '1.0.1'
5
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'ruby_pipeline/version'
4
+ require 'ruby_pipeline/configuration'
5
+ require 'ruby_pipeline/base_pipeline'
6
+
7
+ module RubyPipeline
8
+ class << self
9
+ def configuration
10
+ @configuration ||= Configuration.new
11
+ end
12
+
13
+ def configure
14
+ yield(configuration)
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path('lib/ruby_pipeline/version', __dir__)
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'ruby_pipeline'
7
+ s.version = RubyPipeline::VERSION
8
+ s.summary = 'Pipelines for your ruby apps'
9
+ s.description = ''
10
+ s.authors = ['Ian Vaughan']
11
+ s.email = 'ian@out.fund'
12
+ s.files = `git ls-files -z`.split("\x0").reject do |f|
13
+ f.match(%r{^(test|spec|features)/})
14
+ end
15
+ s.homepage = 'https://rubygems.org/out-fund/ruby_pipeline'
16
+ s.license = 'MIT'
17
+
18
+ s.metadata['rubygems_mfa_required'] = 'true'
19
+ s.required_ruby_version = '>= 3.1.4'
20
+ s.require_paths = ['lib']
21
+ end
metadata ADDED
@@ -0,0 +1,58 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruby_pipeline
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ian Vaughan
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-08-16 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: ''
14
+ email: ian@out.fund
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - ".github/workflows/release.yml"
20
+ - ".github/workflows/tests.yml"
21
+ - ".rspec"
22
+ - ".rubocop.yml"
23
+ - ".ruby-version"
24
+ - ".tool-versions"
25
+ - Gemfile
26
+ - Gemfile.lock
27
+ - LICENSE
28
+ - README.md
29
+ - lib/ruby_pipeline.rb
30
+ - lib/ruby_pipeline/base_pipeline.rb
31
+ - lib/ruby_pipeline/configuration.rb
32
+ - lib/ruby_pipeline/version.rb
33
+ - ruby_pipeline.gemspec
34
+ homepage: https://rubygems.org/out-fund/ruby_pipeline
35
+ licenses:
36
+ - MIT
37
+ metadata:
38
+ rubygems_mfa_required: 'true'
39
+ post_install_message:
40
+ rdoc_options: []
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 3.1.4
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ requirements: []
54
+ rubygems_version: 3.3.26
55
+ signing_key:
56
+ specification_version: 4
57
+ summary: Pipelines for your ruby apps
58
+ test_files: []