polypaperclip 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -0
- data/Gemfile.lock +8 -0
- data/VERSION +1 -1
- data/lib/polypaperclip/attachment.rb +1 -0
- data/lib/polypaperclip/persisted_attachment.rb +2 -0
- data/lib/polypaperclip.rb +14 -2
- data/polypaperclip.gemspec +5 -2
- data/spec/page_spec.rb +8 -0
- metadata +31 -17
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -30,6 +30,7 @@ GEM
|
|
30
30
|
activesupport (3.0.7)
|
31
31
|
arel (2.0.10)
|
32
32
|
builder (2.1.2)
|
33
|
+
columnize (0.3.2)
|
33
34
|
diff-lcs (1.1.2)
|
34
35
|
erubis (2.6.6)
|
35
36
|
abstract (>= 1.0.0)
|
@@ -39,6 +40,7 @@ GEM
|
|
39
40
|
bundler (~> 1.0.0)
|
40
41
|
git (>= 1.2.5)
|
41
42
|
rake
|
43
|
+
linecache (0.43)
|
42
44
|
mail (2.2.19)
|
43
45
|
activesupport (>= 2.3.6)
|
44
46
|
i18n (>= 0.4.0)
|
@@ -78,6 +80,11 @@ GEM
|
|
78
80
|
rspec-expectations (2.3.0)
|
79
81
|
diff-lcs (~> 1.1.2)
|
80
82
|
rspec-mocks (2.3.0)
|
83
|
+
ruby-debug (0.10.4)
|
84
|
+
columnize (>= 0.1)
|
85
|
+
ruby-debug-base (~> 0.10.4.0)
|
86
|
+
ruby-debug-base (0.10.4)
|
87
|
+
linecache (>= 0.3)
|
81
88
|
sqlite3 (1.3.3)
|
82
89
|
sqlite3-ruby (1.3.3)
|
83
90
|
sqlite3 (>= 1.3.3)
|
@@ -99,5 +106,6 @@ DEPENDENCIES
|
|
99
106
|
rake (= 0.8.7)
|
100
107
|
rcov
|
101
108
|
rspec (~> 2.3.0)
|
109
|
+
ruby-debug
|
102
110
|
sqlite3-ruby (~> 1.3.0)
|
103
111
|
yard (~> 0.6.0)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/lib/polypaperclip.rb
CHANGED
@@ -46,10 +46,10 @@ module Polypaperclip
|
|
46
46
|
#initialize a polypaperclip model if a configuration hasn't already been loaded
|
47
47
|
def initialize_polypaperclip
|
48
48
|
if polypaperclip_definitions.nil?
|
49
|
-
has_many_attachments_association
|
50
|
-
|
51
49
|
after_save :save_attached_files
|
52
50
|
before_destroy :destroy_attached_files
|
51
|
+
|
52
|
+
has_many_attachments_association
|
53
53
|
|
54
54
|
write_inheritable_attribute(:polypaperclip_definitions, {})
|
55
55
|
|
@@ -62,6 +62,7 @@ module Polypaperclip
|
|
62
62
|
def has_many_attachments_association
|
63
63
|
unless self.respond_to?(:attachments)
|
64
64
|
has_many :attachments,
|
65
|
+
:class_name => "Polypaperclip::PersistedAttachment",
|
65
66
|
:as => :attachable
|
66
67
|
end
|
67
68
|
end
|
@@ -74,6 +75,17 @@ module Polypaperclip
|
|
74
75
|
yield(name, paperclip_attachment_for(name))
|
75
76
|
end
|
76
77
|
end
|
78
|
+
|
79
|
+
def save_attached_files
|
80
|
+
#premptively save each attachment
|
81
|
+
Paperclip.log("Saving attachments.")
|
82
|
+
each_attachment do |name, attachment|
|
83
|
+
if attachment && attachment.instance
|
84
|
+
attachment.instance.save
|
85
|
+
attachment.send(:save)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
77
89
|
|
78
90
|
def paperclip_attachment_for(name)
|
79
91
|
@_paperclip_attachments ||= {}
|
data/polypaperclip.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{polypaperclip}
|
8
|
-
s.version = "0.1.
|
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 = ["Dan Pickett"]
|
12
|
-
s.date = %q{2011-
|
12
|
+
s.date = %q{2011-06-06}
|
13
13
|
s.description = %q{hacks paperclip to have a single repo of attachments}
|
14
14
|
s.email = %q{dpickett@enlightsolutions.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -55,6 +55,7 @@ Gem::Specification.new do |s|
|
|
55
55
|
s.add_runtime_dependency(%q<rake>, ["= 0.8.7"])
|
56
56
|
s.add_runtime_dependency(%q<paperclip>, ["~> 2.3"])
|
57
57
|
s.add_runtime_dependency(%q<rails>, ["~> 3.0.0"])
|
58
|
+
s.add_development_dependency(%q<ruby-debug>, [">= 0"])
|
58
59
|
s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
|
59
60
|
s.add_development_dependency(%q<yard>, ["~> 0.6.0"])
|
60
61
|
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
@@ -66,6 +67,7 @@ Gem::Specification.new do |s|
|
|
66
67
|
s.add_dependency(%q<rake>, ["= 0.8.7"])
|
67
68
|
s.add_dependency(%q<paperclip>, ["~> 2.3"])
|
68
69
|
s.add_dependency(%q<rails>, ["~> 3.0.0"])
|
70
|
+
s.add_dependency(%q<ruby-debug>, [">= 0"])
|
69
71
|
s.add_dependency(%q<rspec>, ["~> 2.3.0"])
|
70
72
|
s.add_dependency(%q<yard>, ["~> 0.6.0"])
|
71
73
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
@@ -78,6 +80,7 @@ Gem::Specification.new do |s|
|
|
78
80
|
s.add_dependency(%q<rake>, ["= 0.8.7"])
|
79
81
|
s.add_dependency(%q<paperclip>, ["~> 2.3"])
|
80
82
|
s.add_dependency(%q<rails>, ["~> 3.0.0"])
|
83
|
+
s.add_dependency(%q<ruby-debug>, [">= 0"])
|
81
84
|
s.add_dependency(%q<rspec>, ["~> 2.3.0"])
|
82
85
|
s.add_dependency(%q<yard>, ["~> 0.6.0"])
|
83
86
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
data/spec/page_spec.rb
CHANGED
@@ -43,6 +43,14 @@ describe "Page" do
|
|
43
43
|
subject.primary_image_attachment.attachment_updated_at.should_not be_nil
|
44
44
|
end
|
45
45
|
|
46
|
+
it "should set the appropriate id for the image" do
|
47
|
+
attach_primary_image
|
48
|
+
subject.save!
|
49
|
+
subject.primary_image_attachment.id.should_not be_nil
|
50
|
+
subject.primary_image.instance.should_not be_nil
|
51
|
+
subject.primary_image.path.should =~ /#{subject.primary_image_attachment.id}/
|
52
|
+
end
|
53
|
+
|
46
54
|
PRIMARY_IMAGE_PATH = File.dirname(__FILE__) + "/fixtures/rails.png"
|
47
55
|
def attach_primary_image
|
48
56
|
subject.primary_image = File.open(PRIMARY_IMAGE_PATH)
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: polypaperclip
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Dan Pickett
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-06-06 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -68,6 +68,20 @@ dependencies:
|
|
68
68
|
- !ruby/object:Gem::Dependency
|
69
69
|
type: :development
|
70
70
|
requirement: &id004 !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
hash: 3
|
76
|
+
segments:
|
77
|
+
- 0
|
78
|
+
version: "0"
|
79
|
+
name: ruby-debug
|
80
|
+
version_requirements: *id004
|
81
|
+
prerelease: false
|
82
|
+
- !ruby/object:Gem::Dependency
|
83
|
+
type: :development
|
84
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
71
85
|
none: false
|
72
86
|
requirements:
|
73
87
|
- - ~>
|
@@ -79,11 +93,11 @@ dependencies:
|
|
79
93
|
- 0
|
80
94
|
version: 2.3.0
|
81
95
|
name: rspec
|
82
|
-
version_requirements: *
|
96
|
+
version_requirements: *id005
|
83
97
|
prerelease: false
|
84
98
|
- !ruby/object:Gem::Dependency
|
85
99
|
type: :development
|
86
|
-
requirement: &
|
100
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
87
101
|
none: false
|
88
102
|
requirements:
|
89
103
|
- - ~>
|
@@ -95,11 +109,11 @@ dependencies:
|
|
95
109
|
- 0
|
96
110
|
version: 0.6.0
|
97
111
|
name: yard
|
98
|
-
version_requirements: *
|
112
|
+
version_requirements: *id006
|
99
113
|
prerelease: false
|
100
114
|
- !ruby/object:Gem::Dependency
|
101
115
|
type: :development
|
102
|
-
requirement: &
|
116
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
103
117
|
none: false
|
104
118
|
requirements:
|
105
119
|
- - ~>
|
@@ -111,11 +125,11 @@ dependencies:
|
|
111
125
|
- 0
|
112
126
|
version: 1.0.0
|
113
127
|
name: bundler
|
114
|
-
version_requirements: *
|
128
|
+
version_requirements: *id007
|
115
129
|
prerelease: false
|
116
130
|
- !ruby/object:Gem::Dependency
|
117
131
|
type: :development
|
118
|
-
requirement: &
|
132
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
119
133
|
none: false
|
120
134
|
requirements:
|
121
135
|
- - ~>
|
@@ -127,11 +141,11 @@ dependencies:
|
|
127
141
|
- 2
|
128
142
|
version: 1.5.2
|
129
143
|
name: jeweler
|
130
|
-
version_requirements: *
|
144
|
+
version_requirements: *id008
|
131
145
|
prerelease: false
|
132
146
|
- !ruby/object:Gem::Dependency
|
133
147
|
type: :development
|
134
|
-
requirement: &
|
148
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
135
149
|
none: false
|
136
150
|
requirements:
|
137
151
|
- - ~>
|
@@ -143,11 +157,11 @@ dependencies:
|
|
143
157
|
- 0
|
144
158
|
version: 1.3.0
|
145
159
|
name: sqlite3-ruby
|
146
|
-
version_requirements: *
|
160
|
+
version_requirements: *id009
|
147
161
|
prerelease: false
|
148
162
|
- !ruby/object:Gem::Dependency
|
149
163
|
type: :development
|
150
|
-
requirement: &
|
164
|
+
requirement: &id010 !ruby/object:Gem::Requirement
|
151
165
|
none: false
|
152
166
|
requirements:
|
153
167
|
- - ">="
|
@@ -157,11 +171,11 @@ dependencies:
|
|
157
171
|
- 0
|
158
172
|
version: "0"
|
159
173
|
name: rcov
|
160
|
-
version_requirements: *
|
174
|
+
version_requirements: *id010
|
161
175
|
prerelease: false
|
162
176
|
- !ruby/object:Gem::Dependency
|
163
177
|
type: :development
|
164
|
-
requirement: &
|
178
|
+
requirement: &id011 !ruby/object:Gem::Requirement
|
165
179
|
none: false
|
166
180
|
requirements:
|
167
181
|
- - ">="
|
@@ -171,7 +185,7 @@ dependencies:
|
|
171
185
|
- 0
|
172
186
|
version: "0"
|
173
187
|
name: mocha
|
174
|
-
version_requirements: *
|
188
|
+
version_requirements: *id011
|
175
189
|
prerelease: false
|
176
190
|
description: hacks paperclip to have a single repo of attachments
|
177
191
|
email: dpickett@enlightsolutions.com
|