dragonfly 0.5.7 → 0.6.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 (77) hide show
  1. data/.gitignore +1 -0
  2. data/.yardopts +1 -0
  3. data/History.md +109 -0
  4. data/VERSION +1 -1
  5. data/config.rb +1 -1
  6. data/dragonfly.gemspec +19 -16
  7. data/extra_docs/ActiveRecord.md +8 -7
  8. data/extra_docs/Analysers.md +1 -1
  9. data/extra_docs/Encoding.md +1 -1
  10. data/extra_docs/ExampleUseCases.md +66 -73
  11. data/extra_docs/GettingStarted.md +1 -1
  12. data/extra_docs/Processing.md +1 -1
  13. data/extra_docs/Shortcuts.md +2 -2
  14. data/extra_docs/UsingWithRails.md +25 -37
  15. data/features/rails_2.3.5.feature +1 -8
  16. data/features/rails_3.0.0.beta3.feature +7 -0
  17. data/features/steps/rails_steps.rb +1 -11
  18. data/features/support/env.rb +1 -1
  19. data/fixtures/files/app/views/albums/show.html.erb +1 -0
  20. data/fixtures/files/config/initializers/{aaa_dragonfly_load_path.rb → dragonfly.rb} +1 -0
  21. data/fixtures/rails_2.3.5/template.rb +4 -6
  22. data/fixtures/rails_3.0.0.beta3/template.rb +16 -0
  23. data/lib/dragonfly.rb +23 -1
  24. data/lib/dragonfly/active_record_extensions/attachment.rb +1 -1
  25. data/lib/dragonfly/analyser_list.rb +4 -0
  26. data/lib/dragonfly/analysis/base.rb +1 -0
  27. data/lib/dragonfly/analysis/r_magick_analyser.rb +7 -0
  28. data/lib/dragonfly/app.rb +3 -11
  29. data/lib/dragonfly/belongs_to_app.rb +24 -0
  30. data/lib/dragonfly/config/heroku_rails_images.rb +23 -0
  31. data/lib/dragonfly/config/r_magick_images.rb +69 -0
  32. data/lib/dragonfly/config/r_magick_text.rb +25 -0
  33. data/lib/dragonfly/config/rails_defaults.rb +18 -0
  34. data/lib/dragonfly/config/rails_images.rb +13 -0
  35. data/lib/dragonfly/configurable.rb +4 -3
  36. data/lib/dragonfly/data_storage/base.rb +2 -0
  37. data/lib/dragonfly/data_storage/s3data_store.rb +11 -4
  38. data/lib/dragonfly/delegator.rb +22 -10
  39. data/lib/dragonfly/encoder_list.rb +4 -0
  40. data/lib/dragonfly/encoding/base.rb +1 -0
  41. data/lib/dragonfly/encoding/r_magick_encoder.rb +52 -8
  42. data/lib/dragonfly/extended_temp_object.rb +26 -27
  43. data/lib/dragonfly/processing/base.rb +1 -0
  44. data/lib/dragonfly/processing/r_magick_processor.rb +12 -127
  45. data/lib/dragonfly/processing/r_magick_text_processor.rb +155 -0
  46. data/lib/dragonfly/processor_list.rb +4 -0
  47. data/lib/dragonfly/rails/images.rb +2 -14
  48. data/lib/dragonfly/temp_object.rb +41 -34
  49. data/spec/dragonfly/active_record_extensions/migration.rb +7 -0
  50. data/spec/dragonfly/active_record_extensions/model_spec.rb +10 -11
  51. data/spec/dragonfly/active_record_extensions/spec_helper.rb +1 -1
  52. data/spec/dragonfly/analysis/r_magick_analyser_spec.rb +14 -1
  53. data/spec/dragonfly/belongs_to_app_spec.rb +55 -0
  54. data/spec/dragonfly/configurable_spec.rb +21 -6
  55. data/spec/dragonfly/data_storage/s3_data_store_spec.rb +1 -0
  56. data/spec/dragonfly/delegator_spec.rb +23 -12
  57. data/spec/dragonfly/extended_temp_object_spec.rb +13 -29
  58. data/spec/dragonfly/processing/{rmagick_processor_spec.rb → r_magick_processor_spec.rb} +8 -75
  59. data/spec/dragonfly/processing/r_magick_text_processor_spec.rb +84 -0
  60. data/spec/dragonfly/temp_object_spec.rb +126 -151
  61. data/spec/dragonfly_spec.rb +12 -0
  62. data/spec/ginger_scenarios.rb +2 -2
  63. data/spec/image_matchers.rb +2 -2
  64. data/yard/setup.rb +12 -2
  65. data/yard/templates/default/fulldoc/html/css/common.css +1 -2
  66. data/yard/templates/default/layout/html/layout.erb +3 -2
  67. metadata +21 -18
  68. data/History.txt +0 -75
  69. data/features/rails_3.0.0.beta.feature +0 -15
  70. data/fixtures/dragonfly_setup.rb +0 -1
  71. data/fixtures/rails +0 -22
  72. data/fixtures/rails_3.0.0.beta/template.rb +0 -13
  73. data/generators/dragonfly_app/USAGE +0 -16
  74. data/generators/dragonfly_app/dragonfly_app_generator.rb +0 -24
  75. data/generators/dragonfly_app/templates/initializer.erb +0 -35
  76. data/lib/dragonfly/r_magick_configuration.rb +0 -67
  77. data/spec/dragonfly/active_record_extensions/initializer.rb +0 -1
@@ -1,4 +1,16 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper'
2
2
 
3
3
  describe "Dragonfly" do
4
+
5
+ it "should return RMagickConfiguration as Config::RMagickImages, with a deprecation warning" do
6
+ Dragonfly.should_receive(:puts).with(string_matching(/WARNING/))
7
+ Dragonfly::RMagickConfiguration.should == Dragonfly::Config::RMagickImages
8
+ end
9
+
10
+ it "should raise an error for other undefined constants" do
11
+ lambda{
12
+ Dragonfly::Eggheads
13
+ }.should raise_error(NameError)
14
+ end
15
+
4
16
  end
@@ -6,8 +6,8 @@ Ginger.configure do |config|
6
6
  activerecord_2_3_5 = Ginger::Scenario.new("ActiveRecord 2.3.5")
7
7
  activerecord_2_3_5[/^active_?record$/] = "2.3.5"
8
8
 
9
- activerecord_3_0_0 = Ginger::Scenario.new("ActiveRecord 3.0.0 beta")
10
- activerecord_3_0_0[/^active_?record$/] = "3.0.0.beta"
9
+ activerecord_3_0_0 = Ginger::Scenario.new("ActiveRecord 3.0.0 beta3")
10
+ activerecord_3_0_0[/^active_?record$/] = "3.0.0.beta3"
11
11
 
12
12
  config.scenarios << activerecord_2_3_5 << activerecord_3_0_0
13
13
  end
@@ -23,11 +23,11 @@ def image_properties(image)
23
23
  end
24
24
 
25
25
  def have_width(width)
26
- simple_matcher("have width #{width}"){|given| image_properties(given)[:width].to_i.should == width }
26
+ simple_matcher("have width #{width}"){|given| width.should === image_properties(given)[:width].to_i }
27
27
  end
28
28
 
29
29
  def have_height(height)
30
- simple_matcher("have height #{height}"){|given| image_properties(given)[:height].to_i.should == height }
30
+ simple_matcher("have height #{height}"){|given| height.should === image_properties(given)[:height].to_i }
31
31
  end
32
32
 
33
33
  def have_format(format)
data/yard/setup.rb CHANGED
@@ -1,5 +1,15 @@
1
- YARD::Templates::Engine.register_template_path(File.dirname(__FILE__) + '/templates')
2
- Dir[File.dirname(__FILE__) + '/handlers/*.rb'].each do |file|
1
+ this_dir = File.dirname(__FILE__)
2
+
3
+ YARD::Templates::Engine.register_template_path(this_dir + '/templates')
4
+ Dir[this_dir + '/handlers/*.rb'].each do |file|
3
5
  require File.expand_path(file)
4
6
  end
5
7
  YARD::Parser::SourceParser.parser_type = :ruby18
8
+
9
+ version = ENV['DRAGONFLY_VERSION']
10
+ DRAGONFLY_VERSION = if version
11
+ puts "Setting the version in the docs to #{version}"
12
+ version
13
+ else
14
+ File.read(this_dir + '/../VERSION').strip
15
+ end
@@ -79,10 +79,9 @@ ul.main_files li a {
79
79
  #header #logo {
80
80
  float:left;
81
81
  width:50%;
82
- font-size: 24px;
82
+ font-size: 32px;
83
83
  letter-spacing: -1px;
84
84
  margin-top: 20px;
85
- text-transform: uppercase;
86
85
  }
87
86
  #header #search {
88
87
  position:static;
@@ -11,7 +11,7 @@
11
11
 
12
12
  <div id="header" class="clearfix">
13
13
  <%#= erb(:breadcrumb) %>
14
- <div id="logo">Dragonfly Documentation</div>
14
+ <div id="logo">DRAGONFLY (v <%= DRAGONFLY_VERSION %>)</div>
15
15
  <%= erb(:search) %>
16
16
  </div>
17
17
 
@@ -36,7 +36,8 @@
36
36
  ['Encoding', 'Encoding'],
37
37
  ['Shortcuts', 'Shortcuts for processing and encoding'],
38
38
  ['MimeTypes', 'Mime Types'],
39
- ['ExampleUseCases', 'Example use cases']
39
+ ['ExampleUseCases', 'Example use cases'],
40
+ ['History', 'History'],
40
41
  ].map{|(file, text)|
41
42
  "<li>#{link_file(file, text)}</li>"
42
43
  }.join
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 5
8
- - 7
9
- version: 0.5.7
7
+ - 6
8
+ - 0
9
+ version: 0.6.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Mark Evans
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-04-18 00:00:00 +01:00
17
+ date: 2010-05-11 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -161,7 +161,7 @@ extra_rdoc_files:
161
161
  files:
162
162
  - .gitignore
163
163
  - .yardopts
164
- - History.txt
164
+ - History.md
165
165
  - LICENSE
166
166
  - README.md
167
167
  - Rakefile
@@ -184,25 +184,20 @@ files:
184
184
  - features/images.feature
185
185
  - features/no_processing.feature
186
186
  - features/rails_2.3.5.feature
187
- - features/rails_3.0.0.beta.feature
187
+ - features/rails_3.0.0.beta3.feature
188
188
  - features/steps/common_steps.rb
189
189
  - features/steps/dragonfly_steps.rb
190
190
  - features/steps/rails_steps.rb
191
191
  - features/support/env.rb
192
- - fixtures/dragonfly_setup.rb
193
192
  - fixtures/files/app/models/album.rb
194
193
  - fixtures/files/app/views/albums/new.html.erb
195
194
  - fixtures/files/app/views/albums/show.html.erb
196
- - fixtures/files/config/initializers/aaa_dragonfly_load_path.rb
195
+ - fixtures/files/config/initializers/dragonfly.rb
197
196
  - fixtures/files/features/manage_album_images.feature
198
197
  - fixtures/files/features/step_definitions/album_steps.rb
199
198
  - fixtures/files/features/support/paths.rb
200
- - fixtures/rails
201
199
  - fixtures/rails_2.3.5/template.rb
202
- - fixtures/rails_3.0.0.beta/template.rb
203
- - generators/dragonfly_app/USAGE
204
- - generators/dragonfly_app/dragonfly_app_generator.rb
205
- - generators/dragonfly_app/templates/initializer.erb
200
+ - fixtures/rails_3.0.0.beta3/template.rb
206
201
  - irbrc.rb
207
202
  - lib/dragonfly.rb
208
203
  - lib/dragonfly/active_record_extensions.rb
@@ -215,6 +210,12 @@ files:
215
210
  - lib/dragonfly/analysis/file_command_analyser.rb
216
211
  - lib/dragonfly/analysis/r_magick_analyser.rb
217
212
  - lib/dragonfly/app.rb
213
+ - lib/dragonfly/belongs_to_app.rb
214
+ - lib/dragonfly/config/heroku_rails_images.rb
215
+ - lib/dragonfly/config/r_magick_images.rb
216
+ - lib/dragonfly/config/r_magick_text.rb
217
+ - lib/dragonfly/config/rails_defaults.rb
218
+ - lib/dragonfly/config/rails_images.rb
218
219
  - lib/dragonfly/configurable.rb
219
220
  - lib/dragonfly/core_ext/object.rb
220
221
  - lib/dragonfly/core_ext/string.rb
@@ -236,8 +237,8 @@ files:
236
237
  - lib/dragonfly/parameters.rb
237
238
  - lib/dragonfly/processing/base.rb
238
239
  - lib/dragonfly/processing/r_magick_processor.rb
240
+ - lib/dragonfly/processing/r_magick_text_processor.rb
239
241
  - lib/dragonfly/processor_list.rb
240
- - lib/dragonfly/r_magick_configuration.rb
241
242
  - lib/dragonfly/rails/images.rb
242
243
  - lib/dragonfly/temp_object.rb
243
244
  - lib/dragonfly/url_handler.rb
@@ -248,7 +249,6 @@ files:
248
249
  - samples/taj.jpg
249
250
  - spec/argument_matchers.rb
250
251
  - spec/dragonfly/active_record_extensions/attachment_spec.rb
251
- - spec/dragonfly/active_record_extensions/initializer.rb
252
252
  - spec/dragonfly/active_record_extensions/migration.rb
253
253
  - spec/dragonfly/active_record_extensions/model_spec.rb
254
254
  - spec/dragonfly/active_record_extensions/models.rb
@@ -256,6 +256,7 @@ files:
256
256
  - spec/dragonfly/analysis/file_command_analyser_spec.rb
257
257
  - spec/dragonfly/analysis/r_magick_analyser_spec.rb
258
258
  - spec/dragonfly/app_spec.rb
259
+ - spec/dragonfly/belongs_to_app_spec.rb
259
260
  - spec/dragonfly/configurable_spec.rb
260
261
  - spec/dragonfly/core_ext/string_spec.rb
261
262
  - spec/dragonfly/core_ext/symbol_spec.rb
@@ -268,7 +269,8 @@ files:
268
269
  - spec/dragonfly/extended_temp_object_spec.rb
269
270
  - spec/dragonfly/middleware_spec.rb
270
271
  - spec/dragonfly/parameters_spec.rb
271
- - spec/dragonfly/processing/rmagick_processor_spec.rb
272
+ - spec/dragonfly/processing/r_magick_processor_spec.rb
273
+ - spec/dragonfly/processing/r_magick_text_processor_spec.rb
272
274
  - spec/dragonfly/temp_object_spec.rb
273
275
  - spec/dragonfly/url_handler_spec.rb
274
276
  - spec/dragonfly_spec.rb
@@ -315,7 +317,6 @@ summary: Dragonfly is an on-the-fly Rack processing/encoding framework. It inclu
315
317
  test_files:
316
318
  - spec/argument_matchers.rb
317
319
  - spec/dragonfly/active_record_extensions/attachment_spec.rb
