paperclip_database 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/lib/paperclip/storage/database.rb +16 -12
- data/lib/paperclip_database/version.rb +1 -1
- metadata +24 -24
data/Gemfile.lock
CHANGED
@@ -26,8 +26,8 @@ module Paperclip
|
|
26
26
|
# end
|
27
27
|
# execute 'ALTER TABLE avatars ADD COLUMN file_contents LONGBLOB'
|
28
28
|
#
|
29
|
-
# You can optionally specify any storage table name you want as follows:
|
30
|
-
# has_attached_file :avatar, :storage => :database, :database_table => 'avatar_files'
|
29
|
+
# You can optionally specify any storage table name you want and whether or not deletion is done by cascading or not as follows:
|
30
|
+
# has_attached_file :avatar, :storage => :database, :database_table => 'avatar_files', :cascade_deletion => true
|
31
31
|
#
|
32
32
|
# 3. By default, URLs will be set to this pattern:
|
33
33
|
# /:relative_root/:class/:attachment/:id?style=:style
|
@@ -84,18 +84,18 @@ module Paperclip
|
|
84
84
|
@paperclip_files = "#{instance.class.name.underscore}_#{name.to_s}_paperclip_files"
|
85
85
|
if !Object.const_defined?(@paperclip_files.classify)
|
86
86
|
@paperclip_file = Object.const_set(@paperclip_files.classify, Class.new(::ActiveRecord::Base))
|
87
|
+
@paperclip_file.set_table_name @options[:database_table] || name.to_s.pluralize
|
88
|
+
@paperclip_file.validates_uniqueness_of :style, :scope => instance.class.table_name.classify.underscore + '_id'
|
89
|
+
case Rails::VERSION::STRING
|
90
|
+
when /^2/
|
91
|
+
@paperclip_file.named_scope :file_for, lambda {|style| { :conditions => ['style = ?', style] }}
|
92
|
+
else # 3.x
|
93
|
+
@paperclip_file.scope :file_for, lambda {|style| { :conditions => ['style = ?', style] }}
|
94
|
+
end
|
87
95
|
else
|
88
96
|
@paperclip_file = Object.const_get(@paperclip_files.classify)
|
89
97
|
end
|
90
|
-
@database_table = @
|
91
|
-
@paperclip_file.set_table_name @database_table
|
92
|
-
@paperclip_file.validates_uniqueness_of :style, :scope => instance.class.table_name.classify.underscore + '_id'
|
93
|
-
case Rails::VERSION::STRING
|
94
|
-
when /^2/
|
95
|
-
@paperclip_file.named_scope :file_for, lambda {|style| { :conditions => ['style = ?', style] }}
|
96
|
-
else # 3.x
|
97
|
-
@paperclip_file.scope :file_for, lambda {|style| { :conditions => ['style = ?', style] }}
|
98
|
-
end
|
98
|
+
@database_table = @paperclip_file.table_name
|
99
99
|
#FIXME: This fails when using set_table_name "<myname>" in your model
|
100
100
|
#FIXME: This should be fixed in ActiveRecord...
|
101
101
|
instance.class.has_many @paperclip_files, :foreign_key => instance.class.table_name.classify.underscore + '_id'
|
@@ -174,7 +174,11 @@ module Paperclip
|
|
174
174
|
ActiveRecord::Base.logger.info("[paperclip] Deleting files for #{name}")
|
175
175
|
@queued_for_delete.each do |path|
|
176
176
|
/id=([0-9]+)/.match(path)
|
177
|
-
@
|
177
|
+
if @options[:cascade_deletion] && !instance.class.exists?(instance.id)
|
178
|
+
raise RuntimeError, "Deletion has not been done by through cascading." if @paperclip_file.exists?($1)
|
179
|
+
else
|
180
|
+
@paperclip_file.destroy $1
|
181
|
+
end
|
178
182
|
end
|
179
183
|
@queued_for_delete = []
|
180
184
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paperclip_database
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-02-02 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: paperclip
|
16
|
-
requirement: &
|
16
|
+
requirement: &18765700 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *18765700
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: appraisal
|
27
|
-
requirement: &
|
27
|
+
requirement: &18765040 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 0.4.0
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *18765040
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: mocha
|
38
|
-
requirement: &
|
38
|
+
requirement: &18764480 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *18764480
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: sqlite3
|
49
|
-
requirement: &
|
49
|
+
requirement: &18763760 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 1.3.4
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *18763760
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: cucumber
|
60
|
-
requirement: &
|
60
|
+
requirement: &18763120 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: 1.1.0
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *18763120
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: aruba
|
71
|
-
requirement: &
|
71
|
+
requirement: &18750580 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *18750580
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: capybara
|
82
|
-
requirement: &
|
82
|
+
requirement: &18749960 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *18749960
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: bundler
|
93
|
-
requirement: &
|
93
|
+
requirement: &18749420 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ! '>='
|
@@ -98,10 +98,10 @@ dependencies:
|
|
98
98
|
version: '0'
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *18749420
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: rake
|
104
|
-
requirement: &
|
104
|
+
requirement: &18748780 !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
107
|
- - ! '>='
|
@@ -109,10 +109,10 @@ dependencies:
|
|
109
109
|
version: '0'
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
|
-
version_requirements: *
|
112
|
+
version_requirements: *18748780
|
113
113
|
- !ruby/object:Gem::Dependency
|
114
114
|
name: fakeweb
|
115
|
-
requirement: &
|
115
|
+
requirement: &18748200 !ruby/object:Gem::Requirement
|
116
116
|
none: false
|
117
117
|
requirements:
|
118
118
|
- - ! '>='
|
@@ -120,7 +120,7 @@ dependencies:
|
|
120
120
|
version: '0'
|
121
121
|
type: :development
|
122
122
|
prerelease: false
|
123
|
-
version_requirements: *
|
123
|
+
version_requirements: *18748200
|
124
124
|
description: ! 'To have all your data i one place: the database'
|
125
125
|
email:
|
126
126
|
- jarl@softace.dk
|
@@ -180,7 +180,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
180
180
|
version: '0'
|
181
181
|
segments:
|
182
182
|
- 0
|
183
|
-
hash:
|
183
|
+
hash: -4564896165259778295
|
184
184
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
185
185
|
none: false
|
186
186
|
requirements:
|
@@ -189,7 +189,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
189
189
|
version: '0'
|
190
190
|
segments:
|
191
191
|
- 0
|
192
|
-
hash:
|
192
|
+
hash: -4564896165259778295
|
193
193
|
requirements:
|
194
194
|
- ImageMagick
|
195
195
|
rubyforge_project: paperclip_database
|