rggen-spreadsheet-loader 0.20.0 → 0.21.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e0f3c849dfe3a2e44abfe3dc1014c4a4254fe8be92bdd4b64745fd1778cb0b42
4
- data.tar.gz: 690e61fab0e402d9171aa2ee50befbf25111ad44810acf01cd5c9af11fba7e8f
3
+ metadata.gz: 1ecef914a6486bf3e24f727a5245c6d80f484cd71801549c13bd53133d61146d
4
+ data.tar.gz: 42692af472b677c5c2b352ade9e991e3531d5ea2c174e83493decc33f9a105b2
5
5
  SHA512:
6
- metadata.gz: 23770bfa1f24804808d6c75885f07338831f18833147c165783b8dd1bac3edde07e90f281f1ed2f326fcf71487ff972bb1f14353d08142491660a68997b57676
7
- data.tar.gz: e162d610aa891cd2928370e9cb8f9bf6d4057be34f344efc855de1539ecc2b743054c4d00d4209a999747facbe579cf947fc8cdae44f2c36e72dfbd29cf33c40
6
+ metadata.gz: 54cb03880736f943c2be367d6b6fe2537a1bbcb67b8e19dca400e77221edc4aae9facfc9b79b3d67391d831599a96bbcd2aa61b011e79548e50b335073c6a02d
7
+ data.tar.gz: 6744d166b12b23d1a96c439dbe4028255c590c0290b0576c8fe630a01342c33d16ab5a90ab8600637b1f5f627d09893861bbf04ba2fadc71a70985c1b82df4f4
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2019-2021 Taichi Ishitani
3
+ Copyright (c) 2019-2022 Taichi Ishitani
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -40,7 +40,7 @@ Feedbacks, bug reports, questions and etc. are wellcome! You can post them by us
40
40
 
41
41
  ## Copyright & License
42
42
 
