BBenezech-papermill 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.2.2
@@ -45,7 +45,7 @@ module Papermill
45
45
  :button_image_url => '/images/papermill/upload-blank.png',
46
46
  :button_width => 61,
47
47
  :button_height => 22,
48
- # Wording and CSS processed through an Adobe Flash styler. Result is terrible. Feel free to put a CSS button overlayed directly on the SWF button. See swfupload website.
48
+ # Wording and CSS processed through an Adobe Flash styler. Result is so-so. Feel free to put a CSS button overlayed directly on the SWF button. See swfupload website.
49
49
  :button_text => %{<span class="button-text">#{I18n.t("upload-button-wording", :scope => :papermill)}</span>},
50
50
  :button_text_style => %{.button-text { color: red; font-size: 12pt; font-weight: bold; }},
51
51
  :button_disabled => "false",
@@ -56,7 +56,7 @@ module Papermill
56
56
  # See swfupload.js for details.
57
57
  },
58
58
  :images_only => false, # set to true to forbid upload of anything else than images
59
- :file_size_limit_mb => 10, # file max size
59
+ :file_size_limit_mb => 10, # file max size, MegaBytes
60
60
  :button_after_container => false, # set to true to move the upload button below the container
61
61
 
62
62
  # DO NOT CHANGE THESE IN YOUR CLASSES. Only application wide (routes depend on it..)
@@ -113,9 +113,8 @@ module Papermill
113
113
 
114
114
  @papermill_associations.merge!({assoc => {:class => asset_class}})
115
115
  @papermill_options = Papermill::PAPERMILL_DEFAULTS.deep_merge(options)
116
- association_finder = assoc.to_s + "_finder"
117
- # using finder_sql because ActiveRecord chokes with STI on polymorphic tables. (Stupidely uses class.to_s instead of class.sti_name in association, god knows when it will get fixed, but tickets seems on the way for rails 3.0)
118
- has_many association_finder, :finder_sql => 'SELECT * FROM papermill_assets WHERE papermill_assets.assetable_id = #{id} AND papermill_assets.assetable_type = "#{self.class.sti_name}" AND papermill_assets.type ' + (asset_class == PapermillAsset ? "IS NULL" : %{= "#{asset_class.to_s}"}) + ' ORDER BY papermill_assets.position'
116
+ before_destroy :destroy_assets
117
+ after_destroy :remove_papermill_folder
119
118
  after_create :rebase_assets
120
119
  # reinventing the wheel because ActiveRecord chokes on :finder_sql with associations
121
120
  # TODO Clean the mess
@@ -133,7 +132,7 @@ module Papermill
133
132
  asset_class.find(:all, :conditions => conditions, :order => order)
134
133
  end
135
134
 
136
- after_destroy :remove_papermill_folder
135
+
137
136
  class_eval <<-EOV
138
137
  include Papermill::InstanceMethods
139
138
  EOV
@@ -161,9 +160,16 @@ module Papermill
161
160
 
162
161
  private
163
162
 
163
+ def destroy_assets
164
+ PapermillAsset.find(:all, :conditions => {:assetable_id => self.id, :assetable_type => self.class.sti_name}).each do |asset|
165
+ asset.destroy
166
+ end
167
+ true
168
+ end
169
+
164
170
  def rebase_assets
165
171
  return true unless timestamp
166
- PapermillAsset.find(:all, :conditions => {:assetable_id => self.timestamp}).each do |asset|
172
+ PapermillAsset.find(:all, :conditions => {:assetable_id => self.timestamp, :assetable_type => self.class.sti_name}).each do |asset|
167
173
  if asset.created_at < 2.hours.ago
168
174
  asset.destroy
169
175
  else
data/papermill.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{papermill}
8
- s.version = "0.2.1"
8
+ s.version = "0.2.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Benoit B\303\251n\303\251zech"]
12
- s.date = %q{2009-08-30}
12
+ s.date = %q{2009-08-31}
13
13
  s.description = %q{Paperclip wrapper}
14
14
  s.email = %q{benoit.benezech@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -59,7 +59,7 @@ Gem::Specification.new do |s|
59
59
  s.homepage = %q{http://github.com/BBenezech/papermill}
60
60
  s.rdoc_options = ["--charset=UTF-8"]
61
61
  s.require_paths = ["lib"]
62
- s.rubygems_version = %q{1.3.5}
62
+ s.rubygems_version = %q{1.3.4}
63
63
  s.summary = %q{Paperclip wrapper}
64
64
  s.test_files = [
65
65
  "test/papermill_test.rb",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: BBenezech-papermill
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Benoit B\xC3\xA9n\xC3\xA9zech"
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-08-30 00:00:00 -07:00
12
+ date: 2009-08-31 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15