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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a304ea3db4e8015621d0464fb87513565ec11037
4
- data.tar.gz: 808ec638afd890440f88bb37081ba72c4cbdc89a
3
+ metadata.gz: 05f1d74c1a43250334c4040f4feab83b564a43da
4
+ data.tar.gz: c2fe54c3fabb5e1e13a7922580c765b8fcc47cb9
5
5
  SHA512:
6
- metadata.gz: abb245a6fd266c16899e7341e8b206bcb0996457b2a4863746d25ea8cee88deb8704ca57a18c5bad6b41e74cd3e41c1b9b63744a59e98be3b8ee0f46fb61e7b3
7
- data.tar.gz: 55661b1c7bd5da2696bf79ff2cc98954d46af5918041efaa7585206e3c31dcaf46f722082a818a80a0667b4605ec30e131924eb4d2b22125c5149edebd67c0f6
6
+ metadata.gz: 73fba62862a657d8b87e7d4daccceabd59ee69913e2f852c0cc3067b893dcc49bcf748e64bb2bd8de61f3d57f1bb7b99fb8d1230fd6ecccdf0c5be0f8155d912
7
+ data.tar.gz: d563f2c1eeca82112a93b4be12623a8353b209b42afde35d08543dae9db409e487365f3af362ce14d1e261d1d637017bd1c208ce51691b095d7a9babbb06fda4
data/.travis.yml CHANGED
@@ -1,4 +1,6 @@
1
1
  language: ruby
2
+ sudo: false
2
3
  rvm:
3
- - 2.2.3
4
- before_install: gem install bundler -v 1.11.2
4
+ - 2.2
5
+ before_install: gem install bundler -v 1.10.4
6
+ script: bundle exec rspec spec
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
- -> { "Pipe" }.| { |e| "#{e} things" }
5
- .| { |e| "#{e} in Ruby!" }
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.piped = call if piped.nil?
8
- chained.piped = chained.call(piped)
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
- piped || call
16
+ to_pipe || call(piped)
17
+ rescue ArgumentError
18
+ call
14
19
  end
15
20
  end
16
21
 
@@ -1,3 +1,3 @@
1
1
  module PipedRuby
2
- VERSION = '0.2.0'
2
+ VERSION = '0.2.1'
3
3
  end
data/piped_ruby.gemspec CHANGED
@@ -22,4 +22,5 @@ Gem::Specification.new do |spec|
22
22
  spec.add_development_dependency "bundler", "~> 1.11"
23
23
  spec.add_development_dependency "rake", "~> 10.0"
24
24
  spec.add_development_dependency "rspec", "~> 3.0"
25
+ spec.add_development_dependency "pry", "~> 0.10.3"
25
26
  end
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.0
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: