<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>test_rails/complex_pic_test.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,7 +1,7 @@
 Gem::Specification.new do |s|
   s.name = &quot;has_image&quot;
-  s.version = &quot;0.2.3&quot;
-  s.date = &quot;2008-10-09&quot;
+  s.version = &quot;0.3.0&quot;
+  s.date = &quot;2008-10-22&quot;
   s.add_dependency('mini_magick', '&gt;= 1.2.3')
   s.rubyforge_project = 'has-image'  
   s.summary = &quot;Lets you attach images with thumbnails to active record models.&quot;
@@ -27,8 +27,8 @@ Gem::Specification.new do |s|
     &quot;test_rails/fixtures/bad_image.jpg&quot;,
     &quot;test_rails/fixtures/image.jpg&quot;,
     &quot;test_rails/fixtures/image.png&quot;,
-    &quot;test_rails/pic.rb&quot;,
     &quot;test_rails/pic_test.rb&quot;,
+    &quot;test_rails/complex_pic_test.rb&quot;,
     &quot;test_rails/schema.rb&quot;,
     &quot;test_rails/test_helper.rb&quot;,
     &quot;test/processor_test.rb&quot;,</diff>
      <filename>has_image.gemspec</filename>
    </modified>
    <modified>
      <diff>@@ -1,8 +1,8 @@
 def imagemagick_installed?
   `which identify`
-   $?.success?
+  $?.success?
 end
 
 require 'has_image'
 
-abort 'ImageMagick not found in PATH. Is it installed?' unless imagemagick_installed?
+abort 'ImageMagick not found in PATH. Is it installed?' unless imagemagick_installed?
\ No newline at end of file</diff>
      <filename>init.rb</filename>
    </modified>
    <modified>
      <diff>@@ -9,9 +9,9 @@ module HasImage
   class FileTooBigError &lt; StorageError ; end
   class FileTooSmallError &lt; StorageError ; end
   class InvalidGeometryError &lt; ProcessorError ; end
-  
+
   class &lt;&lt; self
-    
+
     def included(base) # :nodoc:
       base.extend(ClassMethods)
     end
@@ -68,61 +68,104 @@ module HasImage
         :image_too_big_message =&gt; &quot;The image is too big.&quot;
       }
     end
-    
+
   end
 
   module ClassMethods
+    # == Using HasImage
+    #
     # To use HasImage with a Rails model, all you have to do is add a column