318
- - spec/dragonfly/active_record_extensions/initializer.rb
319
320
  - spec/dragonfly/active_record_extensions/migration.rb
320
321
  - spec/dragonfly/active_record_extensions/model_spec.rb
321
322
  - spec/dragonfly/active_record_extensions/models.rb
@@ -323,6 +324,7 @@ test_files:
323
324
  - spec/dragonfly/analysis/file_command_analyser_spec.rb
324
325
  - spec/dragonfly/analysis/r_magick_analyser_spec.rb
325
326
  - spec/dragonfly/app_spec.rb
327
+ - spec/dragonfly/belongs_to_app_spec.rb
326
328
  - spec/dragonfly/configurable_spec.rb
327
329
  - spec/dragonfly/core_ext/string_spec.rb
328
330
  - spec/dragonfly/core_ext/symbol_spec.rb
@@ -335,7 +337,8 @@ test_files:
335
337
  - spec/dragonfly/extended_temp_object_spec.rb
336
338
  - spec/dragonfly/middleware_spec.rb
337
339
  - spec/dragonfly/parameters_spec.rb
338
- - spec/dragonfly/processing/rmagick_processor_spec.rb
340
+ - spec/dragonfly/processing/r_magick_processor_spec.rb
341
+ - spec/dragonfly/processing/r_magick_text_processor_spec.rb
339
342
  - spec/dragonfly/temp_object_spec.rb
340
343
  - spec/dragonfly/url_handler_spec.rb
341
344
  - spec/dragonfly_spec.rb
data/History.txt DELETED
@@ -1,75 +0,0 @@
1
- 0.5.6 (2010-04-13)
2
- ==================
3
-
4
- Fixes
5
- --------
6
- - Wasn't working properly with Single-Table Inheritance
7
-
8
- 0.5.5 (2010-04-13)
9
- ==================
10
-
11
- Fixes
12
- --------
13
- - Rails 3 has changed 'metaclass' -> 'singleton_class' so adapt accordingly
14
-
15
- 0.5.4 (2010-04-12)
16
- ==================
17
-
18
- Features
19
- --------
20
- - Allow setting the uid manually
21
-
22
- Fixes
23
- -----
24
- - Assigning an accessor to nil wasn't working properly
25
-
26
-
27
- 0.5.3 (2010-03-27)
28
- ==================
29
-
30
- Fixes
31
- -----
32
- - Assigning an accessor to nil wasn't working properly
33
-
34
-
35
- 0.5.2 (2010-03-04)
36
- ==================
37
-
38
- Features
39
- --------
40
- - Added 'registered mime-types'
41
- - Enhanced docs
42
-
43
- Fixes
44
- -----
45
- - RMagickEncoder only encodes if not already in that format
46
-
47
-
48
- 0.5.1 (2010-02-20)
49
- ==================
50
-
51
- Fixes
52
- -----
53
- - Fixed 'broken pipe' errors in FileCommandAnalyser due to outputting loads of stuff to the command line stdin
54
-
55
- 0.5.0 (2010-02-20)
56
- ==================
57
-
58
- Added support
59
- -------------
60
- - support for Rails 3
61
-
62
-
63
- 0.4.4 (2010-02-16)
64
- ==================
65
-
66
- Better late than never to start logging change history...
67
-
68
- New features
69
- ------------
70
- - added aspect_ratio to rmagick_analyser
71
-
72
- Added support
73
- -------------
74
- - support for ruby 1.9
75
- - added development dependencies to gemspec for easier setting up
@@ -1,15 +0,0 @@
1
- Feature: champion uses dragonfly in his Rails 3.0.0.beta application
2
- In order to be a champion
3
- A user uses dragonfly in his Rails 3.0.0.beta application
4
-
5
- Background:
6
- Given PENDING: Neither cucumber generators nor Rails templates seem to be working properly yet for Rails 3
7
- Given a Rails 3.0.0.beta application set up for using dragonfly
8
-
9
- Scenario: Set up dragonfly using the generator
10
- When I use the Rails 3.0.0.beta generator to set up dragonfly
11
- Then the cucumber features in my Rails 3.0.0.beta app should pass
12
-
13
- Scenario: Set up dragonfly using bundler require
14
- When I use the provided 3.0.0.beta initializer
15
- Then the cucumber features in my Rails 3.0.0.beta app should pass
@@ -1 +0,0 @@
1
- require 'dragonfly/rails/images'
data/fixtures/rails DELETED
@@ -1,22 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # I'm using this file because at the time of writing, the Rails 3 exec file
3
- # doesn't allow for running older versions side by side
4
-
5
- require 'rubygems'
6
-
7
- version = ">= 0"
8
-
9
- if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
10
- version = $1
11
- ARGV.shift
12
- end
13
-
14
- if version =~ /^3|[^.]3/
15
- # Rails 3...
16
- gem 'railties', version
17
- load Gem.bin_path('railties', 'rails', version)
18
- else
19
- # ... pre Rails 3
20
- gem 'rails', version
21
- load Gem.bin_path('rails', 'rails', version)
22
- end
@@ -1,13 +0,0 @@
1
- run "script/rails generate scaffold albums cover_image_uid:string"
2
- rake 'db:migrate'
3
-
4
- # Cucumber generator doesn't seem to be working yet...
5
- # gem 'cucumber'
6
- # run 'script/rails generate cucumber:skeleton'
7
- gem 'rack-cache', :require => 'rack/cache'
8
- run 'echo "" >> Gemfile' # Annoyingly the generators don't insert line-breaks yet
9
- gem 'rmagick', :require => 'RMagick'
10
-
11
- # # Copy over all files from the template dir
12
- files_dir = File.expand_path(File.dirname(__FILE__) + '/../../files')
13
- run "cp -r #{files_dir}/** ."
@@ -1,16 +0,0 @@
1
- ------------------------------------------------------------------------
2
-
3
- Example:
4
-
5
- ./script/generate dragonfly_app images
6
-
7
- This will create an initializer called dragonfly_images, which will:
8
- - create and configure a dragonfly app for serving images
9
- - add the app to the middleware stack
10
- - extend activerecord, so you can do things like
11
-
12
- image_accessor :preview_image
13
-
14
- in your models.
15
-
16
- ------------------------------------------------------------------------
@@ -1,24 +0,0 @@
1
- require 'digest/sha1'
2
-
3
- class DragonflyAppGenerator < Rails::Generator::NamedBase
4
-
5
- def manifest
6
- app_name = plural_name
7
-
8
- record do |m|
9
- m.template(
10
- 'initializer.erb',
11
- File.join('config', 'initializers', "dragonfly_#{app_name}.rb"),
12
- :assigns => {
13
- :app_name => app_name,
14
- :accessor_prefix => singular_name.singularize,
15
- :path_prefix => 'media',
16
- :random_secret => Digest::SHA1.hexdigest(Time.now.to_s)
17
- },
18
- :collision => :ask
19
- )
20
-
21
- end
22
- end
23
-
24
- end
@@ -1,35 +0,0 @@
1
- require 'dragonfly'
2
-
3
- # Configuration
4
- app = Dragonfly::App[:<%= app_name %>]
5
- app.configure_with(Dragonfly::RMagickConfiguration)
6
- app.configure do |c|
7
- c.log = Rails.logger
8
- c.datastore.configure do |d|
9
- d.root_path = "#{Rails.root}/public/system/dragonfly/#{Rails.env}"
10
- end
11
- c.url_handler.configure do |u|
12
- u.secret = '<%= random_secret %>'
13
- u.path_prefix = '/<%= path_prefix %>'
14
- end
15
- end
16
-
17
- # Extend ActiveRecord
18
- # This allows you to use e.g.
19
- # <%= accessor_prefix %>_accessor :my_attribute
20
- # in your models.
21
- ActiveRecord::Base.extend Dragonfly::ActiveRecordExtensions
22
- ActiveRecord::Base.register_dragonfly_app(:<%= accessor_prefix %>, Dragonfly::App[:<%= app_name %>])
23
-
24
- # Add the Dragonfly App to the middleware stack
25
- ActionController::Dispatcher.middleware.insert_after ActionController::Failsafe, Dragonfly::Middleware, :<%= app_name %>
26
-
27
- # # UNCOMMENT THIS IF YOU WANT TO CACHE REQUESTS WITH Rack::Cache, and add the line
28
- # # config.gem 'rack-cache', :lib => 'rack/cache'
29
- # # to environment.rb
30
- # require 'rack/cache'
31
- # ActionController::Dispatcher.middleware.insert_before Dragonfly::Middleware, Rack::Cache, {
32
- # :verbose => true,
33
- # :metastore => "file:#{Rails.root}/tmp/dragonfly/cache/meta",
34
- # :entitystore => "file:#{Rails.root}/tmp/dragonfly/cache/body"
35
- # }
@@ -1,67 +0,0 @@
1
- module Dragonfly
2
-
3
- # RMagickConfiguration is a saved configuration for Dragonfly apps, which does the following:
4
- # - registers an rmagick analyser
5
- # - registers an rmagick processor
6
- # - registers an rmagick encoder
7
- # - adds parameter shortcuts like '280x140!', etc.
8
- # Look at the source code for apply_configuration to see exactly how it configures the app.
9
- module RMagickConfiguration
10
-
11
- def self.apply_configuration(app)
12
- app.configure do |c|
13
- c.register_analyser(Analysis::FileCommandAnalyser)
14
- c.register_analyser(Analysis::RMagickAnalyser)
15
- c.register_processor(Processing::RMagickProcessor)
16
- c.register_encoder(Encoding::RMagickEncoder)
17
- c.parameters.configure do |p|
18
- p.default_format = :jpg
19
- # Standard resizing like '30x40!', etc.
20
- p.add_shortcut(Symbol) do |format|
21
- {:format => format}
22
- end
23
- p.add_shortcut(/^\d*x\d*[><%^!]?$|^\d+@$/) do |geometry, match_data|
24
- {
25
- :processing_method => :resize,
26
- :processing_options => {:geometry => geometry}
27
- }
28
- end
29
- # Cropped resizing like '20x50#ne'
30
- p.add_shortcut(/^(\d+)x(\d+)#(\w{1,2})?/) do |geometry, match_data|
31
- {
32
- :processing_method => :resize_and_crop,
33
- :processing_options => {:width => match_data[1], :height => match_data[2], :gravity => match_data[3]}
34
- }
35
- end
36
- # Cropping like '30x30+10+10ne'
37
- p.add_shortcut(/^(\d+)x(\d+)([+-]\d+)([+-]\d+)(\w{1,2})?/) do |geometry, match_data|
38
- {
39
- :processing_method => :crop,
40
- :processing_options => {
41
- :width => match_data[1],
42
- :height => match_data[2],
43
- :x => match_data[3],
44
- :y => match_data[4],
45
- :gravity => match_data[5]
46
- }
47
- }
48
- end
49
- p.add_shortcut(/^\d*x/, Symbol) do |geometry, format|
50
- p.hash_from_shortcut(geometry).merge(:format => format)
51
- end
52
- p.add_shortcut(:rotate, Numeric) do |_, amount|
53
- {
54
- :processing_method => :rotate,
55
- :processing_options => {:amount => amount, :background_colour => '#0000'}
56
- }
57
- end
58
- p.add_shortcut(:rotate, Numeric, Symbol) do |a, b, format|
59
- p.hash_from_shortcut(a,b).merge(:format => format)
60
- end
61
- end
62
- end
63
-
64
- end
65
-
66
- end
67
- end