public
Description: Rails plugin for uploading images as resources, with support for resizing, text stamping, and other special effects.
Homepage: http://wiki.github.com/Squeegy/fleximage
Clone URL: git://github.com/Squeegy/fleximage.git
Simplification of some unnecesary and noisy meta programming trickery.
Squeegy (author)
Wed May 21 11:59:05 -0700 2008
commit  81e51e7489ee4e397574a624d0eea432c675677d
tree    bf65542a0fe3015425d2b3553a9c60e9bdfb1a72
parent  a6c1bde3146fa8c92a6d1d4453378ed285edc8ce
...
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
90
91
...
247
248
249
250
251
252
253
 
 
254
255
256
...
70
71
72
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
...
245
246
247
 
 
 
 
248
249
250
251
252
0
@@ -70,22 +70,20 @@ module Fleximage
0
       # configure with a nice looking block.
0
       def acts_as_fleximage(options = {})
0
         
0
-        # Insert class methods
0
-        class_eval do
0
-          include Fleximage::Model::InstanceMethods
0
-          
0
-          # Call this class method just like you would call +operate+ in a view.
0
-          # The image transoformation in the provided block will be run on every uploaded image before its saved as the 
0
-          # master image.
0
-          def self.preprocess_image(&block)
0
-            preprocess_image_operation(block)
0
-          end
0
-          
0
-          # Internal method to ask this class if it stores image in the DB.
0
-          def self.db_store?
0
-            columns.find do |col|
0
-              col.name == 'image_file_data'
0
-            end
0
+        # Include the necesary instance methods
0
+        include Fleximage::Model::InstanceMethods
0
+        
0
+        # Call this class method just like you would call +operate+ in a view.
0
+        # The image transoformation in the provided block will be run on every uploaded image before its saved as the 
0
+        # master image.
0
+        def self.preprocess_image(&block)
0
+          preprocess_image_operation(block)
0
+        end
0
+        
0
+        # Internal method to ask this class if it stores image in the DB.
0
+        def self.db_store?
0
+          columns.find do |col|
0
+            col.name == 'image_file_data'
0
           end
0
         end
0
         
0
@@ -247,10 +245,8 @@ module Fleximage
0
           
0
           # Force a URL based file to have an original_filename
0
           eval <<-CODE
0
-            class << file
0
-              def original_filename
0
-                "#{file_url}"
0
-              end
0
+            def file.original_filename
0
+              "#{file_url}"
0
             end
0
           CODE
0
           
...
25
26
27
 
 
 
 
 
 
 
28
...
25
26
27
28
29
30
31
32
33
34
35
0
@@ -25,4 +25,11 @@ class FleximageFileUploadFromUrlTest < Test::Unit::TestCase
0
   rescue SocketError
0
     print '!'
0
   end
0
+  
0
+  def test_should_have_an_original_filename
0
+    p = PhotoFile.new(:image_file_url => files(:web_photo))
0
+    assert_equal p.image_filename, files(:web_photo)
0
+  rescue SocketError
0
+    print '!'
0
+  end
0
 end
...
23
24
25
 
 
 
 
 
 
 
 
26
...
23
24
25
26
27
28
29
30
31
32
33
34
0
@@ -23,4 +23,12 @@ class FleximageFileUploadToDbTest < Test::Unit::TestCase
0
     assert_equal 1, p.errors.size
0
     assert_equal 'was not a readable image', p.errors.on(:image_file)
0
   end
0
+  
0
+  def test_should_retrieve_a_stored_image
0
+    id = PhotoDb.create(:image_file => files(:photo)).id
0
+    p = PhotoDb.find(id)
0
+    assert_kind_of Magick::Image, p.load_image
0
+    assert_equal 768,  p.load_image.columns
0
+    assert_equal 1024, p.load_image.rows
0
+  end
0
 end

Comments