pipe_envy 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pipe_envy.rb +0 -12
- data/lib/pipe_envy/version.rb +1 -1
- data/test/pipe_envy_test.rb +3 -8
- 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: dbf66e669e3f292fc9b155dc75993c09fa9c1014
|
4
|
+
data.tar.gz: 59b48abc5c93d18e1bd75c441a81731bc0b017b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6c6e8cdd366cb365844ebdd2e98368167950bbfd800ff51667f48b35f3db66fc22b5e26b84aad7b7ff8d9c27cae227e6e23303e27dc1ea327a4bf9db48fb44c
|
7
|
+
data.tar.gz: b6478a260e15d66d325ba37501614ced5c3c994459c7ad800144c3d34fa5f6b39de7218f6c9b016101774270bdec1ae91031614d699000047e1e63a57e736fbc
|
data/lib/pipe_envy.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require "delegate"
|
2
1
|
require_relative "./pipe_envy/version"
|
3
2
|
|
4
3
|
PIPE_ENVY_PIPE = -> (arg) do
|
@@ -17,22 +16,11 @@ PIPE_ENVY_PIPE = -> (arg) do
|
|
17
16
|
else
|
18
17
|
result = send(method, *args, &block)
|
19
18
|
end
|
20
|
-
result = PipeEnvyArray.new(result) if result.is_a?(Array)
|
21
19
|
#puts "#{self.class.name}, method=#{method.inspect}, args=#{args.inspect}, block=#{block.inspect}, result=#{result.inspect}"
|
22
20
|
#puts
|
23
21
|
result
|
24
22
|
end
|
25
23
|
|
26
|
-
class PipeEnvyArray < SimpleDelegator
|
27
|
-
define_method :|, &PIPE_ENVY_PIPE
|
28
|
-
|
29
|
-
# Original Array pipe operator method logic
|
30
|
-
# SEE: https://ruby-doc.org/core-2.4.1/Array.html#method-i-7C
|
31
|
-
def union(other_array=[])
|
32
|
-
(self + (other_array - self)).uniq
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
24
|
module PipeEnvy
|
37
25
|
refine Object do
|
38
26
|
define_method :|, &PIPE_ENVY_PIPE
|
data/lib/pipe_envy/version.rb
CHANGED
data/test/pipe_envy_test.rb
CHANGED
@@ -1,4 +1,7 @@
|
|
1
1
|
require_relative "../lib/pipe_envy"
|
2
|
+
require "coveralls"
|
3
|
+
Coveralls.wear!
|
4
|
+
SimpleCov.command_name "pry-test"
|
2
5
|
using PipeEnvy
|
3
6
|
|
4
7
|
class PipeEnvyTest < PryTest::Test
|
@@ -14,14 +17,6 @@ class PipeEnvyTest < PryTest::Test
|
|
14
17
|
assert output == "E"
|
15
18
|
end
|
16
19
|
|
17
|
-
test "array pipes with union" do
|
18
|
-
output = "example" \
|
19
|
-
| :chars \
|
20
|
-
| [:union, ["a", "b", "c"]]
|
21
|
-
assert output == ["e", "x", "a", "m", "p", "l", "b", "c"]
|
22
|
-
assert output | :size == 8
|
23
|
-
end
|
24
|
-
|
25
20
|
test "pipes with block" do
|
26
21
|
output = [1, 2, 3, 4, 5, 6, 7, 8, 9] \
|
27
22
|
| [:select!, -> (i) { i.even? }]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pipe_envy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Hopkins
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: coveralls
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
description:
|
56
70
|
email:
|
57
71
|
- natehop@gmail.com
|