rggen-spreadsheet-loader 0.25.1 → 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: 846308d8caaad7e74d696d8fff51773dd6fa0a4283628d2a4ab46bda69397005
4
- data.tar.gz: 1eafeb29fda650a323165ad6dbc9e1f2e9217b521b08ca4a2337c691536953fe
3
+ metadata.gz: c5bf64cb074862e23c184ac78876386609d3d490e0d73df93fe51792025ff06e
4
+ data.tar.gz: 2d040f729f9814615804526850226929826d21990c0e564ffbd23aa8de473045
5
5
  SHA512:
6
- metadata.gz: 39c4e72865263bc9e55500b3a0f2863551625b8f9d0cb8e0e082c78836ae24dfd5f1cc23954160c918fd69aea962450b025b62386351d7ac898b6a3527cc1d3c
7
- data.tar.gz: d2c4f78721fbe0d46ec2ad252e7d2e76d96fedb78e3182b0ce604a4bf3ae6c8546e37adfab44e2698737da3a635799f70fc794267af58d432461e3fad46d9f66
6
+ metadata.gz: 70135e09a97f971bb5ff38e707f06af2d0bb4f568017070043160cc42357ec6d234e2c72e60c104d0c0dd71c6071533814cb1e3d81213e71d4e2cfdf597be836
7
+ data.tar.gz: f868400bb4e8e70b264c17c150bd83089cf7d180057f9ec63b0c4f1c73f5b83b00eca14f90ca55f7beb80a8e0c82337825dd91e1e8c4557a4a906b8de37f81c5
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2019-2023 Taichi Ishitani
3
+ Copyright (c) 2019-2024 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
@@ -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
 
@@ -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-2023 Taichi Ishitani. RgGen::SpreadsheetLoader is licensed under the [MIT License](https://opensource.org/licenses/MIT), see [LICENSE](LICENSE) for futher details.
43
+ Copyright © 2019-2024 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
 
@@ -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.1'
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.1
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-03 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
@@ -44,28 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 0.5.0
47
+ version: 0.6.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: 0.5.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
54
+ version: 0.6.0
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:
@@ -112,8 +97,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
97
  - !ruby/object:Gem::Version
113
98
  version: '0'
114
99
  requirements: []
115
- rubygems_version: 3.5.3
100
+ rubygems_version: 3.5.5
116
101
  signing_key:
117
102
  specification_version: 4
118
- summary: rggen-spreadsheet-loader-0.25.1
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