honey_format 0.7.0 → 0.8.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: 1c3b35ed8d8cac5eace438a1eb5365b4970d96e2fee1a3faece4555eae44f1a3
4
- data.tar.gz: 01ed3a3b5bc973b5882c6ec2f61c647bf24d0edadd76c7155568e2a6c2cbcbbb
3
+ metadata.gz: cd129c5fad5db62fff083b435b6fcda0ffffd8a267a3212ddf0207d55687b0ea
4
+ data.tar.gz: 06bd0c47a814e1d9dba272604438e251a86961928ad403ea51528bd11050a653
5
5
  SHA512:
6
- metadata.gz: af026b70d5fa369633788e5be0796723161b8564aca45084e704fa0691ad7da1fbe1a4578262dec60806d71fe1757984630c8d3e7be1fc4df276b0c3bf3cac1f
7
- data.tar.gz: 267b348cff25cffb1204e26ec4f34f60fafb4154b44afa6005599bfd71ab8946024be7fd56deca52ff5c5ee31f53fe4f4ab79fd25ead5df0ad79ece91cfdeb5d
6
+ metadata.gz: c969983ad1c3af2a1f5c0fff16726e6181b91db3db2504a16a4f71105e213142941ca3b06507e3efff36b111edba7cfbdf8c286f64aadb5e74ed37022c26f57a
7
+ data.tar.gz: 2ac22026db03b89aa5f37c64a1be68e40d19b7edc71a5e90af106e15e80e43c0c610233d434da626879419ba132fa64da74869748eee596fbe8a772e463d2740
data/CHANGELOG.md CHANGED
@@ -1,8 +1,14 @@
1
+ # v0.8.0
2
+
3
+ * _[Feature]_ Add `#size` and `#length` methods to `Header` and `Rows` objects
4
+ * _[Bugfix]_ Improved Row error handling for when row size differs from header column
5
+
6
+
1
7
  # v0.7.0
2
8
 
3
- - Don't sanitize each row :rocket: (improves performance from ~1.4x times slower than raw CSV to ~1.1)
4
- - Fold `Columns` class into `Header`
5
- - Remove `Sanitize` class
9
+ * Don't sanitize each row :rocket: (improves performance from ~1.4x times slower than raw CSV to ~1.1)
10
+ * Fold `Columns` class into `Header`
11
+ * Remove `Sanitize` class
6
12
 
7
13
  # v0.6.0
8
14
 
@@ -45,6 +45,13 @@ module HoneyFormat
45
45
  @columns
46
46
  end
47
47
 
48
+ # Return the number of header columns
49
+ # @return [Integer] the number of header columns
50
+ def length
51
+ @columns.length
52
+ end
53
+ alias_method :size, :length
54
+
48
55
  # Header as CSV-string
49
56
  # @return [String] CSV-string representation.
50
57
  def to_csv
@@ -32,11 +32,14 @@ module HoneyFormat
32
32
  built_row = @row_builder.call(row)
33
33
  return built_row unless @builder
34
34
  @builder.call(built_row)
35
- rescue ArgumentError, 'struct size differs'
35
+ rescue ArgumentError => e
36
+ raise unless e.message == 'struct size differs'
37
+
36
38
  err_msg = [
37
39
  "Row length #{row.length}",
38
- "for columns #{@columns.length}",
39
- "row: #{row.inspect}"
40
+ "column length #{@columns.length}",
41
+ "row: #{row.inspect}",
42
+ "orignal message: '#{e.message}'"
40
43
  ].join(', ')
41
44
  raise(InvalidRowLengthError, err_msg)
42
45
  end
@@ -27,6 +27,13 @@ module HoneyFormat
27
27
  @rows
28
28
  end
29
29
 
30
+ # Return the number of rows
31
+ # @return [Integer] the number of rows
32
+ def length
33
+ @rows.length
34
+ end
35
+ alias_method :size, :length
36
+
30
37
  # @return [String] CSV-string representation.
31
38
  def to_csv
32
39
  to_a.map(&:to_csv).join
@@ -1,4 +1,4 @@
1
1
  module HoneyFormat
2
2
  # Gem version
3
- VERSION = '0.7.0'
3
+ VERSION = '0.8.0'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: honey_format
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jacob Burenstam