dragonfly 0.9.15 → 1.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of dragonfly might be problematic. Click here for more details.

Files changed (203) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +1 -8
  3. data/.travis.yml +11 -0
  4. data/Gemfile +1 -0
  5. data/History.md +52 -2
  6. data/LICENSE +1 -1
  7. data/README.md +38 -95
  8. data/dev/grid.jpg +0 -0
  9. data/dev/irbrc.rb +27 -0
  10. data/dev/rails_template.rb +38 -0
  11. data/dev/test.ru +56 -0
  12. data/dev/test_rails +19 -0
  13. data/dragonfly.gemspec +3 -21
  14. data/lib/dragonfly.rb +45 -44
  15. data/lib/dragonfly/app.rb +175 -96
  16. data/lib/dragonfly/configurable.rb +71 -170
  17. data/lib/dragonfly/content.rb +211 -0
  18. data/lib/dragonfly/core_ext/object.rb +1 -6
  19. data/lib/dragonfly/file_data_store.rb +197 -0
  20. data/lib/dragonfly/image_magick/analysers/image_properties.rb +23 -0
  21. data/lib/dragonfly/image_magick/generators/convert.rb +19 -0
  22. data/lib/dragonfly/image_magick/generators/plain.rb +26 -0
  23. data/lib/dragonfly/image_magick/generators/plasma.rb +25 -0
  24. data/lib/dragonfly/image_magick/generators/text.rb +127 -0
  25. data/lib/dragonfly/image_magick/plugin.rb +83 -0
  26. data/lib/dragonfly/image_magick/processors/convert.rb +29 -0
  27. data/lib/dragonfly/image_magick/processors/encode.rb +18 -0
  28. data/lib/dragonfly/image_magick/processors/thumb.rb +76 -0
  29. data/lib/dragonfly/job.rb +118 -134
  30. data/lib/dragonfly/job_endpoint.rb +2 -0
  31. data/lib/dragonfly/memory_data_store.rb +34 -0
  32. data/lib/dragonfly/middleware.rb +5 -3
  33. data/lib/dragonfly/{active_model_extensions.rb → model.rb} +5 -3
  34. data/lib/dragonfly/{active_model_extensions → model}/attachment.rb +40 -35
  35. data/lib/dragonfly/{active_model_extensions → model}/attachment_class_methods.rb +36 -40
  36. data/lib/dragonfly/model/class_methods.rb +109 -0
  37. data/lib/dragonfly/{active_model_extensions → model}/instance_methods.rb +2 -2
  38. data/lib/dragonfly/{active_model_extensions → model}/validations.rb +17 -12
  39. data/lib/dragonfly/railtie.rb +8 -6
  40. data/lib/dragonfly/register.rb +27 -0
  41. data/lib/dragonfly/response.rb +47 -52
  42. data/lib/dragonfly/routed_endpoint.rb +4 -0
  43. data/lib/dragonfly/serializer.rb +15 -5
  44. data/lib/dragonfly/server.rb +56 -29
  45. data/lib/dragonfly/shell.rb +12 -23
  46. data/lib/dragonfly/spec/data_store_examples.rb +64 -0
  47. data/lib/dragonfly/temp_object.rb +32 -47
  48. data/lib/dragonfly/url_attributes.rb +19 -22
  49. data/lib/dragonfly/url_mapper.rb +3 -0
  50. data/lib/dragonfly/utils.rb +12 -0
  51. data/lib/dragonfly/version.rb +1 -1
  52. data/lib/dragonfly/whitelist.rb +19 -0
  53. data/lib/rails/generators/dragonfly/USAGE +8 -0
  54. data/lib/rails/generators/dragonfly/dragonfly_generator.rb +24 -0
  55. data/lib/rails/generators/dragonfly/templates/initializer.rb.erb +27 -0
  56. data/samples/gif.gif +0 -0
  57. data/spec/dragonfly/app_spec.rb +270 -64
  58. data/spec/dragonfly/configurable_spec.rb +142 -418
  59. data/spec/dragonfly/content_spec.rb +353 -0
  60. data/spec/dragonfly/cookie_monster_spec.rb +2 -1
  61. data/spec/dragonfly/file_data_store_spec.rb +301 -0
  62. data/spec/dragonfly/image_magick/analysers/image_properties_spec.rb +20 -0
  63. data/spec/dragonfly/image_magick/generators/convert_spec.rb +19 -0
  64. data/spec/dragonfly/image_magick/generators/plain_spec.rb +50 -0
  65. data/spec/dragonfly/image_magick/generators/plasma_spec.rb +32 -0
  66. data/spec/dragonfly/image_magick/generators/text_spec.rb +77 -0
  67. data/spec/dragonfly/image_magick/plugin_spec.rb +131 -0
  68. data/spec/dragonfly/image_magick/processors/convert_spec.rb +56 -0
  69. data/spec/dragonfly/image_magick/processors/thumb_spec.rb +173 -0
  70. data/spec/dragonfly/job_endpoint_spec.rb +30 -73
  71. data/spec/dragonfly/job_spec.rb +280 -608
  72. data/spec/dragonfly/memory_data_store_spec.rb +20 -0
  73. data/spec/dragonfly/middleware_spec.rb +47 -27
  74. data/spec/dragonfly/{active_model_extensions → model}/model_spec.rb +331 -555
  75. data/spec/dragonfly/model/validations_spec.rb +196 -0
  76. data/spec/dragonfly/register_spec.rb +35 -0
  77. data/spec/dragonfly/routed_endpoint_spec.rb +6 -6
  78. data/spec/dragonfly/serializer_spec.rb +13 -15
  79. data/spec/dragonfly/server_spec.rb +122 -46
  80. data/spec/dragonfly/shell_spec.rb +43 -24
  81. data/spec/dragonfly/temp_object_spec.rb +69 -94
  82. data/spec/dragonfly/url_attributes_spec.rb +49 -0
  83. data/spec/dragonfly/utils_spec.rb +32 -0
  84. data/spec/dragonfly/whitelist_spec.rb +30 -0
  85. data/spec/dragonfly_spec.rb +43 -0
  86. data/spec/fixtures/deprecated_stored_content/eggs.bonus +1 -0
  87. data/spec/fixtures/deprecated_stored_content/eggs.bonus.meta +1 -0
  88. data/spec/functional/configuration_spec.rb +19 -0
  89. data/spec/functional/model_urls_spec.rb +43 -41
  90. data/spec/functional/remote_on_the_fly_spec.rb +14 -16
  91. data/spec/functional/shell_commands_spec.rb +24 -14
  92. data/spec/functional/to_response_spec.rb +10 -10
  93. data/spec/functional/urls_spec.rb +5 -3
  94. data/spec/spec_helper.rb +23 -28
  95. data/spec/support/argument_matchers.rb +7 -8
  96. data/spec/support/image_matchers.rb +14 -36
  97. data/spec/support/model_helpers.rb +97 -0
  98. data/spec/support/simple_matchers.rb +12 -0
  99. metadata +92 -393
  100. data/.yardopts +0 -29
  101. data/Rakefile +0 -36
  102. data/config.ru +0 -14
  103. data/docs.watchr +0 -1
  104. data/extra_docs/Analysers.md +0 -68
  105. data/extra_docs/Caching.md +0 -23
  106. data/extra_docs/Configuration.md +0 -149
  107. data/extra_docs/Couch.md +0 -49
  108. data/extra_docs/DataStorage.md +0 -226
  109. data/extra_docs/Encoding.md +0 -67
  110. data/extra_docs/ExampleUseCases.md +0 -116
  111. data/extra_docs/GeneralUsage.md +0 -105
  112. data/extra_docs/Generators.md +0 -68
  113. data/extra_docs/Heroku.md +0 -50
  114. data/extra_docs/ImageMagick.md +0 -136
  115. data/extra_docs/Index.md +0 -33
  116. data/extra_docs/MimeTypes.md +0 -40
  117. data/extra_docs/Models.md +0 -441
  118. data/extra_docs/Mongo.md +0 -42
  119. data/extra_docs/Processing.md +0 -77
  120. data/extra_docs/Rack.md +0 -52
  121. data/extra_docs/Rails2.md +0 -57
  122. data/extra_docs/Rails3.md +0 -56
  123. data/extra_docs/ServingRemotely.md +0 -104
  124. data/extra_docs/Sinatra.md +0 -25
  125. data/extra_docs/URLs.md +0 -203
  126. data/features/images.feature +0 -47
  127. data/features/no_processing.feature +0 -14
  128. data/features/rails.feature +0 -8
  129. data/features/steps/common_steps.rb +0 -8
  130. data/features/steps/dragonfly_steps.rb +0 -66
  131. data/features/steps/rails_steps.rb +0 -40
  132. data/features/support/env.rb +0 -13
  133. data/features/support/setup.rb +0 -41
  134. data/fixtures/rails/files/app/models/album.rb +0 -6
  135. data/fixtures/rails/files/app/views/albums/new.html.erb +0 -7
  136. data/fixtures/rails/files/app/views/albums/show.html.erb +0 -6
  137. data/fixtures/rails/files/config/initializers/dragonfly.rb +0 -4
  138. data/fixtures/rails/files/features/manage_album_images.feature +0 -38
  139. data/fixtures/rails/files/features/step_definitions/helper_steps.rb +0 -7
  140. data/fixtures/rails/files/features/step_definitions/image_steps.rb +0 -25
  141. data/fixtures/rails/files/features/step_definitions/web_steps.rb +0 -189
  142. data/fixtures/rails/files/features/support/paths.rb +0 -17
  143. data/fixtures/rails/files/features/text_images.feature +0 -7
  144. data/fixtures/rails/template.rb +0 -20
  145. data/irbrc.rb +0 -19
  146. data/lib/dragonfly/active_model_extensions/class_methods.rb +0 -98
  147. data/lib/dragonfly/analyser.rb +0 -58
  148. data/lib/dragonfly/analysis/file_command_analyser.rb +0 -33
  149. data/lib/dragonfly/analysis/image_magick_analyser.rb +0 -6
  150. data/lib/dragonfly/config/heroku.rb +0 -26
  151. data/lib/dragonfly/config/image_magick.rb +0 -6
  152. data/lib/dragonfly/config/rails.rb +0 -20
  153. data/lib/dragonfly/data_storage.rb +0 -11
  154. data/lib/dragonfly/data_storage/couch_data_store.rb +0 -83
  155. data/lib/dragonfly/data_storage/file_data_store.rb +0 -144
  156. data/lib/dragonfly/data_storage/mongo_data_store.rb +0 -96
  157. data/lib/dragonfly/data_storage/s3data_store.rb +0 -168
  158. data/lib/dragonfly/encoder.rb +0 -13
  159. data/lib/dragonfly/encoding/image_magick_encoder.rb +0 -6
  160. data/lib/dragonfly/function_manager.rb +0 -67
  161. data/lib/dragonfly/generation/image_magick_generator.rb +0 -6
  162. data/lib/dragonfly/generator.rb +0 -9
  163. data/lib/dragonfly/image_magick/analyser.rb +0 -53
  164. data/lib/dragonfly/image_magick/config.rb +0 -44
  165. data/lib/dragonfly/image_magick/encoder.rb +0 -57
  166. data/lib/dragonfly/image_magick/generator.rb +0 -147
  167. data/lib/dragonfly/image_magick/processor.rb +0 -114
  168. data/lib/dragonfly/image_magick/utils.rb +0 -46
  169. data/lib/dragonfly/image_magick_utils.rb +0 -4
  170. data/lib/dragonfly/job_builder.rb +0 -39
  171. data/lib/dragonfly/job_definitions.rb +0 -30
  172. data/lib/dragonfly/loggable.rb +0 -28
  173. data/lib/dragonfly/processing/image_magick_processor.rb +0 -6
  174. data/lib/dragonfly/processor.rb +0 -9
  175. data/lib/dragonfly/rails/images.rb +0 -32
  176. data/lib/dragonfly/simple_cache.rb +0 -23
  177. data/spec/dragonfly/active_model_extensions/spec_helper.rb +0 -95
  178. data/spec/dragonfly/analyser_spec.rb +0 -123
  179. data/spec/dragonfly/analysis/file_command_analyser_spec.rb +0 -49
  180. data/spec/dragonfly/data_storage/couch_data_store_spec.rb +0 -84
  181. data/spec/dragonfly/data_storage/file_data_store_spec.rb +0 -308
  182. data/spec/dragonfly/data_storage/mongo_data_store_spec.rb +0 -81
  183. data/spec/dragonfly/data_storage/s3_data_store_spec.rb +0 -277
  184. data/spec/dragonfly/data_storage/shared_data_store_examples.rb +0 -77
  185. data/spec/dragonfly/function_manager_spec.rb +0 -154
  186. data/spec/dragonfly/image_magick/analyser_spec.rb +0 -73
  187. data/spec/dragonfly/image_magick/encoder_spec.rb +0 -46
  188. data/spec/dragonfly/image_magick/generator_spec.rb +0 -178
  189. data/spec/dragonfly/image_magick/processor_spec.rb +0 -293
  190. data/spec/dragonfly/job_builder_spec.rb +0 -37
  191. data/spec/dragonfly/job_definitions_spec.rb +0 -57
  192. data/spec/dragonfly/loggable_spec.rb +0 -80
  193. data/spec/dragonfly/simple_cache_spec.rb +0 -27
  194. data/spec/dragonfly/url_attributes.rb +0 -47
  195. data/spec/functional/deprecations_spec.rb +0 -51
  196. data/spec/functional/image_magick_app_spec.rb +0 -27
  197. data/spec/test_imagemagick.ru +0 -49
  198. data/yard/handlers/configurable_attr_handler.rb +0 -38
  199. data/yard/setup.rb +0 -15
  200. data/yard/templates/default/fulldoc/html/css/common.css +0 -109
  201. data/yard/templates/default/layout/html/layout.erb +0 -93
  202. data/yard/templates/default/module/html/configuration_summary.erb +0 -31
  203. data/yard/templates/default/module/setup.rb +0 -17
@@ -1,57 +0,0 @@
1
- module Dragonfly
2
- module ImageMagick
3
- class Encoder
4
-
5
- include Configurable
6
- include Utils
7
-
8
- configurable_attr :supported_formats, [
9
- :ai,
10
- :bmp,
11
- :eps,
12
- :gif,
13
- :gif87,
14
- :ico,
15
- :j2c,
16
- :jp2,
17
- :jpeg,
18
- :jpg,
19
- :pbm,
20
- :pcd,
21
- :pct,
22
- :pcx,
23
- :pdf,
24
- :pict,
25
- :pjpeg,
26
- :png,
27
- :png24,
28
- :png32,
29
- :png8,
30
- :pnm,
31
- :ppm,
32
- :ps,
33
- :psd,
34
- :ras,
35
- :tga,
36
- :tiff,
37
- :wbmp,
38
- :xbm,
39
- :xpm,
40
- :xwd
41
- ]
42
-
43
- def encode(temp_object, format, args='')
44
- format = format.to_s.downcase
45
- throw :unable_to_handle unless supported_formats.include?(format.to_sym)
46
- details = identify(temp_object)
47
-
48
- if details[:format] == format.to_sym && args.empty?
49
- temp_object
50
- else
51
- convert(temp_object, args, format)
52
- end
53
- end
54
-
55
- end
56
- end
57
- end
@@ -1,147 +0,0 @@
1
- module Dragonfly
2
- module ImageMagick
3
- class Generator
4
-
5
- FONT_STYLES = {
6
- 'normal' => 'normal',
7
- 'italic' => 'italic',
8
- 'oblique' => 'oblique'
9
- }
10
-
11
- FONT_STRETCHES = {
12
- 'normal' => 'normal',
13
- 'semi-condensed' => 'semi-condensed',
14
- 'condensed' => 'condensed',
15
- 'extra-condensed' => 'extra-condensed',
16
- 'ultra-condensed' => 'ultra-condensed',
17
- 'semi-expanded' => 'semi-expanded',
18
- 'expanded' => 'expanded',
19
- 'extra-expanded' => 'extra-expanded',
20
- 'ultra-expanded' => 'ultra-expanded'
21
- }
22
-
23
- FONT_WEIGHTS = {
24
- 'normal' => 'normal',
25
- 'bold' => 'bold',
26
- 'bolder' => 'bolder',
27
- 'lighter' => 'lighter',
28
- '100' => 100,
29
- '200' => 200,
30
- '300' => 300,
31
- '400' => 400,
32
- '500' => 500,
33
- '600' => 600,
34
- '700' => 700,
35
- '800' => 800,
36
- '900' => 900
37
- }
38
-
39
- include Configurable
40
- include Utils
41
-
42
- def plain(width, height, colour, opts={})
43
- opts = Dragonfly::Utils.symbolize_keys(opts)
44
-
45
- format = opts[:format] || 'png'
46
- [
47
- convert(nil, "-size #{width}x#{height} xc:#{colour}", format),
48
- {:format => format.to_sym, :name => "plain.#{format}"}
49
- ]
50
- end
51
-
52
- def plasma(width, height, format='png')
53
- [
54
- convert(nil, "-size #{width}x#{height} plasma:fractal", format),
55
- {:format => format.to_sym, :name => "plasma.#{format}"}
56
- ]
57
- end
58
-
59
- def text(string, opts={})
60
- opts = HashWithCssStyleKeys[opts]
61
- args = []
62
- format = (opts[:format] || :png)
63
- background = opts[:background_color] || 'none'
64
- font_size = (opts[:font_size] || 12).to_i
65
- escaped_string = "\"#{string.gsub(/"/, '\"')}\""
66
-
67
- # Settings
68
- args.push("-gravity NorthWest")
69
- args.push("-antialias")
70
- args.push("-pointsize #{font_size}")
71
- args.push("-font \"#{opts[:font]}\"") if opts[:font]
72
- args.push("-family '#{opts[:font_family]}'") if opts[:font_family]
73
- args.push("-fill #{opts[:color]}") if opts[:color]
74
- args.push("-stroke #{opts[:stroke_color]}") if opts[:stroke_color]
75
- args.push("-style #{FONT_STYLES[opts[:font_style]]}") if opts[:font_style]
76
- args.push("-stretch #{FONT_STRETCHES[opts[:font_stretch]]}") if opts[:font_stretch]
77
- args.push("-weight #{FONT_WEIGHTS[opts[:font_weight]]}") if opts[:font_weight]
78
- args.push("-background #{background}")
79
- args.push("label:#{escaped_string}")
80
-
81
- # Padding
82
- pt, pr, pb, pl = parse_padding_string(opts[:padding]) if opts[:padding]
83
- padding_top = (opts[:padding_top] || pt || 0)
84
- padding_right = (opts[:padding_right] || pr || 0)
85
- padding_bottom = (opts[:padding_bottom] || pb || 0)
86
- padding_left = (opts[:padding_left] || pl || 0)
87
-
88
- tempfile = convert(nil, args.join(' '), format)
89
-
90
- if (padding_top || padding_right || padding_bottom || padding_left)
91
- attrs = identify(tempfile)
92
- text_width = attrs[:width].to_i
93
- text_height = attrs[:height].to_i
94
- width = padding_left + text_width + padding_right
95
- height = padding_top + text_height + padding_bottom
96
-
97
- args = args.slice(0, args.length - 2)
98
- args.push("-size #{width}x#{height}")
99
- args.push("xc:#{background}")
100
- args.push("-annotate 0x0+#{padding_left}+#{padding_top} #{escaped_string}")
101
- run convert_command, "#{args.join(' ')} #{quote tempfile.path}"
102
- end
103
-
104
- [
105
- tempfile,
106
- {:format => format, :name => "text.#{format}"}
107
- ]
108
- end
109
-
110
- private
111
-
112
- # Use css-style padding declaration, i.e.
113
- # 10 (all sides)
114
- # 10 5 (top/bottom, left/right)
115
- # 10 5 10 (top, left/right, bottom)
116
- # 10 5 10 5 (top, right, bottom, left)
117
- def parse_padding_string(str)
118
- padding_parts = str.gsub('px','').split(/\s+/).map{|px| px.to_i}
119
- case padding_parts.size
120
- when 1
121
- p = padding_parts.first
122
- [p,p,p,p]
123
- when 2
124
- p,q = padding_parts
125
- [p,q,p,q]
126
- when 3
127
- p,q,r = padding_parts
128
- [p,q,r,q]
129
- when 4
130
- padding_parts
131
- else raise ArgumentError, "Couldn't parse padding string '#{str}' - should be a css-style string"
132
- end
133
- end
134
-
135
- def scale_factor_for(font_size)
136
- # Scale approximately to 64 if below
137
- min_size = 64
138
- if font_size < min_size
139
- (min_size.to_f / font_size).ceil
140
- else
141
- 1
142
- end.to_f
143
- end
144
-
145
- end
146
- end
147
- end
@@ -1,114 +0,0 @@
1
- module Dragonfly
2
- module ImageMagick
3
- class Processor
4
-
5
- GRAVITIES = {
6
- 'nw' => 'NorthWest',
7
- 'n' => 'North',
8
- 'ne' => 'NorthEast',
9
- 'w' => 'West',
10
- 'c' => 'Center',
11
- 'e' => 'East',
12
- 'sw' => 'SouthWest',
13
- 's' => 'South',
14
- 'se' => 'SouthEast'
15
- }
16
-
17
- # Geometry string patterns
18
- RESIZE_GEOMETRY = /^\d*x\d*[><%^!]?$|^\d+@$/ # e.g. '300x200!'
19
- CROPPED_RESIZE_GEOMETRY = /^(\d+)x(\d+)#(\w{1,2})?$/ # e.g. '20x50#ne'
20
- CROP_GEOMETRY = /^(\d+)x(\d+)([+-]\d+)?([+-]\d+)?(\w{1,2})?$/ # e.g. '30x30+10+10'
21
- THUMB_GEOMETRY = Regexp.union RESIZE_GEOMETRY, CROPPED_RESIZE_GEOMETRY, CROP_GEOMETRY
22
-
23
- include Configurable
24
- include Utils
25
-
26
- def resize(temp_object, geometry)
27
- convert(temp_object, "-resize #{geometry}")
28
- end
29
-
30
- def auto_orient(temp_object)
31
- convert(temp_object, "-auto-orient")
32
- end
33
-
34
- def crop(temp_object, opts={})
35
- opts = Dragonfly::Utils.symbolize_keys(opts)
36
-
37
- width = opts[:width]
38
- height = opts[:height]
39
- gravity = GRAVITIES[opts[:gravity]]
40
- x = "#{opts[:x] || 0}"
41
- x = '+' + x unless x[/^[+-]/]
42
- y = "#{opts[:y] || 0}"
43
- y = '+' + y unless y[/^[+-]/]
44
- repage = opts[:repage] == false ? '' : '+repage'
45
- resize = opts[:resize]
46
-
47
- convert(temp_object, "#{"-resize #{resize} " if resize}#{"-gravity #{gravity} " if gravity}-crop #{width}x#{height}#{x}#{y} #{repage}")
48
- end
49
-
50
- def flip(temp_object)
51
- convert(temp_object, "-flip")
52
- end
53
-
54
- def flop(temp_object)
55
- convert(temp_object, "-flop")
56
- end
57
-
58
- def greyscale(temp_object)
59
- convert(temp_object, "-colorspace Gray")
60
- end
61
- alias grayscale greyscale
62
-
63
- def resize_and_crop(temp_object, opts={})
64
- opts = Dragonfly::Utils.symbolize_keys(opts)
65
-
66
- if !opts[:width] && !opts[:height]
67
- return temp_object
68
- elsif !opts[:width] || !opts[:height]
69
- attrs = identify(temp_object)
70
- opts[:width] ||= attrs[:width]
71
- opts[:height] ||= attrs[:height]
72
- end
73
-
74
- opts[:gravity] ||= 'c'
75
-
76
- opts[:resize] = "#{opts[:width]}x#{opts[:height]}^^"
77
- crop(temp_object, opts)
78
- end
79
-
80
- def rotate(temp_object, amount, opts={})
81
- opts = Dragonfly::Utils.symbolize_keys(opts)
82
-
83
- convert(temp_object, "-rotate #{amount}#{opts[:qualifier]}")
84
- end
85
-
86
- def strip(temp_object)
87
- convert(temp_object, "-strip")
88
- end
89
-
90
- def thumb(temp_object, geometry)
91
- case geometry
92
- when RESIZE_GEOMETRY
93
- resize(temp_object, geometry)
94
- when CROPPED_RESIZE_GEOMETRY
95
- resize_and_crop(temp_object, 'width' => $1, 'height' => $2, 'gravity' => $3)
96
- when CROP_GEOMETRY
97
- crop(temp_object,
98
- 'width' => $1,
99
- 'height' => $2,
100
- 'x' => $3,
101
- 'y' => $4,
102
- 'gravity' => $5
103
- )
104
- else raise ArgumentError, "Didn't recognise the geometry string #{geometry}"
105
- end
106
- end
107
-
108
- def convert(temp_object, args='', format=nil)
109
- format ? [super, {:format => format.to_sym}] : super
110
- end
111
-
112
- end
113
- end
114
- end
@@ -1,46 +0,0 @@
1
- require 'tempfile'
2
-
3
- module Dragonfly
4
- module ImageMagick
5
- module Utils
6
-
7
- include Shell
8
- include Loggable
9
- include Configurable
10
- configurable_attr :convert_command, "convert"
11
- configurable_attr :identify_command, "identify"
12
-
13
- private
14
-
15
- def convert(temp_object=nil, args='', format=nil)
16
- tempfile = new_tempfile(format)
17
- run convert_command, %(#{quote(temp_object.path) if temp_object} #{args} #{quote(tempfile.path)})
18
- tempfile
19
- end
20
-
21
- def identify(temp_object)
22
- # example of details string:
23
- # myimage.png PNG 200x100 200x100+0+0 8-bit DirectClass 31.2kb
24
- format, width, height, depth = raw_identify(temp_object).scan(/([A-Z0-9]+) (\d+)x(\d+) .+ (\d+)-bit/)[0]
25
- {
26
- :format => format.downcase.to_sym,
27
- :width => width.to_i,
28
- :height => height.to_i,
29
- :depth => depth.to_i
30
- }
31
- end
32
-
33
- def raw_identify(temp_object, args='')
34
- run identify_command, "#{args} #{quote(temp_object.path)}"
35
- end
36
-
37
- def new_tempfile(ext=nil)
38
- tempfile = ext ? Tempfile.new(['dragonfly', ".#{ext}"]) : Tempfile.new('dragonfly')
39
- tempfile.binmode
40
- tempfile.close
41
- tempfile
42
- end
43
-
44
- end
45
- end
46
- end
@@ -1,4 +0,0 @@
1
- module Dragonfly
2
- puts "WARNING: Dragonfly::ImageMagickUtils is DEPRECATED and will soon be removed. Please use Dragonfly::ImageMagick::Utils instead."
3
- ImageMagickUtils = ImageMagick::Utils
4
- end
@@ -1,39 +0,0 @@
1
- module Dragonfly
2
- class JobBuilder
3
-
4
- def initialize(&block)
5
- @block = block
6
- end
7
-
8
- def build(job, *args)
9
- evaluate_block(job, false, *args)
10
- end
11
-
12
- def build!(job, *args)
13
- evaluate_block(job, true, *args)
14
- end
15
-
16
- Job.step_names.each do |step|
17
-
18
- # fetch, process, etc.
19
- define_method step do |*args|
20
- if @perform_with_bangs
21
- @job.send("#{step}!", *args)
22
- else
23
- @job = @job.send(step, *args)
24
- end
25
- end
26
-
27
- end
28
-
29
- private
30
-
31
- def evaluate_block(job, perform_with_bangs, *args)
32
- @job = job
33
- @perform_with_bangs = perform_with_bangs
34
- instance_exec(*args, &@block)
35
- @job
36
- end
37
-
38
- end
39
- end
@@ -1,30 +0,0 @@
1
- module Dragonfly
2
- class JobDefinitions < Module
3
-
4
- def initialize
5
- @job_definitions = {}
6
- end
7
-
8
- def add(name, &definition_proc)
9
- job_definitions[name] = JobBuilder.new(&definition_proc)
10
- jd = job_definitions # Needed because we're about to change 'self'
11
-
12
- define_method name do |*args|
13
- jd[name].build(self, *args)
14
- end
15
-
16
- define_method "#{name}!" do |*args|
17
- jd[name].build!(self, *args)
18
- end
19
- end
20
-
21
- def definition_names
22
- job_definitions.keys
23
- end
24
-
25
- private
26
-
27
- attr_reader :job_definitions
28
-
29
- end
30
- end
@@ -1,28 +0,0 @@
1
- require 'logger'
2
-
3
- module Dragonfly
4
- module Loggable
5
-
6
- def log
7
- case @log_object
8
- when nil
9
- @log_object = Logger.new($stdout)
10
- when Proc
11
- @log_object[]
12
- when Logger
13
- @log_object
14
- end
15
- end
16
-
17
- def log=(object)
18
- @log_object = object
19
- end
20
-
21
- attr_reader :log_object
22
-
23
- def use_same_log_as(object)
24
- self.log = proc{ object.log }
25
- end
26
-
27
- end
28
- end