io-like 0.3.1 → 0.4.0.pre1
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.
- checksums.yaml +7 -0
 - data/LICENSE +1 -1
 - data/NEWS.md +14 -1
 - data/README.md +75 -94
 - data/lib/io/like.rb +1916 -1314
 - data/lib/io/like_helpers/abstract_io.rb +512 -0
 - data/lib/io/like_helpers/blocking_io.rb +86 -0
 - data/lib/io/like_helpers/buffered_io.rb +555 -0
 - data/lib/io/like_helpers/character_io/basic_reader.rb +122 -0
 - data/lib/io/like_helpers/character_io/converter_reader.rb +252 -0
 - data/lib/io/like_helpers/character_io.rb +529 -0
 - data/lib/io/like_helpers/delegated_io.rb +250 -0
 - data/lib/io/like_helpers/duplexed_io.rb +259 -0
 - data/lib/io/like_helpers/io.rb +21 -0
 - data/lib/io/like_helpers/io_wrapper.rb +290 -0
 - data/lib/io/like_helpers/pipeline.rb +77 -0
 - data/lib/io/like_helpers/ruby_facts.rb +33 -0
 - data/lib/io/like_helpers.rb +14 -0
 - metadata +107 -224
 - data/.yardopts +0 -1
 - data/Rakefile +0 -228
 - data/ruby.1.8.mspec +0 -7
 - data/spec/binmode_spec.rb +0 -29
 - data/spec/close_read_spec.rb +0 -64
 - data/spec/close_spec.rb +0 -36
 - data/spec/close_write_spec.rb +0 -61
 - data/spec/closed_spec.rb +0 -16
 - data/spec/each_byte_spec.rb +0 -38
 - data/spec/each_line_spec.rb +0 -11
 - data/spec/each_spec.rb +0 -11
 - data/spec/eof_spec.rb +0 -11
 - data/spec/fixtures/classes.rb +0 -96
 - data/spec/fixtures/gets.txt +0 -9
 - data/spec/fixtures/numbered_lines.txt +0 -5
 - data/spec/fixtures/one_byte.txt +0 -1
 - data/spec/fixtures/paragraphs.txt +0 -7
 - data/spec/fixtures/readlines.txt +0 -6
 - data/spec/flush_spec.rb +0 -8
 - data/spec/getc_spec.rb +0 -44
 - data/spec/gets_spec.rb +0 -212
 - data/spec/isatty_spec.rb +0 -6
 - data/spec/lineno_spec.rb +0 -84
 - data/spec/output_spec.rb +0 -47
 - data/spec/pos_spec.rb +0 -53
 - data/spec/print_spec.rb +0 -97
 - data/spec/printf_spec.rb +0 -24
 - data/spec/putc_spec.rb +0 -57
 - data/spec/puts_spec.rb +0 -99
 - data/spec/read_spec.rb +0 -162
 - data/spec/readchar_spec.rb +0 -49
 - data/spec/readline_spec.rb +0 -60
 - data/spec/readlines_spec.rb +0 -140
 - data/spec/readpartial_spec.rb +0 -92
 - data/spec/rewind_spec.rb +0 -56
 - data/spec/seek_spec.rb +0 -72
 - data/spec/shared/each.rb +0 -204
 - data/spec/shared/eof.rb +0 -116
 - data/spec/shared/pos.rb +0 -39
 - data/spec/shared/tty.rb +0 -12
 - data/spec/shared/write.rb +0 -53
 - data/spec/sync_spec.rb +0 -56
 - data/spec/sysread_spec.rb +0 -87
 - data/spec/sysseek_spec.rb +0 -68
 - data/spec/syswrite_spec.rb +0 -60
 - data/spec/tell_spec.rb +0 -7
 - data/spec/to_io_spec.rb +0 -19
 - data/spec/tty_spec.rb +0 -6
 - data/spec/ungetc_spec.rb +0 -118
 - data/spec/write_spec.rb +0 -61
 - data/spec_helper.rb +0 -49
 - /data/{LICENSE-rubyspec → rubyspec/LICENSE} +0 -0
 
    
        data/spec/write_spec.rb
    DELETED
    
    | 
         @@ -1,61 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require File.dirname(__FILE__) + '/../spec_helper'
         
     | 
| 
       2 
     | 
    
         
            -
            require File.dirname(__FILE__) + '/fixtures/classes'
         
     | 
| 
       3 
     | 
    
         
            -
            require File.dirname(__FILE__) + '/shared/write'
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
            describe "IO::Like#write" do
         
     | 
| 
       6 
     | 
    
         
            -
              before :each do
         
     | 
| 
       7 
     | 
    
         
            -
                @filename = tmp("IO_Like__write_test")
         
     | 
| 
       8 
     | 
    
         
            -
                @content = "012345678901234567890123456789"
         
     | 
| 
       9 
     | 
    
         
            -
                File.open(@filename, "w") { |f| f.syswrite(@content) }
         
     | 
| 
       10 
     | 
    
         
            -
                @file = File.open(@filename, "r+")
         
     | 
| 
       11 
     | 
    
         
            -
                @iowrapper = IOWrapper.open(@file)
         
     | 
| 
       12 
     | 
    
         
            -
              end
         
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
              after :each do
         
     | 
| 
       15 
     | 
    
         
            -
                @iowrapper.close unless @iowrapper.closed?
         
     | 
| 
       16 
     | 
    
         
            -
                @file.close unless @file.closed?
         
     | 
| 
       17 
     | 
    
         
            -
                File.delete(@filename)
         
     | 
| 
       18 
     | 
    
         
            -
              end
         
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
              # TODO: impl detail? discuss this with matz. This spec is useless. - rdavis
         
     | 
| 
       21 
     | 
    
         
            -
              it "writes all of the string's bytes but buffers them" do
         
     | 
| 
       22 
     | 
    
         
            -
                written = @iowrapper.write("abcde")
         
     | 
| 
       23 
     | 
    
         
            -
                written.should == 5
         
     | 
| 
       24 
     | 
    
         
            -
                File.open(@filename) do |file|
         
     | 
| 
       25 
     | 
    
         
            -
                  file.read.should == "012345678901234567890123456789"
         
     | 
| 
       26 
     | 
    
         
            -
                  @iowrapper.flush
         
     | 
| 
       27 
     | 
    
         
            -
                  file.rewind
         
     | 
| 
       28 
     | 
    
         
            -
                  file.read.should == "abcde5678901234567890123456789"
         
     | 
| 
       29 
     | 
    
         
            -
                end
         
     | 
| 
       30 
     | 
    
         
            -
              end
         
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
              it "returns the number of bytes written" do
         
     | 
| 
       33 
     | 
    
         
            -
                @iowrapper.write('').should == 0
         
     | 
| 
       34 
     | 
    
         
            -
                @iowrapper.write('abcde').should == 5
         
     | 
| 
       35 
     | 
    
         
            -
              end
         
     | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
       37 
     | 
    
         
            -
              it "writes all of the string's bytes without buffering if mode is sync" do
         
     | 
| 
       38 
     | 
    
         
            -
                @iowrapper.sync = true
         
     | 
| 
       39 
     | 
    
         
            -
                written = @iowrapper.write("abcde")
         
     | 
| 
       40 
     | 
    
         
            -
                written.should == 5
         
     | 
| 
       41 
     | 
    
         
            -
                File.open(@filename) do |file|
         
     | 
| 
       42 
     | 
    
         
            -
                  file.read(10).should == "abcde56789"
         
     | 
| 
       43 
     | 
    
         
            -
                end
         
     | 
| 
       44 
     | 
    
         
            -
              end
         
     | 
| 
       45 
     | 
    
         
            -
             
     | 
| 
       46 
     | 
    
         
            -
              it "does not raise IOError on read-only stream if writing zero bytes" do
         
     | 
| 
       47 
     | 
    
         
            -
                lambda do
         
     | 
| 
       48 
     | 
    
         
            -
                  IOSpecs.readable_iowrapper do |iowrapper|
         
     | 
| 
       49 
     | 
    
         
            -
                    iowrapper.write("")
         
     | 
| 
       50 
     | 
    
         
            -
                  end
         
     | 
| 
       51 
     | 
    
         
            -
                end.should_not raise_error
         
     | 
| 
       52 
     | 
    
         
            -
              end
         
     | 
| 
       53 
     | 
    
         
            -
             
     | 
| 
       54 
     | 
    
         
            -
              it "does not raise IOError on closed stream if writing zero bytes" do
         
     | 
| 
       55 
     | 
    
         
            -
                lambda { IOSpecs.closed_file.write("") }.should_not raise_error
         
     | 
| 
       56 
     | 
    
         
            -
              end
         
     | 
| 
       57 
     | 
    
         
            -
            end
         
     | 
| 
       58 
     | 
    
         
            -
             
     | 
| 
       59 
     | 
    
         
            -
            describe "IO::Like#write" do
         
     | 
| 
       60 
     | 
    
         
            -
              it_behaves_like :io_like__write, :write
         
     | 
| 
       61 
     | 
    
         
            -
            end
         
     | 
    
        data/spec_helper.rb
    DELETED
    
    | 
         @@ -1,49 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            unless ENV['MSPEC_RUNNER']
         
     | 
| 
       2 
     | 
    
         
            -
              begin
         
     | 
| 
       3 
     | 
    
         
            -
                require "pp"
         
     | 
| 
       4 
     | 
    
         
            -
                require 'mspec/version'
         
     | 
| 
       5 
     | 
    
         
            -
                require 'mspec/helpers'
         
     | 
| 
       6 
     | 
    
         
            -
                require 'mspec/guards'
         
     | 
| 
       7 
     | 
    
         
            -
                require 'mspec/runner/shared'
         
     | 
| 
       8 
     | 
    
         
            -
                require 'mspec/matchers/be_ancestor_of'
         
     | 
| 
       9 
     | 
    
         
            -
                require 'mspec/matchers/output'
         
     | 
| 
       10 
     | 
    
         
            -
                require 'mspec/matchers/output_to_fd'
         
     | 
| 
       11 
     | 
    
         
            -
                require 'mspec/matchers/complain'
         
     | 
| 
       12 
     | 
    
         
            -
                require 'mspec/matchers/equal_element'
         
     | 
| 
       13 
     | 
    
         
            -
                require 'mspec/matchers/equal_utf16'
         
     | 
| 
       14 
     | 
    
         
            -
                require 'mspec/matchers/match_yaml'
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
                # Code to setup HOME directory correctly on Windows
         
     | 
| 
       17 
     | 
    
         
            -
                # This duplicates Ruby 1.9 semantics for defining HOME
         
     | 
| 
       18 
     | 
    
         
            -
                platform_is :windows do
         
     | 
| 
       19 
     | 
    
         
            -
                  if ENV['HOME']
         
     | 
| 
       20 
     | 
    
         
            -
                    ENV['HOME'] = ENV['HOME'].tr '\\', '/'
         
     | 
| 
       21 
     | 
    
         
            -
                  elsif ENV['HOMEDIR'] && ENV['HOMEDRIVE']
         
     | 
| 
       22 
     | 
    
         
            -
                    ENV['HOME'] = File.join(ENV['HOMEDRIVE'], ENV['HOMEDIR'])
         
     | 
| 
       23 
     | 
    
         
            -
                  elsif ENV['HOMEDIR']
         
     | 
| 
       24 
     | 
    
         
            -
                    ENV['HOME'] = ENV['HOMEDIR']
         
     | 
| 
       25 
     | 
    
         
            -
                  elsif ENV['HOMEDRIVE']
         
     | 
| 
       26 
     | 
    
         
            -
                    ENV['HOME'] = ENV['HOMEDRIVE']
         
     | 
| 
       27 
     | 
    
         
            -
                  elsif ENV['USERPROFILE']
         
     | 
| 
       28 
     | 
    
         
            -
                    ENV['HOME'] = ENV['USERPROFILE']
         
     | 
| 
       29 
     | 
    
         
            -
                  else
         
     | 
| 
       30 
     | 
    
         
            -
                    puts "No suitable HOME environment found. This means that all of"
         
     | 
| 
       31 
     | 
    
         
            -
                    puts "HOME, HOMEDIR, HOMEDRIVE, and USERPROFILE are not set"
         
     | 
| 
       32 
     | 
    
         
            -
                    exit 1
         
     | 
| 
       33 
     | 
    
         
            -
                  end
         
     | 
| 
       34 
     | 
    
         
            -
                end
         
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
       36 
     | 
    
         
            -
                TOLERANCE = 0.00003 unless Object.const_defined?(:TOLERANCE)
         
     | 
| 
       37 
     | 
    
         
            -
              rescue LoadError
         
     | 
| 
       38 
     | 
    
         
            -
                puts "Please install the MSpec gem to run the specs."
         
     | 
| 
       39 
     | 
    
         
            -
                exit 1
         
     | 
| 
       40 
     | 
    
         
            -
              end
         
     | 
| 
       41 
     | 
    
         
            -
            end
         
     | 
| 
       42 
     | 
    
         
            -
             
     | 
| 
       43 
     | 
    
         
            -
            minimum_version = "1.5.9"
         
     | 
| 
       44 
     | 
    
         
            -
            unless MSpec::VERSION >= minimum_version
         
     | 
| 
       45 
     | 
    
         
            -
              puts "Please install MSpec version >= #{minimum_version} to run the specs"
         
     | 
| 
       46 
     | 
    
         
            -
              exit 1
         
     | 
| 
       47 
     | 
    
         
            -
            end
         
     | 
| 
       48 
     | 
    
         
            -
             
     | 
| 
       49 
     | 
    
         
            -
            $VERBOSE = nil unless ENV['OUTPUT_WARNINGS']
         
     | 
| 
         
            File without changes
         
     |