tinyurl 1.0.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,5 @@
1
+ == 1.0.0 / 2007-09-06
2
+
3
+ * 1 major enhancement
4
+ * Birthday!
5
+
@@ -0,0 +1,7 @@
1
+ History.txt
2
+ Manifest.txt
3
+ README.txt
4
+ Rakefile
5
+ bin/tinyurl
6
+ lib/tinyurl.rb
7
+ test/test_tinyurl.rb
@@ -0,0 +1,52 @@
1
+ tinyurl
2
+ by Logan Koester
3
+ http://logankoester.com/tinyurl
4
+
5
+ == DESCRIPTION:
6
+
7
+ Tools for working with TinyURLs (see http://tinyurl.com)
8
+
9
+ == FEATURES/PROBLEMS:
10
+
11
+ * Create new TinyURLs ( Tinyurl::tinyurlize( "http://myverylongurl.com" ) )
12
+ * Resolve existing TinyURLs to their real address ( Tinyurl::resolve( "http://tinyurl.com/foo" ) )
13
+ * Command-line utility 'tinyurl'
14
+
15
+ == SYNOPSIS:
16
+
17
+ # Like this...
18
+ t = Tinyurl.new( "http://example.com" )
19
+ p t.original => "http://example.com"
20
+ p t.tiny => "http://tinyurl.com/yvdle"
21
+
22
+ # ...or like this
23
+ p Tinyurl::resolve( http://tinyurl.com/yvdle ) => "http://example.com"
24
+
25
+ == INSTALL:
26
+
27
+ * sudo gem install tinyurl
28
+
29
+ == LICENSE:
30
+
31
+ (The MIT License)
32
+
33
+ Copyright (c) 2007 FIX
34
+
35
+ Permission is hereby granted, free of charge, to any person obtaining
36
+ a copy of this software and associated documentation files (the
37
+ 'Software'), to deal in the Software without restriction, including
38
+ without limitation the rights to use, copy, modify, merge, publish,
39
+ distribute, sublicense, and/or sell copies of the Software, and to
40
+ permit persons to whom the Software is furnished to do so, subject to
41
+ the following conditions:
42
+
43
+ The above copyright notice and this permission notice shall be
44
+ included in all copies or substantial portions of the Software.
45
+
46
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
47
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
48
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
49
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
50
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
51
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
52
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,18 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'rubygems'
4
+ require 'hoe'
5
+ require './lib/tinyurl.rb'
6
+
7
+ Hoe.new('tinyurl', Tinyurl::VERSION) do |p|
8
+ p.rubyforge_name = 'tinyurl'
9
+ p.author = 'Logan Koester'
10
+ p.email = 'logan@logankoester.com'
11
+ p.summary = 'Tools for working with TinyURLs (see http://tinyurl.com)'
12
+ p.remote_rdoc_dir = '' # Release to root
13
+ # p.description = p.paragraphs_of('README.txt', 2..5).join("\n\n")
14
+ # p.url = p.paragraphs_of('README.txt', 0).first.split(/\n/)[1..-1]
15
+ p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
16
+ end
17
+
18
+ # vim: syntax=Ruby
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/ruby -ws
2
+
3
+ require 'tinyurl'
4
+
5
+ if $*.length < 1
6
+ puts "tinyurl [url]"
7
+ puts "Create a tinyurl or reveal where an existing tinyurl redirects to."
8
+ abort
9
+ end
10
+
11
+ url = Tinyurl.new( $*[0] )
12
+ if url.is_tiny?
13
+ puts url.original
14
+ else
15
+ puts url.tiny
16
+ end
@@ -0,0 +1,42 @@
1
+ class Tinyurl
2
+ VERSION = '1.0.0'
3
+
4
+ require 'open-uri'
5
+ require 'uri'
6
+
7
+ attr_accessor :url
8
+ attr_reader :tiny, :original
9
+
10
+ def initialize ( url )
11
+ @url = url
12
+ if self.is_tiny?
13
+ @tiny = @url
14
+ @original = resolve(@url)
15
+ else
16
+ @original = @url
17
+ @tiny = tinyurlize(@url)
18
+ end
19
+ end
20
+
21
+ def resolve ( tinyurl )
22
+ original = URI.parse(
23
+ "http://logankoester.com/tools/urls.php?action=reverse_tinyurl&url=#{tinyurl}"
24
+ ).read
25
+ if original.empty?
26
+ raise "TinyURL \"#{tinyurl}\" does not exist"
27
+ else
28
+ return original
29
+ end
30
+ end
31
+
32
+ def tinyurlize ( longurl )
33
+ URI.parse(
34
+ "http://logankoester.com/tools/urls.php?action=tinyurl&url=#{longurl}"
35
+ ).read
36
+ end
37
+
38
+ def is_tiny?
39
+ return true if URI.parse( @url ).host == "tinyurl.com"
40
+ end
41
+
42
+ end
File without changes
metadata ADDED
@@ -0,0 +1,63 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.2
3
+ specification_version: 1
4
+ name: tinyurl
5
+ version: !ruby/object:Gem::Version
6
+ version: 1.0.0
7
+ date: 2007-09-10 00:00:00 -04:00
8
+ summary: Tools for working with TinyURLs (see http://tinyurl.com)
9
+ require_paths:
10
+ - lib
11
+ email: logan@logankoester.com
12
+ homepage: http://www.zenspider.com/ZSS/Products/tinyurl/
13
+ rubyforge_project: tinyurl
14
+ description: The author was too lazy to write a description
15
+ autorequire:
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ post_install_message:
29
+ authors:
30
+ - Logan Koester
31
+ files:
32
+ - History.txt
33
+ - Manifest.txt
34
+ - README.txt
35
+ - Rakefile
36
+ - bin/tinyurl
37
+ - lib/tinyurl.rb
38
+ - test/test_tinyurl.rb
39
+ test_files:
40
+ - test/test_tinyurl.rb
41
+ rdoc_options:
42
+ - --main
43
+ - README.txt
44
+ extra_rdoc_files:
45
+ - History.txt
46
+ - Manifest.txt
47
+ - README.txt
48
+ executables:
49
+ - tinyurl
50
+ extensions: []
51
+
52
+ requirements: []
53
+
54
+ dependencies:
55
+ - !ruby/object:Gem::Dependency
56
+ name: hoe
57
+ version_requirement:
58
+ version_requirements: !ruby/object:Gem::Version::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: 1.3.0
63
+ version: