win32-pipe 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,46 +1,51 @@
1
- == 0.2.2 - 19-Mar-2012
2
- * Added test-unit 2.x as a development dependency.
3
- * Refactored some tests to use features of test-unit 2.x.
4
- * Refactored the Rakefile.
5
-
6
- == 0.2.1 - 9-Aug-2009
7
- * License changed to Artistic 2.0.
8
- * Test and example files renamed.
9
- * Gemspec updates, including license and description.
10
- * Updates to the Rakefile, including the removal of old C rake tasks, as
11
- well as the addition of tasks to run the example programs.
12
-
13
- == 0.2.0 - 28-May-2008
14
- * Now pure Ruby.
15
- * Major interface change. Pipe::Server.new and Pipe::Client.new replace the
16
- Pipe.new_server and Pipe.new_client methods, respectively.
17
- * An optional 3rd argument, the open mode, is now accepted which allows finer
18
- control over how pipes are created.
19
- * Several pipe mode and open mode constants were added.
20
- * The asynchronous pipe server actually works now.
21
- * Added the Pipe#name method.
22
- * Added the Pipe#asynchronous? method.
23
- * Added the Pipe#size method as an alias for Pipe#length.
24
- * Added a Rakefile with tasks for testing and installation.
25
- * Added a gemspec and uploaded a gem file to RubyForge.
26
- * Merged the doc files into the README and/or replaced them with inlined
27
- comments that are RDoc friendly.
28
-
29
- == 0.1.2 - 1-Mar-2005
30
- * Moved the 'examples' directory to the toplevel directory.
31
- * Made the CHANGES and README files rdoc friendly.
32
-
33
- == 0.1.1 - 25-Aug-2004
34
- * Added many more tests to the test suite.
35
- * Moved the example programs to doc/examples.
36
- * Fixed minor bugs in the asynchronous client and server test programs.
37
- * Removed the pipe.html file. You can generate your own html documentation
38
- using rd2 on the pipe.rd file.
39
-
40
- == 0.1.0 - 13-Feb-2004
41
- * Asynchronous support added (thanks Park Heesob)
42
- * Sample test programs added. See files under 'test'.
43
- * Documentation updates.
44
-
45
- == 0.0.1 - 20-Nov-2003
46
- * Initial release
1
+ == 0.3.0 - 8-Sep-2012
2
+ * Converted to FFI. Now works with JRuby, too.
3
+ * Native errors are now raised as SystemCallErrors.
4
+ * Test updates, gemspec dependency updates, etc.
5
+
6
+ == 0.2.2 - 19-Mar-2012
7
+ * Added test-unit 2.x as a development dependency.
8
+ * Refactored some tests to use features of test-unit 2.x.
9
+ * Refactored the Rakefile.
10
+
11
+ == 0.2.1 - 9-Aug-2009
12
+ * License changed to Artistic 2.0.
13
+ * Test and example files renamed.
14
+ * Gemspec updates, including license and description.
15
+ * Updates to the Rakefile, including the removal of old C rake tasks, as
16
+ well as the addition of tasks to run the example programs.
17
+
18
+ == 0.2.0 - 28-May-2008
19
+ * Now pure Ruby.
20
+ * Major interface change. Pipe::Server.new and Pipe::Client.new replace the
21
+ Pipe.new_server and Pipe.new_client methods, respectively.
22
+ * An optional 3rd argument, the open mode, is now accepted which allows finer
23
+ control over how pipes are created.
24
+ * Several pipe mode and open mode constants were added.
25
+ * The asynchronous pipe server actually works now.
26
+ * Added the Pipe#name method.
27
+ * Added the Pipe#asynchronous? method.
28
+ * Added the Pipe#size method as an alias for Pipe#length.
29
+ * Added a Rakefile with tasks for testing and installation.
30
+ * Added a gemspec and uploaded a gem file to RubyForge.
31
+ * Merged the doc files into the README and/or replaced them with inlined
32
+ comments that are RDoc friendly.
33
+
34
+ == 0.1.2 - 1-Mar-2005
35
+ * Moved the 'examples' directory to the toplevel directory.
36
+ * Made the CHANGES and README files rdoc friendly.
37
+
38
+ == 0.1.1 - 25-Aug-2004
39
+ * Added many more tests to the test suite.
40
+ * Moved the example programs to doc/examples.
41
+ * Fixed minor bugs in the asynchronous client and server test programs.
42
+ * Removed the pipe.html file. You can generate your own html documentation
43
+ using rd2 on the pipe.rd file.
44
+
45
+ == 0.1.0 - 13-Feb-2004
46
+ * Asynchronous support added (thanks Park Heesob)
47
+ * Sample test programs added. See files under 'test'.
48
+ * Documentation updates.
49
+
50
+ == 0.0.1 - 20-Nov-2003
51
+ * Initial release
data/MANIFEST CHANGED
@@ -1,15 +1,17 @@
1
- * MANIFEST
2
- * README
3
- * CHANGES
4
- * Rakefile
5
- * win32-pipe.gemspec
6
- * examples/example_server.rb
7
- * examples/example_server_async.rb
8
- * examples/example_client.rb
9
- * examples/example_client_async.rb
10
- * lib/win32/pipe.rb
11
- * lib/win32/pipe/client.rb
12
- * lib/win32/pipe/server.rb
13
- * test/test_win32_pipe.rb
14
- * test/test_win32_pipe_client.rb
15
- * test/test_win32_pipe_server.rb
1
+ * MANIFEST
2
+ * README
3
+ * CHANGES
4
+ * Rakefile
5
+ * win32-pipe.gemspec
6
+ * examples/example_server.rb
7
+ * examples/example_server_async.rb
8
+ * examples/example_client.rb
9
+ * examples/example_client_async.rb
10
+ * lib/win32/pipe.rb
11
+ * lib/win32/pipe/client.rb
12
+ * lib/win32/pipe/server.rb
13
+ * lib/win32/pipe/windows/constants.rb
14
+ * lib/win32/pipe/windows/functions.rb
15
+ * test/test_win32_pipe.rb
16
+ * test/test_win32_pipe_client.rb
17
+ * test/test_win32_pipe_server.rb
data/README CHANGED
@@ -1,55 +1,52 @@
1
- == Description
2
- A Ruby interface for named pipes on Windows.
3
-
4
- == Prerequisites
5
- * windows-pr 0.8.5 or later
6
-
7
- == Installation
8
- === Gem Installation
9
- gem install win32-pipe
10
- === Local
11
- rake install
12
-
13
- == Synopsis
14
- require 'win32/pipe'
15
- include Win32
16
-
17
- # In server.rb
18
- pipe_server = Pipe::Server.new("foo_pipe")
19
- pipe_server.connect
20
- data = pipe_server.read
21
- puts "Got #{data} from client"
22
- pipe_server.close
23
-
24
- # In client.rb (run from a different shell)
25
- pipe_client = Pipe::Client.new("foo_pipe")
26
- pipe_client.write("Hello World")
27
- pipe_client.close
28
-
29
- == What's a named pipe?
30
- A pipe with a name - literally. In practice, it will feel more like a cross
31
- between a socket and a pipe. At least, it does to me.
32
-
33
- == What good is it?
34
- My hope is that it can be used in certain circumstances where a fork might
35
- be desirable, but which is not possible on Windows. It could also be handy
36
- for the traditional "piping data to a server" usage. And if you come up
37
- with anything cool, please let us all know!
38
-
39
- == Future Plans
40
- Add transactions
41
-
42
- == License
43
- Artistic
44
-
45
- == Warranty
46
- This package is provided "as is" and without any express or
47
- implied warranties, including, without limitation, the implied
48
- warranties of merchantability and fitness for a particular purpose.
49
-
50
- == Copyright
51
- (C) 2003-2009, Daniel J. Berger, All Rights Reserved.
52
-
53
- == Authors
54
- Daniel Berger
55
- Park Heesob
1
+ == Description
2
+ A Ruby interface for named pipes on Windows.
3
+
4
+ == Prerequisites
5
+ ffi
6
+
7
+ == Installation
8
+ gem install win32-pipe
9
+
10
+ == Synopsis
11
+ require 'win32/pipe'
12
+ include Win32
13
+
14
+ # In server.rb
15
+ pipe_server = Pipe::Server.new("foo_pipe")
16
+ pipe_server.connect
17
+ data = pipe_server.read
18
+ puts "Got #{data} from client"
19
+ pipe_server.close
20
+
21
+ # In client.rb (run from a different shell)
22
+ pipe_client = Pipe::Client.new("foo_pipe")
23
+ pipe_client.write("Hello World")
24
+ pipe_client.close
25
+
26
+ == What's a named pipe?
27
+ A pipe with a name - literally. In practice, it will feel more like a cross
28
+ between a socket and a pipe. At least, it does to me.
29
+
30
+ == What good is it?
31
+ My hope is that it can be used in certain circumstances where a fork might
32
+ be desirable, but which is not possible on Windows. It could also be handy
33
+ for the traditional "piping data to a server" usage. And if you come up
34
+ with anything cool, please let us all know!
35
+
36
+ == Future Plans
37
+ Add transactions
38
+
39
+ == License
40
+ Artistic 2.0
41
+
42
+ == Warranty
43
+ This package is provided "as is" and without any express or
44
+ implied warranties, including, without limitation, the implied
45
+ warranties of merchantability and fitness for a particular purpose.
46
+
47
+ == Copyright
48
+ (C) 2003-2012, Daniel J. Berger, All Rights Reserved.
49
+
50
+ == Authors
51
+ Daniel Berger
52
+ Park Heesob
data/Rakefile CHANGED
@@ -1,48 +1,68 @@
1
- require 'rake'
2
- require 'rake/clean'
3
- require 'rake/testtask'
4
-
5
- CLEAN.include("**/*.gem")
6
-
7
- namespace :gem do
8
- desc 'Create the win32-pipe gem'
9
- task :create => [:clean] do
10
- spec = eval(IO.read('win32-pipe.gemspec'))
11
- Gem::Builder.new(spec).build
12
- end
13
-
14
- desc 'Install the win32-pipe gem'
15
- task :install => [:create] do
16
- file = Dir['*.gem'].first
17
- sh "gem install #{file}"
18
- end
19
- end
20
-
21
- namespace :example do
22
- desc 'Run the asynchronous client example program'
23
- task :async_client do
24
- ruby '-Ilib examples/example_client_async.rb'
25
- end
26
-
27
- desc 'Run the client example program'
28
- task :client do
29
- ruby '-Ilib examples/example_client.rb'
30
- end
31
-
32
- desc 'Run the asynchronous server example program'
33
- task :async_server do
34
- ruby '-Ilib examples/example_server_async.rb'
35
- end
36
-
37
- desc 'Run the server example program'
38
- task :server do
39
- ruby '-Ilib examples/example_server.rb'
40
- end
41
- end
42
-
43
- Rake::TestTask.new do |test|
44
- test.warning = true
45
- test.verbose = true
46
- end
47
-
48
- task :default => :test
1
+ require 'rake'
2
+ require 'rake/clean'
3
+ require 'rake/testtask'
4
+
5
+ CLEAN.include("**/*.gem")
6
+
7
+ namespace :gem do
8
+ desc 'Create the win32-pipe gem'
9
+ task :create => [:clean] do
10
+ spec = eval(IO.read('win32-pipe.gemspec'))
11
+ Gem::Builder.new(spec).build
12
+ end
13
+
14
+ desc 'Install the win32-pipe gem'
15
+ task :install => [:create] do
16
+ file = Dir['*.gem'].first
17
+ sh "gem install #{file}"
18
+ end
19
+ end
20
+
21
+ namespace :example do
22
+ desc 'Run the asynchronous client example program'
23
+ task :async_client do
24
+ ruby '-Ilib examples/example_client_async.rb'
25
+ end
26
+
27
+ desc 'Run the client example program'
28
+ task :client do
29
+ ruby '-Ilib examples/example_client.rb'
30
+ end
31
+
32
+ desc 'Run the asynchronous server example program'
33
+ task :async_server do
34
+ ruby '-Ilib examples/example_server_async.rb'
35
+ end
36
+
37
+ desc 'Run the server example program'
38
+ task :server do
39
+ ruby '-Ilib examples/example_server.rb'
40
+ end
41
+ end
42
+
43
+ namespace :test do
44
+ Rake::TestTask.new(:base) do |test|
45
+ test.warning = true
46
+ test.verbose = true
47
+ test.test_files = FileList['test\test_win32_pipe.rb']
48
+ end
49
+
50
+ Rake::TestTask.new(:client) do |test|
51
+ test.warning = true
52
+ test.verbose = true
53
+ test.test_files = FileList['test\test_win32_pipe_client.rb']
54
+ end
55
+
56
+ Rake::TestTask.new(:server) do |test|
57
+ test.warning = true
58
+ test.verbose = true
59
+ test.test_files = FileList['test\test_win32_pipe_server.rb']
60
+ end
61
+
62
+ Rake::TestTask.new(:all) do |test|
63
+ test.warning = true
64
+ test.verbose = true
65
+ end
66
+ end
67
+
68
+ task :default => 'test:all'
@@ -1,30 +1,30 @@
1
- #########################################################################
2
- # example_client.rb
3
- #
4
- # Simple client test. Be sure to start the server first in a separate
5
- # terminal. You can run this example via the 'rake example_client' task.
6
- #
7
- # Modify this code as you see fit.
8
- #########################################################################
9
- require 'win32/pipe'
10
- include Win32
11
-
12
- Thread.new { loop { sleep 0.01 } } # Allow Ctrl-C
13
-
14
- puts "VERSION: " + Pipe::VERSION
15
-
16
- # Block form
17
- Pipe::Client.new('foo') do |pipe|
18
- puts "Connected..."
19
- pipe.write("Ruby rocks!")
20
- data = pipe.read
21
- puts "Got [#{data}] back from server"
22
- end
23
-
24
- # Non-block form
25
- #pclient = Pipe::Client.new('foo')
26
- #puts "Connected..."
27
- #pclient.write("Ruby rocks!")
28
- #data = pclient.read
29
- #puts "Got [#{data}] back from server"
1
+ #########################################################################
2
+ # example_client.rb
3
+ #
4
+ # Simple client test. Be sure to start the server first in a separate
5
+ # terminal. You can run this example via the 'rake example_client' task.
6
+ #
7
+ # Modify this code as you see fit.
8
+ #########################################################################
9
+ require 'win32/pipe'
10
+ include Win32
11
+
12
+ Thread.new { loop { sleep 0.01 } } # Allow Ctrl-C
13
+
14
+ puts "VERSION: " + Pipe::VERSION
15
+
16
+ # Block form
17
+ Pipe::Client.new('foo') do |pipe|
18
+ puts "Connected..."
19
+ pipe.write("Ruby rocks!")
20
+ data = pipe.read
21
+ puts "Got [#{data}] back from server"
22
+ end
23
+
24
+ # Non-block form
25
+ #pclient = Pipe::Client.new('foo')
26
+ #puts "Connected..."
27
+ #pclient.write("Ruby rocks!")
28
+ #data = pclient.read
29
+ #puts "Got [#{data}] back from server"
30
30
  #pclient.close
