pvc 0.0.4 → 0.0.5
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 +7 -0
- data/README.md +35 -6
- data/lib/pvc/pipeline.rb +3 -3
- data/lib/pvc/version.rb +1 -1
- data/spec/pvc/integration_spec.rb +8 -6
- data/spec/ruby/pipe_io_spec.rb +19 -5
- metadata +13 -20
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 839a3ec7cd1e8a85e9e151f76e9372c48649b5ae
|
4
|
+
data.tar.gz: cbf8cdcae201edd06e8efc7fd56b8286ba6b9433
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 161da10e1c9ca51059960f78c0f0996e6b06e395dbe5fe7bc0ddde211a0774002a12f97007b9e3596eef1b9652a21b448173cea6327746f6309ee0df994ccec4
|
7
|
+
data.tar.gz: 3f445615d873ed101554e57a1a4dd000f8b8dbebfc2f12a944f1bf89487362f7d02c9c9329da997a57c9c375ecc30285d04500277aac440fbd9e2c534889ef1f
|
data/README.md
CHANGED
@@ -1,15 +1,20 @@
|
|
1
1
|
# PVC
|
2
2
|
|
3
|
-
Pipe between processes as easily as in the shell
|
3
|
+
Pipe between processes as easily as in the shell (currently only on platforms with `IO.pipe`).
|
4
4
|
|
5
|
-
##
|
5
|
+
## Install it
|
6
6
|
|
7
|
-
|
7
|
+
gem install pvc
|
8
|
+
|
9
|
+
## Check out the code
|
10
|
+
|
11
|
+
git clone git://github.com/chrisberkhout/pvc.git && pvc
|
12
|
+
bundle install
|
8
13
|
bundle exec rspec spec
|
9
14
|
|
10
|
-
##
|
15
|
+
## Build the RubyGem yourself
|
11
16
|
|
12
|
-
|
17
|
+
If you like, you can build and install it by running:
|
13
18
|
|
14
19
|
gem build pvc.gemspec
|
15
20
|
gem install pvc-*.gem
|
@@ -61,7 +66,31 @@ This code is packaged as a Gem. If you like, you can build and install it by run
|
|
61
66
|
|
62
67
|
## Compatibility
|
63
68
|
|
64
|
-
|
69
|
+
Tested on Ruby 1.9.3 and 2.1.1.
|
70
|
+
|
71
|
+
## Copyright
|
72
|
+
|
73
|
+
The MIT License
|
74
|
+
|
75
|
+
Copyright (C) 2013 by Chris Berkhout (http://chrisberkhout.com)
|
76
|
+
|
77
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
78
|
+
of this software and associated documentation files (the "Software"), to deal
|
79
|
+
in the Software without restriction, including without limitation the rights
|
80
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
81
|
+
copies of the Software, and to permit persons to whom the Software is
|
82
|
+
furnished to do so, subject to the following conditions:
|
83
|
+
|
84
|
+
The above copyright notice and this permission notice shall be included in
|
85
|
+
all copies or substantial portions of the Software.
|
86
|
+
|
87
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
88
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
89
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
90
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
91
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
92
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
93
|
+
THE SOFTWARE.
|
65
94
|
|
66
95
|
## Contact
|
67
96
|
|
data/lib/pvc/pipeline.rb
CHANGED
@@ -23,7 +23,7 @@ module PVC
|
|
23
23
|
def to(*args, &block)
|
24
24
|
if block_given?
|
25
25
|
@pieces << BlockPiece.new(&block)
|
26
|
-
elsif args.length == 1 && args.first.respond_to?(:pieces)
|
26
|
+
elsif args.length == 1 && args.first.respond_to?(:pieces, true)
|
27
27
|
args.first.pieces.each { |piece| @pieces << piece }
|
28
28
|
else
|
29
29
|
@pieces << ProcessPiece.new(*args)
|
@@ -35,7 +35,7 @@ module PVC
|
|
35
35
|
@pieces << InputPiece.new(input)
|
36
36
|
self
|
37
37
|
end
|
38
|
-
|
38
|
+
|
39
39
|
def with_err
|
40
40
|
@pieces << WithErrPiece.new
|
41
41
|
self
|
@@ -58,7 +58,7 @@ module PVC
|
|
58
58
|
|
59
59
|
def run
|
60
60
|
runners = ([NullPiece.new] + @pieces + [ResultPiece.new]).map(&:runner)
|
61
|
-
|
61
|
+
|
62
62
|
runners.zip(runners[1..-1]).reverse.each do |current, following|
|
63
63
|
current.start(following)
|
64
64
|
end
|
data/lib/pvc/version.rb
CHANGED
@@ -17,20 +17,22 @@ describe "pvc" do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should let you get stderr" do
|
20
|
-
PVC.new("bash", "-c", "echo hello && ls doesnotexist").run.stderr.should
|
20
|
+
PVC.new("bash", "-c", "echo hello && ls doesnotexist").run.stderr.should =~ /ls:( cannot access)? doesnotexist: No such file or directory\n/
|
21
21
|
end
|
22
22
|
|
23
23
|
it "should let you get stdout and stderr together" do
|
24
|
-
PVC.new("bash", "-c", "echo hello && ls doesnotexist").run.stdboth.should
|
24
|
+
PVC.new("bash", "-c", "echo hello && ls doesnotexist").run.stdboth.should =~ /hello\nls:( cannot access)? doesnotexist: No such file or directory\n/
|
25
25
|
end
|
26
26
|
|
27
27
|
it "should let you get the exit code of the last process" do
|
28
28
|
PVC.new("echo", "hello").run.code.should == 0
|
29
|
-
PVC.new("bash", "-c", "echo hello && ls doesnotexist").run.code.should
|
29
|
+
PVC.new("bash", "-c", "echo hello && ls doesnotexist").run.code.should >= 1
|
30
30
|
end
|
31
31
|
|
32
32
|
it "should let you get several outputs from the final result" do
|
33
|
-
PVC.new("bash", "-c", "echo hello && ls doesnotexist").run.get(:stderr, :code)
|
33
|
+
result = PVC.new("bash", "-c", "echo hello && ls doesnotexist").run.get(:stderr, :code)
|
34
|
+
result[0].should =~ /ls:( cannot access)? doesnotexist: No such file or directory\n/
|
35
|
+
result[1].should >= 1
|
34
36
|
end
|
35
37
|
|
36
38
|
it "should let you input into the stdin" do
|
@@ -44,11 +46,11 @@ describe "pvc" do
|
|
44
46
|
end
|
45
47
|
|
46
48
|
it "should let you mix stderr and stdin at some point in a pipeline" do
|
47
|
-
PVC.new("bash", "-c", "echo hello && ls doesnotexist").with_err.to("wc", "-l").run.stdout.should
|
49
|
+
PVC.new("bash", "-c", "echo hello && ls doesnotexist").with_err.to("wc", "-l").run.stdout.should =~ / *2\n/
|
48
50
|
end
|
49
51
|
|
50
52
|
it "should let you pass on only stderr at some point in a pipeline" do
|
51
|
-
PVC.new("bash", "-c", "echo hello && ls doesnotexist").only_err.to("wc", "-l").run.stdout.should
|
53
|
+
PVC.new("bash", "-c", "echo hello && ls doesnotexist").only_err.to("wc", "-l").run.stdout.should =~ / *1\n/
|
52
54
|
end
|
53
55
|
|
54
56
|
it "should let you insert one pipeline into another" do
|
data/spec/ruby/pipe_io_spec.rb
CHANGED
@@ -14,11 +14,25 @@ describe "pipe io" do
|
|
14
14
|
|
15
15
|
# see also the example at: http://rubydoc.info/stdlib/core/1.9.3/IO.pipe
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
write.
|
21
|
-
|
17
|
+
context "on ruby 1.9.3" do
|
18
|
+
before(:each) { pending "run on ruby 1.9.3" unless RUBY_VERSION == "1.9.3" }
|
19
|
+
it "will not show EOF on close if a fork has an open copy of the file handle" do
|
20
|
+
read, write = IO.pipe
|
21
|
+
fork_childprocess do
|
22
|
+
write.close
|
23
|
+
expect { read.read_nonblock(1) }.to raise_error(Errno::EAGAIN) # not yet EOF
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context "on ruby >= 2.1.1" do
|
29
|
+
before(:each) { pending "run on ruby >= 2.1.1" unless RUBY_VERSION >= "2.1.1" }
|
30
|
+
it "will show EOF on close even if a fork has an open copy of the file handle" do
|
31
|
+
read, write = IO.pipe
|
32
|
+
fork_childprocess do
|
33
|
+
write.close
|
34
|
+
expect { read.read_nonblock(1) }.to raise_error(EOFError) # this is nicer
|
35
|
+
end
|
22
36
|
end
|
23
37
|
end
|
24
38
|
|
metadata
CHANGED
@@ -1,46 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pvc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.5
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Chris Berkhout
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-08-25 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: childprocess
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rspec
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - ">="
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - ">="
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
description:
|
@@ -50,8 +45,8 @@ executables: []
|
|
50
45
|
extensions: []
|
51
46
|
extra_rdoc_files: []
|
52
47
|
files:
|
53
|
-
- .gitignore
|
54
|
-
- .rspec
|
48
|
+
- ".gitignore"
|
49
|
+
- ".rspec"
|
55
50
|
- Gemfile
|
56
51
|
- Gemfile.lock
|
57
52
|
- README.md
|
@@ -74,30 +69,28 @@ files:
|
|
74
69
|
- spec/spec_helper.rb
|
75
70
|
homepage: http://github.com/chrisberkhout/pvc
|
76
71
|
licenses: []
|
72
|
+
metadata: {}
|
77
73
|
post_install_message:
|
78
74
|
rdoc_options: []
|
79
75
|
require_paths:
|
80
76
|
- lib
|
81
77
|
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
-
none: false
|
83
78
|
requirements:
|
84
|
-
- -
|
79
|
+
- - ">="
|
85
80
|
- !ruby/object:Gem::Version
|
86
81
|
version: 1.9.0
|
87
82
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
-
none: false
|
89
83
|
requirements:
|
90
|
-
- -
|
84
|
+
- - ">="
|
91
85
|
- !ruby/object:Gem::Version
|
92
86
|
version: '0'
|
93
87
|
requirements: []
|
94
88
|
rubyforge_project: pvc
|
95
|
-
rubygems_version:
|
89
|
+
rubygems_version: 2.2.2
|
96
90
|
signing_key:
|
97
|
-
specification_version:
|
91
|
+
specification_version: 4
|
98
92
|
summary: Easy piping between processes
|
99
93
|
test_files:
|
100
94
|
- spec/pvc/integration_spec.rb
|
101
95
|
- spec/ruby/pipe_io_spec.rb
|
102
96
|
- spec/spec_helper.rb
|
103
|
-
has_rdoc:
|