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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 02300b6137cd03b63ebfef375d7d9de7402a8892
4
- data.tar.gz: d353af7ed05239dca230b63825034ea30d74430e
3
+ metadata.gz: 58ec1d010f7e641bb853d3334ffcfea2422131f1
4
+ data.tar.gz: 96c010fae67db9a77ff16365cc5d724faf6b28e3
5
5
  SHA512:
6
- metadata.gz: cb5dfb4be29ef2ca2e548b37f2176c8a3e7da2b83e3a985aa9d3f7a53d9c7b92a74d293ba567a995f5055b3824babecbb83f143a32a9d1ca52cb8169642d17a2
7
- data.tar.gz: 07787e5e960bb7532855d46fbfbf363e855e2c0814b9fb56a1afcb87cb65440e239a679fc13acf31a0cb08ea6b3e12e290b5ab8eac959c3ddae860ca4cc6b968
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
 
@@ -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 |raw|
11
- raw.map!.with_index do |row, row_index|
12
- row_element = rows[row_index]
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
@@ -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
- rows = [header] + rows
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
- cucumber_table.diff! to_a
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
@@ -1,3 +1,3 @@
1
1
  module Chop
2
- VERSION = "0.14.0"
2
+ VERSION = "0.15.0"
3
3
  end
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.14.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-21 00:00:00.000000000 Z
11
+ date: 2017-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord