fog-dragonfly 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. data/.specopts +2 -0
  2. data/.yardopts +23 -0
  3. data/Gemfile +23 -0
  4. data/Gemfile.rails.2.3.5 +14 -0
  5. data/History.md +266 -0
  6. data/LICENSE +20 -0
  7. data/README.md +88 -0
  8. data/Rakefile +92 -0
  9. data/VERSION +1 -0
  10. data/config.ru +13 -0
  11. data/docs.watchr +1 -0
  12. data/dragonfly.gemspec +293 -0
  13. data/extra_docs/Analysers.md +108 -0
  14. data/extra_docs/Caching.md +23 -0
  15. data/extra_docs/Configuration.md +138 -0
  16. data/extra_docs/DataStorage.md +136 -0
  17. data/extra_docs/Encoding.md +96 -0
  18. data/extra_docs/GeneralUsage.md +121 -0
  19. data/extra_docs/Generators.md +102 -0
  20. data/extra_docs/Heroku.md +50 -0
  21. data/extra_docs/Index.md +36 -0
  22. data/extra_docs/MimeTypes.md +40 -0
  23. data/extra_docs/Models.md +266 -0
  24. data/extra_docs/Mongo.md +45 -0
  25. data/extra_docs/Processing.md +130 -0
  26. data/extra_docs/Rack.md +52 -0
  27. data/extra_docs/Rails2.md +55 -0
  28. data/extra_docs/Rails3.md +62 -0
  29. data/extra_docs/Sinatra.md +25 -0
  30. data/extra_docs/URLs.md +169 -0
  31. data/features/3.0.3.feature +8 -0
  32. data/features/images.feature +47 -0
  33. data/features/no_processing.feature +14 -0
  34. data/features/rails_2.3.5.feature +7 -0
  35. data/features/steps/common_steps.rb +8 -0
  36. data/features/steps/dragonfly_steps.rb +66 -0
  37. data/features/steps/rails_steps.rb +39 -0
  38. data/features/support/env.rb +40 -0
  39. data/fixtures/files/app/models/album.rb +3 -0
  40. data/fixtures/files/app/views/albums/new.html.erb +4 -0
  41. data/fixtures/files/app/views/albums/show.html.erb +4 -0
  42. data/fixtures/files/config/initializers/dragonfly.rb +4 -0
  43. data/fixtures/files/features/manage_album_images.feature +12 -0
  44. data/fixtures/files/features/step_definitions/image_steps.rb +15 -0
  45. data/fixtures/files/features/support/paths.rb +15 -0
  46. data/fixtures/files/features/text_images.feature +7 -0
  47. data/fixtures/rails_2.3.5/template.rb +10 -0
  48. data/fixtures/rails_3.0.3/template.rb +20 -0
  49. data/irbrc.rb +17 -0
  50. data/lib/dragonfly.rb +45 -0
  51. data/lib/dragonfly/active_model_extensions.rb +13 -0
  52. data/lib/dragonfly/active_model_extensions/attachment.rb +169 -0
  53. data/lib/dragonfly/active_model_extensions/class_methods.rb +45 -0
  54. data/lib/dragonfly/active_model_extensions/instance_methods.rb +28 -0
  55. data/lib/dragonfly/active_model_extensions/validations.rb +37 -0
  56. data/lib/dragonfly/analyser.rb +59 -0
  57. data/lib/dragonfly/analysis/file_command_analyser.rb +32 -0
  58. data/lib/dragonfly/analysis/image_magick_analyser.rb +47 -0
  59. data/lib/dragonfly/analysis/r_magick_analyser.rb +63 -0
  60. data/lib/dragonfly/app.rb +182 -0
  61. data/lib/dragonfly/config/heroku.rb +19 -0
  62. data/lib/dragonfly/config/image_magick.rb +41 -0
  63. data/lib/dragonfly/config/r_magick.rb +46 -0
  64. data/lib/dragonfly/config/rails.rb +17 -0
  65. data/lib/dragonfly/configurable.rb +119 -0
  66. data/lib/dragonfly/core_ext/object.rb +8 -0
  67. data/lib/dragonfly/core_ext/string.rb +9 -0
  68. data/lib/dragonfly/core_ext/symbol.rb +9 -0
  69. data/lib/dragonfly/data_storage.rb +9 -0
  70. data/lib/dragonfly/data_storage/file_data_store.rb +114 -0
  71. data/lib/dragonfly/data_storage/mongo_data_store.rb +82 -0
  72. data/lib/dragonfly/data_storage/s3data_store.rb +115 -0
  73. data/lib/dragonfly/encoder.rb +13 -0
  74. data/lib/dragonfly/encoding/image_magick_encoder.rb +57 -0
  75. data/lib/dragonfly/encoding/r_magick_encoder.rb +61 -0
  76. data/lib/dragonfly/function_manager.rb +69 -0
  77. data/lib/dragonfly/generation/hash_with_css_style_keys.rb +23 -0
  78. data/lib/dragonfly/generation/image_magick_generator.rb +140 -0
  79. data/lib/dragonfly/generation/r_magick_generator.rb +155 -0
  80. data/lib/dragonfly/generator.rb +9 -0
  81. data/lib/dragonfly/image_magick_utils.rb +81 -0
  82. data/lib/dragonfly/job.rb +371 -0
  83. data/lib/dragonfly/job_builder.rb +39 -0
  84. data/lib/dragonfly/job_definitions.rb +26 -0
  85. data/lib/dragonfly/job_endpoint.rb +15 -0
  86. data/lib/dragonfly/loggable.rb +28 -0
  87. data/lib/dragonfly/middleware.rb +34 -0
  88. data/lib/dragonfly/processing/image_magick_processor.rb +99 -0
  89. data/lib/dragonfly/processing/r_magick_processor.rb +126 -0
  90. data/lib/dragonfly/processor.rb +9 -0
  91. data/lib/dragonfly/r_magick_utils.rb +48 -0
  92. data/lib/dragonfly/rails/images.rb +22 -0
  93. data/lib/dragonfly/response.rb +82 -0
  94. data/lib/dragonfly/routed_endpoint.rb +40 -0
  95. data/lib/dragonfly/serializer.rb +32 -0
  96. data/lib/dragonfly/simple_cache.rb +23 -0
  97. data/lib/dragonfly/simple_endpoint.rb +63 -0
  98. data/lib/dragonfly/temp_object.rb +220 -0
  99. data/samples/beach.png +0 -0
  100. data/samples/egg.png +0 -0
  101. data/samples/round.gif +0 -0
  102. data/samples/sample.docx +0 -0
  103. data/samples/taj.jpg +0 -0
  104. data/spec/argument_matchers.rb +19 -0
  105. data/spec/dragonfly/active_model_extensions/active_model_setup.rb +97 -0
  106. data/spec/dragonfly/active_model_extensions/active_record_setup.rb +85 -0
  107. data/spec/dragonfly/active_model_extensions/model_spec.rb +723 -0
  108. data/spec/dragonfly/active_model_extensions/spec_helper.rb +11 -0
  109. data/spec/dragonfly/analyser_spec.rb +123 -0
  110. data/spec/dragonfly/analysis/file_command_analyser_spec.rb +57 -0
  111. data/spec/dragonfly/analysis/image_magick_analyser_spec.rb +15 -0
  112. data/spec/dragonfly/analysis/r_magick_analyser_spec.rb +27 -0
  113. data/spec/dragonfly/analysis/shared_analyser_spec.rb +51 -0
  114. data/spec/dragonfly/app_spec.rb +280 -0
  115. data/spec/dragonfly/config/r_magick_spec.rb +25 -0
  116. data/spec/dragonfly/configurable_spec.rb +220 -0
  117. data/spec/dragonfly/core_ext/string_spec.rb +17 -0
  118. data/spec/dragonfly/core_ext/symbol_spec.rb +17 -0
  119. data/spec/dragonfly/data_storage/data_store_spec.rb +76 -0
  120. data/spec/dragonfly/data_storage/file_data_store_spec.rb +169 -0
  121. data/spec/dragonfly/data_storage/mongo_data_store_spec.rb +38 -0
  122. data/spec/dragonfly/data_storage/s3_data_store_spec.rb +94 -0
  123. data/spec/dragonfly/deprecation_spec.rb +20 -0
  124. data/spec/dragonfly/encoding/image_magick_encoder_spec.rb +41 -0
  125. data/spec/dragonfly/encoding/r_magick_encoder_spec.rb +37 -0
  126. data/spec/dragonfly/function_manager_spec.rb +154 -0
  127. data/spec/dragonfly/generation/hash_with_css_style_keys_spec.rb +24 -0
  128. data/spec/dragonfly/generation/image_magick_generator_spec.rb +12 -0
  129. data/spec/dragonfly/generation/r_magick_generator_spec.rb +24 -0
  130. data/spec/dragonfly/generation/shared_generator_spec.rb +91 -0
  131. data/spec/dragonfly/image_magick_utils_spec.rb +16 -0
  132. data/spec/dragonfly/job_builder_spec.rb +37 -0
  133. data/spec/dragonfly/job_definitions_spec.rb +35 -0
  134. data/spec/dragonfly/job_endpoint_spec.rb +120 -0
  135. data/spec/dragonfly/job_spec.rb +773 -0
  136. data/spec/dragonfly/loggable_spec.rb +80 -0
  137. data/spec/dragonfly/middleware_spec.rb +68 -0
  138. data/spec/dragonfly/processing/image_magick_processor_spec.rb +29 -0
  139. data/spec/dragonfly/processing/r_magick_processor_spec.rb +26 -0
  140. data/spec/dragonfly/processing/shared_processing_spec.rb +215 -0
  141. data/spec/dragonfly/routed_endpoint_spec.rb +48 -0
  142. data/spec/dragonfly/serializer_spec.rb +61 -0
  143. data/spec/dragonfly/simple_cache_spec.rb +27 -0
  144. data/spec/dragonfly/simple_endpoint_spec.rb +89 -0
  145. data/spec/dragonfly/temp_object_spec.rb +352 -0
  146. data/spec/image_matchers.rb +47 -0
  147. data/spec/simple_matchers.rb +44 -0
  148. data/spec/spec_helper.rb +58 -0
  149. data/yard/handlers/configurable_attr_handler.rb +38 -0
  150. data/yard/setup.rb +15 -0
  151. data/yard/templates/default/fulldoc/html/css/common.css +107 -0
  152. data/yard/templates/default/layout/html/layout.erb +87 -0
  153. data/yard/templates/default/module/html/configuration_summary.erb +31 -0
  154. data/yard/templates/default/module/setup.rb +17 -0
  155. metadata +550 -0
