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 +4 -4
- data/README.md +1 -0
- data/lib/chop/create.rb +9 -0
- data/lib/chop/dsl.rb +2 -0
- data/lib/chop/form.rb +7 -2
- data/lib/chop/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d8b5d95f8ef75182d64f3228722c55ac54c267d
|
4
|
+
data.tar.gz: 59a7950b76e67a0c5fdeb20c0ae85121c815d5b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
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
|
-
|
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
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.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-
|
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.
|
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!
|