chop 0.25.2 → 0.26.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 +4 -4
- data/.travis.yml +4 -1
- data/README.md +2 -2
- data/lib/chop/create.rb +16 -2
- data/lib/chop/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bee1ec352644193eeff10aabf667030259daaef55aaf4e0e7adcbfe3af6f53f1
|
4
|
+
data.tar.gz: a07d1ce3c87efb2be5a59c5ad7be173ee8b92f0f869b2764d9dabb92e0840eac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b74cb6aafd7b59f8c705220afd644e2295a5355d4f98cd05aff588455dcc9a818406650f4de5f9063802df172cb817c3b7d4994d45e6cc26b9050cae88207e4
|
7
|
+
data.tar.gz: 3b2752804004fc1676c10881f67a9178fdcb42e2d19fd0e8efcf8dbf73686b55cb652026633c9732452347211f8b15f5d7349e5fd0cfe8084eb3e2b7bb738b33
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -33,8 +33,8 @@ Transform the attributes hash derived from the table before passing to `ActiveRe
|
|
33
33
|
|
34
34
|
High-level declarative transformations:
|
35
35
|
|
36
|
-
* `#file`: Replaces a file path with a file handle. Looks in `features/support/fixtures` by default.
|
37
|
-
* `#files`: Replaces a space-delimited list of file paths with an array of file handles. Looks in `features/support/fixtures` by default.
|
36
|
+
* `#file`: Replaces a file path with a file handle. Looks in `features/support/fixtures` by default. Set `upload: true` to wrap file in `Rack::Test::UploadedFile`.
|
37
|
+
* `#files`: Replaces a space-delimited list of file paths with an array of file handles. Looks in `features/support/fixtures` by default. Set `upload: true` to wrap file in `Rack::Test::UploadedFile`.
|
38
38
|
* `#has_one/#belongs_to`: Replaces an entity name with that entity. Uses `.find_by_name` by default.
|
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.
|
data/lib/chop/create.rb
CHANGED
@@ -117,12 +117,20 @@ module Chop
|
|
117
117
|
def file *keys
|
118
118
|
options = extract_options!(keys)
|
119
119
|
path = options.fetch(:path, "features/support/fixtures")
|
120
|
+
upload = options.fetch(:upload, false)
|
120
121
|
|
121
122
|
handle_renames! keys
|
122
123
|
|
123
124
|
keys.each do |key|
|
124
125
|
field key do |file|
|
125
|
-
|
126
|
+
if file.present?
|
127
|
+
file_path = File.join(path, file)
|
128
|
+
if upload
|
129
|
+
Rack::Test::UploadedFile.new(file_path)
|
130
|
+
else
|
131
|
+
File.open(file_path)
|
132
|
+
end
|
133
|
+
end
|
126
134
|
end
|
127
135
|
end
|
128
136
|
end
|
@@ -130,6 +138,7 @@ module Chop
|
|
130
138
|
def files *keys
|
131
139
|
options = extract_options!(keys)
|
132
140
|
path = options.fetch(:path, "features/support/fixtures")
|
141
|
+
upload = options.fetch(:upload, false)
|
133
142
|
delimiter = options.fetch(:delimiter, " ")
|
134
143
|
|
135
144
|
handle_renames! keys
|
@@ -137,7 +146,12 @@ module Chop
|
|
137
146
|
keys.each do |key|
|
138
147
|
field key do |paths|
|
139
148
|
paths.split(delimiter).map do |file|
|
140
|
-
File.
|
149
|
+
file_path = File.join(path, file)
|
150
|
+
if upload
|
151
|
+
Rack::Test::UploadedFile.new(file_path)
|
152
|
+
else
|
153
|
+
File.open(file_path)
|
154
|
+
end
|
141
155
|
end
|
142
156
|
end
|
143
157
|
end
|
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.26.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:
|
11
|
+
date: 2021-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|