paperclip-cloudfiles 2.3.2 → 2.3.8

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.
Files changed (48) hide show
  1. data/README.rdoc +10 -3
  2. data/Rakefile +8 -4
  3. data/generators/paperclip/USAGE +2 -2
  4. data/generators/paperclip/paperclip_generator.rb +8 -8
  5. data/lib/generators/paperclip/USAGE +8 -0
  6. data/lib/generators/paperclip/paperclip_generator.rb +31 -0
  7. data/lib/generators/paperclip/templates/paperclip_migration.rb.erb +19 -0
  8. data/lib/paperclip/attachment.rb +38 -18
  9. data/lib/paperclip/command_line.rb +80 -0
  10. data/lib/paperclip/geometry.rb +7 -7
  11. data/lib/paperclip/interpolations.rb +8 -2
  12. data/lib/paperclip/iostream.rb +11 -25
  13. data/lib/paperclip/matchers/validate_attachment_content_type_matcher.rb +3 -3
  14. data/lib/paperclip/matchers/validate_attachment_presence_matcher.rb +0 -1
  15. data/lib/paperclip/matchers/validate_attachment_size_matcher.rb +0 -1
  16. data/lib/paperclip/processor.rb +15 -6
  17. data/lib/paperclip/railtie.rb +24 -0
  18. data/lib/paperclip/storage/cloud_files.rb +131 -0
  19. data/lib/paperclip/storage/filesystem.rb +73 -0
  20. data/lib/paperclip/storage/s3.rb +192 -0
  21. data/lib/paperclip/storage.rb +3 -371
  22. data/lib/paperclip/style.rb +11 -11
  23. data/lib/paperclip/thumbnail.rb +16 -15
  24. data/lib/paperclip/upfile.rb +5 -3
  25. data/lib/paperclip/version.rb +3 -0
  26. data/lib/paperclip.rb +78 -92
  27. data/lib/tasks/paperclip.rake +72 -0
  28. data/rails/init.rb +2 -0
  29. data/shoulda_macros/paperclip.rb +1 -2
  30. data/test/attachment_test.rb +74 -28
  31. data/test/command_line_test.rb +133 -0
  32. data/test/geometry_test.rb +2 -2
  33. data/test/helper.rb +22 -24
  34. data/test/integration_test.rb +10 -11
  35. data/test/interpolations_test.rb +7 -4
  36. data/test/iostream_test.rb +6 -13
  37. data/test/matchers/have_attached_file_matcher_test.rb +1 -1
  38. data/test/matchers/validate_attachment_content_type_matcher_test.rb +11 -1
  39. data/test/matchers/validate_attachment_presence_matcher_test.rb +1 -1
  40. data/test/matchers/validate_attachment_size_matcher_test.rb +1 -1
  41. data/test/paperclip_test.rb +54 -80
  42. data/test/processor_test.rb +1 -1
  43. data/test/storage_test.rb +32 -12
  44. data/test/style_test.rb +17 -17
  45. data/test/thumbnail_test.rb +18 -18
  46. data/test/upfile_test.rb +1 -1
  47. metadata +58 -31
  48. data/tasks/paperclip_tasks.rake +0 -79
data/test/storage_test.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'test/helper'
1
+ require './test/helper'
2
2
  require 'aws/s3'
3
3
 
4
4
  class StorageTest < Test::Unit::TestCase
@@ -50,29 +50,29 @@ class StorageTest < Test::Unit::TestCase
50
50
 
51
51
  @dummy = Dummy.new
52
52
  @avatar = @dummy.avatar
53
- @current_env = RAILS_ENV
53
+ @current_env = Rails.env
54
54
  end
55
55
 
56
56
  teardown do
57
- Object.const_set("RAILS_ENV", @current_env)
57
+ rails_env(@current_env)
58
58
  end
59
59
 
60
60
  should "get the correct credentials when RAILS_ENV is production" do
61
- Object.const_set('RAILS_ENV', "production")
61
+ rails_env("production")
62
62
  assert_equal({:username => "minter"},
63
63
  @avatar.parse_credentials('production' => {:username => 'minter'},
64
64
  :development => {:username => "mcornick"}))
65
65
  end
66
66
 
67
67
  should "get the correct credentials when RAILS_ENV is development" do
68
- Object.const_set('RAILS_ENV', "development")
68
+ rails_env("development")
69
69
  assert_equal({:key => "mcornick"},
70
70
  @avatar.parse_credentials('production' => {:key => 'minter'},
71
71
  :development => {:key => "mcornick"}))
72
72
  end
73
73
 
74
74
  should "return the argument if the key does not exist" do
75
- Object.const_set('RAILS_ENV', "not really an env")
75
+ rails_env("not_valid")
76
76
  assert_equal({:test => "minter"}, @avatar.parse_credentials(:test => "minter"))
77
77
  end
78
78
  end
@@ -215,18 +215,18 @@ class StorageTest < Test::Unit::TestCase
215
215
  :development => { :container => "dev_container" }
216
216
  }
217
217
  @dummy = Dummy.new
218
- @old_env = RAILS_ENV
218
+ @old_env = Rails.env
219
219
  end
220
220
 
221
- teardown{ Object.const_set("RAILS_ENV", @old_env) }
221
+ teardown{ rails_env(@old_env) }
222
222
 
223
223
  should "get the right container in production" do
224
- Object.const_set("RAILS_ENV", "production")
224
+ rails_env("production")
225
225
  assert_equal "prod_container", @dummy.avatar.container_name
226
226
  end
227
227
 
228
228
  should "get the right bucket in development" do
229
- Object.const_set("RAILS_ENV", "development")
229
+ rails_env("development")
230
230
  assert_equal "dev_container", @dummy.avatar.container_name
231
231
  end
232
232
  end
@@ -277,6 +277,21 @@ class StorageTest < Test::Unit::TestCase
277
277
  end
278
278
  end
279
279
 
280
+ context "and saved without a bucket" do
281
+ setup do
282
+ class AWS::S3::NoSuchBucket < AWS::S3::ResponseError
283
+ # Force the class to be created as a proper subclass of ResponseError thanks to AWS::S3's autocreation of exceptions
284
+ end
285
+ AWS::S3::Bucket.expects(:create).with("testing")
286
+ AWS::S3::S3Object.stubs(:store).raises(AWS::S3::NoSuchBucket.new(:message, :response)).then.returns(true)
287
+ @dummy.save
288
+ end
289
+
290
+ should "succeed" do
291
+ assert true
292
+ end
293
+ end
294
+
280
295
  context "and remove" do
281
296
  setup do
282
297
  AWS::S3::S3Object.stubs(:exists?).returns(true)
@@ -304,7 +319,7 @@ class StorageTest < Test::Unit::TestCase
304
319
 
305
320
  should "be extended by the CloudFile module" do
306
321
  CloudFiles::Connection.stubs(:new).returns(true)
307
- assert Dummy.new.avatar.is_a?(Paperclip::Storage::CloudFile)
322
+ assert Dummy.new.avatar.is_a?(Paperclip::Storage::Cloud_files)
308
323
  end
309
324
 
310
325
  should "not be extended by the Filesystem module" do
@@ -501,7 +516,7 @@ class StorageTest < Test::Unit::TestCase
501
516
  teardown { @file.close }
502
517
 
503
518
  should "still return a Tempfile when sent #to_file" do
504
- assert_equal Tempfile, @dummy.avatar.to_file.class
519
+ assert_equal Paperclip::Tempfile, @dummy.avatar.to_file.class
505
520
  end
506
521
 
507
522
  context "and saved" do
@@ -512,6 +527,11 @@ class StorageTest < Test::Unit::TestCase
512
527
  should "be on S3" do
513
528
  assert true
514
529
  end
530
+
531
+ should "generate a tempfile with the right name" do
532
+ file = @dummy.avatar.to_file
533
+ assert_match /^original.*\.png$/, File.basename(file.path)
534
+ end
515
535
  end
516
536
  end
517
537
  end
data/test/style_test.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
- require 'test/helper'
2
+ require './test/helper'
3
3
 
4
4
  class StyleTest < Test::Unit::TestCase
5
5
 
@@ -9,7 +9,7 @@ class StyleTest < Test::Unit::TestCase
9
9
  :styles => { :foo => {:geometry => "100x100#", :format => :png} }
10
10
  @style = @attachment.styles[:foo]
11
11
  end
12
-
12
+
13
13
  should "be held as a Style object" do
14
14
  assert_kind_of Paperclip::Style, @style
15
15
  end
@@ -21,18 +21,18 @@ class StyleTest < Test::Unit::TestCase
21
21
  should "have the right geometry" do
22
22
  assert_equal "100x100#", @style.geometry
23
23
  end
24
-
24
+
25
25
  should "be whiny if the attachment is" do
26
26
  @attachment.expects(:whiny).returns(true)
27
27
  assert @style.whiny?
28
28
  end
29
-
29
+
30
30
  should "respond to hash notation" do
31
31
  assert_equal [:thumbnail], @style[:processors]
32
32
  assert_equal "100x100#", @style[:geometry]
33
33
  end
34
34
  end
35
-
35
+
36
36
  context "A style rule with properties supplied as procs" do
37
37
  setup do
38
38
  @attachment = attachment :path => ":basename.:extension",
@@ -45,13 +45,13 @@ class StyleTest < Test::Unit::TestCase
45
45
  }
46
46
  }
47
47
  end
48
-
48
+
49
49
  should "defer processing of procs until they are needed" do
50
50
  assert_kind_of Proc, @attachment.styles[:foo].instance_variable_get("@geometry")
51
51
  assert_kind_of Proc, @attachment.styles[:bar].instance_variable_get("@geometry")
52
52
  assert_kind_of Proc, @attachment.instance_variable_get("@processors")
53
53
  end
54
-
54
+
55
55
  should "call procs when they are needed" do
56
56
  assert_equal "300x300#", @attachment.styles[:foo].geometry
57
57
  assert_equal "300x300#", @attachment.styles[:bar].geometry
@@ -63,7 +63,7 @@ class StyleTest < Test::Unit::TestCase
63
63
  context "An attachment with style rules in various forms" do
64
64
  setup do
65
65
  @attachment = attachment :path => ":basename.:extension",
