nozzle 0.1.4 → 0.1.5
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/lib/nozzle/adapter/base.rb +10 -5
- data/lib/nozzle/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6acf45517971815d7ea04dab2de08a5aa4b4db51
|
4
|
+
data.tar.gz: fd100f0680bf760bb5b9cd4c29604449d73ea87d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1cd93c3d5b4d613e7992b8836c9376885e8b19a8d31ca18e2c615427a12ae26aa4e35f5ccc92ee39e978393feb792f37dec8bc3140aa5616e347bba73e4acd02
|
7
|
+
data.tar.gz: 080f3642843fe3bc88ae95b8346087052860075cdbba1e4128b4a95a87830bb11aa274b2a3706d24c9a640811daf50e6f416d037dea30a3abb639c58b4f5f62a
|
data/lib/nozzle/adapter/base.rb
CHANGED
@@ -163,12 +163,12 @@ module Nozzle
|
|
163
163
|
@original_path = path
|
164
164
|
return nil unless value
|
165
165
|
|
166
|
-
new_path = expand_argument
|
166
|
+
new_path, filename_candidate = expand_argument(value)
|
167
167
|
raise Errno::ENOENT, "'#{new_path}'" unless File.exists?(new_path)
|
168
168
|
|
169
169
|
@tempfile_path = File.expand_path(new_path)
|
170
170
|
detect_properties
|
171
|
-
@filename
|
171
|
+
@filename = prepare_filename(filename_candidate)
|
172
172
|
end
|
173
173
|
|
174
174
|
# Stores temporary filename by the constructed path. Deletes old file.
|
@@ -205,6 +205,12 @@ module Nozzle
|
|
205
205
|
|
206
206
|
private
|
207
207
|
|
208
|
+
# Returns a filename prepared for saving. Should be overridden.
|
209
|
+
# instance.avatar.new_filename('image.jpg') # => '0006-avatary-image.jpg'
|
210
|
+
def prepare_filename(candidate=filename)
|
211
|
+
candidate
|
212
|
+
end
|
213
|
+
|
208
214
|
# Tries to detect content_type and size of the file.
|
209
215
|
# Note: this method calls `file` system command to detect file content type.
|
210
216
|
def detect_properties
|
@@ -230,12 +236,11 @@ module Nozzle
|
|
230
236
|
when File, Tempfile
|
231
237
|
value.path
|
232
238
|
when Hash
|
233
|
-
expand_argument( value[:tempfile] || value['tempfile'] )
|
239
|
+
expand_argument( value[:tempfile] || value['tempfile'] ).first
|
234
240
|
else
|
235
241
|
raise ArgumentError, "#{@model}##{@column}= argument must be kind of String, File, Tempfile or Hash[:tempfile => 'path']"
|
236
242
|
end
|
237
|
-
|
238
|
-
tempfile_path
|
243
|
+
[tempfile_path, value.kind_of?(Hash) && ( value[:filename] || value['filename'] ) || File.basename(tempfile_path)]
|
239
244
|
end
|
240
245
|
|
241
246
|
# Deletes the specified file and all empty folders recursively stopping at
|
data/lib/nozzle/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nozzle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Bochkariov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|