chop 0.14.0 → 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/lib/chop/definition_list.rb +3 -14
- data/lib/chop/diff.rb +12 -3
- data/lib/chop/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58ec1d010f7e641bb853d3334ffcfea2422131f1
|
4
|
+
data.tar.gz: 96c010fae67db9a77ff16365cc5d724faf6b28e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f24073305f6ee2fb53ccc7e1bca8f350b48a135c9775034ae918cc2a2774b919d4d14959db8fc8c85c90a951395c2f620aacfeb0784c5b323cfae26332abb781
|
7
|
+
data.tar.gz: 97592730bd93f1fa3d8fecac2ee7c58b08181df1d6fffc372e0bbc977760c90ad0e05cc5876cf33b26cbfcf1e967addf4706264d8c38103a4c746068e1d9f548
|
data/README.md
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
Slice and dice your Cucumber tables with ease! Assumes usage of ActiveRecord and Capybara.
|
4
4
|
|
5
5
|
[![Build Status](https://travis-ci.org/botandrose/chop.svg?branch=master)](https://travis-ci.org/botandrose/chop)
|
6
|
+
[![Code Climate](https://codeclimate.com/github/botandrose/chop/badges/gpa.svg)](https://codeclimate.com/github/botandrose/chop)
|
6
7
|
|
7
8
|
## Installation
|
8
9
|
|
data/lib/chop/definition_list.rb
CHANGED
@@ -7,24 +7,13 @@ module Chop
|
|
7
7
|
self.cells_finder = ->(row) { row.all("dt,dd") }
|
8
8
|
|
9
9
|
def column index, &block
|
10
|
-
transformation do |
|
11
|
-
|
12
|
-
|
13
|
-
cell_element = cells(row_element)[index]
|
14
|
-
row[index] = block.call(row[index], cell_element, row_element)
|
10
|
+
transformation do |rows|
|
11
|
+
rows.map!.with_index do |row, row_index|
|
12
|
+
row[index] = block.call(row[index])
|
15
13
|
row
|
16
14
|
end
|
17
15
|
end
|
18
16
|
end
|
19
|
-
|
20
|
-
def header &block
|
21
|
-
transformation do |raw|
|
22
|
-
new_header = block.call(raw)
|
23
|
-
new_header << "" while new_header.length < (raw.first.try(:length) || 0)
|
24
|
-
raw.unshift new_header
|
25
|
-
raw
|
26
|
-
end
|
27
|
-
end
|
28
17
|
end
|
29
18
|
|
30
19
|
Dl = DefinitionList
|
data/lib/chop/diff.rb
CHANGED
@@ -116,13 +116,16 @@ module Chop
|
|
116
116
|
rows = rows_finder.call(root).map { |row| cells_finder.call(row).to_a }
|
117
117
|
rows = normalize(rows)
|
118
118
|
|
119
|
-
header = @new_header ? normalize([@new_header]).first : rows.shift
|
119
|
+
header = @new_header ? normalize([@new_header]).first : rows.shift || []
|
120
120
|
header_transformations.each do |transformation|
|
121
121
|
transformation.call(header)
|
122
122
|
header = normalize([header]).first
|
123
123
|
end
|
124
124
|
|
125
|
-
|
125
|
+
if header
|
126
|
+
rows = [header] + rows
|
127
|
+
rows = normalize(rows)
|
128
|
+
end
|
126
129
|
|
127
130
|
transformations.each do |transformation|
|
128
131
|
transformation.call(rows)
|
@@ -135,7 +138,13 @@ module Chop
|
|
135
138
|
end
|
136
139
|
|
137
140
|
def diff! cucumber_table = table
|
138
|
-
|
141
|
+
actual = to_a
|
142
|
+
# FIXME should just delegate to Cucumber's #diff!. Cucumber needs to handle empty tables better.
|
143
|
+
if !cucumber_table.raw.flatten.empty? && !actual.flatten.empty?
|
144
|
+
cucumber_table.diff! actual
|
145
|
+
elsif cucumber_table.raw.flatten != actual.flatten
|
146
|
+
raise Cucumber::MultilineArgument::DataTable::Different.new(cucumber_table)
|
147
|
+
end
|
139
148
|
end
|
140
149
|
|
141
150
|
private
|
data/lib/chop/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Micah Geisel
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03-
|
11
|
+
date: 2017-03-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|