roo 1.13.2 → 2.0.0beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (171) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +7 -0
  3. data/.simplecov +4 -0
  4. data/.travis.yml +13 -0
  5. data/CHANGELOG +21 -0
  6. data/Gemfile +16 -10
  7. data/Guardfile +24 -0
  8. data/LICENSE +3 -1
  9. data/README.md +254 -0
  10. data/Rakefile +23 -23
  11. data/examples/roo_soap_client.rb +28 -31
  12. data/examples/roo_soap_server.rb +4 -6
  13. data/examples/write_me.rb +9 -10
  14. data/lib/roo.rb +18 -24
  15. data/lib/roo/base.rb +303 -388
  16. data/lib/roo/csv.rb +120 -113
  17. data/lib/roo/excelx.rb +452 -484
  18. data/lib/roo/excelx/comments.rb +24 -0
  19. data/lib/roo/excelx/extractor.rb +20 -0
  20. data/lib/roo/excelx/relationships.rb +26 -0
  21. data/lib/roo/excelx/shared_strings.rb +40 -0
  22. data/lib/roo/excelx/sheet_doc.rb +202 -0
  23. data/lib/roo/excelx/styles.rb +62 -0
  24. data/lib/roo/excelx/workbook.rb +59 -0
  25. data/lib/roo/font.rb +17 -0
  26. data/lib/roo/libre_office.rb +5 -0
  27. data/lib/roo/link.rb +15 -0
  28. data/lib/roo/{openoffice.rb → open_office.rb} +678 -496
  29. data/lib/roo/spreadsheet.rb +20 -23
  30. data/lib/roo/utils.rb +78 -0
  31. data/lib/roo/version.rb +3 -0
  32. data/roo.gemspec +20 -204
  33. data/spec/lib/roo/base_spec.rb +1 -4
  34. data/spec/lib/roo/csv_spec.rb +21 -13
  35. data/spec/lib/roo/excelx/format_spec.rb +7 -6
  36. data/spec/lib/roo/excelx_spec.rb +388 -11
  37. data/spec/lib/roo/libreoffice_spec.rb +16 -6
  38. data/spec/lib/roo/openoffice_spec.rb +2 -8
  39. data/spec/lib/roo/spreadsheet_spec.rb +40 -12
  40. data/spec/lib/roo/utils_spec.rb +106 -0
  41. data/spec/spec_helper.rb +2 -1
  42. data/test/test_generic_spreadsheet.rb +19 -67
  43. data/test/test_helper.rb +9 -56
  44. data/test/test_roo.rb +252 -477
  45. metadata +63 -302
  46. data/Gemfile.lock +0 -78
  47. data/README.markdown +0 -126
  48. data/VERSION +0 -1
  49. data/lib/roo/excel.rb +0 -355
  50. data/lib/roo/excel2003xml.rb +0 -300
  51. data/lib/roo/google.rb +0 -292
  52. data/lib/roo/roo_rails_helper.rb +0 -83
  53. data/lib/roo/worksheet.rb +0 -18
  54. data/spec/lib/roo/excel2003xml_spec.rb +0 -15
  55. data/spec/lib/roo/excel_spec.rb +0 -17
  56. data/spec/lib/roo/google_spec.rb +0 -64
  57. data/test/files/1900_base.xls +0 -0
  58. data/test/files/1900_base.xlsx +0 -0
  59. data/test/files/1904_base.xls +0 -0
  60. data/test/files/1904_base.xlsx +0 -0
  61. data/test/files/Bibelbund.csv +0 -3741
  62. data/test/files/Bibelbund.ods +0 -0
  63. data/test/files/Bibelbund.xls +0 -0
  64. data/test/files/Bibelbund.xlsx +0 -0
  65. data/test/files/Bibelbund.xml +0 -62518
  66. data/test/files/Bibelbund1.ods +0 -0
  67. data/test/files/Pfand_from_windows_phone.xlsx +0 -0
  68. data/test/files/bad_excel_date.xls +0 -0
  69. data/test/files/bbu.ods +0 -0
  70. data/test/files/bbu.xls +0 -0
  71. data/test/files/bbu.xlsx +0 -0
  72. data/test/files/bbu.xml +0 -152
  73. data/test/files/bode-v1.ods.zip +0 -0
  74. data/test/files/bode-v1.xls.zip +0 -0
  75. data/test/files/boolean.csv +0 -2
  76. data/test/files/boolean.ods +0 -0
  77. data/test/files/boolean.xls +0 -0
  78. data/test/files/boolean.xlsx +0 -0
  79. data/test/files/boolean.xml +0 -112
  80. data/test/files/borders.ods +0 -0
  81. data/test/files/borders.xls +0 -0
  82. data/test/files/borders.xlsx +0 -0
  83. data/test/files/borders.xml +0 -144
  84. data/test/files/bug-numbered-sheet-names.xlsx +0 -0
  85. data/test/files/bug-row-column-fixnum-float.xls +0 -0
  86. data/test/files/bug-row-column-fixnum-float.xml +0 -127
  87. data/test/files/comments.ods +0 -0
  88. data/test/files/comments.xls +0 -0
  89. data/test/files/comments.xlsx +0 -0
  90. data/test/files/csvtypes.csv +0 -1
  91. data/test/files/datetime.ods +0 -0
  92. data/test/files/datetime.xls +0 -0
  93. data/test/files/datetime.xlsx +0 -0
  94. data/test/files/datetime.xml +0 -142
  95. data/test/files/datetime_floatconv.xls +0 -0
  96. data/test/files/datetime_floatconv.xml +0 -148
  97. data/test/files/dreimalvier.ods +0 -0
  98. data/test/files/emptysheets.ods +0 -0
  99. data/test/files/emptysheets.xls +0 -0
  100. data/test/files/emptysheets.xlsx +0 -0
  101. data/test/files/emptysheets.xml +0 -105
  102. data/test/files/excel2003.xml +0 -21140
  103. data/test/files/false_encoding.xls +0 -0
  104. data/test/files/false_encoding.xml +0 -132
  105. data/test/files/file_item_error.xlsx +0 -0
  106. data/test/files/formula.ods +0 -0
  107. data/test/files/formula.xls +0 -0
  108. data/test/files/formula.xlsx +0 -0
  109. data/test/files/formula.xml +0 -134
  110. data/test/files/formula_parse_error.xls +0 -0
  111. data/test/files/formula_parse_error.xml +0 -1833
  112. data/test/files/formula_string_error.xlsx +0 -0
  113. data/test/files/html-escape.ods +0 -0
  114. data/test/files/link.xls +0 -0
  115. data/test/files/link.xlsx +0 -0
  116. data/test/files/matrix.ods +0 -0
  117. data/test/files/matrix.xls +0 -0
  118. data/test/files/named_cells.ods +0 -0
  119. data/test/files/named_cells.xls +0 -0
  120. data/test/files/named_cells.xlsx +0 -0
  121. data/test/files/no_spreadsheet_file.txt +0 -1
  122. data/test/files/numbers1.csv +0 -18
  123. data/test/files/numbers1.ods +0 -0
  124. data/test/files/numbers1.xls +0 -0
  125. data/test/files/numbers1.xlsx +0 -0
  126. data/test/files/numbers1.xml +0 -312
  127. data/test/files/numeric-link.xlsx +0 -0
  128. data/test/files/only_one_sheet.ods +0 -0
  129. data/test/files/only_one_sheet.xls +0 -0
  130. data/test/files/only_one_sheet.xlsx +0 -0
  131. data/test/files/only_one_sheet.xml +0 -67
  132. data/test/files/paragraph.ods +0 -0
  133. data/test/files/paragraph.xls +0 -0
  134. data/test/files/paragraph.xlsx +0 -0
  135. data/test/files/paragraph.xml +0 -127
  136. data/test/files/prova.xls +0 -0
  137. data/test/files/ric.ods +0 -0
  138. data/test/files/simple_spreadsheet.ods +0 -0
  139. data/test/files/simple_spreadsheet.xls +0 -0
  140. data/test/files/simple_spreadsheet.xlsx +0 -0
  141. data/test/files/simple_spreadsheet.xml +0 -225
  142. data/test/files/simple_spreadsheet_from_italo.ods +0 -0
  143. data/test/files/simple_spreadsheet_from_italo.xls +0 -0
  144. data/test/files/simple_spreadsheet_from_italo.xml +0 -242
  145. data/test/files/so_datetime.csv +0 -7
  146. data/test/files/style.ods +0 -0
  147. data/test/files/style.xls +0 -0
  148. data/test/files/style.xlsx +0 -0
  149. data/test/files/style.xml +0 -154
  150. data/test/files/time-test.csv +0 -2
  151. data/test/files/time-test.ods +0 -0
  152. data/test/files/time-test.xls +0 -0
  153. data/test/files/time-test.xlsx +0 -0
  154. data/test/files/time-test.xml +0 -131
  155. data/test/files/type_excel.ods +0 -0
  156. data/test/files/type_excel.xlsx +0 -0
  157. data/test/files/type_excelx.ods +0 -0
  158. data/test/files/type_excelx.xls +0 -0
  159. data/test/files/type_openoffice.xls +0 -0
  160. data/test/files/type_openoffice.xlsx +0 -0
  161. data/test/files/whitespace.ods +0 -0
  162. data/test/files/whitespace.xls +0 -0
  163. data/test/files/whitespace.xlsx +0 -0
  164. data/test/files/whitespace.xml +0 -184
  165. data/test/rm_sub_test.rb +0 -12
  166. data/test/rm_test.rb +0 -7
  167. data/website/index.html +0 -385
  168. data/website/index.txt +0 -423
  169. data/website/javascripts/rounded_corners_lite.inc.js +0 -285
  170. data/website/stylesheets/screen.css +0 -130
  171. data/website/template.rhtml +0 -48
@@ -1,32 +1,29 @@
1
1
  module Roo
2
2
  class Spreadsheet
3
3
  class << self
4
- def open(file, options = {})
5
- file = File === file ? file.path : file
4
+ def open(path, options = {})
5
+ path = path.respond_to?(:path) ? path.path : path
6
+ extension = extension_for(path, options)
6
7
 
7
- extension =
8
- if options[:extension]
9
- options[:file_warning] = :ignore
10
- ".#{options[:extension]}".gsub(/[.]+/, ".")
11
- else
12
- File.extname(URI.parse(file).path)
13
- end
8
+ begin
9
+ Roo::CLASS_FOR_EXTENSION.fetch(extension).new(path, options)
10
+ rescue KeyError
11
+ raise ArgumentError,
12
+ "Can't detect the type of #{path} - please use the :extension option to declare its type."
13
+ end
14
+ end
14
15
 
15
- case extension.downcase
16
- when '.xls'
17
- Roo::Excel.new(file, options)
18
- when '.xlsx'
19
- Roo::Excelx.new(file, options)
20
- when '.ods'
21
- Roo::OpenOffice.new(file, options)
22
- when '.xml'
23
- Roo::Excel2003XML.new(file, options)
24
- when ''
25
- Roo::Google.new(file, options)
26
- when '.csv'
27
- Roo::CSV.new(file, options)
16
+ def extension_for(path, options)
17
+ case (extension = options.delete(:extension))
18
+ when ::Symbol
19
+ options[:file_warning] = :ignore
20
+ extension
21
+ when ::String
22
+ options[:file_warning] = :ignore
23
+ extension.tr('.', '').downcase.to_sym
28
24
  else
