sequel_paperclip 0.4.3 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/sequel_paperclip/attachment.rb +7 -0
- data/lib/sequel_paperclip.rb +8 -3
- data/sequel_paperclip.gemspec +2 -2
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.5.0
|
@@ -67,6 +67,13 @@ module Sequel
|
|
67
67
|
!!model.send("#{name}_basename")
|
68
68
|
end
|
69
69
|
|
70
|
+
def consistent?
|
71
|
+
options[:styles].each_key do |style|
|
72
|
+
return false unless File.exists?(path(style))
|
73
|
+
end
|
74
|
+
true
|
75
|
+
end
|
76
|
+
|
70
77
|
def path(style = :original)
|
71
78
|
Interpolations.interpolate(options[:path], self, model, style)
|
72
79
|
end
|
data/lib/sequel_paperclip.rb
CHANGED
@@ -79,8 +79,10 @@ module Sequel
|
|
79
79
|
basename = attachment_generate_basename(attachment)
|
80
80
|
send("#{name}_basename=", basename)
|
81
81
|
|
82
|
+
original_filename = File.basename(value.respond_to?(:original_filename) ? value.original_filename : value.path)
|
83
|
+
|
82
84
|
if respond_to?("#{name}_filename")
|
83
|
-
send("#{name}_filename=", basename+File.extname(
|
85
|
+
send("#{name}_filename=", basename+File.extname(original_filename).downcase)
|
84
86
|
end
|
85
87
|
|
86
88
|
if respond_to?("#{name}_filesize")
|
@@ -88,7 +90,7 @@ module Sequel
|
|
88
90
|
end
|
89
91
|
|
90
92
|
if respond_to?("#{name}_originalname")
|
91
|
-
send("#{name}_originalname=",
|
93
|
+
send("#{name}_originalname=", original_filename)
|
92
94
|
end
|
93
95
|
else
|
94
96
|
send("#{name}_basename=", nil)
|
@@ -111,7 +113,10 @@ module Sequel
|
|
111
113
|
module InstanceMethods
|
112
114
|
def attachment_generate_basename(attachment)
|
113
115
|
basename = send("#{attachment.name}_basename")
|
114
|
-
|
116
|
+
while true
|
117
|
+
new_basename = ActiveSupport::SecureRandom.hex(4).to_s
|
118
|
+
return new_basename unless new_basename == basename
|
119
|
+
end
|
115
120
|
end
|
116
121
|
|
117
122
|
def after_save
|
data/sequel_paperclip.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{sequel_paperclip}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.5.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Corin Langosch"]
|
12
|
-
s.date = %q{2010-10-
|
12
|
+
s.date = %q{2010-10-10}
|
13
13
|
s.description = %q{Sequel plugin which provides Paperclip (attachments, thumbnail resizing, etc.) functionality for model.}
|
14
14
|
s.email = %q{info@netskin.com}
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
7
|
+
- 5
|
8
|
+
- 0
|
9
|
+
version: 0.5.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Corin Langosch
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-10-
|
17
|
+
date: 2010-10-10 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|