imgix 4.0.2 → 4.1.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
  SHA256:
3
- metadata.gz: b593ef71fdd4683f9af895b093f631c8ee57c0e5e1008dd82ece781d422d1b36
4
- data.tar.gz: eb75567f9424d0b898e7773fac412d0500d24350e4a6d73775babb739f01d971
3
+ metadata.gz: 602b99690fd97aee3a0a4678d6ac1fe6d688daf235d8246945688e047ca74523
4
+ data.tar.gz: b18e77370f3cbc0328bbe96314eb6de431e0b60742d57925b157d6100137c48b
5
5
  SHA512:
6
- metadata.gz: '0389f0633ffba93ba0e5eb3e69dbf7017462ade823648ce3c490451ea0c5bd6c30a9a6c95b8e03f3111eb27cd6bdc4b766eb279b7c9c95f9feae77c6751c6b39'
7
- data.tar.gz: c2033581fb3e629ff440c3aada007804872dc2d5a9f495006a47dded1ad532d043b9a83bc8e12ae3bc9ddb4874c3bc6802e5ac5f2677a8182cee4e6c43e6267e
6
+ metadata.gz: d92620d3a62fef11fe714479e0637baad892ba9a3dea93e59d3ff83dd1b14aab81c61b788f4c0b905a555e24e9d7ae24c2f4ff9432401be93931854b431cdf8e
7
+ data.tar.gz: 488e1b1123b4eff4cb8fb91c58d8e214c7ae06ebbee5a1d5522382678ea7e1a53f673fc84674f585ac9e18110284427cc3964f548b889feb92e2ed33e9d8fbc1
data/.gitignore CHANGED
@@ -4,7 +4,6 @@
4
4
  .config
5
5
  .yardoc
6
6
  .ruby-version
7
- Gemfile.lock
8
7
  InstalledFiles
9
8
  _yardoc
10
9
  coverage
data/CHANGELOG.md CHANGED
@@ -3,112 +3,127 @@
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
+ ## [4.1.0](https://github.com/imgix/imgix-rb/compare/4.0.3...4.1.0) - December 14, 2022
7
+
8
+ - feat: add parameter to disable path encoding ([#124](https://github.com/imgix/imgix-rb/pull/124))
9
+
10
+ ## [4.0.3](https://github.com/imgix/imgix-rb/compare/4.0.2...4.0.3) - May 05, 2021
11
+
12
+ - fix: encode web proxy paths using url_encode ([#111](https://github.com/imgix/imgix-rb/pull/111))
13
+
6
14
  ## [4.0.2](https://github.com/imgix/imgix-rb/compare/4.0.1...4.0.2) - April 22, 2021
7
15
 
8
- * fix(path): correctly encode reserved chars ([#108](https://github.com/imgix/imgix-rb/pull/108))
9
- * test: add benchmark script for Imgix::Path#to_url ([4b00c4b](https://github.com/imgix/imgix-rb/commit/4b00c4b6d27b87787464438b36954b9c166096eb))
10
- * perf: avoid calculating path_and_params twice ([#109](https://github.com/imgix/imgix-rb/pull/109))
11
- * ci: use major version only for Rubinius 3 ([921e41a](https://github.com/imgix/imgix-rb/commit/921e41ac7789a55c78b42d60ac99cc0b641a69fd))
12
- * ci: use optimistic versioning ([#107](https://github.com/imgix/imgix-rb/pull/107))
13
- * ci: remove support for ruby version <2.5 ([#106](https://github.com/imgix/imgix-rb/pull/106))
14
- * perf: precompute DEFAULT_TARGET_WIDTHS to avoid repeating on Path.new ([#105](https://github.com/imgix/imgix-rb/pull/105))
16
+ - fix(path): correctly encode reserved chars ([#108](https://github.com/imgix/imgix-rb/pull/108))
17
+ - test: add benchmark script for Imgix::Path#to_url ([4b00c4b](https://github.com/imgix/imgix-rb/commit/4b00c4b6d27b87787464438b36954b9c166096eb))
18
+ - perf: avoid calculating path_and_params twice ([#109](https://github.com/imgix/imgix-rb/pull/109))
19
+ - ci: use major version only for Rubinius 3 ([921e41a](https://github.com/imgix/imgix-rb/commit/921e41ac7789a55c78b42d60ac99cc0b641a69fd))
20
+ - ci: use optimistic versioning ([#107](https://github.com/imgix/imgix-rb/pull/107))
21
+ - ci: remove support for ruby version <2.5 ([#106](https://github.com/imgix/imgix-rb/pull/106))
22
+ - perf: precompute DEFAULT_TARGET_WIDTHS to avoid repeating on Path.new ([#105](https://github.com/imgix/imgix-rb/pull/105))
15
23
 
16
24
  ## [4.0.1](https://github.com/imgix/imgix-rb/compare/4.0.0...4.0.1) - March 24, 2021
17
25
 
18
- * fix: dpr srcset when only h param ([#101](https://github.com/imgix/imgix-rb/pull/101))
19
- * docs: update travis badge to point to travis-ci.com ([#99](https://github.com/imgix/imgix-rb/pull/99))
20
- * docs: fixed typo w/ srcset min/max widths ([#97](https://github.com/imgix/imgix-rb/pull/97))
26
+ - fix: dpr srcset when only h param ([#101](https://github.com/imgix/imgix-rb/pull/101))
27
+ - docs: update travis badge to point to travis-ci.com ([#99](https://github.com/imgix/imgix-rb/pull/99))
28
+ - docs: fixed typo w/ srcset min/max widths ([#97](https://github.com/imgix/imgix-rb/pull/97))
21
29
 
22
30
  ## [4.0.0](https://github.com/imgix/imgix-rb/compare/3.4.0...4.0.0) - August 26, 2020
23
31
 
24
- * deprecate: host-usage, param_helpers, and prefix-1-ary ([#91](https://github.com/imgix/imgix-rb/pull/91))
25
- * fix: update purge operation api keys ([#93](https://github.com/imgix/imgix-rb/pull/93))
32
+ - deprecate: host-usage, param_helpers, and prefix-1-ary ([#91](https://github.com/imgix/imgix-rb/pull/91))
33
+ - fix: update purge operation api keys ([#93](https://github.com/imgix/imgix-rb/pull/93))
26
34
 
27
35
  ## [3.4.0](https://github.com/imgix/imgix-rb/compare/3.3.1...3.4.0) - August 12, 2020
28
36
 
29
- * fix: deprecate api key versions ([#87](https://github.com/imgix/imgix-rb/pull/87))
30
- * docs(readme): deprecation notice for pre-4.0 api keys ([#88](https://github.com/imgix/imgix-rb/pull/88))
37
+ - fix: deprecate api key versions ([#87](https://github.com/imgix/imgix-rb/pull/87))
38
+ - docs(readme): deprecation notice for pre-4.0 api keys ([#88](https://github.com/imgix/imgix-rb/pull/88))
31
39
 
32
40
  ## [3.3.1](https://github.com/imgix/imgix-rb/compare/3.3.0...3.3.1) - July 27, 2020
33
41
 
34
- * fix: ensure host is initialized ([#82](https://github.com/imgix/imgix-rb/pull/82))
42
+ - fix: ensure host is initialized ([#82](https://github.com/imgix/imgix-rb/pull/82))
35
43
 
36
44
  ## [3.3.0](https://github.com/imgix/imgix-rb/compare/3.2.1...3.3.0) - July 21, 2020
37
45
 
38
- * fix: warn prefix-with-args is deprecated ([#78](https://github.com/imgix/imgix-rb/pull/78))
39
- * fix: warn host has been deprecated in favor of domain ([#76](https://github.com/imgix/imgix-rb/pull/76))
40
- * fix: deprecate ALIASES and corresponding define_method(s) ([#75](https://github.com/imgix/imgix-rb/pull/75))
41
- * fix: deprecate ParamHelpers.rect ([#74](https://github.com/imgix/imgix-rb/pull/74))
42
- * fix: allow rbx-3.107 to fail (travis-config) ([#70](https://github.com/imgix/imgix-rb/pull/70))
43
- * fix: remove ensure even requirement ([#69](https://github.com/imgix/imgix-rb/pull/69))
46
+ - fix: warn prefix-with-args is deprecated ([#78](https://github.com/imgix/imgix-rb/pull/78))
47
+ - fix: warn host has been deprecated in favor of domain ([#76](https://github.com/imgix/imgix-rb/pull/76))
48
+ - fix: deprecate ALIASES and corresponding define_method(s) ([#75](https://github.com/imgix/imgix-rb/pull/75))
49
+ - fix: deprecate ParamHelpers.rect ([#74](https://github.com/imgix/imgix-rb/pull/74))
50
+ - fix: allow rbx-3.107 to fail (travis-config) ([#70](https://github.com/imgix/imgix-rb/pull/70))
51
+ - fix: remove ensure even requirement ([#69](https://github.com/imgix/imgix-rb/pull/69))
44
52
 
45
53
  ## [3.2.1](https://github.com/imgix/imgix-rb/compare/3.2.0...3.2.1) - November 15, 2019
46
54
 
47
- * fix: duplicate entries when using `min_width` or `max_width` ([#59](https://github.com/imgix/imgix-rb/pull/59))
55
+ - fix: duplicate entries when using `min_width` or `max_width` ([#59](https://github.com/imgix/imgix-rb/pull/59))
48
56
 
49
57
  ## [3.2.0](https://github.com/imgix/imgix-rb/compare/3.1.1...3.2.0) - November 15, 2019
50
58
 
51
- * feat: append variable qualities to dpr srcsets ([#58](https://github.com/imgix/imgix-rb/pull/58))
52
- * refactor: pass srcset modifiers through the `options` parameter ([#57](https://github.com/imgix/imgix-rb/pull/57))
53
- * feat: support defining a min and max width range ([#56](https://github.com/imgix/imgix-rb/pull/56))
54
- * feat: add ability to pass in custom widths ([#55](https://github.com/imgix/imgix-rb/pull/55))
55
- * feat: add ability to configure the srcset width tolerance ([#54](https://github.com/imgix/imgix-rb/pull/54))
56
- * style: drop redundant explicit return statements ([#52](https://github.com/imgix/imgix-rb/pull/52))
59
+ - feat: append variable qualities to dpr srcsets ([#58](https://github.com/imgix/imgix-rb/pull/58))
60
+ - refactor: pass srcset modifiers through the `options` parameter ([#57](https://github.com/imgix/imgix-rb/pull/57))
61
+ - feat: support defining a min and max width range ([#56](https://github.com/imgix/imgix-rb/pull/56))
62
+ - feat: add ability to pass in custom widths ([#55](https://github.com/imgix/imgix-rb/pull/55))
63
+ - feat: add ability to configure the srcset width tolerance ([#54](https://github.com/imgix/imgix-rb/pull/54))
64
+ - style: drop redundant explicit return statements ([#52](https://github.com/imgix/imgix-rb/pull/52))
57
65
 
58
66
  ## [3.1.1](https://github.com/imgix/imgix-rb/compare/3.1.0...3.1.1) - July 28, 2019
59
67
 
60
- * fix: include dpr parameter when generating a DPR srcset ([#48](https://github.com/imgix/imgix-rb/pull/48))
61
- * ci(travis): change build dist to trusty and remove bundler script ([#49](https://github.com/imgix/imgix-rb/pull/49))
68
+ - fix: include dpr parameter when generating a DPR srcset ([#48](https://github.com/imgix/imgix-rb/pull/48))
69
+ - ci(travis): change build dist to trusty and remove bundler script ([#49](https://github.com/imgix/imgix-rb/pull/49))
62
70
 
63
71
  ## [3.1.0](https://github.com/imgix/imgix-rb/compare/3.0.0...3.1.0) - July 28, 2019
64
72
 
65
- * feat: add srcset generation ([#47](https://github.com/imgix/imgix-rb/pull/47))
73
+ - feat: add srcset generation ([#47](https://github.com/imgix/imgix-rb/pull/47))
66
74
 
67
75
  ## [3.0.0](https://github.com/imgix/imgix-rb/compare/2.1.0...3.0.0) - June 7, 2019
68
76
 
69
- * fix: remove deprecated domain sharding functionality ([#46](https://github.com/imgix/imgix-rb/pull/46))
77
+ - fix: remove deprecated domain sharding functionality ([#46](https://github.com/imgix/imgix-rb/pull/46))
70
78
 
71
79
  ## [2.1.0](https://github.com/imgix/imgix-rb/compare/2.0.0...2.1.0) - May 7, 2019
72
80
 
73
- * Deprecate domain sharding ([#43](https://github.com/imgix/imgix-rb/pull/43)) ([#45](https://github.com/imgix/imgix-rb/pull/45))
81
+ - Deprecate domain sharding ([#43](https://github.com/imgix/imgix-rb/pull/43)) ([#45](https://github.com/imgix/imgix-rb/pull/45))
74
82
 
75
83
  ## [2.0.0] - February 25, 2019
76
84
 
77
- * Add domain validation during Client initialization [#42](https://github.com/imgix/imgix-rb/pull/42)
78
- * Expand Travis CI config to include bundler v2.x [#41](https://github.com/imgix/imgix-rb/pull/41)
85
+ - Add domain validation during Client initialization [#42](https://github.com/imgix/imgix-rb/pull/42)
86
+ - Expand Travis CI config to include bundler v2.x [#41](https://github.com/imgix/imgix-rb/pull/41)
79
87
 
80
88
  ## [1.2.2] - November 14, 2018
81
89
 
82
- * Improvements to memory usage [#35](https://github.com/imgix/imgix-rb/pull/35)
90
+ - Improvements to memory usage [#35](https://github.com/imgix/imgix-rb/pull/35)
83
91
 
84
92
  ## [1.2.1] - November 5, 2018
85
93
 
86
- * Removed unused `HTTP` dependency [#38](https://github.com/imgix/imgix-rb/pull/37)
94
+ - Removed unused `HTTP` dependency [#38](https://github.com/imgix/imgix-rb/pull/37)
87
95
 
88
96
  ## [1.2.0] - October 29, 2018
89
97
 
90
- * Added `Client#purge` method to allow purging assets from our cache [#37](https://github.com/imgix/imgix-rb/pull/38)
98
+ - Added `Client#purge` method to allow purging assets from our cache [#37](https://github.com/imgix/imgix-rb/pull/38)
91
99
 
92
100
  ## [1.1.0] - February 24, 2016
93
101
 
94
- * Added automatic Base64 encoding for all Base64 variant parameters.
95
- * Properly encoding all keys and values output by `Imgix::Path`.
96
- * Better URL encoding for spaces, with `ERB::Util.url_encode`.
97
- * Normalize trailing `/` in passed hosts.
102
+ - Added automatic Base64 encoding for all Base64 variant parameters.
103
+ - Properly encoding all keys and values output by `Imgix::Path`.
104
+ - Better URL encoding for spaces, with `ERB::Util.url_encode`.
105
+ - Normalize trailing `/` in passed hosts.
98
106
 
99
107
  ## [1.0.0] - December 9, 2015
108
+
100
109
  ### Changed
110
+
101
111
  - Removed `Client#sign_path` to provide a consistent method and code path for generating URLs. [#16](https://github.com/imgix/imgix-rb/issues/16)
102
112
  - Changed `:secure` option to the more clear `:use_https` [#11](https://github.com/imgix/imgix-rb/issues/11)
103
113
  - Changed `:token` option to the more clear `:secure_url_token` [#11](https://github.com/imgix/imgix-rb/issues/11)
104
114
 
105
115
  ### Fixed
116
+
106
117
  - Fixed URL query strings beginning with `?&s=` instead of `?s=` when no other params are present. [#15](https://github.com/imgix/imgix-rb/issues/15)
107
118
 
108
119
  ## [0.3.3] - May 14, 2015
120
+
109
121
  ### Fixed
122
+
110
123
  - Fixed a bug where URLs as the path component for Web Proxy sources would not be encoded would generate URLs that would result in a 400 Bad Request. [#8](https://github.com/imgix/imgix-rb/pull/8)
111
124
 
112
125
  ## [0.3.2] - May 11, 2015
126
+
113
127
  ### Fixed
128
+
114
129
  - Fixed a bug where the library would not work if tokens were not present.
@@ -0,0 +1,3 @@
1
+ # Code of Conduct
2
+
3
+ Please read the imgix [Code of Conduct](https://github.com/imgix/code-of-conduct).
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,108 @@
1
+ # Contributing Guide
2
+
3
+ Thank you for investing your time in contributing to this project! Please take a moment to review this document in order to streamline the contribution process for you and any reviewers involved.
4
+
5
+ Read our [Code of Conduct](./CODE_OF_CONDUCT.md) to keep our community approachable and respectable.
6
+
7
+ In this guide you will get an overview of the contribution workflow from opening an issue, creating a PR, reviewing, and merging the PR.
8
+
9
+ ## New contributor guide
10
+
11
+ To get an overview of the project, read the [README](README.md). Here are some resources to help you get started with open source contributions:
12
+
13
+ - [Finding ways to contribute to open source on GitHub](https://docs.github.com/en/get-started/exploring-projects-on-github/finding-ways-to-contribute-to-open-source-on-github)
14
+ - [Set up Git](https://docs.github.com/en/get-started/quickstart/set-up-git)
15
+ - [GitHub flow](https://docs.github.com/en/get-started/quickstart/github-flow)
16
+ - [Collaborating with pull requests](https://docs.github.com/en/github/collaborating-with-pull-requests)
17
+
18
+ ## Opening a Pull Request
19
+
20
+ _To help the project's maintainers and community quickly understand the nature of your pull request, please be sure to do the following:_
21
+
22
+ 1. Include a descriptive Pull Request title.
23
+ 2. Provide a detailed description that explains the nature of the change(s) introduced. This is not only helpful for your reviewer, but also for future users who may need to revisit your Pull Request for context purposes. Screenshots/video captures are helpful here!
24
+ 3. Make incremental, modular changes, with a clean commit history. This helps reviewers understand your contribution more easily and maintain project quality.
25
+
26
+ ### Checklist
27
+
28
+ Check to see that you have completed each of the following before requesting a review of your Pull Request:
29
+
30
+ - [ ] All existing unit tests are still passing (if applicable)
31
+ - [ ] Add new passing unit tests to cover the code introduced by your PR
32
+ - [ ] Update the README
33
+ - [ ] Update or add any necessary API documentation
34
+ - [ ] All commits in the branch adhere to the [conventional commit](#conventional-commit-spec) format: e.g. `fix: bug #issue-number`
35
+
36
+ ## Conventional Commit Spec
37
+
38
+ Commits should be in the format `<type>(<scope>): <description>`. This allows our team to leverage tooling for automatic releases and changelog generation. An example of a commit in this format might be: `docs(readme): fix typo in documentation`
39
+
40
+ `type` can be any of the follow:
41
+
42
+ - `feat`: a feature, or breaking change
43
+ - `fix`: a bug-fix
44
+ - `test`: Adding missing tests or correcting existing tests
45
+ - `docs`: documentation only changes (readme, changelog, contributing guide)
46
+ - `refactor`: a code change that neither fixes a bug nor adds a feature
47
+ - `chore`: reoccurring tasks for project maintainability (example scopes: release, deps)
48
+ - `config`: changes to tooling configurations used in the project
49
+ - `build`: changes that affect the build system or external dependencies (example scopes: npm, bundler, gradle)
50
+ - `ci`: changes to CI configuration files and scripts (example scopes: travis)
51
+ - `perf`: a code change that improves performance
52
+ - `style`: changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
53
+
54
+ `scope` is optional, and can be anything.
55
+ `description` should be a short description of the change, written in the imperative-mood.
56
+
57
+ ### Example workflow
58
+
59
+ Follow this process if you'd like your work considered for inclusion in the
60
+ project:
61
+
62
+ 1. [Fork](http://help.github.com/fork-a-repo/) the project, clone your fork,
63
+ and configure the remotes:
64
+
65
+ ```bash
66
+ # Clone your fork of the repo into the current directory
67
+ git clone git@github.com:<YOUR_USERNAME>/imgix-rb.git
68
+ # Navigate to the newly cloned directory
69
+ cd imgix-rb
70
+ # Assign the original repo to a remote called "upstream"
71
+ git remote add upstream https://github.com/imgix/imgix-rb
72
+ ```
73
+
74
+ 2. If you cloned a while ago, get the latest changes from upstream:
75
+
76
+ ```bash
77
+ git checkout <dev-branch>
78
+ git pull upstream <dev-branch>
79
+ ```
80
+
81
+ 3. Create a new topic branch (off the main project development branch) to
82
+ contain your feature, change, or fix:
83
+
84
+ ```bash
85
+ git checkout -b <topic-branch-name>
86
+ ```
87
+
88
+ 4. Commit your changes in logical chunks. Use Git's
89
+ [interactive rebase](https://help.github.com/articles/interactive-rebase)
90
+ feature to tidy up your commits before making them public.
91
+
92
+ 5. Locally merge (or rebase) the upstream development branch into your topic branch:
93
+
94
+ ```bash
95
+ git pull [--rebase] upstream <dev-branch>
96
+ ```
97
+
98
+ 6. Push your topic branch up to your fork:
99
+
100
+ ```bash
101
+ git push origin <topic-branch-name>
102
+ ```
103
+
104
+ 7. [Open a Pull Request](https://help.github.com/articles/using-pull-requests/)
105
+ with a clear title and description.
106
+
107
+ **IMPORTANT**: By submitting a patch, you agree to allow the project owner to
108
+ license your work under the same license as that used by the project.
data/Gemfile CHANGED
@@ -7,8 +7,10 @@ gemspec
7
7
 
8
8
  gem 'rake'
9
9
  gem 'json'
10
- gem 'minitest'
11
- gem 'minitest-reporters'
12
- gem 'webmock'
13
10
  gem 'benchmark-ips'
14
11
 
12
+ group :test do
13
+ gem 'minitest'
14
+ gem 'minitest-reporters'
15
+ gem 'webmock'
16
+ end
data/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  <!-- ix-docs-ignore -->
2
2
  ![imgix logo](https://assets.imgix.net/sdk-imgix-logo.svg)
3
3
 
4
- `imgix-rb` is a client library for generating image URLs with [imgix](https://www.imgix.com/). It is tested under Ruby versions `2.3.0`, `2.2.4`, `2.1.8`, `jruby-9.2.11.0`, and `rbx-3.107`.
4
+ `imgix-rb` is a client library for generating image URLs with [imgix](https://www.imgix.com/). It is tested under Ruby versions `3.1`, `3.0`, `2.7`, and `jruby-9.2.11.0`.
5
5
 
6
6
  [![Gem Version](https://img.shields.io/gem/v/imgix.svg)](https://rubygems.org/gems/imgix)
7
- [![Build Status](https://travis-ci.com/imgix/imgix-rb.svg?branch=main)](https://travis-ci.com/imgix/imgix-rb)
7
+ [![Build Status](https://circleci.com/gh/imgix/imgix-rb.svg?style=shield)](https://circleci.com/gh/imgix/imgix-rb)
8
8
  ![Downloads](https://img.shields.io/gem/dt/imgix)
9
9
  [![License](https://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://github.com/imgix/imgix-rb/blob/main/LICENSE)
10
10
  [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fimgix%2Fimgix-rb.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fimgix%2Fimgix-rb?ref=badge_shield)
@@ -56,12 +56,21 @@ client.path('/images/demo.png').to_url(w: 200)
56
56
  #=> https://your-subdomain.imgix.net/images/demo.png?w=200&s=2eadddacaa9bba4b88900d245f03f51e
57
57
  ```
58
58
 
59
+ To disable path encoding, pass `{disable_path_encoding: true}` as the second argument to the `Imgix#Path#to_url` function.
60
+
61
+ ```rb
62
+ client = Imgix::Client.new(domain: 'your-subdomain.imgix.net', secure_url_token: 'your-token')
63
+ client.path('/[images]/demo.png').to_url
64
+ #=> https://your-subdomain.imgix.net/%5Bimages%5D/demo.png?s=270832685733a36ba02bd8ab9fd72df5
65
+ client.path('/[images]/demo.png').to_url({},{disable_path_encoding: true})
66
+ #=> https://your-subdomain.imgix.net/[images]/demo.png?s=ed6eb07e9eff3f6c8bbcc83fc4f63198
67
+ ```
59
68
  ## Srcset Generation
60
69
 
61
70
  The imgix gem allows for generation of custom `srcset` attributes, which can be invoked through `Imgix::Path#to_srcset`. By default, the `srcset` generated will allow for responsive size switching by building a list of image-width mappings.
62
71
 
63
72
  ```rb
64
- client = Imgix::Client.new(domain: 'your-subdomain.imgix.net', secure_url_token: 'your-token', include_library_param: false)
73
+ client = Imgix::Client.new(domain: 'your-subdomain.imgix.net', secure_url_token: 'your-token')
65
74
  path = client.path('/images/demo.png')
66
75
 
67
76
  srcset = path.to_srcset
@@ -83,7 +92,7 @@ https://your-subdomain.imgix.net/images/demo.png?w=8192&s=9fbd257c53e770e345ce34
83
92
  In cases where enough information is provided about an image's dimensions, `to_srcset` will instead build a `srcset` that will allow for an image to be served at different resolutions. The parameters taken into consideration when determining if an image is fixed-width are `w` or `h`. By invoking `to_srcset` with either a width **or** height provided, a different `srcset` will be generated for a fixed-size image instead.
84
93
 
85
94
  ```rb
86
- client = Imgix::Client.new(domain: 'your-subdomain.imgix.net', secure_url_token: 'your-token', include_library_param: false)
95
+ client = Imgix::Client.new(domain: 'your-subdomain.imgix.net', secure_url_token: 'your-token')
87
96
  path = client.path('/images/demo.png')
88
97
 
89
98
  srcset = path.to_srcset(h:800, ar:'3:2', fit:'crop')
@@ -106,7 +115,7 @@ For more information to better understand `srcset`, we highly recommend [Eric Po
106
115
  In situations where specific widths are desired when generating `srcset` pairs, a user can specify them by passing an array of integers via `widths` to the `options` keyword argument.
107
116
 
108
117
  ```rb
109
- @client ||= Imgix::Client.new(domain: 'testing.imgix.net', include_library_param: false)
118
+ @client ||= Imgix::Client.new(domain: 'testing.imgix.net')
110
119
  .path('image.jpg')
111
120
  .to_srcset(options: { widths: [100, 500, 1000, 1800] })
112
121
  ```
@@ -129,7 +138,7 @@ The `srcset` width tolerance dictates the maximum tolerated size difference betw
129
138
  By default this rate is set to 8 percent, which we consider to be the ideal rate for maximizing cache hits without sacrificing visual quality. Users can specify their own width tolerance by passing a positive numeric value to `width_tolerance` within the `options` keyword argument:
130
139
 
131
140
  ```rb
132
- client = Imgix::Client.new(domain: 'testing.imgix.net', secure_url_token: 'MYT0KEN', include_library_param: false)
141
+ client = Imgix::Client.new(domain: 'testing.imgix.net', secure_url_token: 'MYT0KEN')
133
142
  client.path('image.jpg').to_srcset(options: { width_tolerance: 0.20 })
134
143
  ```
135
144
 
@@ -148,7 +157,7 @@ https://testing.imgix.net/image.jpg?w=8192 8192w
148
157
  If the exact number of minimum/maximum physical pixels that an image will need to be rendered at is known, a user can specify them by passing an integer via `min_width` and/or `max_width` to the `options` keyword parameters:
149
158
 
150
159
  ```rb
151
- client = Imgix::Client.new(domain: 'testing.imgix.net', include_library_param: false)
160
+ client = Imgix::Client.new(domain: 'testing.imgix.net')
152
161
  client.path('image.jpg').to_srcset(options: { min_width: 500, max_width: 2000 })
153
162
  ```
154
163
 
@@ -181,7 +190,7 @@ This behavior will respect any overriding `q` value passed in as a parameter. Ad
181
190
  This behavior specifically occurs when a [fixed-size image](https://github.com/imgix/imgix-rb#fixed-image-rendering) is rendered, for example:
182
191
 
183
192
  ```rb
184
- srcset = Imgix::Client.new(domain: 'testing.imgix.net', include_library_param: false)
193
+ srcset = Imgix::Client.new(domain: 'testing.imgix.net')
185
194
  .path('image.jpg')
186
195
  .to_srcset(w:100)
187
196
  ```
@@ -223,7 +232,7 @@ client = Imgix::Client.new(domain: 'your-subdomain.imgix.net', include_library_p
223
232
 
224
233
  ## Contributing
225
234
 
226
- See the [contributing guide](Contributing.markdown).
235
+ See the [contributing guide](CONTRIBUTING.md).
227
236
 
228
237
  ## License
229
238
  [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fimgix%2Fimgix-rb.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fimgix%2Fimgix-rb?ref=badge_large)
data/imgix.gemspec CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
20
20
  }
21
21
 
22
22
  spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
23
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|.github)/}) }
23
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|.github|.vscode|.circleci)/}) }
24
24
  end
25
25
 
26
26
  spec.require_paths = ["lib"]
data/lib/imgix/path.rb CHANGED
@@ -14,10 +14,10 @@ module Imgix
14
14
  @options = {}
15
15
  end
16
16
 
17
- def to_url(opts = {})
18
- sanitized_path = sanitize_path(@path)
17
+ def to_url(params = {}, options = {})
18
+ sanitized_path = sanitize_path(@path, options)
19
19
  prev_options = @options.dup
20
- @options.merge!(opts)
20
+ @options.merge!(params)
21
21
 
22
22
  current_path_and_params = path_and_params(sanitized_path)
23
23
  url = @prefix + current_path_and_params
@@ -132,11 +132,13 @@ module Imgix
132
132
  # This includes " +?:#" characters. If a path is being used as a proxy, utf8
133
133
  # encode everything. If it is not being used as proxy, leave certain chars, like
134
134
  # "/", alone. Method assumes path is not already encoded.
135
- def sanitize_path(path)
135
+ def sanitize_path(path, options = {})
136
136
  # remove the leading "/", we'll add it back after encoding
137
137
  path = path.slice(1, path.length) if Regexp.new('^/') =~ path
138
+ if options[:disable_path_encoding]
139
+ return "/" + path
138
140
  # if path is being used as a proxy, encode the entire thing
139
- if /^https?/ =~ path
141
+ elsif /^https?/ =~ path
140
142
  return encode_URI_Component(path)
141
143
  else
142
144
  # otherwise, encode only specific characters
@@ -146,7 +148,7 @@ module Imgix
146
148
 
147
149
  # URL encode the entire path
148
150
  def encode_URI_Component(path)
149
- return "/" + CGI.escape(path)
151
+ return "/" + ERB::Util.url_encode(path)
150
152
  end
151
153
 
152
154
  # URL encode every character in the path, including
@@ -207,7 +209,7 @@ module Imgix
207
209
 
208
210
  srcset_widths.each do |width|
209
211
  params[:w] = width
210
- srcset += "#{to_url(params)} #{width}w,\n"
212
+ srcset += "#{to_url(params, options)} #{width}w,\n"
211
213
  end
212
214
 
213
215
  srcset[0..-3]
@@ -227,7 +229,7 @@ module Imgix
227
229
 
228
230
  params[:q] = quality || DPR_QUALITY[ratio] unless disable_variable_quality
229
231
 
230
- srcset += "#{to_url(params)} #{ratio}x,\n"
232
+ srcset += "#{to_url(params, options)} #{ratio}x,\n"
231
233
  end
232
234
 
233
235
  srcset[0..-3]
data/lib/imgix/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Imgix
4
- VERSION = "4.0.2"
4
+ VERSION = "4.1.0"
5
5
  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: 4.0.2
4
+ version: 4.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kelly Sutton
@@ -10,10 +10,10 @@ authors:
10
10
  - Antony Denyer
11
11
  - Paul Straw
12
12
  - Sherwin Heydarbeygi
13
- autorequire:
13
+ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2021-04-26 00:00:00.000000000 Z
16
+ date: 2022-12-15 00:00:00.000000000 Z
17
17
  dependencies: []
18
18
  description: Easily create and sign imgix URLs.
19
19
  email:
@@ -29,10 +29,9 @@ extra_rdoc_files: []
29
29
  files:
30
30
  - ".gitignore"
31
31
  - ".rubocop.yml"
32
- - ".travis.yml"
33
- - ".vscode/tasks.json"
34
32
  - CHANGELOG.md
35
- - Contributing.markdown
33
+ - CODE-OF-CONDUCT.md
34
+ - CONTRIBUTING.md
36
35
  - Gemfile
37
36
  - LICENSE
38
37
  - README.md
@@ -50,9 +49,9 @@ licenses:
50
49
  metadata:
51
50
  bug_tracker_uri: https://github.com/imgix/imgix-rb/issues
52
51
  changelog_uri: https://github.com/imgix/imgix-rb/blob/main/CHANGELOG.md
53
- documentation_uri: https://www.rubydoc.info/gems/imgix/4.0.2
54
- source_code_uri: https://github.com/imgix/imgix-rb/tree/4.0.2
55
- post_install_message:
52
+ documentation_uri: https://www.rubydoc.info/gems/imgix/4.1.0
53
+ source_code_uri: https://github.com/imgix/imgix-rb/tree/4.1.0
54
+ post_install_message:
56
55
  rdoc_options: []
57
56
  require_paths:
58
57
  - lib
@@ -67,8 +66,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
67
66
  - !ruby/object:Gem::Version
68
67
  version: '0'
69
68
  requirements: []
70
- rubygems_version: 3.2.3
71
- signing_key:
69
+ rubygems_version: 3.0.3.1
70
+ signing_key:
72
71
  specification_version: 4
73
72
  summary: Official Ruby Gem for easily creating and signing imgix URLs.
74
73
  test_files: []
data/.travis.yml DELETED
@@ -1,19 +0,0 @@
1
- dist: trusty
2
- language: ruby
3
- bundler_args: --without development
4
- rvm:
5
- - 2.7
6
- - 2.6
7
- - jruby-9.2.11.0
8
-
9
- jobs:
10
- # Use `fast_finish`, don't wait for any allowed failures.
11
- fast_finish: true
12
-
13
- include:
14
- - name: Rubinius
15
- rvm: rbx-3
16
- dist: trusty
17
-
18
- allow_failures:
19
- - name: Rubinius
data/.vscode/tasks.json DELETED
@@ -1,29 +0,0 @@
1
- {
2
- "version": "2.0.0",
3
- "tasks": [
4
- {
5
- "label": "rake: test",
6
- "type": "shell",
7
- "group":{
8
- "kind": "test",
9
- "isDefault": true
10
- },
11
- "problemMatcher": {
12
- "owner": "ruby",
13
- "fileLocation": ["relative", "${workspaceFolder}"],
14
- "pattern": [
15
- {
16
- "regexp": "^([^:]+: .+)",
17
- "message": 1
18
- },
19
- {
20
- "regexp": "^ ([^:]+):(\\d+)",
21
- "file": 1,
22
- "line": 2
23
- }
24
- ]
25
- },
26
- "command": "bundle exec rake test"
27
- }
28
- ]
29
- }
@@ -1,19 +0,0 @@
1
- ## Submitting a Pull Request
2
-
3
- 1. [Fork the repository.][fork]
4
- 2. [Create a topic branch.][branch]
5
- 3. Add tests for your unimplemented feature or bug fix.
6
- 4. Run `bundle exec rake`. If your tests pass, return to step 3.
7
- 5. Implement your feature or bug fix.
8
- 6. Run `bundle exec rake`. If your tests fail, return to step 5.
9
- 7. Run `open coverage/index.html`. If your changes are not completely covered
10
- by your tests, return to step 3.
11
- 8. Add documentation for your feature or bug fix.
12
- 9. Run `bundle exec rake doc`. If your changes are not 100% documented, go
13
- back to step 8.
14
- 10. Add, commit, and push your changes.
15
- 11. [Submit a pull request.][pr]
16
-
17
- [fork]: http://help.github.com/fork-a-repo/
18
- [branch]: http://learn.github.com/p/branching.html
19
- [pr]: http://help.github.com/send-pull-requests/