66
- :styles => {
66
+ :styles => {
67
67
  :aslist => ["100x100", :png],
68
68
  :ashash => {:geometry => "100x100", :format => :png},
69
69
  :asstring => "100x100"
@@ -73,13 +73,13 @@ class StyleTest < Test::Unit::TestCase
73
73
  assert_kind_of Hash, @attachment.styles
74
74
  assert_equal 3, @attachment.styles.size
75
75
  end
76
-
76
+
77
77
  should "have styles as Style objects" do
78
78
  [:aslist, :ashash, :aslist].each do |s|
79
79
  assert_kind_of Paperclip::Style, @attachment.styles[s]
80
80
  end
81
81
  end
82
-
82
+
83
83
  should "have the right geometries" do
84
84
  [:aslist, :ashash, :aslist].each do |s|
85
85
  assert_equal @attachment.styles[s].geometry, "100x100"
@@ -107,32 +107,32 @@ class StyleTest < Test::Unit::TestCase
107
107
  before_should "not have called extra_options_for(:thumb/:large) on initialization" do
108
108
  @attachment.expects(:extra_options_for).never
109
109
  end
110
-
110
+
111
111
  should "call extra_options_for(:thumb/:large) when convert options are requested" do
112
112
  @attachment.expects(:extra_options_for).with(:thumb)
113
113
  @attachment.styles[:thumb].convert_options
114
114
  end
115
115
  end
116
-
116
+
117
117
  context "A style rule with its own :processors" do
118
118
  setup do
119
119
  @attachment = attachment :path => ":basename.:extension",
120
- :styles => {
120
+ :styles => {
121
121
  :foo => {
122
- :geometry => "100x100#",
122
+ :geometry => "100x100#",
123
123
  :format => :png,
124
124
  :processors => [:test]
125
- }
125
+ }
126
126
  },
127
127
  :processors => [:thumbnail]
128
128
  @style = @attachment.styles[:foo]
129
129
  end
130
-
130
+
131
131
  should "not get processors from the attachment" do
132
132
  @attachment.expects(:processors).never
133
133
  assert_not_equal [:thumbnail], @style.processors
134
134
  end
135
-
135
+
136
136
  should "report its own processors" do
137
137
  assert_equal [:test], @style.processors
138
138
  end
@@ -1,10 +1,10 @@
1
- require 'test/helper'
1
+ require './test/helper'
2
2
 
3
3
  class ThumbnailTest < Test::Unit::TestCase
4
4
 
5
5
  context "A Paperclip Tempfile" do
6
6
  setup do
7
- @tempfile = Paperclip::Tempfile.new("file.jpg")
7
+ @tempfile = Paperclip::Tempfile.new(["file", ".jpg"])
8
8
  end
9
9
 
10
10
  should "have its path contain a real extension" do
@@ -47,7 +47,7 @@ class ThumbnailTest < Test::Unit::TestCase
47
47
  end
48
48
 
49
49
  should "start with dimensions of 434x66" do
50
- cmd = %Q[identify -format "%wx%h" "#{@file.path}"]
50
+ cmd = %Q[identify -format "%wx%h" "#{@file.path}"]
51
51
  assert_equal "434x66", `#{cmd}`.chomp
52
52
  end
53
53
 
@@ -61,7 +61,7 @@ class ThumbnailTest < Test::Unit::TestCase
61
61
  end
62
62
 
63
63
  should "be the size we expect it to be" do
64
- cmd = %Q[identify -format "%wx%h" "#{@thumb_result.path}"]
64
+ cmd = %Q[identify -format "%wx%h" "#{@thumb_result.path}"]
65
65
  assert_equal args[1], `#{cmd}`.chomp
66
66
  end
67
67
  end
@@ -85,14 +85,14 @@ class ThumbnailTest < Test::Unit::TestCase
85
85
  should "have whiny turned on by default" do
86
86
  assert @thumb.whiny
87
87
  end
88
-
88
+
89
89
  should "have convert_options set to nil by default" do
90
90
  assert_equal nil, @thumb.convert_options
91
91
  end
92
92
 
93
93
  should "send the right command to convert when sent #make" do
94
- Paperclip.expects(:"`").with do |arg|
95
- arg.match %r{convert '#{File.expand_path(@thumb.file.path)}\[0\]' '-resize' 'x50' '-crop' '100x50\+114\+0' '\+repage' '.*?'}
94
+ Paperclip::CommandLine.expects(:"`").with do |arg|
95
+ arg.match %r{convert ["']#{File.expand_path(@thumb.file.path)}\[0\]["'] -resize ["']x50["'] -crop ["']100x50\+114\+0["'] \+repage ["'].*?["']}
96
96
  end
97
97
  @thumb.make
98
98
  end
@@ -102,7 +102,7 @@ class ThumbnailTest < Test::Unit::TestCase
102
102
  assert_match /100x50/, `identify "#{dst.path}"`
103
103
  end
104
104
  end
105
-
105
+
106
106
  context "being thumbnailed with source file options set" do
107
107
  setup do
108
108
  @thumb = Paperclip::Thumbnail.new(@file,
@@ -115,8 +115,8 @@ class ThumbnailTest < Test::Unit::TestCase
115
115
  end
116
116
 
117
117
  should "send the right command to convert when sent #make" do
118
- Paperclip.expects(:"`").with do |arg|
119
- arg.match %r{convert '-strip' '#{File.expand_path(@thumb.file.path)}\[0\]' '-resize' 'x50' '-crop' '100x50\+114\+0' '\+repage' '.*?'}
118
+ Paperclip::CommandLine.expects(:"`").with do |arg|
119
+ arg.match %r{convert -strip ["']#{File.expand_path(@thumb.file.path)}\[0\]["'] -resize ["']x50["'] -crop ["']100x50\+114\+0["'] \+repage ["'].*?["']}
120
120
  end
121
121
  @thumb.make
122
122
  end
@@ -125,7 +125,7 @@ class ThumbnailTest < Test::Unit::TestCase
125
125
  dst = @thumb.make
126
126
  assert_match /100x50/, `identify "#{dst.path}"`
127
127
  end
128
-
128
+
129
129
  context "redefined to have bad source_file_options setting" do
130
130
  setup do
131
131
  @thumb = Paperclip::Thumbnail.new(@file,
@@ -138,7 +138,7 @@ class ThumbnailTest < Test::Unit::TestCase
138
138
  @thumb.make
139
139
  end
140
140
  end
141
- end
141
+ end
142
142
  end
143
143
 
144
144
  context "being thumbnailed with convert options set" do
@@ -153,8 +153,8 @@ class ThumbnailTest < Test::Unit::TestCase
153
153
  end
154
154
 
155
155
  should "send the right command to convert when sent #make" do
156
- Paperclip.expects(:"`").with do |arg|
157
- arg.match %r{convert '#{File.expand_path(@thumb.file.path)}\[0\]' '-resize' 'x50' '-crop' '100x50\+114\+0' '\+repage' '-strip' '-depth' '8' '.*?'}
156
+ Paperclip::CommandLine.expects(:"`").with do |arg|
157
+ arg.match %r{convert ["']#{File.expand_path(@thumb.file.path)}\[0\]["'] -resize ["']x50["'] -crop ["']100x50\+114\+0["'] \+repage -strip -depth 8 ["'].*?["']}
158
158
  end
159
159
  @thumb.make
160
160
  end
@@ -163,7 +163,7 @@ class ThumbnailTest < Test::Unit::TestCase
163
163
  dst = @thumb.make
164
164
  assert_match /100x50/, `identify "#{dst.path}"`
165
165
  end
166
-
166
+
167
167
  context "redefined to have bad convert_options setting" do
168
168
  setup do
169
169
  @thumb = Paperclip::Thumbnail.new(@file,
@@ -176,16 +176,16 @@ class ThumbnailTest < Test::Unit::TestCase
176
176
  @thumb.make
177
177
  end
178
178
  end
179
- end
179
+ end
180
180
  end
181
-
181
+
182
182
  context "being thumbnailed with a blank geometry string" do
183
183
  setup do
184
184
  @thumb = Paperclip::Thumbnail.new(@file,
185
185
  :geometry => "",
186
186
  :convert_options => "-gravity center -crop \"300x300+0-0\"")
187
187
  end
188
-
188
+
189
189
  should "not get resized by default" do
190
190
  assert !@thumb.transformation_command.include?("-resize")
191
191
  end
data/test/upfile_test.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'test/helper'
1
+ require './test/helper'
2
2
 
3
3
  class UpfileTest < Test::Unit::TestCase
4
4
  { %w(jpg jpe jpeg) => 'image/jpeg',
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paperclip-cloudfiles
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 2
8
8
  - 3
9
- - 2
10
- version: 2.3.2
9
+ - 8
10
+ version: 2.3.8
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jon Yurek
@@ -16,13 +16,12 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-05-27 00:00:00 -05:00
19
+ date: 2011-01-04 00:00:00 -05:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
- name: shoulda
24
23
  prerelease: false
25
- requirement: &id001 !ruby/object:Gem::Requirement
24
+ version_requirements: &id001 !ruby/object:Gem::Requirement
26
25
  none: false
27
26
  requirements:
28
27
  - - ">="
@@ -31,12 +30,12 @@ dependencies:
31
30
  segments:
32
31
  - 0
33
32
  version: "0"
34
- type: :development
35
- version_requirements: *id001
33
+ requirement: *id001
34
+ name: activerecord
35
+ type: :runtime
36
36
  - !ruby/object:Gem::Dependency
37
- name: mocha
38
37
  prerelease: false
39
- requirement: &id002 !ruby/object:Gem::Requirement
38
+ version_requirements: &id002 !ruby/object:Gem::Requirement
40
39
  none: false
41
40
  requirements:
42
41
  - - ">="
@@ -45,12 +44,12 @@ dependencies:
45
44
  segments:
46
45
  - 0
47
46
  version: "0"
48
- type: :development
49
- version_requirements: *id002
47
+ requirement: *id002
48
+ name: activesupport
49
+ type: :runtime
50
50
  - !ruby/object:Gem::Dependency
51
- name: aws-s3
52
51
  prerelease: false
53
- requirement: &id003 !ruby/object:Gem::Requirement
52
+ version_requirements: &id003 !ruby/object:Gem::Requirement
54
53
  none: false
55
54
  requirements:
56
55
  - - ">="
@@ -59,12 +58,12 @@ dependencies:
59
58
  segments:
60
59
  - 0
61
60
  version: "0"
61
+ requirement: *id003
62
+ name: shoulda
62
63
  type: :development
63
- version_requirements: *id003
64
64
  - !ruby/object:Gem::Dependency
65
- name: cloudfiles
66
65
  prerelease: false
67
- requirement: &id004 !ruby/object:Gem::Requirement
66
+ version_requirements: &id004 !ruby/object:Gem::Requirement
68
67
  none: false
69
68
  requirements:
70
69
  - - ">="
@@ -73,12 +72,12 @@ dependencies:
73
72
  segments:
74
73
  - 0
75
74
  version: "0"
75
+ requirement: *id004
76
+ name: appraisal
76
77
  type: :development
77
- version_requirements: *id004
78
78
  - !ruby/object:Gem::Dependency
79
- name: sqlite3-ruby
80
79
  prerelease: false
81
- requirement: &id005 !ruby/object:Gem::Requirement
80
+ version_requirements: &id005 !ruby/object:Gem::Requirement
82
81
  none: false
83
82
  requirements:
84
83
  - - ">="
@@ -87,12 +86,12 @@ dependencies:
87
86
  segments:
88
87
  - 0
89
88
  version: "0"
89
+ requirement: *id005
90
+ name: mocha
90
91
  type: :development
91
- version_requirements: *id005
92
92
  - !ruby/object:Gem::Dependency
93
- name: active_record
94
93
  prerelease: false
95
- requirement: &id006 !ruby/object:Gem::Requirement
94
+ version_requirements: &id006 !ruby/object:Gem::Requirement
96
95
  none: false
97
96
  requirements:
98
97
  - - ">="
@@ -101,12 +100,28 @@ dependencies:
101
100
  segments:
102
101
  - 0
103
102
  version: "0"
103
+ requirement: *id006
104
+ name: aws-s3
104
105
  type: :development
105
- version_requirements: *id006
106
106
  - !ruby/object:Gem::Dependency
107
- name: active_support
108
107
  prerelease: false
109
- requirement: &id007 !ruby/object:Gem::Requirement
108
+ version_requirements: &id007 !ruby/object:Gem::Requirement
109
+ none: false
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ hash: 21
114
+ segments:
115
+ - 1
116
+ - 4
117
+ - 9
118
+ version: 1.4.9
119
+ requirement: *id007
120
+ name: cloudfiles
121
+ type: :development
122
+ - !ruby/object:Gem::Dependency
123
+ prerelease: false
124
+ version_requirements: &id008 !ruby/object:Gem::Requirement
110
125
  none: false
111
126
  requirements:
112
127
  - - ">="
@@ -115,8 +130,9 @@ dependencies:
115
130
  segments:
116
131
  - 0
117
132
  version: "0"
133
+ requirement: *id008
134
+ name: sqlite3-ruby
118
135
  type: :development
119
- version_requirements: *id007
120
136
  description: Easy upload management for ActiveRecord with Rackspace Cloud Files support
121
137
  email:
122
138
  - jyurek@thoughtbot.com
@@ -132,11 +148,12 @@ files:
132
148
  - LICENSE
133
149
  - Rakefile
134
150
  - init.rb
135
- - generators/paperclip/paperclip_generator.rb
136
- - generators/paperclip/templates/paperclip_migration.rb.erb
137
- - generators/paperclip/USAGE
151
+ - lib/generators/paperclip/paperclip_generator.rb
152
+ - lib/generators/paperclip/templates/paperclip_migration.rb.erb
153
+ - lib/generators/paperclip/USAGE
138
154
  - lib/paperclip/attachment.rb
139
155
  - lib/paperclip/callback_compatability.rb
156
+ - lib/paperclip/command_line.rb
140
157
  - lib/paperclip/geometry.rb
141
158
  - lib/paperclip/interpolations.rb
142
159
  - lib/paperclip/iostream.rb
@@ -146,14 +163,20 @@ files:
146
163
  - lib/paperclip/matchers/validate_attachment_size_matcher.rb
147
164
  - lib/paperclip/matchers.rb
148
165
  - lib/paperclip/processor.rb
166
+ - lib/paperclip/railtie.rb
167
+ - lib/paperclip/storage/cloud_files.rb
168
+ - lib/paperclip/storage/filesystem.rb
169
+ - lib/paperclip/storage/s3.rb
149
170
  - lib/paperclip/storage.rb
150
171
  - lib/paperclip/style.rb
151
172
  - lib/paperclip/thumbnail.rb
152
173
  - lib/paperclip/upfile.rb
174
+ - lib/paperclip/version.rb
153
175
  - lib/paperclip.rb
154
- - tasks/paperclip_tasks.rake
176
+ - lib/tasks/paperclip.rake
155
177
  - test/attachment_test.rb
156
178
  - test/cloudfiles.yml
179
+ - test/command_line_test.rb
157
180
  - test/database.yml
158
181
  - test/fixtures/12k.png
159
182
  - test/fixtures/50x50.png
@@ -177,6 +200,10 @@ files:
177
200
  - test/style_test.rb
178
201
  - test/thumbnail_test.rb
179
202
  - test/upfile_test.rb
203
+ - rails/init.rb
204
+ - generators/paperclip/paperclip_generator.rb
205
+ - generators/paperclip/templates/paperclip_migration.rb.erb
206
+ - generators/paperclip/USAGE
180
207
  - shoulda_macros/paperclip.rb
181
208
  has_rdoc: true
182
209
  homepage: http://github.com/minter/paperclip
@@ -1,79 +0,0 @@
1
- def obtain_class
2
- class_name = ENV['CLASS'] || ENV['class']
3
- raise "Must specify CLASS" unless class_name
4
- @klass = Object.const_get(class_name)
5
- end
6
-
7
- def obtain_attachments
8
- name = ENV['ATTACHMENT'] || ENV['attachment']
9
- raise "Class #{@klass.name} has no attachments specified" unless @klass.respond_to?(:attachment_definitions)
10
- if !name.blank? && @klass.attachment_definitions.keys.include?(name)
11
- [ name ]
12
- else
13
- @klass.attachment_definitions.keys
14
- end
15
- end
16
-
17
- def for_all_attachments
18
- klass = obtain_class
19
- names = obtain_attachments
20
- ids = klass.connection.select_values(klass.send(:construct_finder_sql, :select => 'id'))
21
-
22
- ids.each do |id|
23
- instance = klass.find(id)
24
- names.each do |name|
25
- result = if instance.send("#{ name }?")
26
- yield(instance, name)
27
- else
28
- true
29
- end
30
- print result ? "." : "x"; $stdout.flush
31
- end
32
- end
33
- puts " Done."
34
- end
35
-
36
- namespace :paperclip do
37
- desc "Refreshes both metadata and thumbnails."
38
- task :refresh => ["paperclip:refresh:metadata", "paperclip:refresh:thumbnails"]
39
-
40
- namespace :refresh do
41
- desc "Regenerates thumbnails for a given CLASS (and optional ATTACHMENT)."
42
- task :thumbnails => :environment do
43
- errors = []
44
- for_all_attachments do |instance, name|
45
- result = instance.send(name).reprocess!
46
- errors << [instance.id, instance.errors] unless instance.errors.blank?
47
- result
48
- end
49
- errors.each{|e| puts "#{e.first}: #{e.last.full_messages.inspect}" }
50
- end
51
-
52
- desc "Regenerates content_type/size metadata for a given CLASS (and optional ATTACHMENT)."
53
- task :metadata => :environment do
54
- for_all_attachments do |instance, name|
55
- if file = instance.send(name).to_file
56
- instance.send("#{name}_file_name=", instance.send("#{name}_file_name").strip)
57
- instance.send("#{name}_content_type=", file.content_type.strip)
58
- instance.send("#{name}_file_size=", file.size) if instance.respond_to?("#{name}_file_size")
59
- instance.save(false)
60
- else
61
- true
62
- end
63
- end
64
- end
65
- end
66
-
67
- desc "Cleans out invalid attachments. Useful after you've added new validations."
68
- task :clean => :environment do
69
- for_all_attachments do |instance, name|
70
- instance.send(name).send(:validate)
71
- if instance.send(name).valid?
72
- true
73
- else
74
- instance.send("#{name}=", nil)
75
- instance.save
76
- end
77
- end
78
- end
79
- end