simple_pipeline 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
  SHA1:
3
- metadata.gz: f5cbe78df308227f273429f35076b7cd0cbbe76d
4
- data.tar.gz: 8bba7a8aa97709ab873daa5387bbc79d4947c852
3
+ metadata.gz: d7498222868fb61586a42e233b459aed023f91a4
4
+ data.tar.gz: 157c751b613f41bd2b0a507606a4ed2be6b5538b
5
5
  SHA512:
6
- metadata.gz: 2e4084681ee5817434341d714df17d16320f13d197ae90ba744ee1c807838264110c4f8b6f769ec836d84004c121d0c5f35ecf7902527ddb93bcb78e0073852e
7
- data.tar.gz: 197fc96cc90add02ce7dd2395ada21ca2ed6acfdaf98f1ae98d8552fedbea7d04512b92a79a37800b87cfeedb5ffdf209e205b4ddb0cdf71eb3b8bf93161da6b
6
+ metadata.gz: e86424d591224a4bd4e0822666c83877f0fa497d33c570989748329c007842e8d7c3f7d7861262a75a1b01252014f838bc2d9bee772a459a2d22107b13b9b689
7
+ data.tar.gz: 2d6b0b662fd764343825ca652469940879e270434d4b0a7f8185aa8d74e988bd8f60dfbf73bf57fe4a620c937e0d8e22183629adae1676c2faba1448053c37c4
data/.gitignore ADDED
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
15
+ build.bat
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in simple_pipeline.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Jonathan Wong
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,31 @@
1
+ # SimplePipeline
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'simple_pipeline'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install simple_pipeline
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/[my-github-username]/simple_pipeline/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,5 @@
1
+ require 'rspec/core/rake_task'
2
+
3
+ RSpec::Core::RakeTask.new :spec
4
+
5
+ task :default => :spec
@@ -0,0 +1,19 @@
1
+ require 'timeout'
2
+
3
+ class SimplePipeline
4
+
5
+ module Timeout
6
+
7
+ def set_timeout (sec)
8
+ @timeout_in_sec = sec
9
+ end
10
+
11
+ def process_with_timeout (payload)
12
+ ::Timeout::timeout(@timeout_in_sec) {
13
+ process(payload)
14
+ }
15
+ end
16
+
17
+ end
18
+
19
+ end
@@ -1,3 +1,3 @@
1
- module SimplePipeline
2
- VERSION = "0.0.1"
1
+ class SimplePipeline
2
+ VERSION = "0.0.2"
3
3
  end