-    # named &quot;has_image_file.&quot; For configuration defaults, you might want to take
-    # a look at the default options specified in HasImage#default_options_for.
-    # The different setting options are described below.
-    # 
-    # Options:
-    # *  +:resize_to+ - Dimensions to resize to. This should be an aImageMagick {geometry string}[http://www.imagemagick.org/script/command-line-options.php#resize]. Fixed sizes are recommended.
-    # *  +:thumbnails&lt;/tt&gt; - A hash of thumbnail names and dimensions. The dimensions should be ImageMagick {geometry strings}[http://www.imagemagick.org/script/command-line-options.php#resize]. Fixed sized are recommended.
-    # *  +:auto_generate_thumbnails+ - Flag to indicate whether to automatically generate thumbnails when the image_data changes (e.g. on create). If you set this to false, your application code needs to take care of generating Thumbnails, e.g. using +#generate_thumbnail+
-    # *  +:delete+ - Flag to indicate if the images should be delete from the storage (e.g. the Filesystem) when the record is destroyed
-    # *  +:min_size&lt;/tt&gt; - Minimum file size allowed. It's recommended that you set this size in kilobytes.
-    # *  +:max_size&lt;/tt&gt; - Maximum file size allowed. It's recommended that you set this size in megabytes.
-    # *  +:base_path&lt;/tt&gt; - Where to install the images. You should probably leave this alone, except for tests.
-    # *  +:path_prefix&lt;/tt&gt; - Where to install the images, relative to basepath. You should probably leave this alone.
-    # *  +:convert_to&lt;/tt&gt; - An ImageMagick format to convert images to. Recommended formats: JPEG, PNG, GIF.
-    # *  +:output_quality&lt;/tt&gt; - Image output quality passed to ImageMagick.
-    # *  +:invalid_image_message&lt;/tt&gt; - The message that will be shown when the image data can't be processed.
-    # *  +:image_too_small_message&lt;/tt&gt; - The message that will be shown when the image file is too small. You should ideally set this to something that tells the user what the minimum is.
-    # *  +:image_too_big_message&lt;/tt&gt; - The message that will be shown when the image file is too big. You should ideally set this to something that tells the user what the maximum is.
+    # named &quot;has_image_file.&quot; For configuration defaults, you might want to
+    # take a look at the default options specified in
+    # HasImage#default_options_for. The different setting options are
+    # described below.
+    #    
+    # === Options
+    #
+    # *  &lt;tt&gt;:resize_to&lt;/tt&gt; - Dimensions to resize to. This should be an ImageMagick {geometry string}[http://www.imagemagick.org/script/command-line-options.php#resize]. Fixed sizes are recommended.
+    # *  &lt;tt&gt;:thumbnails&lt;/tt&gt; - A hash of thumbnail names and dimensions. The dimensions should be ImageMagick {geometry strings}[http://www.imagemagick.org/script/command-line-options.php#resize]. Fixed sized are recommended.
+    # *  &lt;tt&gt;:auto_generate_thumbnails&lt;/tt&gt; - Flag to indicate whether to automatically generate thumbnails when the image_data changes (e.g. on create). If you set this to false, your application code needs to take care of generating thumbnails, e.g. using +#generate_thumbnail+
+    # *  &lt;tt&gt;:delete&lt;/tt&gt; - Flag to indicate if the images should be deleted from the storage (e.g. the filesystem) when the record is destroyed.
+    # *  &lt;tt&gt;:min_size&lt;/tt&gt; - Minimum file size allowed. It's recommended that you set this size in kilobytes.
+    # *  &lt;tt&gt;:max_size&lt;/tt&gt; - Maximum file size allowed. It's recommended that you set this size in megabytes.
+    # *  &lt;tt&gt;:base_path&lt;/tt&gt; - Where to install the images.
+    # *  &lt;tt&gt;:path_prefix&lt;/tt&gt; - Where to install the images, relative to basepath.
+    # *  &lt;tt&gt;:convert_to&lt;/tt&gt; - An ImageMagick format to convert images to.
+    # *  &lt;tt&gt;:output_quality&lt;/tt&gt; - Image output quality passed to ImageMagick.
+    # *  &lt;tt&gt;:invalid_image_message&lt;/tt&gt; - The message that will be shown when the image data can't be processed.
+    # *  &lt;tt&gt;:image_too_small_message&lt;/tt&gt; - The message that will be shown when the image file is too small. You should ideally set this to something that tells the user what the minimum is.
+    # *  &lt;tt&gt;:image_too_big_message&lt;/tt&gt; - The message that will be shown when the image file is too big. You should ideally set this to something that tells the user what the maximum is.
+    #
+    # === Basic Examples
     #
-    # Examples:
     #   has_image # uses all default options
     #   has_image :resize_to &quot;800x800&quot;, :thumbnails =&gt; {:square =&gt; &quot;150x150&quot;}
     #   has_image :resize_to &quot;100x150&quot;, :max_size =&gt; 500.kilobytes
-    #   has_image :invalid_image_message =&gt; &quot;No se puede procesar la imagen.&quot;
+    #
+    # === Some slightly more advanced examples
+    #
+    # ==== Localizing HasImage
+    #
+    #  has_image :invalid_image_message =&gt; &quot;No se puede procesar la imagen.&quot;
+    #
+    # ==== Using has_image with Capistrano
+    #
+    # When deploying using Capistrano, you will likely want to keep images
+    # under a &quot;system&quot; directory so that newly deployed versions have access
+    # to them:
+    #
+    #   has_image :resize_to =&gt; &quot;150x150&quot;,
+    #     :thumbnails =&gt; {
+    #       :square =&gt; &quot;75x75&quot;,
+    #     },
+    #     :base_path =&gt; File.join(Rails.root, 'public', 'system')
+    #
+    # ==== Testing with HasImage:
+    #
+    # If you want your tests to actually run the image processing, you should
+    # make sure your tests write the image files somewhere outside your public
+    # directory. Add something like this to your config/environments/test.rb:
+    #
+    #   config.after_initialize do
+    #     MyClass.has_image_options[:base_path] = File.join(RAILS_ROOT, &quot;tmp&quot;) 
+    #   end
+    #
+    # If you want to stub out calls to has_image so that your tests don't do
+    # the (slow) image processing, here's an example using Test::Unit and
+    # Mocha:
+    #
+    #   def setup
+    #     Photo.any_instance.stubs(:image_data=).returns(true)
+    #     Photo.any_instance.stubs(:install_images).returns(true)
+    #     Photo.any_instance.stubs(:image_data_valid?).returns(true)
+    #   end
+    #
     def has_image(options = {})
       options.assert_valid_keys(HasImage.default_options_for(self).keys)
       options = HasImage.default_options_for(self).merge(options)
       class_inheritable_accessor :has_image_options
       write_inheritable_attribute(:has_image_options, options)
-      
+
       after_create :install_images
       after_save :update_images
       after_destroy :remove_images
-      
+
       validate_on_create :image_data_valid?
-      
+
       include ModelInstanceMethods
       extend  ModelClassMethods
-    
+
     end
-    
+
   end
 
   module ModelInstanceMethods
-    
+
     # Does the object have an image?
     def has_image?
       !send(has_image_options[:column]).blank?
     end
-    
+
     # Sets the uploaded image data. Image data can be an instance of Tempfile,
     # or an instance of any class than inherits from IO.
     # aliased as uploaded_data= for compatibility with attachment_fu
@@ -137,7 +180,7 @@ module HasImage
       nil
     end
     alias_method :uploaded_data, :image_data
-    
+
     # Is the image data a file that ImageMagick can process, and is it within
     # the allowed minimum and maximum sizes?
     def image_data_valid?
@@ -150,7 +193,7 @@ module HasImage
         errors.add_to_base(self.class.has_image_options[:invalid_image_message])
       end
     end
-    
+
     # Gets the &quot;web path&quot; for the image, or optionally, its thumbnail.
     # Aliased as +public_filename+ for compatibility with attachment-Fu
     def public_path(thumbnail = nil)
@@ -163,29 +206,29 @@ module HasImage
     def absolute_path(thumbnail = nil)
       storage.filesystem_path_for(self, thumbnail)
     end
-    
+
     # Regenerates the thumbails from the main image.
     def regenerate_thumbnails!
       storage.generate_thumbnails(has_image_id, send(has_image_options[:column]))
     end
     alias_method :regenerate_thumbnails, :regenerate_thumbnails! #Backwards compat
-    
+
     def generate_thumbnail!(thumb_name)
       storage.generate_thumbnail(has_image_id, send(has_image_options[:column]), thumb_name)
     end
-    
+
     def width
       self[:width] || storage.measure(absolute_path, :width)
     end
-    
+
     def height
       self[:height] || storage.measure(absolute_path, :height)
     end
-    
+
     def image_size
       [width, height] * 'x'
     end
-    
+
     # Deletes the image from the storage.
     def remove_images
       return if send(has_image_options[:column]).blank? || !has_image_options[:delete]
@@ -204,7 +247,7 @@ module HasImage
         end
       end
     end
-    
+
     # Creates new images and removes the old ones when image_data has been
     # set.
     def update_images
@@ -218,21 +261,13 @@ module HasImage
       return if !storage.temp_file
       populate_attributes
     end
-    
-    def populate_attributes
-      send(&quot;#{has_image_options[:column]}=&quot;, storage.install_images(self))
-      self[:width] = storage.measure(absolute_path, :width) if self.class.column_names.include?('width')
-      self[:height] = storage.measure(absolute_path, :height) if self.class.column_names.include?('height')
-      save!
-    end
-    private :populate_attributes
-    
+
     # Gets an instance of the underlying storage functionality. See
     # HasImage::Storage.
     def storage
       @storage ||= HasImage::Storage.new(has_image_options)
     end
-    
+
     # By default, just returns the model's id. Since this id is used to divide
     # the images up in directories, you can override this to return a related
     # model's id if you want the images to be grouped differently. For example,
@@ -241,7 +276,17 @@ module HasImage
     def has_image_id
       id
     end
-    
+
+    private
+
+    def populate_attributes
+      send(&quot;#{has_image_options[:column]}=&quot;, storage.install_images(self))
+      self[:width] = storage.measure(absolute_path, :width) if self.class.column_names.include?('width')
+      self[:height] = storage.measure(absolute_path, :height) if self.class.column_names.include?('height')
+      save!
+    end
+
+
   end
 
   module ModelClassMethods
@@ -251,11 +296,11 @@ module HasImage
     def thumbnails
       has_image_options[:thumbnails]
     end
-    
+
     def from_partitioned_path(path)
       find HasImage::Storage.id_from_path(path)
     end
-    
+
   end
 
 end</diff>
      <filename>lib/has_image.rb</filename>
    </modified>
    <modified>
      <diff>@@ -9,17 +9,24 @@ module HasImage
     
     class &lt;&lt; self
       
-      # &quot;The form of an {extended geometry
-      # string}[http://www.imagemagick.org/script/command-line-options.php?#resize] is
-      # &lt;width&gt;x&lt;height&gt;{+-}&lt;xoffset&gt;{+-}&lt;yoffset&gt;{%}{!}{&lt;}{&gt;}&quot;
+      # The form of an {extended geometry string}[http://www.imagemagick.org/script/command-line-options.php?#resize] is:
+      #
+      #   &lt;width&gt;x&lt;height&gt;{+-}&lt;xoffset&gt;{+-}&lt;yoffset&gt;{%}{!}{&lt;}{&gt;}
       def geometry_string_valid?(string)
         string =~ /\A[\d]*x[\d]*([+-][0-9][+-][0-9])?[%@!&lt;&gt;^]?\Z/
       end
       
-      # Arg should be either a file, or a path. This runs ImageMagick's
-      # &quot;identify&quot; command and looks for an exit status indicating an error. If
-      # there is no error, then ImageMagick has identified the file as something
-      # it can work with and it will be converted to the desired output format.
+      # Arg should be either a file or a path. This runs ImageMagick's
+      # &quot;identify&quot; command and looks for an exit status indicating an error.
+      # If there is no error, then ImageMagick has identified the file as
+      # something it can work with and it will be converted to the desired
+      # output format.
+      #
+      # Note that this is used in place of any mimetype checks. HasImage
+      # assumes that is ImageMagick is able to process the file, then it's OK.
+      # Since ImageMagick can be compiled with many different options for
+      # supporting various file types (or not) this is safer and more complete
+      # than checking the mime type.
       def valid?(arg)
         arg.close if arg.respond_to?(:close) &amp;&amp; !arg.closed?
         silence_stderr do
@@ -35,13 +42,13 @@ module HasImage
       @options = options
     end
     
-    # Create the resized image, and transforms it to the desired output
+    # Creates the resized image, and transforms it to the desired output
     # format if necessary. 
     # 
     # +size+ should be a valid ImageMagick {geometry string}[http://www.imagemagick.org/script/command-line-options.php#resize].
     # +format+ should be an image format supported by ImageMagick, e.g. &quot;PNG&quot;, &quot;JPEG&quot;
-    # yields the processed Image file as a file-like
-    def process(file, size=options[:resize_to], format=options[:convert_to])
+    # If a block is given, it yields the processed image file as a file-like object using IO#read.
+    def process(file, size = options[:resize_to], format = options[:convert_to])
       unless size.blank? || Processor.geometry_string_valid?(size)
         raise InvalidGeometryError.new('&quot;%s&quot; is not a valid ImageMagick geometry string' % size)
       end
@@ -54,14 +61,13 @@ module HasImage
     end
     alias_method :resize, :process #Backwards-compat
     
-    # Gets the given +dimension+ (width/height) from the image file at +path+
+    # Gets the given +dimension+ (width/height) from the image file at +path+.
     def measure(path, dimension)
       MiniMagick::Image.from_file(path)[dimension.to_sym]
     end
     
   private
-    # operate on the image with MiniMagick
-    # yields a MiniMagick::Image object
+    # Operates on the image with MiniMagick. Yields a MiniMagick::Image object.
     def with_image(file)
       path = file.respond_to?(:path) ? file.path : file
       file.close if file.respond_to?(:close) &amp;&amp; !file.closed?
@@ -77,7 +83,6 @@ module HasImage
       end
     end
   
-    # +image+ should be a MiniMagick::Image and +size+ a Geometry String
     # Image resizing is placed in a separate method for easy monkey-patching.
     # This is intended to be invoked from resize, rather than directly.
     # By default, the following ImageMagick functionality is invoked:
@@ -87,6 +92,8 @@ module HasImage
     # * gravity[http://www.imagemagick.org/script/command-line-options.php#gravity]
     # * extent[http://www.imagemagick.org/script/command-line-options.php#extent]
     # * quality[http://www.imagemagick.org/script/command-line-options.php#quality]
+    #
+    # +image+ should be a MiniMagick::Image. +size+ should be a geometry string.
     def resize_image(image, size)
       image.combine_options do |commands|
         commands.send(&quot;auto-orient&quot;.to_sym)</diff>
      <filename>lib/has_image/processor.rb</filename>
    </modified>
    <modified>
      <diff>@@ -14,11 +14,11 @@ class PicTest &lt; Test::Unit::TestCase
     Pic.has_image_options = HasImage.default_options_for(Pic)
     Pic.has_image_options[:base_path] = File.join(RAILS_ROOT, 'tmp')
   end
-  
+
   def teardown
     FileUtils.rm_rf(File.join(RAILS_ROOT, 'tmp', 'pics'))
   end
-  
+
   def test_should_be_valid
     @pic = Pic.new(:image_data =&gt; fixture_file_upload(&quot;/image.jpg&quot;, &quot;image/jpeg&quot;))
     assert @pic.valid? , &quot;#{@pic.errors.full_messages.to_sentence}&quot;
@@ -54,24 +54,24 @@ class PicTest &lt; Test::Unit::TestCase
     @pic.image_data = fixture_file_upload(&quot;/image.png&quot;, &quot;image/png&quot;)
     assert @pic.save!
   end
-  
+
   def test_finding_from_url_path
     @pic = Pic.new(:image_data =&gt; fixture_file_upload(&quot;/image.jpg&quot;, &quot;image/jpeg&quot;))
     @pic.save!
     path = HasImage::Storage.partitioned_path @pic.id
     assert_equal @pic, Pic.from_partitioned_path(path)
   end
-  
+
   def test_default_options_respect_table_name
     assert_equal 'pics', HasImage.default_options_for(PicWithDifferentTableName)[:path_prefix]
   end
-  
+
   def test_generate_thumbnails_on_create
     Pic.has_image_options[:thumbnails] = {:tiny =&gt; &quot;16x16&quot;}
     @pic = Pic.create!(:image_data =&gt; fixture_file_upload(&quot;/image.jpg&quot;, &quot;image/jpeg&quot;))
     assert File.exist?(@pic.absolute_path(:tiny))
   end
-  
+
   def test_doesnt_generate_thumbnails_if_option_disabled
     Pic.has_image_options[:thumbnails] = {:tiny =&gt; &quot;16x16&quot;}
     Pic.has_image_options[:auto_generate_thumbnails] = false
@@ -96,7 +96,7 @@ class PicTest &lt; Test::Unit::TestCase
     @pic.save!
     assert @pic.destroy
   end
-  
+
   def test_destroy_should_not_remove_image_file_if_option_is_set
     Pic.has_image_options[:delete] = false
     @pic = Pic.create!(:image_data =&gt; fixture_file_upload(&quot;/image.jpg&quot;, &quot;image/jpeg&quot;))
@@ -123,7 +123,7 @@ class PicTest &lt; Test::Unit::TestCase
     @pic.valid?
     assert @pic.valid?
   end
-  
+
   def test_dimension_getters
     Pic.has_image_options[:resize_to] = &quot;100x200&quot;
     pic = Pic.create!(:image_data =&gt; fixture_file_upload(&quot;/image.jpg&quot;, &quot;image/jpeg&quot;))
@@ -131,7 +131,7 @@ class PicTest &lt; Test::Unit::TestCase
     assert_equal 200, pic.height
     assert_equal '100x200', pic.image_size
   end
-  
+
   def test_image_isnt_resized_when_resize_to_set_to_nil
     Pic.has_image_options[:resize_to] = nil
     pic = Pic.create!(:image_data =&gt; fixture_file_upload(&quot;/image.jpg&quot;, &quot;image/jpeg&quot;))
@@ -139,7 +139,7 @@ class PicTest &lt; Test::Unit::TestCase
     assert_equal 1916, pic.width
     assert_equal 1990, pic.height
   end
-  
+
   def test_image_isnt_resized_but_converted_when_resize_to_set_to_nil
     Pic.has_image_options[:resize_to] = nil
     Pic.has_image_options[:convert_to] = 'PNG'
@@ -149,6 +149,5 @@ class PicTest &lt; Test::Unit::TestCase
     assert_equal 1916, pic.width
     assert_equal 1990, pic.height
   end
-  
-end
 
+end
\ No newline at end of file</diff>
      <filename>test_rails/pic_test.rb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>test_rails/compex_pic_test.rb</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>cb5ffb6f02bc7d7439b2e195a88c9851f93812ec</id>
    </parent>
  </parents>
  <author>
    <name>Norman Clarke</name>
    <email>norman@randomba.org</email>
  </author>
  <url>http://github.com/norman/has_image/commit/756d467405fc9cc7c275bd479f8d79eff1480b11</url>
  <id>756d467405fc9cc7c275bd479f8d79eff1480b11</id>
  <committed-date>2008-10-22T06:59:24-07:00</committed-date>
  <authored-date>2008-10-22T06:59:24-07:00</authored-date>
  <message>Cleaning up exapanding documentation. Cleaning up whitespace. Bumped Gem
version.</message>
  <tree>d3846bbc30129a9f1eb88c30e26d3d25cb2908c2</tree>
  <committer>
    <name>Norman Clarke</name>
    <email>norman@randomba.org</email>
  </committer>
</commit>
