imgix 3.4.0 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -0
- data/.travis.yml +2 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +1 -1
- data/README.md +2 -37
- data/imgix.gemspec +17 -19
- data/lib/imgix.rb +4 -4
- data/lib/imgix/client.rb +64 -55
- data/lib/imgix/path.rb +89 -77
- data/lib/imgix/version.rb +1 -1
- metadata +7 -54
- data/.github/CODEOWNERS +0 -2
- data/.github/ISSUE_TEMPLATE/bug_report.md +0 -28
- data/.github/ISSUE_TEMPLATE/feature_request.md +0 -27
- data/.github/ISSUE_TEMPLATE/question.md +0 -17
- data/.github/pull_request_template.md +0 -73
- data/lib/imgix/param_helpers.rb +0 -19
- data/test/test_helper.rb +0 -12
- data/test/units/domains_test.rb +0 -17
- data/test/units/param_helpers_test.rb +0 -23
- data/test/units/path_test.rb +0 -182
- data/test/units/purge_test.rb +0 -70
- data/test/units/srcset_test.rb +0 -755
- data/test/units/url_test.rb +0 -80
data/lib/imgix/version.rb
CHANGED
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:
|
4
|
+
version: 4.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kelly Sutton
|
@@ -13,36 +13,8 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2020-08-
|
17
|
-
dependencies:
|
18
|
-
- !ruby/object:Gem::Dependency
|
19
|
-
name: addressable
|
20
|
-
requirement: !ruby/object:Gem::Requirement
|
21
|
-
requirements:
|
22
|
-
- - ">="
|
23
|
-
- !ruby/object:Gem::Version
|
24
|
-
version: '0'
|
25
|
-
type: :runtime
|
26
|
-
prerelease: false
|
27
|
-
version_requirements: !ruby/object:Gem::Requirement
|
28
|
-
requirements:
|
29
|
-
- - ">="
|
30
|
-
- !ruby/object:Gem::Version
|
31
|
-
version: '0'
|
32
|
-
- !ruby/object:Gem::Dependency
|
33
|
-
name: webmock
|
34
|
-
requirement: !ruby/object:Gem::Requirement
|
35
|
-
requirements:
|
36
|
-
- - ">="
|
37
|
-
- !ruby/object:Gem::Version
|
38
|
-
version: '0'
|
39
|
-
type: :development
|
40
|
-
prerelease: false
|
41
|
-
version_requirements: !ruby/object:Gem::Requirement
|
42
|
-
requirements:
|
43
|
-
- - ">="
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: '0'
|
16
|
+
date: 2020-08-27 00:00:00.000000000 Z
|
17
|
+
dependencies: []
|
46
18
|
description: Easily create and sign imgix URLs.
|
47
19
|
email:
|
48
20
|
- kelly@imgix.com
|
@@ -55,12 +27,8 @@ executables: []
|
|
55
27
|
extensions: []
|
56
28
|
extra_rdoc_files: []
|
57
29
|
files:
|
58
|
-
- ".github/CODEOWNERS"
|
59
|
-
- ".github/ISSUE_TEMPLATE/bug_report.md"
|
60
|
-
- ".github/ISSUE_TEMPLATE/feature_request.md"
|
61
|
-
- ".github/ISSUE_TEMPLATE/question.md"
|
62
|
-
- ".github/pull_request_template.md"
|
63
30
|
- ".gitignore"
|
31
|
+
- ".rubocop.yml"
|
64
32
|
- ".travis.yml"
|
65
33
|
- CHANGELOG.md
|
66
34
|
- Contributing.markdown
|
@@ -71,24 +39,16 @@ files:
|
|
71
39
|
- imgix.gemspec
|
72
40
|
- lib/imgix.rb
|
73
41
|
- lib/imgix/client.rb
|
74
|
-
- lib/imgix/param_helpers.rb
|
75
42
|
- lib/imgix/path.rb
|
76
43
|
- lib/imgix/version.rb
|
77
|
-
- test/test_helper.rb
|
78
|
-
- test/units/domains_test.rb
|
79
|
-
- test/units/param_helpers_test.rb
|
80
|
-
- test/units/path_test.rb
|
81
|
-
- test/units/purge_test.rb
|
82
|
-
- test/units/srcset_test.rb
|
83
|
-
- test/units/url_test.rb
|
84
44
|
homepage: https://github.com/imgix/imgix-rb
|
85
45
|
licenses:
|
86
46
|
- MIT
|
87
47
|
metadata:
|
88
48
|
bug_tracker_uri: https://github.com/imgix/imgix-rb/issues
|
89
49
|
changelog_uri: https://github.com/imgix/imgix-rb/blob/main/CHANGELOG.md
|
90
|
-
documentation_uri: https://www.rubydoc.info/gems/imgix/
|
91
|
-
source_code_uri: https://github.com/imgix/imgix-rb/tree/
|
50
|
+
documentation_uri: https://www.rubydoc.info/gems/imgix/4.0.0
|
51
|
+
source_code_uri: https://github.com/imgix/imgix-rb/tree/4.0.0
|
92
52
|
post_install_message:
|
93
53
|
rdoc_options: []
|
94
54
|
require_paths:
|
@@ -108,11 +68,4 @@ rubygems_version: 3.1.2
|
|
108
68
|
signing_key:
|
109
69
|
specification_version: 4
|
110
70
|
summary: Official Ruby Gem for easily creating and signing imgix URLs.
|
111
|
-
test_files:
|
112
|
-
- test/test_helper.rb
|
113
|
-
- test/units/domains_test.rb
|
114
|
-
- test/units/param_helpers_test.rb
|
115
|
-
- test/units/path_test.rb
|
116
|
-
- test/units/purge_test.rb
|
117
|
-
- test/units/srcset_test.rb
|
118
|
-
- test/units/url_test.rb
|
71
|
+
test_files: []
|
data/.github/CODEOWNERS
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
---
|
2
|
-
name: Bug report
|
3
|
-
about: Create a report to help us improve
|
4
|
-
title: ''
|
5
|
-
labels: bug
|
6
|
-
assignees:
|
7
|
-
|
8
|
-
---
|
9
|
-
|
10
|
-
Please provide the following information and someone from @imgix/imgix-sdk-team will respond to your issue shortly.
|
11
|
-
|
12
|
-
**Describe the bug**
|
13
|
-
A clear and concise description of what the bug is.
|
14
|
-
|
15
|
-
**To Reproduce**
|
16
|
-
Steps to reproduce the behavior:
|
17
|
-
|
18
|
-
**Expected behavior**
|
19
|
-
A clear and concise description of what you expected to happen.
|
20
|
-
|
21
|
-
**Screenshots**
|
22
|
-
If applicable, add screenshots to help explain your problem.
|
23
|
-
|
24
|
-
**Information:**
|
25
|
-
- imgix-rb version: [e.g. 2.0.0]
|
26
|
-
|
27
|
-
**Additional context**
|
28
|
-
Add any other context about the problem here.
|
@@ -1,27 +0,0 @@
|
|
1
|
-
---
|
2
|
-
name: Feature request
|
3
|
-
about: Suggest an idea for this project
|
4
|
-
title: ''
|
5
|
-
labels: ''
|
6
|
-
assignees:
|
7
|
-
|
8
|
-
---
|
9
|
-
|
10
|
-
Please provide the following information and someone from @imgix/imgix-sdk-team will respond to your issue shortly.
|
11
|
-
|
12
|
-
**Before you submit:**
|
13
|
-
|
14
|
-
- [ ] Please search through the [existing issues](https://github.com/imgix/imgix-rb/issues?utf8=%E2%9C%93&q=is%3Aissue) to see if your feature has already been discussed.
|
15
|
-
- [ ] Please take a moment to find out whether your idea fits with the scope and aims of this project.
|
16
|
-
|
17
|
-
**Is your feature request related to a problem? Please describe.**
|
18
|
-
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
19
|
-
|
20
|
-
**Describe the solution you'd like**
|
21
|
-
A clear and concise description of what you want to happen.
|
22
|
-
|
23
|
-
**Describe alternatives you've considered**
|
24
|
-
A clear and concise description of any alternative solutions or features you've considered.
|
25
|
-
|
26
|
-
**Additional context**
|
27
|
-
Add any other context or screenshots about the feature request here.
|
@@ -1,17 +0,0 @@
|
|
1
|
-
---
|
2
|
-
name: Question
|
3
|
-
about: Ask a question about the project
|
4
|
-
title: ''
|
5
|
-
labels: ''
|
6
|
-
assignees:
|
7
|
-
|
8
|
-
---
|
9
|
-
|
10
|
-
Please provide the following information and someone from @imgix/imgix-sdk-team will respond to your issue shortly.
|
11
|
-
|
12
|
-
**Before you submit:**
|
13
|
-
|
14
|
-
- [ ] Please search through the [existing issues](https://github.com/imgix/imgix-rb/issues?utf8=%E2%9C%93&q=is%3Aissue) to see if your question has already been discussed.
|
15
|
-
|
16
|
-
**Question**
|
17
|
-
A clear and concise description of your question.
|
@@ -1,73 +0,0 @@
|
|
1
|
-
<!--
|
2
|
-
Hello, and thanks for contributing to imgix-rb! 🎉🙌
|
3
|
-
Please take a second to fill out PRs with the following template!
|
4
|
-
-->
|
5
|
-
|
6
|
-
# Description
|
7
|
-
|
8
|
-
<!-- What is accomplished by this PR? If there is something potentially controversial in your PR, please take a moment to tell us about your choices. -->
|
9
|
-
|
10
|
-
<!--
|
11
|
-
Please use the checklist that is most closely related to your PR, and delete the other checklists. -->
|
12
|
-
|
13
|
-
## Checklist: Fixing typos/Doc change
|
14
|
-
|
15
|
-
- [ ] Each commit follows the [Conventional Commit](https://www.conventionalcommits.org/en/v1.0.0/#summary) format: e.g. `chore(readme): fixed typo`. See the end of this file for more information.
|
16
|
-
|
17
|
-
## Checklist: Bug Fix
|
18
|
-
|
19
|
-
- [ ] Each commit follows the [Conventional Commit](https://www.conventionalcommits.org/en/v1.0.0/#summary) format: e.g. `chore(readme): fixed typo`. See the end of this file for more information.
|
20
|
-
- [ ] All existing unit tests are still passing (if applicable)
|
21
|
-
- [ ] Add new passing unit tests to cover the code introduced by your PR
|
22
|
-
- [ ] Update the readme
|
23
|
-
- [ ] Update or add any necessary API documentation
|
24
|
-
- [ ] Add some [steps](#steps-to-test) so we can test your bug fix
|
25
|
-
|
26
|
-
## Checklist: New Feature
|
27
|
-
|
28
|
-
- [ ] Each commit follows the [Conventional Commit](https://www.conventionalcommits.org/en/v1.0.0/#summary) format: e.g. `chore(readme): fixed typo`. See the end of this file for more information.
|
29
|
-
- [ ] Any breaking changes are specified on the commit on which they are introduced with `BREAKING CHANGE` in the body of the commit.
|
30
|
-
- [ ] If this is a big feature with breaking changes, consider [opening an issue](https://github.com/imgix/imgix-rb/issues/new?labels=&template=feature_request.md&title=) to discuss first. This is completely up to you, but please keep in mind that your PR might not be accepted.
|
31
|
-
- [ ] Run unit tests to ensure all existing tests are still passing
|
32
|
-
- [ ] Add new passing unit tests to cover the code introduced by your PR
|
33
|
-
- [ ] Update the readme
|
34
|
-
- [ ] Add some [steps](#steps-to-test) so we can test your cool new feature!
|
35
|
-
|
36
|
-
## Steps to Test
|
37
|
-
|
38
|
-
<!-- Delete this selction if you are just submitting a doc change/small fix -->
|
39
|
-
|
40
|
-
<!-- A code example or a set of steps is preferred -->
|
41
|
-
|
42
|
-
Related issue: [e.g. #42]
|
43
|
-
|
44
|
-
Code:
|
45
|
-
|
46
|
-
```rb
|
47
|
-
// A standalone Ruby example of what the PR solves
|
48
|
-
```
|
49
|
-
|
50
|
-
<!-- A link to a codepen/codesandbox is also an option. -->
|
51
|
-
|
52
|
-
<!--
|
53
|
-
|
54
|
-
## Conventional Commit Spec
|
55
|
-
|
56
|
-
PR titles should be in the format `<type>(<scope>): <description>`. For example: `chore(readme): fix typo`
|
57
|
-
|
58
|
-
`type` can be any of the follow:
|
59
|
-
- `feat`: a feature, or breaking change
|
60
|
-
- `fix`: a bug-fix
|
61
|
-
- `test`: Adding missing tests or correcting existing tests
|
62
|
-
- `docs`: documentation only changes (readme, changelog, contributing guide)
|
63
|
-
- `refactor`: a code change that neither fixes a bug nor adds a feature
|
64
|
-
- `chore`: reoccurring tasks for project maintainability (example scopes: release, deps)
|
65
|
-
- `config`: changes to tooling configurations used in the project
|
66
|
-
- `build`: changes that affect the build system or external dependencies (example scopes: npm, bundler, gradle)
|
67
|
-
- `ci`: changes to CI configuration files and scripts (example scopes: travis)
|
68
|
-
- `perf`: a code change that improves performance
|
69
|
-
- `style`: changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
|
70
|
-
|
71
|
-
`scope` is optional, and can be anything.
|
72
|
-
`description` should be a short description of the change, written in the imperative-mood.
|
73
|
-
-->
|
data/lib/imgix/param_helpers.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Imgix
|
4
|
-
module ParamHelpers
|
5
|
-
def rect(position)
|
6
|
-
warn "Warning: `ParamHelpers.rect` has been deprecated and will be removed in the next major version.\n"
|
7
|
-
@options[:rect] = position and return self if position.is_a?(String)
|
8
|
-
|
9
|
-
@options[:rect] = [
|
10
|
-
position[:x] || position[:left],
|
11
|
-
position[:y] || position[:top],
|
12
|
-
position[:width] || (position[:right] - position[:left]),
|
13
|
-
position[:height] || (position[:bottom] - position[:top])
|
14
|
-
].join(',')
|
15
|
-
|
16
|
-
return self
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
data/test/test_helper.rb
DELETED
data/test/units/domains_test.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'test_helper'
|
4
|
-
|
5
|
-
class DomainsTest < Imgix::Test
|
6
|
-
def test_invalid_domain_append_slash
|
7
|
-
assert_raises(ArgumentError) {Imgix::Client.new(host: "assets.imgix.net/")}
|
8
|
-
end
|
9
|
-
|
10
|
-
def test_invalid_domain_prepend_scheme
|
11
|
-
assert_raises(ArgumentError) {Imgix::Client.new(host: "https://assets.imgix.net")}
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_invalid_domain_append_dash
|
15
|
-
assert_raises(ArgumentError) {Imgix::Client.new(host: "assets.imgix.net-")}
|
16
|
-
end
|
17
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'test_helper'
|
4
|
-
|
5
|
-
class ParamHelpers < Imgix::Test
|
6
|
-
def test_param_helpers_emits_dep_warning
|
7
|
-
host_warn = "Warning: The identifier `host' has been deprecated and " \
|
8
|
-
"will\nappear as `domain' in the next major version, e.g. " \
|
9
|
-
"`@host'\nbecomes `@domain', `options[:host]' becomes " \
|
10
|
-
"`options[:domain]'.\n"
|
11
|
-
|
12
|
-
assert_output(nil, host_warn) {
|
13
|
-
client = Imgix::Client.new(host: 'test.imgix.net')
|
14
|
-
|
15
|
-
rect_warn = "Warning: `ParamHelpers.rect` has been deprecated and " \
|
16
|
-
"will be removed in the next major version.\n"
|
17
|
-
|
18
|
-
assert_output(nil, rect_warn){
|
19
|
-
client.path('/images/demo.png').rect(x: 0, y: 50, width: 200, height: 300)
|
20
|
-
}
|
21
|
-
}
|
22
|
-
end
|
23
|
-
end
|
data/test/units/path_test.rb
DELETED
@@ -1,182 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'test_helper'
|
4
|
-
|
5
|
-
class PathTest < Imgix::Test
|
6
|
-
def test_prefix_with_arg_warns
|
7
|
-
prefix_warn = "Warning: `Client::prefix' will take zero arguments " \
|
8
|
-
"in the next major version.\n"
|
9
|
-
|
10
|
-
assert_output(nil, prefix_warn) {
|
11
|
-
Imgix::Client.new(
|
12
|
-
domain: 'test.imgix.net',
|
13
|
-
include_library_param: false
|
14
|
-
).prefix("")
|
15
|
-
}
|
16
|
-
|
17
|
-
# `new_prefix' is a placeholder until the bump, when it will become
|
18
|
-
# `prefix`.
|
19
|
-
assert_output(nil, nil) {
|
20
|
-
Imgix::Client.new(
|
21
|
-
domain: 'test.imgix.net',
|
22
|
-
include_library_param: false
|
23
|
-
).new_prefix
|
24
|
-
}
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_creating_a_path
|
28
|
-
path = client.path('/images/demo.png')
|
29
|
-
assert_equal 'https://demo.imgix.net/images/demo.png?s=2c7c157eaf23b06a0deb2f60b81938c4', path.to_url
|
30
|
-
|
31
|
-
path = client.path('images/demo.png')
|
32
|
-
assert_equal 'https://demo.imgix.net/images/demo.png?s=2c7c157eaf23b06a0deb2f60b81938c4', path.to_url
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_signing_path_with_param
|
36
|
-
url = 'https://demo.imgix.net/images/demo.png?w=200&s=da421114ca238d1f4a927b889f67c34e'
|
37
|
-
path = client.path('/images/demo.png')
|
38
|
-
|
39
|
-
assert_output(nil, "Warning: `Path.width=' has been deprecated and " \
|
40
|
-
"will be removed in the next major version (along " \
|
41
|
-
"with all parameter `ALIASES`).\n") {
|
42
|
-
path.width = 200
|
43
|
-
}
|
44
|
-
|
45
|
-
assert_equal url, path.to_url
|
46
|
-
|
47
|
-
path = client.path('/images/demo.png')
|
48
|
-
assert_equal url, path.to_url(w: 200)
|
49
|
-
|
50
|
-
path = client.path('/images/demo.png')
|
51
|
-
|
52
|
-
assert_output(nil, "Warning: `Path.width' has been deprecated and " \
|
53
|
-
"will be removed in the next major version (along " \
|
54
|
-
"with all parameter `ALIASES`).\n") {
|
55
|
-
assert_equal url, path.width(200).to_url
|
56
|
-
}
|
57
|
-
end
|
58
|
-
|
59
|
-
def test_resetting_defaults
|
60
|
-
url = 'https://demo.imgix.net/images/demo.png?w=200&s=da421114ca238d1f4a927b889f67c34e'
|
61
|
-
path = client.path('/images/demo.png')
|
62
|
-
|
63
|
-
assert_output(nil, "Warning: `Path.height=' has been deprecated and " \
|
64
|
-
"will be removed in the next major version (along " \
|
65
|
-
"with all parameter `ALIASES`).\n") {
|
66
|
-
path.height = 300
|
67
|
-
}
|
68
|
-
|
69
|
-
assert_equal url, path.defaults.to_url(w: 200)
|
70
|
-
end
|
71
|
-
|
72
|
-
def test_path_with_multiple_params
|
73
|
-
url = 'https://demo.imgix.net/images/demo.png?h=200&w=200&s=d570a1ecd765470f7b34a69b56718a7a'
|
74
|
-
path = client.path('/images/demo.png')
|
75
|
-
|
76
|
-
assert_equal url, path.to_url(h: 200, w: 200)
|
77
|
-
|
78
|
-
path = client.path('/images/demo.png')
|
79
|
-
|
80
|
-
assert_output(nil, "Warning: `Path.height' has been deprecated and " \
|
81
|
-
"will be removed in the next major version (along " \
|
82
|
-
"with all parameter `ALIASES`).\n") {
|
83
|
-
path.height(200)
|
84
|
-
}
|
85
|
-
|
86
|
-
|
87
|
-
assert_output(nil, "Warning: `Path.width' has been deprecated and " \
|
88
|
-
"will be removed in the next major version (along " \
|
89
|
-
"with all parameter `ALIASES`).\n") {
|
90
|
-
path.width(200)
|
91
|
-
}
|
92
|
-
|
93
|
-
assert_equal url, path.to_url
|
94
|
-
end
|
95
|
-
|
96
|
-
def test_path_with_multi_value_param_safely_encoded
|
97
|
-
url = 'https://demo.imgix.net/images/demo.png?markalign=middle%2Ccenter&s=f0d0e28a739f022638f4ba6dddf9b694'
|
98
|
-
path = client.path('/images/demo.png')
|
99
|
-
|
100
|
-
assert_equal url, path.markalign('middle', 'center').to_url
|
101
|
-
end
|
102
|
-
|
103
|
-
def test_param_keys_are_escaped
|
104
|
-
ix_url = unsigned_client.path('demo.png').to_url({
|
105
|
-
:'hello world' => 'interesting'
|
106
|
-
})
|
107
|
-
|
108
|
-
assert_equal "https://demo.imgix.net/demo.png?hello%20world=interesting", ix_url
|
109
|
-
end
|
110
|
-
|
111
|
-
def test_param_values_are_escaped
|
112
|
-
ix_url = unsigned_client.path('demo.png').to_url({
|
113
|
-
hello_world: '/foo"> <script>alert("hacked")</script><'
|
114
|
-
})
|
115
|
-
|
116
|
-
assert_equal "https://demo.imgix.net/demo.png?hello_world=%2Ffoo%22%3E%20%3Cscript%3Ealert%28%22hacked%22%29%3C%2Fscript%3E%3C", ix_url
|
117
|
-
end
|
118
|
-
|
119
|
-
def test_base64_param_variants_are_base64_encoded
|
120
|
-
ix_url = unsigned_client.path('~text').to_url({
|
121
|
-
txt64: 'I cannøt belîév∑ it wors! 😱'
|
122
|
-
})
|
123
|
-
|
124
|
-
assert_equal "https://demo.imgix.net/~text?txt64=SSBjYW5uw7h0IGJlbMOuw6l24oiRIGl0IHdvcu-jv3MhIPCfmLE", ix_url
|
125
|
-
end
|
126
|
-
|
127
|
-
def test_host_is_required
|
128
|
-
assert_raises(ArgumentError) {Imgix::Client.new}
|
129
|
-
end
|
130
|
-
|
131
|
-
def test_token_is_optional
|
132
|
-
client = Imgix::Client.new(host: 'demo.imgix.net', include_library_param: false)
|
133
|
-
url = 'https://demo.imgix.net/images/demo.png'
|
134
|
-
path = client.path('/images/demo.png')
|
135
|
-
|
136
|
-
assert_equal url, path.to_url
|
137
|
-
end
|
138
|
-
|
139
|
-
def test_https_is_optional
|
140
|
-
client = Imgix::Client.new(host: 'demo.imgix.net', include_library_param: false, use_https: false)
|
141
|
-
url = 'http://demo.imgix.net/images/demo.png'
|
142
|
-
path = client.path('/images/demo.png')
|
143
|
-
|
144
|
-
assert_equal url, path.to_url
|
145
|
-
end
|
146
|
-
|
147
|
-
def test_full_url
|
148
|
-
path = 'https://google.com/cats.gif'
|
149
|
-
|
150
|
-
assert_equal "https://demo.imgix.net/#{CGI.escape(path)}?s=e686099fbba86fc2b8141d3c1ff60605", client.path(path).to_url
|
151
|
-
end
|
152
|
-
|
153
|
-
def test_full_url_with_a_space
|
154
|
-
path = 'https://my-demo-site.com/files/133467012/avatar icon.png'
|
155
|
-
assert_equal "https://demo.imgix.net/#{CGI.escape(path)}?s=35ca40e2e7b6bd208be2c4f7073f658e", client.path(path).to_url
|
156
|
-
end
|
157
|
-
|
158
|
-
def test_include_library_param
|
159
|
-
client = Imgix::Client.new(host: 'demo.imgix.net') # enabled by default
|
160
|
-
url = client.path('/images/demo.png').to_url
|
161
|
-
|
162
|
-
assert_equal "ixlib=rb-#{Imgix::VERSION}", URI(url).query
|
163
|
-
end
|
164
|
-
|
165
|
-
def test_configure_library_param
|
166
|
-
library = "sinatra"
|
167
|
-
version = Imgix::VERSION
|
168
|
-
client = Imgix::Client.new(host: 'demo.imgix.net', library_param: library, library_version: version) # enabled by default
|
169
|
-
url = client.path('/images/demo.png').to_url
|
170
|
-
|
171
|
-
assert_equal "ixlib=#{library}-#{version}", URI(url).query
|
172
|
-
end
|
173
|
-
|
174
|
-
private
|
175
|
-
def client
|
176
|
-
@client ||= Imgix::Client.new(host: 'demo.imgix.net', secure_url_token: '10adc394', include_library_param: false)
|
177
|
-
end
|
178
|
-
|
179
|
-
def unsigned_client
|
180
|
-
@unsigned_client ||= Imgix::Client.new(host: 'demo.imgix.net', include_library_param: false)
|
181
|
-
end
|
182
|
-
end
|