chop 0.25.2 → 0.26.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
  SHA256:
3
- metadata.gz: 60f2038bae8b6de4d0f84113ad67cc767801680b44cabd7cd3c6bcecd1c5713a
4
- data.tar.gz: cb31b02477ae71c42a6efc29c223746482b0e1dc6d59a1feb024e37eed2aad4b
3
+ metadata.gz: bee1ec352644193eeff10aabf667030259daaef55aaf4e0e7adcbfe3af6f53f1
4
+ data.tar.gz: a07d1ce3c87efb2be5a59c5ad7be173ee8b92f0f869b2764d9dabb92e0840eac
5
5
  SHA512:
6
- metadata.gz: 72533d44429257e54a7c6136e8df1ac6550d0d528bc28c101923daff40f83db159c411b2e8a374dbd42adb12ffb34bc17b1ec2a1de994418cf3348cdcf8f3720
7
- data.tar.gz: ba0e4264a9472e4f0a9c5ad58c699d0008263627f9b036edebe7f2ebad1cc7f5569d7f1d07860cd95cc58c90ae78024bdc0af699d4608a846cd318f632405086
6
+ metadata.gz: 1b74cb6aafd7b59f8c705220afd644e2295a5355d4f98cd05aff588455dcc9a818406650f4de5f9063802df172cb817c3b7d4994d45e6cc26b9050cae88207e4
7
+ data.tar.gz: 3b2752804004fc1676c10881f67a9178fdcb42e2d19fd0e8efcf8dbf73686b55cb652026633c9732452347211f8b15f5d7349e5fd0cfe8084eb3e2b7bb738b33
@@ -1,3 +1,6 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2.3
3
+ - 2.4
4
+ - 2.5
5
+ - 2.6
6
+ - 2.7
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.
@@ -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
- File.open(File.join(path, file)) if file.present?
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.open(File.join(path, 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
@@ -1,3 +1,3 @@
1
1
  module Chop
2
- VERSION = "0.25.2"
2
+ VERSION = "0.26.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.25.2
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: 2020-03-17 00:00:00.000000000 Z
11
+ date: 2021-01-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord