tabular 0.4.2 → 0.4.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 06bed6b335edf9465b7f56b489f5544ec11b4ee4
4
- data.tar.gz: 8679fb4cd37f748c6f9f0f6e9fe80e01af31cb49
2
+ SHA256:
3
+ metadata.gz: c19a82173246cea63f0982182ac47392729a607b2d5317de215713e8b5a45b85
4
+ data.tar.gz: 4256afcc9b6ab088be5172f65bf319c03f75b7a9f6ba9a09598010278eba603a
5
5
  SHA512:
6
- metadata.gz: 70e496dbbf3fce7bc1350905279fb895d64197f8f4403de65572317661b6d64024ee94d2377aa0e5225840e5c9a8cc80ae3bf1fe9b09d5fca4b44ff142ac7ab3
7
- data.tar.gz: 3a35d6603c2c8fe97b8db93ed19817e347530f2b596d2cf9fc8a6b681e55a26f05271fbca172581f8e36123d48457038a82a347e1320e16b5d237b834a110c0c
6
+ metadata.gz: 3856bd6dceea72caf352f57eeb687e227899549d3f3498a77ecacfd1db080d986ff0f71047b22ea5e6d11063e5d6f260f3990b2b2dac2fd316d617043aa72958
7
+ data.tar.gz: 4a8db3195a5d17e58520831406931d9e401c8e6f1e946c5d85a1f75d9c48d214ab8aeb421323f076eb45a839aff7c5cd7492b696a33a45f36c393c5211308cc6
data/Gemfile CHANGED
@@ -1,5 +1,16 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source "https://rubygems.org"
2
4
 
5
+ ruby ">= 2.4.0"
6
+
7
+ git_source(:github) { |name| "https://github.com/#{name}.git" }
8
+
9
+ gem "bundler", ">= 2.0"
10
+ gem "bundler-audit"
11
+ gem "minitest"
3
12
  gem "rake"
4
- gem "roo", github: "roo-rb/roo"
5
- gem "roo-xls", github: "roo-rb/roo-xls"
13
+ gem "roo", github: "scottwillson/roo"
14
+ gem "roo-xls"
15
+
16
+ gemspec
@@ -1,36 +1,51 @@
1
1
  GIT
2
- remote: git://github.com/roo-rb/roo-xls.git
3
- revision: a316a88d042ca6e28a83c46a0db1906a9feebb62
2
+ remote: https://github.com/scottwillson/roo.git
3
+ revision: 7affb556878466faf1a476f2ed5802f6af5b1066
4
4
  specs:
5
- roo-xls (0.0.1)
6
- nokogiri
7
- roo (>= 2.0.0)
8
- spreadsheet (> 0.9.0)
5
+ roo (2.8.2)
6
+ nokogiri (~> 1)
7
+ rubyzip (>= 1.2.1, < 2.0.0)
9
8
 
10
- GIT
11
- remote: git://github.com/roo-rb/roo.git
12
- revision: 12f3f7b1b9c7cc31cada36db360125531d408405
9
+ PATH
10
+ remote: .
13
11
  specs:
14
- roo (2.0.0)
15
- nokogiri
16
- rubyzip (>= 1.0.0)
12
+ tabular (0.4.8)
17
13
 
18
14
  GEM
19
15
  remote: https://rubygems.org/
20
16
  specs:
21
- mini_portile (0.6.2)
22
- nokogiri (1.6.5)
23
- mini_portile (~> 0.6.0)
24
- rake (10.4.2)
25
- ruby-ole (1.2.11.8)
26
- rubyzip (1.1.6)
27
- spreadsheet (1.0.0)
17
+ bundler-audit (0.7.0.1)
18
+ bundler (>= 1.2.0, < 3)
19
+ thor (>= 0.18, < 2)
20
+ mini_portile2 (2.4.0)
21
+ minitest (5.14.2)
22
+ nokogiri (1.10.10)
23
+ mini_portile2 (~> 2.4.0)
24
+ rake (13.0.1)
25
+ roo-xls (1.2.0)
26
+ nokogiri
27
+ roo (>= 2.0.0, < 3)
28
+ spreadsheet (> 0.9.0)
29
+ ruby-ole (1.2.12.2)
30
+ rubyzip (1.3.0)
31
+ spreadsheet (1.2.6)
28
32
  ruby-ole (>= 1.0)
33
+ thor (1.0.1)
29
34
 
30
35
  PLATFORMS
31
36
  ruby
32
37
 
33
38
  DEPENDENCIES
39
+ bundler (>= 2.0)
40
+ bundler-audit
41
+ minitest
34
42
  rake
35
43
  roo!
36
- roo-xls!
44
+ roo-xls
45
+ tabular!
46
+
47
+ RUBY VERSION
48
+ ruby 2.6.0p0
49
+
50
+ BUNDLED WITH
51
+ 2.1.4
data/README CHANGED
@@ -62,6 +62,8 @@ There's basic test coverage. More comprehensive test coverage needs to be extrac
62
62
 
63
63
  Changes
64
64
  -------
65
+ 0.4.6 Gem updates. Lint.
66
+ 0.4.3 Gem updates
65
67
  0.4.2 Refactor minor ugly things. No behavior changes.
66
68
  0.4.0 rchristensen: Add sheet argument to Table.read
67
69
  0.3.0 Revise Table creation methods to something sensible. Use Roo to read
@@ -95,4 +97,4 @@ Changes
95
97
  Copyright
96
98
  ---------
97
99
 
98
- Copyright (c) 2014 Scott Willson. See LICENSE for details.
100
+ Copyright (c) 2019 Scott Willson. See LICENSE for details.
data/Rakefile CHANGED
@@ -1,21 +1,23 @@
1
- require 'rubygems'
2
- require 'rake'
1
+ # frozen_string_literal: true
3
2
 
4
- require 'rake/testtask'
3
+ require "rubygems"
4
+ require "rake"
5
+
6
+ require "rake/testtask"
5
7
  Rake::TestTask.new(:test) do |test|
6
- test.libs << 'lib' << 'test'
7
- test.pattern = 'test/**/*_test.rb'
8
+ test.libs << "lib" << "test"
9
+ test.pattern = "test/**/*_test.rb"
8
10
  test.verbose = true
9
11
  end
10
12
 
11
- task :default => :test
13
+ task default: :test
12
14
 
13
- require 'rdoc/task'
15
+ require "rdoc/task"
14
16
  Rake::RDocTask.new do |rdoc|
15
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
17
+ version = File.exist?("VERSION") ? File.read("VERSION") : ""
16
18
 
17
- rdoc.rdoc_dir = 'rdoc'
19
+ rdoc.rdoc_dir = "rdoc"
18
20
  rdoc.title = "tabular #{version}"
19
- rdoc.rdoc_files.include('README*')
20
- rdoc.rdoc_files.include('lib/**/*.rb')
21
+ rdoc.rdoc_files.include("README*")
22
+ rdoc.rdoc_files.include("lib/**/*.rb")
21
23
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "rubygems"
2
4
 
3
5
  $LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../lib")
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tabular
2
4
  # Don't mess with Object
3
5
  module Blank
4
- def is_blank?(object)
6
+ def is_blank?(object) # rubocop:disable Naming/PredicateName
5
7
  case object
6
8
  when NilClass
7
9
  true
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tabular
2
4
  class Column
3
5
  attr_reader :key, :column_type
@@ -10,13 +12,13 @@ module Tabular
10
12
  @table = table
11
13
  @key = self.columns.column_mapper.map(key)
12
14
 
13
- if @key && @key.to_s["date"]
14
- @column_type = :date
15
- elsif @key && @key.to_s[/\?\z/]
16
- @column_type = :boolean
17
- else
18
- @column_type = :string
19
- end
15
+ @column_type = if @key && @key.to_s["date"]
16
+ :date
17
+ elsif @key && @key.to_s[/\?\z/]
18
+ :boolean
19
+ else
20
+ :string
21
+ end
20
22
  end
21
23
 
22
24
  def rows
@@ -35,7 +37,7 @@ module Tabular
35
37
 
36
38
  # Number of zeros to the right of the decimal point. Useful for formtting time data.
37
39
  def precision
38
- @precision ||= cells.map(&:to_f).map {|n| n.round(3) }.map {|n| n.to_s.split(".").last.gsub(/0+$/, "").length }.max
40
+ @precision ||= cells.map(&:to_f).map { |n| n.round(3) }.map { |n| n.to_s.split(".").last.gsub(/0+$/, "").length }.max
39
41
  end
40
42
 
41
43
  # Widest string in column
@@ -65,7 +67,6 @@ module Tabular
65
67
  key.to_s
66
68
  end
67
69
 
68
-
69
70
  protected
70
71
 
71
72
  def columns
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tabular
2
4
  class ColumnMapper
3
5
  include Tabular::Blank
@@ -5,22 +7,21 @@ module Tabular
5
7
  # Convert +key+ to normalized symbol. Subclass for more complex mapping.
6
8
  def map(key)
7
9
  return nil if is_blank?(key)
10
+
8
11
  symbolize key
9
12
  end
10
13
 
11
14
  def symbolize(key)
12
- begin
13
- key.to_s.strip.gsub(/::/, '/').
14
- gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
15
- gsub(/([a-z\d])([A-Z])/,'\1_\2').
16
- tr("-", "_").
17
- gsub(/ +/, "_").
18
- delete(";").
19
- downcase.
20
- to_sym
21
- rescue
22
- nil
23
- end
15
+ key.to_s.strip.gsub(/::/, "/")
16
+ .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
17
+ .gsub(/([a-z\d])([A-Z])/, '\1_\2')
18
+ .tr("-", "_")
19
+ .gsub(/ +/, "_")
20
+ .delete(";")
21
+ .downcase
22
+ .to_sym
23
+ rescue StandardError
24
+ nil
24
25
  end
25
26
  end
26
27
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tabular
2
4
  # The Table's header: a list of Columns.
3
5
  class Columns
@@ -5,8 +7,8 @@ module Tabular
5
7
  include Tabular::Blank
6
8
  include Tabular::Keys
7
9
 
8
- attr_accessor :column_mapper
9
- attr_accessor :renderer
10
+ attr_writer :column_mapper
11
+ attr_writer :renderer
10
12
 
11
13
  # +table+ -- Table
12
14
  # +data+ -- array of header names
@@ -17,6 +19,7 @@ module Tabular
17
19
 
18
20
  def initialize(table = Table.new, names = [], column_mapper = nil)
19
21
  @table = table
22
+ @renderer = nil
20
23
  self.column_mapper = column_mapper
21
24
 
22
25
  @column_indexes = {}
@@ -28,9 +31,7 @@ module Tabular
28
31
  def set_columns(table = Table.new, names = [])
29
32
  index = 0
30
33
 
31
- if names.respond_to?(:keys)
32
- names = names.keys
33
- end
34
+ names = names.keys if names.respond_to?(:keys)
34
35
 
35
36
  @columns = names.map do |name|
36
37
  new_column = Tabular::Column.new(table, self, name)
@@ -38,14 +39,23 @@ module Tabular
38
39
  @column_indexes[new_column.key] = index
39
40
  @columns_by_key[new_column.key] = new_column
40
41
  end
41
- index = index + 1
42
+ index += 1
42
43
  new_column
43
44
  end
44
45
  end
45
46
 
47
+ def empty?
48
+ size.zero?
49
+ end
50
+
51
+ # Deprecated
52
+ def has_key?(key) # rubocop:disable Naming/PredicateName
53
+ key? key
54
+ end
55
+
46
56
  # Is the a Column with this key? Keys are lower-case, underscore symbols.
47
57
  # Example: :postal_code
48
- def has_key?(key)
58
+ def key?(key)
49
59
  @columns.any? { |column| column.key == key }
50
60
  end
51
61
 
@@ -67,12 +77,12 @@ module Tabular
67
77
  # Add a new Column with +key+
68
78
  def <<(key)
69
79
  column = Column.new(@table, self, key)
70
- unless is_blank?(column.key) || has_key?(key)
71
- @column_indexes[column.key] = @columns.size
72
- @column_indexes[@columns.size] = column
73
- @columns_by_key[column.key] = column
74
- @columns << column
75
- end
80
+ return if is_blank?(column.key) || key?(key)
81
+
82
+ @column_indexes[column.key] = @columns.size
83
+ @column_indexes[@columns.size] = column
84
+ @columns_by_key[column.key] = column
85
+ @columns << column
76
86
  end
77
87
 
78
88
  def delete(key)
@@ -90,7 +100,7 @@ module Tabular
90
100
  @columns.size
91
101
  end
92
102
 
93
- # Renderer for Column +key+. Default to Table#renderer.
103
+ # Renderer for Column +key+. Default to Table#Renderer.
94
104
  def renderer(key)
95
105
  renderers[key] || @renderer || Renderer
96
106
  end
@@ -1,8 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tabular
2
4
  module Keys
3
5
  # Return Symbol for +key+. Translate Column and String. Return +key+ unmodified for anything else.
4
6
  def key_to_sym(key)
5
- _key = case key
7
+ case key
6
8
  when Column
7
9
  key.key
8
10
  when String
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tabular
2
4
  # Custom display of cells. By default, return to_s.
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "date"
2
4
 
3
5
  module Tabular
@@ -38,7 +40,7 @@ module Tabular
38
40
 
39
41
  # Set cell value. Adds cell to end of Row and adds new Column if there is no Column for +key_
40
42
  def []=(key, value)
41
- if columns.has_key?(key)
43
+ if columns.key?(key)
42
44
  @array[columns.index(key)] = value
43
45
  else
44
46
  @array << value
@@ -52,6 +54,11 @@ module Tabular
52
54
  @array.each(&block)
53
55
  end
54
56
 
57
+ # Call +block+ for each key
58
+ def each_key(&block)
59
+ keys.each(&block)
60
+ end
61
+
55
62
  # Call +block+ for each cell
56
63
  def each_with_key(&block)
57
64
  hash.each(&block)
@@ -74,9 +81,7 @@ module Tabular
74
81
 
75
82
  # Previous Row
76
83
  def previous
77
- if index > 0
78
- @table.rows[index - 1]
79
- end
84
+ @table.rows[index - 1] if index.positive?
80
85
  end
81
86
 
82
87
  # Next Row
@@ -113,13 +118,13 @@ module Tabular
113
118
  end
114
119
 
115
120
  def to_space_delimited
116
- _cells = []
121
+ cells = []
117
122
 
118
- hash.each do |key, _|
119
- _cells << (render(key) || "").ljust(columns[key].width)
123
+ hash.each_key do |key|
124
+ cells << (render(key) || "").ljust(columns[key].width)
120
125
  end
121
126
 
122
- _cells.join " "
127
+ cells.join " "
123
128
  end
124
129
 
125
130
  def inspect
@@ -130,7 +135,6 @@ module Tabular
130
135
  @array.join(", ").to_s
131
136
  end
132
137
 
133
-
134
138
  protected
135
139
 
136
140
  def hash #:nodoc:
@@ -138,13 +142,11 @@ module Tabular
138
142
  end
139
143
 
140
144
  def build_hash #:nodoc:
141
- _hash = Hash.new
145
+ hash = {}
142
146
  columns.each do |column|
143
- if column.key
144
- _hash[column.key] = value_for_hash(column)
145
- end
147
+ hash[column.key] = value_for_hash(column) if column.key
146
148
  end
147
- _hash
149
+ hash
148
150
  end
149
151
 
150
152
  def value_for_hash(column) #:nodoc:
@@ -155,7 +157,7 @@ module Tabular
155
157
 
156
158
  case column.column_type
157
159
  when :boolean
158
- [ 1, "1", true, "true" ].include?(value)
160
+ [1, "1", true, "true"].include?(value)
159
161
  when :date
160
162
  if date?(value)
161
163
  value
@@ -167,7 +169,6 @@ module Tabular
167
169
  end
168
170
  end
169
171
 
170
-
171
172
  private
172
173
 
173
174
  def date?(value)
@@ -181,11 +182,7 @@ module Tabular
181
182
  Date.parse(value.to_s, true)
182
183
  rescue ArgumentError
183
184
  date = parse_invalid_date(value)
184
- if date
185
- date
186
- else
187
- raise ArgumentError, "'#{key}' index #{index} #{value}' is not a valid date"
188
- end
185
+ date || raise(ArgumentError, "'#{key}' index #{index} #{value}' is not a valid date")
189
186
  end
190
187
  end
191
188
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tabular
2
4
  # Simple Enumerable list of Hashes. Use Table.read(file_path) to read file. Can also create a Table with Table.new. Either
3
5
  # pass in data or set options and then call row=.
@@ -7,9 +9,8 @@ module Tabular
7
9
  include Tabular::Tables::FileReading
8
10
  include Tabular::Zero
9
11
 
10
- attr_accessor :column_mapper
11
12
  attr_accessor :row_mapper
12
- attr_reader :rows
13
+ attr_reader :column_mapper
13
14
 
14
15
  def self.read(file, options = {})
15
16
  table = Table.new
@@ -20,6 +21,7 @@ module Tabular
20
21
  # Pass data in as +rows+. Expects rows to be an Enumerable of Enumerables.
21
22
  # Maps rows to Hash-like Tabular::Rows.
22
23
  def initialize(rows = [])
24
+ @columns = nil
23
25
  self.rows = rows
24
26
  end
25
27
 
@@ -29,13 +31,11 @@ module Tabular
29
31
 
30
32
  # Set table rows. Calls row <<, which creates columns and links the source rows to Row#source.
31
33
  def rows=(source_rows = [])
32
- return [] unless source_rows
34
+ return unless source_rows
33
35
 
34
36
  source_rows.each do |row|
35
37
  self.<< row
36
38
  end
37
-
38
- rows
39
39
  end
40
40
 
41
41
  # Return Row at zero-based index, or nil if Row is out of bounds
@@ -47,25 +47,23 @@ module Tabular
47
47
  # To control how source data is added to the Table, use Table#mapper= to set a class that
48
48
  # implements map(row) and returns a Hash.
49
49
  def <<(row)
50
- if row_mapper
51
- cells = row_mapper.map(row)
52
- else
53
- cells = row
54
- end
50
+ cells = if row_mapper
51
+ row_mapper.map(row)
52
+ else
53
+ row
54
+ end
55
55
 
56
- if @columns.nil? || @columns.size == 0
56
+ if @columns.nil? || @columns.empty?
57
57
  @columns = Tabular::Columns.new(self, cells, column_mapper)
58
- if !cells.respond_to?(:keys)
59
- return columns
60
- end
58
+ return columns unless cells.respond_to?(:keys)
61
59
  end
62
60
 
63
- _row = Tabular::Row.new(self, cells, row)
64
- _row.keys.each do |key|
61
+ new_row = Tabular::Row.new(self, cells, row)
62
+ new_row.each_key do |key|
65
63
  columns << key
66
64
  end
67
- rows << _row
68
- _row
65
+ rows << new_row
66
+ new_row
69
67
  end
70
68
 
71
69
  def inspect
@@ -78,27 +76,25 @@ module Tabular
78
76
  end
79
77
 
80
78
  # Remove all columns that only contain a blank string, zero, or nil
81
- def delete_blank_columns!(*_options)
82
- exceptions = extract_exceptions(_options)
79
+ def delete_blank_columns!(*options)
80
+ exceptions = extract_exceptions(options)
83
81
 
84
82
  (columns.map(&:key) - exceptions).each do |key|
85
- if rows.all? { |row| is_blank?(row[key]) || is_zero?(row[key]) }
83
+ if rows.all? { |row| is_blank?(row[key]) || is_zero?(row[key]) } # rubocop:disable Style/IfUnlessModifier
86
84
  delete_column key
87
85
  end
88
86
  end
89
87
  end
90
88
 
91
89
  # Remove all columns that contain the same value in all rows
92
- def delete_homogenous_columns!(*_options)
90
+ def delete_homogenous_columns!(*options)
93
91
  return if rows.size < 2
94
92
 
95
- exceptions = extract_exceptions(_options)
93
+ exceptions = extract_exceptions(options)
96
94
 
97
95
  (columns.map(&:key) - exceptions).each do |key|
98
96
  value = rows.first[key]
99
- if rows.all? { |row| row[key] == value }
100
- delete_column key
101
- end
97
+ delete_column key if rows.all? { |row| row[key] == value }
102
98
  end
103
99
  end
104
100
 
@@ -142,9 +138,7 @@ module Tabular
142
138
  end
143
139
 
144
140
  def column_mapper=(mapper)
145
- if rows.nil? || rows.size == 0
146
- @columns = nil
147
- end
141
+ @columns = nil if rows.nil? || rows.empty?
148
142
  @column_mapper = mapper
149
143
  end
150
144
 
@@ -154,14 +148,13 @@ module Tabular
154
148
  end
155
149
 
156
150
  def to_space_delimited
157
- ([ columns ] + rows).map(&:to_space_delimited).join("\n") << "\n"
151
+ ([columns] + rows).map(&:to_space_delimited).join("\n") << "\n"
158
152
  end
159
153
 
160
154
  def to_s
161
155
  "#<#{self.class} #{rows.size}>"
162
156
  end
163
157
 
164
-
165
158
  private
166
159
 
167
160
  def extract_exceptions(options)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tabular
2
4
  module Tables
3
5
  module FileReading
@@ -12,43 +14,39 @@ module Tabular
12
14
  format ||= format_from(format, file_path)
13
15
 
14
16
  self.rows = case format
15
- when :xls, :xlsx
16
- # Set to first sheet if undefined.
17
- sheet ||= 0
18
- read_spreadsheet file_path, format, sheet
19
- when :txt
20
- read_txt file_path
21
- when :csv
22
- read_csv file_path
23
- else
24
- raise "Cannot read '#{format}' format. Expected :xls, :xlsx, :txt, or :csv"
25
- end
17
+ when :xls, :xlsx
18
+ # Set to first sheet if undefined.
19
+ sheet ||= 0
20
+ read_spreadsheet file_path, format, sheet
21
+ when :txt
22
+ read_txt file_path
23
+ when :csv
24
+ read_csv file_path
25
+ else
26
+ raise "Cannot read '#{format}' format. Expected :xls, :xlsx, :txt, or :csv"
27
+ end
26
28
  end
27
29
 
28
30
  def format_from(as_option, file_path)
29
- if as_option
30
- as_option
31
- else
32
- case File.extname(file_path)
33
- when ".xls"
34
- :xls
35
- when ".xlsx"
36
- :xlsx
37
- when ".txt"
38
- :txt
39
- when ".csv"
40
- :csv
41
- end
42
- end
31
+ as_option || case File.extname(file_path)
32
+ when ".xls"
33
+ :xls
34
+ when ".xlsx"
35
+ :xlsx
36
+ when ".txt"
37
+ :txt
38
+ when ".csv"
39
+ :csv
40
+ end
43
41
  end
44
42
 
45
43
  def to_file_path(file)
46
44
  file_path = case file
