rggen-spreadsheet-loader 0.19.0 → 0.22.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: 9a9e3cd2d0e9852524f09edcecf3d62cab2a6b496f4f59571052cb0c7b879aba
4
- data.tar.gz: 491fb225fd336ccc3640d1359849fe0383850e1d94b0a70502dbccdec111191d
3
+ metadata.gz: b5ce9ef2c15d7c9f7342f30ab32f262e6a94e2cc4d33e43a43ee9ecfed7a0246
4
+ data.tar.gz: ed3b67e0e3e2da74eee1e4c747e0faf06db85884238d0438433bf7930dec5766
5
5
  SHA512:
6
- metadata.gz: 88dd693a44503622b944dc5ddead75f8c1845ba48ab8dd9c7e1ff2d69096f6e491ae6dbb67ad0f96015e9dcdbc8dfd04761ced92a289cff893f13fbbad04dc91
7
- data.tar.gz: e1544ef459e4f3dc3a4ade4e8d5396b66d9be1f4eaac30adaf77e0330c9bd08567ed8ae520712e77c77edd2831aaafb06665ece1f94dc5a7f8cd475df20bfe5a
6
+ metadata.gz: 95928dbd88bb525055d95c8f1de3fa8b4bb9852cb1ee170a96c78aa3673ffb3c959e9ca79779f02e8625571c5f1258edb2f865c76db103fd0ad3ddf67729bc98
7
+ data.tar.gz: bc9aea1778d1e2a7a4b87d36fbdf68dfe5f571fcf9ff05fd28bbd1671d4b86833aa9e4408f2471ee315f0788f335f70e499330790dbe902749fe3a9d3f960654
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)
@@ -58,7 +59,8 @@ module RgGen
58
59
  end
59
60
 
60
61
  def collect_register_data(sheet)
61
- sheet.rows(register_start_position.row)
62
+ sheet
63
+ .rows(register_start_position.row)
62
64
  .reject { |row| row.cells.all?(&:empty_cell?) }
63
65
  .each_with_object([], &method(:collect_register_rows))
64
66
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RgGen
4
4
  module SpreadsheetLoader
5
- VERSION = '0.19.0'
5
+ VERSION = '0.22.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,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.19.0
4
+ version: 0.22.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-01-20 00:00:00.000000000 Z
11
+ date: 2022-07-05 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.4'
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.3
101
116
  signing_key:
102
117
  specification_version: 4
103
- summary: rggen-spreadsheet-loader-0.19.0
118
+ summary: rggen-spreadsheet-loader-0.22.0
104
119
  test_files: []
@@ -1,33 +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) do |pagename, page|
12
- book.add_sheet(pagename, collect_cells(page))
13
- end
14
- end
15
-
16
- private
17
-
18
- def read_roo(file)
19
- require 'roo'
20
- Roo::Spreadsheet.open(file, extension: File.extname(file))
21
- .each_with_pagename do |pagename, page|
22
- page.first_row && yield(pagename, page)
23
- end
24
- end
25
-
26
- def collect_cells(page)
27
- (1..page.last_row).map do |row|
28
- (1..page.last_column).map { |column| page.cell(row, column) }
29
- end
30
- end
31
- end
32
- end
33
- 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