win32-pipe 0.2.1 → 0.2.2
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/CHANGES +5 -0
- data/Rakefile +36 -36
- data/lib/win32/pipe.rb +1 -1
- data/lib/win32/pipe/client.rb +56 -40
- data/test/test_win32_pipe.rb +105 -101
- data/test/test_win32_pipe_client.rb +49 -17
- data/test/test_win32_pipe_server.rb +1 -1
- data/win32-pipe.gemspec +19 -22
- metadata +48 -40
    
        data/CHANGES
    CHANGED
    
    
    
        data/Rakefile
    CHANGED
    
    | @@ -1,48 +1,48 @@ | |
| 1 1 | 
             
            require 'rake'
         | 
| 2 2 | 
             
            require 'rake/clean'
         | 
| 3 3 | 
             
            require 'rake/testtask'
         | 
| 4 | 
            -
            require 'rbconfig'
         | 
| 5 | 
            -
            include Config
         | 
| 6 4 |  | 
| 7 | 
            -
             | 
| 8 | 
            -
            task :install do
         | 
| 9 | 
            -
               sitelibdir = CONFIG['sitelibdir']
         | 
| 5 | 
            +
            CLEAN.include("**/*.gem")
         | 
| 10 6 |  | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 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 13 |  | 
| 14 | 
            -
             | 
| 15 | 
            -
             | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 18 | 
            -
             | 
| 19 | 
            -
             | 
| 20 | 
            -
               FileUtils.cp(pipe_file, pipe_installdir, :verbose => true)   
         | 
| 21 | 
            -
               FileUtils.cp(client_file, sub_installdir, :verbose => true)   
         | 
| 22 | 
            -
               FileUtils.cp(server_file, sub_installdir, :verbose => true)   
         | 
| 23 | 
            -
            end
         | 
| 24 | 
            -
             | 
| 25 | 
            -
            desc 'Run the asynchronous client example program'
         | 
| 26 | 
            -
            task :example_async_client do
         | 
| 27 | 
            -
               ruby '-Ilib examples/example_client_async.rb'
         | 
| 28 | 
            -
            end
         | 
| 29 | 
            -
             | 
| 30 | 
            -
            desc 'Run the client example program'
         | 
| 31 | 
            -
            task :example_client do
         | 
| 32 | 
            -
               ruby '-Ilib examples/example_client.rb'
         | 
| 33 | 
            -
            end
         | 
| 34 | 
            -
             | 
| 35 | 
            -
            desc 'Run the asynchronous server example program'
         | 
| 36 | 
            -
            task :example_async_server do
         | 
| 37 | 
            -
               ruby '-Ilib examples/example_server_async.rb'
         | 
| 14 | 
            +
              desc 'Install the win32-pipe gem'
         | 
| 15 | 
            +
              task :install => [:create] do
         | 
| 16 | 
            +
                file = Dir['*.gem'].first
         | 
| 17 | 
            +
                sh "gem install #{file}"
         | 
| 18 | 
            +
              end
         | 
| 38 19 | 
             
            end
         | 
| 39 20 |  | 
| 40 | 
            -
             | 
| 41 | 
            -
             | 
| 42 | 
            -
             | 
| 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
         | 
| 43 41 | 
             
            end
         | 
| 44 42 |  | 
| 45 43 | 
             
            Rake::TestTask.new do |test|
         | 
| 46 | 
            -
             | 
| 47 | 
            -
             | 
| 44 | 
            +
              test.warning = true
         | 
| 45 | 
            +
              test.verbose = true
         | 
| 48 46 | 
             
            end
         | 
| 47 | 
            +
             | 
| 48 | 
            +
            task :default => :test
         | 
    
        data/lib/win32/pipe.rb
    CHANGED
    
    
    
        data/lib/win32/pipe/client.rb
    CHANGED
    
    | @@ -1,49 +1,65 @@ | |
| 1 1 | 
             
            # The Win32 module serves as a namespace only
         | 
| 2 2 | 
             
            module Win32
         | 
| 3 | 
            -
             | 
| 4 | 
            -
             | 
| 5 | 
            -
             | 
| 6 | 
            -
             | 
| 7 | 
            -
             | 
| 8 | 
            -
             | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 15 | 
            -
             | 
| 3 | 
            +
             | 
| 4 | 
            +
              # The Pipe::Client class encapsulates the client side of a named pipe
         | 
| 5 | 
            +
              # connection.
         | 
| 6 | 
            +
              #
         | 
| 7 | 
            +
              class Pipe::Client < Pipe
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                # Create and return a new Pipe::Client instance. The +name+, +pipe_mode+,
         | 
| 10 | 
            +
                # and +open_mode+ are passed to the Win32::Pipe superclass.
         | 
| 11 | 
            +
                #
         | 
| 12 | 
            +
                # The default +pipe_mode+ is NOWAIT.
         | 
| 13 | 
            +
                #
         | 
| 14 | 
            +
                # The default +open_mode+ is FILE_ATTRIBUTE_NORMAL | FILE_FLAG_WRITE_THROUGH.
         | 
| 15 | 
            +
                #
         | 
| 16 | 
            +
                # In block form the client object is yield, and is automatically
         | 
| 17 | 
            +
                # disconnected and closed at the end of the block.
         | 
| 18 | 
            +
                #
         | 
| 19 | 
            +
                # Example:
         | 
| 20 | 
            +
                #
         | 
| 21 | 
            +
                #   require 'win32/pipe'
         | 
| 22 | 
            +
                #
         | 
| 23 | 
            +
                #   Pipe::Client.new('foo') do |pipe|
         | 
| 24 | 
            +
                #     puts "Connected..."
         | 
| 25 | 
            +
                #     pipe.write("Ruby rocks!")
         | 
| 26 | 
            +
                #     data = pipe.read
         | 
| 27 | 
            +
                #     puts "Got [#{data}] back from pipe server"
         | 
| 28 | 
            +
                #  end
         | 
| 29 | 
            +
                #
         | 
| 30 | 
            +
                def initialize(name, pipe_mode = DEFAULT_PIPE_MODE, open_mode = DEFAULT_OPEN_MODE)
         | 
| 31 | 
            +
                  super(name, pipe_mode, open_mode)
         | 
| 16 32 |  | 
| 17 | 
            -
             | 
| 18 | 
            -
             | 
| 19 | 
            -
             | 
| 20 | 
            -
             | 
| 21 | 
            -
             | 
| 22 | 
            -
             | 
| 23 | 
            -
             | 
| 24 | 
            -
             | 
| 25 | 
            -
             | 
| 33 | 
            +
                  @pipe = CreateFile(
         | 
| 34 | 
            +
                    @name,
         | 
| 35 | 
            +
                    GENERIC_READ | GENERIC_WRITE,
         | 
| 36 | 
            +
                    FILE_SHARE_READ | FILE_SHARE_WRITE,
         | 
| 37 | 
            +
                    nil,
         | 
| 38 | 
            +
                    OPEN_EXISTING,
         | 
| 39 | 
            +
                    @open_mode,
         | 
| 40 | 
            +
                    nil 
         | 
| 41 | 
            +
                  )
         | 
| 26 42 |  | 
| 27 | 
            -
             | 
| 43 | 
            +
                  error = GetLastError()
         | 
| 28 44 |  | 
| 29 | 
            -
             | 
| 30 | 
            -
             | 
| 31 | 
            -
             | 
| 32 | 
            -
             | 
| 33 | 
            -
             | 
| 45 | 
            +
                  if error == ERROR_PIPE_BUSY
         | 
| 46 | 
            +
                    unless WaitNamedPipe(@name, NMPWAIT_WAIT_FOREVER)
         | 
| 47 | 
            +
                      raise Error, get_last_error
         | 
| 48 | 
            +
                    end
         | 
| 49 | 
            +
                  end
         | 
| 34 50 |  | 
| 35 | 
            -
             | 
| 36 | 
            -
             | 
| 37 | 
            -
             | 
| 51 | 
            +
                  if @pipe == INVALID_HANDLE_VALUE
         | 
| 52 | 
            +
                    raise Error, get_last_error
         | 
| 53 | 
            +
                  end
         | 
| 38 54 |  | 
| 39 | 
            -
             | 
| 40 | 
            -
             | 
| 41 | 
            -
             | 
| 42 | 
            -
             | 
| 43 | 
            -
             | 
| 44 | 
            -
             | 
| 45 | 
            -
             | 
| 46 | 
            -
                     end
         | 
| 55 | 
            +
                  if block_given?
         | 
| 56 | 
            +
                    begin
         | 
| 57 | 
            +
                      yield self
         | 
| 58 | 
            +
                    ensure
         | 
| 59 | 
            +
                      disconnect
         | 
| 60 | 
            +
                      close
         | 
| 61 | 
            +
                    end
         | 
| 47 62 | 
             
                  end
         | 
| 48 | 
            -
             | 
| 63 | 
            +
                end
         | 
| 64 | 
            +
              end
         | 
| 49 65 | 
             
            end
         | 
    
        data/test/test_win32_pipe.rb
    CHANGED
    
    | @@ -4,119 +4,123 @@ | |
| 4 4 | 
             
            # Test suite for the win32-pipe library. This test suite should be run
         | 
| 5 5 | 
             
            # via the 'rake test' task.
         | 
| 6 6 | 
             
            ##########################################################################
         | 
| 7 | 
            +
            require 'rubygems'
         | 
| 8 | 
            +
            gem 'test-unit'
         | 
| 7 9 | 
             
            require 'test/unit'
         | 
| 10 | 
            +
             | 
| 8 11 | 
             
            require 'win32/pipe'
         | 
| 9 12 | 
             
            include Win32
         | 
| 10 13 |  | 
| 11 14 | 
             
            class TC_Win32_Pipe < Test::Unit::TestCase
         | 
| 12 | 
            -
             | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 15 | 
            +
              def setup
         | 
| 16 | 
            +
                @pipe = Pipe.new('foo')
         | 
| 17 | 
            +
              end
         | 
| 15 18 |  | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 18 | 
            -
             | 
| 19 | 
            +
              def test_version
         | 
| 20 | 
            +
                assert_equal('0.2.2', Pipe::VERSION)
         | 
| 21 | 
            +
              end
         | 
| 19 22 |  | 
| 20 | 
            -
             | 
| 21 | 
            -
             | 
| 22 | 
            -
             | 
| 23 | 
            -
             | 
| 24 | 
            -
             | 
| 23 | 
            +
              def test_name
         | 
| 24 | 
            +
                assert_respond_to(@pipe, :name)
         | 
| 25 | 
            +
                assert_nothing_raised{ @pipe.name }
         | 
| 26 | 
            +
                assert_equal("\\\\.\\pipe\\foo", @pipe.name)
         | 
| 27 | 
            +
              end
         | 
| 25 28 |  | 
| 26 | 
            -
             | 
| 27 | 
            -
             | 
| 28 | 
            -
             | 
| 29 | 
            -
             | 
| 30 | 
            -
             | 
| 29 | 
            +
              def test_pipe_mode
         | 
| 30 | 
            +
                assert_respond_to(@pipe, :pipe_mode)
         | 
| 31 | 
            +
                assert_nothing_raised{ @pipe.pipe_mode }
         | 
| 32 | 
            +
                assert_equal(Pipe::DEFAULT_PIPE_MODE, @pipe.pipe_mode)
         | 
| 33 | 
            +
              end
         | 
| 31 34 |  | 
| 32 | 
            -
             | 
| 33 | 
            -
             | 
| 34 | 
            -
             | 
| 35 | 
            -
             | 
| 36 | 
            -
             | 
| 37 | 
            -
             | 
| 38 | 
            -
             | 
| 39 | 
            -
             | 
| 40 | 
            -
             | 
| 41 | 
            -
             | 
| 42 | 
            -
             | 
| 43 | 
            -
             | 
| 44 | 
            -
             | 
| 45 | 
            -
             | 
| 46 | 
            -
             | 
| 47 | 
            -
             | 
| 48 | 
            -
             | 
| 49 | 
            -
             | 
| 50 | 
            -
             | 
| 51 | 
            -
             | 
| 52 | 
            -
             | 
| 53 | 
            -
             | 
| 54 | 
            -
             | 
| 55 | 
            -
             | 
| 56 | 
            -
             | 
| 57 | 
            -
             | 
| 35 | 
            +
              def test_open_mode
         | 
| 36 | 
            +
                assert_respond_to(@pipe, :open_mode)
         | 
| 37 | 
            +
                assert_nothing_raised{ @pipe.open_mode }
         | 
| 38 | 
            +
                assert_equal(Pipe::DEFAULT_OPEN_MODE, @pipe.open_mode)
         | 
| 39 | 
            +
              end
         | 
| 40 | 
            +
             
         | 
| 41 | 
            +
              def test_buffer
         | 
| 42 | 
            +
                assert_respond_to(@pipe, :buffer)
         | 
| 43 | 
            +
                assert_nothing_raised{ @pipe.buffer }
         | 
| 44 | 
            +
              end
         | 
| 45 | 
            +
             
         | 
| 46 | 
            +
              def test_size
         | 
| 47 | 
            +
                assert_respond_to(@pipe, :size)
         | 
| 48 | 
            +
                assert_nothing_raised{ @pipe.size }
         | 
| 49 | 
            +
              end
         | 
| 50 | 
            +
             
         | 
| 51 | 
            +
              def test_length_alias
         | 
| 52 | 
            +
                assert_respond_to(@pipe, :length)
         | 
| 53 | 
            +
                assert_true(@pipe.method(:length) == @pipe.method(:size))
         | 
| 54 | 
            +
                assert_alias_method(@pipe, :length, :size)
         | 
| 55 | 
            +
              end
         | 
| 56 | 
            +
             
         | 
| 57 | 
            +
              def test_pending
         | 
| 58 | 
            +
                assert_respond_to(@pipe, :pending?)
         | 
| 59 | 
            +
                assert_nothing_raised{ @pipe.pending? }
         | 
| 60 | 
            +
                assert_false(@pipe.pending?)
         | 
| 61 | 
            +
              end
         | 
| 58 62 |  | 
| 59 | 
            -
             | 
| 60 | 
            -
             | 
| 61 | 
            -
             | 
| 62 | 
            -
             | 
| 63 | 
            -
             | 
| 64 | 
            -
             | 
| 65 | 
            -
             | 
| 66 | 
            -
             | 
| 67 | 
            -
             | 
| 68 | 
            -
             | 
| 69 | 
            -
             | 
| 70 | 
            -
             | 
| 71 | 
            -
             | 
| 72 | 
            -
             | 
| 73 | 
            -
             | 
| 74 | 
            -
             | 
| 75 | 
            -
             | 
| 76 | 
            -
             | 
| 77 | 
            -
             | 
| 78 | 
            -
             | 
| 79 | 
            -
             | 
| 80 | 
            -
             | 
| 81 | 
            -
             | 
| 82 | 
            -
             | 
| 83 | 
            -
             | 
| 84 | 
            -
             | 
| 63 | 
            +
              def test_asynchronous
         | 
| 64 | 
            +
                assert_respond_to(@pipe, :asynchronous?)
         | 
| 65 | 
            +
                assert_nothing_raised{ @pipe.asynchronous? }
         | 
| 66 | 
            +
                assert_false(@pipe.asynchronous?)
         | 
| 67 | 
            +
              end
         | 
| 68 | 
            +
             
         | 
| 69 | 
            +
              def test_read
         | 
| 70 | 
            +
                assert_respond_to(@pipe, :read)
         | 
| 71 | 
            +
                assert_raises(Pipe::Error){ @pipe.read } # Nothing to read
         | 
| 72 | 
            +
              end
         | 
| 73 | 
            +
             
         | 
| 74 | 
            +
              def test_transferred
         | 
| 75 | 
            +
                assert_respond_to(@pipe, :transferred)
         | 
| 76 | 
            +
                assert_nothing_raised{ @pipe.transferred }
         | 
| 77 | 
            +
              end
         | 
| 78 | 
            +
             
         | 
| 79 | 
            +
              def test_wait
         | 
| 80 | 
            +
                assert_respond_to(@pipe, :wait)
         | 
| 81 | 
            +
                assert_raises(Pipe::Error){ @pipe.wait } # Can't wait in blocking mode
         | 
| 82 | 
            +
              end
         | 
| 83 | 
            +
             
         | 
| 84 | 
            +
              def test_write
         | 
| 85 | 
            +
                assert_respond_to(@pipe, :write)
         | 
| 86 | 
            +
                assert_raises(ArgumentError){ @pipe.write }      # Must have 1 argument
         | 
| 87 | 
            +
                assert_raises(Pipe::Error){ @pipe.write("foo") } # Nothing to write to
         | 
| 88 | 
            +
              end
         | 
| 85 89 |  | 
| 86 | 
            -
             | 
| 87 | 
            -
             | 
| 88 | 
            -
             | 
| 89 | 
            -
             | 
| 90 | 
            +
              def test_disconnect
         | 
| 91 | 
            +
                assert_respond_to(@pipe, :disconnect)
         | 
| 92 | 
            +
                assert_nothing_raised{ @pipe.disconnect }
         | 
| 93 | 
            +
              end
         | 
| 90 94 |  | 
| 91 | 
            -
             | 
| 92 | 
            -
             | 
| 93 | 
            -
             | 
| 94 | 
            -
             | 
| 95 | 
            -
             | 
| 96 | 
            -
             | 
| 97 | 
            -
             | 
| 98 | 
            -
             | 
| 99 | 
            -
             | 
| 100 | 
            -
             | 
| 101 | 
            -
             | 
| 102 | 
            -
             | 
| 103 | 
            -
             | 
| 95 | 
            +
              def test_close
         | 
| 96 | 
            +
                assert_respond_to(@pipe, :close)
         | 
| 97 | 
            +
                assert_nothing_raised{ @pipe.close }
         | 
| 98 | 
            +
              end
         | 
| 99 | 
            +
             
         | 
| 100 | 
            +
              def test_pipe_mode_constants
         | 
| 101 | 
            +
                assert_not_nil(Pipe::WAIT)
         | 
| 102 | 
            +
                assert_not_nil(Pipe::NOWAIT)
         | 
| 103 | 
            +
                assert_not_nil(Pipe::TYPE_BYTE)
         | 
| 104 | 
            +
                assert_not_nil(Pipe::TYPE_MESSAGE)
         | 
| 105 | 
            +
                assert_not_nil(Pipe::READMODE_BYTE)
         | 
| 106 | 
            +
                assert_not_nil(Pipe::READMODE_MESSAGE)
         | 
| 107 | 
            +
              end
         | 
| 104 108 |  | 
| 105 | 
            -
             | 
| 106 | 
            -
             | 
| 107 | 
            -
             | 
| 108 | 
            -
             | 
| 109 | 
            -
             | 
| 110 | 
            -
             | 
| 111 | 
            -
             | 
| 112 | 
            -
             | 
| 109 | 
            +
              def test_open_mode_constants
         | 
| 110 | 
            +
                assert_not_nil(Pipe::ACCESS_DUPLEX)
         | 
| 111 | 
            +
                assert_not_nil(Pipe::ACCESS_INBOUND)
         | 
| 112 | 
            +
                assert_not_nil(Pipe::ACCESS_OUTBOUND)
         | 
| 113 | 
            +
                assert_not_nil(Pipe::FIRST_PIPE_INSTANCE)
         | 
| 114 | 
            +
                assert_not_nil(Pipe::WRITE_THROUGH)
         | 
| 115 | 
            +
                assert_not_nil(Pipe::OVERLAPPED)
         | 
| 116 | 
            +
              end
         | 
| 113 117 |  | 
| 114 | 
            -
             | 
| 115 | 
            -
             | 
| 116 | 
            -
             | 
| 117 | 
            -
             | 
| 118 | 
            -
             | 
| 119 | 
            -
             | 
| 120 | 
            -
             | 
| 121 | 
            -
             | 
| 118 | 
            +
              def test_other_constants
         | 
| 119 | 
            +
                assert_not_nil(Pipe::INFINITE)
         | 
| 120 | 
            +
              end
         | 
| 121 | 
            +
             
         | 
| 122 | 
            +
              def teardown
         | 
| 123 | 
            +
                @pipe.close
         | 
| 124 | 
            +
                @pipe = nil
         | 
| 125 | 
            +
              end
         | 
| 122 126 | 
             
            end
         | 
| @@ -6,23 +6,55 @@ | |
| 6 6 | 
             
            ##########################################################################
         | 
| 7 7 | 
             
            require 'test/unit'
         | 
| 8 8 | 
             
            require 'win32/pipe'
         | 
| 9 | 
            -
            include Win32
         | 
| 10 9 |  | 
| 11 10 | 
             
            class TC_Win32_Pipe_Client < Test::Unit::TestCase
         | 
| 12 | 
            -
             | 
| 13 | 
            -
             | 
| 14 | 
            -
                | 
| 15 | 
            -
             | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 18 | 
            -
             | 
| 19 | 
            -
             | 
| 20 | 
            -
             | 
| 21 | 
            -
             | 
| 22 | 
            -
             | 
| 23 | 
            -
             | 
| 24 | 
            -
             | 
| 25 | 
            -
             | 
| 26 | 
            -
             | 
| 27 | 
            -
             | 
| 11 | 
            +
              def setup
         | 
| 12 | 
            +
                @server = Win32::Pipe::Server.new('test')
         | 
| 13 | 
            +
                @pipe   = nil
         | 
| 14 | 
            +
                @name   = 'test'
         | 
| 15 | 
            +
                @pmode  = Win32::Pipe::PIPE_NOWAIT
         | 
| 16 | 
            +
                @omode  = Win32::Pipe::DEFAULT_OPEN_MODE
         | 
| 17 | 
            +
              end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
              test "constructor basic functionality" do
         | 
| 20 | 
            +
                assert_respond_to(Win32::Pipe::Client, :new)
         | 
| 21 | 
            +
                assert_nothing_raised{ @pipe = Win32::Pipe::Client.new(@name) }
         | 
| 22 | 
            +
              end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
              test "constructor accepts an optional pipe mode" do
         | 
| 25 | 
            +
                assert_nothing_raised{ @pipe = Win32::Pipe::Client.new(@name, @pmode) }
         | 
| 26 | 
            +
              end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
              test "constructor accepts an optional open mode" do
         | 
| 29 | 
            +
                assert_nothing_raised{ @pipe = Win32::Pipe::Client.new(@name, @pmode, @omode) }
         | 
| 30 | 
            +
              end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
              test "constructor requires a pipe name" do
         | 
| 33 | 
            +
                assert_raise(ArgumentError){ Win32::Pipe::Client.new }
         | 
| 34 | 
            +
              end
         | 
| 35 | 
            +
             | 
| 36 | 
            +
              test "pipe name must be a string" do
         | 
| 37 | 
            +
                assert_raise(TypeError){ Win32::Pipe::Client.new(1) }
         | 
| 38 | 
            +
              end
         | 
| 39 | 
            +
             | 
| 40 | 
            +
              test "an error is raised if the named pipe cannot be found" do
         | 
| 41 | 
            +
                assert_raise(Win32::Pipe::Error){ Win32::Pipe::Client.new('bogus') }
         | 
| 42 | 
            +
              end
         | 
| 43 | 
            +
             | 
| 44 | 
            +
              def teardown
         | 
| 45 | 
            +
                if @pipe
         | 
| 46 | 
            +
                  @pipe.disconnect
         | 
| 47 | 
            +
                  @pipe.close
         | 
| 48 | 
            +
                end
         | 
| 49 | 
            +
             | 
| 50 | 
            +
                if @server
         | 
| 51 | 
            +
                  @server.disconnect
         | 
| 52 | 
            +
                  @server.close
         | 
| 53 | 
            +
                end
         | 
| 54 | 
            +
             | 
| 55 | 
            +
                @pmode  = nil
         | 
| 56 | 
            +
                @omode  = nil
         | 
| 57 | 
            +
                @pipe   = nil
         | 
| 58 | 
            +
                @server = nil
         | 
| 59 | 
            +
              end
         | 
| 28 60 | 
             
            end
         | 
| @@ -15,7 +15,7 @@ class TC_Win32_Pipe_Server < Test::Unit::TestCase | |
| 15 15 |  | 
| 16 16 | 
             
               def test_constructor_basic
         | 
| 17 17 | 
             
                  assert_respond_to(Pipe::Server, :new)
         | 
| 18 | 
            -
                  assert_nothing_raised{ Pipe::Server.new('foo') }
         | 
| 18 | 
            +
                  assert_nothing_raised{ @pipe = Pipe::Server.new('foo') }
         | 
| 19 19 | 
             
               end
         | 
| 20 20 |  | 
| 21 21 | 
             
               def test_connect
         | 
    
        data/win32-pipe.gemspec
    CHANGED
    
    | @@ -1,28 +1,25 @@ | |
| 1 1 | 
             
            require 'rubygems'
         | 
| 2 2 |  | 
| 3 | 
            -
             | 
| 4 | 
            -
            	 | 
| 5 | 
            -
            	 | 
| 6 | 
            -
            	 | 
| 7 | 
            -
             | 
| 8 | 
            -
            	 | 
| 9 | 
            -
            	 | 
| 10 | 
            -
            	 | 
| 11 | 
            -
            	 | 
| 12 | 
            -
             | 
| 13 | 
            -
            	gem.has_rdoc   = true
         | 
| 14 | 
            -
               gem.files      = Dir['**/*'].reject{ |f| f.include?('CVS') }
         | 
| 3 | 
            +
            Gem::Specification.new do |spec|
         | 
| 4 | 
            +
            	spec.name       = 'win32-pipe'
         | 
| 5 | 
            +
            	spec.version    = '0.2.2'
         | 
| 6 | 
            +
            	spec.author     = 'Daniel J. Berger'
         | 
| 7 | 
            +
              spec.license    = 'Artistic 2.0'
         | 
| 8 | 
            +
            	spec.email      = 'djberg96@gmail.com'
         | 
| 9 | 
            +
            	spec.homepage   = 'http://www.rubyforge.org/projects/win32utils'
         | 
| 10 | 
            +
            	spec.summary    = 'An interface for named pipes on MS Windows' 
         | 
| 11 | 
            +
            	spec.test_files = Dir['test/test_*.rb']
         | 
| 12 | 
            +
              spec.files      = Dir['**/*'].reject{ |f| f.include?('git') }
         | 
| 15 13 |  | 
| 16 | 
            -
            	 | 
| 17 | 
            -
            	 | 
| 14 | 
            +
            	spec.rubyforge_project = 'win32utils'
         | 
| 15 | 
            +
            	spec.extra_rdoc_files  = ['CHANGES', 'README', 'MANIFEST']
         | 
| 18 16 |  | 
| 19 | 
            -
            	 | 
| 17 | 
            +
            	spec.add_dependency('windows-pr', '>= 1.0.6')
         | 
| 18 | 
            +
              spec.add_development_dependency('test-unit', '>= 2.1.0')
         | 
| 20 19 |  | 
| 21 | 
            -
            	 | 
| 22 | 
            -
             | 
| 23 | 
            -
             | 
| 24 | 
            -
             | 
| 25 | 
            -
             | 
| 20 | 
            +
            	spec.description = <<-EOF
         | 
| 21 | 
            +
                The win32-pipe library provides an interface for named pipes on Windows.
         | 
| 22 | 
            +
                A named pipe is a named, one-way or duplex pipe for communication
         | 
| 23 | 
            +
                between the pipe server and one or more pipe clients. 
         | 
| 24 | 
            +
              EOF
         | 
| 26 25 | 
             
            end
         | 
| 27 | 
            -
             | 
| 28 | 
            -
            Gem::Builder.new(spec).build
         | 
    
        metadata
    CHANGED
    
    | @@ -1,38 +1,49 @@ | |
| 1 | 
            -
            --- !ruby/object:Gem::Specification | 
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: win32-pipe
         | 
| 3 | 
            -
            version: !ruby/object:Gem::Version | 
| 4 | 
            -
              version: 0.2. | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 0.2.2
         | 
| 5 | 
            +
              prerelease: 
         | 
| 5 6 | 
             
            platform: ruby
         | 
| 6 | 
            -
            authors: | 
| 7 | 
            +
            authors:
         | 
| 7 8 | 
             
            - Daniel J. Berger
         | 
| 8 9 | 
             
            autorequire: 
         | 
| 9 10 | 
             
            bindir: bin
         | 
| 10 11 | 
             
            cert_chain: []
         | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 13 | 
            -
             | 
| 14 | 
            -
            dependencies: 
         | 
| 15 | 
            -
            - !ruby/object:Gem::Dependency 
         | 
| 12 | 
            +
            date: 2012-03-19 00:00:00.000000000 Z
         | 
| 13 | 
            +
            dependencies:
         | 
| 14 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 16 15 | 
             
              name: windows-pr
         | 
| 17 | 
            -
               | 
| 18 | 
            -
             | 
| 19 | 
            -
             | 
| 20 | 
            -
                 | 
| 21 | 
            -
             | 
| 22 | 
            -
                  - !ruby/object:Gem::Version 
         | 
| 16 | 
            +
              requirement: &21666690 !ruby/object:Gem::Requirement
         | 
| 17 | 
            +
                none: false
         | 
| 18 | 
            +
                requirements:
         | 
| 19 | 
            +
                - - ! '>='
         | 
| 20 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 23 21 | 
             
                    version: 1.0.6
         | 
| 24 | 
            -
             | 
| 25 | 
            -
             | 
| 22 | 
            +
              type: :runtime
         | 
| 23 | 
            +
              prerelease: false
         | 
| 24 | 
            +
              version_requirements: *21666690
         | 
| 25 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 26 | 
            +
              name: test-unit
         | 
| 27 | 
            +
              requirement: &21666430 !ruby/object:Gem::Requirement
         | 
| 28 | 
            +
                none: false
         | 
| 29 | 
            +
                requirements:
         | 
| 30 | 
            +
                - - ! '>='
         | 
| 31 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 32 | 
            +
                    version: 2.1.0
         | 
| 33 | 
            +
              type: :development
         | 
| 34 | 
            +
              prerelease: false
         | 
| 35 | 
            +
              version_requirements: *21666430
         | 
| 36 | 
            +
            description: ! "    The win32-pipe library provides an interface for named pipes on
         | 
| 37 | 
            +
              Windows.\n    A named pipe is a named, one-way or duplex pipe for communication\n
         | 
| 38 | 
            +
              \   between the pipe server and one or more pipe clients. \n"
         | 
| 26 39 | 
             
            email: djberg96@gmail.com
         | 
| 27 40 | 
             
            executables: []
         | 
| 28 | 
            -
             | 
| 29 41 | 
             
            extensions: []
         | 
| 30 | 
            -
             | 
| 31 | 
            -
            extra_rdoc_files: 
         | 
| 42 | 
            +
            extra_rdoc_files:
         | 
| 32 43 | 
             
            - CHANGES
         | 
| 33 44 | 
             
            - README
         | 
| 34 45 | 
             
            - MANIFEST
         | 
| 35 | 
            -
            files: | 
| 46 | 
            +
            files:
         | 
| 36 47 | 
             
            - CHANGES
         | 
| 37 48 | 
             
            - examples/example_client.rb
         | 
| 38 49 | 
             
            - examples/example_client_async.rb
         | 
| @@ -48,35 +59,32 @@ files: | |
| 48 59 | 
             
            - test/test_win32_pipe_client.rb
         | 
| 49 60 | 
             
            - test/test_win32_pipe_server.rb
         | 
| 50 61 | 
             
            - win32-pipe.gemspec
         | 
| 51 | 
            -
            has_rdoc: true
         | 
| 52 62 | 
             
            homepage: http://www.rubyforge.org/projects/win32utils
         | 
| 53 | 
            -
            licenses: | 
| 63 | 
            +
            licenses:
         | 
| 54 64 | 
             
            - Artistic 2.0
         | 
| 55 65 | 
             
            post_install_message: 
         | 
| 56 66 | 
             
            rdoc_options: []
         | 
| 57 | 
            -
             | 
| 58 | 
            -
            require_paths: 
         | 
| 67 | 
            +
            require_paths:
         | 
| 59 68 | 
             
            - lib
         | 
| 60 | 
            -
            required_ruby_version: !ruby/object:Gem::Requirement | 
| 61 | 
            -
               | 
| 62 | 
            -
               | 
| 63 | 
            -
             | 
| 64 | 
            -
             | 
| 65 | 
            -
             | 
| 66 | 
            -
            required_rubygems_version: !ruby/object:Gem::Requirement | 
| 67 | 
            -
               | 
| 68 | 
            -
               | 
| 69 | 
            -
             | 
| 70 | 
            -
             | 
| 71 | 
            -
             | 
| 69 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 70 | 
            +
              none: false
         | 
| 71 | 
            +
              requirements:
         | 
| 72 | 
            +
              - - ! '>='
         | 
| 73 | 
            +
                - !ruby/object:Gem::Version
         | 
| 74 | 
            +
                  version: '0'
         | 
| 75 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 76 | 
            +
              none: false
         | 
| 77 | 
            +
              requirements:
         | 
| 78 | 
            +
              - - ! '>='
         | 
| 79 | 
            +
                - !ruby/object:Gem::Version
         | 
| 80 | 
            +
                  version: '0'
         | 
| 72 81 | 
             
            requirements: []
         | 
| 73 | 
            -
             | 
| 74 82 | 
             
            rubyforge_project: win32utils
         | 
| 75 | 
            -
            rubygems_version: 1. | 
| 83 | 
            +
            rubygems_version: 1.8.11
         | 
| 76 84 | 
             
            signing_key: 
         | 
| 77 85 | 
             
            specification_version: 3
         | 
| 78 86 | 
             
            summary: An interface for named pipes on MS Windows
         | 
| 79 | 
            -
            test_files: | 
| 87 | 
            +
            test_files:
         | 
| 80 88 | 
             
            - test/test_win32_pipe.rb
         | 
| 81 89 | 
             
            - test/test_win32_pipe_client.rb
         | 
| 82 90 | 
             
            - test/test_win32_pipe_server.rb
         |