papermill 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.1
1
+ 1.0.2
@@ -8,14 +8,14 @@ class <%= migration_name %> < ActiveRecord::Migration
8
8
  t.integer :file_file_size
9
9
 
10
10
  # Papermill fields (required)
11
- t.integer :position
12
- t.integer :assetable_id
13
- t.string :assetable_type
14
- t.string :assetable_key
15
- t.string :type
11
+ t.integer :position # sets are ordered by position
12
+ t.integer :assetable_id # Assetable
13
+ t.string :assetable_type # Assetable
14
+ t.string :assetable_key # Assetable sets
15
+ t.string :type # STI
16
+ t.string :title # raw filename, without file extension, for your own use
16
17
 
17
18
  # Custom fields (optionnals)
18
- t.string :title
19
19
  t.string :alt
20
20
  t.string :copyright
21
21
  t.text :description
@@ -1,5 +1,5 @@
1
1
  module Papermill
2
- PAPERCLIP_INTERPOLATION_STRING = ":id_partition/:style/:escaped_basename.:extension"
2
+ PAPERCLIP_INTERPOLATION_STRING = ":id_partition/:style/:basename.:extension"
3
3
 
4
4
  def self.included(base)
5
5
  base.extend(ClassMethods)
@@ -7,11 +7,7 @@ class PapermillAsset < ActiveRecord::Base
7
7
  :path => "#{Papermill::options[:public_root]}/#{Papermill::options[:papermill_prefix]}/#{Papermill::PAPERCLIP_INTERPOLATION_STRING}",
8
8
  :url => "/#{Papermill::options[:papermill_prefix]}/#{Papermill::PAPERCLIP_INTERPOLATION_STRING}"
9
9
 
10
- before_post_process :set_real_file_name
11
-
12
- Paperclip.interpolates :escaped_basename do |attachment, style|
13
- Paperclip::Interpolations[:basename].call(attachment, style).to_url
14
- end
10
+ before_post_process :set_file_name
15
11
 
16
12
  validates_attachment_presence :file
17
13
 
@@ -95,8 +91,10 @@ class PapermillAsset < ActiveRecord::Base
95
91
 
96
92
  private
97
93
 
98
- def set_real_file_name
99
- self.file.instance_write(:file_name, @real_file_name) if @real_file_name
94
+ def set_file_name
95
+ return if @real_file_name.blank?
96
+ self.title = (basename = @real_file_name.gsub(/#{extension = File.extname(@real_file_name)}$/, ""))
97
+ self.file.instance_write(:file_name, "#{basename.to_url}#{extension}")
100
98
  end
101
99
 
102
100
  def set_position
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: papermill
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Benoit B\xC3\xA9n\xC3\xA9zech"