paperclip-removable 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+
2
+ Copyright (C) 2011 Dimitrij Denissenko
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining
5
+ a copy of this software and associated documentation files (the
6
+ "Software"), to deal in the Software without restriction, including
7
+ without limitation the rights to use, copy, modify, merge, publish,
8
+ distribute, sublicense, and/or sell copies of the Software, and to
9
+ permit persons to whom the Software is furnished to do so, subject to
10
+ the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,25 @@
1
+ = Paperclip removable plugin
2
+
3
+ Allows removal of previously uploaded files.
4
+
5
+ == Installation
6
+
7
+ Just add <tt>gem paperclip-removable</tt> to your Gemfile.
8
+
9
+ Alternatively, run <tt>sudo gem install paperclip-removable</tt> and add
10
+ <tt>require 'paperclip_removable'</tt> to your app.
11
+
12
+ == Example
13
+
14
+ In the model, you can specify:
15
+
16
+ class User < ActiveRecord::Base
17
+ has_attached_file :photo, :removable => true
18
+ attr_accessible :photo, :remove_photo
19
+ end
20
+
21
+ In the form you can then have:
22
+
23
+ = f.inputs do
24
+ = f.input :photo
25
+ = f.input :remove_photo, :as => :boolean if f.object.photo?
@@ -0,0 +1,46 @@
1
+ require 'paperclip'
2
+ require 'open-uri'
3
+
4
+ =begin
5
+ Allows removal of previously uploaded files. Example:
6
+
7
+ In the model, you can specify:
8
+
9
+ class User < ActiveRecord::Base
10
+ has_attached_file :photo, :removable => true
11
+ attr_accessible :photo, :remove_photo
12
+ end
13
+
14
+ In the form you can then have:
15
+
16
+ = f.inputs do
17
+ = f.input :photo
18
+ = f.input :remove_photo, :as => :boolean if f.object.photo?
19
+
20
+ =end
21
+ module Paperclip::Removable
22
+
23
+ def has_attached_file_with_removable(name, options = {})
24
+ has_attached_file_without_removable(name, options)
25
+
26
+ if attachment_definitions[name][:removable]
27
+ define_method(:"remove_#{name}") do
28
+ false
29
+ end
30
+
31
+ define_method(:"remove_#{name}=") do |value|
32
+ value = ActiveRecord::ConnectionAdapters::Column.value_to_boolean(value)
33
+ send(name).clear if value
34
+ value
35
+ end
36
+ end
37
+ end
38
+
39
+ end
40
+
41
+ module Paperclip::ClassMethods # :nodoc:
42
+ include Paperclip::Removable
43
+
44
+ alias_method :has_attached_file_without_removable, :has_attached_file
45
+ alias_method :has_attached_file, :has_attached_file_with_removable
46
+ end
@@ -0,0 +1 @@
1
+ require 'paperclip_removable'
@@ -0,0 +1 @@
1
+ require 'paperclip/removable'
data/rails/init.rb ADDED
@@ -0,0 +1 @@
1
+ require 'paperclip_removable'
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: paperclip-removable
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Dimitrij Denissenko
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-06-17 00:00:00 +01:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: paperclip
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 2
32
+ - 3
33
+ - 0
34
+ version: 2.3.0
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ description: Allows removal of previously uploaded files
38
+ email: dimitrij@blacksquaremedia.com
39
+ executables: []
40
+
41
+ extensions: []
42
+
43
+ extra_rdoc_files: []
44
+
45
+ files:
46
+ - LICENSE
47
+ - README.rdoc
48
+ - lib/paperclip_removable.rb
49
+ - lib/paperclip-removable.rb
50
+ - lib/paperclip/removable.rb
51
+ - rails/init.rb
52
+ has_rdoc: true
53
+ homepage: https://github.com/bsm/paperclip-removable
54
+ licenses: []
55
+
56
+ post_install_message:
57
+ rdoc_options: []
58
+
59
+ require_paths:
60
+ - lib
61
+ required_ruby_version: !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ hash: 57
67
+ segments:
68
+ - 1
69
+ - 8
70
+ - 7
71
+ version: 1.8.7
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ hash: 23
78
+ segments:
79
+ - 1
80
+ - 3
81
+ - 6
82
+ version: 1.3.6
83
+ requirements: []
84
+
85
+ rubyforge_project:
86
+ rubygems_version: 1.6.2
87
+ signing_key:
88
+ specification_version: 3
89
+ summary: Plugin for Paperclip
90
+ test_files: []
91
+