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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2469a06f8110bdaa52d7a0aa1b9c5c870034b3d8
4
- data.tar.gz: 5211e3ae85961fc29376156120569220cbfbbe7b
3
+ metadata.gz: c1ec41909edd94071bbd39eb8c39ad1a610f8f59
4
+ data.tar.gz: 1482e4b7d1de2ce8966f7627d3c3dd2b2f638337
5
5
  SHA512:
6
- metadata.gz: bbae1e0e681f369f4ec0ee8c71a880c3b6fe24cc815cde0b337bd63e77a0103edf04b77de320a212e772a8ac1a68ad9ee5f5be3b52672806fbc18592536db83d
7
- data.tar.gz: 91a54b399f41ee9d459b9bb3868c5cd2990963297c274f4dc5f4a78034137a8c617f9ac34db75418e8f0989683219637cb9a096536259e9cb76fe9cca780b132
6
+ metadata.gz: c46ede35b0e40c86cd0a9329ec15d1fd55147aaaf1433ad5ff6f0fa6881d3f8a4148791b960c6c2f801f301f34f134ad911a10e006361959a468cd8ef03428bd
7
+ data.tar.gz: f9f3c660aa13985bc7138a236b84b79491d21b8159cd27d71e793e643d05db4ae80c44d08142c8d2fc73d68f2de82f4428991ff2e14e52cc3e3e7d1eafeb7b19
@@ -0,0 +1,7 @@
1
+ /pkg/
2
+ /log/
3
+ /coverage/
4
+ .ruby-version
5
+ .project
6
+ *.lock
7
+ .idea
@@ -0,0 +1,4 @@
1
+ SimpleCov.start do
2
+ add_filter 'spec'
3
+ add_filter 'test'
4
+ end
@@ -0,0 +1,13 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ - 2.1
5
+ - 2.2.0
6
+ - ruby-head
7
+ - jruby-19mode # JRuby in 1.9 mode
8
+ - rbx-2
9
+ matrix:
10
+ allow_failures:
11
+ - rvm: ruby-head
12
+ - rvm: jruby-19mode
13
+ bundler_args: --without local_development
data/CHANGELOG CHANGED
@@ -1,3 +1,24 @@
1
+ == unreleased
2
+
3
+ * enhancements
4
+ * Extend Roo::Spreadsheet.open to accept Tempfiles and other arguments responding to #path. Note they require an :extension option to be declared, as the tempfile mangles the extension. #84.
5
+ * Remove deprecated code.
6
+ * Remove the Roo::ZipFile abstraction. Roo now depends on rubyzip 1.0.0+
7
+ * Extract Roo::Excel and Roo::Excel2003XML to roo-xls
8
+ * Extract Roo::Google to roo-google
9
+ * Accept the tmpdir_root option in Roo::Excelx
10
+ * Change the tmpdir prefix from oo_ to roo_
11
+ * In Excelx, load styles, shared strings and the workbook lazily. Leave the tmpdir open so that reading may take place after initialize. The OS will be responsible for cleaning it up.
12
+ * In OpenOffice / LibreOffice, load the content xml lazily. Leave the tmpdir open so that reading may take place after initialize. The OS will be responsible for cleaning it up.
13
+ * Lazily initialize @default_sheet, to avoid reading the sheets earlier than necessary. Use the #default_sheet accessor instead.
14
+
15
+ * bugfixes
16
+ * Fix that paths with spaces in them would fail with
17
+ URI::InvalidURIError. #121.
18
+ # Fix that #parse-ing with a hash of columns not in the document
19
+ would fail mysteriously. #129
20
+ * Fix that Roo::Excelx#celltype would not return :link when appropriate.
21
+
1
22
  == 1.13.2 2013-12-23
2
23
 
3
24
  * bugfixes
data/Gemfile CHANGED
@@ -1,18 +1,24 @@
1
- source 'http://rubygems.org'
1
+ source 'https://rubygems.org'
2
2
 
3
- gem 'spreadsheet', '> 0.6.4'
4
- gem 'nokogiri'
5
- gem 'rubyzip'
6
-
7
- group :development do
8
- gem 'google_drive'
9
- gem 'jeweler'
10
- end
3
+ gemspec
11
4
 
12
5
  group :test do
13
6
  # additional testing libs
14
7
  gem 'webmock'
15
8
  gem 'shoulda'
16
- gem 'rspec'
9
+ gem 'rspec', '>= 3.0.0'
17
10
  gem 'vcr'