29
- raise ArgumentError, "Don't know how to open file #{file}"
25
+ res = ::File.extname((path =~ ::URI.regexp) ? ::URI.parse(::URI.encode(path)).path : path)
26
+ res.tr('.', '').downcase.to_sym
30
27
  end
31
28
  end
32
29
  end
@@ -0,0 +1,78 @@
1
+ module Roo
2
+ module Utils
3
+ extend self
4
+
5
+ def split_coordinate(str)
6
+ @split_coordinate ||= {}
7
+
8
+ @split_coordinate[str] ||= begin
9
+ letter, number = split_coord(str)
10
+ x = letter_to_number(letter)
11
+ y = number
12
+ [y, x]
13
+ end
14
+ end
15
+
16
+ alias_method :ref_to_key, :split_coordinate
17
+
18
+ def split_coord(s)
19
+ if s =~ /([a-zA-Z]+)([0-9]+)/
20
+ letter = Regexp.last_match[1]
21
+ number = Regexp.last_match[2].to_i
22
+ else
23
+ fail ArgumentError
24
+ end
25
+ [letter, number]
26
+ end
27
+
28
+ # convert a number to something like 'AB' (1 => 'A', 2 => 'B', ...)
29
+ def number_to_letter(num)
30
+ results = []
31
+ num = num.to_i
32
+
33
+ while (num > 0)
34
+ mod = (num - 1) % 26
35
+ results = [(65 + mod).chr] + results
36
+ num = ((num - mod) / 26)
37
+ end
38
+
39
+ results.join
40
+ end
41
+
42
+ def letter_to_number(letters)
43
+ @letter_to_number ||= {}
44
+ @letter_to_number[letters] ||= begin
45
+ result = 0
46
+
47
+ # :bytes method returns an enumerator in 1.9.3 and an array in 2.0+
48
+ letters.bytes.to_a.map{|b| b > 96 ? b - 96 : b - 64 }.reverse.each_with_index{ |num, i| result += num * 26 ** i }
49
+
50
+ result
51
+ end
52
+ end
53
+
54
+ # Compute upper bound for cells in a given cell range.
55
+ def num_cells_in_range(str)
56
+ cells = str.split(':')
57
+ return 1 if cells.count == 1
58
+ raise ArgumentError.new("invalid range string: #{str}. Supported range format 'A1:B2'") if cells.count != 2
59
+ x1, y1 = split_coordinate(cells[0])
60
+ x2, y2 = split_coordinate(cells[1])
61
+ (x2 - (x1 - 1)) * (y2 - (y1 - 1))
62
+ end
63
+
64
+ def load_xml(path)
65
+ ::File.open(path, 'rb') do |file|
66
+ ::Nokogiri::XML(file)
67
+ end
68
+ end
69
+
70
+ # Yield each element of a given type ('row', 'c', etc.) to caller
71
+ def each_element(path, elements)
72
+ Nokogiri::XML::Reader(::File.open(path, 'rb'), nil, nil, Nokogiri::XML::ParseOptions::NOBLANKS).each do |node|
73
+ next unless node.node_type == Nokogiri::XML::Reader::TYPE_ELEMENT && Array(elements).include?(node.name)
74
+ yield Nokogiri::XML(node.outer_xml).root if block_given?
75
+ end
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,3 @@
1
+ module Roo
2
+ VERSION = "2.0.0beta1"
3
+ end
@@ -1,209 +1,25 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
- # -*- encoding: utf-8 -*-
1
+ # encoding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'roo/version'
5
5
 
6
- Gem::Specification.new do |s|
7
- s.name = "roo"
8
- s.version = "1.13.2"
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'roo'
8
+ spec.version = Roo::VERSION
9
+ spec.authors = ['Thomas Preymesser', 'Hugh McGowan', 'Ben Woosley', 'Oleksandr Simonov']
10
+ spec.email = ['ruby.ruby.ruby.roo@gmail.com', 'oleksandr@simonov.me']
11
+ spec.summary = 'Roo can access the contents of various spreadsheet files.'
12
+ spec.description = "Roo can access the contents of various spreadsheet files. It can handle\n* OpenOffice\n* Excelx\n* LibreOffice\n* CSV"
13
+ spec.homepage = 'http://github.com/roo-rb/roo'
14
+ spec.license = 'MIT'
9
15
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Thomas Preymesser", "Hugh McGowan", "Ben Woosley"]
12
- s.date = "2013-12-23"
13
- 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"
14
- s.email = "ruby.ruby.ruby.roo@gmail.com"
15
- s.extra_rdoc_files = [
16
- "LICENSE",
17
- "README.markdown"
18
- ]
19
- s.files = [
20
- "CHANGELOG",
21
- "Gemfile",
22
- "Gemfile.lock",
23
- "LICENSE",
24
- "README.markdown",
25
- "Rakefile",
26
- "VERSION",
27
- "examples/roo_soap_client.rb",
28
- "examples/roo_soap_server.rb",
29
- "examples/write_me.rb",
30
- "lib/roo.rb",
31
- "lib/roo/base.rb",
32
- "lib/roo/csv.rb",
33
- "lib/roo/excel.rb",
34
- "lib/roo/excel2003xml.rb",
35
- "lib/roo/excelx.rb",
36
- "lib/roo/google.rb",
37
- "lib/roo/openoffice.rb",
38
- "lib/roo/roo_rails_helper.rb",
39
- "lib/roo/spreadsheet.rb",
40
- "lib/roo/worksheet.rb",
41
- "roo.gemspec",
42
- "scripts/txt2html",
43
- "spec/fixtures/vcr_cassettes/google_drive.yml",
44
- "spec/fixtures/vcr_cassettes/google_drive_access_token.yml",
45
- "spec/fixtures/vcr_cassettes/google_drive_set.yml",
46
- "spec/lib/roo/base_spec.rb",
47
- "spec/lib/roo/csv_spec.rb",
48
- "spec/lib/roo/excel2003xml_spec.rb",
49
- "spec/lib/roo/excel_spec.rb",
50
- "spec/lib/roo/excelx/format_spec.rb",
51
- "spec/lib/roo/excelx_spec.rb",
52
- "spec/lib/roo/google_spec.rb",
53
- "spec/lib/roo/libreoffice_spec.rb",
54
- "spec/lib/roo/openoffice_spec.rb",
55
- "spec/lib/roo/spreadsheet_spec.rb",
56
- "spec/spec_helper.rb",
57
- "test/all_ss.rb",
58
- "test/files/1900_base.xls",
59
- "test/files/1900_base.xlsx",
60
- "test/files/1904_base.xls",
61
- "test/files/1904_base.xlsx",
62
- "test/files/Bibelbund.csv",
63
- "test/files/Bibelbund.ods",
64
- "test/files/Bibelbund.xls",
65
- "test/files/Bibelbund.xlsx",
66
- "test/files/Bibelbund.xml",
67
- "test/files/Bibelbund1.ods",
68
- "test/files/Pfand_from_windows_phone.xlsx",
69
- "test/files/bad_excel_date.xls",
70
- "test/files/bbu.ods",
71
- "test/files/bbu.xls",
72
- "test/files/bbu.xlsx",
73
- "test/files/bbu.xml",
74
- "test/files/bode-v1.ods.zip",
75
- "test/files/bode-v1.xls.zip",
76
- "test/files/boolean.csv",
77
- "test/files/boolean.ods",
78
- "test/files/boolean.xls",
79
- "test/files/boolean.xlsx",
80
- "test/files/boolean.xml",
81
- "test/files/borders.ods",
82
- "test/files/borders.xls",
83
- "test/files/borders.xlsx",
84
- "test/files/borders.xml",
85
- "test/files/bug-numbered-sheet-names.xlsx",
86
- "test/files/bug-row-column-fixnum-float.xls",
87
- "test/files/bug-row-column-fixnum-float.xml",
88
- "test/files/comments.ods",
89
- "test/files/comments.xls",
90
- "test/files/comments.xlsx",
91
- "test/files/csvtypes.csv",
92
- "test/files/datetime.ods",
93
- "test/files/datetime.xls",
94
- "test/files/datetime.xlsx",
95
- "test/files/datetime.xml",
96
- "test/files/datetime_floatconv.xls",
97
- "test/files/datetime_floatconv.xml",
98
- "test/files/dreimalvier.ods",
99
- "test/files/emptysheets.ods",
100
- "test/files/emptysheets.xls",
101
- "test/files/emptysheets.xlsx",
102
- "test/files/emptysheets.xml",
103
- "test/files/excel2003.xml",
104
- "test/files/false_encoding.xls",
105
- "test/files/false_encoding.xml",
106
- "test/files/file_item_error.xlsx",
107
- "test/files/formula.ods",
108
- "test/files/formula.xls",
109
- "test/files/formula.xlsx",
110
- "test/files/formula.xml",
111
- "test/files/formula_parse_error.xls",
112
- "test/files/formula_parse_error.xml",
113
- "test/files/formula_string_error.xlsx",
114
- "test/files/html-escape.ods",
115
- "test/files/link.xls",
116
- "test/files/link.xlsx",
117
- "test/files/matrix.ods",
118
- "test/files/matrix.xls",
119
- "test/files/named_cells.ods",
120
- "test/files/named_cells.xls",
121
- "test/files/named_cells.xlsx",
122
- "test/files/no_spreadsheet_file.txt",
123
- "test/files/numbers1.csv",
124
- "test/files/numbers1.ods",
125
- "test/files/numbers1.xls",
126
- "test/files/numbers1.xlsx",
127
- "test/files/numbers1.xml",
128
- "test/files/numeric-link.xlsx",
129
- "test/files/only_one_sheet.ods",
130
- "test/files/only_one_sheet.xls",
131
- "test/files/only_one_sheet.xlsx",
132
- "test/files/only_one_sheet.xml",
133
- "test/files/paragraph.ods",
134
- "test/files/paragraph.xls",
135
- "test/files/paragraph.xlsx",
136
- "test/files/paragraph.xml",
137
- "test/files/prova.xls",
138
- "test/files/ric.ods",
139
- "test/files/simple_spreadsheet.ods",
140
- "test/files/simple_spreadsheet.xls",
141
- "test/files/simple_spreadsheet.xlsx",
142
- "test/files/simple_spreadsheet.xml",
143
- "test/files/simple_spreadsheet_from_italo.ods",
144
- "test/files/simple_spreadsheet_from_italo.xls",
145
- "test/files/simple_spreadsheet_from_italo.xml",
146
- "test/files/so_datetime.csv",
147
- "test/files/style.ods",
148
- "test/files/style.xls",
149
- "test/files/style.xlsx",
150
- "test/files/style.xml",
151
- "test/files/time-test.csv",
152
- "test/files/time-test.ods",
153
- "test/files/time-test.xls",
154
- "test/files/time-test.xlsx",
155
- "test/files/time-test.xml",
156
- "test/files/type_excel.ods",
157
- "test/files/type_excel.xlsx",
158
- "test/files/type_excelx.ods",
159
- "test/files/type_excelx.xls",
160
- "test/files/type_openoffice.xls",
161
- "test/files/type_openoffice.xlsx",
162
- "test/files/whitespace.ods",
163
- "test/files/whitespace.xls",
164
- "test/files/whitespace.xlsx",
165
- "test/files/whitespace.xml",
166
- "test/rm_sub_test.rb",
167
- "test/rm_test.rb",
168
- "test/test_generic_spreadsheet.rb",
169
- "test/test_helper.rb",
170
- "test/test_roo.rb",
171
- "website/index.html",
172
- "website/index.txt",
173
- "website/javascripts/rounded_corners_lite.inc.js",
174
- "website/stylesheets/screen.css",
175
- "website/template.rhtml"
176
- ]
177
- s.homepage = "http://github.com/Empact/roo"
178
- s.licenses = ["MIT"]
179
- s.require_paths = ["lib"]
180
- s.required_ruby_version = Gem::Requirement.new(">= 1.9.0")
181
- s.rubygems_version = "2.0.14"
182
- s.summary = "Roo can access the contents of various spreadsheet files."
183
- s.test_files = ["spec/fixtures/vcr_cassettes/google_drive.yml", "spec/fixtures/vcr_cassettes/google_drive_access_token.yml", "spec/fixtures/vcr_cassettes/google_drive_set.yml", "spec/lib/roo/base_spec.rb", "spec/lib/roo/csv_spec.rb", "spec/lib/roo/excel2003xml_spec.rb", "spec/lib/roo/excel_spec.rb", "spec/lib/roo/excelx/format_spec.rb", "spec/lib/roo/excelx_spec.rb", "spec/lib/roo/google_spec.rb", "spec/lib/roo/libreoffice_spec.rb", "spec/lib/roo/openoffice_spec.rb", "spec/lib/roo/spreadsheet_spec.rb", "spec/spec_helper.rb", "test/all_ss.rb", "test/files/1900_base.xls", "test/files/1900_base.xlsx", "test/files/1904_base.xls", "test/files/1904_base.xlsx", "test/files/Bibelbund.csv", "test/files/Bibelbund.ods", "test/files/Bibelbund.xls", "test/files/Bibelbund.xlsx", "test/files/Bibelbund.xml", "test/files/Bibelbund1.ods", "test/files/Pfand_from_windows_phone.xlsx", "test/files/bad_excel_date.xls", "test/files/bbu.ods", "test/files/bbu.xls", "test/files/bbu.xlsx", "test/files/bbu.xml", "test/files/bode-v1.ods.zip", "test/files/bode-v1.xls.zip", "test/files/boolean.csv", "test/files/boolean.ods", "test/files/boolean.xls", "test/files/boolean.xlsx", "test/files/boolean.xml", "test/files/borders.ods", "test/files/borders.xls", "test/files/borders.xlsx", "test/files/borders.xml", "test/files/bug-numbered-sheet-names.xlsx", "test/files/bug-row-column-fixnum-float.xls", "test/files/bug-row-column-fixnum-float.xml", "test/files/comments.ods", "test/files/comments.xls", "test/files/comments.xlsx", "test/files/csvtypes.csv", "test/files/datetime.ods", "test/files/datetime.xls", "test/files/datetime.xlsx", "test/files/datetime.xml", "test/files/datetime_floatconv.xls", "test/files/datetime_floatconv.xml", "test/files/dreimalvier.ods", "test/files/emptysheets.ods", "test/files/emptysheets.xls", "test/files/emptysheets.xlsx", "test/files/emptysheets.xml", "test/files/excel2003.xml", "test/files/false_encoding.xls", "test/files/false_encoding.xml", "test/files/file_item_error.xlsx", "test/files/formula.ods", "test/files/formula.xls", "test/files/formula.xlsx", "test/files/formula.xml", "test/files/formula_parse_error.xls", "test/files/formula_parse_error.xml", "test/files/formula_string_error.xlsx", "test/files/html-escape.ods", "test/files/link.xls", "test/files/link.xlsx", "test/files/matrix.ods", "test/files/matrix.xls", "test/files/named_cells.ods", "test/files/named_cells.xls", "test/files/named_cells.xlsx", "test/files/no_spreadsheet_file.txt", "test/files/numbers1.csv", "test/files/numbers1.ods", "test/files/numbers1.xls", "test/files/numbers1.xlsx", "test/files/numbers1.xml", "test/files/numeric-link.xlsx", "test/files/only_one_sheet.ods", "test/files/only_one_sheet.xls", "test/files/only_one_sheet.xlsx", "test/files/only_one_sheet.xml", "test/files/paragraph.ods", "test/files/paragraph.xls", "test/files/paragraph.xlsx", "test/files/paragraph.xml", "test/files/prova.xls", "test/files/ric.ods", "test/files/simple_spreadsheet.ods", "test/files/simple_spreadsheet.xls", "test/files/simple_spreadsheet.xlsx", "test/files/simple_spreadsheet.xml", "test/files/simple_spreadsheet_from_italo.ods", "test/files/simple_spreadsheet_from_italo.xls", "test/files/simple_spreadsheet_from_italo.xml", "test/files/so_datetime.csv", "test/files/style.ods", "test/files/style.xls", "test/files/style.xlsx", "test/files/style.xml", "test/files/time-test.csv", "test/files/time-test.ods", "test/files/time-test.xls", "test/files/time-test.xlsx", "test/files/time-test.xml", "test/files/type_excel.ods", "test/files/type_excel.xlsx", "test/files/type_excelx.ods", "test/files/type_excelx.xls", "test/files/type_openoffice.xls", "test/files/type_openoffice.xlsx", "test/files/whitespace.ods", "test/files/whitespace.xls", "test/files/whitespace.xlsx", "test/files/whitespace.xml", "test/rm_sub_test.rb", "test/rm_test.rb", "test/test_generic_spreadsheet.rb", "test/test_helper.rb", "test/test_roo.rb"]
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.files.reject! { |fn| fn.include?('test/files') }
18
+ spec.require_paths = ['lib']
184
19
 
