magickly 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gemtest +0 -0
- data/.rspec +1 -0
- data/Gemfile +28 -0
- data/Gemfile.lock +57 -0
- data/LICENSE.txt +20 -0
- data/README.md +73 -0
- data/Rakefile +53 -0
- data/VERSION +1 -0
- data/bin/magickly +12 -0
- data/config.ru +6 -0
- data/lib/dragonfly/data_storage/remote_data_store.rb +37 -0
- data/lib/magickly.rb +69 -0
- data/lib/views/index.haml +45 -0
- data/magickly.gemspec +95 -0
- data/spec/requests/magickly_spec.rb +42 -0
- data/spec/spec_helper.rb +18 -0
- data/spec/support/imagemagick.png +0 -0
- metadata +265 -0
data/.document
ADDED
data/.gemtest
ADDED
File without changes
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
source 'http://rubygems.org'
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem 'activesupport', '>= 2.3.5'
|
5
|
+
|
6
|
+
gem 'sinatra', '~> 1.2.1', :require => 'sinatra/base'
|
7
|
+
gem 'rack-cache', :require => 'rack/cache'
|
8
|
+
gem 'dragonfly', '~> 0.8.2'
|
9
|
+
|
10
|
+
gem 'haml', '~> 3.0.25'
|
11
|
+
gem 'httparty', '~> 0.7.3'
|
12
|
+
gem 'activesupport', '>= 2.0.0', :require => false
|
13
|
+
|
14
|
+
# Add dependencies to develop your gem here.
|
15
|
+
# Include everything needed to run rake, tests, features, etc.
|
16
|
+
group :development do
|
17
|
+
gem 'jeweler', '~> 1.5'
|
18
|
+
gem 'rcov', '>= 0'
|
19
|
+
end
|
20
|
+
|
21
|
+
group :development, :test do
|
22
|
+
gem 'rack-test'
|
23
|
+
gem 'rspec', '~> 2.4'
|
24
|
+
gem 'webmock', '~> 1.6'
|
25
|
+
gem 'imagesize', '~> 0.1'
|
26
|
+
#gem 'ruby-debug19', :platforms => :ruby_19
|
27
|
+
#gem 'ruby-debug', :platforms => :ruby_18
|
28
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
activesupport (3.0.5)
|
5
|
+
addressable (2.2.4)
|
6
|
+
crack (0.1.8)
|
7
|
+
diff-lcs (1.1.2)
|
8
|
+
dragonfly (0.8.2)
|
9
|
+
rack
|
10
|
+
git (1.2.5)
|
11
|
+
haml (3.0.25)
|
12
|
+
httparty (0.7.3)
|
13
|
+
crack (= 0.1.8)
|
14
|
+
imagesize (0.1.1)
|
15
|
+
jeweler (1.5.2)
|
16
|
+
bundler (~> 1.0.0)
|
17
|
+
git (>= 1.2.5)
|
18
|
+
rake
|
19
|
+
rack (1.2.2)
|
20
|
+
rack-cache (1.0)
|
21
|
+
rack (>= 0.4)
|
22
|
+
rack-test (0.5.7)
|
23
|
+
rack (>= 1.0)
|
24
|
+
rake (0.8.7)
|
25
|
+
rcov (0.9.9)
|
26
|
+
rspec (2.5.0)
|
27
|
+
rspec-core (~> 2.5.0)
|
28
|
+
rspec-expectations (~> 2.5.0)
|
29
|
+
rspec-mocks (~> 2.5.0)
|
30
|
+
rspec-core (2.5.1)
|
31
|
+
rspec-expectations (2.5.0)
|
32
|
+
diff-lcs (~> 1.1.2)
|
33
|
+
rspec-mocks (2.5.0)
|
34
|
+
sinatra (1.2.1)
|
35
|
+
rack (~> 1.1)
|
36
|
+
tilt (< 2.0, >= 1.2.2)
|
37
|
+
tilt (1.2.2)
|
38
|
+
webmock (1.6.2)
|
39
|
+
addressable (>= 2.2.2)
|
40
|
+
crack (>= 0.1.7)
|
41
|
+
|
42
|
+
PLATFORMS
|
43
|
+
ruby
|
44
|
+
|
45
|
+
DEPENDENCIES
|
46
|
+
activesupport (>= 2.0.0)
|
47
|
+
dragonfly (~> 0.8.2)
|
48
|
+
haml (~> 3.0.25)
|
49
|
+
httparty (~> 0.7.3)
|
50
|
+
imagesize (~> 0.1)
|
51
|
+
jeweler (~> 1.5)
|
52
|
+
rack-cache
|
53
|
+
rack-test
|
54
|
+
rcov
|
55
|
+
rspec (~> 2.4)
|
56
|
+
sinatra (~> 1.2.1)
|
57
|
+
webmock (~> 1.6)
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Aidan Feldman
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
# magickly
|
2
|
+
|
3
|
+
A service for image manipulation - built as a simple wrapper of Imagemagick which handles caching, c/o the [Dragonfly](http://markevans.github.com/dragonfly/) gem.
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
Say the base URL is the hosted version of this app, [magickly.heroku.com](http://magickly.heroku.com). The image URL is appended to the query string as a `src=`, followed by any of the supported imagemagick operations. For example, you could get a 100x100 thumbnail of [the imagemagick logo](http://upload.wikimedia.org/wikipedia/commons/0/0d/Imagemagick-logo.png) like so:
|
8
|
+
|
9
|
+
[http://magickly.heroku.com/?src=http://upload.wikimedia.org/wikipedia/commons/0/0d/Imagemagick-logo.png&resize=100x100](http://magickly.heroku.com/?src=http://upload.wikimedia.org/wikipedia/commons/0/0d/Imagemagick-logo.png&resize=100x100)
|
10
|
+
|
11
|
+
### Parameters (required)
|
12
|
+
|
13
|
+
**src** - the URL of the original image
|
14
|
+
|
15
|
+
### Parameters (optional):
|
16
|
+
|
17
|
+
See the [imagemagick command line params documentation](http://www.imagemagick.org/script/command-line-options.php) for details about allowed values.
|
18
|
+
|
19
|
+
**crop**
|
20
|
+
|
21
|
+
**flip**
|
22
|
+
|
23
|
+
**flop**
|
24
|
+
|
25
|
+
**greyscale**
|
26
|
+
|
27
|
+
**resize**
|
28
|
+
|
29
|
+
**rotate**
|
30
|
+
|
31
|
+
**thumb**
|
32
|
+
|
33
|
+
|
34
|
+
## Installation
|
35
|
+
|
36
|
+
$ gem install magickly
|
37
|
+
|
38
|
+
## Running the App
|
39
|
+
|
40
|
+
A few options:
|
41
|
+
|
42
|
+
### A. Run the app directly
|
43
|
+
|
44
|
+
$ magickly
|
45
|
+
|
46
|
+
The app can be accessed at [http://localhost:4567](http://localhost:4567)
|
47
|
+
|
48
|
+
### B. Use as an endpoint in another Rack app
|
49
|
+
|
50
|
+
As an example, to have magickly accessible at `/images` in a Rails app:
|
51
|
+
|
52
|
+
# Gemfile
|
53
|
+
gem 'magickly', '~> 0.1'
|
54
|
+
|
55
|
+
# config/routes.rb
|
56
|
+
match '/magickly', :to => MagicklyApp, :anchor => false
|
57
|
+
|
58
|
+
For more info, see [Rails Routing from the Outside In](http://guides.rubyonrails.org/routing.html#routing-to-rack-applications) or Michael Raidel's [Mount Rails apps in Rails 3](http://inductor.induktiv.at/blog/2010/05/23/mount-rack-apps-in-rails-3/).
|
59
|
+
|
60
|
+
## Contributing to magickly
|
61
|
+
|
62
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
63
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
64
|
+
* Fork the project
|
65
|
+
* Start a feature/bugfix branch
|
66
|
+
* Commit and push until you are happy with your contribution
|
67
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
68
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
69
|
+
|
70
|
+
## Copyright
|
71
|
+
|
72
|
+
Copyright (c) 2011 Aidan Feldman. See LICENSE.txt for
|
73
|
+
further details.
|
data/Rakefile
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'rake'
|
11
|
+
|
12
|
+
require 'jeweler'
|
13
|
+
Jeweler::Tasks.new do |gem|
|
14
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
15
|
+
gem.name = "magickly"
|
16
|
+
gem.homepage = "http://github.com/afeld/magickly"
|
17
|
+
gem.license = "MIT"
|
18
|
+
gem.summary = %Q{Imagemagick as a service}
|
19
|
+
gem.description = %Q{A simple wrapper of Imagemagick which handles caching, c/o the Dragonfly gem.}
|
20
|
+
gem.email = "aidan.feldman@gmail.com"
|
21
|
+
gem.authors = ["Aidan Feldman"]
|
22
|
+
gem.executables = ['magickly']
|
23
|
+
gem.files.include '.gemtest'
|
24
|
+
# Include your dependencies below. Runtime dependencies are required when using your gem,
|
25
|
+
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
26
|
+
# gem.add_runtime_dependency 'jabber4r', '> 0.1'
|
27
|
+
# gem.add_development_dependency 'rspec', '> 1.2.3'
|
28
|
+
end
|
29
|
+
Jeweler::RubygemsDotOrgTasks.new
|
30
|
+
|
31
|
+
require 'rspec/core'
|
32
|
+
require 'rspec/core/rake_task'
|
33
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
34
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
35
|
+
end
|
36
|
+
|
37
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
38
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
39
|
+
spec.rcov = true
|
40
|
+
end
|
41
|
+
|
42
|
+
task :default => :spec
|
43
|
+
task :test => :spec
|
44
|
+
|
45
|
+
require 'rake/rdoctask'
|
46
|
+
Rake::RDocTask.new do |rdoc|
|
47
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
48
|
+
|
49
|
+
rdoc.rdoc_dir = 'rdoc'
|
50
|
+
rdoc.title = "magickly #{version}"
|
51
|
+
rdoc.rdoc_files.include('README*')
|
52
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
53
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.0.0
|
data/bin/magickly
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'magickly'
|
5
|
+
rescue LoadError => e
|
6
|
+
require 'rubygems'
|
7
|
+
path = File.expand_path '../../lib', __FILE__
|
8
|
+
$:.unshift(path) if File.directory?(path) && !$:.include?(path)
|
9
|
+
require 'magickly'
|
10
|
+
end
|
11
|
+
|
12
|
+
MagicklyApp.run!
|
data/config.ru
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
|
3
|
+
module Dragonfly
|
4
|
+
module DataStorage
|
5
|
+
|
6
|
+
#class Forbidden < StandardError; end
|
7
|
+
|
8
|
+
class RemoteDataStore
|
9
|
+
include Configurable
|
10
|
+
|
11
|
+
configurable_attr :cookie_str
|
12
|
+
|
13
|
+
def store(temp_object, opts={})
|
14
|
+
raise "Sorry friend, this datastore is read-only."
|
15
|
+
end
|
16
|
+
|
17
|
+
def retrieve(uid)
|
18
|
+
response = HTTParty.get uid, :headers => {'cookie' => cookie_str || ''}
|
19
|
+
unless response.ok?
|
20
|
+
#raise Forbidden if response.code == 403
|
21
|
+
raise DataNotFound
|
22
|
+
end
|
23
|
+
|
24
|
+
content = response.body
|
25
|
+
extra_data = {}
|
26
|
+
[
|
27
|
+
content, # either a File, String or Tempfile
|
28
|
+
extra_data # Hash with optional keys :meta, :name, :format
|
29
|
+
]
|
30
|
+
end
|
31
|
+
|
32
|
+
def destroy(uid)
|
33
|
+
raise "Sorry friend, this datastore is read-only."
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/magickly.rb
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'active_support/core_ext/object/blank'
|
2
|
+
require 'active_support/ordered_hash'
|
3
|
+
|
4
|
+
require 'sinatra/base'
|
5
|
+
require 'dragonfly'
|
6
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'dragonfly', 'data_storage', 'remote_data_store'))
|
7
|
+
|
8
|
+
|
9
|
+
class MagicklyApp < Sinatra::Base
|
10
|
+
RESERVED_PARAMS = ['src']
|
11
|
+
|
12
|
+
enable :logging
|
13
|
+
set :root, File.dirname(__FILE__)
|
14
|
+
set :homepage, "http://github.com/afeld/magickly"
|
15
|
+
|
16
|
+
dragonfly = Dragonfly[:images].configure_with(:imagemagick)
|
17
|
+
dragonfly.configure do |c|
|
18
|
+
c.datastore = Dragonfly::DataStorage::RemoteDataStore.new
|
19
|
+
c.log = Logger.new($stdout)
|
20
|
+
end
|
21
|
+
set :dragonfly, dragonfly
|
22
|
+
|
23
|
+
def magickify(src, options={})
|
24
|
+
raise ArgumentError.new("src needed") if src.blank?
|
25
|
+
escaped_src = URI.escape(src)
|
26
|
+
image = settings.dragonfly.fetch(escaped_src)
|
27
|
+
|
28
|
+
options.each do |method, val|
|
29
|
+
if val == 'true'
|
30
|
+
image = image.process method
|
31
|
+
else
|
32
|
+
image = image.process method, val
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
image
|
37
|
+
end
|
38
|
+
|
39
|
+
before do
|
40
|
+
dragonfly.datastore.configure do |d|
|
41
|
+
# pass cookies to subsequent request
|
42
|
+
d.cookie_str = request.env["rack.request.cookie_string"]
|
43
|
+
end
|
44
|
+
|
45
|
+
@options = ActiveSupport::OrderedHash.new
|
46
|
+
request.query_string.split('&').each do |e|
|
47
|
+
k,v = e.split('=')
|
48
|
+
@options[k] = v unless RESERVED_PARAMS.include?(k)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
get '/' do
|
53
|
+
src = params['src']
|
54
|
+
|
55
|
+
if src
|
56
|
+
image = magickify(src, @options)
|
57
|
+
image.to_response(env)
|
58
|
+
else
|
59
|
+
# fallback for Dragonfly v0.8.2 and below
|
60
|
+
klass = Dragonfly::ImageMagick::Processor rescue Dragonfly::Processing::ImageMagickProcessor
|
61
|
+
@methods = klass.instance_methods(false)
|
62
|
+
haml :index
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# start the server if ruby file executed directly
|
67
|
+
run! if __FILE__ == $0
|
68
|
+
end
|
69
|
+
|
@@ -0,0 +1,45 @@
|
|
1
|
+
!!!
|
2
|
+
%html
|
3
|
+
%head
|
4
|
+
%title Magickly Demo Page
|
5
|
+
%script{:type => 'text/javascript', :src => 'http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js'}
|
6
|
+
:javascript
|
7
|
+
function updateResult(){
|
8
|
+
var query = [];
|
9
|
+
var params = $('#params').val();
|
10
|
+
if (params) {
|
11
|
+
query.push(params);
|
12
|
+
}
|
13
|
+
query.push('src=' + $('#src-img').val());
|
14
|
+
|
15
|
+
var resultUrl = '?' + query.join('&');
|
16
|
+
$('#result-url').val(location + resultUrl);
|
17
|
+
$('#result-image').attr('src', resultUrl);
|
18
|
+
}
|
19
|
+
|
20
|
+
$(function(){
|
21
|
+
updateResult();
|
22
|
+
$('#src-img').change(updateResult);
|
23
|
+
$('#params').change(updateResult);
|
24
|
+
});
|
25
|
+
|
26
|
+
%body
|
27
|
+
%h1 Welcome to Magickly
|
28
|
+
More info on the
|
29
|
+
%a{:href => "https://github.com/afeld/magickly"} Github project page
|
30
|
+
%br
|
31
|
+
%br
|
32
|
+
%label Image URL:
|
33
|
+
%input#src-img{:size => 80, :value => "http://upload.wikimedia.org/wikipedia/commons/0/0d/Imagemagick-logo.png"}
|
34
|
+
%br
|
35
|
+
%label Params:
|
36
|
+
%input#params{:size => 80, :value => "resize=200x"}
|
37
|
+
%br
|
38
|
+
%strong Available methods:
|
39
|
+
= @methods.join(', ')
|
40
|
+
%br
|
41
|
+
%br
|
42
|
+
%label Result URL:
|
43
|
+
%input#result-url{:size => 80}
|
44
|
+
%br
|
45
|
+
%img#result-image
|
data/magickly.gemspec
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{magickly}
|
8
|
+
s.version = "1.0.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Aidan Feldman"]
|
12
|
+
s.date = %q{2011-04-19}
|
13
|
+
s.description = %q{A simple wrapper of Imagemagick which handles caching, c/o the Dragonfly gem.}
|
14
|
+
s.email = %q{aidan.feldman@gmail.com}
|
15
|
+
s.executables = ["magickly"]
|
16
|
+
s.extra_rdoc_files = [
|
17
|
+
"LICENSE.txt",
|
18
|
+
"README.md"
|
19
|
+
]
|
20
|
+
s.files = [
|
21
|
+
".document",
|
22
|
+
".gemtest",
|
23
|
+
".rspec",
|
24
|
+
"Gemfile",
|
25
|
+
"Gemfile.lock",
|
26
|
+
"LICENSE.txt",
|
27
|
+
"README.md",
|
28
|
+
"Rakefile",
|
29
|
+
"VERSION",
|
30
|
+
"bin/magickly",
|
31
|
+
"config.ru",
|
32
|
+
"lib/dragonfly/data_storage/remote_data_store.rb",
|
33
|
+
"lib/magickly.rb",
|
34
|
+
"lib/views/index.haml",
|
35
|
+
"magickly.gemspec",
|
36
|
+
"spec/requests/magickly_spec.rb",
|
37
|
+
"spec/spec_helper.rb",
|
38
|
+
"spec/support/imagemagick.png"
|
39
|
+
]
|
40
|
+
s.homepage = %q{http://github.com/afeld/magickly}
|
41
|
+
s.licenses = ["MIT"]
|
42
|
+
s.require_paths = ["lib"]
|
43
|
+
s.rubygems_version = %q{1.7.2}
|
44
|
+
s.summary = %q{Imagemagick as a service}
|
45
|
+
s.test_files = [
|
46
|
+
"spec/requests/magickly_spec.rb",
|
47
|
+
"spec/spec_helper.rb"
|
48
|
+
]
|
49
|
+
|
50
|
+
if s.respond_to? :specification_version then
|
51
|
+
s.specification_version = 3
|
52
|
+
|
53
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
54
|
+
s.add_runtime_dependency(%q<sinatra>, ["~> 1.2.1"])
|
55
|
+
s.add_runtime_dependency(%q<rack-cache>, [">= 0"])
|
56
|
+
s.add_runtime_dependency(%q<dragonfly>, ["~> 0.8.2"])
|
57
|
+
s.add_runtime_dependency(%q<haml>, ["~> 3.0.25"])
|
58
|
+
s.add_runtime_dependency(%q<httparty>, ["~> 0.7.3"])
|
59
|
+
s.add_runtime_dependency(%q<activesupport>, [">= 2.0.0"])
|
60
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.5"])
|
61
|
+
s.add_development_dependency(%q<rcov>, [">= 0"])
|
62
|
+
s.add_development_dependency(%q<rack-test>, [">= 0"])
|
63
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.4"])
|
64
|
+
s.add_development_dependency(%q<webmock>, ["~> 1.6"])
|
65
|
+
s.add_development_dependency(%q<imagesize>, ["~> 0.1"])
|
66
|
+
else
|
67
|
+
s.add_dependency(%q<sinatra>, ["~> 1.2.1"])
|
68
|
+
s.add_dependency(%q<rack-cache>, [">= 0"])
|
69
|
+
s.add_dependency(%q<dragonfly>, ["~> 0.8.2"])
|
70
|
+
s.add_dependency(%q<haml>, ["~> 3.0.25"])
|
71
|
+
s.add_dependency(%q<httparty>, ["~> 0.7.3"])
|
72
|
+
s.add_dependency(%q<activesupport>, [">= 2.0.0"])
|
73
|
+
s.add_dependency(%q<jeweler>, ["~> 1.5"])
|
74
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
75
|
+
s.add_dependency(%q<rack-test>, [">= 0"])
|
76
|
+
s.add_dependency(%q<rspec>, ["~> 2.4"])
|
77
|
+
s.add_dependency(%q<webmock>, ["~> 1.6"])
|
78
|
+
s.add_dependency(%q<imagesize>, ["~> 0.1"])
|
79
|
+
end
|
80
|
+
else
|
81
|
+
s.add_dependency(%q<sinatra>, ["~> 1.2.1"])
|
82
|
+
s.add_dependency(%q<rack-cache>, [">= 0"])
|
83
|
+
s.add_dependency(%q<dragonfly>, ["~> 0.8.2"])
|
84
|
+
s.add_dependency(%q<haml>, ["~> 3.0.25"])
|
85
|
+
s.add_dependency(%q<httparty>, ["~> 0.7.3"])
|
86
|
+
s.add_dependency(%q<activesupport>, [">= 2.0.0"])
|
87
|
+
s.add_dependency(%q<jeweler>, ["~> 1.5"])
|
88
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
89
|
+
s.add_dependency(%q<rack-test>, [">= 0"])
|
90
|
+
s.add_dependency(%q<rspec>, ["~> 2.4"])
|
91
|
+
s.add_dependency(%q<webmock>, ["~> 1.6"])
|
92
|
+
s.add_dependency(%q<imagesize>, ["~> 0.1"])
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe MagicklyApp do
|
4
|
+
include Rack::Test::Methods
|
5
|
+
|
6
|
+
def app
|
7
|
+
MagicklyApp
|
8
|
+
end
|
9
|
+
|
10
|
+
it "says hello" do
|
11
|
+
get '/'
|
12
|
+
last_response.should be_ok
|
13
|
+
end
|
14
|
+
|
15
|
+
it "retrieves an image with no options" do
|
16
|
+
image_url = "http://www.foo.com/imagemagick.png"
|
17
|
+
image_path = File.join(File.dirname(__FILE__), '..', 'support', 'imagemagick.png')
|
18
|
+
stub_request(:get, image_url).to_return(:body => File.new(image_path))
|
19
|
+
|
20
|
+
get "/?src=#{image_url}"
|
21
|
+
|
22
|
+
a_request(:get, image_url).should have_been_made.once
|
23
|
+
last_response.should be_ok
|
24
|
+
|
25
|
+
# check that the returned file is identical to the original
|
26
|
+
last_response.body.should eq IO.read(image_path)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "resizes an image" do
|
30
|
+
image_url = "http://www.foo.com/imagemagick.png"
|
31
|
+
image_path = File.join(File.dirname(__FILE__), '..', 'support', 'imagemagick.png')
|
32
|
+
stub_request(:get, image_url).to_return(:body => File.new(image_path))
|
33
|
+
width = 100
|
34
|
+
|
35
|
+
get "/?src=#{image_url}&resize=#{width}x"
|
36
|
+
|
37
|
+
a_request(:get, image_url).should have_been_made.once
|
38
|
+
last_response.should be_ok
|
39
|
+
|
40
|
+
ImageSize.new(last_response.body).get_width.should eq width
|
41
|
+
end
|
42
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'magickly'
|
4
|
+
require 'rack/test'
|
5
|
+
require 'sinatra'
|
6
|
+
require 'webmock/rspec'
|
7
|
+
require 'image_size'
|
8
|
+
#require 'ruby-debug'
|
9
|
+
|
10
|
+
# Requires supporting files with custom matchers and macros, etc,
|
11
|
+
# in ./support/ and its subdirectories.
|
12
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
13
|
+
|
14
|
+
set :environment, :test
|
15
|
+
|
16
|
+
RSpec.configure do |config|
|
17
|
+
|
18
|
+
end
|
Binary file
|
metadata
ADDED
@@ -0,0 +1,265 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: magickly
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 23
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
version: 1.0.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Aidan Feldman
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-04-19 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
22
|
+
none: false
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
hash: 29
|
27
|
+
segments:
|
28
|
+
- 1
|
29
|
+
- 2
|
30
|
+
- 1
|
31
|
+
version: 1.2.1
|
32
|
+
version_requirements: *id001
|
33
|
+
name: sinatra
|
34
|
+
prerelease: false
|
35
|
+
type: :runtime
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
hash: 3
|
43
|
+
segments:
|
44
|
+
- 0
|
45
|
+
version: "0"
|
46
|
+
version_requirements: *id002
|
47
|
+
name: rack-cache
|
48
|
+
prerelease: false
|
49
|
+
type: :runtime
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ~>
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
hash: 59
|
57
|
+
segments:
|
58
|
+
- 0
|
59
|
+
- 8
|
60
|
+
- 2
|
61
|
+
version: 0.8.2
|
62
|
+
version_requirements: *id003
|
63
|
+
name: dragonfly
|
64
|
+
prerelease: false
|
65
|
+
type: :runtime
|
66
|
+
- !ruby/object:Gem::Dependency
|
67
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - ~>
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
hash: 53
|
73
|
+
segments:
|
74
|
+
- 3
|
75
|
+
- 0
|
76
|
+
- 25
|
77
|
+
version: 3.0.25
|
78
|
+
version_requirements: *id004
|
79
|
+
name: haml
|
80
|
+
prerelease: false
|
81
|
+
type: :runtime
|
82
|
+
- !ruby/object:Gem::Dependency
|
83
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
84
|
+
none: false
|
85
|
+
requirements:
|
86
|
+
- - ~>
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
hash: 5
|
89
|
+
segments:
|
90
|
+
- 0
|
91
|
+
- 7
|
92
|
+
- 3
|
93
|
+
version: 0.7.3
|
94
|
+
version_requirements: *id005
|
95
|
+
name: httparty
|
96
|
+
prerelease: false
|
97
|
+
type: :runtime
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
100
|
+
none: false
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
hash: 15
|
105
|
+
segments:
|
106
|
+
- 2
|
107
|
+
- 0
|
108
|
+
- 0
|
109
|
+
version: 2.0.0
|
110
|
+
version_requirements: *id006
|
111
|
+
name: activesupport
|
112
|
+
prerelease: false
|
113
|
+
type: :runtime
|
114
|
+
- !ruby/object:Gem::Dependency
|
115
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
116
|
+
none: false
|
117
|
+
requirements:
|
118
|
+
- - ~>
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
hash: 5
|
121
|
+
segments:
|
122
|
+
- 1
|
123
|
+
- 5
|
124
|
+
version: "1.5"
|
125
|
+
version_requirements: *id007
|
126
|
+
name: jeweler
|
127
|
+
prerelease: false
|
128
|
+
type: :development
|
129
|
+
- !ruby/object:Gem::Dependency
|
130
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
131
|
+
none: false
|
132
|
+
requirements:
|
133
|
+
- - ">="
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
hash: 3
|
136
|
+
segments:
|
137
|
+
- 0
|
138
|
+
version: "0"
|
139
|
+
version_requirements: *id008
|
140
|
+
name: rcov
|
141
|
+
prerelease: false
|
142
|
+
type: :development
|
143
|
+
- !ruby/object:Gem::Dependency
|
144
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
146
|
+
requirements:
|
147
|
+
- - ">="
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
hash: 3
|
150
|
+
segments:
|
151
|
+
- 0
|
152
|
+
version: "0"
|
153
|
+
version_requirements: *id009
|
154
|
+
name: rack-test
|
155
|
+
prerelease: false
|
156
|
+
type: :development
|
157
|
+
- !ruby/object:Gem::Dependency
|
158
|
+
requirement: &id010 !ruby/object:Gem::Requirement
|
159
|
+
none: false
|
160
|
+
requirements:
|
161
|
+
- - ~>
|
162
|
+
- !ruby/object:Gem::Version
|
163
|
+
hash: 11
|
164
|
+
segments:
|
165
|
+
- 2
|
166
|
+
- 4
|
167
|
+
version: "2.4"
|
168
|
+
version_requirements: *id010
|
169
|
+
name: rspec
|
170
|
+
prerelease: false
|
171
|
+
type: :development
|
172
|
+
- !ruby/object:Gem::Dependency
|
173
|
+
requirement: &id011 !ruby/object:Gem::Requirement
|
174
|
+
none: false
|
175
|
+
requirements:
|
176
|
+
- - ~>
|
177
|
+
- !ruby/object:Gem::Version
|
178
|
+
hash: 3
|
179
|
+
segments:
|
180
|
+
- 1
|
181
|
+
- 6
|
182
|
+
version: "1.6"
|
183
|
+
version_requirements: *id011
|
184
|
+
name: webmock
|
185
|
+
prerelease: false
|
186
|
+
type: :development
|
187
|
+
- !ruby/object:Gem::Dependency
|
188
|
+
requirement: &id012 !ruby/object:Gem::Requirement
|
189
|
+
none: false
|
190
|
+
requirements:
|
191
|
+
- - ~>
|
192
|
+
- !ruby/object:Gem::Version
|
193
|
+
hash: 9
|
194
|
+
segments:
|
195
|
+
- 0
|
196
|
+
- 1
|
197
|
+
version: "0.1"
|
198
|
+
version_requirements: *id012
|
199
|
+
name: imagesize
|
200
|
+
prerelease: false
|
201
|
+
type: :development
|
202
|
+
description: A simple wrapper of Imagemagick which handles caching, c/o the Dragonfly gem.
|
203
|
+
email: aidan.feldman@gmail.com
|
204
|
+
executables:
|
205
|
+
- magickly
|
206
|
+
extensions: []
|
207
|
+
|
208
|
+
extra_rdoc_files:
|
209
|
+
- LICENSE.txt
|
210
|
+
- README.md
|
211
|
+
files:
|
212
|
+
- .document
|
213
|
+
- .gemtest
|
214
|
+
- .rspec
|
215
|
+
- Gemfile
|
216
|
+
- Gemfile.lock
|
217
|
+
- LICENSE.txt
|
218
|
+
- README.md
|
219
|
+
- Rakefile
|
220
|
+
- VERSION
|
221
|
+
- bin/magickly
|
222
|
+
- config.ru
|
223
|
+
- lib/dragonfly/data_storage/remote_data_store.rb
|
224
|
+
- lib/magickly.rb
|
225
|
+
- lib/views/index.haml
|
226
|
+
- magickly.gemspec
|
227
|
+
- spec/requests/magickly_spec.rb
|
228
|
+
- spec/spec_helper.rb
|
229
|
+
- spec/support/imagemagick.png
|
230
|
+
homepage: http://github.com/afeld/magickly
|
231
|
+
licenses:
|
232
|
+
- MIT
|
233
|
+
post_install_message:
|
234
|
+
rdoc_options: []
|
235
|
+
|
236
|
+
require_paths:
|
237
|
+
- lib
|
238
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
239
|
+
none: false
|
240
|
+
requirements:
|
241
|
+
- - ">="
|
242
|
+
- !ruby/object:Gem::Version
|
243
|
+
hash: 3
|
244
|
+
segments:
|
245
|
+
- 0
|
246
|
+
version: "0"
|
247
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
248
|
+
none: false
|
249
|
+
requirements:
|
250
|
+
- - ">="
|
251
|
+
- !ruby/object:Gem::Version
|
252
|
+
hash: 3
|
253
|
+
segments:
|
254
|
+
- 0
|
255
|
+
version: "0"
|
256
|
+
requirements: []
|
257
|
+
|
258
|
+
rubyforge_project:
|
259
|
+
rubygems_version: 1.7.2
|
260
|
+
signing_key:
|
261
|
+
specification_version: 3
|
262
|
+
summary: Imagemagick as a service
|
263
|
+
test_files:
|
264
|
+
- spec/requests/magickly_spec.rb
|
265
|
+
- spec/spec_helper.rb
|