piped_ruby 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -2
- data/README.md +7 -6
- data/lib/piped_ruby.rb +9 -4
- data/lib/piped_ruby/version.rb +1 -1
- data/piped_ruby.gemspec +1 -0
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 05f1d74c1a43250334c4040f4feab83b564a43da
|
4
|
+
data.tar.gz: c2fe54c3fabb5e1e13a7922580c765b8fcc47cb9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73fba62862a657d8b87e7d4daccceabd59ee69913e2f852c0cc3067b893dcc49bcf748e64bb2bd8de61f3d57f1bb7b99fb8d1230fd6ecccdf0c5be0f8155d912
|
7
|
+
data.tar.gz: d563f2c1eeca82112a93b4be12623a8353b209b42afde35d08543dae9db409e487365f3af362ce14d1e261d1d637017bd1c208ce51691b095d7a9babbb06fda4
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,11 @@
|
|
1
1
|
# Piped Ruby
|
2
|
+
[![Code Climate](https://codeclimate.com/github/tiagopog/piped_ruby/badges/gpa.svg)](https://codeclimate.com/github/tiagopog/piped_ruby)
|
3
|
+
[![Build Status](https://travis-ci.org/tiagopog/piped_ruby.svg?branch=master)](https://travis-ci.org/tiagopog/piped_ruby)
|
4
|
+
|
2
5
|
|
3
6
|
```ruby
|
4
|
-
-> {
|
5
|
-
|
7
|
+
-> { 'Pipe' }.>> { |e| "#{e} things" }
|
8
|
+
.>> { |e| "#{e} in Ruby!" }
|
6
9
|
.unwrap #=> "Pipe things in Ruby!"
|
7
10
|
```
|
8
11
|
|
@@ -39,8 +42,7 @@ With Piped Ruby doing this:
|
|
39
42
|
```ruby
|
40
43
|
-> { some_text.upcase }.>> { |e| MyModule.method_a(e) }
|
41
44
|
.>> { |e| MyModule.method_b(e, "something") }
|
42
|
-
.>> { |e| MyModule.method_c(e) { |c| do_something3(c) } }
|
43
|
-
.unwrap
|
45
|
+
.>> { |e| MyModule.method_c(e) { |c| do_something3(c) } }.unwrap
|
44
46
|
```
|
45
47
|
|
46
48
|
...is equivalent to this:
|
@@ -64,8 +66,7 @@ def call
|
|
64
66
|
.>> { |e| match_fields_for(e) }
|
65
67
|
.>> { |e| sanitize(e) }
|
66
68
|
.>> { |e| Save.new(attributes: sanitize(e)) }
|
67
|
-
.>> { |save| save.call }
|
68
|
-
.unwrap
|
69
|
+
.>> { |save| save.call }.unwrap
|
69
70
|
end
|
70
71
|
end
|
71
72
|
```
|
data/lib/piped_ruby.rb
CHANGED
@@ -1,16 +1,21 @@
|
|
1
1
|
require 'piped_ruby/version'
|
2
2
|
|
3
3
|
module PipedRuby
|
4
|
-
attr_accessor :piped
|
4
|
+
attr_accessor :to_pipe, :piped
|
5
5
|
|
6
6
|
def >>(&chained)
|
7
|
-
self.
|
8
|
-
|
7
|
+
self.to_pipe = call if to_pipe.nil?
|
8
|
+
|
9
|
+
chained.piped = to_pipe
|
10
|
+
chained.to_pipe = chained.call(to_pipe)
|
11
|
+
|
9
12
|
chained
|
10
13
|
end
|
11
14
|
|
12
15
|
def unwrap
|
13
|
-
|
16
|
+
to_pipe || call(piped)
|
17
|
+
rescue ArgumentError
|
18
|
+
call
|
14
19
|
end
|
15
20
|
end
|
16
21
|
|
data/lib/piped_ruby/version.rb
CHANGED
data/piped_ruby.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: piped_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tiago Guedes
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.10.3
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.10.3
|
55
69
|
description: 'Piped Ruby is a tiny piece of code that brings an awesome feature to
|
56
70
|
Ruby: pipe operators.'
|
57
71
|
email:
|