11
+ gem 'simplecov', '>= 0.9.0', require: false
12
+ gem 'coveralls', require: false
13
+ end
14
+
15
+ group :local_development do
16
+ gem 'terminal-notifier-guard', require: false if RUBY_PLATFORM.downcase.include?('darwin')
17
+ gem 'guard-rspec', '>= 4.3.1', require: false
18
+ gem 'guard-minitest', require: false
19
+ gem 'guard-bundler', require: false
20
+ gem 'guard-preek', require: false
21
+ gem 'guard-rubocop', require: false
22
+ gem 'guard-reek', github: 'pericles/guard-reek', require: false
23
+ gem 'pry'
18
24
  end
@@ -0,0 +1,24 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard :minitest, test_folders: ['test'] do
5
+ watch(%r{^test/(.*)\/?test_(.*)\.rb$})
6
+ watch(%r{^lib/(.*/)?([^/]+)\.rb$}) { |m| "test/#{m[1]}test_#{m[2]}.rb" }
7
+ watch(%r{^test/test_helper\.rb$}) { 'test' }
8
+ end
9
+
10
+ # Note: The cmd option is now required due to the increasing number of ways
11
+ # rspec may be run, below are examples of the most common uses.
12
+ # * bundler: 'bundle exec rspec'
13
+ # * bundler binstubs: 'bin/rspec'
14
+ # * spring: 'bin/rsspec' (This will use spring if running and you have
15
+ # installed the spring binstubs per the docs)
16
+ # * zeus: 'zeus rspec' (requires the server to be started separetly)
17
+ # * 'just' rspec: 'rspec'
18
+ guard :rspec, cmd: 'bundle exec rspec' do
19
+ watch(%r{^spec/.+_spec\.rb$})
20
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
21
+ watch('spec/spec_helper.rb') { "spec" }
22
+ watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
23
+ end
24
+
data/LICENSE CHANGED
@@ -1,4 +1,6 @@
1
- Copyright (c) 2008-2013 Thomas Preymesser, Ben Woosley
1
+ Copyright (c) 2008-2014 Thomas Preymesser, Ben Woosley
2
+
3
+ MIT License
2
4
 
3
5
  Permission is hereby granted, free of charge, to any person obtaining
