chop 0.21.0 → 0.22.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: 3b908d6fd6ee8ad3a672d047bc4b8e6b32c2abd6
4
- data.tar.gz: bc1c246a81f4dda4ef37fbfb14fe2b204566fb26
3
+ metadata.gz: 3d8b5d95f8ef75182d64f3228722c55ac54c267d
4
+ data.tar.gz: 59a7950b76e67a0c5fdeb20c0ae85121c815d5b4
5
5
  SHA512:
6
- metadata.gz: 6635faa8663d31c306ddf41b3c18dbeb5d3fe70836f3bc284be5d1916b8d98598e4567727b06d04e2206da71cd311ecb122f35f6ac0de0c84351a958378ed450
7
- data.tar.gz: 22fd0b20cad3052e9f224e523dfdb81b19bbeb03ba49dd02757fe6451b922f96339d09808ed5667ece53bac5fec49696122d924c000b8a1421359eefd348504e
6
+ metadata.gz: dcb1319713dca694adbd7ff509df5ad41754670a70e21cf37d516c817442dbb73fee2c72a03d304bc837171b62a1d41b51df7149f44d7019bfb44c09eefab875
7
+ data.tar.gz: f60933bb80e836a13658c787548c2b27459bf5f8c9d03ec0d8ae48ff0884eff32ca226c43a47a85fefe7e89d7f3ca3cc31931f82ec24d350661ac5f868b02958
data/README.md CHANGED
@@ -39,6 +39,7 @@ High-level declarative transformations:
39
39
  * `#has_many`: Replaces a comma-delimited list of entity names with an array of those entities. Uses `.find_by_name` by default.
40
40
  * `#underscore_keys`: Converts all hash keys to underscored versions.
41
41
  * `#default`: Provides a default value for a given field.
42
+ * `#copy`: Copies the value of one or more fields.
42
43
  * `#rename`: Renames one or more fields.
43
44
  * `#delete`: Deletes one or more fields.
44
45
 
data/lib/chop/create.rb CHANGED
@@ -74,6 +74,15 @@ module Chop
74
74
  end
75
75
  end
76
76
 
77
+ def copy mappings
78
+ transformation do |attributes|
79
+ mappings.each do |from, to|
80
+ attributes[to] = attributes[from]
81
+ end
82
+ attributes
83
+ end
84
+ end
85
+
77
86
  def rename mappings
78
87
  transformation do |attributes|
79
88
  mappings.reduce(attributes) do |attrs, (old, new)|
data/lib/chop/dsl.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require "active_support/inflector"
2
+
1
3
  module Chop
2
4
  module DSL
3
5
  def create! klass, table, &block
data/lib/chop/form.rb CHANGED
@@ -9,7 +9,12 @@ module Chop
9
9
 
10
10
  def self.diff! selector, table, session: Capybara.current_session, &block
11
11
  all_fields = session.find("form").all("input, textarea, select")
12
- deduplicated_fields = all_fields.inject([]) do |fields, field|
12
+ relevant_fields = all_fields.inject([]) do |fields, field|
13
+ next fields if field[:name].blank?
14
+ next fields if field[:type] == "submit"
15
+ fields + [field]
16
+ end
17
+ deduplicated_fields = relevant_fields.inject([]) do |fields, field|
13
18
  next fields if fields.map { |field| field[:name] }.include?(field[:name])
14
19
  fields + [field]
15
20
  end
@@ -22,7 +27,7 @@ module Chop
22
27
  end
23
28
 
24
29
  def self.find_label_for field, session: Capybara.current_session
25
- if field[:id]
30
+ if field[:id].present?
26
31
  session.first("label[for='#{field[:id]}']")
27
32
  else
28
33
  raise "cannot find label without id... yet"
data/lib/chop/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Chop
2
- VERSION = "0.21.0"
2
+ VERSION = "0.22.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.21.0
4
+ version: 0.22.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: 2018-04-19 00:00:00.000000000 Z
11
+ date: 2018-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -156,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
156
156
  version: '0'
157
157
  requirements: []
158
158
  rubyforge_project:
159
- rubygems_version: 2.6.8
159
+ rubygems_version: 2.4.8
160
160
  signing_key:
161
161
  specification_version: 4
162
162
  summary: Slice and dice your cucumber tables with ease!