banzai 0.1.0 → 0.1.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
+ SHA1:
3
+ metadata.gz: 87ecd06527099239eda1d67d3200f3c8bd8af7db
4
+ data.tar.gz: 1deddcd37be707e8f0672792ba3448c1715f20ae
5
+ SHA512:
6
+ metadata.gz: 8480c04557749e992d7acb89e1d8049638f190679a4305399abce780e05b55da529d3aca33a69fc4504dc078dd697f2811c72616dc1f354af6ea3b539d581a8c
7
+ data.tar.gz: 709ea20a481df1a63b6f15bd9a94b62090e199bdc168c1cebadfba4f23699c294f8880db1d5333d787502828b4d4590cbe71d67f7c673d108ed98803e2af959e
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/Gemfile CHANGED
@@ -6,5 +6,5 @@ gemspec
6
6
  group :development do
7
7
  gem 'bundler'
8
8
  gem 'rake'
9
- gem 'minitest'
9
+ gem 'rspec'
10
10
  end
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
- # Banzai
1
+ Banzai
2
+ ======
2
3
 
3
4
  Simple toolkit for processing input using filter/pipeline concept.
4
5
 
@@ -39,8 +40,9 @@ GaussianBlur.call(image)
39
40
  Use pipelines to apply multiple fitlers:
40
41
 
41
42
  ```ruby
42
- # note that you can combine classes and instances
43
- blurred_effect = Banzai::Pipeline.new [GaussianBlur.new(radius:1.1), Nostalgia]
43
+ # Note that you can combine classes and instances
44
+ # Use instances when you need to pass options to the filter
45
+ blurred_effect = Banzai::Pipeline.new(GaussianBlur.new(radius:1.1), Nostalgia)
44
46
  blurred_effect.call(image)
45
47
  ```
46
48
 
@@ -48,7 +50,7 @@ Pipeline is just another filter, so you can mix them too into a new
48
50
  pipeline:
49
51
 
50
52
  ```ruby
51
- Banzai::Pipeline.new [blurred_effect, RoundCorners.new(radius:0.87)]
53
+ Banzai::Pipeline.new(blurred_effect, RoundCorners.new(radius:0.87))
52
54
  ```
53
55
 
54
56
  ## Working Example
@@ -68,13 +70,14 @@ class UpcaseFilter < Banzai::Filter
68
70
  end
69
71
  end
70
72
 
71
- pipeline = Banzai::Pipeline.new [StripFilter, UpcaseFilter]
73
+ pipeline = Banzai::Pipeline.new(StripFilter, UpcaseFilter)
72
74
  puts pipeline.call(' ohai ') # prints "OHAI"
