yourls 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +19 -0
- data/README.markdown +31 -0
- data/lib/yourls/client.rb +3 -2
- data/lib/yourls/yourls.rb +2 -2
- data/yourls.gemspec +7 -7
- metadata +13 -12
- data/README +0 -1
data/MIT-LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2010 Three Stage Media, Inc.
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README.markdown
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Yourls
|
2
|
+
|
3
|
+
[YOURLS](http://yourls.org) is an open-source, PHP url-shortening service.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
gem install yourls
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
Create a Yourls client using your hostname and api key as follows:
|
12
|
+
|
13
|
+
yourls = Yourls.new(your_hosted_yourls_address, your_hosted_yourls_api_key)
|
14
|
+
|
15
|
+
You can then interact with the client to shorten or expand urls or to get statistics about your service:
|
16
|
+
|
17
|
+
yourls.shorten('http://www.google.com')
|
18
|
+
yourls.shorten('http://www.google.com', :keyword => 'goog') # Creates a custom keyword url
|
19
|
+
yourls.expand('goog')
|
20
|
+
yourls.stats
|
21
|
+
|
22
|
+
`expand` and `shorten` both will return a `Yourls::Url` object
|
23
|
+
|
24
|
+
url = yourls.shorten('http://www.google.com', :keyword => 'goog')
|
25
|
+
url.short_url #=> "http://your-service/goog"
|
26
|
+
url.long_url #=> "http://www.google.com"
|
27
|
+
url.keyword #=> "goog"
|
28
|
+
|
29
|
+
## Copyright
|
30
|
+
|
31
|
+
Copyright (c) 2010 [Three Stage Media, Inc.](http://www.threestage.com) and licensed under the MIT License (see MIT-LICENSE for details).
|
data/lib/yourls/client.rb
CHANGED
@@ -4,9 +4,10 @@ module Yourls
|
|
4
4
|
class Client
|
5
5
|
include HTTParty
|
6
6
|
|
7
|
-
def initialize(host, api_key)
|
7
|
+
def initialize(host, api_key, options = {})
|
8
8
|
@host, @api_key = host, api_key
|
9
9
|
@base_uri = File.join(host, 'yourls-api.php')
|
10
|
+
@server_offset = options[:offset] || 0.seconds
|
10
11
|
end
|
11
12
|
|
12
13
|
def stats(options = {})
|
@@ -24,7 +25,7 @@ module Yourls
|
|
24
25
|
|
25
26
|
def get(action, query = {})
|
26
27
|
# Prepare the signature
|
27
|
-
timestamp = Time.now.to_i
|
28
|
+
timestamp = (Time.now + @server_offset).to_i
|
28
29
|
signature = Digest::MD5.hexdigest(timestamp.to_s + @api_key)
|
29
30
|
|
30
31
|
query ||= {}
|
data/lib/yourls/yourls.rb
CHANGED
data/yourls.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.summary = 'Use the Yourls API to shorten or expand URLs'
|
9
9
|
s.description = 'Use the Yourls API to shorten or expand URLs'
|
10
10
|
|
11
|
-
s.files = ["yourls.gemspec", "lib/yourls.rb", "lib/yourls/yourls.rb", "lib/yourls/client.rb", "lib/yourls/url.rb", "README"]
|
11
|
+
s.files = ["yourls.gemspec", "lib/yourls.rb", "lib/yourls/yourls.rb", "lib/yourls/client.rb", "lib/yourls/url.rb", "README.markdown", "MIT-LICENSE"]
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
|
14
14
|
if s.respond_to? :specification_version then
|
@@ -16,14 +16,14 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.specification_version = 3
|
17
17
|
|
18
18
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
19
|
-
s.add_runtime_dependency(%q<crack>, [">= 0.1.
|
20
|
-
s.add_runtime_dependency(%q<httparty>, [">= 0.
|
19
|
+
s.add_runtime_dependency(%q<crack>, [">= 0.1.8"])
|
20
|
+
s.add_runtime_dependency(%q<httparty>, [">= 0.6.1"])
|
21
21
|
else
|
22
|
-
s.add_dependency(%q<crack>, [">= 0.1.
|
23
|
-
s.add_dependency(%q<httparty>, [">= 0.
|
22
|
+
s.add_dependency(%q<crack>, [">= 0.1.8"])
|
23
|
+
s.add_dependency(%q<httparty>, [">= 0.6.1"])
|
24
24
|
end
|
25
25
|
else
|
26
|
-
s.add_dependency(%q<crack>, [">= 0.1.
|
27
|
-
s.add_dependency(%q<httparty>, [">= 0.
|
26
|
+
s.add_dependency(%q<crack>, [">= 0.1.8"])
|
27
|
+
s.add_dependency(%q<httparty>, [">= 0.6.1"])
|
28
28
|
end
|
29
29
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yourls
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Justin Rhinesmith
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-10-
|
18
|
+
date: 2010-10-26 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -26,12 +26,12 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
hash:
|
29
|
+
hash: 11
|
30
30
|
segments:
|
31
31
|
- 0
|
32
32
|
- 1
|
33
|
-
-
|
34
|
-
version: 0.1.
|
33
|
+
- 8
|
34
|
+
version: 0.1.8
|
35
35
|
type: :runtime
|
36
36
|
version_requirements: *id001
|
37
37
|
- !ruby/object:Gem::Dependency
|
@@ -42,12 +42,12 @@ dependencies:
|
|
42
42
|
requirements:
|
43
43
|
- - ">="
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
hash:
|
45
|
+
hash: 5
|
46
46
|
segments:
|
47
47
|
- 0
|
48
|
-
-
|
49
|
-
-
|
50
|
-
version: 0.
|
48
|
+
- 6
|
49
|
+
- 1
|
50
|
+
version: 0.6.1
|
51
51
|
type: :runtime
|
52
52
|
version_requirements: *id002
|
53
53
|
description: Use the Yourls API to shorten or expand URLs
|
@@ -64,7 +64,8 @@ files:
|
|
64
64
|
- lib/yourls/yourls.rb
|
65
65
|
- lib/yourls/client.rb
|
66
66
|
- lib/yourls/url.rb
|
67
|
-
- README
|
67
|
+
- README.markdown
|
68
|
+
- MIT-LICENSE
|
68
69
|
has_rdoc: true
|
69
70
|
homepage:
|
70
71
|
licenses: []
|
data/README
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
Shorten URLs with a custom Yourls installation
|