roo 2.3.1 → 2.3.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cd058c382f97cefc8605bb1fdf40a2900312d6bc
4
- data.tar.gz: 4a62144cc33be58fbab07eababe5d6e8a6205c30
3
+ metadata.gz: a2e51de2c40930cef415563182257a853b10978e
4
+ data.tar.gz: 3b17c8cfb99d1a16778e20289fea7ae9b1ed88a5
5
5
  SHA512:
6
- metadata.gz: 626854d9aea329f2f2113a1fba53d9981d09ccb520c5ffec06936f996f786874a2b437e3fb1125151f4c3c2248006f3b6ca4fc1e6ddb758e96b36c4ebcbe08d1
7
- data.tar.gz: 1432ebdeef169aad8eb64982c612da9cff907743a2512b594ded3ebff2823428a10e9ec1a326561ab6e0c68d9bdb39b1abe15655e797304df51dde68e89e437b
6
+ metadata.gz: a8f57baddedd100e461fb350814c39dfe765a89a911f2cda0579281612cf37ca95fd9d0459f0572a2241d2e99871045dd5f4573d20364827f756b875a01484b4
7
+ data.tar.gz: 87012bc658fbc668b7e655de16b339034cf5887f3e0b3ceb468626e9203c22fd0d05e7d1bbea243525cb7c27e61e2af296f1804bc58def990dc4bf1f95463cd5
@@ -1,4 +1,12 @@
1
- ## [2.3.1] - 2015-01-08
1
+ ## [2.3.2] 2016-02-18
2
+ ### Fixed
3
+ - Handle url with long query params (ex. S3 secure url) [302](https://github.com/roo-rb/roo/pull/302)
4
+ - Allow streaming for Roo::CSV [297](https://github.com/roo-rb/roo/pull/297)
5
+ - Export Fixnums to Added csv [295](https://github.com/roo-rb/roo/pull/295)
6
+ - Removed various Ruby warnings [289](https://github.com/roo-rb/roo/pull/289)
7
+ - Fix incorrect example result in Readme.md [293](https://github.com/roo-rb/roo/pull/293)
8
+
9
+ ## [2.3.1] - 2016-01-08
2
10
  ### Fixed
3
11
  - Properly parse sci-notation number like 1E-3 [#288](https://github.com/roo-rb/roo/pull/288)
4
12
  - Include all tests in default rake run [#283](https://github.com/roo-rb/roo/pull/283)
data/README.md CHANGED
@@ -113,8 +113,8 @@ end
113
113
  Use ``sheet.parse`` to return an array of rows. Column names can be a ``String`` or a ``Regexp``.
114
114
 
115
115
  ```ruby
116
- sheet.parse(:id => /UPC|SKU/,:qty => /ATS*\sATP\s*QTY\z/)
117
- # => [{:upc => 727880013358, :qty => 12}, ...]
116
+ sheet.parse(id: /UPC|SKU/, qty: /ATS*\sATP\s*QTY\z/)
117
+ # => [{:id => 727880013358, :qty => 12}, ...]
118
118
  ```
119
119
 
120
120
  Use the ``:header_search`` option to locate the header row and assign the header names.
@@ -126,7 +126,7 @@ sheet.parse(header_search: [/UPC*SKU/,/ATS*\sATP\s*QTY\z/])
126
126
  Use the ``:clean`` option to strip out control characters and surrounding white space.
127
127
 
128
128
  ```ruby
129
- sheet.parse(:clean => true)
129
+ sheet.parse(clean: true)
130
130
  ```
131
131
 
132
132
  ### Exporting spreadsheets
@@ -209,7 +209,7 @@ Roo::OpenOffice has support for encrypted OpenOffice spreadsheets.
209
209
 
210
210
  ```ruby
211
211
  # Load an encrypted OpenOffice Spreadsheet
212
- ods = Roo::OpenOffice.new("myspreadsheet.ods", :password => "password")
212
+ ods = Roo::OpenOffice.new("myspreadsheet.ods", password: "password")
213
213
  ```
214
214
 
215
215
  ``Roo::OpenOffice`` can access celltype, comments, font information, formulas and labels.
@@ -535,6 +535,16 @@ class Roo::Base
535
535
  initialize(@filename)
536
536
  end
537
537
 
538
+ def find_basename(filename)
539
+ if uri?(filename)
540
+ require 'uri'
541
+ uri = URI::parse filename
542
+ File.basename(uri.path)
543
+ elsif !is_stream?(filename)
544
+ File.basename(filename)
545
+ end
546
+ end
547
+
538
548
  def make_tmpdir(prefix = nil, root = nil, &block)
539
549
  prefix = "#{TEMP_PREFIX}#{prefix}"
540
550
 
@@ -599,7 +609,7 @@ class Roo::Base
599
609
 
600
610
  def download_uri(uri, tmpdir)
601
611
  require 'open-uri'
602
- tempfilename = File.join(tmpdir, File.basename(uri))
612
+ tempfilename = File.join(tmpdir, find_basename(uri))
603
613
  begin
604
614
  File.open(tempfilename, 'wb') do |file|
605
615
  open(uri, 'User-Agent' => "Ruby/#{RUBY_VERSION}") do |net|
@@ -701,6 +711,8 @@ class Roo::Base
701
711
  case onecell
702
712
  when String
703
713
  %("#{onecell.gsub('"', '""')}") unless onecell.empty?
714
+ when Fixnum
715
+ onecell.to_s
704
716
  when Float
705
717
  if onecell == onecell.to_i
706
718
  onecell.to_i.to_s
@@ -60,6 +60,8 @@ class Roo::CSV < Roo::Base
60
60
  tmp_filename = download_uri(filename, tmpdir)
61
61
  CSV.foreach(tmp_filename, options, &block)
62
62
  end
63
+ elsif is_stream?(filename_or_stream)
64
+ CSV.new(filename_or_stream, options).each(&block)
63
65
  else
64
66
  CSV.foreach(filename, options, &block)
65
67
  end
@@ -117,4 +119,6 @@ class Roo::CSV < Roo::Base
117
119
 
118
120
  @cleaned[sheet] = true
119
121
  end
122
+
123
+ alias_method :filename_or_stream, :filename
120
124
  end
@@ -39,7 +39,7 @@ module Roo
39
39
 
40
40
  unless is_stream?(filename_or_stream)
41
41
  file_type_check(filename_or_stream, %w[.xlsx .xlsm], 'an Excel 2007', file_warning, packed)
42
- basename = File.basename(filename_or_stream)
42
+ basename = find_basename(filename_or_stream)
43
43
  end
44
44
 
45
45
  @tmpdir = make_tmpdir(basename, options[:tmpdir_root])
@@ -426,20 +426,6 @@ module Roo
426
426
  end
427
427
  end
428
428
 
429
- # NOTE: To reduce memory, styles, shared_strings, workbook can be class
430
- # variables in a Shared module.
431
- def styles
432
- @styles ||= Styles.new(File.join(@tmpdir, 'roo_styles.xml'))
433
- end
434
-
435
- def shared_strings
436
- @shared_strings ||= SharedStrings.new(File.join(@tmpdir, 'roo_sharedStrings.xml'))
437
- end
438
-
439
- def workbook
440
- @workbook ||= Workbook.new(File.join(@tmpdir, 'roo_workbook.xml'))
441
- end
442
-
443
429
  def safe_send(object, method, *args)
444
430
  object.send(method, *args) if object && object.respond_to?(method)
445
431
  end
@@ -11,7 +11,7 @@ require 'roo/excelx/cell/time'
11
11
  module Roo
12
12
  class Excelx
13
13
  class Cell
14
- attr_reader :type, :formula, :value, :excelx_type, :excelx_value, :style, :hyperlink, :coordinate
14
+ attr_reader :formula, :value, :excelx_type, :excelx_value, :style, :hyperlink, :coordinate
15
15
  attr_writer :value
16
16
 
17
17
  # DEPRECATED: Please use Cell.create_cell instead.
@@ -19,7 +19,7 @@ module Roo
19
19
 
20
20
  @only_visible_sheets = options[:only_visible_sheets]
21
21
  file_type_check(filename, '.ods', 'an Roo::OpenOffice', file_warning, packed)
22
- @tmpdir = make_tmpdir(File.basename(filename), options[:tmpdir_root])
22
+ @tmpdir = make_tmpdir(find_basename(filename), options[:tmpdir_root])
23
23
  @filename = local_filename(filename, @tmpdir, packed)
24
24
  # TODO: @cells_read[:default] = false
25
25
  open_oo_file(options)
@@ -285,7 +285,6 @@ module Roo
285
285
  algorithm_node['manifest:initialisation-vector']
286
286
  )
287
287
  key_derivation_name = key_derivation_node['manifest:key-derivation-name']
288
- key_size = key_derivation_node['manifest:key-size'].to_i
289
288
  iteration_count = key_derivation_node['manifest:iteration-count'].to_i
290
289
  salt = Base64.decode64(key_derivation_node['manifest:salt'])
291
290
 
@@ -294,10 +293,8 @@ module Roo
294
293
  start_key_generation_node[
295
294
  'manifest:start-key-generation-name'
296
295
  ]
297
- key_generation_size = start_key_generation_node['manifest:key-size'].to_i
298
296
 
299
297
  hashed_password = password
300
- key = nil
301
298
 
302
299
  if key_generation_name == 'http://www.w3.org/2000/09/xmldsig#sha256'
303
300
 
@@ -1,3 +1,3 @@
1
1
  module Roo
2
- VERSION = '2.3.1'
2
+ VERSION = '2.3.2'
3
3
  end
@@ -10,6 +10,13 @@ describe Roo::CSV do
10
10
  end
11
11
  end
12
12
 
13
+ describe '.new with stream' do
14
+ let(:csv) { Roo::CSV.new(File.read(path)) }
15
+ it 'creates an instance' do
16
+ expect(csv).to be_a(Roo::CSV)
17
+ end
18
+ end
19
+
13
20
  describe '#parse' do
14
21
  subject do
15
22
  csv.parse(options)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roo
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.1
4
+ version: 2.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Preymesser
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2016-01-08 00:00:00.000000000 Z
15
+ date: 2016-02-19 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: nokogiri
@@ -185,9 +185,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
185
185
  version: '0'
186
186
  requirements: []
187
187
  rubyforge_project:
188
- rubygems_version: 2.4.5
188
+ rubygems_version: 2.4.5.1
189
189
  signing_key:
190
190
  specification_version: 4
191
191
  summary: Roo can access the contents of various spreadsheet files.
192
192
  test_files: []
193
- has_rdoc: