atv 0.1.0 → 1.0.0

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
2
  SHA256:
3
- metadata.gz: 6851e0b146072fde213bbf6fb686c39ab366fed056d8bb7860d8ac7af09b43de
4
- data.tar.gz: 1fb2e9df3b10052fe0def7fe48ed61b5e0e28e17a06985d0de00193f1b9507d0
3
+ metadata.gz: 01241ccb91e5d82a64f6ea850637960f09ae9a311cf2c246776df57e04373df5
4
+ data.tar.gz: 5a04b4843e859ea00808415f876b966cd30ed4eb9330429bb2846b034e07ec1a
5
5
  SHA512:
6
- metadata.gz: 990b8a36bccd11ff01d8f177f5555c10c6b0e558e0596c339747a468e1a0158d372e951ed8d565d180cab2ce9cbd6fa87885b3ed4f5c7ad4082c40a8747c0c41
7
- data.tar.gz: e021c158d45fedce55dc1d75e5122c2fa1ac15962b63073f0bca9ac1d6213109048139ee02c6ddea54cccfdf3a3dd602cdc89b9d289709df3b3029a952518cd3
6
+ metadata.gz: 41f03eb6c3e36e1925c7dca47652ca96d3729ffbb20854219ccd28b8a55f2b1c5c9021978ac0f2290c4492dfa927a24a43414486dd2b0f0a8046831b7b0c7d19
7
+ data.tar.gz: dadd30ee857e755648608d7240ab8fd03d1333a56cdfb2b3623eabd09591d89286f7d04e05be7e230ef1b0b33043ddfb45925a534443bf9d2e3e7d73c3caa3b0
data/README.md CHANGED
@@ -66,8 +66,8 @@ Rows are returned or yielded as [CSV::Row][2] objects.
66
66
  | folded | | strings are folded with a single |
67
67
  | | | space replacing the new line |
68
68
  |-----------------------+------------------------------+-----------------------------------|
69
- | | not available | The CSV::Row object will not |
70
- | | | include columns with blank values |
69
+ | | nil | The CSV::Row object will have nil |
70
+ | | | for blank values |
71
71
  |-----------------------+------------------------------+-----------------------------------|
72
72
  | null | nil | null, true, and false are |
73
73
  | | | special values |
data/lib/atv.rb CHANGED
@@ -7,7 +7,8 @@ class ATV
7
7
  SUBSTITUTIONS = {
8
8
  'true' => true,
9
9
  'false' => false,
10
- 'null' => nil
10
+ 'null' => nil,
11
+ '' => nil
11
12
  }
12
13
 
13
14
  attr_reader :headers
@@ -27,11 +28,9 @@ class ATV
27
28
  next if line =~ /^\s*#/
28
29
  line.chomp!
29
30
  if (!@has_separators && !line_data.empty?) || line =~ /^\|\-/
30
- csv_row = CSV::Row.new(@headers, line_data.
31
- transpose.
32
- map { |tokens| tokens.reject(&:empty?).join(' ') }.
33
- map { |token| SUBSTITUTIONS.has_key?(token) ? SUBSTITUTIONS[token] : token }
34
- ).delete_if {|k, v| v == ''}
31
+ folded_items = line_data.transpose.map { |tokens| tokens.join(' ').rstrip }
32
+ converted_folded_items = folded_items.map { |token| SUBSTITUTIONS.has_key?(token) ? SUBSTITUTIONS[token] : token }
33
+ csv_row = CSV::Row.new(@headers, converted_folded_items)
35
34
  yield csv_row if csv_row.size > 0
36
35
  line_data = []
37
36
  next if @has_separators
data/lib/atv/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Atv
2
- VERSION = "0.1.0"
2
+ VERSION = "1.0.0"
3
3
  end
data/test/atv_test.rb CHANGED
@@ -14,6 +14,8 @@ describe ATV do
14
14
  | Zoe | February 15, 2484 | |
15
15
  | Washburne | | |
16
16
  |-----------+--------------------+--------------|
17
+ | Jane | | true |
18
+ |-----------+--------------------+--------------|
17
19
  # | Inara | October 14, 2489 | |
18
20
  # | Sara | | |
19
21
  # |-----------+--------------------+--------------|
@@ -23,7 +25,8 @@ describe ATV do
23
25
  TEXT
24
26
  @expected = [
25
27
  ['Malcolm Reynolds', 'September 20, 2468', false],
26
- ['Zoe Washburne', 'February 15, 2484'],
28
+ ['Zoe Washburne', 'February 15, 2484', nil],
29
+ ['Jane', nil, true],
27
30
  ['Derrial Book', nil, true]
28
31
  ]
29
32
  end
@@ -46,7 +49,7 @@ describe ATV do
46
49
  row['predictable?'].must_equal(@expected[i][2])
47
50
  i += 1
48
51
  end
49
- i.must_equal(3)
52
+ i.must_equal(4)
50
53
  end
51
54
 
52
55
  it 'without a block it returns an enumerator of data as CSV rows' do
@@ -87,7 +90,7 @@ describe ATV do
87
90
 
88
91
  expected = [
89
92
  ['Malcolm', 'September 20, 2468', false],
90
- ['Zoe', 'February 15, 2484'],
93
+ ['Zoe', 'February 15, 2484', nil],
91
94
  ['Derrial', nil, true]
92
95
  ]
93
96
  @atv = ATV.new(StringIO.new(data_as_table))
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: atv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kelly Felkins