magickly 2.0.1 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +2 -2
- data/Gemfile +4 -3
- data/Gemfile.lock +38 -31
- data/README.md +5 -5
- data/Rakefile +10 -3
- data/lib/magickly/app.rb +24 -22
- data/lib/magickly/version.rb +1 -1
- data/lib/shortcuts.rb +4 -0
- data/spec/requests/magickly_app_spec.rb +42 -33
- data/spec/spec_helper.rb +3 -3
- data/spec/unit/magickly_spec.rb +2 -2
- data/spec/unit/remote_data_store_spec.rb +3 -3
- data/spec/unit/shortcut_spec.rb +4 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 868fc5c7b36e6d2d18b1119d57ecc20f775c8530
|
4
|
+
data.tar.gz: 018b0809e1b4572af9b0d82b4afc46be95d52263
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 191dc04dc5709ed6daace9bded938054021e48979d028321904a42f98d2e83dc11e33681d445f4c8ea0405cc1e3868da0951b41479bbe13f78e93a07aedad187
|
7
|
+
data.tar.gz: 2f19233c16fb77f8c866c8cbe5e19cf81ade4b6882aadb8a35404618d81b23ca3c758eade3924cc1f835a77a18ebbc67c6d7bb17b3a3c04d1e6247b091052d02
|
data/CONTRIBUTING.md
CHANGED
data/Gemfile
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
ruby '2.1.0' unless ENV['CI']
|
4
|
-
|
5
3
|
gemspec
|
6
4
|
|
5
|
+
gem 'dotenv'
|
6
|
+
|
7
|
+
gem 'rake'
|
7
8
|
gem 'rack-cache', :require => 'rack/cache'
|
8
9
|
|
9
10
|
group :development, :test do
|
@@ -13,6 +14,6 @@ group :development, :test do
|
|
13
14
|
gem 'fastimage'
|
14
15
|
end
|
15
16
|
|
16
|
-
group :production do
|
17
|
+
group :production, :staging do
|
17
18
|
gem 'newrelic_rpm', :require => false
|
18
19
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
magickly (
|
5
|
-
activesupport (>= 2.0.0)
|
4
|
+
magickly (2.0.2)
|
5
|
+
activesupport (>= 2.0.0, < 5)
|
6
6
|
addressable (~> 2.2)
|
7
7
|
dragonfly (~> 0.9.14)
|
8
8
|
httparty (~> 0.13)
|
@@ -11,67 +11,74 @@ PATH
|
|
11
11
|
GEM
|
12
12
|
remote: https://rubygems.org/
|
13
13
|
specs:
|
14
|
-
activesupport (4.
|
15
|
-
i18n (~> 0.6, >= 0.6.
|
16
|
-
|
17
|
-
|
14
|
+
activesupport (4.1.8)
|
15
|
+
i18n (~> 0.6, >= 0.6.9)
|
16
|
+
json (~> 1.7, >= 1.7.7)
|
17
|
+
minitest (~> 5.1)
|
18
18
|
thread_safe (~> 0.1)
|
19
|
-
tzinfo (~>
|
20
|
-
addressable (2.3.
|
21
|
-
atomic (1.1.14)
|
19
|
+
tzinfo (~> 1.1)
|
20
|
+
addressable (2.3.6)
|
22
21
|
crack (0.4.2)
|
23
22
|
safe_yaml (~> 1.0.0)
|
24
23
|
diff-lcs (1.2.5)
|
24
|
+
dotenv (1.0.2)
|
25
25
|
dragonfly (0.9.15)
|
26
26
|
multi_json (~> 1.0)
|
27
27
|
rack
|
28
|
-
fastimage (1.6.
|
28
|
+
fastimage (1.6.6)
|
29
29
|
addressable (~> 2.3, >= 2.3.5)
|
30
|
-
httparty (0.13.
|
30
|
+
httparty (0.13.3)
|
31
31
|
json (~> 1.8)
|
32
32
|
multi_xml (>= 0.5.2)
|
33
|
-
i18n (0.6.
|
33
|
+
i18n (0.6.11)
|
34
34
|
json (1.8.1)
|
35
|
-
minitest (4.
|
36
|
-
multi_json (1.
|
35
|
+
minitest (5.4.3)
|
36
|
+
multi_json (1.10.1)
|
37
37
|
multi_xml (0.5.5)
|
38
|
-
newrelic_rpm (3.
|
38
|
+
newrelic_rpm (3.9.8.273)
|
39
39
|
rack (1.5.2)
|
40
40
|
rack-cache (1.2)
|
41
41
|
rack (>= 0.4)
|
42
|
-
rack-protection (1.5.
|
42
|
+
rack-protection (1.5.3)
|
43
43
|
rack
|
44
44
|
rack-test (0.6.2)
|
45
45
|
rack (>= 1.0)
|
46
|
-
|
47
|
-
|
48
|
-
rspec-
|
49
|
-
rspec-
|
50
|
-
|
51
|
-
rspec-
|
52
|
-
|
53
|
-
rspec-
|
54
|
-
|
55
|
-
|
46
|
+
rake (10.4.2)
|
47
|
+
rspec (3.1.0)
|
48
|
+
rspec-core (~> 3.1.0)
|
49
|
+
rspec-expectations (~> 3.1.0)
|
50
|
+
rspec-mocks (~> 3.1.0)
|
51
|
+
rspec-core (3.1.7)
|
52
|
+
rspec-support (~> 3.1.0)
|
53
|
+
rspec-expectations (3.1.2)
|
54
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
55
|
+
rspec-support (~> 3.1.0)
|
56
|
+
rspec-mocks (3.1.3)
|
57
|
+
rspec-support (~> 3.1.0)
|
58
|
+
rspec-support (3.1.2)
|
59
|
+
safe_yaml (1.0.4)
|
60
|
+
sinatra (1.4.5)
|
56
61
|
rack (~> 1.4)
|
57
62
|
rack-protection (~> 1.4)
|
58
63
|
tilt (~> 1.3, >= 1.3.4)
|
59
|
-
thread_safe (0.
|
60
|
-
atomic
|
64
|
+
thread_safe (0.3.4)
|
61
65
|
tilt (1.4.1)
|
62
|
-
tzinfo (
|
63
|
-
|
64
|
-
|
66
|
+
tzinfo (1.2.2)
|
67
|
+
thread_safe (~> 0.1)
|
68
|
+
webmock (1.20.4)
|
69
|
+
addressable (>= 2.3.6)
|
65
70
|
crack (>= 0.3.2)
|
66
71
|
|
67
72
|
PLATFORMS
|
68
73
|
ruby
|
69
74
|
|
70
75
|
DEPENDENCIES
|
76
|
+
dotenv
|
71
77
|
fastimage
|
72
78
|
magickly!
|
73
79
|
newrelic_rpm
|
74
80
|
rack-cache
|
75
81
|
rack-test
|
82
|
+
rake
|
76
83
|
rspec
|
77
84
|
webmock
|
data/README.md
CHANGED
@@ -8,9 +8,10 @@ If no query params are provided, a simple sandbox page is displayed. Try it her
|
|
8
8
|
|
9
9
|
[magickly.afeld.me](http://magickly.afeld.me)
|
10
10
|
|
11
|
-
|
11
|
+
More insights:
|
12
12
|
|
13
|
-
[aidan.jux.com/nerdery/310516
|
13
|
+
* [Blog post](https://aidan.jux.com/nerdery/310516) about how it's used at <a href="https://jux.com">Jux</a>
|
14
|
+
* [Talk](http://www.hakkalabs.co/articles/anatomy-ruby-gem-magickly) at [Anatomy of a Ruby Gem](http://www.meetup.com/Anatomy-of-a-Ruby-Gem/events/163904202/) ([slides](https://docs.google.com/presentation/d/1vuXqmMOssslx3nRxqWh1e3SgGN7_euYdVMIWm94DDPA/edit?usp=sharing))
|
14
15
|
|
15
16
|
## Installation
|
16
17
|
|
@@ -195,7 +196,6 @@ See the [Dragonfly documentation](http://markevans.github.com/dragonfly/file.Gen
|
|
195
196
|
|
196
197
|
The hosted version of the app ([magickly.afeld.me](http://magickly.afeld.me)) is a single app instance intended for demonstration purposes - if you are going to be making a large number of API calls to it or would like to use it in production, please let us know :-)
|
197
198
|
|
198
|
-
##
|
199
|
-
|
200
|
-
Created by [Aidan Feldman](http://www.aidanfeldman.com) at [Jux.com](http://www.jux.com). Thanks to [Mark Evans](https://github.com/markevans) for all his hard work on [Dragonfly](http://markevans.github.com/dragonfly/).
|
199
|
+
## See Also
|
201
200
|
|
201
|
+
* [Thumbor](http://thumbor.org/)
|
data/Rakefile
CHANGED
@@ -1,9 +1,16 @@
|
|
1
|
+
require 'rspec/core/rake_task'
|
2
|
+
|
3
|
+
RSpec::Core::RakeTask.new(:spec)
|
4
|
+
|
5
|
+
desc "Runs tests"
|
6
|
+
task default: :spec
|
7
|
+
|
1
8
|
desc "Runs a performance test of different sigma values to tilt_shift"
|
2
9
|
task :blur_test do
|
3
10
|
file = File.join(File.dirname(__FILE__), 'spec', 'support', 'imagemagick.png')
|
4
11
|
dir = File.join(File.dirname(__FILE__), 'test_output')
|
5
|
-
|
6
|
-
|
12
|
+
FileUtils.mkdir_p(dir)
|
13
|
+
|
7
14
|
(5..10).each do |sigma|
|
8
15
|
print "sigma: #{sigma} "
|
9
16
|
out_file = File.join(dir, "blur_test-#{sigma}.png")
|
@@ -16,7 +23,7 @@ task :blur_test do
|
|
16
23
|
end
|
17
24
|
|
18
25
|
# RESULTS:
|
19
|
-
#
|
26
|
+
#
|
20
27
|
# radius: 5 time: 2.090919
|
21
28
|
# radius: 6 time: 2.855877
|
22
29
|
# radius: 7 time: 3.800624
|
data/lib/magickly/app.rb
CHANGED
@@ -2,16 +2,16 @@ module Magickly
|
|
2
2
|
class App < Sinatra::Base
|
3
3
|
RESERVED_PARAMS = ['src']
|
4
4
|
DEMO_IMAGE = 'http://farm4.static.flickr.com/3351/3450592233_c29fde01ef_z.jpg'
|
5
|
-
|
5
|
+
|
6
6
|
enable :logging
|
7
7
|
set :root, File.join(File.dirname(__FILE__), '..')
|
8
8
|
set :homepage, "http://github.com/afeld/magickly"
|
9
9
|
set :protection, :except => :path_traversal
|
10
|
-
|
10
|
+
|
11
11
|
configure :production do
|
12
|
-
require 'newrelic_rpm' if ENV['
|
12
|
+
require 'newrelic_rpm' if ENV['NEW_RELIC_LICENSE_KEY']
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
before do
|
16
16
|
# redirect to MAGICKLY_APP_DOMAIN, if specified
|
17
17
|
app_host = ENV['MAGICKLY_APP_DOMAIN']
|
@@ -19,17 +19,10 @@ module Magickly
|
|
19
19
|
request_host_with_port = request.env['HTTP_HOST']
|
20
20
|
redirect request.url.sub(request_host_with_port, app_host), 301
|
21
21
|
end
|
22
|
-
|
23
|
-
# parse query params so they are ordered
|
24
|
-
@options = ActiveSupport::OrderedHash.new
|
25
|
-
request.query_string.split('&').each do |e|
|
26
|
-
k,v = e.split('=')
|
27
|
-
@options[k] = URI.unescape(v) unless RESERVED_PARAMS.include?(k)
|
28
|
-
end
|
29
22
|
end
|
30
|
-
|
23
|
+
|
31
24
|
get '/' do
|
32
|
-
process_src_or_display_demo params[:src],
|
25
|
+
process_src_or_display_demo params[:src], ordered_options
|
33
26
|
end
|
34
27
|
|
35
28
|
get '/q/*' do
|
@@ -43,26 +36,26 @@ module Magickly
|
|
43
36
|
|
44
37
|
process_path decoded
|
45
38
|
end
|
46
|
-
|
39
|
+
|
47
40
|
get '/analyze' do
|
48
41
|
@analyzers = Magickly.dragonfly.analyser_methods
|
49
42
|
@analyzers.sort!{|m1, m2| m1.to_s <=> m2.to_s }
|
50
43
|
erb :analyzers
|
51
44
|
end
|
52
|
-
|
45
|
+
|
53
46
|
get '/analyze/:name' do |method|
|
54
47
|
src = params[:src]
|
55
48
|
if src
|
56
49
|
url = uri_to_url(src)
|
57
|
-
image = Magickly.process_src(url,
|
58
|
-
|
50
|
+
image = Magickly.process_src(url, ordered_options)
|
51
|
+
|
59
52
|
begin
|
60
53
|
output = image.send(method.to_sym)
|
61
54
|
rescue NoMethodError
|
62
55
|
method = method.to_s + '?'
|
63
56
|
output = image.send(method.to_sym)
|
64
57
|
end
|
65
|
-
|
58
|
+
|
66
59
|
output.is_a?(String) ? output : output.to_json
|
67
60
|
else
|
68
61
|
status 400
|
@@ -73,7 +66,7 @@ module Magickly
|
|
73
66
|
def process_path splat
|
74
67
|
src = nil
|
75
68
|
opts = []
|
76
|
-
|
69
|
+
|
77
70
|
splat.split('/').each_slice(2) do |k, v|
|
78
71
|
if RESERVED_PARAMS.include? k
|
79
72
|
if k == 'src'
|
@@ -98,20 +91,29 @@ module Magickly
|
|
98
91
|
image.to_response(env)
|
99
92
|
else
|
100
93
|
# display demo page
|
101
|
-
|
94
|
+
|
102
95
|
# get combined list of jobs and processor methods
|
103
96
|
@methods = ( Magickly.dragonfly.job_methods | Magickly.dragonfly.processor_methods )
|
104
97
|
@methods.sort!{|m1, m2| m1.to_s <=> m2.to_s }
|
105
98
|
erb :index
|
106
99
|
end
|
107
100
|
end
|
108
|
-
|
101
|
+
|
102
|
+
def ordered_options
|
103
|
+
options = ActiveSupport::OrderedHash.new
|
104
|
+
request.query_string.split('&').each do |e|
|
105
|
+
k,v = e.split('=')
|
106
|
+
options[k] = URI.unescape(v) unless RESERVED_PARAMS.include?(k)
|
107
|
+
end
|
108
|
+
options
|
109
|
+
end
|
110
|
+
|
109
111
|
def uri_to_url(uri)
|
110
112
|
url = Addressable::URI.parse(uri)
|
111
113
|
url.site ||= Addressable::URI.parse(request.url).site
|
112
114
|
url.to_s
|
113
115
|
end
|
114
|
-
|
116
|
+
|
115
117
|
# start the server if ruby file executed directly
|
116
118
|
run! if __FILE__ == $0
|
117
119
|
end
|
data/lib/magickly/version.rb
CHANGED
data/lib/shortcuts.rb
CHANGED
@@ -28,7 +28,7 @@ describe Magickly::App do
|
|
28
28
|
describe "GET /" do
|
29
29
|
it "should display the demo page for no params" do
|
30
30
|
get '/'
|
31
|
-
last_response.status.
|
31
|
+
expect(last_response.status).to eq(200)
|
32
32
|
# TODO test that it renders the view
|
33
33
|
end
|
34
34
|
|
@@ -37,8 +37,8 @@ describe Magickly::App do
|
|
37
37
|
|
38
38
|
get "/?src=#{@image_url}"
|
39
39
|
|
40
|
-
a_request(:get, @image_url).
|
41
|
-
last_response.status.
|
40
|
+
expect(a_request(:get, @image_url)).to have_been_made.once
|
41
|
+
expect(last_response.status).to eq(200)
|
42
42
|
|
43
43
|
# check that the returned file is identical to the original
|
44
44
|
compare_binary(last_response.body, IO.read(@image_path))
|
@@ -49,8 +49,8 @@ describe Magickly::App do
|
|
49
49
|
|
50
50
|
get "/?src=#{@image_url}&bad_param=666"
|
51
51
|
|
52
|
-
a_request(:get, @image_url).
|
53
|
-
last_response.status.
|
52
|
+
expect(a_request(:get, @image_url)).to have_been_made.once
|
53
|
+
expect(last_response.status).to eq(200)
|
54
54
|
|
55
55
|
# check that the returned file is identical to the original
|
56
56
|
compare_binary(last_response.body, IO.read(@image_path))
|
@@ -61,8 +61,8 @@ describe Magickly::App do
|
|
61
61
|
|
62
62
|
get "/?src=/#{@image_filename}"
|
63
63
|
|
64
|
-
a_request(:get, @image_url).
|
65
|
-
last_response.status.
|
64
|
+
expect(a_request(:get, @image_url)).to have_been_made.once
|
65
|
+
expect(last_response.status).to eq(200)
|
66
66
|
|
67
67
|
# check that the returned file is identical to the original
|
68
68
|
compare_binary(last_response.body, IO.read(@image_path))
|
@@ -74,9 +74,18 @@ describe Magickly::App do
|
|
74
74
|
|
75
75
|
file = get_image "/?src=#{@image_url}&resize=#{width}x"
|
76
76
|
|
77
|
-
a_request(:get, @image_url).
|
78
|
-
last_response.status.
|
79
|
-
FastImage.size(file)[0].
|
77
|
+
expect(a_request(:get, @image_url)).to have_been_made.once
|
78
|
+
expect(last_response.status).to eq(200)
|
79
|
+
expect(FastImage.size(file)[0]).to eq(width)
|
80
|
+
end
|
81
|
+
|
82
|
+
it "outputs an image in a new format" do
|
83
|
+
setup_image
|
84
|
+
|
85
|
+
file = get_image "/?src=#{@image_url}&output=gif"
|
86
|
+
|
87
|
+
expect(a_request(:get, @image_url)).to have_been_made.once
|
88
|
+
expect(FastImage.type(file)).to eq(:gif)
|
80
89
|
end
|
81
90
|
|
82
91
|
it "should use my Dragonfly shortcut with no arguments" do
|
@@ -91,8 +100,8 @@ describe Magickly::App do
|
|
91
100
|
|
92
101
|
file = get_image "/?src=#{@image_url}&#{shortcut}=true"
|
93
102
|
|
94
|
-
last_response.status.
|
95
|
-
FastImage.size(file)[0].
|
103
|
+
expect(last_response.status).to eq(200)
|
104
|
+
expect(FastImage.size(file)[0]).to eq width
|
96
105
|
end
|
97
106
|
|
98
107
|
it "should use my Dragonfly shortcut with one argument" do
|
@@ -107,8 +116,8 @@ describe Magickly::App do
|
|
107
116
|
|
108
117
|
file = get_image "/?src=#{@image_url}&#{shortcut}=#{width}x"
|
109
118
|
|
110
|
-
last_response.status.
|
111
|
-
FastImage.size(file)[0].
|
119
|
+
expect(last_response.status).to eq(200)
|
120
|
+
expect(FastImage.size(file)[0]).to eq width
|
112
121
|
end
|
113
122
|
end
|
114
123
|
|
@@ -120,9 +129,9 @@ describe Magickly::App do
|
|
120
129
|
|
121
130
|
file = get_image "/q/src/#{@escaped_image_url}/resize/#{width}x"
|
122
131
|
|
123
|
-
a_request(:get, @image_url).
|
124
|
-
last_response.status.
|
125
|
-
FastImage.size(file)[0].
|
132
|
+
expect(a_request(:get, @image_url)).to have_been_made.once
|
133
|
+
expect(last_response.status).to eq(200)
|
134
|
+
expect(FastImage.size(file)[0]).to eq width
|
126
135
|
end
|
127
136
|
|
128
137
|
end
|
@@ -142,9 +151,9 @@ describe Magickly::App do
|
|
142
151
|
|
143
152
|
file = get_image "/qe/#{encoded}"
|
144
153
|
|
145
|
-
a_request(:get, @image_url).
|
146
|
-
last_response.status.
|
147
|
-
FastImage.size(file)[0].
|
154
|
+
expect(a_request(:get, @image_url)).to have_been_made.once
|
155
|
+
expect(last_response.status).to eq(200)
|
156
|
+
expect(FastImage.size(file)[0]).to eq width
|
148
157
|
end
|
149
158
|
|
150
159
|
end
|
@@ -155,9 +164,9 @@ describe Magickly::App do
|
|
155
164
|
|
156
165
|
get "/analyze/mime_type?src=#{@image_url}"
|
157
166
|
|
158
|
-
a_request(:get, @image_url).
|
159
|
-
last_response.status.
|
160
|
-
last_response.body.
|
167
|
+
expect(a_request(:get, @image_url)).to have_been_made.once
|
168
|
+
expect(last_response.status).to eq(200)
|
169
|
+
expect(last_response.body).to eq 'image/png'
|
161
170
|
end
|
162
171
|
|
163
172
|
it "retrieves the color palette of an image" do
|
@@ -165,23 +174,23 @@ describe Magickly::App do
|
|
165
174
|
|
166
175
|
get "/analyze/color_palette?src=#{@image_url}"
|
167
176
|
|
168
|
-
a_request(:get, @image_url).
|
169
|
-
last_response.status.
|
170
|
-
last_response.body.
|
177
|
+
expect(a_request(:get, @image_url)).to have_been_made.once
|
178
|
+
expect(last_response.status).to eq(200)
|
179
|
+
expect(last_response.body).to_not be_empty
|
171
180
|
json = ActiveSupport::JSON.decode(last_response.body)
|
172
|
-
json.
|
173
|
-
json.size.
|
181
|
+
expect(json).to be_an Array
|
182
|
+
expect(json.size).to eq 5
|
174
183
|
end
|
175
184
|
|
176
185
|
it "should handle analyzer methods where the question mark is missing" do
|
177
|
-
Magickly.dragonfly.analyser_methods.map{|m| m.to_s }.
|
186
|
+
expect(Magickly.dragonfly.analyser_methods.map{|m| m.to_s }).to include 'landscape?'
|
178
187
|
setup_image
|
179
188
|
|
180
189
|
get "/analyze/landscape?src=#{@image_url}"
|
181
190
|
|
182
|
-
a_request(:get, @image_url).
|
183
|
-
last_response.status.
|
184
|
-
last_response.body.
|
191
|
+
expect(a_request(:get, @image_url)).to have_been_made.once
|
192
|
+
expect(last_response.status).to eq(200)
|
193
|
+
expect(last_response.body).to include('false')
|
185
194
|
end
|
186
195
|
end
|
187
196
|
end
|
@@ -197,7 +206,7 @@ describe MagicklyApp do
|
|
197
206
|
|
198
207
|
it "should display the demo page for no params" do
|
199
208
|
get '/'
|
200
|
-
last_response.status.
|
209
|
+
expect(last_response.status).to eq(200)
|
201
210
|
# TODO test that it renders the view
|
202
211
|
end
|
203
212
|
|
data/spec/spec_helper.rb
CHANGED
@@ -13,7 +13,7 @@ require 'fastimage'
|
|
13
13
|
set :environment, :test
|
14
14
|
|
15
15
|
RSpec.configure do |config|
|
16
|
-
|
16
|
+
config.raise_errors_for_deprecations!
|
17
17
|
end
|
18
18
|
|
19
19
|
def compare_binary(one, two)
|
@@ -22,6 +22,6 @@ def compare_binary(one, two)
|
|
22
22
|
one = one.force_encoding("UTF-8")
|
23
23
|
two = two.force_encoding("UTF-8")
|
24
24
|
end
|
25
|
-
|
26
|
-
one.
|
25
|
+
|
26
|
+
expect(one).to eq two
|
27
27
|
end
|
data/spec/unit/magickly_spec.rb
CHANGED
@@ -9,10 +9,10 @@ describe Magickly do
|
|
9
9
|
|
10
10
|
returned_image = Magickly.process_src(image_url)
|
11
11
|
|
12
|
-
returned_image.
|
12
|
+
expect(returned_image).to_not be_nil
|
13
13
|
|
14
14
|
# check that the returned file is identical to the original
|
15
|
-
IO.read(returned_image.file.path).
|
15
|
+
expect(IO.read(returned_image.file.path)).to eq IO.read(image_path)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
@@ -8,7 +8,7 @@ describe Dragonfly::DataStorage::RemoteDataStore do
|
|
8
8
|
datastore = Dragonfly::DataStorage::RemoteDataStore.new
|
9
9
|
|
10
10
|
datastore.retrieve url
|
11
|
-
a_request(:get, url).
|
11
|
+
expect(a_request(:get, url)).to have_been_made.once
|
12
12
|
end
|
13
13
|
|
14
14
|
it "should return the image" do
|
@@ -18,7 +18,7 @@ describe Dragonfly::DataStorage::RemoteDataStore do
|
|
18
18
|
datastore = Dragonfly::DataStorage::RemoteDataStore.new
|
19
19
|
|
20
20
|
image,extra = datastore.retrieve(url)
|
21
|
-
image.
|
21
|
+
expect(image).to eq IO.read(image_path)
|
22
22
|
end
|
23
23
|
|
24
24
|
it "should fetch the image based on the url_host variable" do
|
@@ -33,7 +33,7 @@ describe Dragonfly::DataStorage::RemoteDataStore do
|
|
33
33
|
end
|
34
34
|
|
35
35
|
datastore.retrieve path
|
36
|
-
a_request(:get, url).
|
36
|
+
expect(a_request(:get, url)).to have_been_made.once
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
data/spec/unit/shortcut_spec.rb
CHANGED
@@ -27,20 +27,20 @@ describe "Dragonfly shortcuts" do
|
|
27
27
|
describe :color_palette do
|
28
28
|
it "should return an array" do
|
29
29
|
palette = @image.color_palette
|
30
|
-
palette.
|
30
|
+
expect(palette).to be_an Array
|
31
31
|
end
|
32
32
|
|
33
33
|
it "should have the default number of colors" do
|
34
34
|
palette = @image.color_palette
|
35
|
-
palette.length.
|
35
|
+
expect(palette.length).to eq Magickly::DEFAULT_PALETTE_COLOR_COUNT
|
36
36
|
end
|
37
37
|
|
38
38
|
it "should have the specified number of colors" do
|
39
39
|
num_colors = 4
|
40
|
-
num_colors.
|
40
|
+
expect(num_colors).to_not eq Magickly::DEFAULT_PALETTE_COLOR_COUNT
|
41
41
|
|
42
42
|
palette = @image.color_palette(num_colors)
|
43
|
-
palette.length.
|
43
|
+
expect(palette.length).to eq num_colors
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: magickly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aidan Feldman
|
@@ -133,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
133
133
|
version: '0'
|
134
134
|
requirements: []
|
135
135
|
rubyforge_project:
|
136
|
-
rubygems_version: 2.
|
136
|
+
rubygems_version: 2.4.5
|
137
137
|
signing_key:
|
138
138
|
specification_version: 4
|
139
139
|
summary: image manipulation as a (plugin-able) service
|