imgix 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/CHANGELOG.md +4 -0
- data/Gemfile +2 -0
- data/README.md +13 -1
- data/imgix.gemspec +2 -0
- data/lib/imgix/client.rb +16 -0
- data/lib/imgix/version.rb +1 -1
- data/test/test_helper.rb +2 -0
- data/test/units/purge_test.rb +25 -0
- metadata +33 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f2350801ae6efed0843066ea4e479508d23d7da
|
4
|
+
data.tar.gz: 00df9bd86854aef93cf18f0004d204f9034f30cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd1bdd5bcee45f9b6fff784aa8603fd9c3781f9cdb94c4382f009fc0ecfc2686021b6e5b92fddc23db4eac47f8d4b131760a4300fa95be1c20bb32b396579329
|
7
|
+
data.tar.gz: bda8d65d92c3803a95e36e129b9f64581c0be82064f6d26f4cbd437cab667c402713192d9f335bc687c4a2ba972e6edfb23226d07813940e877f0723f88aecea
|
data/.travis.yml
CHANGED
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
|
+
## [1.2.0] - October 29, 2018
|
7
|
+
|
8
|
+
* Added `Client#purge` method to allow purging assets from our cache [#37](https://github.com/imgix/imgix-rb/pull/37)
|
9
|
+
|
6
10
|
## [1.1.0] - February 24, 2016
|
7
11
|
|
8
12
|
* Added automatic Base64 encoding for all Base64 variant parameters.
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Imgix
|
2
2
|
|
3
|
-
Official Ruby Gem for signing [imgix](http://imgix.com) URLs. Tested under
|
3
|
+
Official Ruby Gem for signing [imgix](http://imgix.com) URLs. Tested under 2.3.0, 2.2.4, 2.1.8, jruby-9.0.5.0, and rbx-2.11.
|
4
4
|
|
5
5
|
[![Build Status](https://travis-ci.org/imgix/imgix-rb.png?branch=master)](https://travis-ci.org/imgix/imgix-rb)
|
6
6
|
|
@@ -78,6 +78,18 @@ For example to use the noise reduction:
|
|
78
78
|
path.noise_reduction(50,50)
|
79
79
|
```
|
80
80
|
|
81
|
+
|
82
|
+
## Purge Cache
|
83
|
+
|
84
|
+
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.
|
85
|
+
|
86
|
+
```ruby
|
87
|
+
client = Imgix::Client.new(host: 'your-subdomain.imgix.net', api_key: 'your-key')
|
88
|
+
client.purge('/images/demo.png')
|
89
|
+
```
|
90
|
+
|
91
|
+
To learn more about purging assets with imgix, [see our docs](https://docs.imgix.com/setup/purging-images).
|
92
|
+
|
81
93
|
## URL encoding and signed ImgIX URLs
|
82
94
|
|
83
95
|
Some important third parties (like Facebook) apply URL escaping to query string components, which can cause correctly signed ImgIX URLs to to be transformed into incorrectly signed ones. We URL encode the query part of the URL before signing, so you don't have to worry about this.
|
data/imgix.gemspec
CHANGED
data/lib/imgix/client.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
require 'digest'
|
2
2
|
require 'addressable/uri'
|
3
3
|
require 'zlib'
|
4
|
+
require 'net/http'
|
5
|
+
require 'uri'
|
4
6
|
|
5
7
|
module Imgix
|
6
8
|
class Client
|
@@ -11,6 +13,7 @@ module Imgix
|
|
11
13
|
|
12
14
|
@hosts = Array(options[:host]) + Array(options[:hosts]) and validate_hosts!
|
13
15
|
@secure_url_token = options[:secure_url_token]
|
16
|
+
@api_key = options[:api_key]
|
14
17
|
@use_https = options[:use_https]
|
15
18
|
@shard_strategy = options[:shard_strategy] and validate_strategy!
|
16
19
|
@include_library_param = options.fetch(:include_library_param, true)
|
@@ -24,6 +27,19 @@ module Imgix
|
|
24
27
|
p
|
25
28
|
end
|
26
29
|
|
30
|
+
def purge(path)
|
31
|
+
raise "Authentication token required" unless !!(@api_key)
|
32
|
+
url = prefix(path)+path
|
33
|
+
uri = URI.parse('https://api.imgix.com/v2/image/purger')
|
34
|
+
req = Net::HTTP::Post.new(uri.path, {"User-Agent" => "imgix #{@library}-#{@version}"})
|
35
|
+
req.basic_auth @api_key, ''
|
36
|
+
req.set_form_data({'url' => url})
|
37
|
+
sock = Net::HTTP.new(uri.host, uri.port)
|
38
|
+
sock.use_ssl = true
|
39
|
+
res = sock.start {|http| http.request(req) }
|
40
|
+
res
|
41
|
+
end
|
42
|
+
|
27
43
|
def prefix(path)
|
28
44
|
"#{@use_https ? 'https' : 'http'}://#{get_host(path)}"
|
29
45
|
end
|
data/lib/imgix/version.rb
CHANGED
data/test/test_helper.rb
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class PurgeTest < Imgix::Test
|
4
|
+
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
|
+
}
|
9
|
+
end
|
10
|
+
|
11
|
+
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}"},
|
23
|
+
times: 1
|
24
|
+
end
|
25
|
+
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: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kelly Sutton
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date:
|
15
|
+
date: 2018-10-29 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: addressable
|
@@ -28,6 +28,34 @@ dependencies:
|
|
28
28
|
- - ">="
|
29
29
|
- !ruby/object:Gem::Version
|
30
30
|
version: '0'
|
31
|
+
- !ruby/object:Gem::Dependency
|
32
|
+
name: http
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
45
|
+
- !ruby/object:Gem::Dependency
|
46
|
+
name: webmock
|
47
|
+
requirement: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0'
|
52
|
+
type: :development
|
53
|
+
prerelease: false
|
54
|
+
version_requirements: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '0'
|
31
59
|
description: Easily create and sign imgix URLs.
|
32
60
|
email:
|
33
61
|
- kelly@imgix.com
|
@@ -56,6 +84,7 @@ files:
|
|
56
84
|
- test/test_helper.rb
|
57
85
|
- test/units/domains_test.rb
|
58
86
|
- test/units/path_test.rb
|
87
|
+
- test/units/purge_test.rb
|
59
88
|
- test/units/url_test.rb
|
60
89
|
homepage: https://github.com/imgix/imgix-rb
|
61
90
|
licenses:
|
@@ -77,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
106
|
version: '0'
|
78
107
|
requirements: []
|
79
108
|
rubyforge_project:
|
80
|
-
rubygems_version: 2.
|
109
|
+
rubygems_version: 2.5.2.3
|
81
110
|
signing_key:
|
82
111
|
specification_version: 4
|
83
112
|
summary: Official Ruby Gem for easily creating and signing imgix URLs.
|
@@ -85,4 +114,5 @@ test_files:
|
|
85
114
|
- test/test_helper.rb
|
86
115
|
- test/units/domains_test.rb
|
87
116
|
- test/units/path_test.rb
|
117
|
+
- test/units/purge_test.rb
|
88
118
|
- test/units/url_test.rb
|