@@ -1,82 +1,82 @@
1
- #########################################################################
2
- # example_client_async.rb
3
- #
4
- # Simple client test. Be sure to start the server first in a separate
5
- # terminal. You can run this example via the 'rake example_async_client'
6
- # task.
7
- #########################################################################
8
- require 'win32/pipe'
9
- include Win32
10
-
11
- puts "VERSION: " + Pipe::VERSION
12
-
13
- Thread.new { loop { sleep 0.01 } } # Allow Ctrl-C
14
-
15
- CONNECTING_STATE = 0
16
- READING_STATE = 1
17
- WRITING_STATE = 2
18
-
19
- class MyPipe < Pipe::Client
20
- def read_complete
21
- puts "read_complete"
22
- puts "Got [#{buffer}] back from server"
23
- @state = WRITING_STATE
24
- end
25
-
26
- def write_complete
27
- puts "write_complete"
28
- @state = READING_STATE
29
- end
30
-
31
- def mainloop
32
- @state = WRITING_STATE
33
- while true
34
- if wait(1) # wait for 1 second
35
- if pending? # IO is pending
36
- case @state
37
- when READING_STATE
38
- if transferred == 0
39
- reconnect
40
- break
41
- end
42
- read_complete
43
- break
44
- when WRITING_STATE
45
- if transferred != length
46
- reconnect
47
- break
48
- end
49
- write_complete
50
- end
51
- end
52
-
53
- case @state
54
- when READING_STATE
55
- if read
56
- if not pending?
57
- read_complete
58
- break
59
- end
60
- end
61
- when WRITING_STATE
62
- if write("Ruby rocks!")
63
- if not pending?
64
- write_complete
65
- end
66
- end
67
- end
68
- end
69
-
70
- sleep(1)
71
- puts "pipe client is running"
72
- end
73
- end
74
- end
75
-
76
- flags = Pipe::DEFAULT_OPEN_MODE | Pipe::OVERLAPPED
77
-
78
- MyPipe.new('foo', nil, flags) do |client|
79
- puts "Connected..."
80
- client.mainloop
81
- end
82
-
1
+ #########################################################################
2
+ # example_client_async.rb
3
+ #
4
+ # Simple client test. Be sure to start the server first in a separate
5
+ # terminal. You can run this example via the 'rake example_async_client'
6
+ # task.
7
+ #########################################################################
8
+ require 'win32/pipe'
9
+ include Win32
10
+
11
+ puts "VERSION: " + Pipe::VERSION
12
+
13
+ Thread.new { loop { sleep 0.01 } } # Allow Ctrl-C
14
+
15
+ CONNECTING_STATE = 0
16
+ READING_STATE = 1
17
+ WRITING_STATE = 2
18
+
19
+ class MyPipe < Pipe::Client
20
+ def read_complete
21
+ puts "read_complete"
22
+ puts "Got [#{buffer}] back from server"
23
+ @state = WRITING_STATE
24
+ end
25
+
26
+ def write_complete
27
+ puts "write_complete"
28
+ @state = READING_STATE
29
+ end
30
+
31
+ def mainloop
32
+ @state = WRITING_STATE
33
+ while true
34
+ if wait(1) # wait for 1 second
35
+ if pending? # IO is pending
36
+ case @state
37
+ when READING_STATE
38
+ if transferred == 0
39
+ reconnect
40
+ break
41
+ end
42
+ read_complete
43
+ break
44
+ when WRITING_STATE
45
+ if transferred != length
46
+ reconnect
47
+ break
48
+ end
49
+ write_complete
50
+ end
51
+ end
52
+
53
+ case @state
54
+ when READING_STATE
55
+ if read
56
+ if not pending?
57
+ read_complete
58
+ break
59
+ end
60
+ end
61
+ when WRITING_STATE
62
+ if write("Ruby rocks!")
63
+ if not pending?
64
+ write_complete
65
+ end
66
+ end
67
+ end
68
+ end
69
+
70
+ sleep(1)
71
+ puts "pipe client is running"
72
+ end
73
+ end
74
+ end
75
+
76
+ flags = Pipe::DEFAULT_OPEN_MODE | Pipe::OVERLAPPED
77
+
78
+ MyPipe.new('foo', nil, flags) do |client|
79
+ puts "Connected..."
80
+ client.mainloop
81
+ end
82
+