ruby-thumbor 1.3.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 893a41411617f13eb886aa0623348b8465367c2f
4
- data.tar.gz: 4f987bbd23926f386cc6e360a10156007dafb159
3
+ metadata.gz: 4fb9d400670315240363d6886302ee62da8b3b4b
4
+ data.tar.gz: 97818a3c1400417a4d2a0e3520069f547abf9e69
5
5
  SHA512:
6
- metadata.gz: a7534f13bd29cda443f7b9338bf70b411ae6f4ce2802928d5c83e603272a1e3531f88ce4dd369adca224b2d5b59c7a0cbf1889e5d6097c2ea94f42993f242d28
7
- data.tar.gz: 3353dcafc369ea2695b3e2883b7b6400bd63f810ead8557018a4ac313c08cb7dafa6fa5f5e1e1b597980d3c5d2ff9494112b53242d1d843b63ebad8712405ef2
6
+ metadata.gz: 20143d675dd3a3e9721e745f4992e3d5446547b29aa6ef6852a1702623b41010b4f6ca7dc0991d847182532f414438514753f77ba9f47348f4c1d386529f28fb
7
+ data.tar.gz: 49096c792b320fa1deb4ab4a5647367af39218ec80f1702245403b6f2d9a51410452c840948d251fcbb5325bddb6dd8c48eabd4b4643287040ecfb0ebb152624
@@ -4,7 +4,7 @@
4
4
 
5
5
  == DESCRIPTION:
6
6
 
7
- ruby-thumbor is the client to the thumbor imaging service (http://github.com/globocom/thumbor).
7
+ ruby-thumbor is the client to the thumbor imaging service (http://github.com/thumbor/thumbor).
8
8
 
9
9
  == FEATURES:
10
10
 
@@ -15,7 +15,7 @@ ruby-thumbor is the client to the thumbor imaging service (http://github.com/glo
15
15
 
16
16
  No dependencies required for regular usage.
17
17
 
18
- * thumbor (http://github.com/globocom/thumbor) for running ruby-thumbor tests.
18
+ * thumbor (http://github.com/thumbor/thumbor) for running ruby-thumbor tests.
19
19
 
20
20
  == INSTALL:
21
21
 
@@ -23,6 +23,9 @@ No dependencies required for regular usage.
23
23
 
24
24
  gem 'ruby-thumbor'
25
25
 
26
+ == BREAKING CHANGE ON 2.0:
27
+
28
+ Thumbor::Cascade.new now gets key, image
26
29
 
27
30
  == USAGE:
28
31
 
@@ -39,8 +42,7 @@ or
39
42
 
40
43
  require 'ruby-thumbor'
41
44
 
42
- Thumbor.key = 'my-security-key'
43
- image = Thumbor::Cascade.new('my.server.com/path/to/image.jpg')
45
+ image = Thumbor::Cascade.new('my-security-key', 'my.server.com/path/to/image.jpg')
44
46
  image.width(300).height(200).watermark_filter('http://my-server.com/image.png', 30).generate
45
47
 
46
48
  Available arguments to the generate method:
@@ -66,7 +68,7 @@ Available arguments to the generate method:
66
68
 
67
69
  :smart => <bool> - flag that indicates that thumbor should use smart cropping;
68
70
 
69
- If you need more info on what each option does, check thumbor's documentation at https://github.com/globocom/thumbor/wiki.
71
+ If you need more info on what each option does, check thumbor's documentation at https://github.com/thumbor/thumbor/wiki.
70
72
 
71
73
  == CONTRIBUTIONS:
72
74
 
@@ -2,14 +2,5 @@ require 'thumbor/crypto_url'
2
2
  require 'thumbor/cascade'
3
3
 
4
4
  module Thumbor
5
- @@key = nil
6
-
7
- def self.key=(key)
8
- @@key = key
9
- end
10
-
11
- def self.key
12
- @@key
13
- end
14
5
  end
15
6
 
@@ -29,11 +29,12 @@ module Thumbor
29
29
  end
30
30
  end
31
31
 
32
- def initialize(image=nil)
32
+ def initialize(key=false, image=nil)
33
+ @key = key
33
34
  @image = image
34
35
  @options = {}
35
36
  @filters = []
36
- @old_crypto = Thumbor::CryptoURL.new Thumbor.key
37
+ @old_crypto = Thumbor::CryptoURL.new @key
37
38
  end
38
39
 
39
40
  def url_for
@@ -7,12 +7,12 @@ module Thumbor
7
7
  class CryptoURL
8
8
  attr_accessor :computed_key
9
9
 
10
- def initialize(key)
11
- Thumbor.key = key
10
+ def initialize(key=false)
11
+ @key = key
12
12
  end
13
13
 
14
14
  def computed_key
15
- (Thumbor.key * 16)[0..15]
15
+ (@key * 16)[0..15]
16
16
  end
17
17
 
18
18
  def pad(s)
@@ -223,8 +223,8 @@ module Thumbor
223
223
 
224
224
  thumbor_path << options[:image]
225
225
 
226
- if Thumbor.key
227
- signature = url_safe_base64(OpenSSL::HMAC.digest('sha1', Thumbor.key, thumbor_path))
226
+ if @key
227
+ signature = url_safe_base64(OpenSSL::HMAC.digest('sha1', @key, thumbor_path))
228
228
  thumbor_path.insert(0, "/#{signature}/")
229
229
  else
230
230
  thumbor_path.insert(0, "/unsafe/")
@@ -1,3 +1,3 @@
1
1
  module Thumbor
2
- VERSION = '1.3.0'
2
+ VERSION = '2.0.0'
3
3
  end
@@ -1,14 +1,11 @@
1
1
  require 'simplecov'
2
2
 
3
3
  SimpleCov.start do
4
- add_filter '/spec/'
4
+ add_filter '/spec/'
5
5
  end
6
6
 
7
7
 
8
8
  RSpec.configure do |c|
9
9
  c.filter_run :focus => true
10
10
  c.run_all_when_everything_filtered = true
11
- c.expect_with :rspec do |config|
12
- config.syntax = [:should, :expect]
13
- end
14
11
  end
@@ -8,16 +8,9 @@ describe Thumbor::Cascade do
8
8
  let(:image_md5) { 'f33af67e41168e80fcc5b00f8bd8061a' }
9
9
  let(:key) { 'my-security-key' }
10
10
 
11
- subject { Thumbor::Cascade.new image_url }
12
-
13
- after(:each) do
14
- Thumbor.key = nil
15
- end
11
+ subject { Thumbor::Cascade.new key, image_url }
16
12
 
17
13
  describe '#new' do
18
- before do
19
- Thumbor.key = key
20
- end
21
14
 
22
15
  it "should create a new instance passing key and keep it" do
23
16
  expect(subject.computed_key).to eq 'my-security-keym'
@@ -277,9 +270,6 @@ describe Thumbor::Cascade do
277
270
  end
278
271
 
279
272
  describe '#generate' do
280
- before do
281
- Thumbor.key = key
282
- end
283
273
 
284
274
  it "should create a new instance passing key and keep it" do
285
275
  url = subject.width(300).height(200).generate
@@ -287,10 +277,8 @@ describe Thumbor::Cascade do
287
277
  end
288
278
 
289
279
  it "should be able to change the Thumbor key" do
290
- thumbor = subject.width(300).height(200)
291
- url1 = thumbor.generate
292
- Thumbor.key = 'another-thumbor-key'
293
- url2 = thumbor.generate
280
+ url1 = subject.width(300).height(200).generate
281
+ url2 = Thumbor::Cascade.new('another-thumbor-key', image_url).width(300).height(200).generate
294
282
  expect(url1).not_to eq url2
295
283
  end
296
284
 
@@ -326,11 +314,8 @@ describe Thumbor::Cascade do
326
314
  end
327
315
 
328
316
  describe "#generate :old => true" do
329
- before do
330
- Thumbor.key = key
331
- end
332
317
 
333
- subject { Thumbor::Cascade.new(image_url).old(true) }
318
+ subject { Thumbor::Cascade.new(key, image_url).old(true) }
334
319
 
335
320
  it "should create a new instance passing key and keep it" do
336
321
  url = subject.width(300).height(200).generate
@@ -344,11 +329,11 @@ describe Thumbor::Cascade do
344
329
 
345
330
  decrypted = decrypt_in_thumbor(encrypted)
346
331
 
347
- expect(decrypted["horizontal_flip"]).to eq false
348
- expect(decrypted["vertical_flip"]).to eq false
349
- expect(decrypted["smart"]).to eq false
350
- expect(decrypted["meta"]).to eq false
351
- expect(decrypted["fit_in"]).to eq false
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
352
337
  expect(decrypted["crop"]["left"]).to eq 0
353
338
  expect(decrypted["crop"]["top"]).to eq 0
354
339
  expect(decrypted["crop"]["right"]).to eq 0
@@ -368,7 +353,7 @@ describe Thumbor::Cascade do
368
353
 
369
354
  decrypted = decrypt_in_thumbor(encrypted)
370
355
 
371
- expect(decrypted["meta"]).to eq true
356
+ expect(decrypted["meta"]).to be_truthy
372
357
  expect(decrypted["image_hash"]).to eq image_md5
373
358
  expect(decrypted["width"]).to eq 300
374
359
  expect(decrypted["height"]).to eq 200
@@ -382,8 +367,8 @@ describe Thumbor::Cascade do
382
367
 
383
368
  decrypted = decrypt_in_thumbor(encrypted)
384
369
 
385
- expect(decrypted["meta"]).to eq true
386
- expect(decrypted["smart"]).to eq true
370
+ expect(decrypted["meta"]).to be_truthy
371
+ expect(decrypted["smart"]).to be_truthy
387
372
  expect(decrypted["image_hash"]).to eq image_md5
388
373
  expect(decrypted["width"]).to eq 300
389
374
  expect(decrypted["height"]).to eq 200
@@ -397,7 +382,7 @@ describe Thumbor::Cascade do
397
382
 
398
383
  decrypted = decrypt_in_thumbor(encrypted)
399
384
 
400
- expect(decrypted["fit_in"]).to eq true
385
+ expect(decrypted["fit_in"]).to be_truthy
401
386
  expect(decrypted["image_hash"]).to eq image_md5
402
387
  expect(decrypted["width"]).to eq 300
403
388
  expect(decrypted["height"]).to eq 200
@@ -411,12 +396,12 @@ describe Thumbor::Cascade do
411
396
 
412
397
  decrypted = decrypt_in_thumbor(encrypted)
413
398
 
414
- expect(decrypted["meta"]).to eq true
415
- expect(decrypted["smart"]).to eq true
399
+ expect(decrypted["meta"]).to be_truthy
400
+ expect(decrypted["smart"]).to be_truthy
416
401
  expect(decrypted["image_hash"]).to eq image_md5
417
402
  expect(decrypted["width"]).to eq 300
418
403
  expect(decrypted["height"]).to eq 200
419
- expect(decrypted["horizontal_flip"]).to eq true
404
+ expect(decrypted["horizontal_flip"]).to be_truthy
420
405
 
421
406
  end
422
407
 
@@ -427,13 +412,13 @@ describe Thumbor::Cascade do
427
412
 
428
413
  decrypted = decrypt_in_thumbor(encrypted)
429
414
 
430
- expect(decrypted["meta"]).to eq true
431
- expect(decrypted["smart"]).to eq true
415
+ expect(decrypted["meta"]).to be_truthy
416
+ expect(decrypted["smart"]).to be_truthy
432
417
  expect(decrypted["image_hash"]).to eq image_md5
433
418
  expect(decrypted["width"]).to eq 300
434
419
  expect(decrypted["height"]).to eq 200
435
- expect(decrypted["horizontal_flip"]).to eq true
436
- expect(decrypted["vertical_flip"]).to eq true
420
+ expect(decrypted["horizontal_flip"]).to be_truthy
421
+ expect(decrypted["vertical_flip"]).to be_truthy
437
422
 
438
423
  end
439
424
 
@@ -445,13 +430,13 @@ describe Thumbor::Cascade do
445
430
 
446
431
  decrypted = decrypt_in_thumbor(encrypted)
447
432
 
448
- expect(decrypted["meta"]).to eq true
449
- expect(decrypted["smart"]).to eq true
433
+ expect(decrypted["meta"]).to be_truthy
434
+ expect(decrypted["smart"]).to be_truthy
450
435
  expect(decrypted["image_hash"]).to eq image_md5
451
436
  expect(decrypted["width"]).to eq 300
452
437
  expect(decrypted["height"]).to eq 200
453
- expect(decrypted["horizontal_flip"]).to eq true
454
- expect(decrypted["vertical_flip"]).to eq true
438
+ expect(decrypted["horizontal_flip"]).to be_truthy
439
+ expect(decrypted["vertical_flip"]).to be_truthy
455
440
  expect(decrypted["halign"]).to eq "left"
456
441
 
457
442
  end
@@ -464,13 +449,13 @@ describe Thumbor::Cascade do
464
449
 
465
450
  decrypted = decrypt_in_thumbor(encrypted)
466
451
 
467
- expect(decrypted["meta"]).to eq true
468
- expect(decrypted["smart"]).to eq true
452
+ expect(decrypted["meta"]).to be_truthy
453
+ expect(decrypted["smart"]).to be_truthy
469
454
  expect(decrypted["image_hash"]).to eq image_md5
470
455
  expect(decrypted["width"]).to eq 300
471
456
  expect(decrypted["height"]).to eq 200
472
- expect(decrypted["horizontal_flip"]).to eq true
473
- expect(decrypted["vertical_flip"]).to eq true
457
+ expect(decrypted["horizontal_flip"]).to be_truthy
458
+ expect(decrypted["vertical_flip"]).to be_truthy
474
459
  expect(decrypted["halign"]).to eq "left"
475
460
  expect(decrypted["valign"]).to eq "top"
476
461
 
@@ -483,10 +468,10 @@ describe Thumbor::Cascade do
483
468
 
484
469
  decrypted = decrypt_in_thumbor(encrypted)
485
470
 
486
- expect(decrypted["horizontal_flip"]).to eq false
487
- expect(decrypted["vertical_flip"]).to eq false
488
- expect(decrypted["smart"]).to eq false
489
- expect(decrypted["meta"]).to eq false
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
490
475
  expect(decrypted["crop"]["left"]).to eq 10
491
476
  expect(decrypted["crop"]["top"]).to eq 20
492
477
  expect(decrypted["crop"]["right"]).to eq 30
@@ -12,7 +12,7 @@ describe Thumbor::CryptoURL do
12
12
 
13
13
  describe '#new' do
14
14
  it "should create a new instance passing key and keep it" do
15
- subject.computed_key.should == 'my-security-keym'
15
+ expect(subject.computed_key).to eq('my-security-keym')
16
16
  end
17
17
  end
18
18
 
@@ -20,7 +20,7 @@ describe Thumbor::CryptoURL do
20
20
 
21
21
  it "should return just the image hash if no arguments passed" do
22
22
  url = subject.url_for :image => image_url
23
- url.should == image_md5
23
+ expect(url).to eq(image_md5)
24
24
  end
25
25
 
26
26
  it "should raise if no image passed" do
@@ -29,159 +29,159 @@ describe Thumbor::CryptoURL do
29
29
 
30
30
  it "should return proper url for width-only" do
31
31
  url = subject.url_for :image => image_url, :width => 300
32
- url.should == '300x0/' << image_md5
32
+ expect(url).to eq('300x0/' << image_md5)
33
33
  end
34
34
 
35
35
  it "should return proper url for height-only" do
36
36
  url = subject.url_for :image => image_url, :height => 300
37
- url.should == '0x300/' << image_md5
37
+ expect(url).to eq('0x300/' << image_md5)
38
38
  end
39
39
 
40
40
  it "should return proper url for width and height" do
41
41
  url = subject.url_for :image => image_url, :width => 200, :height => 300
42
- url.should == '200x300/' << image_md5
42
+ expect(url).to eq('200x300/' << image_md5)
43
43
  end
44
44
 
45
45
  it "should return proper smart url" do
46
46
  url = subject.url_for :image => image_url, :width => 200, :height => 300, :smart => true
47
- url.should == '200x300/smart/' << image_md5
47
+ expect(url).to eq('200x300/smart/' << image_md5)
48
48
  end
49
49
 
50
50
  it "should return proper fit-in url" do
51
51
  url = subject.url_for :image => image_url, :width => 200, :height => 300, :fit_in => true
52
- url.should == 'fit-in/200x300/' << image_md5
52
+ expect(url).to eq('fit-in/200x300/' << image_md5)
53
53
  end
54
54
 
55
55
  it "should return proper flip url if no width and height" do
56
56
  url = subject.url_for :image => image_url, :flip => true
57
- url.should == '-0x0/' << image_md5
57
+ expect(url).to eq('-0x0/' << image_md5)
58
58
  end
59
59
 
60
60
  it "should return proper flop url if no width and height" do
61
61
  url = subject.url_for :image => image_url, :flop => true
62
- url.should == '0x-0/' << image_md5
62
+ expect(url).to eq('0x-0/' << image_md5)
63
63
  end
64
64
 
65
65
  it "should return proper flip-flop url if no width and height" do
66
66
  url = subject.url_for :image => image_url, :flip => true, :flop => true
67
- url.should == '-0x-0/' << image_md5
67
+ expect(url).to eq('-0x-0/' << image_md5)
68
68
  end
69
69
 
70
70
  it "should return proper flip url if width" do
71
71
  url = subject.url_for :image => image_url, :width => 300, :flip => true
72
- url.should == '-300x0/' << image_md5
72
+ expect(url).to eq('-300x0/' << image_md5)
73
73
  end
74
74
 
75
75
  it "should return proper flop url if height" do
76
76
  url = subject.url_for :image => image_url, :height => 300, :flop => true
77
- url.should == '0x-300/' << image_md5
77
+ expect(url).to eq('0x-300/' << image_md5)
78
78
  end
79
79
 
80
80
  it "should return horizontal align" do
81
81
  url = subject.url_for :image => image_url, :halign => :left
82
- url.should == 'left/' << image_md5
82
+ expect(url).to eq('left/' << image_md5)
83
83
  end
84
84
 
85
85
  it "should not return horizontal align if it is center" do
86
86
  url = subject.url_for :image => image_url, :halign => :center
87
- url.should == image_md5
87
+ expect(url).to eq(image_md5)
88
88
  end
89
89
 
90
90
  it "should return vertical align" do
91
91
  url = subject.url_for :image => image_url, :valign => :top
92
- url.should == 'top/' << image_md5
92
+ expect(url).to eq('top/' << image_md5)
93
93
  end
94
94
 
95
95
  it "should not return vertical align if it is middle" do
96
96
  url = subject.url_for :image => image_url, :valign => :middle
97
- url.should == image_md5
97
+ expect(url).to eq(image_md5)
98
98
  end
99
99
 
100
100
  it "should return halign and valign properly" do
101
101
  url = subject.url_for :image => image_url, :halign => :left, :valign => :top
102
- url.should == 'left/top/' << image_md5
102
+ expect(url).to eq('left/top/' << image_md5)
103
103
  end
104
104
 
105
105
  it "should return meta properly" do
106
106
  url = subject.url_for :image => image_url, :meta => true
107
- url.should == 'meta/' << image_md5
107
+ expect(url).to eq('meta/' << image_md5)
108
108
  end
109
109
 
110
110
  it "should return proper crop url" do
111
111
  url = subject.url_for :image => image_url, :crop => [10, 20, 30, 40]
112
- url.should == '10x20:30x40/' << image_md5
112
+ expect(url).to eq('10x20:30x40/' << image_md5)
113
113
  end
114
114
 
115
115
  it "should ignore crop if all zeros" do
116
116
  url = subject.url_for :image => image_url, :crop => [0, 0, 0, 0]
117
- url.should == image_md5
117
+ expect(url).to eq(image_md5)
118
118
  end
119
119
 
120
120
  it "should have smart after halign and valign" do
121
121
  url = subject.url_for :image => image_url, :halign => :left, :valign => :top, :smart => true
122
- url.should == 'left/top/smart/' << image_md5
122
+ expect(url).to eq('left/top/smart/' << image_md5)
123
123
  end
124
124
 
125
125
  it "should ignore filters if empty" do
126
126
  url = subject.url_for :image => image_url, :filters => []
127
- url.should == image_md5
127
+ expect(url).to eq(image_md5)
128
128
  end
129
129
 
130
130
  it "should have trim without params" do
131
131
  url = subject.url_for :image => image_url, :trim => true
132
- url.should == 'trim/' << image_md5
132
+ expect(url).to eq('trim/' << image_md5)
133
133
  end
134
134
 
135
135
  it "should have trim with direction param" do
136
136
  url = subject.url_for :image => image_url, :trim => ['bottom-right']
137
- url.should == 'trim:bottom-right/' << image_md5
137
+ expect(url).to eq('trim:bottom-right/' << image_md5)
138
138
  end
139
139
 
140
140
  it "should have trim with direction and tolerance param" do
141
141
  url = subject.url_for :image => image_url, :trim => ['bottom-right', 15]
142
- url.should == 'trim:bottom-right:15/' << image_md5
142
+ expect(url).to eq('trim:bottom-right:15/' << image_md5)
143
143
  end
144
144
 
145
145
  it "should have the trim option as the first one" do
146
146
  url = subject.url_for :image => image_url, :smart => true, :trim => true
147
147
 
148
- url.should == 'trim/smart/f33af67e41168e80fcc5b00f8bd8061a'
148
+ expect(url).to eq('trim/smart/f33af67e41168e80fcc5b00f8bd8061a')
149
149
  end
150
150
 
151
151
 
152
152
  it "should have the right crop when cropping horizontally and given a left center" do
153
153
  url = subject.url_for :image => image_url, :original_width => 100, :original_height => 100, :width => 40, :height => 50, :center => [0, 50]
154
- url.should == '0x0:80x100/40x50/' << image_md5
154
+ expect(url).to eq('0x0:80x100/40x50/' << image_md5)
155
155
  end
156
156
 
157
157
  it "should have the right crop when cropping horizontally and given a right center" do
158
158
  url = subject.url_for :image => image_url, :original_width => 100, :original_height => 100, :width => 40, :height => 50, :center => [100, 50]
159
- url.should == '20x0:100x100/40x50/' << image_md5
159
+ expect(url).to eq('20x0:100x100/40x50/' << image_md5)
160
160
  end
161
161
 
162
162
  it "should have the right crop when cropping horizontally and given the actual center" do
163
163
  url = subject.url_for :image => image_url, :original_width => 100, :original_height => 100, :width => 40, :height => 50, :center => [50, 50]
164
- url.should == '10x0:90x100/40x50/' << image_md5
164
+ expect(url).to eq('10x0:90x100/40x50/' << image_md5)
165
165
  end
166
166
 
167
167
  it "should have the right crop when cropping vertically and given a top center" do
168
168
  url = subject.url_for :image => image_url, :original_width => 100, :original_height => 100, :width => 50, :height => 40, :center => [50, 0]
169
- url.should == '0x0:100x80/50x40/' << image_md5
169
+ expect(url).to eq('0x0:100x80/50x40/' << image_md5)
170
170
  end
171
171
 
172
172
  it "should have the right crop when cropping vertically and given a bottom center" do
173
173
  url = subject.url_for :image => image_url, :original_width => 100, :original_height => 100, :width => 50, :height => 40, :center => [50, 100]
174
- url.should == '0x20:100x100/50x40/' << image_md5
174
+ expect(url).to eq('0x20:100x100/50x40/' << image_md5)
175
175
  end
176
176
 
177
177
  it "should have the right crop when cropping vertically and given the actual center" do
178
178
  url = subject.url_for :image => image_url, :original_width => 100, :original_height => 100, :width => 50, :height => 40, :center => [50, 50]
179
- url.should == '0x10:100x90/50x40/' << image_md5
179
+ expect(url).to eq('0x10:100x90/50x40/' << image_md5)
180
180
  end
181
181
 
182
182
  it "should have the no crop when not necessary" do
183
183
  url = subject.url_for :image => image_url, :original_width => 100, :original_height => 100, :width => 50, :height => 50, :center => [50, 0]
184
- url.should == '50x50/' << image_md5
184
+ expect(url).to eq('50x50/' << image_md5)
185
185
  end
186
186
 
187
187
  it "should blow up with a bad center" do
@@ -190,42 +190,42 @@ describe Thumbor::CryptoURL do
190
190
 
191
191
  it "should have no crop with a missing original_height" do
192
192
  url = subject.url_for :image => image_url, :original_width => 100, :width => 50, :height => 40, :center => [50, 50]
193
- url.should == '50x40/' << image_md5
193
+ expect(url).to eq('50x40/' << image_md5)
194
194
  end
195
195
 
196
196
  it "should have no crop with a missing original_width" do
197
197
  url = subject.url_for :image => image_url, :original_height => 100, :width => 50, :height => 40, :center => [50, 50]
198
- url.should == '50x40/' << image_md5
198
+ expect(url).to eq('50x40/' << image_md5)
199
199
  end
200
200
 
201
201
  it "should have no crop with out a width and height" do
202
202
  url = subject.url_for :image => image_url, :original_width => 100, :original_height => 100, :center => [50, 50]
203
- url.should == image_md5
203
+ expect(url).to eq(image_md5)
204
204
  end
205
205
 
206
206
  it "should use the original width with a missing width" do
207
207
  url = subject.url_for :image => image_url, :original_width => 100, :original_height => 100, :height => 80, :center => [50, 50]
208
- url.should == '0x10:100x90/0x80/' << image_md5
208
+ expect(url).to eq('0x10:100x90/0x80/' << image_md5)
209
209
  end
210
210
 
211
211
  it "should use the original height with a missing height" do
212
212
  url = subject.url_for :image => image_url,:original_width => 100, :original_height => 100, :width => 80, :center => [50, 50]
213
- url.should == '10x0:90x100/80x0/' << image_md5
213
+ expect(url).to eq('10x0:90x100/80x0/' << image_md5)
214
214
  end
215
215
 
216
216
  it "should have the right crop with a negative width" do
217
217
  url = subject.url_for :image => image_url, :original_width => 100, :original_height => 100, :width => -50, :height => 40, :center => [50, 50]
218
- url.should == '0x10:100x90/-50x40/' << image_md5
218
+ expect(url).to eq('0x10:100x90/-50x40/' << image_md5)
219
219
  end
220
220
 
221
221
  it "should have the right crop with a negative height" do
222
222
  url = subject.url_for :image => image_url, :original_width => 100, :original_height => 100, :width => 50, :height => -40, :center => [50, 50]
223
- url.should == '0x10:100x90/50x-40/' << image_md5
223
+ expect(url).to eq('0x10:100x90/50x-40/' << image_md5)
224
224
  end
225
225
 
226
226
  it "should have the right crop with a negative height and width" do
227
227
  url = subject.url_for :image => image_url, :original_width => 100, :original_height => 100, :width => -50, :height => -40, :center => [50, 50]
228
- url.should == '0x10:100x90/-50x-40/' << image_md5
228
+ expect(url).to eq('0x10:100x90/-50x-40/' << image_md5)
229
229
  end
230
230
  end
231
231
 
@@ -233,49 +233,49 @@ describe Thumbor::CryptoURL do
233
233
  it "should generate a proper url when only an image url is specified" do
234
234
  url = subject.generate :image => image_url
235
235
 
236
- url.should == "/964rCTkAEDtvjy_a572k7kRa0SU=/#{image_url}"
236
+ expect(url).to eq("/964rCTkAEDtvjy_a572k7kRa0SU=/#{image_url}")
237
237
  end
238
238
 
239
239
  it "should create a new instance passing key and keep it" do
240
240
  url = subject.generate :width => 300, :height => 200, :image => image_url
241
241
 
242
- url.should == '/TQfyd3H36Z3srcNcLOYiM05YNO8=/300x200/my.domain.com/some/image/url.jpg'
242
+ expect(url).to eq('/TQfyd3H36Z3srcNcLOYiM05YNO8=/300x200/my.domain.com/some/image/url.jpg')
243
243
  end
244
244
 
245
245
  it "should create a new instance passing key and keep it" do
246
246
  url = subject.generate :width => 300, :height => 200, :meta => true, :image => image_url
247
247
 
248
- url.should == '/YBQEWd3g_WRMnVEG73zfzcr8Zj0=/meta/300x200/my.domain.com/some/image/url.jpg'
248
+ expect(url).to eq('/YBQEWd3g_WRMnVEG73zfzcr8Zj0=/meta/300x200/my.domain.com/some/image/url.jpg')
249
249
  end
250
250
 
251
251
  it "should create a new instance passing key and keep it" do
252
252
  url = subject.generate :width => 300, :height => 200, :meta => true, :image => image_url, :smart => true
253
253
 
254
- url.should == '/jP89J0qOWHgPlm_lOA28GtOh5GU=/meta/300x200/smart/my.domain.com/some/image/url.jpg'
254
+ expect(url).to eq('/jP89J0qOWHgPlm_lOA28GtOh5GU=/meta/300x200/smart/my.domain.com/some/image/url.jpg')
255
255
  end
256
256
 
257
257
  it "should create a new instance passing key and keep it" do
258
258
  url = subject.generate :width => 300, :height => 200, :meta => true, :image => image_url, :smart => true, :fit_in => true
259
259
 
260
- url.should == '/zrrOh_TtTs4kiLLEQq1w4bcTYdc=/meta/fit-in/300x200/smart/my.domain.com/some/image/url.jpg'
260
+ expect(url).to eq('/zrrOh_TtTs4kiLLEQq1w4bcTYdc=/meta/fit-in/300x200/smart/my.domain.com/some/image/url.jpg')
261
261
  end
262
262
 
263
263
  it "should create a new instance passing key and keep it" do
264
264
  url = subject.generate :width => 300, :height => 200, :meta => true, :image => image_url, :smart => true, :fit_in => true, :flip => true
265
265
 
266
- url.should == '/4t1XK1KH43cOb1QJ9tU00-W2_k8=/meta/fit-in/-300x200/smart/my.domain.com/some/image/url.jpg'
266
+ expect(url).to eq('/4t1XK1KH43cOb1QJ9tU00-W2_k8=/meta/fit-in/-300x200/smart/my.domain.com/some/image/url.jpg')
267
267
  end
268
268
 
269
269
  it "should create a new instance passing key and keep it" do
270
270
  url = subject.generate :width => 300, :height => 200, :meta => true, :image => image_url, :smart => true, :fit_in => true, :flip => true, :flop => true
271
271
 
272
- url.should == '/HJnvjZU69PkPOhyZGu-Z3Uc_W_A=/meta/fit-in/-300x-200/smart/my.domain.com/some/image/url.jpg'
272
+ expect(url).to eq('/HJnvjZU69PkPOhyZGu-Z3Uc_W_A=/meta/fit-in/-300x-200/smart/my.domain.com/some/image/url.jpg')
273
273
  end
274
274
 
275
275
  it "should create a new instance passing key and keep it" do
276
276
  url = subject.generate :filters => ["quality(20)", "brightness(10)"], :image => image_url
277
277
 
278
- url.should == '/q0DiFg-5-eFZIqyN3lRoCvg2K0s=/filters:quality(20):brightness(10)/my.domain.com/some/image/url.jpg'
278
+ expect(url).to eq('/q0DiFg-5-eFZIqyN3lRoCvg2K0s=/filters:quality(20):brightness(10)/my.domain.com/some/image/url.jpg')
279
279
  end
280
280
  end
281
281
 
@@ -284,7 +284,7 @@ describe Thumbor::CryptoURL do
284
284
  it "should create a new instance passing key and keep it" do
285
285
  url = subject.generate :width => 300, :height => 200, :image => image_url, :old => true
286
286
 
287
- url.should == '/qkLDiIbvtiks0Up9n5PACtmpOfX6dPXw4vP4kJU-jTfyF6y1GJBJyp7CHYh1H3R2/' << image_url
287
+ expect(url).to eq('/qkLDiIbvtiks0Up9n5PACtmpOfX6dPXw4vP4kJU-jTfyF6y1GJBJyp7CHYh1H3R2/' << image_url)
288
288
  end
289
289
 
290
290
  it "should allow thumbor to decrypt it properly" do
@@ -294,20 +294,20 @@ describe Thumbor::CryptoURL do
294
294
 
295
295
  decrypted = decrypt_in_thumbor(encrypted)
296
296
 
297
- decrypted["horizontal_flip"].should == false
298
- decrypted["vertical_flip"].should == false
299
- decrypted["smart"].should == false
300
- decrypted["meta"].should == false
301
- decrypted["fit_in"].should == false
302
- decrypted["crop"]["left"].should == 0
303
- decrypted["crop"]["top"].should == 0
304
- decrypted["crop"]["right"].should == 0
305
- decrypted["crop"]["bottom"].should == 0
306
- decrypted["valign"].should == 'middle'
307
- decrypted["halign"].should == 'center'
308
- decrypted["image_hash"].should == image_md5
309
- decrypted["width"].should == 300
310
- decrypted["height"].should == 200
297
+ expect(decrypted["horizontal_flip"]).to be_falsy
298
+ expect(decrypted["vertical_flip"]).to be_falsy
299
+ expect(decrypted["smart"]).to be_falsy
300
+ expect(decrypted["meta"]).to be_falsy
301
+ expect(decrypted["fit_in"]).to be_falsy
302
+ expect(decrypted["crop"]["left"]).to eq(0)
303
+ expect(decrypted["crop"]["top"]).to eq(0)
304
+ expect(decrypted["crop"]["right"]).to eq(0)
305
+ expect(decrypted["crop"]["bottom"]).to eq(0)
306
+ expect(decrypted["valign"]).to eq('middle')
307
+ expect(decrypted["halign"]).to eq('center')
308
+ expect(decrypted["image_hash"]).to eq(image_md5)
309
+ expect(decrypted["width"]).to eq(300)
310
+ expect(decrypted["height"]).to eq(200)
311
311
 
312
312
  end
313
313
 
@@ -318,10 +318,10 @@ describe Thumbor::CryptoURL do
318
318
 
319
319
  decrypted = decrypt_in_thumbor(encrypted)
320
320
 
321
- decrypted["meta"].should == true
322
- decrypted["image_hash"].should == image_md5
323
- decrypted["width"].should == 300
324
- decrypted["height"].should == 200
321
+ expect(decrypted["meta"]).to be_truthy
322
+ expect(decrypted["image_hash"]).to eq(image_md5)
323
+ expect(decrypted["width"]).to eq(300)
324
+ expect(decrypted["height"]).to eq(200)
325
325
 
326
326
  end
327
327
 
@@ -332,11 +332,11 @@ describe Thumbor::CryptoURL do
332
332
 
333
333
  decrypted = decrypt_in_thumbor(encrypted)
334
334
 
335
- decrypted["meta"].should == true
336
- decrypted["smart"].should == true
337
- decrypted["image_hash"].should == image_md5
338
- decrypted["width"].should == 300
339
- decrypted["height"].should == 200
335
+ expect(decrypted["meta"]).to be_truthy
336
+ expect(decrypted["smart"]).to be_truthy
337
+ expect(decrypted["image_hash"]).to eq(image_md5)
338
+ expect(decrypted["width"]).to eq(300)
339
+ expect(decrypted["height"]).to eq(200)
340
340
 
341
341
  end
342
342
 
@@ -347,10 +347,10 @@ describe Thumbor::CryptoURL do
347
347
 
348
348
  decrypted = decrypt_in_thumbor(encrypted)
349
349
 
350
- decrypted["fit_in"].should == true
351
- decrypted["image_hash"].should == image_md5
352
- decrypted["width"].should == 300
353
- decrypted["height"].should == 200
350
+ expect(decrypted["fit_in"]).to be_truthy
351
+ expect(decrypted["image_hash"]).to eq(image_md5)
352
+ expect(decrypted["width"]).to eq(300)
353
+ expect(decrypted["height"]).to eq(200)
354
354
 
355
355
  end
356
356
 
@@ -361,11 +361,11 @@ describe Thumbor::CryptoURL do
361
361
 
362
362
  decrypted = decrypt_in_thumbor(encrypted)
363
363
 
364
- decrypted["meta"].should == true
365
- decrypted["smart"].should == true
366
- decrypted["image_hash"].should == image_md5
367
- decrypted["width"].should == 300
368
- decrypted["height"].should == 200
364
+ expect(decrypted["meta"]).to be_truthy
365
+ expect(decrypted["smart"]).to be_truthy
366
+ expect(decrypted["image_hash"]).to eq(image_md5)
367
+ expect(decrypted["width"]).to eq(300)
368
+ expect(decrypted["height"]).to eq(200)
369
369
  decrypted["flip_horizontally"] == true
370
370
 
371
371
  end
@@ -377,11 +377,11 @@ describe Thumbor::CryptoURL do
377
377
 
378
378
  decrypted = decrypt_in_thumbor(encrypted)
379
379
 
380
- decrypted["meta"].should == true
381
- decrypted["smart"].should == true
382
- decrypted["image_hash"].should == image_md5
383
- decrypted["width"].should == 300
384
- decrypted["height"].should == 200
380
+ expect(decrypted["meta"]).to be_truthy
381
+ expect(decrypted["smart"]).to be_truthy
382
+ expect(decrypted["image_hash"]).to eq(image_md5)
383
+ expect(decrypted["width"]).to eq(300)
384
+ expect(decrypted["height"]).to eq(200)
385
385
  decrypted["flip_horizontally"] == true
386
386
  decrypted["flip_vertically"] == true
387
387
 
@@ -395,11 +395,11 @@ describe Thumbor::CryptoURL do
395
395
 
396
396
  decrypted = decrypt_in_thumbor(encrypted)
397
397
 
398
- decrypted["meta"].should == true
399
- decrypted["smart"].should == true
400
- decrypted["image_hash"].should == image_md5
401
- decrypted["width"].should == 300
402
- decrypted["height"].should == 200
398
+ expect(decrypted["meta"]).to be_truthy
399
+ expect(decrypted["smart"]).to be_truthy
400
+ expect(decrypted["image_hash"]).to eq(image_md5)
401
+ expect(decrypted["width"]).to eq(300)
402
+ expect(decrypted["height"]).to eq(200)
403
403
  decrypted["flip_horizontally"] == true
404
404
  decrypted["flip_vertically"] == true
405
405
  decrypted["halign"] == "left"
@@ -414,11 +414,11 @@ describe Thumbor::CryptoURL do
414
414
 
415
415
  decrypted = decrypt_in_thumbor(encrypted)
416
416
 
417
- decrypted["meta"].should == true
418
- decrypted["smart"].should == true
419
- decrypted["image_hash"].should == image_md5
420
- decrypted["width"].should == 300
421
- decrypted["height"].should == 200
417
+ expect(decrypted["meta"]).to be_truthy
418
+ expect(decrypted["smart"]).to be_truthy
419
+ expect(decrypted["image_hash"]).to eq(image_md5)
420
+ expect(decrypted["width"]).to eq(300)
421
+ expect(decrypted["height"]).to eq(200)
422
422
  decrypted["flip_horizontally"] == true
423
423
  decrypted["flip_vertically"] == true
424
424
  decrypted["halign"] == "left"
@@ -433,19 +433,19 @@ describe Thumbor::CryptoURL do
433
433
 
434
434
  decrypted = decrypt_in_thumbor(encrypted)
435
435
 
436
- decrypted["horizontal_flip"].should == false
437
- decrypted["vertical_flip"].should == false
438
- decrypted["smart"].should == false
439
- decrypted["meta"].should == false
440
- decrypted["crop"]["left"].should == 10
441
- decrypted["crop"]["top"].should == 20
442
- decrypted["crop"]["right"].should == 30
443
- decrypted["crop"]["bottom"].should == 40
444
- decrypted["valign"].should == 'middle'
445
- decrypted["halign"].should == 'center'
446
- decrypted["image_hash"].should == image_md5
447
- decrypted["width"].should == 300
448
- decrypted["height"].should == 200
436
+ expect(decrypted["horizontal_flip"]).to be_falsy
437
+ expect(decrypted["vertical_flip"]).to be_falsy
438
+ expect(decrypted["smart"]).to be_falsy
439
+ expect(decrypted["meta"]).to be_falsy
440
+ expect(decrypted["crop"]["left"]).to eq(10)
441
+ expect(decrypted["crop"]["top"]).to eq(20)
442
+ expect(decrypted["crop"]["right"]).to eq(30)
443
+ expect(decrypted["crop"]["bottom"]).to eq(40)
444
+ expect(decrypted["valign"]).to eq('middle')
445
+ expect(decrypted["halign"]).to eq('center')
446
+ expect(decrypted["image_hash"]).to eq(image_md5)
447
+ expect(decrypted["width"]).to eq(300)
448
+ expect(decrypted["height"]).to eq(200)
449
449
 
450
450
  end
451
451
 
@@ -456,7 +456,7 @@ describe Thumbor::CryptoURL do
456
456
 
457
457
  decrypted = decrypt_in_thumbor(encrypted)
458
458
 
459
- decrypted["filters"].should == "quality(20):brightness(10)"
459
+ expect(decrypted["filters"]).to eq("quality(20):brightness(10)")
460
460
  end
461
461
  end
462
462
 
@@ -465,7 +465,7 @@ describe Thumbor::CryptoURL do
465
465
  it "should generate a unsafe url" do
466
466
  url = subject.generate :image => image_url
467
467
 
468
- url.should == "/unsafe/#{image_url}"
468
+ expect(url).to eq("/unsafe/#{image_url}")
469
469
  end
470
470
  end
471
471
  end
metadata CHANGED
@@ -1,55 +1,56 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-thumbor
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bernardo Heynemann
8
+ - Guilherme Souza
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2014-07-11 00:00:00.000000000 Z
12
+ date: 2015-05-28 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: rspec
15
16
  requirement: !ruby/object:Gem::Requirement
16
17
  requirements:
17
- - - ! '>='
18
+ - - '>='
18
19
  - !ruby/object:Gem::Version
19
20
  version: '0'
20
21
  type: :development
21
22
  prerelease: false
22
23
  version_requirements: !ruby/object:Gem::Requirement
23
24
  requirements:
24
- - - ! '>='
25
+ - - '>='
25
26
  - !ruby/object:Gem::Version
26
27
  version: '0'
27
28
  - !ruby/object:Gem::Dependency
28
29
  name: simplecov
29
30
  requirement: !ruby/object:Gem::Requirement
30
31
  requirements:
31
- - - ! '>='
32
+ - - '>='
32
33
  - !ruby/object:Gem::Version
33
34
  version: '0'
34
35
  type: :development
35
36
  prerelease: false
36
37
  version_requirements: !ruby/object:Gem::Requirement
37
38
  requirements:
38
- - - ! '>='
39
+ - - '>='
39
40
  - !ruby/object:Gem::Version
40
41
  version: '0'
41
42
  - !ruby/object:Gem::Dependency
42
43
  name: guard-rspec
43
44
  requirement: !ruby/object:Gem::Requirement
44
45
  requirements:
45
- - - ! '>='
46
+ - - '>='
46
47
  - !ruby/object:Gem::Version
47
48
  version: '0'
48
49
  type: :development
49
50
  prerelease: false
50
51
  version_requirements: !ruby/object:Gem::Requirement
51
52
  requirements:
52
- - - ! '>='
53
+ - - '>='
53
54
  - !ruby/object:Gem::Version
54
55
  version: '0'
55
56
  - !ruby/object:Gem::Dependency
@@ -84,28 +85,29 @@ dependencies:
84
85
  name: rake
85
86
  requirement: !ruby/object:Gem::Requirement
86
87
  requirements:
87
- - - ! '>='
88
+ - - '>='
88
89
  - !ruby/object:Gem::Version
89
90
  version: '0'
90
91
  type: :development
91
92
  prerelease: false
92
93
  version_requirements: !ruby/object:Gem::Requirement
93
94
  requirements:
94
- - - ! '>='
95
+ - - '>='
95
96
  - !ruby/object:Gem::Version
96
97
  version: '0'
97
98
  description: ruby-thumbor is the client to the thumbor imaging service (http://github.com/globocom/thumbor).
98
99
  email:
99
100
  - heynemann@gmail.com
101
+ - guivideojob@gmail.com
100
102
  executables: []
101
103
  extensions: []
102
104
  extra_rdoc_files: []
103
105
  files:
106
+ - README.rdoc
104
107
  - lib/ruby-thumbor.rb
105
108
  - lib/thumbor/cascade.rb
106
109
  - lib/thumbor/crypto_url.rb
107
110
  - lib/thumbor/version.rb
108
- - README.rdoc
109
111
  - spec/spec_helper.rb
110
112
  - spec/thumbor/cascade_spec.rb
111
113
  - spec/thumbor/crypto_url_spec.rb
@@ -121,17 +123,17 @@ require_paths:
121
123
  - lib
122
124
  required_ruby_version: !ruby/object:Gem::Requirement
123
125
  requirements:
124
- - - ! '>='
126
+ - - '>='
125
127
  - !ruby/object:Gem::Version
126
128
  version: '0'
127
129
  required_rubygems_version: !ruby/object:Gem::Requirement
128
130
  requirements:
129
- - - ! '>='
131
+ - - '>='
130
132
  - !ruby/object:Gem::Version
131
133
  version: '0'
132
134
  requirements: []
133
135
  rubyforge_project:
134
- rubygems_version: 2.1.11
136
+ rubygems_version: 2.4.7
135
137
  signing_key:
136
138
  specification_version: 4
137
139
  summary: ruby-thumbor is the client to the thumbor imaging service (http://github.com/globocom/thumbor).