@@ -1,2 +1,37 @@
1
- require "simple_pipeline/pipe"
2
- require "simple_pipeline/version"
1
+ require "simple_pipeline/timeout"
2
+ require "simple_pipeline/version"
3
+
4
+
5
+ class SimplePipeline
6
+
7
+ def initialize
8
+ @pipes = []
9
+ end
10
+
11
+ def add (pipe)
12
+ begin
13
+ raise ArgumentError, "invalid pipe - incorrect number of arguments for process() method (should be 1)" unless pipe.class.instance_method(:process).arity == 1
14
+ rescue NameError
15
+ raise ArgumentError, "invalid pipe - process() method not found"
16
+ end
17
+
18
+ @pipes << pipe
19
+ end
20
+
21
+ def size
22
+ return @pipes.size
23
+ end
24
+
25
+ def process (payload)
26
+ @pipes.each do |pipe|
27
+ if pipe.is_a? SimplePipeline::Timeout
28
+ pipe.process_with_timeout(payload)
29
+ else
30
+ pipe.process(payload)
31
+ end
32
+ end
33
+ end
34
+
35
+ alias :length :size
36
+
37
+ end
@@ -0,0 +1,18 @@
1
+ require File.expand_path("../lib/simple_pipeline/version", __FILE__)
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "simple_pipeline"
5
+ spec.version = SimplePipeline::VERSION
6
+ spec.authors = ["Jonathan Wong"]
7
+ spec.email = ["jonathan@armchairtheorist.com"]
8
+ spec.summary = "Simple implementation of a configurable processing pipeline for sequential execution of reusable code components."
9
+ spec.homepage = "http://github.com/armchairtheorist/simple_pipeline"
10
+ spec.license = "MIT"
11
+
12
+ spec.files = `git ls-files`.split("\n")
13
+ spec.test_files = `git ls-files -- {spec}/*`.split("\n")
14
+ spec.require_paths = ["lib"]
15
+
16
+ spec.add_development_dependency 'rspec', '~> 0'
17
+ spec.add_development_dependency 'rake', '~> 0'
18
+ end
@@ -0,0 +1,63 @@
1
+ require 'spec_helper'
2
+
3
+ class TestPipe
4
+ def process (payload)
5
+ payload[:test_value] *= 10
6
+ end
7
+ end
8
+
9
+ class BadPipe
10
+ def process (payload1, payload2)
11
+ # do nothing
12
+ end
13
+ end
14
+
15
+ class TimeoutPipe
16
+ include SimplePipeline::Timeout
17
+
18
+ def initialize
19
+ set_timeout 1 # seconds
20
+ end
21
+
22
+ def process (payload)
23
+ sleep 10 # seconds
24
+ end
25
+ end
26
+
27
+ describe SimplePipeline do
28
+ it "should support three normal pipes" do
29
+ pipeline = SimplePipeline.new
30
+ pipeline.add TestPipe.new
31
+ pipeline.add TestPipe.new
32
+ pipeline.add TestPipe.new
33
+
34
+ payload = {:test_value => 10}
35
+
36
+ pipeline.process(payload)
37
+
38
+ expect(pipeline.size).to eq 3
39
+ expect(payload[:test_value]).to eq 10000
40
+ end
41
+
42
+ it "should throw an error for invalid pipes" do
43
+ pipeline = SimplePipeline.new
44
+
45
+ expect {
46
+ pipeline.add Object.new # not a pipe
47
+ }.to raise_error(ArgumentError)
48
+
49
+ expect {
50
+ pipeline.add BadPipe
51
+ }.to raise_error(ArgumentError)
52
+ end
53
+
54
+ it "should support pipes with timeout" do
55
+ pipeline = SimplePipeline.new
56
+ pipe = TimeoutPipe.new
57
+ pipeline.add pipe
58
+
59
+ expect {
60
+ pipeline.process({})
61
+ }.to raise_error(Timeout::Error)
62
+ end
63
+ end
@@ -0,0 +1,98 @@
1
+ require 'simple_pipeline'
2
+
3
+ # This file was generated by the `rspec --init` command. Conventionally, all
4
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
5
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
6
+ # this file to always be loaded, without a need to explicitly require it in any
7
+ # files.
8
+ #
9
+ # Given that it is always loaded, you are encouraged to keep this file as
10
+ # light-weight as possible. Requiring heavyweight dependencies from this file
11
+ # will add to the boot time of your test suite on EVERY test run, even for an
12
+ # individual file that may not need all of that loaded. Instead, consider making
13
+ # a separate helper file that requires the additional dependencies and performs
14
+ # the additional setup, and require it from the spec files that actually need
15
+ # it.
16
+ #
17
+ # The `.rspec` file also contains a few flags that are not defaults but that
18
+ # users commonly want.
19
+ #
20
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
21
+ RSpec.configure do |config|
22
+ # rspec-expectations config goes here. You can use an alternate
23
+ # assertion/expectation library such as wrong or the stdlib/minitest
24
+ # assertions if you prefer.
25
+ config.expect_with :rspec do |expectations|
26
+ # This option will default to `true` in RSpec 4. It makes the `description`
27
+ # and `failure_message` of custom matchers include text for helper methods
28
+ # defined using `chain`, e.g.:
29
+ # be_bigger_than(2).and_smaller_than(4).description
30
+ # # => "be bigger than 2 and smaller than 4"
31
+ # ...rather than:
32
+ # # => "be bigger than 2"
33
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
34
+ end
35
+
36
+ # rspec-mocks config goes here. You can use an alternate test double
37
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
38
+ config.mock_with :rspec do |mocks|
39
+ # Prevents you from mocking or stubbing a method that does not exist on
40
+ # a real object. This is generally recommended, and will default to
41
+ # `true` in RSpec 4.
42
+ mocks.verify_partial_doubles = true
43
+ end
44
+
45
+ # The settings below are suggested to provide a good initial experience
46
+ # with RSpec, but feel free to customize to your heart's content.
47
+ =begin
48
+ # These two settings work together to allow you to limit a spec run
49
+ # to individual examples or groups you care about by tagging them with
50
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
51
+ # get run.
52
+ config.filter_run :focus
53
+ config.run_all_when_everything_filtered = true
54
+
55
+ # Allows RSpec to persist some state between runs in order to support
56
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
57
+ # you configure your source control system to ignore this file.
58
+ config.example_status_persistence_file_path = "spec/examples.txt"
59
+
60
+ # Limits the available syntax to the non-monkey patched syntax that is
61
+ # recommended. For more details, see:
62
+ # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
63
+ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
64
+ # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
65
+ config.disable_monkey_patching!
66
+
67
+ # This setting enables warnings. It's recommended, but in some cases may
68
+ # be too noisy due to issues in dependencies.
69
+ config.warnings = true
70
+
71
+ # Many RSpec users commonly either run the entire suite or an individual
72
+ # file, and it's useful to allow more verbose output when running an
73
+ # individual spec file.
74
+ if config.files_to_run.one?
75
+ # Use the documentation formatter for detailed output,
76
+ # unless a formatter has already been configured
77
+ # (e.g. via a command-line flag).
78
+ config.default_formatter = 'doc'
79
+ end
80
+
81
+ # Print the 10 slowest examples and example groups at the
82
+ # end of the spec run, to help surface which specs are running
83
+ # particularly slow.
84
+ config.profile_examples = 10
85
+
86
+ # Run specs in random order to surface order dependencies. If you find an
87
+ # order dependency and want to debug it, you can fix the order by providing
88
+ # the seed, which is printed after each run.
89
+ # --seed 1234
90
+ config.order = :random
91
+
92
+ # Seed global randomization in this process using the `--seed` CLI option.
93
+ # Setting this allows you to use `--seed` to deterministically reproduce
94
+ # test failures related to randomization by passing the same `--seed` value
95
+ # as the one that triggered the failure.
96
+ Kernel.srand config.seed
97
+ =end
98
+ end
metadata CHANGED
@@ -1,15 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_pipeline
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
  - Jonathan Wong
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-04 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2016-07-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
13
41
  description:
14
42
  email:
15
43
  - jonathan@armchairtheorist.com
@@ -17,9 +45,18 @@ executables: []
17
45
  extensions: []
18
46
  extra_rdoc_files: []
19
47
  files:
48
+ - ".gitignore"
49
+ - ".rspec"
50
+ - Gemfile
51
+ - LICENSE.txt
52
+ - README.md
53
+ - Rakefile
20
54
  - lib/simple_pipeline.rb
21
- - lib/simple_pipeline/pipe.rb
55
+ - lib/simple_pipeline/timeout.rb
22
56
  - lib/simple_pipeline/version.rb
57
+ - simple_pipeline.gemspec
58
+ - spec/simple_pipeline_spec.rb
59
+ - spec/spec_helper.rb
23
60
  homepage: http://github.com/armchairtheorist/simple_pipeline
24
61
  licenses:
25
62
  - MIT
@@ -40,9 +77,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
40
77
  version: '0'
41
78
  requirements: []
42
79
  rubyforge_project:
43
- rubygems_version: 2.4.2
80
+ rubygems_version: 2.5.1
44
81
  signing_key:
45
82
  specification_version: 4
46
- summary: Simple implementation of a configurable processing pipeline framework for
47
- sequential execution of reusable code components.
83
+ summary: Simple implementation of a configurable processing pipeline for sequential
84
+ execution of reusable code components.
48
85
  test_files: []
@@ -1,35 +0,0 @@
1
- module SimplePipeline
2
-
3
- class Pipe
4
-
5
- DEFAULT_OPTIONS = {}
6
-
7
- def initialize (options = {})
8
- @options = DEFAULT_OPTIONS.merge(options)
9
- @sections = []
10
- end
11
-
12
- def add (section)
13
- begin
14
- raise ArgumentError, "invalid section - incorrect number of arguments for process() method (should be 1)" unless section.class.instance_method(:process).arity == 1
15
- rescue NameError
16
- raise ArgumentError, "invalid section - process() method not found"
17
- end
18
-
19
- @sections << section
20
- end
21
-
22
- def size
23
- return @sections.size
24
- end
25
-
26
- def process (payload)
27
- @sections.each do |section|
28
- section.process(payload)
29
- end
30
- end
31
-
32
- alias :length :size
33
- end
34
-
35
- end