from_excel 1.0.1 → 1.1.0
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/lib/excel_import.rb +18 -1
- data/test/test_from_ods.rb +11 -0
- metadata +7 -5
data/lib/excel_import.rb
CHANGED
@@ -157,9 +157,26 @@ module ExcelImport
|
|
157
157
|
def self.included(base)
|
158
158
|
class << base
|
159
159
|
def from_excel spreadsheet, opt={}
|
160
|
-
|
160
|
+
from_spreadsheet(:xls, spreadsheet, opt)
|
161
|
+
end
|
162
|
+
|
163
|
+
def from_ooo spreadsheet, opt={}
|
164
|
+
from_spreadsheet(:ods, spreadsheet, opt)
|
165
|
+
end
|
166
|
+
|
167
|
+
private
|
168
|
+
|
169
|
+
def from_spreadsheet type, spreadsheet, opt={}
|
170
|
+
klass = case type
|
171
|
+
when :ods
|
172
|
+
Openoffice
|
173
|
+
when :xls
|
174
|
+
Excel
|
175
|
+
end
|
176
|
+
integrator = Integrator.new(klass.new(spreadsheet.path), self, opt)
|
161
177
|
integrator.rows_to_objects
|
162
178
|
end
|
179
|
+
|
163
180
|
end
|
164
181
|
end
|
165
182
|
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestFromExcel < Test::Unit::TestCase
|
4
|
+
SIMPLE_SHEET= File.join(File.dirname(__FILE__), 'spreadsheets/simple_sheet.ods')
|
5
|
+
|
6
|
+
def test_import_with_simple_sheet
|
7
|
+
assert users = User.from_ooo(File.new SIMPLE_SHEET)
|
8
|
+
assert_equal sheet_users, users
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: from_excel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
- 0
|
9
8
|
- 1
|
10
|
-
|
9
|
+
- 0
|
10
|
+
version: 1.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Philippe Cantin
|
@@ -31,7 +31,7 @@ dependencies:
|
|
31
31
|
version: "0"
|
32
32
|
type: :runtime
|
33
33
|
version_requirements: *id001
|
34
|
-
description: Import Excel spreadsheet to ruby objects
|
34
|
+
description: Import Excel & OpenOffice spreadsheet to ruby objects
|
35
35
|
email:
|
36
36
|
executables: []
|
37
37
|
|
@@ -49,6 +49,7 @@ files:
|
|
49
49
|
- test/model/user.rb
|
50
50
|
- test/test_bounds.rb
|
51
51
|
- test/test_from_excel.rb
|
52
|
+
- test/test_from_ods.rb
|
52
53
|
- test/test_mapping.rb
|
53
54
|
homepage: http://github.com/anoiaque/from_excel
|
54
55
|
licenses: []
|
@@ -82,7 +83,7 @@ rubyforge_project:
|
|
82
83
|
rubygems_version: 1.8.10
|
83
84
|
signing_key:
|
84
85
|
specification_version: 3
|
85
|
-
summary: Import Excel spreadsheet to ruby objects
|
86
|
+
summary: Import Excel & OpenOffice spreadsheet to ruby objects
|
86
87
|
test_files:
|
87
88
|
- test/helper.rb
|
88
89
|
- test/model/adress.rb
|
@@ -90,4 +91,5 @@ test_files:
|
|
90
91
|
- test/model/user.rb
|
91
92
|
- test/test_bounds.rb
|
92
93
|
- test/test_from_excel.rb
|
94
|
+
- test/test_from_ods.rb
|
93
95
|
- test/test_mapping.rb
|