url_tokenizer-provider-limelight 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/.rspec +2 -0
- data/.travis.yml +18 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +101 -0
- data/Rakefile +11 -0
- data/VERSION +1 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/url_tokenizer/provider/limelight.rb +73 -0
- data/url_tokenizer-provider-limelight.gemspec +25 -0
- metadata +112 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6414cc16864615f8aa80d7a049aa3f22e5f6a04a
|
4
|
+
data.tar.gz: 95ffb3e7ff448102652e7155efc27ff32ec17577
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a7a7015f89d05076573b01f78d5c4a3644205d7f606dd4f2d6602f6ac3c44093432e34ad3641135284f8c9c2ef30423fb865577a764d4fdf52f2f567b2809e5f
|
7
|
+
data.tar.gz: d04007e34516254cc142c9e85ef8e05c7116f106136295c391437227d4316761a732c95ef10c8d03291bde0529bc0bb3b4b7aa52f7d489dc97601f4ecff05d3d
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Alexander Paramonov
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
UrlTokenizer: Limelight provider
|
2
|
+
================================
|
3
|
+
[![Build Status](https://travis-ci.org/AlexParamonov/url_tokenizer-provider-limelight.png?branch=master)](https://travis-ci.org/AlexParamonov/url_tokenizer-provider-limelight)
|
4
|
+
[![Gemnasium Build Status](https://gemnasium.com/AlexParamonov/url_tokenizer-provider-limelight.png)](http://gemnasium.com/AlexParamonov/url_tokenizer-provider-limelight)
|
5
|
+
[![Coverage Status](https://coveralls.io/repos/AlexParamonov/url_tokenizer-provider-limelight/badge.png?branch=master)](https://coveralls.io/r/AlexParamonov/url_tokenizer-provider-limelight?branch=master)
|
6
|
+
[![Gem Version](https://badge.fury.io/rb/url_tokenizer-provider-limelight.png)](http://badge.fury.io/rb/url_tokenizer-provider-limelight)
|
7
|
+
[![Code Climate](https://codeclimate.com/github/AlexParamonov/url_tokenizer-provider-limelight.png)](https://codeclimate.com/github/AlexParamonov/url_tokenizer-provider-limelight)
|
8
|
+
|
9
|
+
Limelight provider for [UrlTokenizer gem](https://github.com/AlexParamonov/url_tokenizer).
|
10
|
+
|
11
|
+
Contents
|
12
|
+
---------
|
13
|
+
1. Installation
|
14
|
+
1. Requirements
|
15
|
+
1. Contacts
|
16
|
+
1. Compatibility
|
17
|
+
1. Contributing
|
18
|
+
1. Copyright
|
19
|
+
|
20
|
+
Installation
|
21
|
+
------------
|
22
|
+
|
23
|
+
Add this line to your application's Gemfile:
|
24
|
+
|
25
|
+
gem 'url_tokenizer-provider-limelight'
|
26
|
+
|
27
|
+
And then execute:
|
28
|
+
|
29
|
+
$ bundle
|
30
|
+
|
31
|
+
Or install it yourself as:
|
32
|
+
|
33
|
+
$ gem install url_tokenizer-provider-limelight
|
34
|
+
|
35
|
+
Most likely you'll install UrlTokenizer gem as well:
|
36
|
+
|
37
|
+
$ gem install url_tokenizer
|
38
|
+
|
39
|
+
Requirements
|
40
|
+
------------
|
41
|
+
1. Ruby >= 1.9
|
42
|
+
1. UrlTokenizer gem
|
43
|
+
|
44
|
+
Usage
|
45
|
+
------------
|
46
|
+
|
47
|
+
Gem is designed to be used with UrlTokenizer gem.
|
48
|
+
Register provider using `UrlTokenizer.register`
|
49
|
+
|
50
|
+
``` ruby
|
51
|
+
UrlTokenizer.register 'LL' => UrlTokenizer::Provider::Limelight
|
52
|
+
```
|
53
|
+
|
54
|
+
Obtain provider and tokenize url:
|
55
|
+
|
56
|
+
``` ruby
|
57
|
+
tokenizer = UrlTokenizer.provider('LL', key: 'super_secret_key')
|
58
|
+
tokenizer.call url, expire_in: 1.hour
|
59
|
+
```
|
60
|
+
|
61
|
+
Or user provider directly:
|
62
|
+
|
63
|
+
``` ruby
|
64
|
+
UrlTokenizer::Provider::Limelight.new('super_secret_key').call url, expire_in: 1.hour
|
65
|
+
```
|
66
|
+
|
67
|
+
Contacts
|
68
|
+
-------------
|
69
|
+
Have questions or recommendations? Contact me via `alexander.n.paramonov@gmail.com`
|
70
|
+
|
71
|
+
Found a bug or have enhancement request? You are welcome at [Github bugtracker](https://github.com/AlexParamonov/url_tokenizer-provider-limelight/issues)
|
72
|
+
|
73
|
+
|
74
|
+
Compatibility
|
75
|
+
-------------
|
76
|
+
tested with Ruby:
|
77
|
+
|
78
|
+
* 2.2
|
79
|
+
* 2.1
|
80
|
+
* 2.0
|
81
|
+
* 1.9.3
|
82
|
+
* ruby-head
|
83
|
+
* rbx-2
|
84
|
+
* jruby-19mode
|
85
|
+
* jruby-head
|
86
|
+
|
87
|
+
See [build history](http://travis-ci.org/#!/AlexParamonov/url_tokenizer-provider-limelight/builds)
|
88
|
+
|
89
|
+
|
90
|
+
## Contributing
|
91
|
+
|
92
|
+
1. Fork repository ( http://github.com/AlexParamonov/url_tokenizer-provider-limelight/fork )
|
93
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
94
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
95
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
96
|
+
5. Create new Pull Request
|
97
|
+
|
98
|
+
Copyright
|
99
|
+
---------
|
100
|
+
Copyright © 2015 Alexander Paramonov.
|
101
|
+
Released under the MIT License. See the LICENSE file for further details.
|
data/Rakefile
ADDED
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "url_tokenizer/provider/limelight"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require 'cgi'
|
3
|
+
require 'digest'
|
4
|
+
|
5
|
+
module UrlTokenizer
|
6
|
+
module Provider
|
7
|
+
class Limelight
|
8
|
+
def initialize(key)
|
9
|
+
@key = key
|
10
|
+
end
|
11
|
+
|
12
|
+
def call(input_url, **options)
|
13
|
+
uri = URI.parse input_url
|
14
|
+
folder = File.dirname input_url
|
15
|
+
|
16
|
+
provider_options = build_options options, url: folder, uri: uri
|
17
|
+
|
18
|
+
query_string = URI.encode_www_form provider_options
|
19
|
+
url_to_encode = [folder, query_string].join '?'
|
20
|
+
|
21
|
+
provider_options[:h] = digest url_to_encode
|
22
|
+
|
23
|
+
uri.query = URI.encode_www_form provider_options
|
24
|
+
uri.to_s
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
attr_reader :key
|
29
|
+
|
30
|
+
|
31
|
+
def build_options(token_options, url:, uri:)
|
32
|
+
{
|
33
|
+
**url_params(uri),
|
34
|
+
p: url.length,
|
35
|
+
e: expiration_date(token_options)
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
def url_params(uri)
|
40
|
+
return {} if uri.query.nil?
|
41
|
+
|
42
|
+
symbolize_keys(CGI.parse(uri.query)).tap do |params|
|
43
|
+
params.delete :h
|
44
|
+
params.delete :e
|
45
|
+
params.delete :p
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def expiration_date(options)
|
50
|
+
Time.now.utc.to_i + options[:expire_in].to_i
|
51
|
+
end
|
52
|
+
|
53
|
+
def digest(url)
|
54
|
+
Digest::MD5.hexdigest "#{ key }#{ url }"
|
55
|
+
end
|
56
|
+
|
57
|
+
def symbolize_keys(hash)
|
58
|
+
hash.inject({}){|result, (key, value)|
|
59
|
+
new_key = case key
|
60
|
+
when String then key.to_sym
|
61
|
+
else key
|
62
|
+
end
|
63
|
+
new_value = case value
|
64
|
+
when Hash then symbolize_keys(value)
|
65
|
+
else value
|
66
|
+
end
|
67
|
+
result[new_key] = new_value
|
68
|
+
result
|
69
|
+
}
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "url_tokenizer-provider-limelight"
|
7
|
+
spec.version = IO.read("VERSION")
|
8
|
+
spec.authors = ["Alexander Paramonov"]
|
9
|
+
spec.email = ["alexander.n.paramonov@gmail.com"]
|
10
|
+
spec.summary = %q{Limelight token provider for url_tokenizer gem.}
|
11
|
+
spec.description = %q{Limelight token provider for url_tokenizer gem.}
|
12
|
+
spec.homepage = "http://github.com/AlexParamonov/url_tokenizer-provider-limelight"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
16
|
+
spec.bindir = "exe"
|
17
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
|
21
|
+
spec.add_dependency 'url_tokenizer', '~> 0.1'
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.0"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: url_tokenizer-provider-limelight
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alexander Paramonov
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-07-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: url_tokenizer
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
description: Limelight token provider for url_tokenizer gem.
|
70
|
+
email:
|
71
|
+
- alexander.n.paramonov@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rspec"
|
78
|
+
- ".travis.yml"
|
79
|
+
- Gemfile
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- VERSION
|
84
|
+
- bin/console
|
85
|
+
- bin/setup
|
86
|
+
- lib/url_tokenizer/provider/limelight.rb
|
87
|
+
- url_tokenizer-provider-limelight.gemspec
|
88
|
+
homepage: http://github.com/AlexParamonov/url_tokenizer-provider-limelight
|
89
|
+
licenses:
|
90
|
+
- MIT
|
91
|
+
metadata: {}
|
92
|
+
post_install_message:
|
93
|
+
rdoc_options: []
|
94
|
+
require_paths:
|
95
|
+
- lib
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
requirements: []
|
107
|
+
rubyforge_project:
|
108
|
+
rubygems_version: 2.4.6
|
109
|
+
signing_key:
|
110
|
+
specification_version: 4
|
111
|
+
summary: Limelight token provider for url_tokenizer gem.
|
112
|
+
test_files: []
|