rggen-spreadsheet-loader 0.18.0 → 0.18.2

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: 3074fea36ab23767182a60bb5c9d1af90f8a2cd17435cd987a86c429671e67ae
4
- data.tar.gz: ae2e1998d57db665cca20101723ee8ddffb3a15989c5d3ded0bd525fa85ec7dd
3
+ metadata.gz: bb30337ed0f7670b7a30412298d500efc2c43a68b23c62cb24710cbd177d6712
4
+ data.tar.gz: 120d91e46af469f9843844afcfdf1d2ec736bada9d57b5405db9ae16bd52aa49
5
5
  SHA512:
6
- metadata.gz: a75fdae70158612c94788bbb5a857bfe589359247c17d47c1a96f97dc12acf6de74392b6eb46703e1ecc5c26eb795ca30e9a126f9123375de02c95aa1c31dfa0
7
- data.tar.gz: 3a4d916d2311ad2b84d23c8bad5344effd12df0e2c91da9c5c78835d9ee564be6ffdee1969c056b7efadefc33f2dd1aee9724edf774e15d1c9bc18a5df77d76a
6
+ metadata.gz: baaede9d7b9dcdcbe08c7671a17da7ae8847cab6d6f5ab9f0c1154419bd321256a7951414f70e0aa5f9b56d6ef452ecd87027ddcf39ecc9f4f16537d6a9300ed
7
+ data.tar.gz: b2bf6f9e744ba823cdcbc77b776f59805c9df88ebd107fa9e18830d5baf0396743989da7e7576fb29f2d3fa1be2d1c240abbd114018f86d3c8bf7bbc55616a51
@@ -5,7 +5,7 @@ module RgGen
5
5
  class CSVLoader < Core::RegisterMap::Loader
6
6
  include SpreadsheetLoader
7
7
 
8
- support_types [:csv]
8
+ support_types [:csv, :tsv]
9
9
 
10
10
  def read_spreadsheet(file, book)
11
11
  sheet = read_csv(file)
@@ -17,7 +17,12 @@ module RgGen
17
17
 
18
18
  def read_csv(file)
19
19
  require 'csv'
20
- CSV.read(file)
20
+ CSV.read(file, col_sep: separator(file))
21
+ end
22
+
23
+ def separator(file)
24
+ ext = File.extname(file)
25
+ ext.casecmp?('.tsv') && "\t" || ','
21
26
  end
22
27
  end
23
28
  end
@@ -59,11 +59,16 @@ module RgGen
59
59
  def collect_register_data(sheet)
60
60
  sheet.rows(register_start_position.row)
61
61
  .reject { |row| row.cells.all?(&:empty_cell?) }
62
- .each_with_object([]) do |row, row_sets|
63
- row[register_start_position.column].empty_cell? ||
64
- (row_sets << [])
65
- row_sets.last << row
66
- end
62
+ .each_with_object([], &method(:collect_register_rows))
63
+ end
64
+
65
+ def collect_register_rows(row, row_sets)
66
+ register_begin?(row) && (row_sets << [])
67
+ row_sets.last << row
68
+ end
69
+
70
+ def register_begin?(row)
71
+ !row[register_start_position.column].empty_cell?
67
72
  end
68
73
 
69
74
  def collect_bit_field_data(rows)
@@ -81,11 +86,11 @@ module RgGen
81
86
 
82
87
  def bit_field_start_position
83
88
  @bit_field_start_position ||=
84
- begin
85
- column =
86
- register_start_position.column + valid_values(:register).size
87
- Position.new(0, column)
88
- end
89
+ Position.new(0, bit_field_start_column)
90
+ end
91
+
92
+ def bit_field_start_column
93
+ register_start_position.column + valid_values(:register).size
89
94
  end
90
95
  end
91
96
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RgGen
4
4
  module SpreadsheetLoader
5
- VERSION = '0.18.0'
5
+ VERSION = '0.18.2'
6
6
  end
7
7
  end
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.18.0
4
+ version: 0.18.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taichi Ishitani
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-17 00:00:00.000000000 Z
11
+ date: 2020-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: roo
@@ -100,5 +100,5 @@ requirements: []
100
100
  rubygems_version: 3.1.2
101
101
  signing_key:
102
102
  specification_version: 4
103
- summary: rggen-spreadsheet-loader-0.18.0
103
+ summary: rggen-spreadsheet-loader-0.18.2
104
104
  test_files: []