1- require ' base64'
2- require ' forwardable'
3- require ' dragonfly/has_filename'
4- require ' dragonfly/temp_object'
5- require ' dragonfly/utils'
1+ require " base64"
2+ require " forwardable"
3+ require " dragonfly/has_filename"
4+ require " dragonfly/temp_object"
5+ require " dragonfly/utils"
66
77module Dragonfly
88
@@ -16,11 +16,10 @@ module Dragonfly
1616 # It is acted upon in generator, processor, analyser and datastore methods and provides a standard interface for updating content,
1717 # no matter how that content first got there (whether in the form of a String/Pathname/File/etc.)
1818 class Content
19-
2019 include HasFilename
2120 extend Forwardable
2221
23- def initialize ( app , obj = "" , meta = nil )
22+ def initialize ( app , obj = "" , meta = nil )
2423 @app = app
2524 @meta = { }
2625 @previous_temp_objects = [ ]
@@ -79,7 +78,7 @@ def name=(name)
7978 # @example "image/jpeg"
8079 # @return [String]
8180 def mime_type
82- meta [ ' mime_type' ] || app . mime_type_for ( ext )
81+ meta [ " mime_type" ] || app . mime_type_for ( ext )
8382 end
8483
8584 # Set the content using a pre-registered generator
@@ -93,7 +92,7 @@ def generate!(name, *args)
9392
9493 # Update the content using a pre-registered processor
9594 # @example
96- # content.process!(:convert , "-resize 300x300")
95+ # content.process!(:thumb , "300x300")
9796 # @return [Content] self
9897 def process! ( name , *args )
9998 app . get_processor ( name ) . call ( self , *args )
@@ -111,10 +110,10 @@ def analyse(name)
111110 # @param obj [String, Pathname, Tempfile, File, Content, TempObject] can be any of these types
112111 # @param meta [Hash] - should be json-like, i.e. contain no types other than String, Number, Boolean
113112 # @return [Content] self
114- def update ( obj , meta = nil )
113+ def update ( obj , meta = nil )
115114 meta ||= { }
116- self . temp_object = TempObject . new ( obj , meta [ ' name' ] )
117- self . meta [ ' name' ] ||= temp_object . name if temp_object . name
115+ self . temp_object = TempObject . new ( obj , meta [ " name" ] )
116+ self . meta [ " name" ] ||= temp_object . name if temp_object . name
118117 clear_analyser_cache
119118 add_meta ( obj . meta ) if obj . respond_to? ( :meta )
120119 add_meta ( meta )
@@ -135,7 +134,7 @@ def add_meta(meta)
135134 # "file --mime-type #{path}"
136135 # end
137136 # # ===> "beach.jpg: image/jpeg"
138- def shell_eval ( opts = { } )
137+ def shell_eval ( opts = { } )
139138 should_escape = opts [ :escape ] != false
140139 command = yield ( should_escape ? shell . escape ( path ) : path )
141140 run command , :escape => should_escape
@@ -148,7 +147,7 @@ def shell_eval(opts={})
148147 # "/usr/local/bin/generate_text gumfry -o #{path}"
149148 # end
150149 # @return [Content] self
151- def shell_generate ( opts = { } )
150+ def shell_generate ( opts = { } )
152151 ext = opts [ :ext ] || self . ext
153152 should_escape = opts [ :escape ] != false
154153 tempfile = Utils . new_tempfile ( ext )
@@ -165,7 +164,7 @@ def shell_generate(opts={})
165164 # "convert -resize 20x10 #{old_path} #{new_path}"
166165 # end
167166 # @return [Content] self
168- def shell_update ( opts = { } )
167+ def shell_update ( opts = { } )
169168 ext = opts [ :ext ] || self . ext
170169 should_escape = opts [ :escape ] != false
171170 tempfile = Utils . new_tempfile ( ext )
@@ -176,7 +175,7 @@ def shell_update(opts={})
176175 update ( tempfile )
177176 end
178177
179- def store ( opts = { } )
178+ def store ( opts = { } )
180179 datastore . write ( self , opts )
181180 end
182181
@@ -188,7 +187,7 @@ def b64_data
188187 end
189188
190189 def close
191- previous_temp_objects . each { |temp_object | temp_object . close }
190+ previous_temp_objects . each { |temp_object | temp_object . close }
192191 temp_object . close
193192 end
194193
@@ -199,6 +198,7 @@ def inspect
199198 private
200199
201200 attr_reader :previous_temp_objects
201+
202202 def temp_object = ( temp_object )
203203 previous_temp_objects . push ( @temp_object ) if @temp_object
204204 @temp_object = temp_object
@@ -215,6 +215,5 @@ def clear_analyser_cache
215215 def run ( command , opts )
216216 shell . run ( command , opts )
217217 end
218-
219218 end
220219end
0 commit comments