banzai 0.1.2 → 0.1.3

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
- SHA1:
3
- metadata.gz: 33df5d09bd02ee144ba10a0b34d13071ba1d3855
4
- data.tar.gz: ab729868341e7b5145c3f70fdf263099dd079fc1
2
+ SHA256:
3
+ metadata.gz: 5f5811af68c70c358149d1715e7c34c1ee457a1d9c4f0c276dfab9a150e79e3e
4
+ data.tar.gz: b68891654e1d0f84b1570949e2468917e51a5c867982c2edc8c9e4c337b882d6
5
5
  SHA512:
6
- metadata.gz: 864fba492a923a8ff6c24b4ce8e5ea56d8b8b47d8a1b414722ded28d5c20aea51228c975e04071e9f30f81537918f46a6190abc1556949e81a97d9e6b053b552
7
- data.tar.gz: 34c9122ab610c73c9b91bcc8dcf2454d7f6fb06d7877c3fb0ecf5c6c55ee3dfbaecb4e9e25501a4f496e6056e99f4a849041464bacea12575d62425fe13fdb41
6
+ metadata.gz: 2fece6ef4f371f9eb356f733037d903a4aa0589a955284f2d19e08c4b8c73bc2125b6710ab92ab954573933778fca1c3afbdb21181f3d4c1377769bb123012f5
7
+ data.tar.gz: f1b5823211f65a050db0540e2c207b25abe6a14b8b5ec731cfbba7b9ab080f0fcee2d25b49774731e79a9f43853ffdc2862e89288968f48fbf3683d757a5fae5
data/README.md CHANGED
@@ -16,13 +16,15 @@ First, implement some filters:
16
16
  ```ruby
17
17
  class GaussianBlur < Banzai::Filter
18
18
  def call(input)
19
- # ... filter implementation ...
19
+ # process input
20
+ # ...
20
21
  end
21
22
  end
22
23
 
23
24
  class Nostalgia < Banzai::Filter
24
25
  def call(input)
25
- # ... filter implementation ...
26
+ # process input
27
+ # ...
26
28
  end
27
29
  end
28
30
  ```
@@ -31,23 +33,25 @@ Then you can apply them to some input:
31
33
 
32
34
  ```ruby
33
35
  GaussianBlur.new(radius:1.1).call(image)
36
+ ```
37
+
38
+ You can also use class method `call` if filter doesn't have options, or you
39
+ want to apply default ones (defined in implementation itself):
34
40
 
35
- # You can also use class method *call* if filter doesn't have options,
36
- # or you want to apply default ones (defined in implementation itself)
37
- GaussianBlur.call(image)
41
+ ```ruby
42
+ Nostalgia.call(image)
38
43
  ```
39
44
 
40
- Use pipelines to apply multiple fitlers:
45
+ To apply multiple filters to input use `Banzai::Pipeline`. Note that you can
46
+ combine filter class and it's instances:
41
47
 
42
48
  ```ruby
43
- # Note that you can combine classes and instances
44
- # Use instances when you need to pass options to the filter
45
49
  blurred_effect = Banzai::Pipeline.new(GaussianBlur.new(radius:1.1), Nostalgia)
46
50
  blurred_effect.call(image)
47
51
  ```
48
52
 
49
- Pipeline is just another filter, so you can mix them too into a new
50
- pipeline:
53
+ `Banzai::Pipeline` is just another filter, so you can mix them with filters
54
+ into a new pipeline:
51
55
 
