imgix 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f6d90cf96e4d279cd74ac1c314f817036597834c
4
+ data.tar.gz: a58e16f0256b02092964d89e2ccc094241ff76f0
5
+ SHA512:
6
+ metadata.gz: 1a9b59a69fddf83c0a3ed7ebc47470cbe1f33deb25422831973af740d1290852a1a583ecb76445da478040e9684e01af8d0a00620f895681e2987851c9b4a579
7
+ data.tar.gz: 5460ef4d06d0d786e8ea902a18c2c13f7c16c60344c16e01e605e39baec7f71d37cf726bc2fdc5ba36185ec5531eb5d0379b2eac0e9780a097b645c7f6ef3def
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in imgix.gemspec
4
+ gemspec
5
+
6
+ gem 'rake'
7
+ gem 'minitest'
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Sam Soffes
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,8 @@
1
+ require 'bundler/gem_tasks'
2
+
3
+ require 'rake/testtask'
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << 'test'
6
+ t.pattern = 'test/**/*_test.rb'
7
+ end
8
+ task default: :test
@@ -0,0 +1,33 @@
1
+ # Imgix
2
+
3
+ Ruby Gem for signing [imgix](http://imgix.com) URLs.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'imgix'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install imgix
18
+
19
+ ## Usage
20
+
21
+ ``` ruby
22
+ client = Imgix::Client.new(host: 'your-subdomain.imgix.net', token: 'your-token', secure: true)
23
+ client.sign_path('/images/demo.png?w=200')
24
+ #=> http://foo.imgix.net/images/demo.png?w=200&s=da421114ca238d1f4a927b889f67c34e
25
+ ```
26
+
27
+ ## Contributing
28
+
29
+ 1. Fork it
30
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
31
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
32
+ 4. Push to the branch (`git push origin my-new-feature`)
33
+ 5. Create new Pull Request
@@ -0,0 +1,23 @@
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'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'imgix'
8
+ spec.version = Imgix::VERSION
9
+ spec.authors = ['Sam Soffes']
10
+ spec.email = ['sam@soff.es']
11
+ spec.description = 'Easily sign imgix URLs.'
12
+ spec.summary = spec.description
13
+ spec.homepage = 'https://github.com/soffes/imgix'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.required_ruby_version = '>= 1.8.7'
22
+ spec.add_dependency 'addressable'
23
+ end
@@ -0,0 +1,5 @@
1
+ require 'imgix/version'
2
+ require 'imgix/client'
3
+
4
+ module Imgix
5
+ end
@@ -0,0 +1,19 @@
1
+ require 'digest'
2
+ require 'addressable/uri'
3
+
4
+ module Imgix
5
+ class Client
6
+ def initialize(options = {})
7
+ @host = options[:host]
8
+ @token = options[:token]
9
+ @secure = options[:secure]
10
+ end
11
+
12
+ def sign_path(path)
13
+ uri = Addressable::URI.parse(path)
14
+ query = (uri.query || '')
15
+ signature = Digest::MD5.hexdigest(@token + uri.path + '?' + query)
16
+ "#{@secure ? 'https' : 'http'}://#{@host}#{uri.path}?#{query}#{query.length > 0 ? '&' : ''}s=#{signature}"
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,3 @@
1
+ module Imgix
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,9 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ Bundler.require :test
4
+
5
+ require 'minitest/autorun'
6
+ require 'imgix'
7
+
8
+ class Imgix::Test < MiniTest::Test
9
+ end
@@ -0,0 +1,27 @@
1
+ require 'test_helper'
2
+
3
+ class UrlTest < Imgix::Test
4
+ def test_signing_with_no_params
5
+ path = '/images/demo.png'
6
+ assert_equal 'http://demo.imgix.net/images/demo.png?s=3c1d676d4daf28c044dd83e8548f834a', client.sign_path(path)
7
+ end
8
+
9
+ def test_signing_with_one
10
+ path = '/images/demo.png?w=200'
11
+ assert_equal 'http://demo.imgix.net/images/demo.png?w=200&s=da421114ca238d1f4a927b889f67c34e', client.sign_path(path)
12
+ end
13
+
14
+ def test_signing_with_multiple_params
15
+ path = '/images/demo.png?h=200&w=200'
16
+ assert_equal 'http://demo.imgix.net/images/demo.png?h=200&w=200&s=d570a1ecd765470f7b34a69b56718a7a', client.sign_path(path)
17
+
18
+ path = '/images/demo.png?w=200&h=200'
19
+ assert_equal 'http://demo.imgix.net/images/demo.png?w=200&h=200&s=00b5cde5c7b8bca8618cb911da4ac379', client.sign_path(path)
20
+ end
21
+
22
+ private
23
+
24
+ def client
25
+ @client ||= Imgix::Client.new(:host => 'demo.imgix.net', :token => '10adc394')
26
+ end
27
+ end
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: imgix
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Sam Soffes
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-06-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: addressable
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: Easily sign imgix URLs.
28
+ email:
29
+ - sam@soff.es
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - .gitignore
35
+ - Gemfile
36
+ - LICENSE
37
+ - Rakefile
38
+ - Readme.markdown
39
+ - imgix.gemspec
40
+ - lib/imgix.rb
41
+ - lib/imgix/client.rb
42
+ - lib/imgix/version.rb
43
+ - test/test_helper.rb
44
+ - test/units/url_test.rb
45
+ homepage: https://github.com/soffes/imgix
46
+ licenses:
47
+ - MIT
48
+ metadata: {}
49
+ post_install_message:
50
+ rdoc_options: []
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - '>='
56
+ - !ruby/object:Gem::Version
57
+ version: 1.8.7
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ requirements: []
64
+ rubyforge_project:
65
+ rubygems_version: 2.0.2
66
+ signing_key:
67
+ specification_version: 4
68
+ summary: Easily sign imgix URLs.
69
+ test_files:
70
+ - test/test_helper.rb
71
+ - test/units/url_test.rb