43
- Copyright © 2019-2021 Taichi Ishitani. RgGen::SpreadsheetLoader is licensed under the [MIT License](https://opensource.org/licenses/MIT), see [LICENSE](LICENSE) for futher details.
43
+ Copyright © 2019-2022 Taichi Ishitani. RgGen::SpreadsheetLoader is licensed under the [MIT License](https://opensource.org/licenses/MIT), see [LICENSE](LICENSE) for futher details.
44
44
 
45
45
  ## Code of Conduct
46
46
 
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RgGen
4
+ module SpreadsheetLoader
5
+ class ODSLoader < Core::RegisterMap::Loader
6
+ include SpreadsheetLoader
7
+
8
+ support_types [:ods]
9
+
10
+ def read_spreadsheet(file, book)
11
+ require 'spreadbase'
12
+ SpreadBase::Document.new(file)
13
+ .tables.each { |table| process_table(table, book) }
14
+ end
15
+
16
+ private
17
+
18
+ def process_table(table, book)
19
+ rows = table.data
20
+ rows.size.positive? && book.add_sheet(table.name, rows)
21
+ end
22
+ end
23
+ end
24
+ end
@@ -50,7 +50,8 @@ module RgGen
50
50
 
51
51
  def format_sub_layer_data(read_data, layer, _file)
52
52
  sub_layer = SUB_LAYERS[layer]
53
- sub_layer && { sub_layer => __send__("collect_#{sub_layer}_data", read_data) }
53
+ sub_layer &&
54
+ [sub_layer].product(__send__("collect_#{sub_layer}_data", read_data))
54
55
  end
55
56
 
56
57
  def collect_register_block_data(book)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RgGen
4
4
  module SpreadsheetLoader
5
- VERSION = '0.20.0'
5
+ VERSION = '0.21.0'
6
6
  end
7
7
  end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RgGen
4
+ module SpreadsheetLoader
5
+ class XLSXLoader < Core::RegisterMap::Loader
6
+ include SpreadsheetLoader
7
+
8
+ support_types [:xlsx]
9
+
10
+ def read_spreadsheet(file, book)
11
+ require 'simple_xlsx_reader'
12
+ SimpleXlsxReader.open(file)
13
+ .sheets.each { |sheet| process_sheet(sheet, book) }
14
+ end
15
+
16
+ private
17
+
18
+ def process_sheet(sheet, book)
19
+ sheet.rows.size.positive? &&
20
+ book.add_sheet(sheet.name, sheet.rows)
21
+ end
22
+ end
23
+ end
24
+ end
@@ -8,17 +8,18 @@ require_relative 'spreadsheet_loader/spreadsheet/sheet'
8
8
  require_relative 'spreadsheet_loader/spreadsheet/book'
9
9
  require_relative 'spreadsheet_loader/spreadsheet_loader'
10
10
  require_relative 'spreadsheet_loader/csv_loader'
11
- require_relative 'spreadsheet_loader/roo_loader'
11
+ require_relative 'spreadsheet_loader/ods_loader'
12
12
  require_relative 'spreadsheet_loader/xls_loader'
13
+ require_relative 'spreadsheet_loader/xlsx_loader'
13
14
 
14
15
  module RgGen
15
16
  module SpreadsheetLoader
16
17
  extend Core::Plugin
17
18
 
18
19
  setup_plugin :'rggen-spreadsheet-loader' do |plugin|
19
- plugin.register_loader :register_map, :spreadsheet, CSVLoader
20
- plugin.register_loader :register_map, :spreadsheet, RooLoader
21
- plugin.register_loader :register_map, :spreadsheet, XLSLoader
20
+ [CSVLoader, ODSLoader, XLSLoader, XLSXLoader].each do |loader|
21
+ plugin.register_loader :register_map, :spreadsheet, loader
22
+ end
22
23
  end
23
24
  end
24
25
  end
metadata CHANGED
@@ -1,29 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rggen-spreadsheet-loader
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.20.0
4
+ version: 0.21.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taichi Ishitani
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-28 00:00:00.000000000 Z
11
+ date: 2022-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: roo
14
+ name: simple_xlsx_reader
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '2.8'
19
+ version: 1.0.4
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '2.8'
26
+ version: 1.0.4
27
+ - !ruby/object:Gem::Dependency
28
+ name: spreadbase
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.4.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 0.4.0
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: spreadsheet
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -64,7 +78,7 @@ files:
64
78
  - README.md
65
79
  - lib/rggen/spreadsheet_loader.rb
66
80
  - lib/rggen/spreadsheet_loader/csv_loader.rb
67
- - lib/rggen/spreadsheet_loader/roo_loader.rb
81
+ - lib/rggen/spreadsheet_loader/ods_loader.rb
68
82
  - lib/rggen/spreadsheet_loader/setup.rb
69
83
  - lib/rggen/spreadsheet_loader/spreadsheet/book.rb
70
84
  - lib/rggen/spreadsheet_loader/spreadsheet/cell.rb
@@ -74,12 +88,14 @@ files:
74
88
  - lib/rggen/spreadsheet_loader/spreadsheet_loader.rb
75
89
  - lib/rggen/spreadsheet_loader/version.rb
76
90
  - lib/rggen/spreadsheet_loader/xls_loader.rb
91
+ - lib/rggen/spreadsheet_loader/xlsx_loader.rb
77
92
  homepage: https://github.com/rggen/rggen-spreadsheet-loader
78
93
  licenses:
79
94
  - MIT
80
95
  metadata:
81
96
  bug_tracker_uri: https://github.com/rggen/rggen-spreadsheet-loader/issues
82
97
  mailing_list_uri: https://groups.google.com/d/forum/rggen
98
+ rubygems_mfa_required: 'true'
83
99
  source_code_uri: https://github.com/rggen/rggen-spreadsheet-loader
84
100
  wiki_uri: https://github.com/rggen/rggen/wiki
85
101
  post_install_message:
@@ -90,15 +106,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
90
106
  requirements:
91
107
  - - ">="
92
108
  - !ruby/object:Gem::Version
93
- version: '2.5'
109
+ version: '2.6'
94
110
  required_rubygems_version: !ruby/object:Gem::Requirement
95
111
  requirements:
96
112
  - - ">="
97
113
  - !ruby/object:Gem::Version
98
114
  version: '0'
99
115
  requirements: []
100
- rubygems_version: 3.2.3
116
+ rubygems_version: 3.3.3
101
117
  signing_key:
102
118
  specification_version: 4
103
- summary: rggen-spreadsheet-loader-0.20.0
119
+ summary: rggen-spreadsheet-loader-0.21.0
104
120
  test_files: []
@@ -1,36 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RgGen
4
- module SpreadsheetLoader
5
- class RooLoader < Core::RegisterMap::Loader
6
- include SpreadsheetLoader
7
-
8
- support_types [:xlsx, :ods]
9
-
10
- def read_spreadsheet(file, book)
11
- read_roo(file, &page_processor(book))
12
- end
13
-
14
- private
15
-
16
- def read_roo(file, &block)
17
- require 'roo'
18
- Roo::Spreadsheet.open(file, extension: File.extname(file))
19
- .each_with_pagename(&block)
20
- end
21
-
22
- def page_processor(book)
23
- lambda do |pagename_and_page|
24
- pagename, page = pagename_and_page
25
- page.first_row && book.add_sheet(pagename, collect_cells(page))
26
- end
27
- end
28
-
29
- def collect_cells(page)
30
- (1..page.last_row).map do |row|
31
- (1..page.last_column).map { |column| page.cell(row, column) }
32
- end
33
- end
34
- end
35
- end
36
- end