yourls 0.1.0 → 0.1.1

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,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.
@@ -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).
@@ -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 ||= {}
@@ -1,6 +1,6 @@
1
1
  module Yourls
2
- def self.new(host, api_key)
3
- Yourls::Client.new(host, api_key)
2
+ def self.new(host, api_key, options = {})
3
+ Yourls::Client.new(host, api_key, options)
4
4
  end
5
5
  end
6
6
 
@@ -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.4"])
20
- s.add_runtime_dependency(%q<httparty>, [">= 0.5.2"])
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.4"])
23
- s.add_dependency(%q<httparty>, [">= 0.5.2"])
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.4"])
27
- s.add_dependency(%q<httparty>, [">= 0.5.2"])
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: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
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-19 00:00:00 -04:00
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: 19
29
+ hash: 11
30
30
  segments:
31
31
  - 0
32
32
  - 1
33
- - 4
34
- version: 0.1.4
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: 15
45
+ hash: 5
46
46
  segments:
47
47
  - 0
48
- - 5
49
- - 2
50
- version: 0.5.2
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