summaryrefslogtreecommitdiff
path: root/vendor/plugins/paperclip/tasks
diff options
context:
space:
mode:
authorerdgeist <erdgeist@erdgeist.org>2026-06-24 04:13:16 +0200
committererdgeist <erdgeist@erdgeist.org>2026-06-24 04:13:16 +0200
commite0a7e0fec760ba12c8067a37e10c96f1f05876e2 (patch)
treed0cf745592a46aee4d4913911fd34c7c24515220 /vendor/plugins/paperclip/tasks
parent6424e10be5a89f175a74c71c55660412a169b8b8 (diff)
Stage 1 complete: Rails 2.3.5 to Rails 3.2.22.5 upgrade
- Converted plugins to gems (Gemfile) - Updated config structure (application.rb, boot.rb, environment.rb) - Converted routes to Rails 3 DSL - Converted named_scope to scope throughout models - Converted find(:all, :conditions) to where() chains - Fixed has_many :order to use ordering scope - Updated session store and secret token configuration - Fixed exception_notification middleware configuration - Patched Ruby 2.4 / Rails 3.2 incompatibilities: - Integer/Float duration arithmetic (ActiveSupport) - Arel visit_Integer for PostgreSQL adapter - create_database String/Integer coercion - ActionController consider_all_requests_local - Migrated taggings schema for acts-as-taggable-on - Replaced dynamic_form gem with custom form_error_messages helper - Fixed Rails 3 block helper syntax (form_for, form_tag, fields_for) - Fixed admin layout yield - Updated test suite for Rails 3 APIs
Diffstat (limited to 'vendor/plugins/paperclip/tasks')
-rw-r--r--vendor/plugins/paperclip/tasks/paperclip_tasks.rake79
1 files changed, 0 insertions, 79 deletions
diff --git a/vendor/plugins/paperclip/tasks/paperclip_tasks.rake b/vendor/plugins/paperclip/tasks/paperclip_tasks.rake
deleted file mode 100644
index 23e4c11a..00000000
--- a/vendor/plugins/paperclip/tasks/paperclip_tasks.rake
+++ /dev/null
@@ -1,79 +0,0 @@
1def obtain_class
2 class_name = ENV['CLASS'] || ENV['class']
3 raise "Must specify CLASS" unless class_name
4 @klass = Object.const_get(class_name)
5end
6
7def obtain_attachments
8 name = ENV['ATTACHMENT'] || ENV['attachment']
9 raise "Class #{@klass.name} has no attachments specified" unless @klass.respond_to?(:attachment_definitions)
10 if !name.blank? && @klass.attachment_definitions.keys.include?(name)
11 [ name ]
12 else
13 @klass.attachment_definitions.keys
14 end
15end
16
17def for_all_attachments
18 klass = obtain_class
19 names = obtain_attachments
20 ids = klass.connection.select_values(klass.send(:construct_finder_sql, :select => 'id'))
21
22 ids.each do |id|
23 instance = klass.find(id)
24 names.each do |name|
25 result = if instance.send("#{ name }?")
26 yield(instance, name)
27 else
28 true
29 end
30 print result ? "." : "x"; $stdout.flush
31 end
32 end
33 puts " Done."
34end
35
36namespace :paperclip do
37 desc "Refreshes both metadata and thumbnails."
38 task :refresh => ["paperclip:refresh:metadata", "paperclip:refresh:thumbnails"]
39
40 namespace :refresh do
41 desc "Regenerates thumbnails for a given CLASS (and optional ATTACHMENT)."
42 task :thumbnails => :environment do
43 errors = []
44 for_all_attachments do |instance, name|
45 result = instance.send(name).reprocess!
46 errors << [instance.id, instance.errors] unless instance.errors.blank?
47 result
48 end
49 errors.each{|e| puts "#{e.first}: #{e.last.full_messages.inspect}" }
50 end
51
52 desc "Regenerates content_type/size metadata for a given CLASS (and optional ATTACHMENT)."
53 task :metadata => :environment do
54 for_all_attachments do |instance, name|
55 if file = instance.send(name).to_file
56 instance.send("#{name}_file_name=", instance.send("#{name}_file_name").strip)
57 instance.send("#{name}_content_type=", file.content_type.strip)
58 instance.send("#{name}_file_size=", file.size) if instance.respond_to?("#{name}_file_size")
59 instance.save(false)
60 else
61 true
62 end
63 end
64 end
65 end
66
67 desc "Cleans out invalid attachments. Useful after you've added new validations."
68 task :clean => :environment do
69 for_all_attachments do |instance, name|
70 instance.send(name).send(:validate)
71 if instance.send(name).valid?
72 true
73 else
74 instance.send("#{name}=", nil)
75 instance.save
76 end
77 end
78 end
79end