dragonfly 0.4.0 → 0.4.1

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.

data/README.md CHANGED
@@ -10,11 +10,9 @@ To use simply for image thumbnails etc. in Rails...
10
10
 
11
11
  environment.rb:
12
12
 
13
- config.gem 'rmagick'
14
- config.gem 'rack-cache'
15
-
16
- config.gem 'dragonfly', :lib => 'dragonfly/rails/images'
17
- config.middleware.use 'Dragonfly::MiddlewareWithCache', :images
13
+ config.gem 'rmagick', :lib => 'RMagick'
14
+ config.gem 'rack-cache', :lib => 'rack/cache'
15
+ config.gem 'dragonfly', :lib => 'dragonfly/rails/images', :source => 'http://gemcutter.org'
18
16
 
19
17
  Migration:
20
18
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.0
1
+ 0.4.1
data/dragonfly.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{dragonfly}
8
- s.version = "0.4.0"
8
+ s.version = "0.4.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Mark Evans"]
12
- s.date = %q{2010-01-04}
12
+ s.date = %q{2010-01-07}
13
13
  s.email = %q{mark@new-bamboo.co.uk}
14
14
  s.extra_rdoc_files = [
15
15
  "LICENSE",
@@ -70,7 +70,6 @@ Gem::Specification.new do |s|
70
70
  "lib/dragonfly/encoding/transparent_encoder.rb",
71
71
  "lib/dragonfly/extended_temp_object.rb",
72
72
  "lib/dragonfly/middleware.rb",
73
- "lib/dragonfly/middleware_with_cache.rb",
74
73
  "lib/dragonfly/parameters.rb",
75
74
  "lib/dragonfly/processing/base.rb",
76
75
  "lib/dragonfly/processing/r_magick_processor.rb",
@@ -101,7 +100,6 @@ Gem::Specification.new do |s|
101
100
  "spec/dragonfly/encoding/r_magick_encoder_spec.rb",
102
101
  "spec/dragonfly/extended_temp_object_spec.rb",
103
102
  "spec/dragonfly/middleware_spec.rb",
104
- "spec/dragonfly/middleware_with_cache_spec.rb",
105
103
  "spec/dragonfly/parameters_spec.rb",
106
104
  "spec/dragonfly/processing/rmagick_processor_spec.rb",
107
105
  "spec/dragonfly/shared_middleware_spec.rb",
@@ -141,7 +139,6 @@ Gem::Specification.new do |s|
141
139
  "spec/dragonfly/encoding/r_magick_encoder_spec.rb",
142
140
  "spec/dragonfly/extended_temp_object_spec.rb",
143
141
  "spec/dragonfly/middleware_spec.rb",
144
- "spec/dragonfly/middleware_with_cache_spec.rb",
145
142
  "spec/dragonfly/parameters_spec.rb",
146
143
  "spec/dragonfly/processing/rmagick_processor_spec.rb",
147
144
  "spec/dragonfly/shared_middleware_spec.rb",
@@ -7,29 +7,16 @@ The quick way
7
7
  -------------
8
8
  In environment.rb:
9
9
 
10
- config.gem 'rmagick'
11
- config.gem 'rack-cache'
12
-
13
- config.gem 'dragonfly', :lib => 'dragonfly/rails/images'
14
- config.middleware.use 'Dragonfly::MiddlewareWithCache', :images
10
+ config.gem 'rmagick', :lib => 'RMagick'
11
+ config.gem 'rack-cache', :lib => 'rack/cache'
12
+ config.gem 'dragonfly', :lib => 'dragonfly/rails/images', :source => 'http://gemcutter.org'
15
13
 
16
14
  The required file 'dragonfly/rails/images.rb' initializes a dragonfly app, configures it to use rmagick processing, encoding, etc.,
17
- and registers the app so that you can use ActiveRecord accessors.
15
+ registers the app so that you can use ActiveRecord accessors, and inserts it into the Rails middleware stack.
18
16
 
19
17
  Because in this case it's configured to use {http://tomayko.com/src/rack-cache/ rack-cache} and {http://rmagick.rubyforge.org/ rmagick},
20
18
  you should include the first two lines above.
21
19
 
22
- The line `config.middleware.use 'Dragonfly::MiddlewareWithCache', :images` configures rails to use a {Dragonfly::MiddlewareWithCache middleware} which uses the named app (named `:images`), and puts
23
- {http://tomayko.com/src/rack-cache/ Rack::Cache} in front of it for performance.
24
- You can pass extra arguments to this line which will go directly to configuring Rack::Cache (see its docs for how to configure it).
25
- The default configuration for Rack::Cache is
26
-
27
- {
28
- :verbose => true,
29
- :metastore => 'file:/var/cache/rack/meta',
30
- :entitystore => 'file:/var/cache/rack/body'
31
- }
32
-
33
20
  To see what you can do with the active record accessors, see {file:ActiveRecord}.
34
21
 
35
22
  The more explicit way - using an initializer
@@ -39,9 +26,9 @@ in an initializer.
39
26
 
40
27
  In that case in environment.rb we only need:
41
28
 
42
- config.gem 'rmagick' # if used
43
- config.gem 'rack-cache' # if used
44
- config.gem 'dragonfly'
29
+ config.gem 'rmagick', :lib => 'RMagick' # if used
30
+ config.gem 'rack-cache', :lib => 'rack/cache' # if used
31
+ config.gem 'dragonfly', :source => 'http://gemcutter.org'
45
32
 
46
33
  The easiest way to create the initializer is using the supplied generator
47
34
  (which will be visible if you have the dragonfly gem installed).
@@ -71,7 +58,7 @@ but make sure to change the 'secret' configuration option, so as to protect your
71
58
  d.root_path = "#{Rails.root}/public/system/dragonfly/#{Rails.env}"
72
59
  end
73
60
  c.url_handler.configure do |u|
74
- u.secret = 'd54d2f8f44e81e9a6c4ec5ba76bc8ba12cf95717'
61
+ u.secret = 'fed49e269eebed54cc85b28a6c51cba6a543e7b5'
75
62
  u.path_prefix = '/media'
76
63
  end
77
64
  end
@@ -84,7 +71,14 @@ but make sure to change the 'secret' configuration option, so as to protect your
84
71
  ActiveRecord::Base.register_dragonfly_app(:image, Dragonfly::App[:images])
85
72
 
86
73
  # Add the Dragonfly App to the middleware stack
87
- ActionController::Dispatcher.middleware.use Dragonfly::Middleware, :images
88
-
89
- # USE THIS INSTEAD IF YOU WANT TO CACHE REQUESTS WITH Rack::Cache (remember to add config.gem for 'rack-cache')
90
- # ActionController::Dispatcher.middleware.use Dragonfly::MiddlewareWithCache, :images
74
+ ActionController::Dispatcher.middleware.insert_after ActionController::Failsafe, Dragonfly::Middleware, :images
75
+
76
+ # # UNCOMMENT THIS IF YOU WANT TO CACHE REQUESTS WITH Rack::Cache, and add the line
77
+ # # config.gem 'rack-cache', :lib => 'rack/cache'
78
+ # # to environment.rb
79
+ # require 'rack/cache'
80
+ # ActionController::Dispatcher.middleware.insert_before Dragonfly::Middleware, Rack::Cache, {
81
+ # :verbose => true,
82
+ # :metastore => "file:#{Rails.root}/tmp/dragonfly/cache/meta",
83
+ # :entitystore => "file:#{Rails.root}/tmp/dragonfly/cache/body"
84
+ # }
@@ -22,7 +22,14 @@ ActiveRecord::Base.extend Dragonfly::ActiveRecordExtensions
22
22
  ActiveRecord::Base.register_dragonfly_app(:<%= accessor_prefix %>, Dragonfly::App[:<%= app_name %>])
23
23
 
24
24
  # Add the Dragonfly App to the middleware stack
25
- ActionController::Dispatcher.middleware.use Dragonfly::Middleware, :<%= app_name %>
25
+ ActionController::Dispatcher.middleware.insert_after ActionController::Failsafe, Dragonfly::Middleware, :<%= app_name %>
26
26
 
27
- # USE THIS INSTEAD IF YOU WANT TO CACHE REQUESTS WITH Rack::Cache (remember to add config.gem for 'rack-cache')
28
- # ActionController::Dispatcher.middleware.use Dragonfly::MiddlewareWithCache, :<%= app_name %>
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,4 +1,5 @@
1
1
  require 'dragonfly'
2
+ require 'rack/cache'
2
3
 
3
4
  ### The dragonfly app ###
4
5
 
@@ -18,3 +19,11 @@ end
18
19
  ### Extend active record ###
19
20
  ActiveRecord::Base.extend Dragonfly::ActiveRecordExtensions
20
21
  ActiveRecord::Base.register_dragonfly_app(:image, app)
22
+
23
+ ### Insert the middleware ###
24
+ ActionController::Dispatcher.middleware.insert_after ActionController::Failsafe, Dragonfly::Middleware, :images
25
+ ActionController::Dispatcher.middleware.insert_before Dragonfly::Middleware, Rack::Cache, {
26
+ :verbose => true,
27
+ :metastore => "file:#{Rails.root}/tmp/dragonfly/cache/meta",
28
+ :entitystore => "file:#{Rails.root}/tmp/dragonfly/cache/body"
29
+ }
@@ -1,14 +1,48 @@
1
- require File.dirname(__FILE__) + '/shared_middleware_spec'
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+ require 'rack'
3
+
4
+ def dummy_rack_app
5
+ lambda{|env| [200, {"Content-Type" => "text/html"}, ["#{env['PATH_INFO']}, #{env['QUERY_STRING']}"]] }
6
+ end
2
7
 
3
8
  describe Dragonfly::Middleware do
4
-
9
+
10
+ def make_request(app, url)
11
+ Rack::MockRequest.new(app).get(url)
12
+ end
13
+
5
14
  before(:each) do
6
15
  @stack = Rack::Builder.new do
7
16
  use Dragonfly::Middleware, :images
8
17
  run dummy_rack_app
9
18
  end
10
19
  end
11
-
12
- it_should_behave_like 'dragonfly middleware'
20
+
21
+ it "should continue the calling chain if the app returns a 404 for that url" do
22
+ Dragonfly::App[:images].should_receive(:call).and_return(
23
+ [404, {"Content-Type" => 'text/plain'}, ['Not found']]
24
+ )
25
+ response = make_request(@stack, 'hello.png?howare=you')
26
+ response.status.should == 200
27
+ response.body.should == 'hello.png, howare=you'
28
+ end
29
+
30
+ it "should return as per the dragonfly app if the app returns a 200" do
31
+ Dragonfly::App[:images].should_receive(:call).and_return(
32
+ [200, {"Content-Type" => 'text/plain'}, ['ABCD']]
33
+ )
34
+ response = make_request(@stack, 'hello.png?howare=you')
35
+ response.status.should == 200
36
+ response.body.should == 'ABCD'
37
+ end
38
+
39
+ it "should return as per the dragonfly app if the app returns a 400" do
40
+ Dragonfly::App[:images].should_receive(:call).and_return(
41
+ [400, {"Content-Type" => 'text/plain'}, ['ABCD']]
42
+ )
43
+ response = make_request(@stack, 'hello.png?howare=you')
44
+ response.status.should == 400
45
+ response.body.should == 'ABCD'
46
+ end
13
47
 
14
48
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dragonfly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Evans
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-04 00:00:00 +00:00
12
+ date: 2010-01-07 00:00:00 +00:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -86,7 +86,6 @@ files:
86
86
  - lib/dragonfly/encoding/transparent_encoder.rb
87
87
  - lib/dragonfly/extended_temp_object.rb
88
88
  - lib/dragonfly/middleware.rb
89
- - lib/dragonfly/middleware_with_cache.rb
90
89
  - lib/dragonfly/parameters.rb
91
90
  - lib/dragonfly/processing/base.rb
92
91
  - lib/dragonfly/processing/r_magick_processor.rb
@@ -117,7 +116,6 @@ files:
117
116
  - spec/dragonfly/encoding/r_magick_encoder_spec.rb
118
117
  - spec/dragonfly/extended_temp_object_spec.rb
119
118
  - spec/dragonfly/middleware_spec.rb
120
- - spec/dragonfly/middleware_with_cache_spec.rb
121
119
  - spec/dragonfly/parameters_spec.rb
122
120
  - spec/dragonfly/processing/rmagick_processor_spec.rb
123
121
  - spec/dragonfly/shared_middleware_spec.rb
@@ -179,7 +177,6 @@ test_files:
179
177
  - spec/dragonfly/encoding/r_magick_encoder_spec.rb
180
178
  - spec/dragonfly/extended_temp_object_spec.rb
181
179
  - spec/dragonfly/middleware_spec.rb
182
- - spec/dragonfly/middleware_with_cache_spec.rb
183
180
  - spec/dragonfly/parameters_spec.rb
184
181
  - spec/dragonfly/processing/rmagick_processor_spec.rb
185
182
  - spec/dragonfly/shared_middleware_spec.rb
@@ -1,26 +0,0 @@
1
- require 'rack/cache'
2
-
3
- module Dragonfly
4
- class MiddlewareWithCache < Middleware
5
-
6
- def initialize(app, dragonfly_app_name, rack_cache_opts={})
7
- super(app, dragonfly_app_name)
8
- @rack_cache_opts = {
9
- :verbose => true,
10
- :metastore => 'file:/var/cache/rack/meta',
11
- :entitystore => 'file:/var/cache/rack/body'
12
- }.merge(rack_cache_opts)
13
- end
14
-
15
- private
16
-
17
- def endpoint
18
- rack_cache_opts = @rack_cache_opts
19
- @endpoint ||= Rack::Builder.new do
20
- use Rack::Cache, rack_cache_opts
21
- run super
22
- end
23
- end
24
-
25
- end
26
- end
@@ -1,14 +0,0 @@
1
- require File.dirname(__FILE__) + '/shared_middleware_spec'
2
-
3
- describe Dragonfly::MiddlewareWithCache do
4
-
5
- before(:each) do
6
- @stack = Rack::Builder.new do
7
- use Dragonfly::MiddlewareWithCache, :images
8
- run dummy_rack_app
9
- end
10
- end
11
-
12
- it_should_behave_like 'dragonfly middleware'
13
-
14
- end