excel_utils 1.1.1 → 1.1.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 +4 -4
- data/lib/excel_utils/sheet.rb +5 -1
- data/lib/excel_utils/version.rb +1 -1
- data/lib/excel_utils/writer.rb +1 -1
- data/spec/write_spec.rb +9 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea8c9b8aeb5945a6d01f5ea29578bf34c48d28f8a572cb6d5f3857757fb48ae9
|
4
|
+
data.tar.gz: f1fc9f86e3a3fe784184cd942739e3ea961f018ea313006222568785988b6f34
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d7ef606b270f1af8ae88e91e12b44c657e693c7653c3df2d5b951d71758339749be6d78ee95a2c04f1e6895544cb653d8f84bae8ba619757bfc2b1bbb945dbe
|
7
|
+
data.tar.gz: 6eea2444670d88df36d2d4fdcca88ba4ced1ac9bfbc8890b8e2ab6b4c6b90d42a0413725599ea99e5bfc93f480bbd931cdc8516e725b04ed2c0a3c355ca00815
|
data/lib/excel_utils/sheet.rb
CHANGED
@@ -15,7 +15,7 @@ module ExcelUtils
|
|
15
15
|
@column_names ||= begin
|
16
16
|
if sheet.first_row
|
17
17
|
first_row = sheet.row sheet.first_row
|
18
|
-
normalize_column_names ? first_row.map { |
|
18
|
+
normalize_column_names ? first_row.map { |name| normalize_column name } : first_row
|
19
19
|
else
|
20
20
|
[]
|
21
21
|
end
|
@@ -46,5 +46,9 @@ module ExcelUtils
|
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
+
def normalize_column(name)
|
50
|
+
Inflecto.underscore(name.strip.gsub(' ', '_')).to_sym
|
51
|
+
end
|
52
|
+
|
49
53
|
end
|
50
54
|
end
|
data/lib/excel_utils/version.rb
CHANGED
data/lib/excel_utils/writer.rb
CHANGED
data/spec/write_spec.rb
CHANGED
@@ -17,7 +17,7 @@ describe ExcelUtils do
|
|
17
17
|
|
18
18
|
data = {
|
19
19
|
'Sheet 1' => [
|
20
|
-
{'column_a' => 1.5, 'column_b' => 'text 1', 'column_c' => DateTime.parse('2019-05-25T16:30:00')
|
20
|
+
{'column_a' => 1.5, 'column_b' => 'text 1', 'column_c' => DateTime.parse('2019-05-25T16:30:00')},
|
21
21
|
{'column_b' => 'text 2', 'column_c' => Date.parse('2019-07-09'), 'column_a' => 2, 'column_d' => '0123'},
|
22
22
|
],
|
23
23
|
'Sheet 2' => [
|
@@ -30,7 +30,14 @@ describe ExcelUtils do
|
|
30
30
|
|
31
31
|
workbook = ExcelUtils.read filename
|
32
32
|
|
33
|
-
workbook.
|
33
|
+
workbook.sheets.each do |sheet|
|
34
|
+
sheet.each_with_index do |row, i|
|
35
|
+
columns = row.keys | data[sheet.name][i].keys
|
36
|
+
columns.each do |column|
|
37
|
+
row[column].must_equal data[sheet.name][i][column]
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
34
41
|
end
|
35
42
|
|
36
43
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: excel_utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gabriel Naiman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-06-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: inflecto
|