POpen4-mingw 0.1.6-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES ADDED
@@ -0,0 +1,19 @@
1
+ == 0.1.6 - 06-Feb-2011
2
+ * Add compatibility with :mingw (by mordaroso)
3
+
4
+ == 0.1.5 - 17-Nov-2009
5
+ * Explicit open4 version dependency
6
+
7
+ == 0.1.4 - 17-Nov-2009
8
+ * Platform specific dependency
9
+
10
+ == 0.1.3 - 20-Oct-2009
11
+ * Use of win32-open3 gem
12
+
13
+ == 0.1.1 - 12-Jun-2006
14
+ * Fixed Bug 4742
15
+ - open3.so Open4 fails to return Process::Status on Windows 2000.
16
+ - Thanks to Park Heesob!
17
+
18
+ == 0.1.0 - 10-Jun-2006
19
+ * Initial release
data/LICENSE ADDED
@@ -0,0 +1,64 @@
1
+ == POpen4 License
2
+
3
+ POpen4 is copyright John-Mason P. Shackelford (john-mason@shackelford.org)
4
+ and made available under the terms of Ruby's license, included below for your
5
+ convenience.
6
+
7
+ == Ruby's License
8
+
9
+ Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.jp>.
10
+ You can redistribute it and/or modify it under either the terms of the GPL
11
+ (see the file GPL), or the conditions below:
12
+
13
+ 1. You may make and give away verbatim copies of the source form of the
14
+ software without restriction, provided that you duplicate all of the
15
+ original copyright notices and associated disclaimers.
16
+
17
+ 2. You may modify your copy of the software in any way, provided that
18
+ you do at least ONE of the following:
19
+
20
+ a) place your modifications in the Public Domain or otherwise
21
+ make them Freely Available, such as by posting said
22
+ modifications to Usenet or an equivalent medium, or by allowing
23
+ the author to include your modifications in the software.
24
+
25
+ b) use the modified software only within your corporation or
26
+ organization.
27
+
28
+ c) give non-standard binaries non-standard names, with
29
+ instructions on where to get the original software distribution.
30
+
31
+ d) make other distribution arrangements with the author.
32
+
33
+ 3. You may distribute the software in object code or binary form,
34
+ provided that you do at least ONE of the following:
35
+
36
+ a) distribute the binaries and library files of the software,
37
+ together with instructions (in the manual page or equivalent)
38
+ on where to get the original distribution.
39
+
40
+ b) accompany the distribution with the machine-readable source of
41
+ the software.
42
+
43
+ c) give non-standard binaries non-standard names, with
44
+ instructions on where to get the original software distribution.
45
+
46
+ d) make other distribution arrangements with the author.
47
+
48
+ 4. You may modify and include the part of the software into any other
49
+ software (possibly commercial). But some files in the distribution
50
+ are not written by the author, so that they are not under these terms.
51
+
52
+ For the list of those files and their copying conditions, see the
53
+ file LEGAL.
54
+
55
+ 5. The scripts and library files supplied as input to or produced as
56
+ output from the software do not automatically fall under the
57
+ copyright of the software, but belong to whomever generated them,
58
+ and may be sold commercially, and may be aggregated with this
59
+ software.
60
+
61
+ 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
62
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
63
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
64
+ PURPOSE.
@@ -0,0 +1,50 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "POpen4-mingw"
8
+ s.version = "0.1.6"
9
+ s.platform = "x86-mingw32"
10
+
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.authors = ["John-Mason P. Shackelford"]
13
+ s.date = "2012-02-06"
14
+ s.description = ""
15
+ s.email = "john-mason@shackelford.org"
16
+ s.extra_rdoc_files = [
17
+ "LICENSE",
18
+ "README.rdoc"
19
+ ]
20
+ s.files = [
21
+ "CHANGES",
22
+ "LICENSE",
23
+ "POpen4-mingw.gemspec",
24
+ "README.rdoc",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "lib/popen4.rb",
28
+ "tests/popen4_test.rb"
29
+ ]
30
+ s.homepage = "http://github.com/pka/popen4"
31
+ s.require_paths = ["lib"]
32
+ s.rubygems_version = "1.8.15"
33
+ s.summary = "Open4 cross-platform"
34
+
35
+ if s.respond_to? :specification_version then
36
+ s.specification_version = 3
37
+
38
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
39
+ s.add_runtime_dependency(%q<Platform>, [">= 0.4.0"])
40
+ s.add_runtime_dependency(%q<win32-open3>, [">= 0"])
41
+ else
42
+ s.add_dependency(%q<Platform>, [">= 0.4.0"])
43
+ s.add_dependency(%q<win32-open3>, [">= 0"])
44
+ end
45
+ else
46
+ s.add_dependency(%q<Platform>, [">= 0.4.0"])
47
+ s.add_dependency(%q<win32-open3>, [">= 0"])
48
+ end
49
+ end
50
+
@@ -0,0 +1,34 @@
1
+ = POpen4
2
+ This is a repackaged version of John-Mason P. Shackelfords {POpen4}[http://popen4.rubyforge.org/]
3
+ gem without native libraries.
4
+
5
+ == About this fork
6
+ This fork adds the compatibility with the MINGW compiled ruby for windows. MINGW is the compilation method used by Ruby Installer (http://rubyinstaller.org/).
7
+
8
+ == Description
9
+ POpen4 provides the Rubyist a single API across platforms for executing a
10
+ command in a child process with handles on stdout, stderr, stdin streams as well
11
+ as access to the process ID and exit status. It does very little other than to
12
+ provide an easy way to use either Ara Howard's Open4 library or the win32-popen3
13
+ library by Park Heesob and Daniel Berger depending on your platform and without
14
+ having to code around the slight differences in their APIs.
15
+
16
+ == Notes
17
+ Rather than adopting either Open4's API or win32-open3's (they differ in several
18
+ respects, but most obviously in the order in which streams are passed to the
19
+ block) I am proposing a third API for couple of reasons. First, Open4 passes the
20
+ PID first and win32-open3 passes stdin neither of which seem to me to be the
21
+ streams we are most likely to use when we don't need all four. POpen4 passes
22
+ stdout and stderr first so that when the others are not required we can omit
23
+ them from the block. Second, I thought it best to break everybody's code rather
24
+ than to be a drop in replacement on one platform and be a surprise on another.
25
+ No surprises--it's a new API on either platform.
26
+
27
+ == Installation
28
+
29
+ $ gem install POpen4 --source http://gemcutter.org
30
+
31
+ == Acknowledgements
32
+ Ara Howard, Park Heesob, Daniel Berger and others have done the real work. Many
33
+ thanks to them for the many hours they have poured into sharing their work with
34
+ the Ruby community at large.
@@ -0,0 +1,70 @@
1
+ require 'rubygems'
2
+ require 'rubygems/user_interaction'
3
+ require 'rake/testtask'
4
+ require 'rake/rdoctask'
5
+
6
+ task :default => [:test]
7
+
8
+ # Test --------------------------------------------------------------------
9
+
10
+ desc "Run the unit tests"
11
+ task :test do
12
+ Rake::TestTask.new("test") do |t|
13
+ t.libs << "tests"
14
+ t.pattern = 'tests/*_test.rb'
15
+ t.verbose = true
16
+ end
17
+ end
18
+
19
+ # Documentation -----------------------------------------------------------
20
+ desc "Generate RDoc"
21
+ rd = Rake::RDocTask.new("rdoc") { |rdoc|
22
+ rdoc.rdoc_dir = 'rdoc'
23
+ rdoc.title = "POpen4 -- Open4 cross-platform"
24
+ rdoc.options << '--main' << 'README'
25
+ rdoc.rdoc_files.include('README', 'LICENSE', 'CHANGES')
26
+ rdoc.rdoc_files.include('lib/**/*.rb', 'doc/**/*.rdoc')
27
+ }
28
+
29
+ # GEM Packaging -----------------------------------------------------------
30
+
31
+ begin
32
+ require 'jeweler'
33
+ # Windows MSWIN
34
+ # Jeweler::Tasks.new do |gemspec|
35
+ # gemspec.name = "POpen4"
36
+ # gemspec.summary = "Open4 cross-platform"
37
+ # gemspec.description = ""
38
+ # gemspec.email = "john-mason@shackelford.org"
39
+ # gemspec.homepage = "http://github.com/pka/popen4"
40
+ # gemspec.authors = ["John-Mason P. Shackelford"]
41
+ # gemspec.add_dependency("Platform", ">= 0.4.0")
42
+ # gemspec.platform = 'x86-mswin32'
43
+ # gemspec.add_dependency("win32-open3")
44
+ # end
45
+ # Windows MINWG
46
+ Jeweler::Tasks.new do |gemspec|
47
+ gemspec.name = "POpen4-mingw"
48
+ gemspec.summary = "Open4 cross-platform"
49
+ gemspec.description = ""
50
+ gemspec.email = "john-mason@shackelford.org"
51
+ gemspec.homepage = "http://github.com/pka/popen4"
52
+ gemspec.authors = ["John-Mason P. Shackelford"]
53
+ gemspec.add_dependency("Platform", ">= 0.4.0")
54
+ gemspec.platform = 'x86-mingw32'
55
+ gemspec.add_dependency("win32-open3")
56
+ end
57
+ # Unix
58
+ # Jeweler::Tasks.new do |gemspec|
59
+ # gemspec.name = "POpen4"
60
+ # gemspec.summary = "Open4 cross-platform"
61
+ # gemspec.description = ""
62
+ # gemspec.email = "john-mason@shackelford.org"
63
+ # gemspec.homepage = "http://github.com/pka/popen4"
64
+ # gemspec.authors = ["John-Mason P. Shackelford"]
65
+ # gemspec.add_dependency("Platform", ">= 0.4.0")
66
+ # gemspec.add_dependency("open4", ">= 0.4.0")
67
+ # end
68
+ rescue LoadError
69
+ puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
70
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.6
@@ -0,0 +1,95 @@
1
+ require 'rubygems'
2
+ require 'platform'
3
+
4
+ case Platform::OS
5
+
6
+ # win32/popen4 yields stdin, stdout, stderr and pid, respectively
7
+ when :win32, :mingw
8
+
9
+ require 'win32/open3'
10
+
11
+ # POpen4 provides the Rubyist a single API across platforms for executing a
12
+ # command in a child process with handles on stdout, stderr, and stdin streams
13
+ # as well as access to the process ID and exit status.
14
+ #
15
+ # Consider the following example (borrowed from Open4):
16
+ #
17
+ # require 'rubygems'
18
+ # require 'popen4'
19
+ #
20
+ # status =
21
+ # POpen4::popen4("cmd") do |stdout, stderr, stdin, pid|
22
+ # stdin.puts "echo hello world!"
23
+ # stdin.puts "echo ERROR! 1>&2"
24
+ # stdin.puts "exit"
25
+ # stdin.close
26
+ #
27
+ # puts "pid : #{ pid }"
28
+ # puts "stdout : #{ stdout.read.strip }"
29
+ # puts "stderr : #{ stderr.read.strip }"
30
+ # end
31
+ #
32
+ # puts "status : #{ status.inspect }"
33
+ # puts "exitstatus : #{ status.exitstatus }"
34
+ #
35
+ module POpen4
36
+ # Starts a new process and hands IO objects representing the subprocess
37
+ # stdout, stderr, stdin streams and the pid (respectively) to the block
38
+ # supplied. If the command could not be started, return nil.
39
+ #
40
+ # The mode argument may be set to t[ext] or b[inary] and is used only on
41
+ # Windows platforms.
42
+ #
43
+ # The stdin stream and/or pid may be omitted from the block parameter list
44
+ # if they are not required.
45
+ def self.popen4(command, mode = "t") # :yields: stdout, stderr, stdin, pid
46
+
47
+ err_output = nil
48
+ Open4.popen4(command, mode) do |stdin,stdout,stderr,pid|
49
+ yield stdout, stderr, stdin, pid
50
+
51
+ # On windows we will always get an exit status of 3 unless
52
+ # we read to the end of the streams so we do this on all platforms
53
+ # so that our behavior is always the same.
54
+ stdout.read unless stdout.closed? or stdout.eof?
55
+
56
+ # On windows executing a non existent command does not raise an error
57
+ # (as in unix) so on unix we return nil instead of a status object and
58
+ # on windows we try to determine if we couldn't start the command and
59
+ # return nil instead of the Process::Status object.
60
+ unless stderr.closed?
61
+ stderr.rewind
62
+ err_output = stderr.read
63
+ end
64
+ end
65
+
66
+ return $?
67
+ end # def
68
+ end # module
69
+
70
+
71
+ else # unix popen4 yields pid, stdin, stdout and stderr, respectively
72
+ # :enddoc:
73
+ require 'open4'
74
+ module POpen4
75
+ def self.popen4(command, mode = "t")
76
+ begin
77
+ return status = Open4.popen4(command) do |pid,stdin,stdout,stderr|
78
+ yield stdout, stderr, stdin, pid
79
+ # On windows we will always get an exit status of 3 unless
80
+ # we read to the end of the streams so we do this on all platforms
81
+ # so that our behavior is always the same.
82
+ stdout.read unless stdout.closed? or stdout.eof?
83
+ stderr.read unless stderr.closed? or stderr.eof?
84
+ end
85
+ rescue Errno::ENOENT => e
86
+ # On windows executing a non existent command does not raise an error
87
+ # (as in unix) so on unix we return nil instead of a status object and
88
+ # on windows we try to determine if we couldn't start the command and
89
+ # return nil instead of the Process::Status object.
90
+ return nil
91
+ end
92
+ end #def
93
+ end #module
94
+
95
+ end
@@ -0,0 +1,78 @@
1
+ $: << File.join( File.dirname( __FILE__ ), '../lib/')
2
+
3
+ require 'test/unit'
4
+ require 'popen4'
5
+
6
+ require 'platform'
7
+
8
+ class POpen4Test < Test::Unit::TestCase
9
+
10
+ case Platform::OS
11
+ when :win32, :mingw
12
+ CMD_SHELL = "cmd"
13
+ CMD_STDERR = "ruby -e \"$stderr.puts 'ruby'\""
14
+ CMD_EXIT = "ruby -e \"$stdout.puts 'ruby'; exit 1\""
15
+ else # unix
16
+ CMD_SHELL = "sh"
17
+ CMD_STDERR = "ruby -e '$stderr.puts \"ruby\"'"
18
+ CMD_EXIT = "ruby -e '$stdout.puts \"ruby\"; exit 1'"
19
+ end
20
+ CMD_GOOD = "ruby --version"
21
+ CMD_BAD = CMD_GOOD.reverse
22
+
23
+ def test_popen4_block_good_cmd
24
+ assert_nothing_raised do
25
+ POpen4.popen4(CMD_GOOD){ |pout, perr, pin, pid| }
26
+ end
27
+ end
28
+
29
+ def test_popen4_block_bad_cmd
30
+ status = nil
31
+ assert_nothing_raised do
32
+ status = POpen4.popen4(CMD_BAD){ |pout, perr, pin, pid| }
33
+ end
34
+ assert_nil status
35
+ end
36
+
37
+ def test_popen4_block_status
38
+ status = POpen4.popen4(CMD_GOOD) do |pout, perr, pin, pid|
39
+ assert_kind_of(IO, pin)
40
+ assert_kind_of(IO, pout)
41
+ assert_kind_of(IO, perr)
42
+ assert_kind_of(Fixnum, pid)
43
+ end
44
+ assert_kind_of Process::Status, status
45
+ end
46
+
47
+ def test_open4_block_read_stdout
48
+ status = POpen4.popen4(CMD_GOOD) do |pout, perr|
49
+ assert_match(/ruby \d\.\d\.\d/, pout.gets)
50
+ end
51
+ assert_equal 0, status.exitstatus
52
+ end
53
+
54
+ def test_open4_block_read_stderr
55
+ status = POpen4.popen4(CMD_STDERR) do |pout, perr|
56
+ assert_match "ruby", perr.gets
57
+ end
58
+ assert_equal 0, status.exitstatus
59
+ end
60
+
61
+ def test_open4_block_exitstatus
62
+ status = POpen4.popen4(CMD_EXIT) do |pout, perr|
63
+ assert_match "ruby", pout.gets
64
+ end
65
+ assert_kind_of Process::Status, status
66
+ assert_equal 1, status.exitstatus
67
+ end
68
+
69
+ def test_open4_block_write_stdin
70
+ status = POpen4.popen4(CMD_SHELL) do |pout, perr, pin|
71
+ pin.puts CMD_GOOD
72
+ pin.puts "exit"
73
+ pin.close
74
+ assert_match(/ruby \d\.\d\.\d/, pout.readlines.join)
75
+ end
76
+ assert_equal 0, status.exitstatus
77
+ end
78
+ end
metadata ADDED
@@ -0,0 +1,102 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: POpen4-mingw
3
+ version: !ruby/object:Gem::Version
4
+ hash: 23
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 6
10
+ version: 0.1.6
11
+ platform: x86-mingw32
12
+ authors:
13
+ - John-Mason P. Shackelford
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2012-02-06 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: Platform
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 15
29
+ segments:
30
+ - 0
31
+ - 4
32
+ - 0
33
+ version: 0.4.0
34
+ type: :runtime
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: win32-open3
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ hash: 3
45
+ segments:
46
+ - 0
47
+ version: "0"
48
+ type: :runtime
49
+ version_requirements: *id002
50
+ description: ""
51
+ email: john-mason@shackelford.org
52
+ executables: []
53
+
54
+ extensions: []
55
+
56
+ extra_rdoc_files:
57
+ - LICENSE
58
+ - README.rdoc
59
+ files:
60
+ - CHANGES
61
+ - LICENSE
62
+ - POpen4-mingw.gemspec
63
+ - README.rdoc
64
+ - Rakefile
65
+ - VERSION
66
+ - lib/popen4.rb
67
+ - tests/popen4_test.rb
68
+ homepage: http://github.com/pka/popen4
69
+ licenses: []
70
+
71
+ post_install_message:
72
+ rdoc_options: []
73
+
74
+ require_paths:
75
+ - lib
76
+ required_ruby_version: !ruby/object:Gem::Requirement
77
+ none: false
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ hash: 3
82
+ segments:
83
+ - 0
84
+ version: "0"
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ hash: 3
91
+ segments:
92
+ - 0
93
+ version: "0"
94
+ requirements: []
95
+
96
+ rubyforge_project:
97
+ rubygems_version: 1.8.15
98
+ signing_key:
99
+ specification_version: 3
100
+ summary: Open4 cross-platform
101
+ test_files: []
102
+