imgix 3.3.1 → 3.4.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: 1af83e026e72b6ce6bfcfdf1169add23c12cbec68a7d7fbe03243150c832b34b
4
- data.tar.gz: 3a7e0d57c3f65b75327e226918370771f7bb579284228de9e6de77d694d4fadc
3
+ metadata.gz: f8de76cc2340cbfa3ecd0479b9bb421fa163f78c1e8e38011dd5938849665802
4
+ data.tar.gz: 10cac9471323181870d48be911b225323ccb2d02583176f45639af5c19d4eddb
5
5
  SHA512:
6
- metadata.gz: 0a68e202aaa183a4974d9c15a20e97f404269879da403cb7a949c04dd5ba3053e4b4802aa2a7006826f357a4268f87fd20d14971034e598d792e18a5cd2b322d
7
- data.tar.gz: e1f068f01a5cd8cac1b959bd16f9e2d586a72278a6b4be844a822c74a41c7b7e110471c36a4bf156b6ec6c17cbcc5e425ebdf40373b2424ce3360bd1ada391d2
6
+ metadata.gz: e2233648d430a37c9ea72d89420f492c50f28f6e341c3cf7fe70eb711983b6a7b12b0cd103b118cd8783c373cb2b27e62d53a8ae6b2f8e93946d0309d7f812e2
7
+ data.tar.gz: 85209a1262a7d3fd7a39796c487fe87e6c0f75a5a55213676d91834a1af456d8ff01ecb9882ff38818a9dc24c638a64f5c6171bcc09b4f415f9bc38bfb0a136c
@@ -27,7 +27,7 @@ Please use the checklist that is most closely related to your PR, and delete the
27
27
 
28
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
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][issues] to discuss first. This is completely up to you, but please keep in mind that your PR might not be accepted.
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
31
  - [ ] Run unit tests to ensure all existing tests are still passing
32
32
  - [ ] Add new passing unit tests to cover the code introduced by your PR
33
33
  - [ ] Update the readme