47
- when File
48
- file.path
49
- else
50
- file
51
- end
45
+ when File
46
+ file.path
47
+ else
48
+ file
49
+ end
52
50
 
53
51
  raise "Could not find '#{file_path}'" unless File.exist?(file_path)
54
52
 
@@ -68,7 +66,7 @@ module Tabular
68
66
  # Row#to_a coerces Excel data to Strings, but we want Dates and Numbers
69
67
  data = []
70
68
  excel.sheet(sheet).each do |excel_row|
71
- data << excel_row.inject([]) { |row, cell| row << cell; row }
69
+ data << excel_row.each_with_object([]) { |cell, row| row << cell }
72
70
  end
73
71
  data
74
72
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tabular
2
- VERSION = "0.4.2"
4
+ VERSION = "0.4.8"
3
5
  end
@@ -1,10 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tabular
2
4
  module Zero
3
- def is_zero?(object)
4
- if object.respond_to?(:zero?)
5
- return object.zero?
6
- end
7
-
5
+ def is_zero?(object) # rubocop:disable Naming/PredicateName
6
+ return object.zero? if object.respond_to?(:zero?)
7
+
8
8
  case object
9
9
  when NilClass, FalseClass, TrueClass
10
10
  false
@@ -1,4 +1,6 @@
1
- $:.push File.expand_path("../lib", __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH.push File.expand_path("lib", __dir__)
2
4
 
3
5
  require "tabular/version"
4
6
 
@@ -9,9 +11,9 @@ Gem::Specification.new do |s|
9
11
  s.authors = ["Scott Willson"]
10
12
  s.description = "Tabular is a Ruby library for reading, writing, and manipulating CSV, tab-delimited and Excel data."
11
13
  s.email = "scott.willson@gmail.com"
12
- s.extra_rdoc_files = [
13
- "LICENSE",
14
- "README"
14
+ s.extra_rdoc_files = %w[
15
+ LICENSE
16
+ README
15
17
  ]
16
18
  s.files = [
17
19
  "Gemfile",
@@ -34,9 +36,7 @@ Gem::Specification.new do |s|
34
36
  "tabular.gemspec"
35
37
  ]
36
38
  s.homepage = "http://github.com/scottwillson/tabular"
39
+ s.license = "MIT"
37
40
  s.require_paths = ["lib"]
38
41
  s.summary = "Read, write, and manipulate CSV, tab-delimited and Excel data"
39
-
40
- s.add_development_dependency "roo", "~> 2.0"
41
- s.add_development_dependency "roo-xls", "~> 0.0.1"
42
42
  end
metadata CHANGED
@@ -1,43 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tabular
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Willson
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-18 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: roo
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '2.0'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '2.0'
27
- - !ruby/object:Gem::Dependency
28
- name: roo-xls
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: 0.0.1
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: 0.0.1
11
+ date: 2020-11-27 00:00:00.000000000 Z
12
+ dependencies: []
41
13
  description: Tabular is a Ruby library for reading, writing, and manipulating CSV,
42
14
  tab-delimited and Excel data.
43
15
  email: scott.willson@gmail.com
@@ -66,9 +38,10 @@ files:
66
38
  - lib/tabular/zero.rb
67
39
  - tabular.gemspec
68
40
  homepage: http://github.com/scottwillson/tabular
69
- licenses: []
41
+ licenses:
42
+ - MIT
70
43
  metadata: {}
71
- post_install_message:
44
+ post_install_message:
72
45
  rdoc_options: []
73
46
  require_paths:
74
47
  - lib
@@ -83,9 +56,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
83
56
  - !ruby/object:Gem::Version
84
57
  version: '0'
85
58
  requirements: []
86
- rubyforge_project:
87
- rubygems_version: 2.4.8
88
- signing_key:
59
+ rubygems_version: 3.1.4
60
+ signing_key:
89
61
  specification_version: 4
90
62
  summary: Read, write, and manipulate CSV, tab-delimited and Excel data
91
63
  test_files: []