52
56
  ```ruby
53
57
  Banzai::Pipeline.new(blurred_effect, RoundCorners.new(radius:0.87))
@@ -80,28 +84,10 @@ Open a pull request but first make sure this is green:
80
84
 
81
85
  bundle exec rake
82
86
 
87
+ ## Code status
83
88
 
84
- ## Licence
85
-
86
- Copyright (c) 2015 Dejan Simic
87
-
88
- MIT License
89
+ [![Circle CI](https://circleci.com/gh/dejan/banzai.svg?style=svg&circle-token=2636aac2d1b87f82160412f7613caa76d66d59ce)](https://circleci.com/gh/dejan/banzai)
89
90
 
90
- Permission is hereby granted, free of charge, to any person obtaining
91
- a copy of this software and associated documentation files (the
92
- "Software"), to deal in the Software without restriction, including
93
- without limitation the rights to use, copy, modify, merge, publish,
94
- distribute, sublicense, and/or sell copies of the Software, and to
95
- permit persons to whom the Software is furnished to do so, subject to
96
- the following conditions:
97
-
98
- The above copyright notice and this permission notice shall be
99
- included in all copies or substantial portions of the Software.
91
+ ## Licence
100
92
 
101
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
102
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
103
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
104
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
105
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
106
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
107
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
93
+ Banzai is released under the [MIT License](https://raw.githubusercontent.com/dejan/banzai/master/MIT-LICENCE).
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Banzai is a simple toolkit for processing any input using filters.
2
4
  # Multiple filters can be combined into a pipeline that will transform input
3
5
  # by appliyng filters in chain feeding next one with the output of the previous.
@@ -1,26 +1,30 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Banzai
2
4
  # Filter transforms an input into desired output. The process of
3
5
  # transformation should be implemented in the {#call} method.
4
6
  class Filter
5
7
  attr_reader :options
6
8
 
7
- # @param options [Hash] filter parameters that method {#call} can utilize
9
+ # @param [Hash] options The parameters that method {#call} can utilize
8
10
  # to make processing customizable
9
11
  def initialize(options = {})
10
12
  @options = options
11
13
  end
12
14
 
13
- # Subclass should redefine this method to transform input to desired output
15
+ # Subclass should redefine this method to transform input to desired output.
16
+ # Input and return value should be the same type to provide way of chaining
17
+ # filters
14
18
  #
15
- # @param input [Object] the type of the input is not defined since it will
16
- # depend on the (re)implementation of the method
19
+ # @param [Object] input
20
+ # @return [Object] the desired output
17
21
  def call(input)
18
22
  input
19
23
  end
20
24
 
21
25
  # Delegates to {#call} by creating an instance with default options
22
26
  #
23
- # @param input [Object]
27
+ # @param [Object] input
24
28
  def self.call(input)
25
29
  new.call(input)
26
30
  end
@@ -1,11 +1,23 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Banzai
2
- # Pipeline is a filter that accept an array of filters that will be applied
4
+ # Pipeline is a filter that accepts an array of filters that will be applied
3
5
  # to input sequentially.
6
+ #
7
+ # @example Create a pipeline and process input
8
+ # Pipeline.new(GaussianBlur.new(radius:1.1), Nostalgia).call(image)
9
+ #
4
10
  class Pipeline < Filter
11
+ # @param [Array<Filter>] filters array of filters that will be in the
12
+ # pipeline. They can be either Filter class or instance.
5
13
  def initialize(*filters)
6
14
  @filters = filters.flatten
7
15
  end
8
16
 
17
+ # Process input by sending it down the filters pipeline
18
+ #
19
+ # @param [Object] input
20
+ # @return [Object]
9
21
  def call(input)
10
22
  @filters.inject(input) do |content, filter|
11
23
  filter.call(content)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  RSpec.describe Banzai::Filter, 'subclass' do
2
4
  # A simple Filter implementation for testing
3
5
  class Yell < Banzai::Filter
@@ -1,18 +1,20 @@
1
- RSpec.describe Banzai::Pipeline do
2
- # Simple filter implementation for testing
3
- class Strip < Banzai::Filter
4
- def call(input)
5
- input.strip
6
- end
1
+ # frozen_string_literal: true
2
+
3
+ # Simple filter implementation for testing
4
+ class Strip < Banzai::Filter
5
+ def call(input)
6
+ input.strip
7
7
  end
8
+ end
8
9
 
9
- # Simple filter implementation for testing
10
- class Upcase < Banzai::Filter
11
- def call(input)
12
- input.upcase
13
- end
10
+ # Simple filter implementation for testing
11
+ class Upcase < Banzai::Filter
12
+ def call(input)
13
+ input.upcase
14
14
  end
15
+ end
15
16
 
17
+ RSpec.describe Banzai::Pipeline do
16
18
  let(:input) { ' ohai ' }
17
19
  let(:output) { 'OHAI' }
18
20
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'banzai'
2
4
 
3
5
  RSpec.configure do |config|
metadata CHANGED
@@ -1,43 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: banzai
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dejan Simic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-03 00:00:00.000000000 Z
11
+ date: 2018-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 12.3.0
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 12.3.0
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: rubocop
15
29
  requirement: !ruby/object:Gem::Requirement
16
30
  requirements:
17
- - - ">="
31
+ - - "~>"
18
32
  - !ruby/object:Gem::Version
19
- version: '0'
33
+ version: 0.53.0
20
34
  type: :development
21
35
  prerelease: false
22
36
  version_requirements: !ruby/object:Gem::Requirement
23
37
  requirements:
24
- - - ">="
38
+ - - "~>"
25
39
  - !ruby/object:Gem::Version
26
- version: '0'
40
+ version: 0.53.0
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: yard
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
- - - ">="
45
+ - - "~>"
32
46
  - !ruby/object:Gem::Version
33
- version: '0'
47
+ version: 0.9.12
34
48
  type: :development
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
- - - ">="
52
+ - - "~>"
39
53
  - !ruby/object:Gem::Version
40
- version: '0'
54
+ version: 0.9.12
41
55
  description: Toolkit for processing input using filters and pipelines
42
56
  email:
43
57
  - desimic@gmail.com
@@ -72,12 +86,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
72
86
  version: '0'
73
87
  requirements: []
74
88
  rubyforge_project:
75
- rubygems_version: 2.4.5
89
+ rubygems_version: 2.7.3
76
90
  signing_key:
77
91
  specification_version: 4
78
92
  summary: Toolkit for processing input using filters and pipelines
79
93
  test_files:
80
- - spec/filter_spec.rb
81
- - spec/pipeline_spec.rb
82
94
  - spec/spec_helper.rb
83
- has_rdoc:
95
+ - spec/pipeline_spec.rb
96
+ - spec/filter_spec.rb