open3_backport 0.0.1
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.
- data/.gitignore +17 -0
- data/.rvmrc +1 -0
- data/BSDL +23 -0
- data/Gemfile +4 -0
- data/Guardfile +13 -0
- data/LICENSE +65 -0
- data/README.md +228 -0
- data/Rakefile +4 -0
- data/lib/open3_backport.rb +6 -0
- data/lib/open3_backport/open3.rb +676 -0
- data/lib/open3_backport/original_open3.rb +729 -0
- data/lib/open3_backport/version.rb +3 -0
- data/open3_backport.gemspec +25 -0
- data/spec.opts +6 -0
- data/spec/lib/open3_spec.rb +198 -0
- data/spec/spec_helper.rb +6 -0
- data/tasks/console.rake +5 -0
- data/tasks/environment.rake +4 -0
- data/tasks/spec.rake +12 -0
- metadata +194 -0
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.unshift File.expand_path('../lib', __FILE__)
|
3
|
+
require 'open3_backport/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.authors = ["Chris Johnson"]
|
7
|
+
gem.email = ["chris@kindkid.com"]
|
8
|
+
gem.description = "Backport of new Open3 methods from Ruby 1.9 to Ruby 1.8"
|
9
|
+
gem.summary = gem.description
|
10
|
+
gem.homepage = "https://github.com/kindkid/open3_backport"
|
11
|
+
|
12
|
+
gem.files = `git ls-files`.split($\)
|
13
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
14
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
15
|
+
gem.name = "open3_backport"
|
16
|
+
gem.require_paths = ["lib"]
|
17
|
+
gem.version = Open3Backport::VERSION
|
18
|
+
gem.add_dependency "open4", "~> 1.3.0"
|
19
|
+
gem.add_development_dependency "rake"
|
20
|
+
gem.add_development_dependency "rspec", "~> 2.11.0"
|
21
|
+
gem.add_development_dependency("rb-fsevent", "~> 0.9.2") if RUBY_PLATFORM =~ /darwin/i
|
22
|
+
gem.add_development_dependency "guard", "~> 1.5.0"
|
23
|
+
gem.add_development_dependency "guard-bundler", "~> 1.0.0"
|
24
|
+
gem.add_development_dependency "guard-rspec", "~> 2.1.0"
|
25
|
+
end
|
data/spec.opts
ADDED
@@ -0,0 +1,198 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe Open3 do
|
4
|
+
context "Open3.popen3" do
|
5
|
+
it "should support block form" do
|
6
|
+
Open3.popen3("echo", "test value") do |i,o,e,t|
|
7
|
+
t.pid.should > 0
|
8
|
+
o.read.strip.should == 'test value'
|
9
|
+
e.read.strip.should == ''
|
10
|
+
t.value.success?.should be_true
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should support non-block form" do
|
15
|
+
i,o,e,t = Open3.popen3("echo", "test value")
|
16
|
+
t[:pid].should > 0
|
17
|
+
o.read.strip.should == 'test value'
|
18
|
+
e.read.strip.should == ''
|
19
|
+
i.close
|
20
|
+
o.close
|
21
|
+
e.close
|
22
|
+
t.value.success?.should be_true
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should expand its first argument" do
|
26
|
+
Open3.popen3("echo $PATH") do |i,o,e,t|
|
27
|
+
output = o.read.strip
|
28
|
+
output.should_not == '$PATH'
|
29
|
+
output.length.should > 0
|
30
|
+
e.read.strip.should == ''
|
31
|
+
t.value.success?.should be_true
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should not expand its other arguments" do
|
36
|
+
Open3.popen3("echo","$PATH","$PATH") do |i,o,e,t|
|
37
|
+
o.read.strip.should == '$PATH $PATH'
|
38
|
+
e.read.strip.should == ''
|
39
|
+
t.value.success?.should be_true
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should keep stdout and stderr seperate" do
|
44
|
+
Open3.popen3("cat - && cat /dev/monkey") do |i,o,e,t|
|
45
|
+
i.write 'test value'
|
46
|
+
i.close
|
47
|
+
o.read.strip.should == 'test value'
|
48
|
+
e.read.strip.should include '/dev/monkey'
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context "Open3.popen2" do
|
54
|
+
it "should support block form" do
|
55
|
+
Open3.popen2("echo", "test value") do |i,o,t|
|
56
|
+
t.pid.should > 0
|
57
|
+
o.read.strip.should == 'test value'
|
58
|
+
t.value.success?.should be_true
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should support non-block form" do
|
63
|
+
i,o,t = Open3.popen2("echo", "test value")
|
64
|
+
t[:pid].should > 0
|
65
|
+
o.read.strip.should == 'test value'
|
66
|
+
i.close
|
67
|
+
o.close
|
68
|
+
t.value.success?.should be_true
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should expand its first argument" do
|
72
|
+
Open3.popen2("echo $PATH") do |i,o,t|
|
73
|
+
output = o.read.strip
|
74
|
+
output.should_not == '$PATH'
|
75
|
+
output.length.should > 0
|
76
|
+
t.value.success?.should be_true
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should not expand its other arguments" do
|
81
|
+
Open3.popen2("echo","$PATH","$PATH") do |i,o,t|
|
82
|
+
o.read.strip.should == '$PATH $PATH'
|
83
|
+
t.value.success?.should be_true
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should keep stdout throw out stderr" do
|
88
|
+
Open3.popen2("cat - && cat /dev/monkey") do |i,o,t|
|
89
|
+
i.write 'test value'
|
90
|
+
i.close
|
91
|
+
o.read.strip.should == 'test value'
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
context "Open3.popen2e" do
|
97
|
+
it "doesn't work yet" do
|
98
|
+
pending "merged_read_stream not implemented"
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
context "Open3.capture3" do
|
103
|
+
it "should expand its first argument" do
|
104
|
+
o,e,s = Open3.capture3("echo $PATH")
|
105
|
+
o.strip.should_not == '$PATH'
|
106
|
+
o.strip.length.should > 0
|
107
|
+
e.should == ''
|
108
|
+
s.success?.should be_true
|
109
|
+
end
|
110
|
+
|
111
|
+
it "should not expand its other arguments" do
|
112
|
+
o,e,s = Open3.capture3("echo","$PATH","$PATH")
|
113
|
+
o.strip.should == '$PATH $PATH'
|
114
|
+
e.should == ''
|
115
|
+
s.success?.should be_true
|
116
|
+
end
|
117
|
+
|
118
|
+
it "should keep stdout and stderr seperate" do
|
119
|
+
o,e,s = Open3.capture3("cat - && cat /dev/monkey", :stdin_data => "test value")
|
120
|
+
o.strip.should == 'test value'
|
121
|
+
e.should include '/dev/monkey'
|
122
|
+
s.success?.should be_false
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
context "Open3.capture2" do
|
127
|
+
it "should expand its first argument" do
|
128
|
+
o,s = Open3.capture2("echo $PATH")
|
129
|
+
o.strip.should_not == '$PATH'
|
130
|
+
o.strip.length.should > 0
|
131
|
+
s.success?.should be_true
|
132
|
+
end
|
133
|
+
|
134
|
+
it "should not expand its other arguments" do
|
135
|
+
o,s = Open3.capture2("echo","$PATH","$PATH")
|
136
|
+
o.strip.should == '$PATH $PATH'
|
137
|
+
s.success?.should be_true
|
138
|
+
end
|
139
|
+
|
140
|
+
it "should keep stdout and throw out stderr" do
|
141
|
+
o,s = Open3.capture2("cat - && cat /dev/monkey", :stdin_data => "test value")
|
142
|
+
o.strip.should == 'test value'
|
143
|
+
s.success?.should be_false
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
context "Open3.capture2e" do
|
148
|
+
it "should expand its first argument" do
|
149
|
+
o,s = Open3.capture2e("echo $PATH")
|
150
|
+
o.strip.should_not == '$PATH'
|
151
|
+
o.strip.length.should > 0
|
152
|
+
s.success?.should be_true
|
153
|
+
end
|
154
|
+
|
155
|
+
it "should not expand its other arguments" do
|
156
|
+
o,s = Open3.capture2e("echo","$PATH","$PATH")
|
157
|
+
o.strip.should == '$PATH $PATH'
|
158
|
+
s.success?.should be_true
|
159
|
+
end
|
160
|
+
|
161
|
+
it "should combine stdout and stderr" do
|
162
|
+
o,s = Open3.capture2e("cat - && cat /dev/monkey", :stdin_data => "test value")
|
163
|
+
o.should include 'test value'
|
164
|
+
o.should include '/dev/monkey'
|
165
|
+
s.success?.should be_false
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
context "Open3.pipeline_rw" do
|
170
|
+
it "doesn't work yet" do
|
171
|
+
pending "not implemented"
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
context "Open3.pipeline_r" do
|
176
|
+
it "doesn't work yet" do
|
177
|
+
pending "not implemented"
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
context "Open3.pipeline_w" do
|
182
|
+
it "doesn't work yet" do
|
183
|
+
pending "not implemented"
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
context "Open3.pipeline_start" do
|
188
|
+
it "doesn't work yet" do
|
189
|
+
pending "not implemented"
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
context "Open3.pipeline" do
|
194
|
+
it "doesn't work yet" do
|
195
|
+
pending "not implemented"
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
data/spec/spec_helper.rb
ADDED
data/tasks/console.rake
ADDED
data/tasks/spec.rake
ADDED
metadata
ADDED
@@ -0,0 +1,194 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: open3_backport
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Chris Johnson
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2012-12-12 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
22
|
+
none: false
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
hash: 27
|
27
|
+
segments:
|
28
|
+
- 1
|
29
|
+
- 3
|
30
|
+
- 0
|
31
|
+
version: 1.3.0
|
32
|
+
prerelease: false
|
33
|
+
type: :runtime
|
34
|
+
name: open4
|
35
|
+
requirement: *id001
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
hash: 3
|
43
|
+
segments:
|
44
|
+
- 0
|
45
|
+
version: "0"
|
46
|
+
prerelease: false
|
47
|
+
type: :development
|
48
|
+
name: rake
|
49
|
+
requirement: *id002
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ~>
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
hash: 35
|
57
|
+
segments:
|
58
|
+
- 2
|
59
|
+
- 11
|
60
|
+
- 0
|
61
|
+
version: 2.11.0
|
62
|
+
prerelease: false
|
63
|
+
type: :development
|
64
|
+
name: rspec
|
65
|
+
requirement: *id003
|
66
|
+
- !ruby/object:Gem::Dependency
|
67
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - ~>
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
hash: 63
|
73
|
+
segments:
|
74
|
+
- 0
|
75
|
+
- 9
|
76
|
+
- 2
|
77
|
+
version: 0.9.2
|
78
|
+
prerelease: false
|
79
|
+
type: :development
|
80
|
+
name: rb-fsevent
|
81
|
+
requirement: *id004
|
82
|
+
- !ruby/object:Gem::Dependency
|
83
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
84
|
+
none: false
|
85
|
+
requirements:
|
86
|
+
- - ~>
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
hash: 3
|
89
|
+
segments:
|
90
|
+
- 1
|
91
|
+
- 5
|
92
|
+
- 0
|
93
|
+
version: 1.5.0
|
94
|
+
prerelease: false
|
95
|
+
type: :development
|
96
|
+
name: guard
|
97
|
+
requirement: *id005
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
version_requirements: &id006 !ruby/object:Gem::Requirement
|
100
|
+
none: false
|
101
|
+
requirements:
|
102
|
+
- - ~>
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
hash: 23
|
105
|
+
segments:
|
106
|
+
- 1
|
107
|
+
- 0
|
108
|
+
- 0
|
109
|
+
version: 1.0.0
|
110
|
+
prerelease: false
|
111
|
+
type: :development
|
112
|
+
name: guard-bundler
|
113
|
+
requirement: *id006
|
114
|
+
- !ruby/object:Gem::Dependency
|
115
|
+
version_requirements: &id007 !ruby/object:Gem::Requirement
|
116
|
+
none: false
|
117
|
+
requirements:
|
118
|
+
- - ~>
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
hash: 11
|
121
|
+
segments:
|
122
|
+
- 2
|
123
|
+
- 1
|
124
|
+
- 0
|
125
|
+
version: 2.1.0
|
126
|
+
prerelease: false
|
127
|
+
type: :development
|
128
|
+
name: guard-rspec
|
129
|
+
requirement: *id007
|
130
|
+
description: Backport of new Open3 methods from Ruby 1.9 to Ruby 1.8
|
131
|
+
email:
|
132
|
+
- chris@kindkid.com
|
133
|
+
executables: []
|
134
|
+
|
135
|
+
extensions: []
|
136
|
+
|
137
|
+
extra_rdoc_files: []
|
138
|
+
|
139
|
+
files:
|
140
|
+
- .gitignore
|
141
|
+
- .rvmrc
|
142
|
+
- BSDL
|
143
|
+
- Gemfile
|
144
|
+
- Guardfile
|
145
|
+
- LICENSE
|
146
|
+
- README.md
|
147
|
+
- Rakefile
|
148
|
+
- lib/open3_backport.rb
|
149
|
+
- lib/open3_backport/open3.rb
|
150
|
+
- lib/open3_backport/original_open3.rb
|
151
|
+
- lib/open3_backport/version.rb
|
152
|
+
- open3_backport.gemspec
|
153
|
+
- spec.opts
|
154
|
+
- spec/lib/open3_spec.rb
|
155
|
+
- spec/spec_helper.rb
|
156
|
+
- tasks/console.rake
|
157
|
+
- tasks/environment.rake
|
158
|
+
- tasks/spec.rake
|
159
|
+
homepage: https://github.com/kindkid/open3_backport
|
160
|
+
licenses: []
|
161
|
+
|
162
|
+
post_install_message:
|
163
|
+
rdoc_options: []
|
164
|
+
|
165
|
+
require_paths:
|
166
|
+
- lib
|
167
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
168
|
+
none: false
|
169
|
+
requirements:
|
170
|
+
- - ">="
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
hash: 3
|
173
|
+
segments:
|
174
|
+
- 0
|
175
|
+
version: "0"
|
176
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
177
|
+
none: false
|
178
|
+
requirements:
|
179
|
+
- - ">="
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
hash: 3
|
182
|
+
segments:
|
183
|
+
- 0
|
184
|
+
version: "0"
|
185
|
+
requirements: []
|
186
|
+
|
187
|
+
rubyforge_project:
|
188
|
+
rubygems_version: 1.8.24
|
189
|
+
signing_key:
|
190
|
+
specification_version: 3
|
191
|
+
summary: Backport of new Open3 methods from Ruby 1.9 to Ruby 1.8
|
192
|
+
test_files:
|
193
|
+
- spec/lib/open3_spec.rb
|
194
|
+
- spec/spec_helper.rb
|