185
- if s.respond_to? :specification_version then
186
- s.specification_version = 4
20
+ spec.add_dependency 'nokogiri', '~> 1'
21
+ spec.add_dependency 'rubyzip', '~> 1.1', '< 2.0.0'
187
22
 
188
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
189
- s.add_runtime_dependency(%q<spreadsheet>, ["> 0.6.4"])
190
- s.add_runtime_dependency(%q<nokogiri>, [">= 0"])
191
- s.add_runtime_dependency(%q<rubyzip>, [">= 0"])
192
- s.add_development_dependency(%q<google_drive>, [">= 0"])
193
- s.add_development_dependency(%q<jeweler>, [">= 0"])
194
- else
195
- s.add_dependency(%q<spreadsheet>, ["> 0.6.4"])
196
- s.add_dependency(%q<nokogiri>, [">= 0"])
197
- s.add_dependency(%q<rubyzip>, [">= 0"])
198
- s.add_dependency(%q<google_drive>, [">= 0"])
199
- s.add_dependency(%q<jeweler>, [">= 0"])
200
- end
201
- else
202
- s.add_dependency(%q<spreadsheet>, ["> 0.6.4"])
203
- s.add_dependency(%q<nokogiri>, [">= 0"])
204
- s.add_dependency(%q<rubyzip>, [">= 0"])
205
- s.add_dependency(%q<google_drive>, [">= 0"])
206
- s.add_dependency(%q<jeweler>, [">= 0"])
207
- end
23
+ spec.add_development_dependency 'rake', '~> 10.1'
24
+ spec.add_development_dependency 'minitest', '~> 5.4', '>= 5.4.3'
208
25
  end