@@ -0,0 +1,2 @@
1
+ --colour
2
+
@@ -0,0 +1,23 @@
1
+ --main extra_docs/Index.md
2
+ -e yard/setup.rb
3
+ -
4
+ README.md
5
+ extra_docs/GeneralUsage.md
6
+ extra_docs/Rails2.md
7
+ extra_docs/Rails3.md
8
+ extra_docs/Rack.md
9
+ extra_docs/Sinatra.md
10
+ extra_docs/Heroku.md
11
+ extra_docs/Mongo.md
12
+ extra_docs/Models.md
13
+ extra_docs/DataStorage.md
14
+ extra_docs/Analysers.md
15
+ extra_docs/Processing.md
16
+ extra_docs/Encoding.md
17
+ extra_docs/Generators.md
18
+ extra_docs/Configuration.md
19
+ extra_docs/URLs.md
20
+ extra_docs/Caching.md
21
+ extra_docs/MimeTypes.md
22
+ LICENSE
23
+ History.md
data/Gemfile ADDED
@@ -0,0 +1,23 @@
1
+ source :rubygems
2
+
3
+ # These gems are needed for development and testing
4
+ group :development, :test, :cucumber do
5
+ gem 'fog'
6
+ gem 'bson_ext'
7
+ gem 'capybara'
8
+ gem 'cucumber', '0.8.5'
9
+ gem 'cucumber-rails'
10
+ gem 'database_cleaner', '>= 0.5.0'
11
+ gem 'jeweler', '~> 1.4'
12
+ gem 'gherkin', '2.1.4' # 2.1.5 seems to segfault on Ruby 1.9.2
13
+ gem 'mongo'
14
+ gem 'nokogiri', '1.5.0.beta.2' # 1.4.3.1 segfaults on Ruby 1.9.2
15
+ gem 'rack', '~>1.1'
16
+ gem 'rack-cache'
17
+ gem 'rails', '3.0.3', :require => nil
18
+ gem 'rake'
19
+ gem 'rmagick', '2.12.2', :require => nil
20
+ gem 'rspec', '~> 1.3'
21
+ gem 'sqlite3-ruby', '1.3.0' # 1.3.1 segfaults on Ruby 1.9.2
22
+ gem 'yard'
23
+ end
@@ -0,0 +1,14 @@
1
+ source :rubygems
2
+
3
+ group :development, :test, :cucumber do
4
+ gem 'capybara'
5
+ gem 'cucumber', '0.8.5'
6
+ gem 'cucumber-rails'
7
+ gem 'database_cleaner', '>= 0.5.0'
8
+ gem 'gherkin', '2.1.4'
9
+ gem 'nokogiri', '1.5.0.beta.2'
10
+ gem 'rack-cache', :require => nil
11
+ gem 'rails', '2.3.5', :require => nil
12
+ gem 'rspec', '~> 1.3'
13
+ gem 'sqlite3-ruby', '1.3.0'
14
+ end
@@ -0,0 +1,266 @@
1
+ 0.8.1 (2010-11-22)
2
+ ==================
3
+ Fixes
4
+ -----
5
+ Removed runtime dependencies that Jeweler automatically takes from the Gemfile
6
+
7
+ 0.8.0 (2010-11-21)
8
+ ==================
9
+ Features
10
+ --------
11
+ - New ImageMagick generator, processor, encoder and analyser, which are now defaults
12
+ (thanks to Henry Phan for work on this)
13
+
14
+ Fixes
15
+ -----
16
+ - Works with Rails 3.0.2 uploaded files (which has a changed API)
17
+
18
+
19
+ 0.7.7 (2010-10-31)
20
+ ==================
21
+ Features
22
+ --------
23
+ - Added username/password authentication to mongo data store
24
+
25
+ Fixes
26
+ -----
27
+ - Fixes for Windows, inc. tempfile binmode and closing files
28
+ - "IOError: closed stream" fix (hopefully!)
29
+
30
+
31
+ 0.7.6 (2010-09-12)
32
+ ==================
33
+ Features
34
+ --------
35
+ - Added methods for querying job steps, and Job#uid, Job#uid_basename, etc.
36
+ - Added Job#b64_data
37
+ - Added configurable url_suffix
38
+ - Added configurable content_disposition and content_filename
39
+ - Can pass extra GET params to url_for
40
+ - Can manually set uid on FileDataStore and S3DataStore
41
+ (not yet documented because attachments have no way to pass it on yet)
42
+ - Model attachments store meta info about themselves
43
+
44
+ Changes
45
+ -------
46
+ - Configurable module doesn't implicitly call 'call' if attribute set as proc
47
+ - Refactored Endpoint module -> Response object
48
+
49
+ Fixes
50
+ -----
51
+ - Ruby 1.9.2-p0 was raising encoding errors due to Tempfiles not being in binmode
52
+
53
+
54
+ 0.7.5 (2010-09-01)
55
+ ==================
56
+ Changes
57
+ --------
58
+ - RMagick processor, encoder, analyser and generator all use the filesystem now
59
+ They can be configured to use in-memory strings with the use_filesystem config option.
60
+ - Upgraded support from Rails 3.0.0.rc -> Rails.3.0.0
61
+
62
+ 0.7.4 (2010-08-28)
63
+ ==================
64
+ Features
65
+ --------
66
+ - Gave model accessors bang methods process! and encode!
67
+
68
+ 0.7.3 (2010-08-27)
69
+ ==================
70
+ Fixes
71
+ -----
72
+ - Seems as though inserting after Rails' Rack::Lock was worth it after all
73
+
74
+ 0.7.2 (2010-08-27)
75
+ ==================
76
+ Fixes
77
+ -----
78
+ - S3DataStore was breaking if previous data hadn't stored meta
79
+
80
+ 0.7.1 (2010-08-26)
81
+ ==================
82
+ Fixes
83
+ -----
84
+ - SimpleEndpoint was modifying env path_info so wasn't creating proper cache keys
85
+ - to_response accepts env, so can use if-not-modified, etc.
86
+
87
+ Features
88
+ --------
89
+ - Doc tweaks: Added mongo page, notes about Capistrano
90
+
91
+ Changes
92
+ -------
93
+ - ETags generated by hash of job.serialize - was getting a bit long
94
+
95
+ 0.7.0 (2010-08-25)
96
+ ==================
97
+
98
+ Features
99
+ --------
100
+ - Ability to chain processing, encoding
101
+ - Added Generators for arbitrary content generation
102
+ - 'fetch_file' method for easily getting local files
103
+ - ActiveModel support
104
+ - Mongoid support
105
+ - Better Sinatra, etc. support (using 'to_response')
106
+ - Data stores now store meta, name and format information too
107
+ - Added Mongo Data Store
108
+ - temp_objects maintain name, meta, etc. across processing, encoding, etc.
109
+ - added portrait? and landscape? to RMagick analyser
110
+ - Ability to add single custom processor/encoder/analyser/generator
111
+ - added flip and flop to RMagick processor
112
+ - ability to configure whether it trusts the file extension
113
+ - nice text response for root path
114
+ - ability to configure url host
115
+ - ability to override path_prefix/host when calling url
116
+ - routed endpoints
117
+ - simple endpoints
118
+ - more intelligent working out of Content-Type to send back
119
+
120
+ Fixes
121
+ -----
122
+ - proper use of ETags
123
+ - remove whitespace from file/s3 datastore uids
124
+ - dragonfly/rails/images url-encodes rack-cache config for windows users
125
+ - Ruby 1.9.2 support
126
+ - Better RMagick memory management using image.destroy!
127
+
128
+ Changes
129
+ -------
130
+ - Dragonfly::App[:images] -> Dragonfly[:images]
131
+ - Moved text/plasma generation into Generator
132
+ - Use of lazy 'Job' objects
133
+ - simplified shortcuts interface
134
+ - changed interface for attaching to ActiveRecord
135
+ - simplified saved configurations and allow referring to them as symbols
136
+ - Removed need for Base class for datastores, processors, analysers and encoders
137
+ - FileCommandAnalyser included in Rails config, not RMagick
138
+ - better use of logging module for sharing logs between classes
139
+ - mounting the app is down the middleware/elsewhere, not the app itself
140
+ - DOS protection off by default
141
+ - encoded urls
142
+ - got rid of unnecessary configurable sha_length
143
+
144
+
145
+
146
+ 0.6.2 (2010-06-24)
147
+ ==================
148
+ Features
149
+ -----
150
+ - Added ability for custom error messages in validations
151
+
152
+ 0.6.1 (2010-05-16)
153
+ ==================
154
+ Fixes
155
+ -----
156
+ - STI was breaking when the model had a mixin too
157
+
158
+ 0.6.0 (2010-05-11)
159
+ ==================
160
+
161
+ Features
162
+ --------
163
+ - Added 'scale factor' for text generation, which gives better quality font rendering for smaller fonts
164
+ - Configurable objects allow for passing args, and passing a block for extra config
165
+ - Added more 'saved configurations', for easier setting up on e.g. Heroku
166
+ - Added RMagickAnalyser#format
167
+ - Added greyscale to RMagickProcessor
168
+ - S3DataStore is configurable as to whether it uses the filesystem or not (to save a tempfile)
169
+
170
+ Fixes
171
+ -----
172
+ - Some specs refactoring, including making text processing specs less brittle
173
+ - RMagickEncoder::SUPPORTED_FORMATS was proving problematic - now we use a configurable list instead
174
+ - Got Rails 3 beta3 cucumber features working
175
+ - Added check to see if bucket already exists in S3DataStore - apparently this was problematic in EU
176
+
177
+ Changes
178
+ -------
179
+ - temp_object.tempfile now returns a closed tempfile, which temp_object.file returns an open file.
180
+ Can also pass a block to temp_object.file which closes the file automatically
181
+ - Processors/Analysers/Encoders know about app now so can log to app's log
182
+ - Imagemagick errors in RMagick processor/analyser/encoder now throw unable_to_handle and log a warning
183
+ - Removed Rails generators - better being more explicit with saved configurations which are more concise now
184
+
185
+ 0.5.7 (2010-04-18)
186
+ ==================
187
+
188
+ Fixes
189
+ --------
190
+ - Strip file command mime_type value because some versions of file command were appending a line-break
191
+
192
+ 0.5.6 (2010-04-13)
193
+ ==================
194
+
195
+ Fixes
196
+ --------
197
+ - Wasn't working properly with Single-Table Inheritance
198
+
199
+ 0.5.5 (2010-04-13)
200
+ ==================
201
+
202
+ Fixes
203
+ --------
204
+ - Rails 3 has changed 'metaclass' -> 'singleton_class' so adapt accordingly
205
+
206
+ 0.5.4 (2010-04-12)
207
+ ==================
208
+
209
+ Features
210
+ --------
211
+ - Allow setting the uid manually
212
+
213
+ Fixes
214
+ -----
215
+ - Assigning an accessor to nil wasn't working properly
216
+
217
+
218
+ 0.5.3 (2010-03-27)
219
+ ==================
220
+
221
+ Fixes
222
+ -----
223
+ - Assigning an accessor to nil wasn't working properly
224
+
225
+
226
+ 0.5.2 (2010-03-04)
227
+ ==================
228
+
229
+ Features
230
+ --------
231
+ - Added 'registered mime-types'
232
+ - Enhanced docs
233
+
234
+ Fixes
235
+ -----
236
+ - RMagickEncoder only encodes if not already in that format
237
+
238
+
239
+ 0.5.1 (2010-02-20)
240
+ ==================
241
+
242
+ Fixes
243
+ -----
244
+ - Fixed 'broken pipe' errors in FileCommandAnalyser due to outputting loads of stuff to the command line stdin
245
+
246
+ 0.5.0 (2010-02-20)
247
+ ==================
248
+
249
+ Added support
250
+ -------------
251
+ - support for Rails 3
252
+
253
+
254
+ 0.4.4 (2010-02-16)
255
+ ==================
256
+
257
+ Better late than never to start logging change history...
258
+
259
+ New features
260
+ ------------
261
+ - added aspect_ratio to rmagick_analyser
262
+
263
+ Added support
264
+ -------------
265
+ - support for ruby 1.9
266
+ - added development dependencies to gemspec for easier setting up
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009-2010 Mark Evans
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,88 @@
1
+ Dragonfly
2
+ ===========
3
+
4
+ Dragonfly is a <a href="http://rack.rubyforge.org">Rack</a> framework for on-the-fly image handling.
5
+
6
+ Ideal for using with Ruby on Rails (2.3 and 3), Sinatra and all that gubbins.
7
+
8
+ For the lazy Rails user...
9
+ --------------------------
10
+ **Gemfile**:
11
+
12
+ gem 'rack-cache', :require => 'rack/cache'
13
+ gem 'dragonfly', '~>0.8.1'
14
+
15
+ **Initializer** (e.g. config/initializers/dragonfly.rb):
16
+
17
+ require 'dragonfly/rails/images'
18
+
19
+ **Migration**:
20
+
21
+ add_column :albums, :cover_image_uid, :string
22
+
23
+ **Model**:
24
+
25
+ class Album < ActiveRecord::Base
26
+ image_accessor :cover_image # 'image_accessor' is provided by Dragonfly
27
+ # this defines a reader/writer for cover_image
28
+ # ...
29
+ end
30
+
31
+ **View** (for uploading via a file field):
32
+
33
+ <% form_for @album, :html => {:multipart => true} do |f| %>
34
+ ...
35
+ <%= f.file_field :cover_image %>
36
+ ...
37
+ <% end %>
38
+
39
+ NB: REMEMBER THE MULTIPART BIT!!!
40
+
41
+ **View** (to display):
42
+
43
+ <%= image_tag @album.cover_image.url %>
44
+ <%= image_tag @album.cover_image.thumb('400x200#').url %>
45
+ <%= image_tag @album.cover_image.jpg.url %>
46
+ <%= image_tag @album.cover_image.process(:greyscale).encode(:tiff).url %>
47
+ ...etc.
48
+
49
+ The above relies on imagemagick being installed. Dragonfly doesn't depend on it per se, but the default configuration `'dragonfly/rails/images'`
50
+ uses it. For alternative configurations, see below.
51
+
52
+ If using Capistrano with the above, you probably will want to keep the cache between deploys, so in deploy.rb:
53
+
54
+ namespace :dragonfly do
55
+ desc "Symlink the Rack::Cache files"
56
+ task :symlink, :roles => [:app] do
57
+ run "mkdir -p #{shared_path}/tmp/dragonfly && ln -nfs #{shared_path}/tmp/dragonfly #{release_path}/tmp/dragonfly"
58
+ end
59
+ end
60
+ after 'deploy:update_code', 'dragonfly:symlink'
61
+
62
+ Using outside of rails, custom storage/processing/encoding/analysis, and more...
63
+ --------------------------------------------------------------------------------
64
+ Dragonfly is primarily a Rack app, so you can use it as a standalone app, or with Sinatra, Merb, etc.
65
+
66
+ It's highly customizable, and works with any data type (not just images).
67
+
68
+ For more info, consult the <a href="http://markevans.github.com/dragonfly"><big><strong>DOCUMENTATION</strong></big></a>
69
+
70
+ Add-ons
71
+ =======
72
+ For third-party add-ons, see [the Add-ons wiki](http://github.com/markevans/dragonfly/wiki/Dragonfly-add-ons)
73
+
74
+ Issues
75
+ ======
76
+ Please use the <a href="http://github.com/markevans/dragonfly/issues">github issue tracker</a> if you have any issues.
77
+
78
+ Suggestions/Questions
79
+ =====================
80
+ <a href="http://groups.google.com/group/dragonfly-users">Google group dragonfly-users</a>
81
+
82
+ Credits
83
+ =======
84
+ - [Mark Evans](http://github.com/markevans) (author)
85
+
86
+ Copyright
87
+ ========
88
+ Copyright (c) 2009-2010 Mark Evans. See LICENSE for details.
@@ -0,0 +1,92 @@
1
+ require 'rake'
2
+
3
+ begin
4
+ require 'jeweler'
5
+ Jeweler::Tasks.new do |s|
6
+ s.name = "fog-dragonfly"
7
+ s.summary = %Q{Dragonfly is an on-the-fly Rack-based image handling framework.
8
+ It is suitable for use with Rails, Sinatra and other web frameworks. Although it's mainly used for images,
9
+ it can handle any content type.}
10
+ s.email = "mark@new-bamboo.co.uk"
11
+ s.homepage = "http://github.com/markevans/dragonfly"
12
+ s.authors = ["Mark Evans", 'Cyril Mougel']
13
+ s.add_dependency('rack')
14
+ end
15
+ Jeweler::GemcutterTasks.new
16
+ rescue LoadError
17
+ puts "Jeweler not available. Install it with: (sudo) gem install jeweler"
18
+ end
19
+
20
+ require 'rake/rdoctask'
21
+ Rake::RDocTask.new do |rdoc|
22
+ rdoc.rdoc_dir = 'rdoc'
23
+ rdoc.title = 'dragonfly'
24
+ rdoc.options << '--line-numbers' << '--inline-source'
25
+ rdoc.rdoc_files.include('README*')
26
+ rdoc.rdoc_files.include('lib/**/*.rb')
27
+ end
28
+
29
+ begin
30
+ require 'yard'
31
+ YARD::Rake::YardocTask.new do |t|
32
+ t.files = ['lib/**/*.rb']
33
+ t.options = []
34
+ end
35
+ YARD::Rake::YardocTask.new 'yard:changed' do |t|
36
+ t.files = `git status | grep '.rb' | grep modified | grep -v yard | cut -d' ' -f4`.split
37
+ t.options = []
38
+ end
39
+ rescue LoadError
40
+ puts "YARD is not available. To run the documentation tasks, install it with: (sudo) gem install yard"
41
+ end
42
+
43
+ desc "Run all the specs"
44
+ task :spec do
45
+ system "bundle exec spec -O .specopts spec/dragonfly"
46
+ end
47
+
48
+ desc "Run the active model specs"
49
+ task :model_spec do
50
+ system "bundle exec spec -O .specopts spec/dragonfly/active_model_extensions"
51
+ end
52
+
53
+ desc "Run the active_record specs (AR 2.3)"
54
+ task :model_spec_235 do
55
+ system "export BUNDLE_GEMFILE=Gemfile.rails.2.3.5 && bundle exec spec -O .specopts spec/dragonfly/active_model_extensions"
56
+ end
57
+
58
+ task :features do
59
+ system "bundle exec cucumber"
60
+ end
61
+
62
+ task :default do
63
+ # Do everything!!!
64
+ puts "*** Running all the specs using the default Gemfile ***"
65
+ Rake::Task['spec'].invoke
66
+ puts "*** Running the model specs with Gemfile.rails.2.3.5 ***"
67
+ Rake::Task['model_spec_235'].invoke
68
+ puts "*** Running the features ***"
69
+ Rake::Task['features'].invoke
70
+ end
71
+
72
+ desc 'Set up a Rails app ready for testing'
73
+ namespace :rails do
74
+
75
+ task :setup do
76
+ version = ENV['RAILS_VERSION']
77
+ raise "Please give a RAILS_VERSION, e.g. RAILS_VERSION=2.3.5" unless version
78
+ path = File.expand_path("fixtures/rails_#{version}")
79
+ app_name = 'tmp_app'
80
+ system %(
81
+ cd #{path} &&
82
+ rm -rf #{app_name} &&
83
+ ../rails _#{version}_ #{app_name} -m template.rb
84
+ )
85
+ FileUtils.cp("fixtures/dragonfly_setup.rb", "#{path}/#{app_name}/config/initializers")
86
+ system %(cd #{path}/#{app_name} && rake db:migrate)
87
+ puts "*** Created a Rails #{version} app in #{path}/#{app_name} ***"
88
+ puts "Now just start the server, and go to localhost:3000/albums"
89
+ puts "***"
90
+ end
91
+
92
+ end