Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Some style change

  • Loading branch information...
commit bdfeebdad369af8ca5ac252126b7406c00dc4e05 1 parent 5ffcc85
@sikachu sikachu authored
Showing with 18 additions and 16 deletions.
  1. +14 −14 lib/paperclip/attachment.rb
  2. +4 −2 lib/paperclip/upfile.rb
View
28 lib/paperclip/attachment.rb
@@ -11,29 +11,29 @@ class Attachment
def self.default_options
@default_options ||= {
- :url => "/system/:attachment/:id/:style/:filename",
- :path => ":rails_root/public:url",
- :styles => {},
+ :convert_options => {},
+ :default_style => :original,
+ :default_url => "/:attachment/:style/missing.png",
+ :hash_data => ":class/:attachment/:id/:style/:updated_at",
+ :hash_digest => "SHA1",
+ :interpolator => Paperclip::Interpolations,
:only_process => [],
+ :path => ":rails_root/public:url",
+ :preserve_files => false,
:processors => [:thumbnail],
- :convert_options => {},
:source_file_options => {},
- :default_url => "/:attachment/:style/missing.png",
- :default_style => :original,
:storage => :filesystem,
+ :styles => {},
+ :url => "/system/:attachment/:id/:style/:filename",
+ :url_generator => Paperclip::UrlGenerator
+ :use_default_time_zone => true,
:use_timestamp => true,
:whiny => Paperclip.options[:whiny] || Paperclip.options[:whiny_thumbnails],
- :use_default_time_zone => true,
- :hash_digest => "SHA1",
- :hash_data => ":class/:attachment/:id/:style/:updated_at",
- :preserve_files => false,
- :interpolator => Paperclip::Interpolations,
- :url_generator => Paperclip::UrlGenerator
}
end
- attr_reader :name, :instance, :default_style, :convert_options, :queued_for_write, :whiny, :options, :interpolator
- attr_reader :source_file_options, :whiny
+ attr_reader :name, :instance, :default_style, :convert_options, :queued_for_write, :whiny,
+ :options, :interpolator, :source_file_options, :whiny
attr_accessor :post_processing
# Creates an Attachment object. +name+ is the name of the attachment,
View
6 lib/paperclip/upfile.rb
@@ -5,7 +5,6 @@ module Paperclip
# to the +File+ class. Useful for testing.
# user.avatar = File.new("test/test_avatar.jpg")
module Upfile
-
# Infer the MIME-type of the file from the extension.
def content_type
types = MIME::Types.type_for(self.original_filename)
@@ -23,7 +22,7 @@ def iterate_over_array_to_find_best_option(types)
end
def type_from_file_command
- # On BSDs, `file` doesn't give a result code of 1 if the file doesn't exist.
+ # On BSDs, `file` doesn't give a result code of 1 if the file doesn't exist.
type = (self.original_filename.match(/\.(\w+)$/)[1] rescue "octet-stream").downcase
mime_type = (Paperclip.run("file", "-b --mime :file", :file => self.path).split(/[:;]\s+/)[0] rescue "application/x-#{type}")
mime_type = "application/x-#{type}" if mime_type.match(/\(.*?\)/)
@@ -45,12 +44,15 @@ def size
if defined? StringIO
class StringIO
attr_accessor :original_filename, :content_type, :fingerprint
+
def original_filename
@original_filename ||= "stringio.txt"
end
+
def content_type
@content_type ||= "text/plain"
end
+
def fingerprint
@fingerprint ||= Digest::MD5.hexdigest(self.string)
end
Please sign in to comment.
Something went wrong with that request. Please try again.