paperclip 2.4.5 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of paperclip might be problematic. Click here for more details.

Files changed (63) hide show
  1. data/.gitignore +22 -0
  2. data/.travis.yml +13 -0
  3. data/Appraisals +14 -0
  4. data/CONTRIBUTING.md +38 -0
  5. data/Gemfile +5 -0
  6. data/NEWS +23 -0
  7. data/README.md +72 -42
  8. data/Rakefile +1 -46
  9. data/cucumber/paperclip_steps.rb +6 -0
  10. data/features/basic_integration.feature +46 -0
  11. data/features/rake_tasks.feature +63 -0
  12. data/features/step_definitions/attachment_steps.rb +65 -0
  13. data/features/step_definitions/html_steps.rb +15 -0
  14. data/features/step_definitions/rails_steps.rb +182 -0
  15. data/features/step_definitions/s3_steps.rb +14 -0
  16. data/features/step_definitions/web_steps.rb +209 -0
  17. data/features/support/env.rb +8 -0
  18. data/features/support/fakeweb.rb +3 -0
  19. data/features/support/fixtures/.boot_config.rb.swo +0 -0
  20. data/features/support/fixtures/boot_config.txt +15 -0
  21. data/features/support/fixtures/gemfile.txt +5 -0
  22. data/features/support/fixtures/preinitializer.txt +20 -0
  23. data/features/support/paths.rb +28 -0
  24. data/features/support/rails.rb +46 -0
  25. data/features/support/selectors.rb +19 -0
  26. data/gemfiles/rails2.gemfile +9 -0
  27. data/gemfiles/rails3.gemfile +9 -0
  28. data/gemfiles/rails3_1.gemfile +9 -0
  29. data/lib/paperclip.rb +26 -19
  30. data/lib/paperclip/attachment.rb +123 -109
  31. data/lib/paperclip/interpolations.rb +7 -4
  32. data/lib/paperclip/matchers.rb +33 -2
  33. data/lib/paperclip/missing_attachment_styles.rb +1 -1
  34. data/lib/paperclip/railtie.rb +5 -0
  35. data/lib/paperclip/schema.rb +39 -0
  36. data/lib/paperclip/storage/fog.rb +21 -10
  37. data/lib/paperclip/storage/s3.rb +107 -40
  38. data/lib/paperclip/style.rb +13 -5
  39. data/lib/paperclip/url_generator.rb +64 -0
  40. data/lib/paperclip/version.rb +1 -1
  41. data/lib/tasks/paperclip.rake +1 -1
  42. data/paperclip.gemspec +41 -0
  43. data/test/.gitignore +1 -0
  44. data/test/attachment_test.rb +155 -168
  45. data/test/fixtures/question?mark.png +0 -0
  46. data/test/helper.rb +24 -1
  47. data/test/interpolations_test.rb +16 -2
  48. data/test/paperclip_missing_attachment_styles_test.rb +16 -0
  49. data/test/paperclip_test.rb +72 -22
  50. data/test/schema_test.rb +98 -0
  51. data/test/storage/filesystem_test.rb +2 -2
  52. data/test/{fog_test.rb → storage/fog_test.rb} +35 -8
  53. data/test/storage/s3_live_test.rb +63 -13
  54. data/test/storage/s3_test.rb +394 -91
  55. data/test/style_test.rb +50 -21
  56. data/test/support/mock_attachment.rb +22 -0
  57. data/test/support/mock_interpolator.rb +24 -0
  58. data/test/support/mock_model.rb +2 -0
  59. data/test/support/mock_url_generator_builder.rb +27 -0
  60. data/test/url_generator_test.rb +187 -0
  61. metadata +307 -125
  62. data/lib/paperclip/options.rb +0 -78
  63. data/test/options_test.rb +0 -75
@@ -1,78 +0,0 @@
1
- module Paperclip
2
- class Options
3
-
4
- attr_accessor :url, :path, :only_process, :normalized_styles, :default_url, :default_style,
5
- :storage, :use_timestamp, :whiny, :use_default_time_zone, :hash_digest, :hash_secret,
6
- :convert_options, :source_file_options, :preserve_files, :http_proxy
7
-
8
- attr_accessor :s3_credentials, :s3_host_name, :s3_options, :s3_permissions, :s3_protocol,
9
- :s3_headers, :s3_host_alias, :bucket
10
-
11
- attr_accessor :fog_directory, :fog_credentials, :fog_host, :fog_public, :fog_file
12
-
13
- def initialize(attachment, hash)
14
- @attachment = attachment
15
-
16
- @url = hash[:url]
17
- @url = @url.call(@attachment) if @url.is_a?(Proc)
18
- @path = hash[:path]
19
- @path = @path.call(@attachment) if @path.is_a?(Proc)
20
- @styles = hash[:styles]
21
- @only_process = hash[:only_process]
22
- @normalized_styles = nil
23
- @default_url = hash[:default_url]
24
- @default_style = hash[:default_style]
25
- @storage = hash[:storage]
26
- @use_timestamp = hash[:use_timestamp]
27
- @whiny = hash[:whiny_thumbnails] || hash[:whiny]
28
- @use_default_time_zone = hash[:use_default_time_zone]
29
- @hash_digest = hash[:hash_digest]
30
- @hash_data = hash[:hash_data]
31
- @hash_secret = hash[:hash_secret]
32
- @convert_options = hash[:convert_options]
33
- @source_file_options = hash[:source_file_options]
34
- @processors = hash[:processors]
35
- @preserve_files = hash[:preserve_files]
36
- @http_proxy = hash[:http_proxy]
37
-
38
- #s3 options
39
- @s3_credentials = hash[:s3_credentials]
40
- @s3_host_name = hash[:s3_host_name]
41
- @bucket = hash[:bucket]
42
- @s3_options = hash[:s3_options]
43
- @s3_permissions = hash[:s3_permissions]
44
- @s3_protocol = hash[:s3_protocol]
45
- @s3_headers = hash[:s3_headers]
46
- @s3_host_alias = hash[:s3_host_alias]
47
-
48
- #fog options
49
- @fog_directory = hash[:fog_directory]
50
- @fog_credentials = hash[:fog_credentials]
51
- @fog_host = hash[:fog_host]
52
- @fog_public = hash[:fog_public]
53
- @fog_file = hash[:fog_file]
54
- end
55
-
56
- def method_missing(method, *args, &blk)
57
- if method.to_s[-1,1] == "="
58
- instance_variable_set("@#{method[0..-2]}", args[0])
59
- else
60
- instance_variable_get("@#{method}")
61
- end
62
- end
63
-
64
- def processors
65
- @processors.respond_to?(:call) ? @processors.call(@attachment.instance) : @processors
66
- end
67
-
68
- def styles
69
- if @styles.respond_to?(:call) || !@normalized_styles
70
- @normalized_styles = ActiveSupport::OrderedHash.new
71
- (@styles.respond_to?(:call) ? @styles.call(@attachment) : @styles).each do |name, args|
72
- normalized_styles[name] = Paperclip::Style.new(name, args.dup, @attachment)
73
- end
74
- end
75
- @normalized_styles
76
- end
77
- end
78
- end
@@ -1,75 +0,0 @@
1
- # encoding: utf-8
2
- require './test/helper'
3
-
4
- class MockAttachment < Struct.new(:one, :two)
5
- def instance
6
- self
7
- end
8
- end
9
-
10
- class OptionsTest < Test::Unit::TestCase
11
- should "be able to set a value" do
12
- @options = Paperclip::Options.new(nil, {})
13
- assert_nil @options.path
14
- @options.path = "this/is/a/path"
15
- assert_equal "this/is/a/path", @options.path
16
- end
17
-
18
- context "#styles with a plain hash" do
19
- setup do
20
- @attachment = MockAttachment.new(nil, nil)
21
- @options = Paperclip::Options.new(@attachment,
22
- :styles => {
23
- :something => ["400x400", :png]
24
- })
25
- end
26
-
27
- should "return the right data for the style's geometry" do
28
- assert_equal "400x400", @options.styles[:something][:geometry]
29
- end
30
-
31
- should "return the right data for the style's format" do
32
- assert_equal :png, @options.styles[:something][:format]
33
- end
34
- end
35
-
36
- context "#styles is a proc" do
37
- setup do
38
- @attachment = MockAttachment.new("123x456", :doc)
39
- @options = Paperclip::Options.new(@attachment,
40
- :styles => lambda {|att|
41
- {:something => {:geometry => att.one, :format => att.two}}
42
- })
43
- end
44
-
45
- should "return the right data for the style's geometry" do
46
- assert_equal "123x456", @options.styles[:something][:geometry]
47
- end
48
-
49
- should "return the right data for the style's format" do
50
- assert_equal :doc, @options.styles[:something][:format]
51
- end
52
-
53
- should "run the proc each time, giving dynamic results" do
54
- assert_equal :doc, @options.styles[:something][:format]
55
- @attachment.two = :pdf
56
- assert_equal :pdf, @options.styles[:something][:format]
57
- end
58
- end
59
-
60
- context "#processors" do
61
- setup do
62
- @attachment = MockAttachment.new(nil, nil)
63
- end
64
- should "return processors if not a proc" do
65
- @options = Paperclip::Options.new(@attachment, :processors => [:one])
66
- assert_equal [:one], @options.processors
67
- end
68
- should "return processors if it is a proc" do
69
- @options = Paperclip::Options.new(@attachment, :processors => lambda{|att| [att.one]})
70
- assert_equal [nil], @options.processors
71
- @attachment.one = :other
72
- assert_equal [:other], @options.processors
73
- end
74
- end
75
- end