imgix 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +2 -0
- data/lib/imgix/client.rb +10 -1
- data/lib/imgix/version.rb +1 -1
- data/test/units/domains_test.rb +66 -47
- 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: 2aca4978f5332c3f2df154b78d11ce06a9a0936a
|
4
|
+
data.tar.gz: adfa18dbcd36b7604c145774b3303c4da1757f76
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 138320aa8a36f436a552cb9fbebd4cd85381ad319a260fc3994e6769c926d871303946bc86a9df2a23f1cd7c9c61d2504ce7a414067a57da29ef061c1f563257
|
7
|
+
data.tar.gz: 79d3e0c87dede9a851dcaed577d1069b75855be885fe72bbac210e94001a8ef7962c8c6cb88c1f6991cd3400023355a5b626a9eb18faf0a3f4066c884abe506d
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,10 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
5
5
|
|
6
|
+
## [2.1.0](https://github.com/imgix/imgix-rb/compare/2.0.0...2.1.0) - May 7, 2019
|
7
|
+
|
8
|
+
* Deprecate domain sharding ([#43](https://github.com/imgix/imgix-rb/pull/43)) ([#45](https://github.com/imgix/imgix-rb/pull/45))
|
9
|
+
|
6
10
|
## [2.0.0] - February 25, 2019
|
7
11
|
|
8
12
|
* Add domain validation during Client initialization [#42](https://github.com/imgix/imgix-rb/pull/42)
|
data/README.md
CHANGED
@@ -48,6 +48,8 @@ path.rect(x: 0, y: 50, width: 200, height: 300).to_url # Rect helper
|
|
48
48
|
|
49
49
|
|
50
50
|
## Domain Sharded URLs
|
51
|
+
**Warning: Domain Sharding has been deprecated and will be removed in the next major release**<br>
|
52
|
+
To find out more, see our [blog post](https://blog.imgix.com/2019/05/03/deprecating-domain-sharding) explaining the decision to remove this feature.
|
51
53
|
|
52
54
|
Domain sharding enables you to spread image requests across multiple domains. This allows you to bypass the requests-per-host limits of browsers. We recommend 2-3 domain shards maximum if you are going to use domain sharding.
|
53
55
|
|
data/lib/imgix/client.rb
CHANGED
@@ -13,6 +13,7 @@ module Imgix
|
|
13
13
|
def initialize(options = {})
|
14
14
|
options = DEFAULTS.merge(options)
|
15
15
|
|
16
|
+
deprecate_warning!(options[:host],options[:hosts])
|
16
17
|
@hosts = Array(options[:host]) + Array(options[:hosts]) and validate_hosts!
|
17
18
|
@secure_url_token = options[:secure_url_token]
|
18
19
|
@api_key = options[:api_key]
|
@@ -59,7 +60,9 @@ module Imgix
|
|
59
60
|
end
|
60
61
|
|
61
62
|
def host_for_cycle
|
62
|
-
|
63
|
+
if not defined? @hosts_cycle
|
64
|
+
@hosts_cycle = @hosts.cycle
|
65
|
+
end
|
63
66
|
@hosts_cycle.next
|
64
67
|
end
|
65
68
|
|
@@ -82,5 +85,11 @@ module Imgix
|
|
82
85
|
end
|
83
86
|
end
|
84
87
|
|
88
|
+
def deprecate_warning!(host, hosts)
|
89
|
+
has_many_domains = (host.kind_of?(Array) && host.length > 1 ) || (hosts.kind_of?(Array) && hosts.length > 1)
|
90
|
+
if has_many_domains
|
91
|
+
warn "Warning: Domain sharding has been deprecated and will be removed in the next major version."
|
92
|
+
end
|
93
|
+
end
|
85
94
|
end
|
86
95
|
end
|
data/lib/imgix/version.rb
CHANGED
data/test/units/domains_test.rb
CHANGED
@@ -4,67 +4,86 @@ require 'test_helper'
|
|
4
4
|
|
5
5
|
class DomainsTest < Imgix::Test
|
6
6
|
def test_deterministically_choosing_a_path
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
7
|
+
assert_output(nil, "Warning: Domain sharding has been deprecated and will be removed in the next major version.\n"){
|
8
|
+
client = Imgix::Client.new(hosts: [
|
9
|
+
"demos-1.imgix.net",
|
10
|
+
"demos-2.imgix.net",
|
11
|
+
"demos-3.imgix.net",
|
12
|
+
],
|
13
|
+
secure_url_token: '10adc394',
|
14
|
+
include_library_param: false)
|
15
|
+
|
16
|
+
path = client.path('/bridge.png')
|
17
|
+
assert_equal 'https://demos-1.imgix.net/bridge.png?s=0233fd6de51f20f11cff6b452b7a9a05', path.to_url
|
18
|
+
|
19
|
+
path = client.path('/flower.png')
|
20
|
+
assert_equal 'https://demos-2.imgix.net/flower.png?s=02105961388864f85c04121ea7b50e08', path.to_url
|
21
|
+
}
|
20
22
|
end
|
21
23
|
|
22
24
|
def test_cycling_choosing_domain_in_order
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
25
|
+
assert_output(nil, "Warning: Domain sharding has been deprecated and will be removed in the next major version.\n"){
|
26
|
+
client = Imgix::Client.new(hosts: [
|
27
|
+
"demos-1.imgix.net",
|
28
|
+
"demos-2.imgix.net",
|
29
|
+
"demos-3.imgix.net",
|
30
|
+
],
|
31
|
+
secure_url_token: '10adc394',
|
32
|
+
shard_strategy: :cycle,
|
33
|
+
include_library_param: false)
|
34
|
+
|
35
|
+
path = client.path('/bridge.png')
|
36
|
+
assert_equal 'https://demos-1.imgix.net/bridge.png?s=0233fd6de51f20f11cff6b452b7a9a05', path.to_url
|
37
|
+
|
38
|
+
path = client.path('/bridge.png')
|
39
|
+
assert_equal 'https://demos-2.imgix.net/bridge.png?s=0233fd6de51f20f11cff6b452b7a9a05', path.to_url
|
40
|
+
|
41
|
+
path = client.path('/bridge.png')
|
42
|
+
assert_equal 'https://demos-3.imgix.net/bridge.png?s=0233fd6de51f20f11cff6b452b7a9a05', path.to_url
|
43
|
+
|
44
|
+
path = client.path('/bridge.png')
|
45
|
+
assert_equal 'https://demos-1.imgix.net/bridge.png?s=0233fd6de51f20f11cff6b452b7a9a05', path.to_url
|
46
|
+
}
|
43
47
|
end
|
44
48
|
|
45
49
|
def test_with_full_paths
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
50
|
+
assert_output(nil, "Warning: Domain sharding has been deprecated and will be removed in the next major version.\n"){
|
51
|
+
client = Imgix::Client.new(hosts: [
|
52
|
+
"demos-1.imgix.net",
|
53
|
+
"demos-2.imgix.net",
|
54
|
+
"demos-3.imgix.net",
|
55
|
+
],
|
56
|
+
secure_url_token: '10adc394',
|
57
|
+
shard_strategy: :cycle,
|
58
|
+
include_library_param: false)
|
59
|
+
|
60
|
+
path = 'https://google.com/cats.gif'
|
61
|
+
assert_equal "https://demos-1.imgix.net/#{CGI.escape(path)}?s=e686099fbba86fc2b8141d3c1ff60605", client.path(path).to_url
|
62
|
+
}
|
57
63
|
end
|
58
64
|
|
59
65
|
def test_invalid_domain_append_slash
|
60
|
-
assert_raises(ArgumentError) {Imgix::Client.new(hosts:
|
66
|
+
assert_raises(ArgumentError) {Imgix::Client.new(hosts: "assets.imgix.net/")}
|
61
67
|
end
|
62
68
|
|
63
69
|
def test_invalid_domain_prepend_scheme
|
64
|
-
assert_raises(ArgumentError) {Imgix::Client.new(hosts:
|
70
|
+
assert_raises(ArgumentError) {Imgix::Client.new(hosts: "https://assets.imgix.net")}
|
65
71
|
end
|
66
72
|
|
67
73
|
def test_invalid_domain_append_dash
|
68
|
-
assert_raises(ArgumentError) {Imgix::Client.new(hosts:
|
74
|
+
assert_raises(ArgumentError) {Imgix::Client.new(hosts: "assets.imgix.net-")}
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_domain_sharding_deprecation_host
|
78
|
+
|
79
|
+
assert_output(nil, "Warning: Domain sharding has been deprecated and will be removed in the next major version.\n"){
|
80
|
+
Imgix::Client.new(host: ["assets1.imgix.net", "assets2.imgix.net"])
|
81
|
+
}
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_domain_sharding_deprecation_hosts
|
85
|
+
assert_output(nil, "Warning: Domain sharding has been deprecated and will be removed in the next major version.\n"){
|
86
|
+
Imgix::Client.new(hosts: ["assets1.imgix.net", "assets2.imgix.net"])
|
87
|
+
}
|
69
88
|
end
|
70
89
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: imgix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kelly Sutton
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2019-
|
16
|
+
date: 2019-05-08 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: addressable
|