carrierwave-datamapper 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
20
20
  s.require_paths = ["lib"]
21
21
 
22
22
  s.add_dependency "dm-core", ["~> 1.0"]
23
- s.add_dependency "carrierwave"
23
+ s.add_dependency "carrierwave", ["~> 0.5.6"]
24
24
  s.add_development_dependency "rspec", ["~> 2.0"]
25
25
  s.add_development_dependency "dm-validations", ["~> 1.0"]
26
26
  s.add_development_dependency "dm-migrations", ["~> 1.0"]
@@ -1,6 +1,8 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require 'carrierwave'
3
4
  require 'dm-core'
5
+ require 'carrierwave/datamapper/property/uploader'
4
6
 
5
7
  module CarrierWave
6
8
  module DataMapper
@@ -11,14 +13,23 @@ module CarrierWave
11
13
  # See +CarrierWave::Mount#mount_uploader+ for documentation
12
14
  #
13
15
  def mount_uploader(column, uploader, options={}, &block)
16
+ if properties.named?(column)
17
+ warn "Defining property for an uploader is deprecated at #{caller[2]}"
18
+ properties.delete(properties[column])
19
+ end
20
+
21
+ property column, Property::Uploader
22
+
14
23
  super
15
24
 
16
- alias_method :read_uploader, :attribute_get
25
+ alias_method :read_uploader, :attribute_get
17
26
  alias_method :write_uploader, :attribute_set
18
- after :save, "store_#{column}!".to_sym
27
+
19
28
  pre_hook = ::DataMapper.const_defined?(:Validate) ? :valid? : :save
29
+
20
30
  before pre_hook, "write_#{column}_identifier".to_sym
21
- after :destroy, "remove_#{column}!".to_sym
31
+ after :save, "store_#{column}!".to_sym
32
+ after :destroy, "remove_#{column}!".to_sym
22
33
 
23
34
  # FIXME: Hack to work around Datamapper not triggering callbacks
24
35
  # for objects that are not dirty. By explicitly calling
@@ -39,4 +50,4 @@ module CarrierWave
39
50
  end # DataMapper
40
51
  end # CarrierWave
41
52
 
42
- DataMapper::Model.send(:include, CarrierWave::DataMapper)
53
+ DataMapper::Model.append_extensions(CarrierWave::DataMapper)
@@ -0,0 +1,19 @@
1
+ module CarrierWave
2
+ module DataMapper
3
+ module Property
4
+ class Uploader < ::DataMapper::Property::String
5
+ def custom?
6
+ true
7
+ end
8
+
9
+ def initialize(model, name, options = {})
10
+ if ::DataMapper.const_defined?(:Validate)
11
+ options[:auto_validation] = false
12
+ end
13
+
14
+ super
15
+ end
16
+ end
17
+ end # Property
18
+ end # DataMapper
19
+ end # CarrierWave
@@ -1,5 +1,5 @@
1
1
  module Carrierwave
2
2
  module Datamapper
3
- VERSION = "0.1.1"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
@@ -20,13 +20,6 @@ describe CarrierWave::DataMapper do
20
20
  storage_names[:default] = 'events'
21
21
 
22
22
  property :id, DataMapper::Property::Serial
23
-
24
- # auto validation off currently for inferred type
25
- # validation. issue is that validations are done on
26
- # the value returned by model#property_name which is overloaded
27
- # by carrierwave. pull request in @dm-more to remedy this.
28
- property :image, String, :auto_validation => false
29
-
30
23
  mount_uploader :image, uploader
31
24
  end
32
25
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: carrierwave-datamapper
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 1
9
- - 1
10
- version: 0.1.1
8
+ - 2
9
+ - 0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jonas Nicklas
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-05-19 00:00:00 -04:00
19
+ date: 2011-07-12 00:00:00 -05:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -40,12 +40,14 @@ dependencies:
40
40
  requirement: &id002 !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
- - - ">="
43
+ - - ~>
44
44
  - !ruby/object:Gem::Version
45
- hash: 3
45
+ hash: 7
46
46
  segments:
47
47
  - 0
48
- version: "0"
48
+ - 5
49
+ - 6
50
+ version: 0.5.6
49
51
  type: :runtime
50
52
  version_requirements: *id002
51
53
  - !ruby/object:Gem::Dependency
@@ -124,6 +126,7 @@ files:
124
126
  - Rakefile
125
127
  - carrierwave-datamapper.gemspec
126
128
  - lib/carrierwave/datamapper.rb
129
+ - lib/carrierwave/datamapper/property/uploader.rb
127
130
  - lib/carrierwave/datamapper/version.rb
128
131
  - spec/datamapper_spec.rb
129
132
  - spec/fixtures/test.jpeg