imgix 0.3.3 → 0.3.4

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
  SHA1:
3
- metadata.gz: 588ae10e0524aac623bad42329e59ab645891c9d
4
- data.tar.gz: 836a1ed328300c1d74ae6919d720acfef0aa373f
3
+ metadata.gz: 54d696fed267d139643d66d0feec9639b5c71b10
4
+ data.tar.gz: 909c82a553d42a2b257ca3b80a08e2109868dc9a
5
5
  SHA512:
6
- metadata.gz: 20e0097bd2e1671598a26c3b70c85aac692ce4edef1615a33e888154d8011b394aac06d39e750abe4ffc58f9c818543dc10213a01e0334a623d0abf9ccead82a
7
- data.tar.gz: 3aab4814449a24f6b2aeca5ac07158dbccd286114563e11a1a52b4f139e477fd2ab14382c509485412da99641125cbe7510427e5954f34dd3ad3f22280bbdd73
6
+ metadata.gz: d17c57373d186ca4309b4f446c107ed3f3bf773d97901999f6fe21d6540affea4f6a19e572f3625a998df3efd6999a602cc1300bedfbe7991706f903eae798cd
7
+ data.tar.gz: b7505c7519afd3b3ee52bf55c27bba6d8f19f58a70f654d0a19895547aeac35b0365dca686ab5d39f687025f082347b357276c6f2124ccb7a0995d3959256459
@@ -1,6 +1,6 @@
1
1
  # Imgix
2
2
 
3
- Unofficial Ruby Gem for signing [imgix](http://imgix.com) URLs. Tested under 1.9.2, 2.2.1, JRuby 1.7.19, and Rubinius 2.2.7.
3
+ Official Ruby Gem for signing [imgix](http://imgix.com) URLs. Tested under 1.9.2, 2.2.2, JRuby 1.7.19, and Rubinius 2.2.7.
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
 
@@ -82,11 +82,19 @@ For example to use the [noise reduction](http://www.imgix.com/docs/urlapi/enhanc
82
82
  path.noise_reduction(50,50)
83
83
  ```
84
84
 
85
-
86
85
  ## URL encoding and signed ImgIX URLs
87
86
 
88
87
  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.
89
88
 
89
+ ## What is the `ixlib` param on every request?
90
+
91
+ For security and diagnostic purposes, we sign all requests with the language and version of library used to generate the URL.
92
+
93
+ This can be disabled by including `:`include_library_param: false` in the instantiation Hash parameter for `Imgix::Client`:
94
+
95
+ ```ruby
96
+ client = Imgix::Client.new({ include_library_param: false })
97
+ ```
90
98
 
91
99
  ## Contributing
92
100
 
@@ -13,10 +13,13 @@ module Imgix
13
13
  @token = options[:token]
14
14
  @secure = options[:secure]
15
15
  @shard_strategy = options[:shard_strategy] and validate_strategy!
16
+ @include_library_param = options.fetch(:include_library_param, true)
16
17
  end
17
18
 
18
19
  def path(path)
19
- Path.new(prefix(path), @token, path)
20
+ p = Path.new(prefix(path), @token, path)
21
+ p.ixlib("rb-#{Imgix::VERSION}") if @include_library_param
22
+ p
20
23
  end
21
24
 
22
25
  def prefix(path)
@@ -1,3 +1,3 @@
1
1
  module Imgix
2
- VERSION = '0.3.3'
2
+ VERSION = '0.3.4'
3
3
  end
@@ -8,7 +8,8 @@ class DomainsTest < Imgix::Test
8
8
  "demos-2.imgix.net",
9
9
  "demos-3.imgix.net",
10
10
  ],
11
- :token => '10adc394')
11
+ :token => '10adc394',
12
+ :include_library_param => false)
12
13
 
13
14
  path = client.path('/bridge.png')
14
15
  assert_equal 'http://demos-1.imgix.net/bridge.png?&s=13e68f249172e5f790344e85e7cdb14b', path.to_url
@@ -24,7 +25,8 @@ class DomainsTest < Imgix::Test
24
25
  "demos-3.imgix.net",
25
26
  ],
26
27
  :token => '10adc394',
27
- :shard_strategy => :cycle)
28
+ :shard_strategy => :cycle,
29
+ :include_library_param => false)
28
30
 
29
31
  path = client.path('/bridge.png')
30
32
  assert_equal 'http://demos-1.imgix.net/bridge.png?&s=13e68f249172e5f790344e85e7cdb14b', path.to_url
@@ -42,7 +44,8 @@ class DomainsTest < Imgix::Test
42
44
  def test_strips_out_protocol
43
45
  client = Imgix::Client.new(:host =>
44
46
  "http://demos-1.imgix.net",
45
- :token => '10adc394')
47
+ :token => '10adc394',
48
+ :include_library_param => false)
46
49
 
47
50
  path = client.path('/bridge.png')
48
51
  assert_equal 'http://demos-1.imgix.net/bridge.png?&s=13e68f249172e5f790344e85e7cdb14b', path.to_url
@@ -55,7 +58,8 @@ class DomainsTest < Imgix::Test
55
58
  "demos-3.imgix.net",
56
59
  ],
57
60
  :token => '10adc394',
58
- :shard_strategy => :cycle)
61
+ :shard_strategy => :cycle,
62
+ :include_library_param => false)
59
63
 
60
64
  path = 'https://google.com/cats.gif'
61
65
  assert_equal "http://demos-1.imgix.net/#{CGI.escape(path)}?&s=4c3ff935011f0d2251800e6a2bb68ee5", client.path(path).to_url
@@ -53,7 +53,7 @@ class PathTest < Imgix::Test
53
53
  end
54
54
 
55
55
  def test_token_is_optional
56
- client = Imgix::Client.new(host: 'demo.imgix.net')
56
+ client = Imgix::Client.new(host: 'demo.imgix.net', :include_library_param => false)
57
57
  url = 'http://demo.imgix.net/images/demo.png?'
58
58
  path = client.path('/images/demo.png')
59
59
 
@@ -71,9 +71,16 @@ class PathTest < Imgix::Test
71
71
  assert_equal "http://demo.imgix.net/#{CGI.escape(path)}?&s=8943817bed50811f6ceedd8f4b84169d", client.path(path).to_url
72
72
  end
73
73
 
74
+ def test_include_library_param
75
+ client = Imgix::Client.new(host: 'demo.imgix.net') # enabled by default
76
+ url = client.path('/images/demo.png').to_url
77
+
78
+ assert_equal "ixlib=rb-#{Imgix::VERSION}", URI(url).query
79
+ end
80
+
74
81
  private
75
82
 
76
83
  def client
77
- @client ||= Imgix::Client.new(:host => 'demo.imgix.net', :token => '10adc394')
84
+ @client ||= Imgix::Client.new(:host => 'demo.imgix.net', :token => '10adc394', :include_library_param => false)
78
85
  end
79
86
  end
@@ -22,6 +22,6 @@ class UrlTest < Imgix::Test
22
22
  private
23
23
 
24
24
  def client
25
- @client ||= Imgix::Client.new(:host => 'demo.imgix.net', :token => '10adc394')
25
+ @client ||= Imgix::Client.new(:host => 'demo.imgix.net', :token => '10adc394', :include_library_param => false)
26
26
  end
27
27
  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: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Soffes
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-05-14 00:00:00.000000000 Z
13
+ date: 2015-06-04 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: addressable
@@ -41,8 +41,8 @@ files:
41
41
  - Contributing.markdown
42
42
  - Gemfile
43
43
  - LICENSE
44
+ - README.md
44
45
  - Rakefile
45
- - Readme.markdown
46
46
  - imgix.gemspec
47
47
  - lib/imgix.rb
48
48
  - lib/imgix/client.rb
@@ -73,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
73
  version: '0'
74
74
  requirements: []
75
75
  rubyforge_project:
76
- rubygems_version: 2.4.6
76
+ rubygems_version: 2.4.7
77
77
  signing_key:
78
78
  specification_version: 4
79
79
  summary: Unofficial Ruby Gem for easily signing imgix URLs.