unshortme 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.
data/CHANGELOG ADDED
@@ -0,0 +1,2 @@
1
+ 0.1.1 - Basic functionality
2
+ 0.1.0 - Initial Version (just structure)
data/Manifest ADDED
@@ -0,0 +1,9 @@
1
+ CHANGELOG
2
+ README.rdoc
3
+ Rakefile
4
+ init.rb
5
+ lib/unshortme.rb
6
+ spec/spec_helper.rb
7
+ spec/unshortme_spec.rb
8
+ unshortme.gemspec
9
+ Manifest
data/README.rdoc ADDED
@@ -0,0 +1,14 @@
1
+ = Unshortme
2
+
3
+ A RubyGem for unshort.me API
4
+
5
+ = Installation
6
+
7
+ gem install unshortme
8
+
9
+ = Usage
10
+
11
+ require 'rubygems'
12
+ require 'unshortme'
13
+
14
+ unshorted = Unshortme.unshort("http://bit.ly/xxxx")
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'echoe'
4
+
5
+ Echoe.new('unshortme', '0.1.1') do |p|
6
+ p.description = "Use the unshort.me API"
7
+ p.url = "http://github.com/julianduque/unshortme"
8
+ p.author = "Julian Duque"
9
+ p.email = "julianduquej@gmail.com"
10
+ p.ignore_pattern = ["tmp/*", "script/*"]
11
+ p.development_dependencies = []
12
+ end
13
+
14
+ Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
data/init.rb ADDED
@@ -0,0 +1 @@
1
+ require 'unshortme'
data/lib/unshortme.rb ADDED
@@ -0,0 +1,21 @@
1
+ require 'json'
2
+ require 'rest-client'
3
+
4
+ module Unshortme
5
+ API_URL = 'http://api.unshort.me'
6
+
7
+ def self.unshort(url)
8
+ begin
9
+ response = RestClient.get API_URL, {:params => {'r' => url, 't' => 'json'}}
10
+ response = JSON.parse(response) if response.code == 200
11
+ if response['success'] == "true"
12
+ unshorted = response['resolvedURL']
13
+ else
14
+ raise Exception.new("Not unshorted")
15
+ end
16
+ rescue Exception => ex
17
+ unshorted = url
18
+ end
19
+ end
20
+
21
+ end
@@ -0,0 +1,7 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+
4
+ require 'unshortme'
5
+
6
+ RSpec.configure do |config|
7
+ end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Unshortme' do
4
+
5
+ it 'should not return the unshorted url' do
6
+ unshorted = Unshortme.unshort("the url")
7
+ unshorted.should_not == nil
8
+ unshorted.should match /the url/
9
+ end
10
+
11
+ it 'should return the unshorted url' do
12
+ unshorted = Unshortme.unshort("http://bit.ly/lathw5")
13
+ unshorted.should_not == nil
14
+ unshorted.should == 'http://get2java.blogspot.com/2011/07/whats-up-in-java-17.html'
15
+ end
16
+ end
data/unshortme.gemspec ADDED
@@ -0,0 +1,29 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{unshortme}
5
+ s.version = "0.1.1"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
+ s.authors = [%q{Julian Duque}]
9
+ s.date = %q{2011-07-07}
10
+ s.description = %q{Use the unshort.me API}
11
+ s.email = %q{julianduquej@gmail.com}
12
+ s.extra_rdoc_files = [%q{CHANGELOG}, %q{README.rdoc}, %q{lib/unshortme.rb}]
13
+ s.files = [%q{CHANGELOG}, %q{README.rdoc}, %q{Rakefile}, %q{init.rb}, %q{lib/unshortme.rb}, %q{spec/spec_helper.rb}, %q{spec/unshortme_spec.rb}, %q{Manifest}, %q{unshortme.gemspec}]
14
+ s.homepage = %q{http://github.com/julianduque/unshortme}
15
+ s.rdoc_options = [%q{--line-numbers}, %q{--inline-source}, %q{--title}, %q{Unshortme}, %q{--main}, %q{README.rdoc}]
16
+ s.require_paths = [%q{lib}]
17
+ s.rubyforge_project = %q{unshortme}
18
+ s.rubygems_version = %q{1.8.5}
19
+ s.summary = %q{Use the unshort.me API}
20
+
21
+ if s.respond_to? :specification_version then
22
+ s.specification_version = 3
23
+
24
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
25
+ else
26
+ end
27
+ else
28
+ end
29
+ end
metadata ADDED
@@ -0,0 +1,81 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: unshortme
3
+ version: !ruby/object:Gem::Version
4
+ hash: 25
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 1
10
+ version: 0.1.1
11
+ platform: ruby
12
+ authors:
13
+ - Julian Duque
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-07-07 00:00:00 Z
19
+ dependencies: []
20
+
21
+ description: Use the unshort.me API
22
+ email: julianduquej@gmail.com
23
+ executables: []
24
+
25
+ extensions: []
26
+
27
+ extra_rdoc_files:
28
+ - CHANGELOG
29
+ - README.rdoc
30
+ - lib/unshortme.rb
31
+ files:
32
+ - CHANGELOG
33
+ - README.rdoc
34
+ - Rakefile
35
+ - init.rb
36
+ - lib/unshortme.rb
37
+ - spec/spec_helper.rb
38
+ - spec/unshortme_spec.rb
39
+ - Manifest
40
+ - unshortme.gemspec
41
+ homepage: http://github.com/julianduque/unshortme
42
+ licenses: []
43
+
44
+ post_install_message:
45
+ rdoc_options:
46
+ - --line-numbers
47
+ - --inline-source
48
+ - --title
49
+ - Unshortme
50
+ - --main
51
+ - README.rdoc
52
+ require_paths:
53
+ - lib
54
+ required_ruby_version: !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ hash: 3
60
+ segments:
61
+ - 0
62
+ version: "0"
63
+ required_rubygems_version: !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ hash: 11
69
+ segments:
70
+ - 1
71
+ - 2
72
+ version: "1.2"
73
+ requirements: []
74
+
75
+ rubyforge_project: unshortme
76
+ rubygems_version: 1.8.5
77
+ signing_key:
78
+ specification_version: 3
79
+ summary: Use the unshort.me API
80
+ test_files: []
81
+