Skip to content

Commit

Permalink
Some style change
Browse files Browse the repository at this point in the history
  • Loading branch information
sikachu committed Jan 27, 2012
1 parent 5ffcc85 commit bdfeebd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
28 changes: 14 additions & 14 deletions lib/paperclip/attachment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 4 additions & 2 deletions lib/paperclip/upfile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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(/\(.*?\)/)
Expand All @@ -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
Expand Down

0 comments on commit bdfeebd

Please sign in to comment.