rubysl-open3 1.0.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: be17e7d953578c551dd3166577d08fc16db550eb
4
+ data.tar.gz: 4d441dbd3cb04edef32a648990ee884caabcd9e6
5
+ SHA512:
6
+ metadata.gz: 80c18721011815e0bbeffe3832320fcf7e05a3003f85df37a48aeed063918e046e86c425ee4132e56350fbe0d6b72ba37824aa76bbe9b0945890f68464abe85a
7
+ data.tar.gz: 14e6a51ecd038dd1217bfd562b98fa80e75ac6d0aa49f0454af60b34f9ddc66d1b61d78e612ea547f36ce230520330094b021401a76b95e36b5f4f03df7b550a
@@ -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,8 @@
1
+ language: ruby
2
+ before_install:
3
+ - gem update --system
4
+ - gem --version
5
+ - gem install rubysl-bundler
6
+ script: bundle exec mspec spec
7
+ rvm:
8
+ - rbx-nightly-18mode
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rubysl-open3.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,25 @@
1
+ Copyright (c) 2013, Brian Shirai
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+
7
+ 1. Redistributions of source code must retain the above copyright notice, this
8
+ list of conditions and the following disclaimer.
9
+ 2. Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation
11
+ and/or other materials provided with the distribution.
12
+ 3. Neither the name of the library nor the names of its contributors may be
13
+ used to endorse or promote products derived from this software without
14
+ specific prior written permission.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19
+ DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY DIRECT,
20
+ INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21
+ BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
23
+ OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
25
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,29 @@
1
+ # Rubysl::Open3
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'rubysl-open3'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install rubysl-open3
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1 @@
1
+ require "rubysl/open3"
@@ -0,0 +1,2 @@
1
+ require "rubysl/open3/open3"
2
+ require "rubysl/open3/version"
@@ -0,0 +1,104 @@
1
+ #
2
+ # = open3.rb: Popen, but with stderr, too
3
+ #
4
+ # Author:: Yukihiro Matsumoto
5
+ # Documentation:: Konrad Meyer
6
+ #
7
+ # Open3 gives you access to stdin, stdout, and stderr when running other
8
+ # programs.
9
+ #
10
+
11
+ #
12
+ # Open3 grants you access to stdin, stdout, and stderr when running another
13
+ # program. Example:
14
+ #
15
+ # require "open3"
16
+ # include Open3
17
+ #
18
+ # stdin, stdout, stderr = popen3('nroff -man')
19
+ #
20
+ # Open3.popen3 can also take a block which will receive stdin, stdout and
21
+ # stderr as parameters. This ensures stdin, stdout and stderr are closed
22
+ # once the block exits. Example:
23
+ #
24
+ # require "open3"
25
+ #
26
+ # Open3.popen3('nroff -man') { |stdin, stdout, stderr| ... }
27
+ #
28
+
29
+ module Open3
30
+ #
31
+ # Open stdin, stdout, and stderr streams and start external executable.
32
+ # Non-block form:
33
+ #
34
+ # require 'open3'
35
+ #
36
+ # [stdin, stdout, stderr] = Open3.popen3(cmd)
37
+ #
38
+ # Block form:
39
+ #
40
+ # require 'open3'
41
+ #
42
+ # Open3.popen3(cmd) { |stdin, stdout, stderr| ... }
43
+ #
44
+ # The parameter +cmd+ is passed directly to Kernel#exec.
45
+ #
46
+ def popen3(*cmd)
47
+ pw = IO.pipe # pipe[0] for read, pipe[1] for write
48
+ pr = IO.pipe
49
+ pe = IO.pipe
50
+
51
+ pid = fork{
52
+ # child
53
+ fork {
54
+ # grandchild
55
+ pw[1].close
56
+ STDIN.reopen(pw[0])
57
+ pw[0].close
58
+
59
+ pr[0].close
60
+ STDOUT.reopen(pr[1])
61
+ pr[1].close
62
+
63
+ pe[0].close
64
+ STDERR.reopen(pe[1])
65
+ pe[1].close
66
+
67
+ exec(*cmd)
68
+ }
69
+ exit!(0)
70
+ }
71
+
72
+ pw[0].close
73
+ pr[1].close
74
+ pe[1].close
75
+
76
+ Process.waitpid(pid)
77
+
78
+ pi = [pw[1], pr[0], pe[0]]
79
+ pw[1].sync = true
80
+
81
+ if block_given?
82
+ begin
83
+ return yield(*pi)
84
+ ensure
85
+ pi.each { |p| p.close unless p.closed? }
86
+ end
87
+ end
88
+ pi
89
+ end
90
+ module_function :popen3
91
+ end
92
+
93
+ if $0 == __FILE__
94
+ a = Open3.popen3("nroff -man")
95
+ Thread.start do
96
+ while line = gets
97
+ a[0].print line
98
+ end
99
+ a[0].close
100
+ end
101
+ while line = a[1].gets
102
+ print ":", line
103
+ end
104
+ end
@@ -0,0 +1,5 @@
1
+ module RubySL
2
+ module Open3
3
+ VERSION = "1.0.0"
4
+ end
5
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ require './lib/rubysl/open3/version'
3
+
4
+ Gem::Specification.new do |spec|
5
+ spec.name = "rubysl-open3"
6
+ spec.version = RubySL::Open3::VERSION
7
+ spec.authors = ["Brian Shirai"]
8
+ spec.email = ["brixen@gmail.com"]
9
+ spec.description = %q{Ruby standard library open3.}
10
+ spec.summary = %q{Ruby standard library open3.}
11
+ spec.homepage = "https://github.com/rubysl/rubysl-open3"
12
+ spec.license = "BSD"
13
+
14
+ spec.files = `git ls-files`.split($/)
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.3"
20
+ spec.add_development_dependency "rake", "~> 10.0"
21
+ spec.add_development_dependency "mspec", "~> 1.5"
22
+ spec.add_development_dependency "rubysl-prettyprint", "~> 1.0"
23
+ end
@@ -0,0 +1,7 @@
1
+ require 'open3'
2
+
3
+ ruby_version_is "1.9" do
4
+ describe "Open3.capture2" do
5
+ it "needs to be reviewed for spec completeness"
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'open3'
2
+
3
+ ruby_version_is "1.9" do
4
+ describe "Open3.capture2e" do
5
+ it "needs to be reviewed for spec completeness"
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'open3'
2
+
3
+ ruby_version_is "1.9" do
4
+ describe "Open3.capture3" do
5
+ it "needs to be reviewed for spec completeness"
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'open3'
2
+
3
+ ruby_version_is "1.9" do
4
+ describe "Open3.pipeline_r" do
5
+ it "needs to be reviewed for spec completeness"
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'open3'
2
+
3
+ ruby_version_is "1.9" do
4
+ describe "Open3.pipeline_rw" do
5
+ it "needs to be reviewed for spec completeness"
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'open3'
2
+
3
+ ruby_version_is "1.9" do
4
+ describe "Open3.pipeline" do
5
+ it "needs to be reviewed for spec completeness"
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'open3'
2
+
3
+ ruby_version_is "1.9" do
4
+ describe "Open3.pipeline_start" do
5
+ it "needs to be reviewed for spec completeness"
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'open3'
2
+
3
+ ruby_version_is "1.9" do
4
+ describe "Open3.pipeline_w" do
5
+ it "needs to be reviewed for spec completeness"
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'open3'
2
+
3
+ ruby_version_is "1.9" do
4
+ describe "Open3.popen2" do
5
+ it "needs to be reviewed for spec completeness"
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'open3'
2
+
3
+ ruby_version_is "1.9" do
4
+ describe "Open3.popen2e" do
5
+ it "needs to be reviewed for spec completeness"
6
+ end
7
+ end
@@ -0,0 +1,28 @@
1
+ require 'open3'
2
+
3
+ describe "Open3.popen3" do
4
+ after :each do
5
+ [@in, @out, @err].each do |io|
6
+ io.close if io && !io.closed?
7
+ end
8
+ end
9
+
10
+ it "executes a process with a pipe to read stdout" do
11
+ @in, @out, @err = Open3.popen3(ruby_cmd("print :foo"))
12
+ @out.read.should == "foo"
13
+ end
14
+
15
+ it "executes a process with a pipe to read stderr" do
16
+ @in, @out, @err = Open3.popen3(ruby_cmd("STDERR.print :foo"))
17
+ @err.read.should == "foo"
18
+ end
19
+
20
+ it "executes a process with a pipe to write stdin" do
21
+ @in, @out, @err = Open3.popen3(ruby_cmd("print STDIN.read"))
22
+ @in.write("foo")
23
+ @in.close
24
+ @out.read.should == "foo"
25
+ end
26
+
27
+ it "needs to be reviewed for spec completeness"
28
+ end
metadata ADDED
@@ -0,0 +1,133 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rubysl-open3
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Brian Shirai
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-12-26 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.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: mspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.5'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.5'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubysl-prettyprint
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '1.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '1.0'
69
+ description: Ruby standard library open3.
70
+ email:
71
+ - brixen@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - .gitignore
77
+ - .travis.yml
78
+ - Gemfile
79
+ - LICENSE
80
+ - README.md
81
+ - Rakefile
82
+ - lib/open3.rb
83
+ - lib/rubysl/open3.rb
84
+ - lib/rubysl/open3/open3.rb
85
+ - lib/rubysl/open3/version.rb
86
+ - rubysl-open3.gemspec
87
+ - spec/capture2_spec.rb
88
+ - spec/capture2e_spec.rb
89
+ - spec/capture3_spec.rb
90
+ - spec/pipeline_r_spec.rb
91
+ - spec/pipeline_rw_spec.rb
92
+ - spec/pipeline_spec.rb
93
+ - spec/pipeline_start_spec.rb
94
+ - spec/pipeline_w_spec.rb
95
+ - spec/popen2_spec.rb
96
+ - spec/popen2e_spec.rb
97
+ - spec/popen3_spec.rb
98
+ homepage: https://github.com/rubysl/rubysl-open3
99
+ licenses:
100
+ - BSD
101
+ metadata: {}
102
+ post_install_message:
103
+ rdoc_options: []
104
+ require_paths:
105
+ - lib
106
+ required_ruby_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ required_rubygems_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - '>='
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ requirements: []
117
+ rubyforge_project:
118
+ rubygems_version: 2.0.7
119
+ signing_key:
120
+ specification_version: 4
121
+ summary: Ruby standard library open3.
122
+ test_files:
123
+ - spec/capture2_spec.rb
124
+ - spec/capture2e_spec.rb
125
+ - spec/capture3_spec.rb
126
+ - spec/pipeline_r_spec.rb
127
+ - spec/pipeline_rw_spec.rb
128
+ - spec/pipeline_spec.rb
129
+ - spec/pipeline_start_spec.rb
130
+ - spec/pipeline_w_spec.rb
131
+ - spec/popen2_spec.rb
132
+ - spec/popen2e_spec.rb
133
+ - spec/popen3_spec.rb