roo 1.10.2 → 1.10.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,4 +1,8 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
3
  # pull reqs from gemspec
4
- gemspec
4
+ gemspec
5
+
6
+ # additional testing libs
7
+ gem 'webmock'
8
+ gem 'shoulda'
@@ -1,32 +1,36 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- roo (1.10.1)
5
- nokogiri (>= 1.5.2)
6
- rubyzip (>= 0.9.6.1)
4
+ roo (1.10.3)
5
+ nokogiri (>= 1.4.0)
6
+ rubyzip (>= 0.9.9)
7
7
  spreadsheet (> 0.6.4)
8
8
 
9
9
  GEM
10
10
  remote: http://rubygems.org/
11
11
  specs:
12
+ addressable (2.3.2)
12
13
  bones (3.8.0)
13
14
  little-plugger (~> 1.1.3)
14
15
  loquacious (~> 1.9.1)
15
16
  rake (>= 0.8.7)
17
+ crack (0.3.1)
16
18
  little-plugger (1.1.3)
17
19
  loquacious (1.9.1)
18
- nokogiri (1.5.5)
19
- nokogiri (1.5.5-java)
20
+ nokogiri (1.5.6)
20
21
  rake (0.9.2.2)
21
- ruby-ole (1.2.11.4)
22
+ ruby-ole (1.2.11.6)
22
23
  rubyzip (0.9.9)
23
24
  shoulda (3.0.1)
24
25
  shoulda-context (~> 1.0.0)
25
26
  shoulda-matchers (~> 1.0.0)
26
27
  shoulda-context (1.0.0)
27
28
  shoulda-matchers (1.0.0)
28
- spreadsheet (0.7.3)
29
+ spreadsheet (0.8.2)
29
30
  ruby-ole (>= 1.0)
31
+ webmock (1.9.0)
32
+ addressable (>= 2.2.7)
33
+ crack (>= 0.1.7)
30
34
 
31
35
  PLATFORMS
32
36
  java
@@ -35,4 +39,5 @@ PLATFORMS
35
39
  DEPENDENCIES
36
40
  bones (>= 3.8.0)
37
41
  roo!
38
- shoulda (~> 3.0)
42
+ shoulda
43
+ webmock
@@ -1,3 +1,18 @@
1
+ == 1.10.3 2013-03-03
2
+
3
+ * 1 bugfix
4
+ * Support both nokogiri 1.5.5 and 1.5.6 (Karsten Richter) https://github.com/Empact/roo/pull/18
5
+
6
+ * 1 enhancement
7
+ * Relax our nokogiri dependency back to 1.4.0, as we have no particular reason
8
+ to require a newer version.
9
+
10
+ == 1.10.2 2013-02-03
11
+
12
+ * 2 bugfixes
13
+ * Support opening URIs with query strings https://github.com/Empact/roo/commit/abf94bdb59cabc16d4f7764025e88e3661983525
14
+ * Support both http: & https: urls https://github.com/Empact/roo/commit/fc5c5899d96dd5f9fbb68125d0efc8ce9be2c7e1
15
+
1
16
  == 1.10.1 2011-11-14
2
17
 
3
18
  * 2 bugfixes
data/lib/roo.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Roo
2
2
 
3
- VERSION = '1.10.2'
3
+ VERSION = '1.10.3'
4
4
 
5
5
  class Spreadsheet
6
6
  class << self
@@ -1,5 +1,4 @@
1
1
  require 'fileutils'
2
- require 'zip/zipfilesystem'
3
2
  require 'date'
4
3
  require 'base64'
5
4
  require 'cgi'
@@ -1,5 +1,4 @@
1
1
  require 'fileutils'
2
- require 'zip/zipfilesystem'
3
2
  require 'date'
4
3
  require 'rubygems'
5
4
  require 'nokogiri'
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'tmpdir'
4
4
  require 'stringio'
