rggen-spreadsheet-loader 0.25.2 → 0.25.3

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: 4f7b3c91e9e412c531d110ccdc0fb860d44c4d3cfb1a4180e739dbd7fda8e7b2
4
- data.tar.gz: 83b9e7f37e92f00869684f2a50569dc2f8b959412e8fe120d8022970c9218721
3
+ metadata.gz: c5bf64cb074862e23c184ac78876386609d3d490e0d73df93fe51792025ff06e
4
+ data.tar.gz: 2d040f729f9814615804526850226929826d21990c0e564ffbd23aa8de473045
5
5
  SHA512:
6
- metadata.gz: d13623f4bf9345638351590b05f11af9a061df988ca7fa170579a305b3ea21605ba3892faca4e0b3c3aad51f952d7270b1e8c26edc9fa57da4af9a2b5f19a8f4
7
- data.tar.gz: e00d35edbd848c9150838dc2435bdf0853b317e04adcb4698212c2d76e648243da8865a64d8a3e60ecdc137abdb4b3936fa864091491346d27450a4408329be5
6
+ metadata.gz: 70135e09a97f971bb5ff38e707f06af2d0bb4f568017070043160cc42357ec6d234e2c72e60c104d0c0dd71c6071533814cb1e3d81213e71d4e2cfdf597be836
7
+ data.tar.gz: f868400bb4e8e70b264c17c150bd83089cf7d180057f9ec63b0c4f1c73f5b83b00eca14f90ca55f7beb80a8e0c82337825dd91e1e8c4557a4a906b8de37f81c5
data/README.md CHANGED
@@ -10,7 +10,7 @@ RgGen::SpreadsheetLoader adds ability to load register map documents written in
10
10
 
11
11
  Supported spreadsheet formats are listed below:
12
12
 
13
- * MS Excel (xlsx and xls)
13
+ * MS Excel (xlsx)
14
14
  * LibreOffice/OpenOffice (ods)
15
15
  * CSV
16
16
 
@@ -16,7 +16,6 @@ module RgGen
16
16
  private
17
17
 
18
18
  def read_csv(file)
19
- require 'csv'
20
19
  CSV.read(file, col_sep: separator(file))
21
20
  end
22
21
 
@@ -8,7 +8,6 @@ module RgGen
8
8
  support_types [:ods]
9
9
 
10
10
  def read_spreadsheet(file, book)
11
- require 'spreadbase'
12
11
  SpreadBase::Document.new(file)
13
12
  .tables.each { |table| process_table(table, book) }
14
13
  end
@@ -3,11 +3,27 @@
3
3
  module RgGen
4
4
  module SpreadsheetLoader
5
5
  module Spreadsheet
6
- Position = Struct.new(:file, :sheet, :row, :column) do
6
+ class Position
7
+ def initialize(file, sheet, row, column)
8
+ @file = file
9
+ @sheet = sheet
10
+ @row = row
11
+ @column = column
12
+ end
13
+
14
+ attr_reader :file
15
+ attr_reader :sheet
16
+
17
+ def row
18
+ @row + 1
19
+ end
20
+
21
+ def column
22
+ @column.times.inject('A') { |l, _| l.next }
23
+ end
24
+
7
25
  def to_s
8
- to_h
9
- .map { |field, value| "#{field}: #{value}" }
10
- .join(' ')
26
+ "file: #{file} sheet: #{sheet} row: #{row} column: #{column}"
11
27
  end
12
28
  end
13
29
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RgGen
4
4
  module SpreadsheetLoader
5
- VERSION = '0.25.2'
5
+ VERSION = '0.25.3'
6
6
  end
7
7
  end
@@ -8,7 +8,6 @@ module RgGen
8
8
  support_types [:xlsx]
9
9
 
10
10
  def read_spreadsheet(file, book)
11
- require 'simple_xlsx_reader'
12
11
  SimpleXlsxReader.open(file)
13
12
  .sheets.each { |sheet| process_sheet(sheet, book) }
14
13
  end
@@ -1,5 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ autoload :CSV, 'csv'
4
+ autoload :SimpleXlsxReader, 'simple_xlsx_reader'
5
+ autoload :SpreadBase, 'spreadbase'
6
+
3
7
  require_relative 'spreadsheet_loader/version'
4
8
  require_relative 'spreadsheet_loader/spreadsheet/position'
5
9
  require_relative 'spreadsheet_loader/spreadsheet/cell'
@@ -9,7 +13,6 @@ require_relative 'spreadsheet_loader/spreadsheet/book'
9
13
  require_relative 'spreadsheet_loader/spreadsheet_loader'
10
14
  require_relative 'spreadsheet_loader/csv_loader'
11
15
  require_relative 'spreadsheet_loader/ods_loader'
12
- require_relative 'spreadsheet_loader/xls_loader'
13
16
  require_relative 'spreadsheet_loader/xlsx_loader'
14
17
 
15
18
  RgGen.setup_plugin :'rggen-spreadsheet-loader' do |plugin|
@@ -18,7 +21,6 @@ RgGen.setup_plugin :'rggen-spreadsheet-loader' do |plugin|
18
21
  entry.register_loaders [
19
22
  RgGen::SpreadsheetLoader::CSVLoader,
20
23
  RgGen::SpreadsheetLoader::ODSLoader,
21
- RgGen::SpreadsheetLoader::XLSLoader,
22
24
  RgGen::SpreadsheetLoader::XLSXLoader
23
25
  ]
24
26
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rggen-spreadsheet-loader
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.25.2
4
+ version: 0.25.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taichi Ishitani
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-23 00:00:00.000000000 Z
11
+ date: 2024-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: csv
@@ -52,20 +52,6 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: 0.6.0
55
- - !ruby/object:Gem::Dependency
56
- name: spreadsheet
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: 1.2.5
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: 1.2.5
69
55
  description: Spreadsheet loader for RgGen register map.
70
56
  email:
71
57
  - rggen@googlegroups.com
@@ -86,7 +72,6 @@ files:
86
72
  - lib/rggen/spreadsheet_loader/spreadsheet/sheet.rb
87
73
  - lib/rggen/spreadsheet_loader/spreadsheet_loader.rb
88
74
  - lib/rggen/spreadsheet_loader/version.rb
89
- - lib/rggen/spreadsheet_loader/xls_loader.rb
90
75
  - lib/rggen/spreadsheet_loader/xlsx_loader.rb
91
76
  homepage: https://github.com/rggen/rggen-spreadsheet-loader
92
77
  licenses:
@@ -115,5 +100,5 @@ requirements: []
115
100
  rubygems_version: 3.5.5
116
101
  signing_key:
117
102
  specification_version: 4
118
- summary: rggen-spreadsheet-loader-0.25.2
103
+ summary: rggen-spreadsheet-loader-0.25.3
119
104
  test_files: []
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RgGen
4
- module SpreadsheetLoader
5
- class XLSLoader < Core::RegisterMap::Loader
6
- include SpreadsheetLoader
7
-
8
- support_types [:xls]
9
-
10
- def read_spreadsheet(file, book)
11
- read_xls(file).each do |sheet|
12
- book.add_sheet(sheet.name, sheet.rows)
13
- end
14
- end
15
-
16
- private
17
-
18
- def read_xls(file)
19
- require 'spreadsheet'
20
- ::Spreadsheet.open(file, 'rb') do |book|
21
- book.worksheets.select { |sheet| sheet.row_count.positive? }
22
- end
23
- end
24
- end
25
- end
26
- end