sequel_paperclip 0.0.2 → 0.1.1
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.
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.1.1
|
data/lib/sequel_paperclip.rb
CHANGED
@@ -3,7 +3,6 @@ require 'sequel_paperclip/interpolations'
|
|
3
3
|
require 'sequel_paperclip/attachment'
|
4
4
|
require 'sequel_paperclip/processors/dummy'
|
5
5
|
require 'sequel_paperclip/processors/image'
|
6
|
-
require 'sequel_paperclip/validators/activemodel'
|
7
6
|
|
8
7
|
module Sequel
|
9
8
|
module Plugins
|
@@ -99,7 +98,15 @@ module Sequel
|
|
99
98
|
if respond_to?("#{attachment.name}_originalname")
|
100
99
|
send("#{attachment.name}_originalname=", file.original_filename)
|
101
100
|
end
|
102
|
-
|
101
|
+
end
|
102
|
+
end
|
103
|
+
super
|
104
|
+
end
|
105
|
+
|
106
|
+
def after_save
|
107
|
+
self.class.attachments.each_value do |attachment|
|
108
|
+
file = send(attachment.name)
|
109
|
+
if file
|
103
110
|
attachment.process(self, file.path)
|
104
111
|
end
|
105
112
|
|
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.1.1"
|
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-09-
|
12
|
+
s.date = %q{2010-09-14}
|
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 = [
|
@@ -28,7 +28,6 @@ Gem::Specification.new do |s|
|
|
28
28
|
"lib/sequel_paperclip/interpolations.rb",
|
29
29
|
"lib/sequel_paperclip/processors/dummy.rb",
|
30
30
|
"lib/sequel_paperclip/processors/image.rb",
|
31
|
-
"lib/sequel_paperclip/validators/activemodel.rb",
|
32
31
|
"sequel_paperclip.gemspec",
|
33
32
|
"spec/sequel_paperclip_spec.rb",
|
34
33
|
"spec/spec.opts",
|
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
|
+
- 1
|
8
|
+
- 1
|
9
|
+
version: 0.1.1
|
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-09-
|
17
|
+
date: 2010-09-14 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -53,7 +53,6 @@ files:
|
|
53
53
|
- lib/sequel_paperclip/interpolations.rb
|
54
54
|
- lib/sequel_paperclip/processors/dummy.rb
|
55
55
|
- lib/sequel_paperclip/processors/image.rb
|
56
|
-
- lib/sequel_paperclip/validators/activemodel.rb
|
57
56
|
- sequel_paperclip.gemspec
|
58
57
|
- spec/sequel_paperclip_spec.rb
|
59
58
|
- spec/spec.opts
|
@@ -1,39 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
class PaperclipValidator < ActiveModel::EachValidator
|
3
|
-
def humanized_size(num)
|
4
|
-
for x in ['Byte','KB','MB','GB','TB']
|
5
|
-
return "%d %s"%[num, x] if num < 1024.0
|
6
|
-
num /= 1024.0
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
def validate_each(model, attribute, value)
|
11
|
-
return unless value
|
12
|
-
|
13
|
-
if options[:size]
|
14
|
-
min = options[:size].min
|
15
|
-
max = options[:size].max
|
16
|
-
if value.size < min
|
17
|
-
model.errors.add(attribute, "zu klein (mindestes #{humanized_size(min)})")
|
18
|
-
end
|
19
|
-
if value.size > max
|
20
|
-
model.errors.add(attribute, "zu groß (maximal #{humanized_size(max)})")
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
if options[:geometry]
|
25
|
-
geo1 = Sequel::Plugins::Paperclip::Processors::Image::Geometry.from_s(options[:geometry])
|
26
|
-
geo2 = Sequel::Plugins::Paperclip::Processors::Image::Geometry.from_file(value)
|
27
|
-
if geo2
|
28
|
-
if geo2.width < geo1.width
|
29
|
-
model.errors.add(attribute, "zu klein (weniger als %d Pixel breit)"%[geo1.width])
|
30
|
-
end
|
31
|
-
if geo2.height < geo1.height
|
32
|
-
model.errors.add(attribute, "zu klein (weniger als %d Pixel hoch)"%[geo1.height])
|
33
|
-
end
|
34
|
-
else
|
35
|
-
model.errors.add(attribute, "unbekanntes Bildformat oder Datei beschäftigt")
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|