Permalink
Browse files

Clean up whitespace

  • Loading branch information...
1 parent 980c9b9 commit 3be55fc85f15a79f1306aba334a6737f6d715991 @joshuaclayton joshuaclayton committed Jun 7, 2010
View
@@ -138,7 +138,7 @@ For example, assuming we had this definition:
has_attached_file :scan, :styles => { :text => { :quality => :better } },
:processors => [:rotator, :ocr]
-then both the :rotator processor and the :ocr processor would receive the
+then both the :rotator processor and the :ocr processor would receive the
options "{ :quality => :better }". This parameter may not mean anything to one
or more or the processors, and they are expected to ignore it.
View
@@ -62,13 +62,13 @@ task :manifest => :clean do
puts file
end
end
-
+
desc "Generate a gemspec file for GitHub"
task :gemspec => :clean do
File.open("#{spec.name}.gemspec", 'w') do |f|
f.write spec.to_ruby
end
-end
+end
desc "Build the gem into the current directory"
task :gem => :gemspec do
@@ -1,5 +1,5 @@
Usage:
script/generate paperclip Class attachment1 (attachment2 ...)
-
-This will create a migration that will add the proper columns to your class's table.
+
+This will create a migration that will add the proper columns to your class's table.
@@ -1,27 +1,27 @@
class PaperclipGenerator < Rails::Generator::NamedBase
attr_accessor :attachments, :migration_name
-
+
def initialize(args, options = {})
super
@class_name, @attachments = args[0], args[1..-1]
end
-
- def manifest
+
+ def manifest
file_name = generate_file_name
@migration_name = file_name.camelize
record do |m|
m.migration_template "paperclip_migration.rb.erb",
File.join('db', 'migrate'),
:migration_file_name => file_name
end
- end
-
- private
-
+ end
+
+ private
+
def generate_file_name
names = attachments.map{|a| a.underscore }
names = names[0..-2] + ["and", names[-1]] if names.length > 1
"add_attachments_#{names.join("_")}_to_#{@class_name.underscore}"
end
-
+
end
View
@@ -52,12 +52,12 @@ module Paperclip
class << self
# Provides configurability to Paperclip. There are a number of options available, such as:
- # * whiny: Will raise an error if Paperclip cannot process thumbnails of
+ # * whiny: Will raise an error if Paperclip cannot process thumbnails of
# an uploaded image. Defaults to true.
# * log: Logs progress to the Rails log. Uses ActiveRecord's logger, so honors
# log levels, etc. Defaults to true.
# * command_path: Defines the path at which to find the command line
- # programs if they are not visible to Rails the system's search path. Defaults to
+ # programs if they are not visible to Rails the system's search path. Defaults to
# nil, which uses the first executable found in the user's search path.
# * image_magick_path: Deprecated alias of command_path.
def options
@@ -100,7 +100,7 @@ def interpolates key, &block
#
# Paperclip.run("echo", "something", :expected_outcodes => [0,1,2,3])
#
- # This method can log the command being run when
+ # This method can log the command being run when
# Paperclip.options[:log_command] is set to true (defaults to false). This
# will only log if logging in general is set to true as well.
def run cmd, *params
@@ -152,7 +152,7 @@ def processor name #:nodoc:
name = name.to_s.camelize
processor = Paperclip.const_get(name)
unless processor.ancestors.include?(Paperclip::Processor)
- raise PaperclipError.new("Processor #{name} was not found")
+ raise PaperclipError.new("Processor #{name} was not found")
end
processor
end
@@ -194,41 +194,41 @@ class InfiniteInterpolationError < PaperclipError #:nodoc:
module ClassMethods
# +has_attached_file+ gives the class it is called on an attribute that maps to a file. This
- # is typically a file stored somewhere on the filesystem and has been uploaded by a user.
+ # is typically a file stored somewhere on the filesystem and has been uploaded by a user.
# The attribute returns a Paperclip::Attachment object which handles the management of
- # that file. The intent is to make the attachment as much like a normal attribute. The
- # thumbnails will be created when the new file is assigned, but they will *not* be saved
- # until +save+ is called on the record. Likewise, if the attribute is set to +nil+ is
- # called on it, the attachment will *not* be deleted until +save+ is called. See the
- # Paperclip::Attachment documentation for more specifics. There are a number of options
+ # that file. The intent is to make the attachment as much like a normal attribute. The
+ # thumbnails will be created when the new file is assigned, but they will *not* be saved
+ # until +save+ is called on the record. Likewise, if the attribute is set to +nil+ is
+ # called on it, the attachment will *not* be deleted until +save+ is called. See the
+ # Paperclip::Attachment documentation for more specifics. There are a number of options
# you can set to change the behavior of a Paperclip attachment:
# * +url+: The full URL of where the attachment is publically accessible. This can just
# as easily point to a directory served directly through Apache as it can to an action
# that can control permissions. You can specify the full domain and path, but usually
- # just an absolute path is sufficient. The leading slash *must* be included manually for
- # absolute paths. The default value is
+ # just an absolute path is sufficient. The leading slash *must* be included manually for
+ # absolute paths. The default value is
# "/system/:attachment/:id/:style/:filename". See
# Paperclip::Attachment#interpolate for more information on variable interpolaton.
# :url => "/:class/:attachment/:id/:style_:filename"
# :url => "http://some.other.host/stuff/:class/:id_:extension"
- # * +default_url+: The URL that will be returned if there is no attachment assigned.
- # This field is interpolated just as the url is. The default value is
+ # * +default_url+: The URL that will be returned if there is no attachment assigned.
+ # This field is interpolated just as the url is. The default value is
# "/:attachment/:style/missing.png"
# has_attached_file :avatar, :default_url => "/images/default_:style_avatar.png"
# User.new.avatar_url(:small) # => "/images/default_small_avatar.png"
- # * +styles+: A hash of thumbnail styles and their geometries. You can find more about
- # geometry strings at the ImageMagick website
+ # * +styles+: A hash of thumbnail styles and their geometries. You can find more about
+ # geometry strings at the ImageMagick website
# (http://www.imagemagick.org/script/command-line-options.php#resize). Paperclip
- # also adds the "#" option (e.g. "50x50#"), which will resize the image to fit maximally
- # inside the dimensions and then crop the rest off (weighted at the center). The
+ # also adds the "#" option (e.g. "50x50#"), which will resize the image to fit maximally
+ # inside the dimensions and then crop the rest off (weighted at the center). The
# default value is to generate no thumbnails.
- # * +default_style+: The thumbnail style that will be used by default URLs.
+ # * +default_style+: The thumbnail style that will be used by default URLs.
# Defaults to +original+.
# has_attached_file :avatar, :styles => { :normal => "100x100#" },
# :default_style => :normal
# user.avatar.url # => "/avatars/23/normal_me.png"
# * +whiny+: Will raise an error if Paperclip cannot post_process an uploaded file due
- # to a command line error. This will override the global setting for this attachment.
+ # to a command line error. This will override the global setting for this attachment.
# Defaults to true. This option used to be called :whiny_thumbanils, but this is
# deprecated.
# * +convert_options+: When creating thumbnails, use this free-form options
@@ -324,19 +324,19 @@ def validates_attachment_thumbnails name, options = {}
# * +unless+: Same as +if+ but validates if lambda or method returns false.
def validates_attachment_presence name, options = {}
message = options[:message] || "must be set."
- validates_presence_of :"#{name}_file_name",
+ validates_presence_of :"#{name}_file_name",
:message => message,
:if => options[:if],
:unless => options[:unless]
end
-
+
# Places ActiveRecord-style validations on the content type of the file
- # assigned. The possible options are:
- # * +content_type+: Allowed content types. Can be a single content type
- # or an array. Each type can be a String or a Regexp. It should be
- # noted that Internet Explorer upload files with content_types that you
- # may not expect. For example, JPEG images are given image/pjpeg and
- # PNGs are image/x-png, so keep that in mind when determining how you
+ # assigned. The possible options are:
+ # * +content_type+: Allowed content types. Can be a single content type
+ # or an array. Each type can be a String or a Regexp. It should be
+ # noted that Internet Explorer upload files with content_types that you
+ # may not expect. For example, JPEG images are given image/pjpeg and
+ # PNGs are image/x-png, so keep that in mind when determining how you
# match. Allows all by default.
# * +message+: The message to display when the uploaded file has an invalid
# content type.
@@ -4,7 +4,7 @@ module Paperclip
# when the model saves, deletes when the model is destroyed, and processes
# the file upon assignment.
class Attachment
-
+
def self.default_options
@default_options ||= {
:url => "/system/:attachment/:id/:style/:filename",
@@ -50,7 +50,7 @@ def initialize name, instance, options = {}
initialize_storage
end
-
+
def styles
unless @normalized_styles
@normalized_styles = {}
@@ -60,7 +60,7 @@ def styles
end
@normalized_styles
end
-
+
def processors
@processors.respond_to?(:call) ? @processors.call(instance) : @processors
end
@@ -69,7 +69,7 @@ def processors
# errors, assigns attributes, and processes the file. It
# also queues up the previous file for deletion, to be flushed away on
# #save of its host. In addition to form uploads, you can also assign
- # another Paperclip attachment:
+ # another Paperclip attachment:
# new_user.avatar = old_user.avatar
def assign uploaded_file
ensure_required_accessors!
@@ -95,7 +95,7 @@ def assign uploaded_file
@dirty = true
post_process
-
+
# Reset the file size if the original file was reprocessed.
instance_write(:file_size, @queued_for_write[:original].size.to_i)
ensure
@@ -179,8 +179,8 @@ def size
def content_type
instance_read(:content_type)
end
-
- # Returns the last modified time of the file as originally assigned, and
+
+ # Returns the last modified time of the file as originally assigned, and
# lives in the <attachment>_updated_at attribute of the model.
def updated_at
time = instance_read(:updated_at)
@@ -220,7 +220,7 @@ def reprocess!
true
end
end
-
+
# Returns true if a file has been assigned.
def file?
!original_filename.blank?
@@ -324,4 +324,3 @@ def flush_errors #:nodoc:
end
end
-
View
@@ -75,12 +75,12 @@ def inspect
to_s
end
- # Returns the scaling and cropping geometries (in string-based ImageMagick format)
- # neccessary to transform this Geometry into the Geometry given. If crop is true,
- # then it is assumed the destination Geometry will be the exact final resolution.
- # In this case, the source Geometry is scaled so that an image containing the
- # destination Geometry would be completely filled by the source image, and any
- # overhanging image would be cropped. Useful for square thumbnail images. The cropping
+ # Returns the scaling and cropping geometries (in string-based ImageMagick format)
+ # neccessary to transform this Geometry into the Geometry given. If crop is true,
+ # then it is assumed the destination Geometry will be the exact final resolution.
+ # In this case, the source Geometry is scaled so that an image containing the
+ # destination Geometry would be completely filled by the source image, and any
+ # overhanging image would be cropped. Useful for square thumbnail images. The cropping
# is weighted at the center of the Geometry.
def transformation_to dst, crop = false
if crop
@@ -78,7 +78,7 @@ def basename attachment, style_name
# Returns the extension of the file. e.g. "jpg" for "file.jpg"
# If the style has a format defined, it will return the format instead
# of the actual extension.
- def extension attachment, style_name
+ def extension attachment, style_name
((style = attachment.styles[style_name]) && style[:format]) ||
File.extname(attachment.original_filename).gsub(/^\.+/, "")
end
@@ -26,7 +26,7 @@ def stream_to path_or_file, in_blocks_of = 8192
while self.read(in_blocks_of, buffer) do
dstio.write(buffer)
end
- dstio.rewind
+ dstio.rewind
dstio
end
end
@@ -42,7 +42,7 @@ def failure_message
end
def negative_failure_message
- "Content types #{@allowed_types.join(", ")} should be rejected" +
+ "Content types #{@allowed_types.join(", ")} should be rejected" +
" and #{@rejected_types.join(", ")} accepted by #{@attachment_name}"
end
@@ -72,4 +72,3 @@ def rejected_types_rejected?
end
end
end
-
@@ -52,4 +52,3 @@ def no_error_when_valid?
end
end
end
-
@@ -93,4 +93,3 @@ def higher_than_high?
end
end
end
-
@@ -6,7 +6,7 @@ module Paperclip
#
# Processors are required to be defined inside the Paperclip module and
# are also required to be a subclass of Paperclip::Processor. There is
- # only one method you *must* implement to properly be a subclass:
+ # only one method you *must* implement to properly be a subclass:
# #make, but #initialize may also be of use. Both methods accept 3
# arguments: the file that will be operated on (which is an instance of
# File), a hash of options that were defined in has_attached_file's
@@ -33,7 +33,7 @@ def self.make file, options = {}, attachment = nil
new(file, options, attachment).make
end
end
-
+
# Due to how ImageMagick handles its image format conversion and how Tempfile
# handles its naming scheme, it is necessary to override how Tempfile makes
# its names so as to allow for file extensions. Idea taken from the comments
Oops, something went wrong.

0 comments on commit 3be55fc

Please sign in to comment.