ruby-thumbor 2.0.1 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.rdoc +12 -8
- data/lib/ruby-thumbor.rb +0 -1
- data/lib/thumbor/cascade.rb +5 -9
- data/lib/thumbor/crypto_url.rb +8 -28
- data/lib/thumbor/version.rb +1 -1
- data/spec/spec_helper.rb +7 -3
- data/spec/thumbor/cascade_spec.rb +147 -324
- metadata +7 -67
- data/spec/thumbor/crypto_url_spec.rb +0 -482
- data/spec/util/thumbor.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3aea89d8e9ceb84d32afce82d907f37e9a36387f599cd99947955259142c2149
|
4
|
+
data.tar.gz: 724e15742e517340b63889d356d6195d6c6244e8835dffb86eb5ad7d873bba61
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e17c2247defe2aa6674d7b6f9ffe299207fed86acffc180c926c3d21d6a2d81bd33faddfcf2290d4fe39bcc6473836d25eb3e2045dd1b383ccb0a6810243780c
|
7
|
+
data.tar.gz: e76fe2e009b22c96f82d6ea2834a02faec7af7d5ebfbe4416c990020f3e23f880aa36a0060e89b46f3708453d6f9e6eafdcd937ae019be92bde6ccb7c015ff41
|
data/README.rdoc
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
= ruby-thumbor {<img src="https://secure.travis-ci.org/thumbor/ruby-thumbor.png?branch=master" alt="Build Status" />}[http://travis-ci.org/thumbor/ruby-thumbor] {<img src="https://
|
2
|
-
|
1
|
+
= ruby-thumbor {<img src="https://secure.travis-ci.org/thumbor/ruby-thumbor.png?branch=master" alt="Build Status" />}[http://travis-ci.org/thumbor/ruby-thumbor] {<img src="https://badge.fury.io/rb/ruby-thumbor.svg" alt="Gem Version" />}[http://badge.fury.io/rb/ruby-thumbor] {<img src="https://coveralls.io/repos/thumbor/ruby-thumbor/badge.svg?branch=master&service=github" alt="Coverage Status" />}[https://coveralls.io/github/thumbor/ruby-thumbor?branch=master]
|
3
2
|
|
4
3
|
|
5
4
|
* http://github.com/thumbor/ruby-thumbor
|
@@ -25,9 +24,10 @@ No dependencies required for regular usage.
|
|
25
24
|
|
26
25
|
gem 'ruby-thumbor'
|
27
26
|
|
28
|
-
== BREAKING CHANGE ON
|
27
|
+
== BREAKING CHANGE ON 3.0:
|
29
28
|
|
30
|
-
|
29
|
+
Old image Url isn't supported anymore
|
30
|
+
Switch from #url_for to #generate method
|
31
31
|
|
32
32
|
== USAGE:
|
33
33
|
|
@@ -35,17 +35,19 @@ No dependencies required for regular usage.
|
|
35
35
|
|
36
36
|
crypto = Thumbor::CryptoURL.new 'my-security-key'
|
37
37
|
|
38
|
-
url = crypto.generate :width => 200, :height => 300, :image => '
|
38
|
+
url = crypto.generate :width => 200, :height => 300, :image => 'remote-image.com/path/to/image.jpg'
|
39
39
|
|
40
40
|
# url will contain something like:
|
41
|
-
# /2913921in321n3k2nj32hjhj3h22/
|
41
|
+
# /2913921in321n3k2nj32hjhj3h22/remote-image.com/path/to/image.jpg
|
42
|
+
|
43
|
+
# Now you just need to concatenate this generated path, with your thumbor server url
|
42
44
|
|
43
45
|
or
|
44
46
|
|
45
47
|
require 'ruby-thumbor'
|
46
48
|
|
47
|
-
image = Thumbor::Cascade.new('my-security-key', '
|
48
|
-
image.width(300).height(200).watermark_filter('http://
|
49
|
+
image = Thumbor::Cascade.new('my-security-key', 'remote-image.com/path/to/image.jpg')
|
50
|
+
image.width(300).height(200).watermark_filter('http://remote-image.com/path/to/image.jpg', 30).generate
|
49
51
|
|
50
52
|
Available arguments to the generate method:
|
51
53
|
|
@@ -70,6 +72,8 @@ Available arguments to the generate method:
|
|
70
72
|
|
71
73
|
:smart => <bool> - flag that indicates that thumbor should use smart cropping;
|
72
74
|
|
75
|
+
:filters => ['blur(20)', 'watermark(http://my.site.com/img.png,-10,-10,50)'] - array of filters and their arguments
|
76
|
+
|
73
77
|
If you need more info on what each option does, check thumbor's documentation at https://github.com/thumbor/thumbor/wiki.
|
74
78
|
|
75
79
|
== CONTRIBUTIONS:
|
data/lib/ruby-thumbor.rb
CHANGED
data/lib/thumbor/cascade.rb
CHANGED
@@ -6,7 +6,7 @@ require 'cgi'
|
|
6
6
|
|
7
7
|
module Thumbor
|
8
8
|
class Cascade
|
9
|
-
attr_accessor :image, :
|
9
|
+
attr_accessor :image, :crypto, :options, :filters
|
10
10
|
|
11
11
|
@available_options = [
|
12
12
|
:meta, :crop, :center,
|
@@ -15,11 +15,11 @@ module Thumbor
|
|
15
15
|
:flop, :halign, :valign,
|
16
16
|
:smart, :fit_in, :adaptive_fit_in,
|
17
17
|
:full_fit_in, :adaptive_full_fit_in,
|
18
|
-
:
|
18
|
+
:trim, :debug]
|
19
19
|
|
20
20
|
extend Forwardable
|
21
21
|
|
22
|
-
def_delegators :@
|
22
|
+
def_delegators :@crypto, :computed_key
|
23
23
|
|
24
24
|
@available_options.each do |opt|
|
25
25
|
define_method(opt) do |*args|
|
@@ -34,15 +34,11 @@ module Thumbor
|
|
34
34
|
@image = image
|
35
35
|
@options = {}
|
36
36
|
@filters = []
|
37
|
-
@
|
38
|
-
end
|
39
|
-
|
40
|
-
def url_for
|
41
|
-
@old_crypto.url_for prepare_options(@options).merge({image: @image, filters: @filters})
|
37
|
+
@crypto = Thumbor::CryptoURL.new @key
|
42
38
|
end
|
43
39
|
|
44
40
|
def generate
|
45
|
-
@
|
41
|
+
@crypto.generate prepare_options(@options).merge({image: @image, filters: @filters})
|
46
42
|
end
|
47
43
|
|
48
44
|
def method_missing(m, *args)
|
data/lib/thumbor/crypto_url.rb
CHANGED
@@ -5,7 +5,7 @@ require 'cgi'
|
|
5
5
|
|
6
6
|
module Thumbor
|
7
7
|
class CryptoURL
|
8
|
-
|
8
|
+
attr_writer :computed_key
|
9
9
|
|
10
10
|
def initialize(key=false)
|
11
11
|
@key = key
|
@@ -15,10 +15,6 @@ module Thumbor
|
|
15
15
|
(@key * 16)[0..15]
|
16
16
|
end
|
17
17
|
|
18
|
-
def pad(s)
|
19
|
-
s + ("{" * (16 - s.length % 16))
|
20
|
-
end
|
21
|
-
|
22
18
|
def calculate_width_and_height(url_parts, options)
|
23
19
|
width = options[:width]
|
24
20
|
height = options[:height]
|
@@ -125,13 +121,17 @@ module Thumbor
|
|
125
121
|
options[:crop] = crop
|
126
122
|
end
|
127
123
|
|
128
|
-
def url_for(options
|
124
|
+
def url_for(options)
|
129
125
|
if not options[:image]
|
130
126
|
raise 'image is a required argument.'
|
131
127
|
end
|
132
128
|
|
133
129
|
url_parts = Array.new
|
134
130
|
|
131
|
+
if options[:debug]
|
132
|
+
url_parts.push('debug')
|
133
|
+
end
|
134
|
+
|
135
135
|
if options[:trim]
|
136
136
|
trim_options = ['trim']
|
137
137
|
trim_options << options[:trim] unless options[:trim] == true or options[:trim][0] == true
|
@@ -189,11 +189,6 @@ module Thumbor
|
|
189
189
|
url_parts.push("filters:#{ filter_parts.join(':') }")
|
190
190
|
end
|
191
191
|
|
192
|
-
if include_hash
|
193
|
-
image_hash = Digest::MD5.hexdigest(options[:image])
|
194
|
-
url_parts.push(image_hash)
|
195
|
-
end
|
196
|
-
|
197
192
|
return url_parts.join('/')
|
198
193
|
end
|
199
194
|
|
@@ -201,20 +196,10 @@ module Thumbor
|
|
201
196
|
Base64.encode64(str).gsub('+', '-').gsub('/', '_').gsub!(/[\n]/, '')
|
202
197
|
end
|
203
198
|
|
204
|
-
def
|
205
|
-
url = pad(url_for(options))
|
206
|
-
cipher = OpenSSL::Cipher::Cipher.new('aes-128-ecb').encrypt
|
207
|
-
cipher.key = computed_key
|
208
|
-
encrypted = cipher.update(url)
|
209
|
-
based = url_safe_base64(encrypted)
|
210
|
-
|
211
|
-
"/#{based}/#{options[:image]}"
|
212
|
-
end
|
213
|
-
|
214
|
-
def generate_new(options)
|
199
|
+
def generate(options)
|
215
200
|
thumbor_path = ""
|
216
201
|
|
217
|
-
image_options = url_for(options
|
202
|
+
image_options = url_for(options)
|
218
203
|
thumbor_path << image_options + '/' unless image_options.empty?
|
219
204
|
|
220
205
|
thumbor_path << options[:image]
|
@@ -227,10 +212,5 @@ module Thumbor
|
|
227
212
|
end
|
228
213
|
thumbor_path
|
229
214
|
end
|
230
|
-
|
231
|
-
def generate(options)
|
232
|
-
return generate_old(options) if options[:old]
|
233
|
-
generate_new(options)
|
234
|
-
end
|
235
215
|
end
|
236
216
|
end
|
data/lib/thumbor/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,12 +1,16 @@
|
|
1
1
|
require 'simplecov'
|
2
|
-
|
3
|
-
|
2
|
+
begin
|
3
|
+
require 'coveralls'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'Running on Jruby'
|
6
|
+
end
|
7
|
+
|
8
|
+
Coveralls.wear! if defined? Coveralls
|
4
9
|
|
5
10
|
SimpleCov.start do
|
6
11
|
add_filter '/spec/'
|
7
12
|
end
|
8
13
|
|
9
|
-
|
10
14
|
RSpec.configure do |c|
|
11
15
|
c.filter_run :focus => true
|
12
16
|
c.run_all_when_everything_filtered = true
|
@@ -1,11 +1,9 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'json'
|
3
3
|
require 'ruby-thumbor'
|
4
|
-
require 'util/thumbor'
|
5
4
|
|
6
5
|
describe Thumbor::Cascade do
|
7
6
|
let(:image_url) { 'my.domain.com/some/image/url.jpg' }
|
8
|
-
let(:image_md5) { 'f33af67e41168e80fcc5b00f8bd8061a' }
|
9
7
|
let(:key) { 'my-security-key' }
|
10
8
|
|
11
9
|
subject { Thumbor::Cascade.new key, image_url }
|
@@ -21,477 +19,302 @@ describe Thumbor::Cascade do
|
|
21
19
|
expect{ subject.god_of_war_crop }.to raise_error(NoMethodError)
|
22
20
|
end
|
23
21
|
|
24
|
-
describe '#
|
22
|
+
describe '#generate' do
|
23
|
+
|
24
|
+
it "should create an unsafe url" do
|
25
|
+
url = Thumbor::Cascade.new(false, image_url).width(300).height(200).generate
|
26
|
+
expect(url).to eq '/unsafe/300x200/my.domain.com/some/image/url.jpg'
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should create an url with debug" do
|
30
|
+
url = subject.debug(true).height(200).generate
|
31
|
+
expect(url).to eq '/5_eX4HHQYk81HQVkc1gBIAvPbLo=/debug/0x200/my.domain.com/some/image/url.jpg'
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should create a new instance passing key and keep it" do
|
35
|
+
url = subject.width(300).height(200).generate
|
36
|
+
expect(url).to eq '/TQfyd3H36Z3srcNcLOYiM05YNO8=/300x200/my.domain.com/some/image/url.jpg'
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should be able to change the Thumbor key" do
|
40
|
+
url1 = subject.width(300).height(200).generate
|
41
|
+
url2 = Thumbor::Cascade.new('another-thumbor-key', image_url).width(300).height(200).generate
|
42
|
+
expect(url1).not_to eq url2
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should create a new instance passing key and keep it" do
|
46
|
+
url = subject.width(300).height(200).meta(true).generate
|
47
|
+
expect(url).to eq '/YBQEWd3g_WRMnVEG73zfzcr8Zj0=/meta/300x200/my.domain.com/some/image/url.jpg'
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should create a new instance passing key and keep it" do
|
51
|
+
url = subject.width(300).height(200).meta(true).smart(true).generate
|
52
|
+
expect(url).to eq '/jP89J0qOWHgPlm_lOA28GtOh5GU=/meta/300x200/smart/my.domain.com/some/image/url.jpg'
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should create a new instance passing key and keep it" do
|
56
|
+
url = subject.width(300).height(200).meta(true).smart(true).fit_in(true).generate
|
57
|
+
expect(url).to eq '/zrrOh_TtTs4kiLLEQq1w4bcTYdc=/meta/fit-in/300x200/smart/my.domain.com/some/image/url.jpg'
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should create a new instance passing key and keep it" do
|
61
|
+
url = subject.width(300).height(200).meta(true).smart(true).fit_in(true).flip(true).generate
|
62
|
+
expect(url).to eq '/4t1XK1KH43cOb1QJ9tU00-W2_k8=/meta/fit-in/-300x200/smart/my.domain.com/some/image/url.jpg'
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should create a new instance passing key and keep it" do
|
66
|
+
url = subject.width(300).height(200).meta(true).smart(true).fit_in(true).flip(true).flop(true).generate
|
67
|
+
expect(url).to eq '/HJnvjZU69PkPOhyZGu-Z3Uc_W_A=/meta/fit-in/-300x-200/smart/my.domain.com/some/image/url.jpg'
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should create a new instance passing key and keep it" do
|
71
|
+
url = subject.quality_filter(20).brightness_filter(10).generate
|
72
|
+
expect(url).to eq '/q0DiFg-5-eFZIqyN3lRoCvg2K0s=/filters:quality(20):brightness(10)/my.domain.com/some/image/url.jpg'
|
73
|
+
end
|
25
74
|
|
26
75
|
it "should return just the image hash if no arguments passed" do
|
27
|
-
url = subject.
|
28
|
-
expect(url).to eq
|
76
|
+
url = subject.generate
|
77
|
+
expect(url).to eq '/964rCTkAEDtvjy_a572k7kRa0SU=/my.domain.com/some/image/url.jpg'
|
29
78
|
end
|
30
79
|
|
31
80
|
it "should raise if no image passed" do
|
32
|
-
expect { Thumbor::Cascade.new.
|
81
|
+
expect { Thumbor::Cascade.new.generate }.to raise_error(RuntimeError)
|
33
82
|
end
|
34
83
|
|
35
84
|
it "should return proper url for width-only" do
|
36
|
-
url = subject.width(300).
|
37
|
-
expect(url).to eq '300x0/'
|
85
|
+
url = subject.width(300).generate
|
86
|
+
expect(url).to eq '/eFwrBWryxtRw9hDSbQPhi5iLpo8=/300x0/my.domain.com/some/image/url.jpg'
|
38
87
|
end
|
39
88
|
|
40
89
|
it "should return proper url for height-only" do
|
41
|
-
url = subject.height(300).
|
42
|
-
expect(url).to eq '0x300/'
|
90
|
+
url = subject.height(300).generate
|
91
|
+
expect(url).to eq '/-VGIgp7g8cMKcfF2gFK9ZpmB_5w=/0x300/my.domain.com/some/image/url.jpg'
|
43
92
|
end
|
44
93
|
|
45
94
|
it "should return proper url for width and height" do
|
46
|
-
url = subject.width(200).height(300).
|
47
|
-
expect(url).to eq '200x300/'
|
95
|
+
url = subject.width(200).height(300).generate
|
96
|
+
expect(url).to eq '/TrM0qqfcivb6VxS3Hxlxn43W21k=/200x300/my.domain.com/some/image/url.jpg'
|
48
97
|
end
|
49
98
|
|
50
99
|
it "should return proper smart url" do
|
51
|
-
url = subject.width(200).height(300).smart(true).
|
52
|
-
expect(url).to eq '200x300/smart/'
|
100
|
+
url = subject.width(200).height(300).smart(true).generate
|
101
|
+
expect(url).to eq '/hdzhxXzK45DzNTru5urV6x6xxSs=/200x300/smart/my.domain.com/some/image/url.jpg'
|
53
102
|
end
|
54
103
|
|
55
104
|
it "should return proper fit-in url" do
|
56
|
-
url = subject.width(200).height(300).fit_in(true).
|
57
|
-
expect(url).to eq 'fit-in/200x300/'
|
105
|
+
url = subject.width(200).height(300).fit_in(true).generate
|
106
|
+
expect(url).to eq '/LOv6ArMOJA2VRpfMQjjs4xSyZpM=/fit-in/200x300/my.domain.com/some/image/url.jpg'
|
58
107
|
end
|
59
108
|
|
60
109
|
it "should return proper adaptive-fit-in url" do
|
61
|
-
url = subject.width(200).height(300).adaptive_fit_in(true).
|
62
|
-
expect(url).to eq 'adaptive-fit-in/200x300/'
|
110
|
+
url = subject.width(200).height(300).adaptive_fit_in(true).generate
|
111
|
+
expect(url).to eq '/V2xmSmQZm4i5-0Flx8iuRtawOkg=/adaptive-fit-in/200x300/my.domain.com/some/image/url.jpg'
|
63
112
|
end
|
64
113
|
|
65
114
|
it "should return proper full-fit-in url" do
|
66
|
-
url = subject.width(200).height(300).full_fit_in(true).
|
67
|
-
expect(url).to eq 'full-fit-in/200x300/'
|
115
|
+
url = subject.width(200).height(300).full_fit_in(true).generate
|
116
|
+
expect(url).to eq '/geXhR7ZFxztQTsKzmkDxYCX-HHg=/full-fit-in/200x300/my.domain.com/some/image/url.jpg'
|
68
117
|
end
|
69
118
|
|
70
119
|
it "should return proper adaptive-full-fit-in url" do
|
71
|
-
url = subject.width(200).height(300).adaptive_full_fit_in(true).
|
72
|
-
expect(url).to eq 'adaptive-full-fit-in/200x300/'
|
120
|
+
url = subject.width(200).height(300).adaptive_full_fit_in(true).generate
|
121
|
+
expect(url).to eq '/jlUfjdC-6rG6jmuHgFp6eKgPy2g=/adaptive-full-fit-in/200x300/my.domain.com/some/image/url.jpg'
|
73
122
|
end
|
74
123
|
|
75
124
|
[:fit_in, :full_fit_in].each do |fit|
|
76
125
|
it "should raise error when using #{fit} without width or height" do
|
77
126
|
subject.send(fit, true)
|
78
|
-
expect{subject.
|
127
|
+
expect{subject.generate}.to raise_error(ArgumentError)
|
79
128
|
end
|
80
129
|
end
|
81
130
|
|
82
131
|
it "should return proper flip url if no width and height" do
|
83
|
-
url = subject.flip(true).
|
84
|
-
expect(url).to eq '-0x0/'
|
132
|
+
url = subject.flip(true).generate
|
133
|
+
expect(url).to eq '/rlI4clPR-p-PR2QAxj5ZWiTfvH4=/-0x0/my.domain.com/some/image/url.jpg'
|
85
134
|
end
|
86
135
|
|
87
136
|
it "should return proper flop url if no width and height" do
|
88
|
-
url = subject.flop(true).
|
89
|
-
expect(url).to eq '0x-0/'
|
137
|
+
url = subject.flop(true).generate
|
138
|
+
expect(url).to eq '/-4dmGj-TwIEqTAL9_9yEqUM8cks=/0x-0/my.domain.com/some/image/url.jpg'
|
90
139
|
end
|
91
140
|
|
92
141
|
it "should return proper flip-flop url if no width and height" do
|
93
|
-
url = subject.flip(true).flop(true).
|
94
|
-
expect(url).to eq '
|
142
|
+
url = subject.flip(true).flop(true).generate
|
143
|
+
expect(url).to eq '/FnMxpQMmxiMpdG219Dsj8pD_4Xc=/-0x-0/my.domain.com/some/image/url.jpg'
|
95
144
|
end
|
96
145
|
|
97
146
|
it "should return proper flip url if width" do
|
98
|
-
url = subject.width(300).flip(true).
|
99
|
-
expect(url).to eq '
|
147
|
+
url = subject.width(300).flip(true).generate
|
148
|
+
expect(url).to eq '/ccr2PoSYcTEGL4_Wzt4u3wWVRKU=/-300x0/my.domain.com/some/image/url.jpg'
|
100
149
|
end
|
101
150
|
|
102
151
|
it "should return proper flop url if height" do
|
103
|
-
url = subject.height(300).flop(true).
|
104
|
-
expect(url).to eq '0x-300/'
|
152
|
+
url = subject.height(300).flop(true).generate
|
153
|
+
expect(url).to eq '/R5K91tkyNgXO65F6E0txgA6C9lY=/0x-300/my.domain.com/some/image/url.jpg'
|
105
154
|
end
|
106
155
|
|
107
156
|
it "should return horizontal align" do
|
108
|
-
url = subject.halign(:left).
|
109
|
-
expect(url).to eq 'left/'
|
157
|
+
url = subject.halign(:left).generate
|
158
|
+
expect(url).to eq '/GTJE3wUt3sURik0O9Nae8sfI928=/left/my.domain.com/some/image/url.jpg'
|
110
159
|
end
|
111
160
|
|
112
161
|
it "should not return horizontal align if it is center" do
|
113
|
-
url = subject.halign(:center).
|
114
|
-
expect(url).to eq
|
162
|
+
url = subject.halign(:center).generate
|
163
|
+
expect(url).to eq '/964rCTkAEDtvjy_a572k7kRa0SU=/my.domain.com/some/image/url.jpg'
|
115
164
|
end
|
116
165
|
|
117
166
|
it "should return vertical align" do
|
118
|
-
url = subject.valign(:top).
|
119
|
-
expect(url).to eq 'top/'
|
167
|
+
url = subject.valign(:top).generate
|
168
|
+
expect(url).to eq '/1QQo5ihObuhgwl95--Z3g78vjiE=/top/my.domain.com/some/image/url.jpg'
|
120
169
|
end
|
121
170
|
|
122
171
|
it "should not return vertical align if it is middle" do
|
123
|
-
url = subject.valign(:middle).
|
124
|
-
expect(url).to eq
|
172
|
+
url = subject.valign(:middle).generate
|
173
|
+
expect(url).to eq '/964rCTkAEDtvjy_a572k7kRa0SU=/my.domain.com/some/image/url.jpg'
|
125
174
|
end
|
126
175
|
|
127
176
|
it "should return halign and valign properly" do
|
128
|
-
url = subject.halign(:left).valign(:top).
|
129
|
-
expect(url).to eq 'left/top/'
|
177
|
+
url = subject.halign(:left).valign(:top).generate
|
178
|
+
expect(url).to eq '/yA2rmtWv_uzHd9klz5OuMIZ5auI=/left/top/my.domain.com/some/image/url.jpg'
|
130
179
|
end
|
131
180
|
|
132
181
|
it "should return meta properly" do
|
133
|
-
url = subject.meta(true).
|
134
|
-
expect(url).to eq 'meta/'
|
182
|
+
url = subject.meta(true).generate
|
183
|
+
expect(url).to eq '/WvIJFDJDePgIl5hZcLgtrzIPxfY=/meta/my.domain.com/some/image/url.jpg'
|
135
184
|
end
|
136
185
|
|
137
186
|
it "should return proper crop url when param is array" do
|
138
|
-
url = subject.crop([10, 20, 30, 40]).
|
139
|
-
expect(url).to eq '10x20:30x40/'
|
187
|
+
url = subject.crop([10, 20, 30, 40]).generate
|
188
|
+
expect(url).to eq '/QcnhqNfHwiP6BHLbD6UvneX7K28=/10x20:30x40/my.domain.com/some/image/url.jpg'
|
140
189
|
end
|
141
190
|
|
142
191
|
it "should return proper crop url" do
|
143
|
-
url = subject.crop(10, 20, 30, 40).
|
144
|
-
expect(url).to eq '10x20:30x40/'
|
192
|
+
url = subject.crop(10, 20, 30, 40).generate
|
193
|
+
expect(url).to eq '/QcnhqNfHwiP6BHLbD6UvneX7K28=/10x20:30x40/my.domain.com/some/image/url.jpg'
|
145
194
|
end
|
146
195
|
|
147
196
|
it "should ignore crop if all zeros" do
|
148
|
-
url = subject.crop(0, 0, 0, 0).
|
149
|
-
expect(url).to eq
|
197
|
+
url = subject.crop(0, 0, 0, 0).generate
|
198
|
+
expect(url).to eq '/964rCTkAEDtvjy_a572k7kRa0SU=/my.domain.com/some/image/url.jpg'
|
150
199
|
end
|
151
200
|
|
152
201
|
it "should have smart after halign and valign" do
|
153
|
-
url = subject.halign(:left).valign(:top).smart(true).
|
154
|
-
expect(url).to eq 'left/top/smart/'
|
202
|
+
url = subject.halign(:left).valign(:top).smart(true).generate
|
203
|
+
expect(url).to eq '/KS6mVuzlGE3hJ75n3JUonfGgSFM=/left/top/smart/my.domain.com/some/image/url.jpg'
|
155
204
|
end
|
156
205
|
|
157
206
|
it "should have quality filter" do
|
158
|
-
url = subject.quality_filter(20).
|
159
|
-
expect(url).to eq 'filters:quality(20)/'
|
207
|
+
url = subject.quality_filter(20).generate
|
208
|
+
expect(url).to eq '/NyA-is4NojxiRqo0NcmJDhB6GTs=/filters:quality(20)/my.domain.com/some/image/url.jpg'
|
160
209
|
end
|
161
210
|
|
162
211
|
it "should have brightness filter" do
|
163
|
-
url = subject.brightness_filter(30).
|
164
|
-
expect(url).to eq 'filters:brightness(30)/'
|
212
|
+
url = subject.brightness_filter(30).generate
|
213
|
+
expect(url).to eq '/oXDmnGD7vQV-rXcj8kCl1tcS3jc=/filters:brightness(30)/my.domain.com/some/image/url.jpg'
|
165
214
|
end
|
166
215
|
|
167
216
|
it "should have 2 filters" do
|
168
|
-
url = subject.brightness_filter(30).quality_filter(20).
|
169
|
-
expect(url).to eq 'filters:brightness(30):quality(20)/'
|
217
|
+
url = subject.brightness_filter(30).quality_filter(20).generate
|
218
|
+
expect(url).to eq '/SW9o4xQG1QAzE69WzEzarL_G3MI=/filters:brightness(30):quality(20)/my.domain.com/some/image/url.jpg'
|
170
219
|
end
|
171
220
|
|
172
221
|
it "should escape url args" do
|
173
|
-
url = subject.watermark_filter('http://my-server.com/image.png', 30).quality_filter(20).
|
174
|
-
expect(url).to eq 'filters:watermark(http%3A%2F%2Fmy-server.com%2Fimage.png,30):quality(20)/'
|
222
|
+
url = subject.watermark_filter('http://my-server.com/image.png', 30).quality_filter(20).generate
|
223
|
+
expect(url).to eq '/4b9kwg0-zsojf7Ed01TPKPYOel4=/filters:watermark(http%3A%2F%2Fmy-server.com%2Fimage.png,30):quality(20)/my.domain.com/some/image/url.jpg'
|
175
224
|
end
|
176
225
|
|
177
226
|
it "should have trim without params" do
|
178
|
-
url = subject.trim.
|
179
|
-
expect(url).to eq 'trim/'
|
227
|
+
url = subject.trim.generate
|
228
|
+
expect(url).to eq '/w23BC0dUiYBFrUnuoYJe8XROuyw=/trim/my.domain.com/some/image/url.jpg'
|
180
229
|
end
|
181
230
|
|
182
231
|
it "should have trim with direction param" do
|
183
|
-
url = subject.trim('bottom-right').
|
184
|
-
expect(url).to eq 'trim:bottom-right/'
|
232
|
+
url = subject.trim('bottom-right').generate
|
233
|
+
expect(url).to eq '/kXPwSmqEvPFQezgzBCv9BtPWmBY=/trim:bottom-right/my.domain.com/some/image/url.jpg'
|
185
234
|
end
|
186
235
|
|
187
236
|
it "should have trim with direction and tolerance param" do
|
188
|
-
url = subject.trim('bottom-right', 15).
|
189
|
-
expect(url).to eq 'trim:bottom-right:15/'
|
237
|
+
url = subject.trim('bottom-right', 15).generate
|
238
|
+
expect(url).to eq '/TUCEIhtWfI1Uv9zjavCSl_i0A_8=/trim:bottom-right:15/my.domain.com/some/image/url.jpg'
|
190
239
|
end
|
191
240
|
|
192
241
|
it "should have the right crop when cropping horizontally and given a left center" do
|
193
|
-
url = subject.original_width(100).original_height(100).width(40).height(50).center(0, 50).
|
194
|
-
expect(url).to eq '0x0:80x100/40x50/'
|
242
|
+
url = subject.original_width(100).original_height(100).width(40).height(50).center(0, 50).generate
|
243
|
+
expect(url).to eq '/SZIT3w4Qgebv5DuVJ8G1IH1mkCU=/0x0:80x100/40x50/my.domain.com/some/image/url.jpg'
|
195
244
|
end
|
196
245
|
|
197
246
|
it "should have the right crop when cropping horizontally and given a right center" do
|
198
|
-
url = subject.original_width(100).original_height(100).width(40).height(50).center(100, 50).
|
199
|
-
expect(url).to eq '20x0:100x100/40x50/'
|
247
|
+
url = subject.original_width(100).original_height(100).width(40).height(50).center(100, 50).generate
|
248
|
+
expect(url).to eq '/NEtCYehaISE7qR3zFj15CxnZoCs=/20x0:100x100/40x50/my.domain.com/some/image/url.jpg'
|
200
249
|
end
|
201
250
|
|
202
251
|
it "should have the right crop when cropping horizontally and given the actual center" do
|
203
|
-
url = subject.original_width(100).original_height(100).width(40).height(50).center(50, 50).
|
204
|
-
expect(url).to eq '10x0:90x100/40x50/'
|
252
|
+
url = subject.original_width(100).original_height(100).width(40).height(50).center(50, 50).generate
|
253
|
+
expect(url).to eq '/JLH65vJTu6d-cXBmqe5hYoSD4ho=/10x0:90x100/40x50/my.domain.com/some/image/url.jpg'
|
205
254
|
end
|
206
255
|
|
207
256
|
it "should have the right crop when cropping vertically and given a top center" do
|
208
|
-
url = subject.original_width(100).original_height(100).width(50).height(40).center(50, 0).
|
209
|
-
expect(url).to eq '0x0:100x80/50x40/'
|
257
|
+
url = subject.original_width(100).original_height(100).width(50).height(40).center(50, 0).generate
|
258
|
+
expect(url).to eq '/FIMZcLatW6bjgSRH9xTkEwUZAZ8=/0x0:100x80/50x40/my.domain.com/some/image/url.jpg'
|
210
259
|
end
|
211
260
|
|
212
261
|
it "should have the right crop when cropping vertically and given a bottom center" do
|
213
|
-
url = subject.original_width(100).original_height(100).width(50).height(40).center(50, 100).
|
214
|
-
expect(url).to eq '0x20:100x100/50x40/'
|
262
|
+
url = subject.original_width(100).original_height(100).width(50).height(40).center(50, 100).generate
|
263
|
+
expect(url).to eq '/9Ud0sVo6i9DLOjlKbQP_4JXgFmA=/0x20:100x100/50x40/my.domain.com/some/image/url.jpg'
|
215
264
|
end
|
216
265
|
|
217
266
|
it "should have the right crop when cropping vertically and given the actual center" do
|
218
|
-
url = subject.original_width(100).original_height(100).width(50).height(40).center(50, 50).
|
219
|
-
expect(url).to eq '0x10:100x90/50x40/'
|
267
|
+
url = subject.original_width(100).original_height(100).width(50).height(40).center(50, 50).generate
|
268
|
+
expect(url).to eq '/WejLJn8djJLn7DkMUq3S0zZCvZE=/0x10:100x90/50x40/my.domain.com/some/image/url.jpg'
|
220
269
|
end
|
221
270
|
|
222
271
|
it "should have the no crop when not necessary" do
|
223
|
-
url = subject.original_width(100).original_height(100).width(50).height(50).center(50, 0).
|
224
|
-
expect(url).to eq '50x50/'
|
272
|
+
url = subject.original_width(100).original_height(100).width(50).height(50).center(50, 0).generate
|
273
|
+
expect(url).to eq '/trIjfr513nkGkCpKXK6qgox2jPA=/50x50/my.domain.com/some/image/url.jpg'
|
225
274
|
end
|
226
275
|
|
227
276
|
it "should blow up with a bad center" do
|
228
|
-
expect { subject.original_width(100).original_height(100).width(50).height(50).center(50).
|
277
|
+
expect { subject.original_width(100).original_height(100).width(50).height(50).center(50).generate }.to raise_error(RuntimeError)
|
229
278
|
end
|
230
279
|
|
231
280
|
it "should have no crop with a missing original_height" do
|
232
|
-
url = subject.original_width(100).width(50).height(40).center(50, 0).
|
233
|
-
expect(url).to eq '50x40/'
|
281
|
+
url = subject.original_width(100).width(50).height(40).center(50, 0).generate
|
282
|
+
expect(url).to eq '/veYlY0msKmemAaXpeav2kCNftmU=/50x40/my.domain.com/some/image/url.jpg'
|
234
283
|
end
|
235
284
|
|
236
285
|
it "should have no crop with a missing original_width" do
|
237
|
-
url = subject.original_height(100).width(50).height(40).center(50, 0).
|
238
|
-
expect(url).to eq '50x40/'
|
286
|
+
url = subject.original_height(100).width(50).height(40).center(50, 0).generate
|
287
|
+
expect(url).to eq '/veYlY0msKmemAaXpeav2kCNftmU=/50x40/my.domain.com/some/image/url.jpg'
|
239
288
|
end
|
240
289
|
|
241
290
|
it "should have no crop with out a width and height" do
|
242
|
-
url = subject.original_width(100).original_height(100).center(50, 50).
|
243
|
-
expect(url).to eq
|
291
|
+
url = subject.original_width(100).original_height(100).center(50, 50).generate
|
292
|
+
expect(url).to eq '/964rCTkAEDtvjy_a572k7kRa0SU=/my.domain.com/some/image/url.jpg'
|
244
293
|
end
|
245
294
|
|
246
295
|
it "should use the original width with a missing width" do
|
247
|
-
url = subject.original_width(100).original_height(100).height(80).center(50, 50).
|
248
|
-
expect(url).to eq '0x10:100x90/0x80/'
|
296
|
+
url = subject.original_width(100).original_height(100).height(80).center(50, 50).generate
|
297
|
+
expect(url).to eq '/02BNIIJ9NYNV9Q03JHPtlP0DIDg=/0x10:100x90/0x80/my.domain.com/some/image/url.jpg'
|
249
298
|
end
|
250
299
|
|
251
300
|
it "should use the original height with a missing height" do
|
252
|
-
url = subject.original_width(100).original_height(100).width(80).center(50, 50).
|
253
|
-
expect(url).to eq '10x0:90x100/80x0/'
|
301
|
+
url = subject.original_width(100).original_height(100).width(80).center(50, 50).generate
|
302
|
+
expect(url).to eq '/0XL5BmMi3vlJQfw6aGOVW-M1vVI=/10x0:90x100/80x0/my.domain.com/some/image/url.jpg'
|
254
303
|
end
|
255
304
|
|
256
305
|
it "should have the right crop with a negative width" do
|
257
|
-
url = subject.original_width(100).original_height(100).width(-50).height(40).center(50, 50).
|
258
|
-
expect(url).to eq '0x10:100x90/-50x40/'
|
306
|
+
url = subject.original_width(100).original_height(100).width(-50).height(40).center(50, 50).generate
|
307
|
+
expect(url).to eq '/IuRNPlFlpTVol45bDkOm2PGvneo=/0x10:100x90/-50x40/my.domain.com/some/image/url.jpg'
|
259
308
|
end
|
260
309
|
|
261
310
|
it "should have the right crop with a negative height" do
|
262
|
-
url = subject.original_width(100).original_height(100).width(50).height(-40).center(50, 50).
|
263
|
-
expect(url).to eq '0x10:100x90/50x-40/'
|
311
|
+
url = subject.original_width(100).original_height(100).width(50).height(-40).center(50, 50).generate
|
312
|
+
expect(url).to eq '/-8IhWGEeXaY1uv945i9EHLVjwuk=/0x10:100x90/50x-40/my.domain.com/some/image/url.jpg'
|
264
313
|
end
|
265
314
|
|
266
315
|
it "should have the right crop with a negative height and width" do
|
267
|
-
url = subject.original_width(100).original_height(100).width(-50).height(-40).center(50, 50).
|
268
|
-
expect(url).to eq '0x10:100x90/-50x-40/'
|
269
|
-
end
|
270
|
-
end
|
271
|
-
|
272
|
-
describe '#generate' do
|
273
|
-
|
274
|
-
it "should create a new instance passing key and keep it" do
|
275
|
-
url = subject.width(300).height(200).generate
|
276
|
-
expect(url).to eq '/TQfyd3H36Z3srcNcLOYiM05YNO8=/300x200/my.domain.com/some/image/url.jpg'
|
277
|
-
end
|
278
|
-
|
279
|
-
it "should be able to change the Thumbor key" do
|
280
|
-
url1 = subject.width(300).height(200).generate
|
281
|
-
url2 = Thumbor::Cascade.new('another-thumbor-key', image_url).width(300).height(200).generate
|
282
|
-
expect(url1).not_to eq url2
|
283
|
-
end
|
284
|
-
|
285
|
-
it "should create a new instance passing key and keep it" do
|
286
|
-
url = subject.width(300).height(200).meta(true).generate
|
287
|
-
expect(url).to eq '/YBQEWd3g_WRMnVEG73zfzcr8Zj0=/meta/300x200/my.domain.com/some/image/url.jpg'
|
288
|
-
end
|
289
|
-
|
290
|
-
it "should create a new instance passing key and keep it" do
|
291
|
-
url = subject.width(300).height(200).meta(true).smart(true).generate
|
292
|
-
expect(url).to eq '/jP89J0qOWHgPlm_lOA28GtOh5GU=/meta/300x200/smart/my.domain.com/some/image/url.jpg'
|
293
|
-
end
|
294
|
-
|
295
|
-
it "should create a new instance passing key and keep it" do
|
296
|
-
url = subject.width(300).height(200).meta(true).smart(true).fit_in(true).generate
|
297
|
-
expect(url).to eq '/zrrOh_TtTs4kiLLEQq1w4bcTYdc=/meta/fit-in/300x200/smart/my.domain.com/some/image/url.jpg'
|
298
|
-
end
|
299
|
-
|
300
|
-
it "should create a new instance passing key and keep it" do
|
301
|
-
url = subject.width(300).height(200).meta(true).smart(true).fit_in(true).flip(true).generate
|
302
|
-
expect(url).to eq '/4t1XK1KH43cOb1QJ9tU00-W2_k8=/meta/fit-in/-300x200/smart/my.domain.com/some/image/url.jpg'
|
303
|
-
end
|
304
|
-
|
305
|
-
it "should create a new instance passing key and keep it" do
|
306
|
-
url = subject.width(300).height(200).meta(true).smart(true).fit_in(true).flip(true).flop(true).generate
|
307
|
-
expect(url).to eq '/HJnvjZU69PkPOhyZGu-Z3Uc_W_A=/meta/fit-in/-300x-200/smart/my.domain.com/some/image/url.jpg'
|
308
|
-
end
|
309
|
-
|
310
|
-
it "should create a new instance passing key and keep it" do
|
311
|
-
url = subject.quality_filter(20).brightness_filter(10).generate
|
312
|
-
expect(url).to eq '/q0DiFg-5-eFZIqyN3lRoCvg2K0s=/filters:quality(20):brightness(10)/my.domain.com/some/image/url.jpg'
|
313
|
-
end
|
314
|
-
end
|
315
|
-
|
316
|
-
describe "#generate :old => true" do
|
317
|
-
|
318
|
-
subject { Thumbor::Cascade.new(key, image_url).old(true) }
|
319
|
-
|
320
|
-
it "should create a new instance passing key and keep it" do
|
321
|
-
url = subject.width(300).height(200).generate
|
322
|
-
expect(url).to eq '/qkLDiIbvtiks0Up9n5PACtmpOfX6dPXw4vP4kJU-jTfyF6y1GJBJyp7CHYh1H3R2/' << image_url
|
323
|
-
end
|
324
|
-
|
325
|
-
it "should allow thumbor to decrypt it properly" do
|
326
|
-
url = subject.width(300).height(200).generate
|
327
|
-
|
328
|
-
encrypted = url.split('/')[1]
|
329
|
-
|
330
|
-
decrypted = decrypt_in_thumbor(encrypted)
|
331
|
-
|
332
|
-
expect(decrypted["horizontal_flip"]).to be_falsy
|
333
|
-
expect(decrypted["vertical_flip"]).to be_falsy
|
334
|
-
expect(decrypted["smart"]).to be_falsy
|
335
|
-
expect(decrypted["meta"]).to be_falsy
|
336
|
-
expect(decrypted["fit_in"]).to be_falsy
|
337
|
-
expect(decrypted["crop"]["left"]).to eq 0
|
338
|
-
expect(decrypted["crop"]["top"]).to eq 0
|
339
|
-
expect(decrypted["crop"]["right"]).to eq 0
|
340
|
-
expect(decrypted["crop"]["bottom"]).to eq 0
|
341
|
-
expect(decrypted["valign"]).to eq 'middle'
|
342
|
-
expect(decrypted["halign"]).to eq 'center'
|
343
|
-
expect(decrypted["image_hash"]).to eq image_md5
|
344
|
-
expect(decrypted["width"]).to eq 300
|
345
|
-
expect(decrypted["height"]).to eq 200
|
346
|
-
|
347
|
-
end
|
348
|
-
|
349
|
-
it "should allow thumbor to decrypt it properly with meta" do
|
350
|
-
url = subject.width(300).height(200).meta(true).generate
|
351
|
-
|
352
|
-
encrypted = url.split('/')[1]
|
353
|
-
|
354
|
-
decrypted = decrypt_in_thumbor(encrypted)
|
355
|
-
|
356
|
-
expect(decrypted["meta"]).to be_truthy
|
357
|
-
expect(decrypted["image_hash"]).to eq image_md5
|
358
|
-
expect(decrypted["width"]).to eq 300
|
359
|
-
expect(decrypted["height"]).to eq 200
|
360
|
-
|
361
|
-
end
|
362
|
-
|
363
|
-
it "should allow thumbor to decrypt it properly with smart" do
|
364
|
-
url = subject.width(300).height(200).meta(true).smart(true).generate
|
365
|
-
|
366
|
-
encrypted = url.split('/')[1]
|
367
|
-
|
368
|
-
decrypted = decrypt_in_thumbor(encrypted)
|
369
|
-
|
370
|
-
expect(decrypted["meta"]).to be_truthy
|
371
|
-
expect(decrypted["smart"]).to be_truthy
|
372
|
-
expect(decrypted["image_hash"]).to eq image_md5
|
373
|
-
expect(decrypted["width"]).to eq 300
|
374
|
-
expect(decrypted["height"]).to eq 200
|
375
|
-
|
376
|
-
end
|
377
|
-
|
378
|
-
it "should allow thumbor to decrypt it properly with fit-in" do
|
379
|
-
url = subject.width(300).height(200).fit_in(true).generate
|
380
|
-
|
381
|
-
encrypted = url.split('/')[1]
|
382
|
-
|
383
|
-
decrypted = decrypt_in_thumbor(encrypted)
|
384
|
-
|
385
|
-
expect(decrypted["fit_in"]).to be_truthy
|
386
|
-
expect(decrypted["image_hash"]).to eq image_md5
|
387
|
-
expect(decrypted["width"]).to eq 300
|
388
|
-
expect(decrypted["height"]).to eq 200
|
389
|
-
|
390
|
-
end
|
391
|
-
|
392
|
-
it "should allow thumbor to decrypt it properly with flip" do
|
393
|
-
url = subject.width(300).height(200).meta(true).smart(true).flip(true).generate
|
394
|
-
|
395
|
-
encrypted = url.split('/')[1]
|
396
|
-
|
397
|
-
decrypted = decrypt_in_thumbor(encrypted)
|
398
|
-
|
399
|
-
expect(decrypted["meta"]).to be_truthy
|
400
|
-
expect(decrypted["smart"]).to be_truthy
|
401
|
-
expect(decrypted["image_hash"]).to eq image_md5
|
402
|
-
expect(decrypted["width"]).to eq 300
|
403
|
-
expect(decrypted["height"]).to eq 200
|
404
|
-
expect(decrypted["horizontal_flip"]).to be_truthy
|
405
|
-
|
406
|
-
end
|
407
|
-
|
408
|
-
it "should allow thumbor to decrypt it properly with flop" do
|
409
|
-
url = subject.width(300).height(200).meta(true).smart(true).flip(true).flop(true).generate
|
410
|
-
|
411
|
-
encrypted = url.split('/')[1]
|
412
|
-
|
413
|
-
decrypted = decrypt_in_thumbor(encrypted)
|
414
|
-
|
415
|
-
expect(decrypted["meta"]).to be_truthy
|
416
|
-
expect(decrypted["smart"]).to be_truthy
|
417
|
-
expect(decrypted["image_hash"]).to eq image_md5
|
418
|
-
expect(decrypted["width"]).to eq 300
|
419
|
-
expect(decrypted["height"]).to eq 200
|
420
|
-
expect(decrypted["horizontal_flip"]).to be_truthy
|
421
|
-
expect(decrypted["vertical_flip"]).to be_truthy
|
422
|
-
|
423
|
-
end
|
424
|
-
|
425
|
-
it "should allow thumbor to decrypt it properly with halign" do
|
426
|
-
url = subject.width(300).height(200).meta(true).smart(true).flip(true).flop(true).
|
427
|
-
halign(:left).generate
|
428
|
-
|
429
|
-
encrypted = url.split('/')[1]
|
430
|
-
|
431
|
-
decrypted = decrypt_in_thumbor(encrypted)
|
432
|
-
|
433
|
-
expect(decrypted["meta"]).to be_truthy
|
434
|
-
expect(decrypted["smart"]).to be_truthy
|
435
|
-
expect(decrypted["image_hash"]).to eq image_md5
|
436
|
-
expect(decrypted["width"]).to eq 300
|
437
|
-
expect(decrypted["height"]).to eq 200
|
438
|
-
expect(decrypted["horizontal_flip"]).to be_truthy
|
439
|
-
expect(decrypted["vertical_flip"]).to be_truthy
|
440
|
-
expect(decrypted["halign"]).to eq "left"
|
441
|
-
|
442
|
-
end
|
443
|
-
|
444
|
-
it "should allow thumbor to decrypt it properly with valign" do
|
445
|
-
url = subject.width(300).height(200).meta(true).smart(true).flip(true).flop(true).
|
446
|
-
halign(:left).valign(:top).generate
|
447
|
-
|
448
|
-
encrypted = url.split('/')[1]
|
449
|
-
|
450
|
-
decrypted = decrypt_in_thumbor(encrypted)
|
451
|
-
|
452
|
-
expect(decrypted["meta"]).to be_truthy
|
453
|
-
expect(decrypted["smart"]).to be_truthy
|
454
|
-
expect(decrypted["image_hash"]).to eq image_md5
|
455
|
-
expect(decrypted["width"]).to eq 300
|
456
|
-
expect(decrypted["height"]).to eq 200
|
457
|
-
expect(decrypted["horizontal_flip"]).to be_truthy
|
458
|
-
expect(decrypted["vertical_flip"]).to be_truthy
|
459
|
-
expect(decrypted["halign"]).to eq "left"
|
460
|
-
expect(decrypted["valign"]).to eq "top"
|
461
|
-
|
462
|
-
end
|
463
|
-
|
464
|
-
it "should allow thumbor to decrypt it properly with cropping" do
|
465
|
-
url = subject.width(300).height(200).crop([10, 20, 30, 40]).generate
|
466
|
-
|
467
|
-
encrypted = url.split('/')[1]
|
468
|
-
|
469
|
-
decrypted = decrypt_in_thumbor(encrypted)
|
470
|
-
|
471
|
-
expect(decrypted["horizontal_flip"]).to be_falsy
|
472
|
-
expect(decrypted["vertical_flip"]).to be_falsy
|
473
|
-
expect(decrypted["smart"]).to be_falsy
|
474
|
-
expect(decrypted["meta"]).to be_falsy
|
475
|
-
expect(decrypted["crop"]["left"]).to eq 10
|
476
|
-
expect(decrypted["crop"]["top"]).to eq 20
|
477
|
-
expect(decrypted["crop"]["right"]).to eq 30
|
478
|
-
expect(decrypted["crop"]["bottom"]).to eq 40
|
479
|
-
expect(decrypted["valign"]).to eq 'middle'
|
480
|
-
expect(decrypted["halign"]).to eq 'center'
|
481
|
-
expect(decrypted["image_hash"]).to eq image_md5
|
482
|
-
expect(decrypted["width"]).to eq 300
|
483
|
-
expect(decrypted["height"]).to eq 200
|
484
|
-
|
485
|
-
end
|
486
|
-
|
487
|
-
it "should allow thumbor to decrypt it properly with filters" do
|
488
|
-
url = subject.quality_filter(20).brightness_filter(10).generate
|
489
|
-
|
490
|
-
encrypted = url.split('/')[1]
|
491
|
-
|
492
|
-
decrypted = decrypt_in_thumbor(encrypted)
|
493
|
-
|
494
|
-
expect(decrypted["filters"]).to eq "quality(20):brightness(10)"
|
316
|
+
url = subject.original_width(100).original_height(100).width(-50).height(-40).center(50, 50).generate
|
317
|
+
expect(url).to eq '/lfjGLTTEaW_Rcvc1q0ZhfYup2jg=/0x10:100x90/-50x-40/my.domain.com/some/image/url.jpg'
|
495
318
|
end
|
496
319
|
end
|
497
320
|
end
|