5
+ require 'zip/zipfilesystem'
5
6
 
6
7
  # Base class for all other types of spreadsheets
7
8
  class Roo::GenericSpreadsheet
@@ -536,6 +537,10 @@ class Roo::GenericSpreadsheet
536
537
  else
537
538
  raise "unknown file type: #{ext}"
538
539
  end
540
+
541
+ if uri?(filename) && qs_begin = filename.rindex('?')
542
+ filename = filename[0..qs_begin-1]
543
+ end
539
544
  if File.extname(filename).downcase != ext
540
545
  case warning_level
541
546
  when :error
@@ -1,6 +1,5 @@
1
1
  require 'rubygems'
2
2
  require 'fileutils'
3
- require 'zip/zipfilesystem'
4
3
  require 'date'
5
4
  require 'nokogiri'
6
5
  require 'cgi'
@@ -184,7 +183,7 @@ class Roo::Openoffice < Roo::GenericSpreadsheet
184
183
  def sheets
185
184
  return_sheets = []
186
185
  @doc.xpath("//*[local-name()='table']").each do |sheet|
187
- return_sheets << sheet['name']
186
+ return_sheets << sheet.attributes["name"].value
188
187
  end
189
188
  return_sheets
190
189
  end
@@ -271,7 +270,7 @@ class Roo::Openoffice < Roo::GenericSpreadsheet
271
270
  # read the version of the OO-Version
272
271
  def oo_version
273
272
  @doc.xpath("//*[local-name()='document-content']").each do |office|
274
- @officeversion = office.attributes['version'].to_s
273
+ @officeversion = attr(office,'version')
275
274
  end
276
275
  end
277
276
 
@@ -299,10 +298,10 @@ class Roo::Openoffice < Roo::GenericSpreadsheet
299
298
  @cell[sheet][key] = str_v
300
299
  when :date
301
300
  #TODO: if table_cell.attributes['date-value'].size != "XXXX-XX-XX".size
302
- if table_cell.attributes['date-value'].to_s.size != "XXXX-XX-XX".size
301
+ if attr(table_cell,'date-value').size != "XXXX-XX-XX".size
303
302
  #-- dann ist noch eine Uhrzeit vorhanden
304
303
  #-- "1961-11-21T12:17:18"
305
- @cell[sheet][key] = DateTime.parse(table_cell.attributes['date-value'].to_s)
304
+ @cell[sheet][key] = DateTime.parse(attr(table_cell,'date-value').to_s)
306
305
  @cell_type[sheet][key] = :datetime
307
306
  else
308
307
  @cell[sheet][key] = table_cell.attributes['date-value']
@@ -328,7 +327,7 @@ class Roo::Openoffice < Roo::GenericSpreadsheet
328
327
  sheet_found = false
329
328
 
330
329
  @doc.xpath("//*[local-name()='table']").each do |ws|
331
- if sheet == ws['name']
330
+ if sheet == attr(ws,'name')
332
331
  sheet_found = true
333
332
  col = 1
334
333
  row = 1
@@ -338,15 +337,15 @@ class Roo::Openoffice < Roo::GenericSpreadsheet
338
337
  @style_defaults[sheet] << table_element.attributes['default-cell-style-name']
339
338
  when 'table-row'
340
339
  if table_element.attributes['number-rows-repeated']
341
- skip_row = table_element.attributes['number-rows-repeated'].to_s.to_i
340
+ skip_row = attr(table_element,'number-rows-repeated').to_s.to_i
342
341
  row = row + skip_row - 1
343
342
  end
344
343
  table_element.children.each do |cell|
345
- skip_col = cell['number-columns-repeated']
346
- formula = cell['formula']
347
- value_type = cell['value-type']
348
- v = cell['value']
349
- style_name = cell['style-name']
344
+ skip_col = attr(cell, 'number-columns-repeated')
345
+ formula = attr(cell,'formula')
346
+ value_type = attr(cell,'value-type')
347
+ v = attr(cell,'value')
348
+ style_name = attr(cell,'style-name')
350
349
  case value_type
