dragonfly 0.7.0 → 0.7.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/.yardopts +1 -0
- data/History.md +17 -0
- data/README.md +11 -1
- data/VERSION +1 -1
- data/dragonfly.gemspec +3 -2
- data/extra_docs/Caching.md +2 -1
- data/extra_docs/DataStorage.md +2 -1
- data/extra_docs/Index.md +3 -0
- data/extra_docs/Mongo.md +45 -0
- data/extra_docs/Rails2.md +13 -1
- data/extra_docs/Rails3.md +13 -1
- data/extra_docs/Sinatra.md +5 -1
- data/features/support/env.rb +1 -1
- data/lib/dragonfly/app.rb +1 -1
- data/lib/dragonfly/job.rb +7 -3
- data/spec/dragonfly/job_endpoint_spec.rb +1 -1
- data/spec/dragonfly/simple_endpoint_spec.rb +11 -0
- data/spec/spec_helper.rb +1 -1
- data/yard/templates/default/layout/html/layout.erb +2 -1
- metadata +4 -3
data/.yardopts
CHANGED
data/History.md
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
0.7.1 (2010-08-26)
|
2
|
+
==================
|
3
|
+
Fixes
|
4
|
+
-----
|
5
|
+
- SimpleEndpoint was modifying env path_info so wasn't creating proper cache keys
|
6
|
+
- to_response accepts env, so can use if-not-modified, etc.
|
7
|
+
|
8
|
+
Features
|
9
|
+
--------
|
10
|
+
- Doc tweaks: Added mongo page, notes about Capistrano
|
11
|
+
|
12
|
+
Changes
|
13
|
+
-------
|
14
|
+
- ETags generated by hash of job.serialize - was getting a bit long
|
15
|
+
|
1
16
|
0.7.0 (2010-08-25)
|
2
17
|
==================
|
3
18
|
|
@@ -28,6 +43,8 @@ Fixes
|
|
28
43
|
- proper use of ETags
|
29
44
|
- remove whitespace from file/s3 datastore uids
|
30
45
|
- dragonfly/rails/images url-encodes rack-cache config for windows users
|
46
|
+
- Ruby 1.9.2 support
|
47
|
+
- Better RMagick memory management using image.destroy!
|
31
48
|
|
32
49
|
Changes
|
33
50
|
-------
|
data/README.md
CHANGED
@@ -11,7 +11,7 @@ For the lazy Rails user...
|
|
11
11
|
|
12
12
|
gem 'rmagick', :require => 'RMagick'
|
13
13
|
gem 'rack-cache', :require => 'rack/cache'
|
14
|
-
gem 'dragonfly', '~>0.7.
|
14
|
+
gem 'dragonfly', '~>0.7.1'
|
15
15
|
|
16
16
|
**Initializer** (e.g. config/initializers/dragonfly.rb):
|
17
17
|
|
@@ -47,6 +47,16 @@ NB: REMEMBER THE MULTIPART BIT!!!
|
|
47
47
|
<%= image_tag @album.cover_image.process(:greyscale).encode(:tiff).url %>
|
48
48
|
...etc.
|
49
49
|
|
50
|
+
If using Capistrano with the above, you probably will want to keep the cache between deploys, so in deploy.rb:
|
51
|
+
|
52
|
+
namespace :dragonfly do
|
53
|
+
desc "Symlink the Rack::Cache files"
|
54
|
+
task :symlink, :roles => [:app] do
|
55
|
+
run "mkdir -p #{shared_path}/tmp/dragonfly && ln -nfs #{shared_path}/tmp/dragonfly #{release_path}/tmp/dragonfly"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
after 'deploy:update_code', 'dragonfly:symlink'
|
59
|
+
|
50
60
|
Using outside of rails, custom storage/processing/encoding/analysis, and more...
|
51
61
|
--------------------------------------------------------------------------------
|
52
62
|
Dragonfly is primarily a Rack app, so you can use it as a standalone app, or with Sinatra, Merb, etc.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.7.
|
1
|
+
0.7.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.7.
|
8
|
+
s.version = "0.7.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-08-
|
12
|
+
s.date = %q{2010-08-26}
|
13
13
|
s.email = %q{mark@new-bamboo.co.uk}
|
14
14
|
s.extra_rdoc_files = [
|
15
15
|
"LICENSE",
|
@@ -40,6 +40,7 @@ Gem::Specification.new do |s|
|
|
40
40
|
"extra_docs/Index.md",
|
41
41
|
"extra_docs/MimeTypes.md",
|
42
42
|
"extra_docs/Models.md",
|
43
|
+
"extra_docs/Mongo.md",
|
43
44
|
"extra_docs/Processing.md",
|
44
45
|
"extra_docs/Rack.md",
|
45
46
|
"extra_docs/Rails2.md",
|
data/extra_docs/Caching.md
CHANGED
@@ -9,7 +9,8 @@ proxy like {http://varnish.projects.linpro.no Varnish}, {http://www.squid-cache.
|
|
9
9
|
{http://tomayko.com/src/rack-cache/ Rack::Cache}, etc. in front of the app, so that subsequent requests are served
|
10
10
|
super-quickly straight out of the cache.
|
11
11
|
|
12
|
-
The file 'dragonfly/rails/images' puts Rack::Cache in front of Dragonfly by default
|
12
|
+
The file 'dragonfly/rails/images' puts Rack::Cache in front of Dragonfly by default, but for better performance
|
13
|
+
you may wish to look into something like Varnish.
|
13
14
|
|
14
15
|
Given a dragonfly app
|
15
16
|
|
data/extra_docs/DataStorage.md
CHANGED
data/extra_docs/Index.md
CHANGED
@@ -8,6 +8,9 @@ I actually lied about image handling - it can be used for any type of content.
|
|
8
8
|
|
9
9
|
See the links on the right for more info.
|
10
10
|
|
11
|
+
**NOTE: the API has changed since v0.6.2!
|
12
|
+
[Docs for v0.6.2 are here](v0.6.2/index.html) for a very limited time.**
|
13
|
+
|
11
14
|
Installation
|
12
15
|
------------
|
13
16
|
|
data/extra_docs/Mongo.md
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
Mongo
|
2
|
+
=====
|
3
|
+
Dragonfly can be used with any ActiveModel-compatible model, therefore libraries like [Mongoid](http://mongoid.org) work out of the box.
|
4
|
+
|
5
|
+
Furthermore, Mongo DB has support for storing blob-like objects directly in the database (using MongoDB 'GridFS'),
|
6
|
+
so you can make use of this with the supplied {Dragonfly::DataStorage::MongoDataStore MongoDataStore}.
|
7
|
+
|
8
|
+
For more info about ActiveModel, see {file:Models}.
|
9
|
+
|
10
|
+
For more info about using the Mongo data store, see {file:DataStorage}.
|
11
|
+
|
12
|
+
Example setup in Rails, using Mongoid
|
13
|
+
-------------------------------------
|
14
|
+
In config/initializers/dragonfly.rb:
|
15
|
+
|
16
|
+
require 'dragonfly'
|
17
|
+
|
18
|
+
app = Dragonfly[:images]
|
19
|
+
|
20
|
+
# Get database name from config/mongoid.yml
|
21
|
+
db = YAML.load_file(Rails.root.join('config/mongoid.yml'))[Rails.env]['database']
|
22
|
+
|
23
|
+
# Configure to use RMagick, Rails defaults, and the Mongo data store
|
24
|
+
app.configure_with(:rmagick)
|
25
|
+
app.configure_with(:rails) do |c|
|
26
|
+
c.datastore = Dragonfly::DataStorage::MongoDataStore.new :database => db
|
27
|
+
end
|
28
|
+
|
29
|
+
# Allow all mongoid models to use the macro 'image_accessor'
|
30
|
+
app.define_macro_on_include(Mongoid::Document, :image_accessor)
|
31
|
+
|
32
|
+
# ... any other setup, see Rails docs
|
33
|
+
|
34
|
+
Then in models:
|
35
|
+
|
36
|
+
class Album
|
37
|
+
include Mongoid::Document
|
38
|
+
|
39
|
+
field :cover_image_uid
|
40
|
+
image_accessor :cover_image
|
41
|
+
|
42
|
+
# ...
|
43
|
+
end
|
44
|
+
|
45
|
+
See {file:Models} for more info.
|
data/extra_docs/Rails2.md
CHANGED
@@ -34,10 +34,22 @@ Gems
|
|
34
34
|
----
|
35
35
|
environment.rb
|
36
36
|
|
37
|
-
config.gem 'dragonfly', '~>0.7.
|
37
|
+
config.gem 'dragonfly', '~>0.7.1'
|
38
38
|
config.gem 'rmagick', :lib => 'RMagick'
|
39
39
|
config.gem 'rack-cache', :lib => 'rack/cache'
|
40
40
|
|
41
|
+
Capistrano
|
42
|
+
----------
|
43
|
+
If using Capistrano with the above, you probably will want to keep the cache between deploys, so in deploy.rb:
|
44
|
+
|
45
|
+
namespace :dragonfly do
|
46
|
+
desc "Symlink the Rack::Cache files"
|
47
|
+
task :symlink, :roles => [:app] do
|
48
|
+
run "mkdir -p #{shared_path}/tmp/dragonfly && ln -nfs #{shared_path}/tmp/dragonfly #{release_path}/tmp/dragonfly"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
after 'deploy:update_code', 'dragonfly:symlink'
|
52
|
+
|
41
53
|
Use it!
|
42
54
|
-------
|
43
55
|
|
data/extra_docs/Rails3.md
CHANGED
@@ -33,10 +33,22 @@ application.rb:
|
|
33
33
|
Gemfile
|
34
34
|
-------
|
35
35
|
|
36
|
-
gem 'dragonfly', '~>0.7.
|
36
|
+
gem 'dragonfly', '~>0.7.1'
|
37
37
|
gem 'rmagick', :require => 'RMagick'
|
38
38
|
gem 'rack-cache', :require => 'rack/cache'
|
39
39
|
|
40
|
+
Capistrano
|
41
|
+
----------
|
42
|
+
If using Capistrano with the above, you probably will want to keep the cache between deploys, so in deploy.rb:
|
43
|
+
|
44
|
+
namespace :dragonfly do
|
45
|
+
desc "Symlink the Rack::Cache files"
|
46
|
+
task :symlink, :roles => [:app] do
|
47
|
+
run "mkdir -p #{shared_path}/tmp/dragonfly && ln -nfs #{shared_path}/tmp/dragonfly #{release_path}/tmp/dragonfly"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
after 'deploy:update_code', 'dragonfly:symlink'
|
51
|
+
|
40
52
|
Use it!
|
41
53
|
-------
|
42
54
|
|
data/extra_docs/Sinatra.md
CHANGED
@@ -2,10 +2,14 @@ Sinatra
|
|
2
2
|
=======
|
3
3
|
You can use {Dragonfly::Job Job}'s `to_response` method like so:
|
4
4
|
|
5
|
+
app = Dragonfly[:images].configure_with(:rmagick)
|
6
|
+
|
5
7
|
get '/images/:size.:format' do |size, format|
|
6
|
-
app.fetch_file('~/some/image.png').thumb(size).encode(format).to_response
|
8
|
+
app.fetch_file('~/some/image.png').thumb(size).encode(format).to_response(env)
|
7
9
|
end
|
8
10
|
|
11
|
+
`to_response` returns a rack-style response array with status, headers and body.
|
12
|
+
|
9
13
|
NOTE: uids from the datastore currently have slashes and dots in them so may cause problems when using ':uid' as
|
10
14
|
a path segment.
|
11
15
|
|
data/features/support/env.rb
CHANGED
data/lib/dragonfly/app.rb
CHANGED
@@ -46,7 +46,7 @@ module Dragonfly
|
|
46
46
|
configurable_attr :url_path_prefix
|
47
47
|
configurable_attr :url_host
|
48
48
|
configurable_attr :protect_from_dos_attacks, false
|
49
|
-
configurable_attr :secret
|
49
|
+
configurable_attr :secret, 'secret yo'
|
50
50
|
configurable_attr :log do Logger.new('/var/tmp/dragonfly.log') end
|
51
51
|
configurable_attr :infer_mime_type_from_file_ext, true
|
52
52
|
|
data/lib/dragonfly/job.rb
CHANGED
@@ -128,6 +128,7 @@ module Dragonfly
|
|
128
128
|
end
|
129
129
|
|
130
130
|
def from_path(path, app)
|
131
|
+
path = path.dup
|
131
132
|
path.sub!(app.url_path_prefix, '') if app.url_path_prefix
|
132
133
|
path.sub!('/', '')
|
133
134
|
deserialize(path, app)
|
@@ -237,7 +238,10 @@ module Dragonfly
|
|
237
238
|
def serialize
|
238
239
|
Serializer.marshal_encode(to_a)
|
239
240
|
end
|
240
|
-
|
241
|
+
|
242
|
+
def unique_signature
|
243
|
+
Digest::SHA1.hexdigest(serialize)
|
244
|
+
end
|
241
245
|
|
242
246
|
def sha
|
243
247
|
Digest::SHA1.hexdigest("#{serialize}#{app.secret}")[0...8]
|
@@ -258,8 +262,8 @@ module Dragonfly
|
|
258
262
|
JobEndpoint.new(self)
|
259
263
|
end
|
260
264
|
|
261
|
-
def to_response
|
262
|
-
to_app.call
|
265
|
+
def to_response(env={})
|
266
|
+
to_app.call(env)
|
263
267
|
end
|
264
268
|
|
265
269
|
def url(*args)
|
@@ -56,7 +56,7 @@ describe Dragonfly::JobEndpoint do
|
|
56
56
|
end
|
57
57
|
|
58
58
|
it "should not have applied any steps if the correct ETag is specified in HTTP_IF_NONE_MATCH header" do
|
59
|
-
response = make_request(@job, 'HTTP_IF_NONE_MATCH' => @job.
|
59
|
+
response = make_request(@job, 'HTTP_IF_NONE_MATCH' => @job.unique_signature)
|
60
60
|
@job.applied_steps.should be_empty
|
61
61
|
end
|
62
62
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../spec_helper'
|
2
2
|
require 'rack/mock'
|
3
|
+
require 'rack/cache'
|
3
4
|
|
4
5
|
def request(app, path)
|
5
6
|
Rack::MockRequest.new(app).get(path)
|
@@ -75,4 +76,14 @@ describe Dragonfly::SimpleEndpoint do
|
|
75
76
|
response.content_type.should == 'text/plain'
|
76
77
|
end
|
77
78
|
|
79
|
+
it "should return a cacheable response" do
|
80
|
+
url = "/#{@app.fetch(@uid).serialize}"
|
81
|
+
cache = Rack::Cache.new(@endpoint, :entitystore => 'heap:/')
|
82
|
+
response = request(cache, url)
|
83
|
+
response.status.should == 200
|
84
|
+
response.headers['X-Rack-Cache'].should == "miss, store"
|
85
|
+
response = request(cache, url)
|
86
|
+
response.status.should == 200
|
87
|
+
response.headers['X-Rack-Cache'].should == "fresh"
|
88
|
+
end
|
78
89
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -18,7 +18,7 @@ ENV['PATH'] += ':' + extra_paths.join(':')
|
|
18
18
|
SAMPLES_DIR = File.expand_path(File.dirname(__FILE__) + '/../samples') unless defined?(SAMPLES_DIR)
|
19
19
|
|
20
20
|
Spec::Runner.configure do |c|
|
21
|
-
c.after(:all){
|
21
|
+
c.after(:all){ Dir["#{ROOT_PATH}/Gemfile*.lock"].each{|f| FileUtils.rm_f(f) } }
|
22
22
|
end
|
23
23
|
|
24
24
|
def todo
|
@@ -52,13 +52,14 @@
|
|
52
52
|
['Rack', 'Rack'],
|
53
53
|
['Sinatra', 'Sinatra'],
|
54
54
|
['Heroku', 'Heroku'],
|
55
|
+
['Mongo', 'Mongo'],
|
55
56
|
['DataStorage', 'Data Storage'],
|
56
57
|
['Analysers', 'Analysers'],
|
57
58
|
['Processing', 'Processing'],
|
58
59
|
['Encoding', 'Encoding'],
|
59
60
|
['Generators', 'Generators'],
|
60
61
|
['Configuration', 'Configuration'],
|
61
|
-
['URLs', 'URLs'],
|
62
|
+
['URLs', 'URLs / Endpoints'],
|
62
63
|
['MimeTypes', 'Mime Types'],
|
63
64
|
['Caching', 'Caching'],
|
64
65
|
['History', 'History'],
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 7
|
8
|
-
-
|
9
|
-
version: 0.7.
|
8
|
+
- 1
|
9
|
+
version: 0.7.1
|
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-08-
|
17
|
+
date: 2010-08-26 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -64,6 +64,7 @@ files:
|
|
64
64
|
- extra_docs/Index.md
|
65
65
|
- extra_docs/MimeTypes.md
|
66
66
|
- extra_docs/Models.md
|
67
|
+
- extra_docs/Mongo.md
|
67
68
|
- extra_docs/Processing.md
|
68
69
|
- extra_docs/Rack.md
|
69
70
|
- extra_docs/Rails2.md
|