pipeable 0.0.1 → 0.2.0
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 +5 -5
- checksums.yaml.gz.sig +0 -0
- data/LICENSE.adoc +134 -0
- data/README.adoc +572 -0
- data/lib/pipeable/composable.rb +12 -0
- data/lib/pipeable/definer.rb +49 -0
- data/lib/pipeable/pipe.rb +16 -0
- data/lib/pipeable/steps/abstract.rb +25 -0
- data/lib/pipeable/steps/as.rb +12 -0
- data/lib/pipeable/steps/bind.rb +10 -0
- data/lib/pipeable/steps/check.rb +30 -0
- data/lib/pipeable/steps/container.rb +26 -0
- data/lib/pipeable/steps/fmap.rb +10 -0
- data/lib/pipeable/steps/insert.rb +27 -0
- data/lib/pipeable/steps/map.rb +10 -0
- data/lib/pipeable/steps/merge.rb +27 -0
- data/lib/pipeable/steps/or.rb +10 -0
- data/lib/pipeable/steps/tee.rb +22 -0
- data/lib/pipeable/steps/to.rb +27 -0
- data/lib/pipeable/steps/try.rb +23 -0
- data/lib/pipeable/steps/use.rb +19 -0
- data/lib/pipeable/steps/validate.rb +28 -0
- data/lib/pipeable.rb +21 -3
- data/pipeable.gemspec +30 -18
- data.tar.gz.sig +0 -0
- metadata +121 -49
- metadata.gz.sig +3 -0
- data/.gitignore +0 -17
- data/.travis.yml +0 -1
- data/Gemfile +0 -5
- data/LICENSE.txt +0 -22
- data/README.md +0 -46
- data/Rakefile +0 -1
- data/lib/pipeable/version.rb +0 -3
- data/spec/pipeable_spec.rb +0 -27
- data/spec/spec_helper.rb +0 -11
data/README.md
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
# Pipeable
|
|
2
|
-
|
|
3
|
-
A play at Unix Piping in Ruby for kicks. It helps to break up some more exotic logic and chaining.
|
|
4
|
-
|
|
5
|
-
It can be used to play with a value in a method chain and return whatever you want out of the block. Personally I'm
|
|
6
|
-
still toying with how it can be used and working to find clever tricks with it.
|
|
7
|
-
|
|
8
|
-
_That being said, this is a 5 minute hack. You've been warned._
|
|
9
|
-
|
|
10
|
-
Piping is simple, we take the object and put a pipe on it:
|
|
11
|
-
```ruby
|
|
12
|
-
1.pipe { |x| "#{x} is great!" }
|
|
13
|
-
# => '1 is great!'
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
How do you get going with pipe?
|
|
17
|
-
```ruby
|
|
18
|
-
include Pipeable
|
|
19
|
-
```
|
|
20
|
-
...and your object is ready to go!
|
|
21
|
-
|
|
22
|
-
## Installation
|
|
23
|
-
|
|
24
|
-
Add this line to your application's Gemfile:
|
|
25
|
-
|
|
26
|
-
gem 'pipeable'
|
|
27
|
-
|
|
28
|
-
And then execute:
|
|
29
|
-
|
|
30
|
-
$ bundle
|
|
31
|
-
|
|
32
|
-
Or install it yourself as:
|
|
33
|
-
|
|
34
|
-
$ gem install pipeable
|
|
35
|
-
|
|
36
|
-
## Usage
|
|
37
|
-
|
|
38
|
-
Slap a pipe on the end of it!
|
|
39
|
-
|
|
40
|
-
## Contributing
|
|
41
|
-
|
|
42
|
-
1. Fork it ( http://github.com/baweaver/pipeable/fork )
|
|
43
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
44
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
45
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
|
46
|
-
5. Create new Pull Request
|
data/Rakefile
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
require "bundler/gem_tasks"
|
data/lib/pipeable/version.rb
DELETED
data/spec/pipeable_spec.rb
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
require 'ostruct'
|
|
3
|
-
|
|
4
|
-
# Monkey Patch it in
|
|
5
|
-
class Object
|
|
6
|
-
include Pipeable
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
describe 'Pipeable' do
|
|
10
|
-
context 'When used with an Integer' do
|
|
11
|
-
it 'returns 100 when piped multiple times' do
|
|
12
|
-
value = 1.pipe { |v| v * 10 }.pipe { |v| v * 10 }
|
|
13
|
-
|
|
14
|
-
expect(value).to eq(100)
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
context 'When used with a Person' do
|
|
19
|
-
let(:person) { OpenStruct.new(name: 'brandon', foo: true, bar: true, baz: true)}
|
|
20
|
-
|
|
21
|
-
it 'returns true with conditionals' do
|
|
22
|
-
value = person.pipe { |me| me.foo && me.bar && me.baz }
|
|
23
|
-
|
|
24
|
-
expect(value).to be_true
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|