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
Added Fleximage::Operator::Base tests, as well as some slight cleanup to 
Fleximage::ImageProxy
Squeegy (author)
Mon Apr 21 11:09:52 -0700 2008
commit  371b930be0ae30dd1b4c911bb1ece4a3cd0ece57
tree    f358b92fefa380d9e80383cc09968718e2583278
parent  1e45f1e75cb4297bfe5db13084be614c8217fc43
...
17
18
19
20
 
21
22
23
24
25
26
27
28
 
29
30
31
 
 
32
33
34
35
36
37
38
 
 
39
40
41
...
17
18
19
 
20
21
22
23
24
25
26
 
 
27
28
29
 
30
31
32
33
34
35
36
 
 
37
38
39
40
41
0
@@ -17,25 +17,25 @@ module Fleximage
0
     # The image to be manipulated by operators.
0
     attr_accessor :image
0
     
0
-    # Create a new image operator proxy.  Just provide the name of the image
0
+    # Create a new image operator proxy.
0
     def initialize(image, model_obj)
0
       @image = image
0
       @model = model_obj
0
     end
0
     
0
     # A call to an unknown method will look for an Operator by that method's name.
0
-    # If it finds one, it will execute that operator, otherwise it will simply call super for the
0
-    # default method missing behavior.
0
+    # If it finds one, it will execute that operator.
0
     def method_missing(method_name, *args)
0
       # Find the operator class
0
-      operator_class = "Fleximage::Operator::#{method_name.to_s.camelcase}".constantize
0
+      class_name = method_name.to_s.camelcase
0
+      operator_class = "Fleximage::Operator::#{class_name}".constantize
0
       
0
       # Execute the operator
0
       @image = operator_class.new(self, @image, @model).execute(*args)
0
     
0
     rescue NameError => e
0
-      if e.to_s =~ /uninitialized constant Fleximage::Operator::#{method_name.to_s.camelcase}/
0
-        raise OepratorNotFound, "No correspoding operator found for the method \"#{method_name}\""
0
+      if e.to_s =~ /uninitialized constant Fleximage::Operator::#{class_name}/
0
+        raise OepratorNotFound, "No operator Fleximage::Operator::#{class_name} found for the method \"#{method_name}\""
0
       else
0
         raise e
0
       end
...
1
2
3
4
 
 
 
 
5
6
7
...
39
40
41
42
 
43
44
45
...
1
2
3
 
4
5
6
7
8
9
10
...
42
43
44
 
45
46
47
48
0
@@ -1,7 +1,10 @@
0
 module Fleximage
0
   module Operator
0
     
0
-    class BadOperatorResult < RuntimeError #:nodoc:
0
+    class BadOperatorResult < Exception #:nodoc:
0
+    end
0
+    
0
+    class OperationNotImplemented < Exception #:nodoc:
0
     end
0
     
0
     # The Operator::Base class is what all other Operator classes inherit from.
0
@@ -39,7 +42,7 @@ module Fleximage
0
       # Perform the operation.  Override this method in your Operator::Base subclasses
0
       # in order to write your own image operators.
0
       def operate(*args)
0
-        raise "Override this method in your own subclass."
0
+        raise OperationNotImplemented, "Override this method in your own subclass."
0
       end
0
       
0
       # ---

Comments