73
75
  ```
74
76
 
77
+
75
78
  ## Licence
76
79
 
77
- Copyright (c) 2012 Dejan Simic
80
+ Copyright (c) 2015 Dejan Simic
78
81
 
79
82
  MIT License
80
83
 
data/lib/banzai/filter.rb CHANGED
@@ -1,17 +1,17 @@
1
1
  module Banzai
2
2
  class Filter
3
-
3
+
4
4
  attr_reader :options
5
5
 
6
6
  def initialize(options={})
7
7
  @options = options
8
8
  end
9
9
 
10
- # should be redefined in subclass
10
+ # This method should be redefined in subclasses
11
11
  def call(input)
12
12
  raise NotImplementedError
13
13
  end
14
-
14
+
15
15
  def self.call(input)
16
16
  new.call(input)
17
17
  end
@@ -1,8 +1,8 @@
1
1
  module Banzai
2
2
  class Pipeline < Filter
3
3
 
4
- def initialize(filters=[])
5
- @filters = filters
4
+ def initialize(*filters)
5
+ @filters = filters.flatten
6
6
  end
7
7
 
8
8
  def call(input)
@@ -1,3 +1,3 @@
1
1
  module Banzai
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -0,0 +1,26 @@
1
+ describe Banzai::Filter, 'subclass' do
2
+
3
+ class LeetFilter < Banzai::Filter
4
+ def call(input)
5
+ input.gsub(/elite/, '1337')
6
+ end
7
+ end
8
+
9
+ context 'instance' do
10
+ it 'is created with options' do
11
+ filter = LeetFilter.new(:mode => 'hardcore')
12
+ expect(filter.options[:mode]).to eq 'hardcore'
13
+ end
14
+
15
+ it 'applies to input' do
16
+ expect(LeetFilter.new.call('elite security')).to eq '1337 security'
17
+ end
18
+ end
19
+
20
+ context 'class' do
21
+ it 'applies to input' do
22
+ expect(LeetFilter.call('elite security')).to eq '1337 security'
23
+ end
24
+ end
25
+
26
+ end
@@ -0,0 +1,25 @@
1
+ describe Banzai::Pipeline do
2
+
3
+ class StripFilter < Banzai::Filter
4
+ def call(input)
5
+ input.strip
6
+ end
7
+ end
8
+
9
+ class UpcaseFilter < Banzai::Filter
10
+ def call(input)
11
+ input.upcase
12
+ end
13
+ end
14
+
15
+ it 'applies provided filters to input' do
16
+ pipeline = Banzai::Pipeline.new(StripFilter, UpcaseFilter)
17
+ expect(pipeline.call(' ohai ')).to eq 'OHAI'
18
+ end
19
+
20
+ it 'accepts array of filters' do
21
+ pipeline = Banzai::Pipeline.new([StripFilter, UpcaseFilter])
22
+ expect(pipeline.call(' ohai ')).to eq 'OHAI'
23
+ end
24
+
25
+ end
@@ -0,0 +1,98 @@
1
+ require 'banzai'
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://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
63
+ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
64
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
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,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: banzai
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
5
- prerelease:
4
+ version: 0.1.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Dejan Simic
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-12-29 00:00:00.000000000 Z
11
+ date: 2015-09-27 00:00:00.000000000 Z
13
12
  dependencies: []
14
13
  description: Simple toolkit for processing input using filter/pipeline concept
15
14
  email:
@@ -18,7 +17,8 @@ executables: []
18
17
  extensions: []
19
18
  extra_rdoc_files: []
20
19
  files:
21
- - .gitignore
20
+ - ".gitignore"
21
+ - ".rspec"
22
22
  - Gemfile
23
23
  - README.md
24
24
  - Rakefile
@@ -27,35 +27,33 @@ files:
27
27
  - lib/banzai/filter.rb
28
28
  - lib/banzai/pipeline.rb
29
29
  - lib/banzai/version.rb
30
- - test/banzai/filter_test.rb
31
- - test/banzai/pipeline_test.rb
32
- - test/test_helper.rb
30
+ - spec/filter_spec.rb
31
+ - spec/pipeline_spec.rb
32
+ - spec/spec_helper.rb
33
33
  homepage: https://github.com/dejan/banzai
34
34
  licenses: []
35
+ metadata: {}
35
36
  post_install_message:
36
37
  rdoc_options: []
37
38
  require_paths:
38
39
  - lib
39
40
  required_ruby_version: !ruby/object:Gem::Requirement
40
- none: false
41
41
  requirements:
42
- - - ! '>='
42
+ - - ">="
43
43
  - !ruby/object:Gem::Version
44
44
  version: '0'
45
45
  required_rubygems_version: !ruby/object:Gem::Requirement
46
- none: false
47
46
  requirements:
48
- - - ! '>='
47
+ - - ">="
49
48
  - !ruby/object:Gem::Version
50
49
  version: '0'
51
50
  requirements: []
52
51
  rubyforge_project:
53
- rubygems_version: 1.8.24
52
+ rubygems_version: 2.4.5
54
53
  signing_key:
55
- specification_version: 3
54
+ specification_version: 4
56
55
  summary: Simple toolkit for processing input using filter/pipeline concept
57
56
  test_files:
58
- - test/banzai/filter_test.rb
59
- - test/banzai/pipeline_test.rb
60
- - test/test_helper.rb
61
- has_rdoc:
57
+ - spec/filter_spec.rb
58
+ - spec/pipeline_spec.rb
59
+ - spec/spec_helper.rb
@@ -1,21 +0,0 @@
1
- require 'test_helper'
2
-
3
- class LeetFilter < Banzai::Filter
4
- def call(input)
5
- input.gsub(/elite/, '1337')
6
- end
7
- end
8
-
9
- describe Banzai::Filter do
10
- describe 'subclass' do
11
- it 'can be created with some options' do
12
- filter = LeetFilter.new(:mode => 'hardcore')
13
- assert 'hardcore', filter.options[:mode]
14
- end
15
-
16
- it 'applies to some input' do
17
- assert_equal '1337 security', LeetFilter.call('elite security')
18
- assert_equal '1337 security', LeetFilter.new.call('elite security')
19
- end
20
- end
21
- end
@@ -1,20 +0,0 @@
1
- require 'test_helper'
2
-
3
- class StripFilter < Banzai::Filter
4
- def call(input)
5
- input.strip
6
- end
7
- end
8
-
9
- class UpcaseFilter < Banzai::Filter
10
- def call(input)
11
- input.upcase
12
- end
13
- end
14
-
15
- describe Banzai::Pipeline do
16
- it 'applies to input' do
17
- pipeline = Banzai::Pipeline.new [StripFilter, UpcaseFilter]
18
- assert_equal 'OHAI', pipeline.call(' ohai ')
19
- end
20
- end
data/test/test_helper.rb DELETED
@@ -1,5 +0,0 @@
1
- require 'rubygems'
2
- require 'bundler/setup'
3
- require 'banzai'
4
- require 'minitest/autorun'
5
-