351
350
  when 'string'
352
351
  str_v = ''
@@ -407,7 +406,7 @@ class Roo::Openoffice < Roo::GenericSpreadsheet
407
406
  when 'float'
408
407
  #
409
408
  when 'boolean'
410
- v = cell.attributes['boolean-value'].to_s
409
+ v = attr(cell,'boolean-value').to_s
411
410
  else
412
411
  # raise "unknown type #{value_type}"
413
412
  end
@@ -449,8 +448,8 @@ class Roo::Openoffice < Roo::GenericSpreadsheet
449
448
  #-
450
449
  # $Sheet1.$C$5
451
450
  #+
452
- name = ne.attribute('name').to_s
453
- sheetname,coords = ne.attribute('cell-range-address').to_s.split('.$')
451
+ name = attr(ne,'name').to_s
452
+ sheetname,coords = attr(ne,'cell-range-address').to_s.split('.$')
454
453
  col, row = coords.split('$')
455
454
  sheetname = sheetname[1..-1] if sheetname[0,1] == '$'
456
455
  [name, [sheetname,row,col]]
@@ -461,12 +460,12 @@ class Roo::Openoffice < Roo::GenericSpreadsheet
461
460
  @style_definitions['Default'] = Roo::Openoffice::Font.new
462
461
  style_elements.each do |style|
463
462
  next unless style.name == 'style'
464
- style_name = style.attributes['name']
463
+ style_name = attr(style,'name')
465
464
  style.each do |properties|
466
465
  font = Roo::Openoffice::Font.new
467
- font.bold = properties.attributes['font-weight']
468
- font.italic = properties.attributes['font-style']
469
- font.underline = properties.attributes['text-underline-style']
466
+ font.bold = attr(properties,'font-weight')
467
+ font.italic = attr(properties,'font-style')
468
+ font.underline = attr(properties,'text-underline-style')
470
469
  @style_definitions[style_name] = font
471
470
  end
472
471
  end
@@ -507,6 +506,14 @@ class Roo::Openoffice < Roo::GenericSpreadsheet
507
506
  result
508
507
  end
509
508
 
509
+
510
+ private
511
+ def attr(node, attr_name)
512
+ if node.attributes[attr_name]
513
+ node.attributes[attr_name].value
514
+ end
515
+ end
516
+
510
517
  end # class
511
518
 
512
519
  # Libreoffice is just an alias for Roo::Openoffice class
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "roo"
5
- s.version = "1.10.2"
5
+ s.version = "1.10.3"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Thomas Preymesser", "Hugh McGowan", "Ben Woosley"]
9
- s.date = "2012-11-05"
9
+ s.date = "2013-03-04"
10
10
  s.description = "Roo can access the contents of various spreadsheet files. It can handle\n* Openoffice\n* Excel\n* Google spreadsheets\n* Excelx\n* Libreoffice\n* CSV"
11
11
  s.email = "thopre@gmail.com"
12
12
  s.executables = ["roo"]
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
16
16
  s.rdoc_options = ["--main", "README.txt"]
17
17
  s.require_paths = ["lib"]
18
18
  s.rubyforge_project = "roo"
19
- s.rubygems_version = "1.8.23"
19
+ s.rubygems_version = "1.8.24"
20
20
  s.summary = "Roo can access the contents of various spreadsheet files."
21
21
  s.test_files = ["test/test_generic_spreadsheet.rb", "test/test_helper.rb", "test/test_roo.rb"]
22
22
 
@@ -25,18 +25,18 @@ Gem::Specification.new do |s|
25
25
 
26
26
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
27
27
  s.add_runtime_dependency(%q<spreadsheet>, ["> 0.6.4"])
28
- s.add_runtime_dependency(%q<nokogiri>, [">= 1.5.5"])
28
+ s.add_runtime_dependency(%q<nokogiri>, [">= 1.4.0"])
29
29
  s.add_runtime_dependency(%q<rubyzip>, [">= 0.9.9"])
30
30
  s.add_development_dependency(%q<bones>, [">= 3.8.0"])
31
31
  else
32
32
  s.add_dependency(%q<spreadsheet>, ["> 0.6.4"])
33
- s.add_dependency(%q<nokogiri>, [">= 1.5.5"])
33
+ s.add_dependency(%q<nokogiri>, [">= 1.4.0"])
34
34
  s.add_dependency(%q<rubyzip>, [">= 0.9.9"])
35
35
  s.add_dependency(%q<bones>, [">= 3.8.0"])
36
36
  end
37
37
  else
38
38
  s.add_dependency(%q<spreadsheet>, ["> 0.6.4"])
39
- s.add_dependency(%q<nokogiri>, [">= 1.5.5"])
39
+ s.add_dependency(%q<nokogiri>, [">= 1.4.0"])
40
40
  s.add_dependency(%q<rubyzip>, [">= 0.9.9"])
41
41
  s.add_dependency(%q<bones>, [">= 3.8.0"])
42
42
  end
@@ -7,6 +7,7 @@ require 'fileutils'
7
7
  require 'timeout'
8
8
  require 'logger'
9
9
  require 'date'
10
+ require 'webmock/test_unit'
10
11
 
11
12
  # require gem files
12
13
  require File.dirname(__FILE__) + '/../lib/roo'
@@ -186,4 +187,4 @@ class Test::Unit::TestCase
186
187
  # )
187
188
  # end
188
189
  # end
189
- end
190
+ end
@@ -2684,6 +2684,22 @@ This attached file is the newer format of Microsoft Excel (.xlsx).
2684
2684
  end
2685
2685
  end
2686
2686
 
2687
+ def test_open_from_uri_with_query_string
2688
+ dir = File.expand_path("#{File.dirname __FILE__}/files")
2689
+ { xls: [EXCEL, Roo::Excel],
2690
+ xlsx: [EXCELX, Roo::Excelx],
2691
+ ods: [OPENOFFICE, Roo::Openoffice]}.each do |extension, (flag, type)|
2692
+ if flag
2693
+ file = "#{dir}/simple_spreadsheet.#{extension}"
2694
+ url = "http://test.example.com/simple_spreadsheet.#{extension}?query-param=value"
2695
+ stub_request(:any, url).to_return(body: File.read(file))
2696
+ spreadsheet = type.new(url)
2697
+ spreadsheet.default_sheet = spreadsheet.sheets.first
2698
+ assert_equal 'Task 1', spreadsheet.cell('f', 4)
2699
+ end
2700
+ end
2701
+ end
2702
+
2687
2703
  def test_to_ascii_openoffice #file does not exist
2688
2704
  local_only do
2689
2705
  with_each_spreadsheet(:name=>'verysimple_spreadsheet', :format=>:openoffice) do |oo|
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: 1.10.2
4
+ version: 1.10.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2013-02-03 00:00:00.000000000 Z
14
+ date: 2013-03-04 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: spreadsheet
@@ -252,12 +252,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
252
252
  - - ! '>='
253
253
  - !ruby/object:Gem::Version
254
254
  version: '0'
255
+ segments:
256
+ - 0
257
+ hash: 888687487029488184
255
258
  required_rubygems_version: !ruby/object:Gem::Requirement
256
259
  none: false
257
260
  requirements:
258
261
  - - ! '>='
259
262
  - !ruby/object:Gem::Version
260
263
  version: '0'
264
+ segments:
265
+ - 0
266
+ hash: 888687487029488184
261
267
  requirements: []
262
268
  rubyforge_project: roo
263
269
  rubygems_version: 1.8.24