pipeable 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1407794b407ad74a49d4485e3d1797e081e8189e
4
+ data.tar.gz: 64760a0c1c037b9fd849a889422838b1dbf68025
5
+ SHA512:
6
+ metadata.gz: e2acbb685996de12768e48c6d5f950221377be0148d1bf0141f6cfd7a462a96b084a0cdf32799e95934506b125b7f248cca017ec18ba419386f0ce1bcd4e349d
7
+ data.tar.gz: 3c6c4ca77d3c3454ee0dd7f4d634f6ee952e4a1e58e2eb09507c7aa0db56e6ec18d5dce6b46b984dd5538cc0a72067f60f1f04e0933e6e3e6e22edeac63ea6e7
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
@@ -0,0 +1 @@
1
+ language: ruby
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in pipeable.gemspec
4
+ gemspec
5
+ gem 'coveralls', require: false
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Brandon Weaver
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,46 @@
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
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,7 @@
1
+ require "pipeable/version"
2
+
3
+ module Pipeable
4
+ def pipe(&block)
5
+ yield self
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ module Pipeable
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,22 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'pipeable/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "pipeable"
8
+ spec.version = Pipeable::VERSION
9
+ spec.authors = ["Brandon Weaver"]
10
+ spec.email = ["keystonelemur@gmail.com"]
11
+ spec.summary = %q{A Mock at Unix Piping in Ruby}
12
+ spec.homepage = "https://www.github.com/baweaver/pipeable"
13
+ spec.license = "MIT"
14
+ spec.files = `git ls-files -z`.split("\x0")
15
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
16
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
+ spec.require_paths = ["lib"]
18
+
19
+ spec.add_development_dependency "bundler", "~> 1.5"
20
+ spec.add_development_dependency "rake"
21
+ spec.add_development_dependency "rspec"
22
+ end
@@ -0,0 +1,27 @@
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
@@ -0,0 +1,11 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+
4
+ require 'pipeable'
5
+
6
+ require 'coveralls'
7
+ Coveralls.wear!
8
+
9
+ RSpec.configure do |config|
10
+ # some (optional) config here
11
+ end
metadata ADDED
@@ -0,0 +1,99 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pipeable
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Brandon Weaver
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-01-31 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description:
56
+ email:
57
+ - keystonelemur@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - .gitignore
63
+ - .travis.yml
64
+ - Gemfile
65
+ - LICENSE.txt
66
+ - README.md
67
+ - Rakefile
68
+ - lib/pipeable.rb
69
+ - lib/pipeable/version.rb
70
+ - pipeable.gemspec
71
+ - spec/pipeable_spec.rb
72
+ - spec/spec_helper.rb
73
+ homepage: https://www.github.com/baweaver/pipeable
74
+ licenses:
75
+ - MIT
76
+ metadata: {}
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubyforge_project:
93
+ rubygems_version: 2.2.1
94
+ signing_key:
95
+ specification_version: 4
96
+ summary: A Mock at Unix Piping in Ruby
97
+ test_files:
98
+ - spec/pipeable_spec.rb
99
+ - spec/spec_helper.rb