spreadsheet 0.6.1.4 → 0.6.1.5
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/History.txt +10 -0
- data/Manifest.txt +1 -0
- data/lib/spreadsheet.rb +1 -1
- data/lib/spreadsheet/encodings.rb +0 -14
- data/lib/spreadsheet/excel/worksheet.rb +4 -4
- data/lib/spreadsheet/worksheet.rb +3 -3
- data/test/data/test_empty.xls +0 -0
- data/test/integration.rb +19 -0
- metadata +3 -2
    
        data/History.txt
    CHANGED
    
    | @@ -1,3 +1,13 @@ | |
| 1 | 
            +
            === 0.6.1.4 / 2008-10-24
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            * 2 Bugfixes
         | 
| 4 | 
            +
             | 
| 5 | 
            +
              * Removed obsolete code which triggered Iconv::InvalidEncoding
         | 
| 6 | 
            +
                on Systems with non-gnu Iconv:
         | 
| 7 | 
            +
                http://rubyforge.org/tracker/index.php?func=detail&aid=22541&group_id=678&atid=2677
         | 
| 8 | 
            +
              * Handle empty Worksheets
         | 
| 9 | 
            +
                (Thanks to Charles Lowe for the Patches)
         | 
| 10 | 
            +
             | 
| 1 11 | 
             
            === 0.6.1.4 / 2008-10-23
         | 
| 2 12 |  | 
| 3 13 | 
             
            * 1 Bugfix
         | 
    
        data/Manifest.txt
    CHANGED
    
    
    
        data/lib/spreadsheet.rb
    CHANGED
    
    
| @@ -3,9 +3,6 @@ module Spreadsheet | |
| 3 3 | 
             
              # Methods for Encoding-conversions. You should not need to use any of these.
         | 
| 4 4 | 
             
              module Encodings
         | 
| 5 5 | 
             
                if RUBY_VERSION >= '1.9'
         | 
| 6 | 
            -
                  def ascii string
         | 
| 7 | 
            -
                    string.encode 'ASCII//TRANSLIT//IGNORE'
         | 
| 8 | 
            -
                  end
         | 
| 9 6 | 
             
                  def client string, internal='UTF-16LE'
         | 
| 10 7 | 
             
                    string.encode Spreadsheet.client_encoding
         | 
| 11 8 | 
             
                  end
         | 
| @@ -14,15 +11,7 @@ module Spreadsheet | |
| 14 11 | 
             
                  end
         | 
| 15 12 | 
             
                else
         | 
| 16 13 | 
             
                  require 'iconv'
         | 
| 17 | 
            -
                  @@utf8_utf16 = Iconv.new('UTF-16LE', 'UTF-8')
         | 
| 18 | 
            -
                  @@utf16_ascii = Iconv.new('ASCII//TRANSLIT//IGNORE', 'UTF-16LE')
         | 
| 19 | 
            -
                  @@utf16_utf8 = Iconv.new('UTF-8//TRANSLIT//IGNORE', 'UTF-16LE')
         | 
| 20 14 | 
             
                  @@iconvs = {}
         | 
| 21 | 
            -
                  def ascii string
         | 
| 22 | 
            -
                    @@utf16_ascii.iconv string
         | 
| 23 | 
            -
                  rescue
         | 
| 24 | 
            -
                    string.gsub /[^\x20-\x7e]+/, ''
         | 
| 25 | 
            -
                  end
         | 
| 26 15 | 
             
                  def client string, internal='UTF-16LE'
         | 
| 27 16 | 
             
                    key = [Spreadsheet.client_encoding, internal]
         | 
| 28 17 | 
             
                    iconv = @@iconvs[key] ||= Iconv.new(Spreadsheet.client_encoding, internal)
         | 
| @@ -36,9 +25,6 @@ module Spreadsheet | |
| 36 25 | 
             
                end
         | 
| 37 26 | 
             
              rescue LoadError
         | 
| 38 27 | 
             
                warn "You don't have Iconv support compiled in your Ruby. Spreadsheet may not work as expected"
         | 
| 39 | 
            -
                def ascii string
         | 
| 40 | 
            -
                  string.gsub /[^\x20-\x7e]+/, ''
         | 
| 41 | 
            -
                end
         | 
| 42 28 | 
             
                def client string, internal='UTF-16LE'
         | 
| 43 29 | 
             
                  string.delete "\0"
         | 
| 44 30 | 
             
                end
         | 
| @@ -78,17 +78,17 @@ class Worksheet < Spreadsheet::Worksheet | |
| 78 78 | 
             
                shorten @rows
         | 
| 79 79 | 
             
                @dimensions = []
         | 
| 80 80 | 
             
                @dimensions[0] = [ index_of_first(@rows),
         | 
| 81 | 
            -
                                   index_of_first(@row_addresses) ].compact.min
         | 
| 82 | 
            -
                @dimensions[1] = [ @rows.size, @row_addresses.size ].compact.max
         | 
| 81 | 
            +
                                   index_of_first(@row_addresses) ].compact.min || 0
         | 
| 82 | 
            +
                @dimensions[1] = [ @rows.size, @row_addresses.size ].compact.max || 0
         | 
| 83 83 | 
             
                compact = @rows.compact
         | 
| 84 84 | 
             
                first_rows = compact.collect do |row| index_of_first row end.compact.min
         | 
| 85 85 | 
             
                first_addrs = @row_addresses.compact.collect do |addr|
         | 
| 86 86 | 
             
                  addr[:first_used] end.min
         | 
| 87 | 
            -
                @dimensions[2] = [ first_rows, first_addrs ].compact.min
         | 
| 87 | 
            +
                @dimensions[2] = [ first_rows, first_addrs ].compact.min || 0
         | 
| 88 88 | 
             
                last_rows = compact.collect do |row| row.size end.max
         | 
| 89 89 | 
             
                last_addrs = @row_addresses.compact.collect do |addr|
         | 
| 90 90 | 
             
                  addr[:first_unused] end.max
         | 
| 91 | 
            -
                @dimensions[3] = [last_rows, last_addrs].compact.max
         | 
| 91 | 
            +
                @dimensions[3] = [last_rows, last_addrs].compact.max || 0
         | 
| 92 92 | 
             
                @dimensions
         | 
| 93 93 | 
             
              end
         | 
| 94 94 | 
             
            end
         | 
| @@ -242,11 +242,11 @@ module Spreadsheet | |
| 242 242 | 
             
                def recalculate_dimensions # :nodoc:
         | 
| 243 243 | 
             
                  shorten @rows
         | 
| 244 244 | 
             
                  @dimensions = []
         | 
| 245 | 
            -
                  @dimensions[0] = index_of_first | 
| 245 | 
            +
                  @dimensions[0] = index_of_first(@rows) || 0
         | 
| 246 246 | 
             
                  @dimensions[1] = @rows.size
         | 
| 247 247 | 
             
                  compact = @rows.compact
         | 
| 248 | 
            -
                  @dimensions[2] = compact.collect do |row| index_of_first row end.compact.min
         | 
| 249 | 
            -
                  @dimensions[3] = compact.collect do |row| row.size end.max
         | 
| 248 | 
            +
                  @dimensions[2] = compact.collect do |row| index_of_first row end.compact.min || 0
         | 
| 249 | 
            +
                  @dimensions[3] = compact.collect do |row| row.size end.max || 0
         | 
| 250 250 | 
             
                  @dimensions
         | 
| 251 251 | 
             
                end
         | 
| 252 252 | 
             
                def shorten ary # :nodoc:
         | 
| Binary file | 
    
        data/test/integration.rb
    CHANGED
    
    | @@ -30,6 +30,25 @@ module Spreadsheet | |
| 30 30 | 
             
                ensure
         | 
| 31 31 | 
             
                  File.delete copy if File.exist? copy
         | 
| 32 32 | 
             
                end
         | 
| 33 | 
            +
                def test_empty_workbook
         | 
| 34 | 
            +
                  path = File.join @data, 'test_empty.xls'
         | 
| 35 | 
            +
                  book = Spreadsheet.open path
         | 
| 36 | 
            +
                  assert_instance_of Excel::Workbook, book
         | 
| 37 | 
            +
                  assert_equal 8, book.biff_version
         | 
| 38 | 
            +
                  assert_equal 'Microsoft Excel 97/2000/XP', book.version_string
         | 
| 39 | 
            +
                  enc = 'UTF-16LE'
         | 
| 40 | 
            +
                  if defined? Encoding
         | 
| 41 | 
            +
                    enc = Encoding.find enc
         | 
| 42 | 
            +
                  end
         | 
| 43 | 
            +
                  assert_equal enc, book.encoding
         | 
| 44 | 
            +
                  assert_equal 21, book.formats.size
         | 
| 45 | 
            +
                  assert_equal 4, book.fonts.size
         | 
| 46 | 
            +
                  assert_equal 0, book.sst.size
         | 
| 47 | 
            +
                  sheet = book.worksheet 0
         | 
| 48 | 
            +
                  assert_equal 0, sheet.row_count
         | 
| 49 | 
            +
                  assert_equal 0, sheet.column_count
         | 
| 50 | 
            +
                  assert_nothing_raised do sheet.inspect end
         | 
| 51 | 
            +
                end
         | 
| 33 52 | 
             
                def test_version_excel97__ooffice__utf16
         | 
| 34 53 | 
             
                  Spreadsheet.client_encoding = 'UTF-16LE'
         | 
| 35 54 | 
             
                  assert_equal 'UTF-16LE', Spreadsheet.client_encoding
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification 
         | 
| 2 2 | 
             
            name: spreadsheet
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            -
              version: 0.6.1. | 
| 4 | 
            +
              version: 0.6.1.5
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors: 
         | 
| 7 7 | 
             
            - Hannes Wyss
         | 
| @@ -9,7 +9,7 @@ autorequire: | |
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 11 |  | 
| 12 | 
            -
            date: 2008-10- | 
| 12 | 
            +
            date: 2008-10-24 00:00:00 +02:00
         | 
| 13 13 | 
             
            default_executable: 
         | 
| 14 14 | 
             
            dependencies: 
         | 
| 15 15 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| @@ -86,6 +86,7 @@ files: | |
| 86 86 | 
             
            - lib/spreadsheet/worksheet.rb
         | 
| 87 87 | 
             
            - lib/spreadsheet/writer.rb
         | 
| 88 88 | 
             
            - test/data/test_copy.xls
         | 
| 89 | 
            +
            - test/data/test_empty.xls
         | 
| 89 90 | 
             
            - test/data/test_version_excel5.xls
         | 
| 90 91 | 
             
            - test/data/test_version_excel95.xls
         | 
| 91 92 | 
             
            - test/data/test_version_excel97.xls
         |