@@ -3,6 +3,11 @@
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
+ ## [3.4.0](https://github.com/imgix/imgix-rb/compare/3.3.1...3.4.0) - August 12, 2020
7
+
8
+ * fix: deprecate api key versions ([#87](https://github.com/imgix/imgix-rb/pull/87))
9
+ * docs(readme): deprecation notice for pre-4.0 api keys ([#88](https://github.com/imgix/imgix-rb/pull/88))
10
+
6
11
  ## [3.3.1](https://github.com/imgix/imgix-rb/compare/3.3.0...3.3.1) - July 27, 2020
7
12
 
8
13
  * fix: ensure host is initialized ([#82](https://github.com/imgix/imgix-rb/pull/82))
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in imgix.gemspec
data/README.md CHANGED
@@ -230,6 +230,8 @@ path.noise_reduction(50,50)
230
230
 
231
231
  ## Purge Cache
232
232
 
233
+ **Deprecation Notice:** The API keys used in `Imgix::Client#purge` version `3.3.X` have been deprecated. To utilize the updated `Imgix::Client#purge` method in version `4.0.0`, please regenerate your API key at `http://dashboard.imgix.com/api-keys`. Feel free to reach out to our [support line](support@imgix.com) if you have any questions or concerns.
234
+
233
235
  If you need to remove or update an image on imgix, you can purge it from our cache by initializing a client with your api_key, then calling Imgix::Client#purge with the resource path.
234
236
 
235
237
  ```ruby
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler/gem_tasks'
2
4
 
3
5
  require 'rake/testtask'
@@ -1,7 +1,6 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'imgix/version'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/imgix/version'
5
4
 
6
5
  Gem::Specification.new do |spec|
7
6
  spec.name = 'imgix'
@@ -44,8 +44,13 @@ module Imgix
44
44
  end
45
45
 
46
46
  def purge(path)
47
- token_error = 'Authentication token required'
48
- raise token_error if @api_key.nil?
47
+ api_key_deprecated = \
48
+ "Warning: Your `api_key` will no longer work after upgrading to\n" \
49
+ "imgix-rb version >= 4.0.0.\n"
50
+ warn api_key_deprecated
51
+
52
+ api_key_error = 'A valid api key is required to send purge requests'
53
+ raise api_key_error if @api_key.nil?
49
54
 
50
55
  url = new_prefix + path
51
56
  uri = URI.parse('https://api.imgix.com/v2/image/purger')
@@ -153,7 +153,7 @@ module Imgix
153
153
  srcset_widths = @target_widths
154
154
  end
155
155
 
156
- for width in srcset_widths do
156
+ srcset_widths.each do |width|
157
157
  params[:w] = width
158
158
  srcset += "#{to_url(params)} #{width}w,\n"
159
159
  end
@@ -170,7 +170,7 @@ module Imgix
170
170
  target_ratios = [1, 2, 3, 4, 5]
171
171
  quality = params[:q]
172
172
 
173
- for ratio in target_ratios do
173
+ target_ratios.each do |ratio|
174
174
  params[:dpr] = ratio
175
175
 
176
176
  unless disable_variable_quality
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Imgix
4
- VERSION = '3.3.1'
4
+ VERSION = '3.4.0'
5
5
  end
@@ -7,7 +7,6 @@ Bundler.require :test
7
7
  require 'minitest/autorun'
8
8
  require 'imgix'
9
9
  require 'webmock/minitest'
10
- include WebMock::API
11
10
 
12
11
  class Imgix::Test < MiniTest::Test
13
12
  end
@@ -1,25 +1,70 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class PurgeTest < Imgix::Test
4
6
  def test_runtime_error_without_api_key
5
- assert_raises(RuntimeError) {
6
- Imgix::Client.new(host: 'demo.imgix.net', include_library_param: false)
7
- .purge('https://demo.imgix.net/images/demo.png')
8
- }
7
+ assert_raises(RuntimeError) do
8
+ mock_client(api_key: nil).purge(mock_image)
9
+ end
10
+ end
11
+
12
+ def test_purger_version_warns
13
+ stub_request(:post, endpoint).with(body: body).to_return(status: 200)
14
+
15
+ assert_output(nil, deprecation_warning) do
16
+ mock_client(api_key: '10adc394').purge('/images/demo.png')
17
+ end
9
18
  end
10
-
19
+
11
20
  def test_successful_purge
12
- stub_request(:post, "https://api.imgix.com/v2/image/purger").
13
- with(
14
- body: {"url"=>"https://demo.imgix.net/images/demo.png"}).
15
- to_return(status: 200)
16
-
17
- Imgix::Client.new(host: 'demo.imgix.net', api_key: '10adc394')
18
- .purge('/images/demo.png')
19
-
20
- assert_requested :post, 'https://api.imgix.com/v2/image/purger',
21
- body: 'url=https%3A%2F%2Fdemo.imgix.net%2Fimages%2Fdemo.png',
22
- headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Basic MTBhZGMzOTQ6', 'Content-Type'=>'application/x-www-form-urlencoded', 'User-Agent'=>"imgix rb-#{ Imgix::VERSION}"},
21
+ stub_request(:post, endpoint).with(body: body).to_return(status: 200)
22
+
23
+ mock_client(api_key: '10adc394').purge('/images/demo.png')
24
+
25
+ assert_requested(
26
+ :post,
27
+ endpoint,
28
+ body: 'url=https%3A%2F%2Fdemo.imgix.net%2Fimages%2Fdemo.png',
29
+ headers: mock_headers,
23
30
  times: 1
31
+ )
32
+ end
33
+
34
+ private
35
+
36
+ def mock_client(api_key: '')
37
+ Imgix::Client.new(
38
+ domain: 'demo.imgix.net',
39
+ api_key: api_key,
40
+ include_library_param: false
41
+ )
42
+ end
43
+
44
+ def mock_headers
45
+ {
46
+ 'Accept' => '*/*',
47
+ 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
48
+ 'Authorization' => 'Basic MTBhZGMzOTQ6',
49
+ 'Content-Type' => 'application/x-www-form-urlencoded',
50
+ 'User-Agent' => "imgix rb-#{Imgix::VERSION}"
51
+ }
52
+ end
53
+
54
+ def mock_image
55
+ 'https://demo.imgix.net/images/demo.png'
56
+ end
57
+
58
+ def endpoint
59
+ 'https://api.imgix.com/v2/image/purger'
60
+ end
61
+
62
+ def body
63
+ { 'url' => mock_image }
64
+ end
65
+
66
+ def deprecation_warning
67
+ "Warning: Your `api_key` will no longer work after upgrading to\n" \
68
+ "imgix-rb version >= 4.0.0.\n"
24
69
  end
25
- end
70
+ 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: 3.3.1
4
+ version: 3.4.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: 2020-07-27 00:00:00.000000000 Z
16
+ date: 2020-08-12 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: addressable
@@ -87,8 +87,8 @@ licenses:
87
87
  metadata:
88
88
  bug_tracker_uri: https://github.com/imgix/imgix-rb/issues
89
89
  changelog_uri: https://github.com/imgix/imgix-rb/blob/main/CHANGELOG.md
90
- documentation_uri: https://www.rubydoc.info/gems/imgix/3.3.1
91
- source_code_uri: https://github.com/imgix/imgix-rb/tree/3.3.1
90
+ documentation_uri: https://www.rubydoc.info/gems/imgix/3.4.0
91
+ source_code_uri: https://github.com/imgix/imgix-rb/tree/3.4.0
92
92
  post_install_message:
93
93
  rdoc_options: []
94
94
  require_paths: