carrierwave 0.3.1 → 0.3.2

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

Potentially problematic release.


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

Files changed (52) hide show
  1. data/Rakefile +1 -1
  2. data/lib/carrierwave.rb +3 -0
  3. data/lib/carrierwave/compatibility/paperclip.rb +2 -0
  4. data/lib/carrierwave/core_ext/blank.rb +46 -0
  5. data/lib/carrierwave/core_ext/inheritable_attributes.rb +2 -0
  6. data/lib/carrierwave/core_ext/module_setup.rb +2 -0
  7. data/lib/carrierwave/mount.rb +2 -0
  8. data/lib/carrierwave/orm/activerecord.rb +2 -0
  9. data/lib/carrierwave/orm/datamapper.rb +2 -0
  10. data/lib/carrierwave/orm/sequel.rb +37 -12
  11. data/lib/carrierwave/processing/image_science.rb +2 -0
  12. data/lib/carrierwave/processing/rmagick.rb +2 -0
  13. data/lib/carrierwave/sanitized_file.rb +4 -0
  14. data/lib/carrierwave/storage/abstract.rb +2 -0
  15. data/lib/carrierwave/storage/file.rb +2 -0
  16. data/lib/carrierwave/storage/s3.rb +28 -5
  17. data/lib/carrierwave/test/matchers.rb +2 -0
  18. data/lib/carrierwave/uploader.rb +2 -0
  19. data/lib/carrierwave/uploader/cache.rb +2 -0
  20. data/lib/carrierwave/uploader/callbacks.rb +2 -0
  21. data/lib/carrierwave/uploader/default_path.rb +2 -0
  22. data/lib/carrierwave/uploader/extension_whitelist.rb +2 -0
  23. data/lib/carrierwave/uploader/mountable.rb +2 -0
  24. data/lib/carrierwave/uploader/paths.rb +2 -0
  25. data/lib/carrierwave/uploader/processing.rb +2 -0
  26. data/lib/carrierwave/uploader/proxy.rb +2 -0
  27. data/lib/carrierwave/uploader/remove.rb +2 -0
  28. data/lib/carrierwave/uploader/store.rb +2 -0
  29. data/lib/carrierwave/uploader/url.rb +2 -0
  30. data/lib/carrierwave/uploader/versions.rb +2 -0
  31. data/lib/generators/uploader_generator.rb +2 -0
  32. data/rails_generators/uploader/templates/uploader.rb +2 -0
  33. data/rails_generators/uploader/uploader_generator.rb +2 -0
  34. data/spec/compatibility/paperclip_spec.rb +2 -0
  35. data/spec/mount_spec.rb +2 -0
  36. data/spec/orm/activerecord_spec.rb +5 -3
  37. data/spec/orm/datamapper_spec.rb +5 -3
  38. data/spec/orm/sequel_spec.rb +8 -4
  39. data/spec/sanitized_file_spec.rb +2 -0
  40. data/spec/spec_helper.rb +4 -2
  41. data/spec/uploader/cache_spec.rb +2 -0
  42. data/spec/uploader/default_path_spec.rb +2 -0
  43. data/spec/uploader/extension_whitelist_spec.rb +2 -0
  44. data/spec/uploader/mountable_spec.rb +2 -0
  45. data/spec/uploader/paths_spec.rb +2 -0
  46. data/spec/uploader/processing_spec.rb +2 -0
  47. data/spec/uploader/proxy_spec.rb +2 -0
  48. data/spec/uploader/remove_spec.rb +2 -0
  49. data/spec/uploader/store_spec.rb +2 -0
  50. data/spec/uploader/url_spec.rb +2 -0
  51. data/spec/uploader/versions_spec.rb +2 -0
  52. metadata +3 -2
data/Rakefile CHANGED
@@ -13,7 +13,7 @@ require 'spec/rake/verify_rcov'
13
13
  require 'cucumber/rake/task'
14
14
 
15
15
  NAME = "carrierwave"
16
- GEM_VERSION = "0.3.1"
16
+ GEM_VERSION = "0.3.2"
17
17
  AUTHOR = "Jonas Nicklas"
18
18
  EMAIL = "jonas.nicklas@gmail.com"
19
19
  HOMEPAGE = "http://www.example.com"
data/lib/carrierwave.rb CHANGED
@@ -1,4 +1,7 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'fileutils'
4
+ require 'carrierwave/core_ext/blank'
2
5
  require 'carrierwave/core_ext/module_setup'
3
6
  require 'carrierwave/core_ext/inheritable_attributes'
4
7
 
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module CarrierWave
2
4
  module Compatibility
3
5
 
@@ -0,0 +1,46 @@
1
+ # encoding: utf-8
2
+
3
+ unless "".respond_to?(:blank?)
4
+ # blank? methods for several different class types
5
+ class Object
6
+ # Returns true if the object is nil or empty (if applicable)
7
+ def blank?
8
+ nil? || (respond_to?(:empty?) && empty?)
9
+ end
10
+ end # class Object
11
+
12
+ class Numeric
13
+ # Numerics can't be blank
14
+ def blank?
15
+ false
16
+ end
17
+ end # class Numeric
18
+
19
+ class NilClass
20
+ # Nils are always blank
21
+ def blank?
22
+ true
23
+ end
24
+ end # class NilClass
25
+
26
+ class TrueClass
27
+ # True is not blank.
28
+ def blank?
29
+ false
30
+ end
31
+ end # class TrueClass
32
+
33
+ class FalseClass
34
+ # False is always blank.
35
+ def blank?
36
+ true
37
+ end
38
+ end # class FalseClass
39
+
40
+ class String
41
+ # Strips out whitespace then tests if the string is empty.
42
+ def blank?
43
+ strip.empty?
44
+ end
45
+ end # class String
46
+ end
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  # Stolen from Rails 3
2
4
 
3
5
  # Copyright (c) 2005-2009 David Heinemeier Hansson
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  # Stolen from Rails 3
2
4
 
3
5
  # Copyright (c) 2005-2009 David Heinemeier Hansson
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module CarrierWave
2
4
 
3
5
  ##
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'activerecord'
2
4
 
3
5
  module CarrierWave
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'dm-core'
2
4
 
3
5
  module CarrierWave
@@ -1,21 +1,27 @@
1
- require 'sequel'
1
+ # encoding: utf-8
2
2
 
3
+ require 'sequel'
4
+
3
5
  module CarrierWave
4
6
  module Sequel
5
-
6
7
  include CarrierWave::Mount
7
-
8
+
8
9
  def mount_uploader(column, uploader)
9
10
  super
10
-
11
+
11
12
  alias_method :read_uploader, :[]
12
13
  alias_method :write_uploader, :[]=
13
-
14
- after_save "store_#{column}!"
15
- before_save "write_#{column}_identifier"
16
- before_destroy "remove_#{column}!"
14
+
15
+ if CarrierWave::Sequel.new_sequel?
16
+ include CarrierWave::Sequel::Hooks
17
+ include CarrierWave::Sequel::Validations
18
+ else
19
+ after_save "store_#{column}!"
20
+ before_save "write_#{column}_identifier"
21
+ before_destroy "remove_#{column}!"
22
+ end
17
23
  end
18
-
24
+
19
25
  # Determine if we're using Sequel > 2.12
20
26
  #
21
27
  # ==== Returns
@@ -23,10 +29,29 @@ module CarrierWave
23
29
  def self.new_sequel?
24
30
  ::Sequel::Model.respond_to?(:plugin)
25
31
  end
26
-
27
32
  end # Sequel
28
33
  end # CarrierWave
34
+
35
+ # Instance hook methods for the Sequel 3.x
36
+ module CarrierWave::Sequel::Hooks
37
+ def after_save
38
+ return false if super == false
39
+ self.class.uploaders.each_key {|column| self.send("store_#{column}!") }
40
+ end
41
+
42
+ def before_save
43
+ return false if super == false
44
+ self.class.uploaders.each_key {|column| self.send("write_#{column}_identifier") }
45
+ end
46
+
47
+ def before_destroy
48
+ return false if super == false
49
+ self.class.uploaders.each_key {|column| self.send("remove_#{column}!") }
50
+ end
51
+ end
52
+
53
+ # Instance validation methods for the Sequel 3.x
54
+ module CarrierWave::Sequel::Validations
55
+ end
29
56
 
30
- # Sequel 3.x.x removed class hook methods and moved them to the plugin
31
- Sequel::Model.plugin(:hook_class_methods) if CarrierWave::Sequel.new_sequel?
32
57
  Sequel::Model.send(:extend, CarrierWave::Sequel)
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require "image_science"
2
4
 
3
5
  module CarrierWave
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  begin
2
4
  require 'rmagick'
3
5
  rescue LoadError
@@ -1,3 +1,7 @@
1
+ # encoding: utf-8
2
+
3
+ require 'pathname'
4
+
1
5
  module CarrierWave
2
6
 
3
7
  ##
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module CarrierWave
2
4
  module Storage
3
5
 
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module CarrierWave
2
4
  module Storage
3
5
 
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module CarrierWave
2
4
  module Storage
3
5
 
@@ -87,20 +89,41 @@ module CarrierWave
87
89
  ["http://s3.amazonaws.com", bucket, @path].compact.join('/')
88
90
  end
89
91
 
90
- def respond_to?(*args)
91
- super || s3_object.respond_to?(*args)
92
+ def about
93
+ s3_object.about
92
94
  end
93
95
 
94
- private
96
+ def metadata
97
+ s3_object.metadata
98
+ end
99
+
100
+ def content_type
101
+ s3_object.content_type
102
+ end
103
+
104
+ def content_type=(new_content_type)
105
+ s3_object.content_type = new_content_type
106
+ end
95
107
 
96
- def method_missing(*args, &block)
97
- s3_object.send(*args, &block)
108
+ def content_disposition
109
+ s3_object.content_disposition
110
+ end
111
+
112
+ def content_disposition=(new_disposition)
113
+ s3_object.content_disposition = new_disposition
114
+ end
115
+
116
+ def store
117
+ s3_object.store
98
118
  end
99
119
 
100
120
  def s3_object
101
121
  @s3_object ||= AWS::S3::S3Object.find(@path, bucket)
102
122
  end
103
123
 
124
+
125
+ private
126
+
104
127
  def bucket
105
128
  CarrierWave::Storage::S3.bucket
106
129
  end
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module CarrierWave
2
4
  module Test
3
5
 
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module CarrierWave
2
4
 
3
5
  ##
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module CarrierWave
2
4
  module Uploader
3
5
  module Cache
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module CarrierWave
2
4
  module Uploader
3
5
  module Callbacks
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module CarrierWave
2
4
  module Uploader
3
5
  module DefaultPath
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module CarrierWave
2
4
  module Uploader
3
5
  module ExtensionWhitelist
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module CarrierWave
2
4
  module Uploader
3
5
  module Mountable
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module CarrierWave
2
4
  module Uploader
3
5
  module Paths
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module CarrierWave
2
4
  module Uploader
3
5
  module Processing
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module CarrierWave
2
4
  module Uploader
3
5
  module Proxy
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module CarrierWave
2
4
  module Uploader
3
5
  module Remove
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module CarrierWave
2
4
  module Uploader
3
5
  module Store
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module CarrierWave
2
4
  module Uploader
3
5
  module Url
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module CarrierWave
2
4
  module Uploader
3
5
  module Versions
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module Merb
2
4
  module Generators
3
5
  class UploaderGenerator < NamedGenerator
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  class <%= class_name %>Uploader < CarrierWave::Uploader::Base
2
4
 
3
5
  # Include RMagick or ImageScience support
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  class UploaderGenerator < Rails::Generator::NamedBase
2
4
 
3
5
  def manifest
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require File.dirname(__FILE__) + '/../spec_helper'
2
4
 
3
5
  require 'carrierwave/orm/activerecord'
data/spec/mount_spec.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require File.dirname(__FILE__) + '/spec_helper'
2
4
 
3
5
  describe CarrierWave::Mount do
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require File.dirname(__FILE__) + '/../spec_helper'
2
4
 
3
5
  require 'carrierwave/orm/activerecord'
@@ -52,11 +54,11 @@ describe CarrierWave::ActiveRecord do
52
54
 
53
55
  describe '#image' do
54
56
 
55
- it "should return nil when nothing has been assigned" do
57
+ it "should return blank uploader when nothing has been assigned" do
56
58
  @event.image.should be_blank
57
59
  end
58
60
 
59
- it "should return nil when an empty string has been assigned" do
61
+ it "should return blank uploader when an empty string has been assigned" do
60
62
  @event[:image] = ''
61
63
  @event.save
62
64
  @event.reload
@@ -266,4 +268,4 @@ describe CarrierWave::ActiveRecord do
266
268
 
267
269
  end
268
270
 
269
- end
271
+ end
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require File.dirname(__FILE__) + '/../spec_helper'
2
4
 
3
5
  require 'carrierwave/orm/datamapper'
@@ -30,11 +32,11 @@ describe CarrierWave::DataMapper do
30
32
 
31
33
  describe '#image' do
32
34
 
33
- it "should return nil when nothing has been assigned" do
35
+ it "should return blank uploader when nothing has been assigned" do
34
36
  @event.image.should be_blank
35
37
  end
36
38
 
37
- it "should return nil when an empty string has been assigned" do
39
+ it "should return blank uploader when an empty string has been assigned" do
38
40
  repository(:default).adapter.query("INSERT INTO events (image) VALUES ('')")
39
41
  @event = @class.first
40
42
 
@@ -156,4 +158,4 @@ describe CarrierWave::DataMapper do
156
158
 
157
159
  end
158
160
 
159
- end
161
+ end
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require File.dirname(__FILE__) + '/../spec_helper'
2
4
 
3
5
  require 'carrierwave/orm/sequel'
@@ -27,19 +29,21 @@ describe CarrierWave::Sequel do
27
29
  DB.drop_table :events
28
30
  end
29
31
 
30
- before do
32
+ before(:each) do
31
33
  @class = Class.new(Sequel::Model)
32
34
  @class.set_dataset :events
33
35
  @class, @uploader, @event = setup_variables_for_class(@class)
34
36
  end
37
+
38
+ after(:each) { @class.delete }
35
39
 
36
40
  describe '#image' do
37
41
 
38
- it "should return nil when nothing has been assigned" do
42
+ it "should return blank uploader when nothing has been assigned" do
39
43
  @event.image.should be_blank
40
44
  end
41
45
 
42
- it "should return nil when an empty string has been assigned" do
46
+ it "should return blank uploader when an empty string has been assigned" do
43
47
  @event[:image] = ''
44
48
  @event.save
45
49
  @event.reload
@@ -87,7 +91,7 @@ describe CarrierWave::Sequel do
87
91
  @event.image = ''
88
92
  @event.image.should be_blank
89
93
  end
90
-
94
+
91
95
  end
92
96
 
93
97
  describe '#save' do
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require File.dirname(__FILE__) + '/spec_helper'
2
4
 
3
5
  describe CarrierWave::SanitizedFile do
data/spec/spec_helper.rb CHANGED
@@ -1,12 +1,14 @@
1
+ # encoding: utf-8
2
+
1
3
  $TESTING=true
2
- $:.push File.join(File.dirname(__FILE__), '..', 'lib')
4
+ $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
3
5
 
4
6
  require 'rubygems'
5
7
 
6
8
  if ENV["AS"]
7
9
  puts "--> using ActiveSupport"
8
10
  require 'activesupport'
9
- else
11
+ elsif ENV["EXTLIB"]
10
12
  puts "--> using Extlib"
11
13
  require 'extlib'
12
14
  end
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require File.dirname(__FILE__) + '/../spec_helper'
2
4
 
3
5
  describe CarrierWave::Uploader do
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require File.dirname(__FILE__) + '/../spec_helper'
2
4
 
3
5
  describe CarrierWave::Uploader do
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require File.dirname(__FILE__) + '/../spec_helper'
2
4
 
3
5
  describe CarrierWave::Uploader do
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require File.dirname(__FILE__) + '/../spec_helper'
2
4
 
3
5
  describe CarrierWave::Uploader do
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require File.dirname(__FILE__) + '/../spec_helper'
2
4
 
3
5
  describe CarrierWave::Uploader do
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require File.dirname(__FILE__) + '/../spec_helper'
2
4
 
3
5
  describe CarrierWave::Uploader do
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require File.dirname(__FILE__) + '/../spec_helper'
2
4
 
3
5
  describe CarrierWave::Uploader do
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require File.dirname(__FILE__) + '/../spec_helper'
2
4
 
3
5
  describe CarrierWave::Uploader do
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require File.dirname(__FILE__) + '/../spec_helper'
2
4
 
3
5
  describe CarrierWave::Uploader do
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require File.dirname(__FILE__) + '/../spec_helper'
2
4
 
3
5
  describe CarrierWave::Uploader do
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require File.dirname(__FILE__) + '/../spec_helper'
2
4
 
3
5
  describe CarrierWave::Uploader do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: carrierwave
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonas Nicklas
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-07-01 00:00:00 +02:00
12
+ date: 2009-07-18 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -30,6 +30,7 @@ files:
30
30
  - Rakefile
31
31
  - TODO
32
32
  - lib/carrierwave/compatibility/paperclip.rb
33
+ - lib/carrierwave/core_ext/blank.rb
33
34
  - lib/carrierwave/core_ext/inheritable_attributes.rb
34
35
  - lib/carrierwave/core_ext/module_setup.rb
35
36
  - lib/carrierwave/mount.rb