ripta-dm-paperclip 2.5.1 → 2.6.1

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.
data/README.markdown CHANGED
@@ -1,6 +1,10 @@
1
1
  # DataMapper Paperclip
2
2
 
3
- **Compatibility note:** dm-paperclip 2.5.0 requires datamapper (dm-core) 1.0, while dm-paperclip 2.5.1 requires dm-core 1.1.
3
+ **Compatibility note:**
4
+
5
+ * dm-paperclip v2.5.0 requires datamapper (dm-core) v1.0
6
+ * dm-paperclip v2.5.1 requires dm-core v1.1
7
+ * dm-paperclip v2.6.x requires dm-core v1.2; it was tested on ruby 1.9.3
4
8
 
5
9
  dm-paperclip is a port of Thoughtbot's Paperclip plugin to work with DataMapper. This plugin is fully compatible with
6
10
  the original ActiveRecord-oriented Paperclip. You could take an existing ActiveRecord database and use it with DataMapper.
@@ -42,6 +42,7 @@ module Paperclip
42
42
  class Tempfile < ::Tempfile
43
43
  # Replaces Tempfile's +make_tmpname+ with one that honors file extensions.
44
44
  def make_tmpname(basename, n)
45
+ n ||= 0
45
46
  extension = File.extname(basename)
46
47
  sprintf("%s,%d,%d%s", File.basename(basename, extension), $$, n, extension)
47
48
  end
@@ -10,19 +10,17 @@ module Paperclip
10
10
  # * +greater_than+: equivalent to :in => options[:greater_than]..Infinity
11
11
  # * +message+: error message to display, use :min and :max as replacements
12
12
  def validates_attachment_size(*fields)
13
- opts = opts_from_validator_args(fields)
14
- add_validator_to_context(opts, fields, Paperclip::Validate::SizeValidator)
13
+ validators.add(Paperclip::Validate::SizeValidator, *fields)
15
14
  end
16
15
 
17
16
  # Adds errors if thumbnail creation fails. The same as specifying :whiny_thumbnails => true.
18
- def validates_attachment_thumbnails name, options = {}
17
+ def validates_attachment_thumbnails(name, options = {})
19
18
  self.attachment_definitions[name][:whiny_thumbnails] = true
20
19
  end
21
20
 
22
21
  # Places ActiveRecord-style validations on the presence of a file.
23
22
  def validates_attachment_presence(*fields)
24
- opts = opts_from_validator_args(fields)
25
- add_validator_to_context(opts, fields, Paperclip::Validate::RequiredFieldValidator)
23
+ validators.add(Paperclip::Validate::RequiredFieldValidator, *fields)
26
24
  end
27
25
 
28
26
  # Places ActiveRecord-style validations on the content type of the file assigned. The
@@ -30,18 +28,12 @@ module Paperclip
30
28
  # * +content_type+: Allowed content types. Can be a single content type or an array. Allows all by default.
31
29
  # * +message+: The message to display when the uploaded file has an invalid content type.
32
30
  def validates_attachment_content_type(*fields)
33
- opts = opts_from_validator_args(fields)
34
- add_validator_to_context(opts, fields, Paperclip::Validate::ContentTypeValidator)
31
+ validators.add(Paperclip::Validate::ContentTypeValidator, *fields)
35
32
  end
36
33
 
37
34
  end
38
35
 
39
36
  class SizeValidator < DataMapper::Validate::GenericValidator #:nodoc:
40
- def initialize(field_name, options={})
41
- super
42
- @field_name, @options = field_name, options
43
- end
44
-
45
37
  def call(target)
46
38
  field_value = target.validation_property_value(:"#{@field_name}_file_size")
47
39
  return true if field_value.nil?
@@ -60,11 +52,6 @@ module Paperclip
60
52
  end
61
53
 
62
54
  class RequiredFieldValidator < DataMapper::Validate::GenericValidator #:nodoc:
63
- def initialize(field_name, options={})
64
- super
65
- @field_name, @options = field_name, options
66
- end
67
-
68
55
  def call(target)
69
56
  field_value = target.validation_property_value(@field_name)
70
57
  if field_value.nil? || field_value.original_filename.blank?
@@ -77,11 +64,6 @@ module Paperclip
77
64
  end
78
65
 
79
66
  class ContentTypeValidator < DataMapper::Validate::GenericValidator #:nodoc:
80
- def initialize(field_name, options={})
81
- super
82
- @field_name, @options = field_name, options
83
- end
84
-
85
67
  def call(target)
86
68
  valid_types = [@options[:content_type]].flatten
87
69
  field_value = target.validation_property_value(@field_name)
@@ -103,11 +85,6 @@ module Paperclip
103
85
  end
104
86
 
105
87
  class CopyAttachmentErrors < DataMapper::Validate::GenericValidator #:nodoc:
106
- def initialize(field_name, options={})
107
- super
108
- @field_name, @options = field_name, options
109
- end
110
-
111
88
  def call(target)
112
89
  field_value = target.validation_property_value(@field_name)
113
90
  unless field_value.nil? || field_value.original_filename.blank?
data/lib/dm-paperclip.rb CHANGED
@@ -43,7 +43,7 @@ require 'dm-paperclip/attachment'
43
43
  # documentation for Paperclip::ClassMethods for more useful information.
44
44
  module Paperclip
45
45
 
46
- VERSION = "2.5.1"
46
+ VERSION = "2.6.1"
47
47
 
48
48
  # To configure Paperclip, put this code in an initializer, Rake task, or wherever:
49
49
  #
@@ -326,7 +326,7 @@ module Paperclip
326
326
  end
327
327
 
328
328
  if Paperclip.config.use_dm_validations
329
- add_validator_to_context(opts_from_validator_args([name]), [name], Paperclip::Validate::CopyAttachmentErrors)
329
+ validators.add(Paperclip::Validate::CopyAttachmentErrors, name)
330
330
  end
331
331
 
332
332
  end
@@ -1,4 +1,4 @@
1
- require 'test/helper'
1
+ require File.dirname(__FILE__) + '/helper'
2
2
 
3
3
  class Dummy
4
4
  # This is a dummy class
@@ -1,4 +1,4 @@
1
- require 'test/helper.rb'
1
+ require File.dirname(__FILE__) + '/helper'
2
2
 
3
3
  class IntegrationTest < Test::Unit::TestCase
4
4
  context "Many models at once" do
@@ -1,4 +1,4 @@
1
- require 'test/helper'
1
+ require File.dirname(__FILE__) + '/helper'
2
2
 
3
3
  class IOStreamTest < Test::Unit::TestCase
4
4
  context "IOStream" do
@@ -1,4 +1,4 @@
1
- require 'test/helper.rb'
1
+ require File.dirname(__FILE__) + '/helper'
2
2
 
3
3
  class PaperclipTest < Test::Unit::TestCase
4
4
  context "A DataMapper model with an 'avatar' attachment" do
data/test/storage_test.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'test/helper'
1
+ require File.dirname(__FILE__) + '/helper'
2
2
  require 'aws/s3'
3
3
 
4
4
  class StorageTest < Test::Unit::TestCase
metadata CHANGED
@@ -1,33 +1,90 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: ripta-dm-paperclip
3
- version: !ruby/object:Gem::Version
4
- hash: 25
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.6.1
5
5
  prerelease:
6
- segments:
7
- - 2
8
- - 5
9
- - 1
10
- version: 2.5.1
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Ken Robertson
9
+ - Ripta Pasay
14
10
  autorequire:
15
11
  bindir: bin
16
12
  cert_chain: []
17
-
18
- date: 2011-04-06 00:00:00 -04:00
19
- default_executable:
20
- dependencies: []
21
-
13
+ date: 2012-03-21 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: dm-core
17
+ requirement: !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ~>
21
+ - !ruby/object:Gem::Version
22
+ version: 1.2.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ~>
29
+ - !ruby/object:Gem::Version
30
+ version: 1.2.0
31
+ - !ruby/object:Gem::Dependency
32
+ name: shoulda
33
+ requirement: !ruby/object:Gem::Requirement
34
+ none: false
35
+ requirements:
36
+ - - ! '>='
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ type: :development
40
+ prerelease: false
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: mocha
49
+ requirement: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: 0.9.8
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - '='
61
+ - !ruby/object:Gem::Version
62
+ version: 0.9.8
63
+ - !ruby/object:Gem::Dependency
64
+ name: aws-s3
65
+ requirement: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ type: :development
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
22
79
  description:
23
- email: ken@invalidlogic.com
80
+ email:
81
+ - ken@invalidlogic.com
82
+ - github@r8y.org
24
83
  executables: []
25
-
26
84
  extensions: []
27
-
28
- extra_rdoc_files:
85
+ extra_rdoc_files:
29
86
  - README.markdown
30
- files:
87
+ files:
31
88
  - README.markdown
32
89
  - LICENSE
33
90
  - Rakefile
@@ -49,7 +106,6 @@ files:
49
106
  - test/fixtures/50x50.png
50
107
  - test/fixtures/5k.png
51
108
  - test/fixtures/bad.png
52
- - test/fixtures/s3.yml
53
109
  - test/fixtures/text.txt
54
110
  - test/geometry_test.rb
55
111
  - test/helper.rb
@@ -58,41 +114,33 @@ files:
58
114
  - test/paperclip_test.rb
59
115
  - test/storage_test.rb
60
116
  - test/thumbnail_test.rb
61
- has_rdoc: true
62
- homepage: http://invalidlogic.com/dm-paperclip/
117
+ homepage: http://github.com/ripta/dm-paperclip
63
118
  licenses: []
64
-
65
119
  post_install_message:
66
- rdoc_options:
120
+ rdoc_options:
67
121
  - --line-numbers
68
122
  - --inline-source
69
- require_paths:
123
+ require_paths:
70
124
  - lib
71
- required_ruby_version: !ruby/object:Gem::Requirement
125
+ required_ruby_version: !ruby/object:Gem::Requirement
72
126
  none: false
73
- requirements:
74
- - - ">="
75
- - !ruby/object:Gem::Version
76
- hash: 3
77
- segments:
78
- - 0
79
- version: "0"
80
- required_rubygems_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ! '>='
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
132
  none: false
82
- requirements:
83
- - - ">="
84
- - !ruby/object:Gem::Version
85
- hash: 3
86
- segments:
87
- - 0
88
- version: "0"
89
- requirements:
133
+ requirements:
134
+ - - ! '>='
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ requirements:
90
138
  - ImageMagick
91
- - data_mapper
92
139
  rubyforge_project: dm-paperclip
93
- rubygems_version: 1.6.2
140
+ rubygems_version: 1.8.18
94
141
  signing_key:
95
142
  specification_version: 3
96
- summary: File attachments as attributes for DataMapper, based on the original Paperclip by Jon Yurek at Thoughtbot
143
+ summary: File attachments as attributes for DataMapper 1.1, based on the original
144
+ Paperclip by Jon Yurek at Thoughtbot; updated for ruby 1.9 and rails 3.2
97
145
  test_files: []
98
-
146
+ has_rdoc:
data/test/fixtures/s3.yml DELETED
@@ -1,8 +0,0 @@
1
- development:
2
- key: 54321
3
- production:
4
- key: 12345
5
- test:
6
- bucket: <%= ENV['S3_BUCKET'] %>
7
- access_key_id: <%= ENV['S3_KEY'] %>
8
- secret_access_key: <%= ENV['S3_SECRET'] %>