polypaperclip 0.1.8 → 0.1.13

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,12 +1,12 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- gem "rake", "0.8.7"
3
+ gem "rake", "~> 0.8.7"
4
4
  gem "paperclip", "~> 2.3"
5
5
 
6
6
  gem "rails", "~>3.0.0"
7
7
 
8
8
  group :development do
9
- gem "ruby-debug"
9
+ gem "ruby-debug19"
10
10
  gem "rspec", "~> 2.3.0"
11
11
  gem "yard", "~> 0.6.0"
12
12
  gem "bundler", "~> 1.0.0"
@@ -28,9 +28,10 @@ GEM
28
28
  activemodel (= 3.0.7)
29
29
  activesupport (= 3.0.7)
30
30
  activesupport (3.0.7)
31
+ archive-tar-minitar (0.5.2)
31
32
  arel (2.0.10)
32
33
  builder (2.1.2)
33
- columnize (0.3.2)
34
+ columnize (0.3.4)
34
35
  diff-lcs (1.1.2)
35
36
  erubis (2.6.6)
36
37
  abstract (>= 1.0.0)
@@ -40,7 +41,8 @@ GEM
40
41
  bundler (~> 1.0.0)
41
42
  git (>= 1.2.5)
42
43
  rake
43
- linecache (0.43)
44
+ linecache19 (0.5.12)
45
+ ruby_core_source (>= 0.1.4)
44
46
  mail (2.2.19)
45
47
  activesupport (>= 2.3.6)
46
48
  i18n (>= 0.4.0)
@@ -80,11 +82,16 @@ GEM
80
82
  rspec-expectations (2.3.0)
81
83
  diff-lcs (~> 1.1.2)
82
84
  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)
85
+ ruby-debug-base19 (0.11.25)
86
+ columnize (>= 0.3.1)
87
+ linecache19 (>= 0.5.11)
88
+ ruby_core_source (>= 0.1.4)
89
+ ruby-debug19 (0.11.6)
90
+ columnize (>= 0.3.1)
91
+ linecache19 (>= 0.5.11)
92
+ ruby-debug-base19 (>= 0.11.19)
93
+ ruby_core_source (0.1.5)
94
+ archive-tar-minitar (>= 0.5.2)
88
95
  sqlite3 (1.3.3)
89
96
  sqlite3-ruby (1.3.3)
90
97
  sqlite3 (>= 1.3.3)
@@ -103,9 +110,9 @@ DEPENDENCIES
103
110
  mocha
104
111
  paperclip (~> 2.3)
105
112
  rails (~> 3.0.0)
106
- rake (= 0.8.7)
113
+ rake (~> 0.8.7)
107
114
  rcov
108
115
  rspec (~> 2.3.0)
109
- ruby-debug
116
+ ruby-debug19
110
117
  sqlite3-ruby (~> 1.3.0)
111
118
  yard (~> 0.6.0)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.8
1
+ 0.1.13
@@ -72,7 +72,7 @@ module Polypaperclip
72
72
  #we override Paperclip's each_attachment so that we proxy through the attachments model
73
73
  def each_attachment
74
74
  self.class.polypaperclip_definitions.each do |name, definition|
75
- yield(name, paperclip_attachment_for(name)) rescue nil
75
+ yield(name, paperclip_attachment_for(name))
76
76
  end
77
77
  end
78
78
 
@@ -18,6 +18,14 @@ module Polypaperclip
18
18
  build_instance if @instance.nil? #we want to replace
19
19
  super
20
20
  end
21
+
22
+ def instance_read(attr)
23
+ if @instance.nil?
24
+ nil
25
+ else
26
+ super
27
+ end
28
+ end
21
29
 
22
30
  protected
23
31
  def build_instance
@@ -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"
8
+ s.version = "0.1.13"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Dan Pickett"]
12
- s.date = %q{2011-07-13}
11
+ s.authors = [%q{Dan Pickett}]
12
+ s.date = %q{2011-07-30}
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 = [
@@ -36,27 +36,28 @@ Gem::Specification.new do |s|
36
36
  "spec/database.yml",
37
37
  "spec/fixtures/rails.png",
38
38
  "spec/page_spec.rb",
39
- "spec/spec_helper.rb"
39
+ "spec/spec_helper.rb",
40
+ "spec/super_page_spec.rb"
40
41
  ]