209
-
@@ -1,7 +1,4 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Roo::GenericSpreadsheet do
4
- it 'is an alias of Base' do
5
- expect(Roo::GenericSpreadsheet).to eq(Roo::Base)
6
- end
3
+ describe Roo::Base do
7
4
  end
@@ -11,11 +11,25 @@ describe Roo::CSV do
11
11
  end
12
12
 
13
13
  describe '#parse' do
14
- subject {
14
+ subject do
15
15
  csv.parse(options)
16
- }
16
+ end
17
17
  context 'with headers: true' do
18
- let(:options) { {headers: true} }
18
+ let(:options) { { headers: true } }
19
+
20
+ it "doesn't blow up" do
21
+ expect { subject }.to_not raise_error
22
+ end
23
+ end
24
+ end
25
+
26
+ describe '#parse_with_clean_option' do
27
+ subject do
28
+ csv.parse(options)
29
+ end
30
+ context 'with clean: true' do
31
+ let(:options) { {clean: true} }
32
+ let(:path) { 'test/files/parse_with_clean_option.csv' }
19
33
 
20
34
  it "doesn't blow up" do
21
35
  expect { subject }.to_not raise_error
@@ -25,30 +39,24 @@ describe Roo::CSV do
25
39
 
26
40
  describe '#csv_options' do
27
41
  context 'when created with the csv_options option' do
28
- let(:options) {
42
+ let(:options) do
29
43
  {
30
44
  col_sep: '\t',
31
45
  quote_char: "'"
32
46
  }
33
- }
47
+ end
34
48
 
35
49
  it 'returns the csv options' do
36
50
  csv = Roo::CSV.new(path, csv_options: options)
37
- csv.csv_options.should == options
51
+ expect(csv.csv_options).to eq(options)
38
52
  end
39
53
  end
40
54
 
41
55
  context 'when created without the csv_options option' do
42
56
  it 'returns a hash' do
43
57
  csv = Roo::CSV.new(path)
44
- csv.csv_options.should == {}
58
+ expect(csv.csv_options).to eq({})
45
59
  end
46
60
  end
47
61
  end
48
62
  end
49
-
50
- describe Roo::Csv do
51
- it 'is an alias of LibreOffice' do
52
- expect(Roo::Csv).to eq(Roo::CSV)
53
- end
54
- end
@@ -11,8 +11,8 @@ describe Roo::Excelx::Format do
11
11
  '0%' => :percentage,
12
12
  '0.00%' => :percentage,
13
13
  '0.00E+00' => :float,
14
- '# ?/?' => :float, #??? TODO:
15
- '# ??/??' => :float, #??? TODO:
14
+ '# ?/?' => :float, # ??? TODO:
15
+ '# ??/??' => :float, # ??? TODO:
16
16
  'mm-dd-yy' => :date,
17
17
  'd-mmm-yy' => :date,
18
18
  'd-mmm' => :date,
@@ -33,17 +33,18 @@ describe Roo::Excelx::Format do
33
33
  '##0.0E+0' => :float,
34
34
  '@' => :float,
35
35
  #-- zusaetzliche Formate, die nicht standardmaessig definiert sind:
36
- "yyyy\\-mm\\-dd" => :date,
36
+ 'yyyy\\-mm\\-dd' => :date,
37
37
  'dd/mm/yy' => :date,
38
38
  'hh:mm:ss' => :time,
39
- "dd/mm/yy\\ hh:mm" => :datetime,
39
+ 'dd/mm/yy\\ hh:mm' => :datetime,
40
40
  'dd/mmm/yy\\ hh:mm' => :datetime,
41
41
  'dd/mmm/yy' => :date, # 2011-05-21
42
42
  'yyyy-mm-dd' => :date, # 2011-09-16
43
- 'yyyy-mm-dd;@' => :date
43
+ 'yyyy-mm-dd;@' => :date,
44
+ '#0_);[Red]\(0\)' => :float
44
45
  }.each do |format, type|
45
46
  it "translates #{format} to #{type}" do
46
- Roo::Excelx::Format.to_type(format).should == type
47
+ expect(Roo::Excelx::Format.to_type(format)).to eq(type)
47
48
  end
48
49
  end
49
50
  end