rggen-spreadsheet-loader 0.20.0 → 0.22.1

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: c6d2262607ca5ee32919659967bc45109e23f85d1cb35fde4887ac87fc292a31
4
+ data.tar.gz: 0f659c416f9c5c1cc946e6eec0fd9b0e01d1ad4a1aacc1177374cd628ec7cb6c
5
5
  SHA512:
6
- metadata.gz: 23770bfa1f24804808d6c75885f07338831f18833147c165783b8dd1bac3edde07e90f281f1ed2f326fcf71487ff972bb1f14353d08142491660a68997b57676
7
- data.tar.gz: e162d610aa891cd2928370e9cb8f9bf6d4057be34f344efc855de1539ecc2b743054c4d00d4209a999747facbe579cf947fc8cdae44f2c36e72dfbd29cf33c40
6
+ metadata.gz: 39b07729604ec7c6658d430e6e596382170524e0fedf82127ff98e5acb0cc9ba10399220a6b51cbd71b56101ba47eb22fc7be9feaf57f30b139342d53029d276
7
+ data.tar.gz: 711dad4ead0057108a78a15b69ac003de52114b700d5f1d6c5a25295fb9808e6007a92535320c5279ac0566a54fac2b4faaac9b2a88a5ceeaac7db7b4874fd32
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
@@ -33,14 +33,15 @@ $ gem install rggen-spreadsheet-loader
33
33
 
34
34
  Feedbacks, bug reports, questions and etc. are wellcome! You can post them by using following ways:
35
35
 
36
- * [GitHub Issue Tracker](https://github.com/rggen/rggen-spreadsheet-loader/issues)
36
+ * [GitHub Issue Tracker](https://github.com/rggen/rggen/issues)
37
+ * [GitHub Discussions](https://github.com/rggen/rggen/discussions)
37
38
  * [Chat Room](https://gitter.im/rggen/rggen)
38
39
  * [Mailing List](https://groups.google.com/d/forum/rggen)
39
40
  * [Mail](mailto:rggen@googlegroups.com)
40
41
 
41
42
  ## Copyright & License
42
43
 
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.
44
+ 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
45
 
45
46
  ## Code of Conduct
46
47
 
@@ -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.22.1'
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.count.positive? &&
20
+ book.add_sheet(sheet.name, sheet.rows)
21
+ end
22
+ end
23
+ end
24
+ end
@@ -8,17 +8,21 @@ 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
- module RgGen
15
- module SpreadsheetLoader
16
- extend Core::Plugin
15
+ RgGen.setup_plugin :'rggen-spreadsheet-loader' do |plugin|
16
+ plugin.version RgGen::SpreadsheetLoader::VERSION
17
+ plugin.setup_loader :register_map, :spreadsheet do |entry|
18
+ entry.register_loaders [
19
+ RgGen::SpreadsheetLoader::CSVLoader,
20
+ RgGen::SpreadsheetLoader::ODSLoader,
21
+ RgGen::SpreadsheetLoader::XLSLoader,
22
+ RgGen::SpreadsheetLoader::XLSXLoader
23
+ ]
17
24
 
18
- 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
22
- end
25
+ entry.ignore_value :register_block, :comment
26
+ entry.ignore_value :register, :comment
23
27
  end
24
28
  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.22.1
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-08-21 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,8 +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
68
- - lib/rggen/spreadsheet_loader/setup.rb
81
+ - lib/rggen/spreadsheet_loader/ods_loader.rb
69
82
  - lib/rggen/spreadsheet_loader/spreadsheet/book.rb
70
83
  - lib/rggen/spreadsheet_loader/spreadsheet/cell.rb
71
84
  - lib/rggen/spreadsheet_loader/spreadsheet/position.rb
@@ -74,12 +87,14 @@ files:
74
87
  - lib/rggen/spreadsheet_loader/spreadsheet_loader.rb
75
88
  - lib/rggen/spreadsheet_loader/version.rb
76
89
  - lib/rggen/spreadsheet_loader/xls_loader.rb
90
+ - lib/rggen/spreadsheet_loader/xlsx_loader.rb
77
91
  homepage: https://github.com/rggen/rggen-spreadsheet-loader
78
92
  licenses:
79
93
  - MIT
80
94
  metadata:
81
- bug_tracker_uri: https://github.com/rggen/rggen-spreadsheet-loader/issues
95
+ bug_tracker_uri: https://github.com/rggen/rggen/issues
82
96
  mailing_list_uri: https://groups.google.com/d/forum/rggen
97
+ rubygems_mfa_required: 'true'
83
98
  source_code_uri: https://github.com/rggen/rggen-spreadsheet-loader
84
99
  wiki_uri: https://github.com/rggen/rggen/wiki
85
100
  post_install_message:
@@ -90,15 +105,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
90
105
  requirements:
91
106
  - - ">="
92
107
  - !ruby/object:Gem::Version
93
- version: '2.5'
108
+ version: '2.6'
94
109
  required_rubygems_version: !ruby/object:Gem::Requirement
95
110
  requirements:
96
111
  - - ">="
97
112
  - !ruby/object:Gem::Version
98
113
  version: '0'
99
114
  requirements: []
100
- rubygems_version: 3.2.3
115
+ rubygems_version: 3.3.7
101
116
  signing_key:
102
117
  specification_version: 4
103
- summary: rggen-spreadsheet-loader-0.20.0
118
+ summary: rggen-spreadsheet-loader-0.22.1
104
119
  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
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rggen/spreadsheet_loader'
4
-
5
- RgGen.register_plugin RgGen::SpreadsheetLoader do |builder|
6
- builder.ignore_value :register_map, :spreadsheet, :register_block, :comment
7
- builder.ignore_value :register_map, :spreadsheet, :register, :comment
8
- end