41
42
  s.homepage = %q{http://github.com/dpickett/polypaperclip}
42
- s.licenses = ["MIT"]
43
- s.require_paths = ["lib"]
44
- s.rubygems_version = %q{1.3.7}
43
+ s.licenses = [%q{MIT}]
44
+ s.require_paths = [%q{lib}]
45
+ s.rubygems_version = %q{1.8.6}
45
46
  s.summary = %q{Polymorphic attachments with paperclip}
46
47
  s.test_files = [
47
48
  "spec/page_spec.rb",
48
- "spec/spec_helper.rb"
49
+ "spec/spec_helper.rb",
50
+ "spec/super_page_spec.rb"
49
51
  ]
50
52
 
51
53
  if s.respond_to? :specification_version then
52
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
53
54
  s.specification_version = 3
54
55
 
55
56
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
56
- s.add_runtime_dependency(%q<rake>, ["= 0.8.7"])
57
+ s.add_runtime_dependency(%q<rake>, ["~> 0.8.7"])
57
58
  s.add_runtime_dependency(%q<paperclip>, ["~> 2.3"])
58
59
  s.add_runtime_dependency(%q<rails>, ["~> 3.0.0"])
59
- s.add_development_dependency(%q<ruby-debug>, [">= 0"])
60
+ s.add_development_dependency(%q<ruby-debug19>, [">= 0"])
60
61
  s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
61
62
  s.add_development_dependency(%q<yard>, ["~> 0.6.0"])
62
63
  s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
@@ -65,10 +66,10 @@ Gem::Specification.new do |s|
65
66
  s.add_development_dependency(%q<rcov>, [">= 0"])
66
67
  s.add_development_dependency(%q<mocha>, [">= 0"])
67
68
  else
68
- s.add_dependency(%q<rake>, ["= 0.8.7"])
69
+ s.add_dependency(%q<rake>, ["~> 0.8.7"])
69
70
  s.add_dependency(%q<paperclip>, ["~> 2.3"])
70
71
  s.add_dependency(%q<rails>, ["~> 3.0.0"])
71
- s.add_dependency(%q<ruby-debug>, [">= 0"])
72
+ s.add_dependency(%q<ruby-debug19>, [">= 0"])
72
73
  s.add_dependency(%q<rspec>, ["~> 2.3.0"])
73
74
  s.add_dependency(%q<yard>, ["~> 0.6.0"])
74
75
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
@@ -78,10 +79,10 @@ Gem::Specification.new do |s|
78
79
  s.add_dependency(%q<mocha>, [">= 0"])
79
80
  end
80
81
  else
81
- s.add_dependency(%q<rake>, ["= 0.8.7"])
82
+ s.add_dependency(%q<rake>, ["~> 0.8.7"])
82
83
  s.add_dependency(%q<paperclip>, ["~> 2.3"])
83
84
  s.add_dependency(%q<rails>, ["~> 3.0.0"])
84
- s.add_dependency(%q<ruby-debug>, [">= 0"])
85
+ s.add_dependency(%q<ruby-debug19>, [">= 0"])
85
86
  s.add_dependency(%q<rspec>, ["~> 2.3.0"])
86
87
  s.add_dependency(%q<yard>, ["~> 0.6.0"])
87
88
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
@@ -57,7 +57,26 @@ describe "Page" do
57
57
  subject.primary_image.url.should_not be_nil
58
58
  subject.primary_image_attachment.attachment_type.should eql("primary_image")
59
59
  end
60
-
60
+
61
+ it "destroys without error" do
62
+ attach_primary_image
63
+ subject.save!
64
+ lambda { subject.destroy }.should_not raise_error
65
+ end
66
+
67
+ it "destroys without error if I don't have an attachment" do
68
+ attach_primary_image
69
+ subject.save!
70
+ lambda { subject.destroy }.should_not raise_error
71
+ end
72
+
73
+ it "removes the association" do
74
+ attach_primary_image
75
+ subject.save!
76
+ subject.destroy
77
+ subject.attachments.count.should eql(0)
78
+ end
79
+
61
80
  PRIMARY_IMAGE_PATH = File.dirname(__FILE__) + "/fixtures/rails.png"
62
81
  def attach_primary_image
63
82
  subject.primary_image = File.open(PRIMARY_IMAGE_PATH)
@@ -41,6 +41,9 @@ RSpec.configure do |config|
41
41
  :styles => {:large => "200x200", :thumb => "50x50"}
42
42
  end
43
43
 
44
+ class SuperPage < Page
45
+ end
46
+
44
47
  Object.const_set(:Rails, stub('Rails', :root => File.dirname(__FILE__), :env => 'test'))
45
48
  end
46
49
  end
@@ -0,0 +1,27 @@
1
+ require "spec_helper"
2
+
3
+ describe "SuperPage" do
4
+ subject { SuperPage.new(:name => "some page") }
5
+
6
+ its(:primary_image) { should_not be_nil }
7
+ its(:primary_image_attachment) { should be_nil }
8
+
9
+ its(:secondary_image) { should_not be_nil }
10
+ its(:secondary_image_attachment) { should be_nil }
11
+
12
+ it "does not save an attachment if I did not assign one" do
13
+ subject.save!
14
+ subject.primary_image_attachment.should be_nil
15
+ end
16
+
17
+ it "saves an attachment when I do save one" do
18
+ attach_primary_image
19
+ subject.save!
20
+ subject.primary_image_attachment.should_not be_nil
21
+ end
22
+
23
+ PRIMARY_IMAGE_PATH = File.dirname(__FILE__) + "/fixtures/rails.png"
24
+ def attach_primary_image
25
+ subject.primary_image = File.open(PRIMARY_IMAGE_PATH)
26
+ end
27
+ end
metadata CHANGED
@@ -1,202 +1,145 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: polypaperclip
3
- version: !ruby/object:Gem::Version
4
- hash: 11
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 1
9
- - 8
10
- version: 0.1.8
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.13
5
+ prerelease:
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Dan Pickett
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-07-13 00:00:00 -07:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
22
- requirement: &id001 !ruby/object:Gem::Requirement
12
+ date: 2011-07-30 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: &2168810580 !ruby/object:Gem::Requirement
23
17
  none: false
24
- requirements:
25
- - - "="
26
- - !ruby/object:Gem::Version
27
- hash: 49
28
- segments:
29
- - 0
30
- - 8
31
- - 7
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
32
21
  version: 0.8.7
33
22
  type: :runtime
34
- name: rake
35
23
  prerelease: false
36
- version_requirements: *id001
37
- - !ruby/object:Gem::Dependency
38
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *2168810580
25
+ - !ruby/object:Gem::Dependency
26
+ name: paperclip
27
+ requirement: &2168826480 !ruby/object:Gem::Requirement
39
28
  none: false
40
- requirements:
29
+ requirements:
41
30
  - - ~>
42
- - !ruby/object:Gem::Version
43
- hash: 5
44
- segments:
45
- - 2
46
- - 3
47
- version: "2.3"
31
+ - !ruby/object:Gem::Version
32
+ version: '2.3'
48
33
  type: :runtime
49
- name: paperclip
50
34
  prerelease: false
51
- version_requirements: *id002
52
- - !ruby/object:Gem::Dependency
53
- requirement: &id003 !ruby/object:Gem::Requirement
35
+ version_requirements: *2168826480
36
+ - !ruby/object:Gem::Dependency
37
+ name: rails
38
+ requirement: &2168826000 !ruby/object:Gem::Requirement
54
39
  none: false
55
- requirements:
40
+ requirements:
56
41
  - - ~>
57
- - !ruby/object:Gem::Version
58
- hash: 7
59
- segments:
60
- - 3
61
- - 0
62
- - 0
42
+ - !ruby/object:Gem::Version
63
43
  version: 3.0.0
64
44
  type: :runtime
65
- name: rails
66
45
  prerelease: false
67
- version_requirements: *id003
68
- - !ruby/object:Gem::Dependency
69
- requirement: &id004 !ruby/object:Gem::Requirement
46
+ version_requirements: *2168826000
47
+ - !ruby/object:Gem::Dependency
48
+ name: ruby-debug19
49
+ requirement: &2168825520 !ruby/object:Gem::Requirement
70
50
  none: false
71
- requirements:
72
- - - ">="
73
- - !ruby/object:Gem::Version
74
- hash: 3
75
- segments:
76
- - 0
77
- version: "0"
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
78
55
  type: :development
79
- name: ruby-debug
80
56
  prerelease: false
81
- version_requirements: *id004
82
- - !ruby/object:Gem::Dependency
83
- requirement: &id005 !ruby/object:Gem::Requirement
57
+ version_requirements: *2168825520
58
+ - !ruby/object:Gem::Dependency
59
+ name: rspec
60
+ requirement: &2168825040 !ruby/object:Gem::Requirement
84
61
  none: false
85
- requirements:
62
+ requirements:
86
63
  - - ~>
87
- - !ruby/object:Gem::Version
88
- hash: 3
89
- segments:
90
- - 2
91
- - 3
92
- - 0
64
+ - !ruby/object:Gem::Version
93
65
  version: 2.3.0
94
66
  type: :development
95
- name: rspec
96
67
  prerelease: false
97
- version_requirements: *id005
98
- - !ruby/object:Gem::Dependency
99
- requirement: &id006 !ruby/object:Gem::Requirement
68
+ version_requirements: *2168825040
69
+ - !ruby/object:Gem::Dependency
70
+ name: yard
71
+ requirement: &2168824560 !ruby/object:Gem::Requirement
100
72
  none: false
101
- requirements:
73
+ requirements:
102
74
  - - ~>
103
- - !ruby/object:Gem::Version
104
- hash: 7
105
- segments:
106
- - 0
107
- - 6
108
- - 0
75
+ - !ruby/object:Gem::Version
109
76
  version: 0.6.0
110
77
  type: :development
111
- name: yard
112
78
  prerelease: false
113
- version_requirements: *id006
114
- - !ruby/object:Gem::Dependency
115
- requirement: &id007 !ruby/object:Gem::Requirement
79
+ version_requirements: *2168824560
80
+ - !ruby/object:Gem::Dependency
81
+ name: bundler
82
+ requirement: &2168824080 !ruby/object:Gem::Requirement
116
83
  none: false
117
- requirements:
84
+ requirements:
118
85
  - - ~>
119
- - !ruby/object:Gem::Version
120
- hash: 23
121
- segments:
122
- - 1
123
- - 0
124
- - 0
86
+ - !ruby/object:Gem::Version
125
87
  version: 1.0.0
126
88
  type: :development
127
- name: bundler
128
89
  prerelease: false
129
- version_requirements: *id007
130
- - !ruby/object:Gem::Dependency
131
- requirement: &id008 !ruby/object:Gem::Requirement
90
+ version_requirements: *2168824080
91
+ - !ruby/object:Gem::Dependency
92
+ name: jeweler
93
+ requirement: &2168823600 !ruby/object:Gem::Requirement
132
94
  none: false
133
- requirements:
95
+ requirements:
134
96
  - - ~>
135
- - !ruby/object:Gem::Version
136
- hash: 7
137
- segments:
138
- - 1
139
- - 5
140
- - 2
97
+ - !ruby/object:Gem::Version
141
98
  version: 1.5.2
142
99
  type: :development
143
- name: jeweler
144
100
  prerelease: false
145
- version_requirements: *id008
146
- - !ruby/object:Gem::Dependency
147
- requirement: &id009 !ruby/object:Gem::Requirement
101
+ version_requirements: *2168823600
102
+ - !ruby/object:Gem::Dependency
103
+ name: sqlite3-ruby
104
+ requirement: &2168823120 !ruby/object:Gem::Requirement
148
105
  none: false
149
- requirements:
106
+ requirements:
150
107
  - - ~>
151
- - !ruby/object:Gem::Version
152
- hash: 27
153
- segments:
154
- - 1
155
- - 3
156
- - 0
108
+ - !ruby/object:Gem::Version
157
109
  version: 1.3.0
158
110
  type: :development
159
- name: sqlite3-ruby
160
111
  prerelease: false
161
- version_requirements: *id009
162
- - !ruby/object:Gem::Dependency
163
- requirement: &id010 !ruby/object:Gem::Requirement
112
+ version_requirements: *2168823120
113
+ - !ruby/object:Gem::Dependency
114
+ name: rcov
115
+ requirement: &2168822640 !ruby/object:Gem::Requirement
164
116
  none: false
165
- requirements:
166
- - - ">="
167
- - !ruby/object:Gem::Version
168
- hash: 3
169
- segments:
170
- - 0
171
- version: "0"
117
+ requirements:
118
+ - - ! '>='
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
172
121
  type: :development
173
- name: rcov
174
122
  prerelease: false
175
- version_requirements: *id010
176
- - !ruby/object:Gem::Dependency
177
- requirement: &id011 !ruby/object:Gem::Requirement
123
+ version_requirements: *2168822640
124
+ - !ruby/object:Gem::Dependency
125
+ name: mocha
126
+ requirement: &2168822160 !ruby/object:Gem::Requirement
178
127
  none: false
179
- requirements:
180
- - - ">="
181
- - !ruby/object:Gem::Version
182
- hash: 3
183
- segments:
184
- - 0
185
- version: "0"
128
+ requirements:
129
+ - - ! '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
186
132
  type: :development
187
- name: mocha
188
133
  prerelease: false
189
- version_requirements: *id011
134
+ version_requirements: *2168822160
190
135
  description: hacks paperclip to have a single repo of attachments
191
136
  email: dpickett@enlightsolutions.com
192
137
  executables: []
193
-
194
138
  extensions: []
195
-
196
- extra_rdoc_files:
139
+ extra_rdoc_files:
197
140
  - LICENSE.txt
198
141
  - README.rdoc
199
- files:
142
+ files:
200
143
  - .document
201
144
  - .rspec
202
145
  - Gemfile
@@ -217,40 +160,36 @@ files:
217
160
  - spec/fixtures/rails.png
218
161
  - spec/page_spec.rb
219
162
  - spec/spec_helper.rb
220
- has_rdoc: true
163
+ - spec/super_page_spec.rb
221
164
  homepage: http://github.com/dpickett/polypaperclip
222
- licenses:
165
+ licenses:
223
166
  - MIT
224
167
  post_install_message:
225
168
  rdoc_options: []
226
-
227
- require_paths:
169
+ require_paths:
228
170
  - lib
229
- required_ruby_version: !ruby/object:Gem::Requirement
171
+ required_ruby_version: !ruby/object:Gem::Requirement
230
172
  none: false
231
- requirements:
232
- - - ">="
233
- - !ruby/object:Gem::Version
234
- hash: 3
235
- segments:
173
+ requirements:
174
+ - - ! '>='
175
+ - !ruby/object:Gem::Version
176
+ version: '0'
177
+ segments:
236
178
  - 0
237
- version: "0"
238
- required_rubygems_version: !ruby/object:Gem::Requirement
179
+ hash: -747686627091737760
180
+ required_rubygems_version: !ruby/object:Gem::Requirement
239
181
  none: false
240
- requirements:
241
- - - ">="
242
- - !ruby/object:Gem::Version
243
- hash: 3
244
- segments:
245
- - 0
246
- version: "0"
182
+ requirements:
183
+ - - ! '>='
184
+ - !ruby/object:Gem::Version
185
+ version: '0'
247
186
  requirements: []
248
-
249
187
  rubyforge_project:
250
- rubygems_version: 1.3.7
188
+ rubygems_version: 1.8.6
251
189
  signing_key:
252
190
  specification_version: 3
253
191
  summary: Polymorphic attachments with paperclip
254
- test_files:
192
+ test_files:
255
193
  - spec/page_spec.rb
256
194
  - spec/spec_helper.rb
195
+ - spec/super_page_spec.rb