4
6
  a copy of this software and associated documentation files (the
@@ -0,0 +1,254 @@
1
+ # Roo
2
+
3
+ [![Build Status](https://img.shields.io/travis/roo-rb/roo.svg?style=flat-square)](https://travis-ci.org/roo-rb/roo) [![Code Climate](https://img.shields.io/codeclimate/github/roo-rb/roo.svg?style=flat-square)](https://codeclimate.com/github/roo-rb/roo) [![Coverage Status](https://img.shields.io/coveralls/roo-rb/roo.svg?style=flat-square)](https://coveralls.io/r/roo-rb/roo) [![Gem Version](https://img.shields.io/gem/v/roo.svg?style=flat-square)](https://rubygems.org/gems/roo)
4
+
5
+ Roo implements read access for all common spreadsheet types. It can handle:
6
+
7
+ * Excelx
8
+ * OpenOffice / LibreOffice
9
+ * CSV
10
+
11
+ ## Additional Libraries
12
+
13
+ In addition, the [roo-xls](https://github.com/roo-rb/roo-xls) and [roo-google](https://github.com/roo-rb/roo-google) gems exist to extend Roo to support reading classic Excel formats (i.e. `.xls` and ``Excel2003XML``) and read/write access for Google spreadsheets.
14
+
15
+ # #Installation
16
+
17
+ Install as a gem
18
+
19
+ $ gem install roo
20
+
21
+ Or add it to your Gemfile
22
+
23
+ ```ruby
24
+ gem 'roo', '2.0.0-beta'
25
+ ```
26
+ ## Usage
27
+
28
+ Opening a spreadsheet
29
+
30
+ ```ruby
31
+ require 'roo'
32
+
33
+ xlsx = Roo::Spreadsheet.open('./new_prices.xlsx')
34
+ xlsx = Roo::Excelx("./new_prices.xlsx")
35
+
36
+ # Use the extension option if the extension is ambiguous.
37
+ xlsx = Roo::Spreadsheet.open('./rails_temp_upload', extension: :xlsx)
38
+
39
+ xlsx.info
40
+ # => Returns basic info about the spreadsheet file
41
+ ```
42
+
43
+ ``Roo::Spreadsheet.open`` can accept both paths and ``File`` instances.
44
+
45
+ ### Working with sheets
46
+
47
+ ```ruby
48
+ ods.sheets
49
+ # => ['Info', 'Sheet 2', 'Sheet 3'] # an Array of sheet names in the workbook
50
+
51
+ ods.sheet('Info').row(1)
52
+ ods.sheet(0).row(1)
53
+
54
+ # Set the last sheet as the default sheet.
55
+ ods.default_sheet = ods.sheets.last
56
+ ods.default_sheet = s.sheets[3]
57
+ ods.default_sheet = 'Sheet 3'
58
+
59
+ # Iterate through each sheet
60
+ ods.each_with_pagename do |name, sheet|
61
+ p sheet.row(1)
62
+ end
63
+ ```
64
+
65
+ ### Accessing rows and columns
66
+
67
+ Roo uses Excel's numbering for rows, columns and cells, so `1` is the first index, not `0` as it is in an ``Array``
68
+
69
+ ```ruby
70
+ sheet.row(1)
71
+ # returns the first row of the spreadsheet.
72
+
73
+ sheet.column(1)
74
+ # returns the first column of the spreadsheet.
75
+ ```
76
+
77
+ Almost all methods have an optional argument `sheet`. If this parameter is omitted, the default_sheet will be used.
78
+
79
+ ```ruby
80
+ sheet.first_row(sheet.sheets[0])
81
+ # => 1 # the number of the first row
82
+ sheet.last_row
83
+ # => 42 # the number of the last row
84
+ sheet.first_column
85
+ # => 1 # the number of the first column
86
+ sheet.last_column
87
+ # => 10 # the number of the last column
88
+ ```
89
+
90
+ #### Accessing cells
91
+
92
+ You can access the top-left cell in the following ways
93
+
94
+ ```ruby
95
+ s.cell(1,1)
96
+ s.cell('A',1)
97
+ s.cell(1,'A')
98
+ s.a1
99
+
100
+ # Access the second sheet's top-left cell.
101
+ s.cell(1,'A',s.sheets[1])
102
+ ```
103
+
104
+ #### Querying a spreadsheet
105
+ Use ``each`` with a ``block`` to iterate over each row.
106
+
107
+ If each is given a hash with the names of some columns, then each will generate a hash with the columns supplied for each row.
108
+
109
+ ```ruby
110
+ sheet.each(id: 'ID', name: 'FULL_NAME') do |hash|
111
+ puts hash.inspect
112
+ # => { id: 1, name: 'John Smith' }
113
+ end
114
+ ```
115
+
116
+ Use ``sheet.parse`` to return an array of rows. Column names can be a ``String`` or a ``Regexp``.
117
+
118
+ ```ruby
119
+ sheet.parse(:id => /UPC|SKU/,:qty => /ATS*\sATP\s*QTY\z/)
120
+ # => [{:upc => 727880013358, :qty => 12}, ...]
121
+ ```
122
+
123
+ Use the ``:header_search`` option to locate the header row and assign the header names.
124
+
125
+ ```ruby
126
+ sheet.parse(header_search: [/UPC*SKU/,/ATS*\sATP\s*QTY\z/])
127
+ ```
128
+
129
+ Use the ``:clean`` option to strip out control characters and surrounding white space.
130
+
131
+ ```ruby
132
+ sheet.parse(:clean => true)
133
+ ```
134
+
135
+ ### Exporting spreadsheets
136
+ Roo has the ability to export sheets using the following formats. It
137
+ will only export the ``default_sheet``.
138
+
139
+ ```ruby
140
+ sheet.to_csv
141
+ sheet.to_matrix
142
+ sheet.to_xml
143
+ sheet.to_yaml
144
+ ```
145
+
146
+ ### Excel (xlsx) Support
147
+
148
+ Stream rows from an Excelx spreadsheet.
149
+
150
+ ```ruby
151
+ xlsx = Roo::Excelx.new("./test_data/test_small.xlsx")
152
+ xlsx.each_row_streaming do |row|
153
+ puts row.inspect # Array of Excelx::Cell objects
154
+ end
155
+ ```
156
+
157
+ Iterate over each row
158
+
159
+ ```ruby
160
+ xlsx.each_row do |row|
161
+ ...
162
+ end
163
+ ```
164
+
165
+ ``Roo::Excelx`` also provides these helpful methods.
166
+
167
+ ```ruby
168
+ xlsx.excelx_type(3, 'C')
169
+ # => :numeric_or_formula
170
+
171
+ xlsx.cell(3, 'C')
172
+ # => 600000383.0
173
+
174
+ xlsx.excelx_value(row,col)
175
+ # => '0600000383'
176
+ ```
177
+
178
+ ``Roo::Excelx`` can access celltype, comments, font information, formulas, hyperlinks and labels.
179
+
180
+ ```ruby
181
+ xlsx.comment(1,1, ods.sheets[-1])
182
+ xlsx.font(1,1).bold?
183
+ xlsx.formula('A', 2)
184
+ ```
185
+
186
+ ### OpenOffice / LibreOffice Support
187
+
188
+ Roo::OpenOffice supports for encrypted OpenOffice spreadsheets.
189
+
190
+ ```ruby
191
+ # Load an encrypted OpenOffice Spreadsheet
192
+ ods = Roo::OpenOffice.new("myspreadsheet.ods", :password => "password")
193
+ ```
194
+
195
+ ``Roo::OpenOffice`` can access celltype, comments, font information, formulas and labels.
196
+
197
+ ```ruby
198
+ ods.celltype
199
+ # => :percentage
200
+
201
+ ods.comment(1,1, ods.sheets[-1])
202
+
203
+ ods.font(1,1).italic?
204
+ # => false
205
+
206
+ ods.formula('A', 2)
207
+ ```
208
+
209
+ ### CSV Support
210
+
211
+ ```ruby
212
+ # Load a CSV file
213
+ s = Roo::CSV.new("mycsv.csv")
214
+ ```
215
+
216
+ Because Roo uses the [standard CSV library](), and you can use options available to that library to parse csv files. You can pass options using the ``csv_options`` key.
217
+
218
+ For instance, you can load tab-delimited files (``.tsv``), and you can use a particular encoding when opening the file.
219
+
220
+
221
+ ```ruby
222
+ # Load a tab-delimited csv
223
+ s = Roo::CSV.new("mytsv.tsv", csv_options: {col_sep: "\t"})
224
+
225
+ # Load a csv with an explicit encoding
226
+ s = Roo::CSV.new("mycsv.csv", csv_options: {encoding: Encoding::ISO_8859_1})
227
+ ```
228
+
229
+ ## Upgrading from Roo 1.13.x
230
+ If you use ``.xls`` or Google spreadsheets, you will need to install ``roo-xls`` or ``roo-google`` to continue using that functionality.
231
+
232
+ Roo's public methods have stayed relatively consistent between 1.13.x and 2.0.0, but please check the [Changelog](https://github.com/roo-rb/roo/blob/master/CHANGELOG) to better understand the changes made since 1.13.x.
233
+
234
+
235
+
236
+ ## Contributing
237
+ ### Features
238
+ 1. Fork it ( https://github.com/[my-github-username]/roo/fork )
239
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
240
+ 3. Commit your changes (`git commit -am 'My new feature'`)
241
+ 4. Push to the branch (`git push origin my-new-feature`)
242
+ 5. Create a new Pull Request
243
+
244
+ ### Issues
245
+
246
+ If you find an issue, please create a gist and refer to it in an issue ([sample gist](https://gist.github.com/stevendaniels/98a05849036e99bb8b3c)). Here are some instructions for creating such a gist.
247
+
248
+ 1. [Create a gist](https://gist.github.com) with code that creates the error.
249
+ 2. Clone the gist repo locally, add a stripped down version of the offending spreadsheet to the gist repo, and push the gist's changes master.
250
+ 3. Paste the gist url here.
251
+
252
+
253
+ ## License
254
+ [Roo uses an MIT License](https://github.com/roo-rb/roo/blob/master/LICENSE)
data/Rakefile CHANGED
@@ -1,23 +1,23 @@
1
- require 'jeweler'
2
-
3
- Jeweler::Tasks.new do |gem|
4
- # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
5
- gem.name = "roo"
6
- gem.summary = "Roo can access the contents of various spreadsheet files."
7
- gem.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"
8
- gem.email = "ruby.ruby.ruby.roo@gmail.com"
9
- gem.homepage = "http://github.com/Empact/roo"
10
- gem.authors = ['Thomas Preymesser', 'Hugh McGowan', 'Ben Woosley']
11
-
12
- gem.license = 'MIT'
13
- gem.required_ruby_version = '>= 1.9.0'
14
-
15
- gem.test_files = FileList["{spec,test}/**/*.*"]
16
- end
17
-
18
- require 'rake/testtask'
19
- Rake::TestTask.new do |t|
20
- t.libs << "test"
21
- t.test_files = FileList['test/test*.rb']
22
- t.verbose = true
23
- end
1
+ require 'bundler/gem_tasks'
2
+
3
+ require 'rake/testtask'
4
+ require 'rspec/core/rake_task'
5
+ require 'coveralls/rake/task'
6
+
7
+ # Test unit
8
+ Rake::TestTask.new do |t|
9
+ t.libs << 'test'
10
+ t.test_files = FileList['test/test*.rb']
11
+ t.verbose = true
12
+ end
13
+
14
+ # RSpec
15
+ RSpec::Core::RakeTask.new(:spec)
16
+
17
+ # Coveralls
18
+ Coveralls::RakeTask.new
19
+
20
+ default_task = [:test, :spec]
21
+ default_task << 'coveralls:push' if ENV['TRAVIS']
22
+
23
+ task default: default_task
@@ -1,38 +1,38 @@
1
1
  require 'soap/rpc/driver'
2
2
 
3
- def ferien_fuer_region(proxy, region, year=nil)
4
- proxy.first_row.upto(proxy.last_row) { |row|
5
- if proxy.cell(row, 2) == region
6
- jahr = proxy.cell(row,1).to_i
7
- if year == nil || jahr == year
8
- bis_datum = proxy.cell(row,5)
9
- if DateTime.now > bis_datum
10
- print '('
11
- end
12
- print jahr.to_s+" "
13
- print proxy.cell(row,2)+" "
14
- print proxy.cell(row,3)+" "
15
- print proxy.cell(row,4).to_s+" "
16
- print bis_datum.to_s+" "
17
- print (proxy.cell(row,6) || '')+" "
18
- if DateTime.now > bis_datum
19
- print ')'
20
- end
21
- puts
3
+ def ferien_fuer_region(proxy, region, year = nil)
4
+ proxy.first_row.upto(proxy.last_row) do |row|
5
+ if proxy.cell(row, 2) == region
6
+ jahr = proxy.cell(row, 1).to_i
7
+ if year.nil? || jahr == year
8
+ bis_datum = proxy.cell(row, 5)
9
+ if DateTime.now > bis_datum
10
+ print '('
22
11
  end
23
- end
24
- }
12
+ print jahr.to_s + ' '
13
+ print proxy.cell(row, 2) + ' '
14
+ print proxy.cell(row, 3) + ' '
15
+ print proxy.cell(row, 4).to_s + ' '
16
+ print bis_datum.to_s + ' '
17
+ print (proxy.cell(row, 6) || '') + ' '
18
+ if DateTime.now > bis_datum
19
+ print ')'
20
+ end
21
+ puts
22
+ end
23
+ end
25
24
  end
25
+ end
26
26
 
27
- proxy = SOAP::RPC::Driver.new("http://localhost:12321","spreadsheetserver")
28
- proxy.add_method('cell','row','col')
27
+ proxy = SOAP::RPC::Driver.new('http://localhost:12321', 'spreadsheetserver')
28
+ proxy.add_method('cell', 'row', 'col')
29
29
  proxy.add_method('officeversion')
30
30
  proxy.add_method('last_row')
31
31
  proxy.add_method('last_column')
32
32
  proxy.add_method('first_row')
33
33
  proxy.add_method('first_column')
34
34
  proxy.add_method('sheets')
35
- proxy.add_method('set_default_sheet','s')
35
+ proxy.add_method('set_default_sheet', 's')
36
36
  proxy.add_method('ferien_fuer_region', 'region')
37
37
 
38
38
  sheets = proxy.sheets
@@ -42,12 +42,9 @@ puts "first row: #{proxy.first_row}"
42
42
  puts "first column: #{proxy.first_column}"
43
43
  puts "last row: #{proxy.last_row}"
44
44
  puts "last column: #{proxy.last_column}"
45
- puts "cell: #{proxy.cell('C',8)}"
46
- puts "cell: #{proxy.cell('F',12)}"
45
+ puts "cell: #{proxy.cell('C', 8)}"
46
+ puts "cell: #{proxy.cell('F', 12)}"
47
47
  puts "officeversion: #{proxy.officeversion}"
48
- puts "Berlin:"
49
-
50
- ferien_fuer_region(proxy, "Berlin")
51
-
52
-
48
+ puts 'Berlin:'
53
49
 
50
+ ferien_fuer_region(proxy, 'Berlin')