mush 0.1.2 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +8 -0
- data/Gemfile.lock +18 -0
- data/README.md +100 -0
- data/Rakefile +2 -2
- data/VERSION +1 -1
- data/bin/isgd +1 -1
- data/bin/mush +1 -1
- data/bin/{unu → owly} +22 -4
- data/bin/shorten +49 -0
- data/lib/mush/services/custom.rb +26 -0
- data/lib/mush/services/owly.rb +38 -0
- data/mush.gemspec +39 -28
- data/test/test_mush.rb +35 -14
- metadata +75 -23
- data/.gitignore +0 -21
- data/README.rdoc +0 -74
- data/lib/mush/services/unu.rb +0 -20
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
crack (0.1.8)
|
5
|
+
httparty (0.6.1)
|
6
|
+
crack (= 0.1.8)
|
7
|
+
mocha (0.9.8)
|
8
|
+
rake
|
9
|
+
rake (0.8.7)
|
10
|
+
shoulda (2.11.3)
|
11
|
+
|
12
|
+
PLATFORMS
|
13
|
+
ruby
|
14
|
+
|
15
|
+
DEPENDENCIES
|
16
|
+
httparty (= 0.6.1)
|
17
|
+
mocha (= 0.9.8)
|
18
|
+
shoulda (= 2.11.3)
|
data/README.md
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
MUSh
|
2
|
+
====
|
3
|
+
|
4
|
+
A multiple service URL shortener gem with command-line utilities
|
5
|
+
|
6
|
+
NOTE: This gem only supports url shortening, nothing else, no stats, no info, no expand and it won't support any of them.
|
7
|
+
|
8
|
+
Installation
|
9
|
+
------------
|
10
|
+
|
11
|
+
MUSh depends on [HTTParty](https://github.com/jnunemaker/httparty "HTTParty")
|
12
|
+
|
13
|
+
sudo gem install httparty
|
14
|
+
sudo gem install mush
|
15
|
+
|
16
|
+
or
|
17
|
+
|
18
|
+
sudo gem install mush --include-dependencies
|
19
|
+
|
20
|
+
Supported services
|
21
|
+
------------------
|
22
|
+
|
23
|
+
* bit.ly
|
24
|
+
* is.gd
|
25
|
+
|
26
|
+
and thanks to [Noel Dellofano](https://github.com/pinkvelociraptor]) from [ZenDesk](http://www.zendesk.com/)
|
27
|
+
|
28
|
+
* ow.ly
|
29
|
+
* custom service
|
30
|
+
|
31
|
+
Usage as a command line utility
|
32
|
+
-------------------------------
|
33
|
+
|
34
|
+
$ bitly -l login -k apikey -u http://foo.raflabs.com
|
35
|
+
|
36
|
+
$ isgd http://foo.raflabs.com
|
37
|
+
|
38
|
+
$ owly -k apikey -u foo.raflabs.com
|
39
|
+
|
40
|
+
$ shorten -s "http://chop.ws/index.php?api=1&return_url_text=1&longUrl={{url}}" -u foo.raflabs.com
|
41
|
+
|
42
|
+
**NOTE:** _The 'shorten' command uses <code>Mush::Service::Custom</code> and currently it only works with services that accept 'get' as method (not 'post') and with services that return only the shortened url not a full html page_
|
43
|
+
|
44
|
+
Sorry, but at this moment, if you want to use the <code>bitly</code> or <code>owly</code> command line without apikey or login do this:
|
45
|
+
|
46
|
+
Add the following alias to your ~/.bash_profile or ~/.bashrc
|
47
|
+
|
48
|
+
alias bitly='bitly -l your_login -k your_apikey'
|
49
|
+
|
50
|
+
alias owly='owly -k your_apikey'
|
51
|
+
|
52
|
+
then use it this way (you won't need the -u)
|
53
|
+
|
54
|
+
$ bitly http://google.com
|
55
|
+
|
56
|
+
$ owly http://google.com
|
57
|
+
|
58
|
+
Usage as a Gem
|
59
|
+
--------------
|
60
|
+
|
61
|
+
require 'rubygems' #in a Rails project you won't need this line
|
62
|
+
require 'mush'
|
63
|
+
|
64
|
+
bitly = Mush::Services::Bitly.new
|
65
|
+
|
66
|
+
bitly.login = "login"
|
67
|
+
bitly.apikey = "apikey"
|
68
|
+
|
69
|
+
bitly.shorten "http://foo.raflabs.com"
|
70
|
+
|
71
|
+
isgd = Mush::Services::IsGd.new
|
72
|
+
isgd.shorten "http://foo.raflabs.com"
|
73
|
+
|
74
|
+
custom = Mush::Services::Custom.new
|
75
|
+
custom.set_service = "http://chop.ws/index.php?api=1&return_url_text=1&longUrl={{url}}"
|
76
|
+
custom.shorten 'foo.raflabs.com'
|
77
|
+
|
78
|
+
ToDo
|
79
|
+
----
|
80
|
+
|
81
|
+
* Use bitly commmand without -l and -k, save config in home folder (.mush file)
|
82
|
+
* Make shorten method to accept multiple URLs
|
83
|
+
* add j.mp and maybe other services
|
84
|
+
* Cache
|
85
|
+
|
86
|
+
Note on Patches/Pull Requests
|
87
|
+
-----------------------------
|
88
|
+
|
89
|
+
* Fork the project.
|
90
|
+
* Make your feature/service addition or bug fix.
|
91
|
+
* Add tests for it. This is important so I don't break it in a
|
92
|
+
future version unintentionally.
|
93
|
+
* Commit, do not mess with rakefile, version, or history.
|
94
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
95
|
+
* Send me a pull request. Bonus points for topic branches.
|
96
|
+
|
97
|
+
Copyright
|
98
|
+
---------
|
99
|
+
|
100
|
+
Copyright (c) 2011 Rafael Magana. See LICENSE for details.
|
data/Rakefile
CHANGED
@@ -6,8 +6,8 @@ begin
|
|
6
6
|
require 'jeweler'
|
7
7
|
Jeweler::Tasks.new do |gem|
|
8
8
|
gem.name = "mush"
|
9
|
-
gem.summary = %Q{A multiple service URL shortener gem with command-line
|
10
|
-
gem.description = %Q{A gem to shorten URLs using different services, it has one command-line utility for each supported service.}
|
9
|
+
gem.summary = %Q{A multiple service URL shortener gem with command-line utilities}
|
10
|
+
gem.description = %Q{A gem to shorten URLs using different services, it has one command-line utility for each supported service and one for custom shorteners called 'shorten'.}
|
11
11
|
gem.email = "raf.magana@gmail.com"
|
12
12
|
gem.homepage = "http://github.com/rafmagana/mush"
|
13
13
|
gem.authors = ["Rafael Magaña"]
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1
|
1
|
+
0.2.1
|
data/bin/isgd
CHANGED
data/bin/mush
CHANGED
data/bin/{unu → owly}
RENAMED
@@ -16,9 +16,19 @@ options = {}
|
|
16
16
|
opts = OptionParser.new do |opts|
|
17
17
|
opts.banner = <<-EOF
|
18
18
|
Usage:
|
19
|
-
|
19
|
+
owly -k apikey -u url
|
20
|
+
|
21
|
+
Options:
|
20
22
|
EOF
|
21
23
|
|
24
|
+
opts.on("-kAPIKEY", "--apikey APIKEY", "API Key") do |apikey|
|
25
|
+
options[:apikey] = apikey
|
26
|
+
end
|
27
|
+
|
28
|
+
opts.on("-uURL", "--url URL", "The long URL to be shortened") do |url|
|
29
|
+
options[:url] = url
|
30
|
+
end
|
31
|
+
|
22
32
|
opts.on("-v", "--version", "Print the version number and exit") do
|
23
33
|
options[:version] = true
|
24
34
|
end
|
@@ -32,9 +42,17 @@ end
|
|
32
42
|
|
33
43
|
options[:url] = ARGV.first if ARGV.length == 1
|
34
44
|
|
35
|
-
#
|
45
|
+
#validate
|
46
|
+
unless options[:apikey]
|
47
|
+
abort("You must specify an API Key to access the Ow.ly API")
|
48
|
+
end
|
49
|
+
|
36
50
|
unless options[:url]
|
37
|
-
abort("
|
51
|
+
abort("Please provide a valid URL, including http://")
|
38
52
|
end
|
39
53
|
|
40
|
-
|
54
|
+
owly = Mush::Services::Owly.new
|
55
|
+
|
56
|
+
owly.apikey = options[:apikey]
|
57
|
+
|
58
|
+
puts owly.shorten options[:url]
|
data/bin/shorten
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
STDOUT.sync = true
|
4
|
+
|
5
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
|
6
|
+
|
7
|
+
require 'rubygems'
|
8
|
+
require 'optparse'
|
9
|
+
require 'mush'
|
10
|
+
|
11
|
+
ORIGINAL_ARGV = ARGV.dup
|
12
|
+
|
13
|
+
#the defaults
|
14
|
+
options = {}
|
15
|
+
|
16
|
+
opts = OptionParser.new do |opts|
|
17
|
+
opts.banner = <<-EOF
|
18
|
+
Usage:
|
19
|
+
custom -s service -u url
|
20
|
+
EOF
|
21
|
+
|
22
|
+
opts.on("-v", "--version", "Print the version number and exit") do
|
23
|
+
options[:version] = true
|
24
|
+
end
|
25
|
+
opts.on("-sService", "--service Service", "The url of the custom shortener to use. ie. http://short.en?url={{url}}") do |service|
|
26
|
+
options[:service] = service
|
27
|
+
end
|
28
|
+
opts.on("-uURL", "--url URL", "The long URL to be shortened") do |url|
|
29
|
+
options[:url] = url
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
opts.parse!
|
34
|
+
|
35
|
+
if options[:version]
|
36
|
+
abort("Version " + Mush.version)
|
37
|
+
end
|
38
|
+
|
39
|
+
# validate
|
40
|
+
unless options[:service]
|
41
|
+
abort("You must specify a shortener URL of form http://short.en?url={{url}} to use the custom service")
|
42
|
+
end
|
43
|
+
unless options[:url]
|
44
|
+
abort("You must specify a URL to use the custom service")
|
45
|
+
end
|
46
|
+
|
47
|
+
custom = Mush::Services::Custom.new
|
48
|
+
custom.set_service options[:service]
|
49
|
+
puts custom.shorten options[:url]
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Mush
|
2
|
+
|
3
|
+
module Services
|
4
|
+
|
5
|
+
# General class to accept a custom shortener
|
6
|
+
# e.g. http://short.en?url={{url}}&api_key=982AAJHKDLFDF
|
7
|
+
class Custom < Service
|
8
|
+
|
9
|
+
def set_service(service_url)
|
10
|
+
@service = service_url
|
11
|
+
end
|
12
|
+
|
13
|
+
def shorten(url)
|
14
|
+
raise InvalidURI.new("Please provide a valid URI") if url.empty?
|
15
|
+
|
16
|
+
options = {}
|
17
|
+
path = @service.gsub(/\{\{url\}\}/, url)
|
18
|
+
get(path,options).body.chomp
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Mush
|
2
|
+
|
3
|
+
module Services
|
4
|
+
|
5
|
+
require 'json'
|
6
|
+
class Owly < AuthenticatedService
|
7
|
+
|
8
|
+
base_uri 'http://ow.ly/api/1.1/url'
|
9
|
+
format :json
|
10
|
+
|
11
|
+
#Ow.ly api bug, response is in json, but response type is html so force parse
|
12
|
+
def self.response_parse
|
13
|
+
Proc.new do |body, format|
|
14
|
+
JSON.parse(body)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
parser response_parse
|
18
|
+
|
19
|
+
def shorten(url)
|
20
|
+
invalid_uri_msg = "Please provide a valid URI, including http://"
|
21
|
+
invalid_auth_msg = "Invalid Authorization Data, please provide apikey"
|
22
|
+
|
23
|
+
raise InvalidURI.new invalid_uri_msg if url.empty?
|
24
|
+
raise InvalidAuthorizationData.new(invalid_auth_msg) if apikey.empty?
|
25
|
+
|
26
|
+
options = {:format => 'json'}
|
27
|
+
options[:query] = {:apiKey => self.apikey, :longUrl => url}
|
28
|
+
|
29
|
+
response = get('/shorten', options)
|
30
|
+
|
31
|
+
response.code == 200 ? response["results"]["shortUrl"] : response["error"]
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
data/mush.gemspec
CHANGED
@@ -1,52 +1,54 @@
|
|
1
1
|
# Generated by jeweler
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{mush}
|
8
|
-
s.version = "0.1
|
8
|
+
s.version = "0.2.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Rafael Maga\303\261a"]
|
12
|
-
s.date = %q{
|
13
|
-
s.description = %q{A gem to shorten URLs using different services, it has one command-line utility for each supported service.}
|
12
|
+
s.date = %q{2011-01-17}
|
13
|
+
s.description = %q{A gem to shorten URLs using different services, it has one command-line utility for each supported service and one for custom shorteners called 'shorten'.}
|
14
14
|
s.email = %q{raf.magana@gmail.com}
|
15
|
-
s.executables = ["
|
15
|
+
s.executables = ["isgd", "mush", "bitly", "shorten", "owly"]
|
16
16
|
s.extra_rdoc_files = [
|
17
17
|
"LICENSE",
|
18
|
-
|
18
|
+
"README.md"
|
19
19
|
]
|
20
20
|
s.files = [
|
21
21
|
".document",
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
22
|
+
"Gemfile",
|
23
|
+
"Gemfile.lock",
|
24
|
+
"LICENSE",
|
25
|
+
"README.md",
|
26
|
+
"Rakefile",
|
27
|
+
"VERSION",
|
28
|
+
"bin/bitly",
|
29
|
+
"bin/isgd",
|
30
|
+
"bin/mush",
|
31
|
+
"bin/owly",
|
32
|
+
"bin/shorten",
|
33
|
+
"lib/mush.rb",
|
34
|
+
"lib/mush/authenticated_service.rb",
|
35
|
+
"lib/mush/errors.rb",
|
36
|
+
"lib/mush/service.rb",
|
37
|
+
"lib/mush/services/bitly.rb",
|
38
|
+
"lib/mush/services/custom.rb",
|
39
|
+
"lib/mush/services/isgd.rb",
|
40
|
+
"lib/mush/services/owly.rb",
|
41
|
+
"mush.gemspec",
|
42
|
+
"test/helper.rb",
|
43
|
+
"test/test_mush.rb"
|
41
44
|
]
|
42
45
|
s.homepage = %q{http://github.com/rafmagana/mush}
|
43
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
44
46
|
s.require_paths = ["lib"]
|
45
47
|
s.rubygems_version = %q{1.3.7}
|
46
|
-
s.summary = %q{A multiple service URL shortener gem with command-line
|
48
|
+
s.summary = %q{A multiple service URL shortener gem with command-line utilities}
|
47
49
|
s.test_files = [
|
48
50
|
"test/helper.rb",
|
49
|
-
|
51
|
+
"test/test_mush.rb"
|
50
52
|
]
|
51
53
|
|
52
54
|
if s.respond_to? :specification_version then
|
@@ -54,15 +56,24 @@ Gem::Specification.new do |s|
|
|
54
56
|
s.specification_version = 3
|
55
57
|
|
56
58
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
59
|
+
s.add_runtime_dependency(%q<httparty>, ["= 0.6.1"])
|
60
|
+
s.add_development_dependency(%q<mocha>, ["= 0.9.8"])
|
61
|
+
s.add_development_dependency(%q<shoulda>, ["= 2.11.3"])
|
57
62
|
s.add_development_dependency(%q<shoulda>, [">= 2.11.3"])
|
58
63
|
s.add_development_dependency(%q<mocha>, [">= 0.9.8"])
|
59
64
|
s.add_runtime_dependency(%q<httparty>, [">= 0.6.1"])
|
60
65
|
else
|
66
|
+
s.add_dependency(%q<httparty>, ["= 0.6.1"])
|
67
|
+
s.add_dependency(%q<mocha>, ["= 0.9.8"])
|
68
|
+
s.add_dependency(%q<shoulda>, ["= 2.11.3"])
|
61
69
|
s.add_dependency(%q<shoulda>, [">= 2.11.3"])
|
62
70
|
s.add_dependency(%q<mocha>, [">= 0.9.8"])
|
63
71
|
s.add_dependency(%q<httparty>, [">= 0.6.1"])
|
64
72
|
end
|
65
73
|
else
|
74
|
+
s.add_dependency(%q<httparty>, ["= 0.6.1"])
|
75
|
+
s.add_dependency(%q<mocha>, ["= 0.9.8"])
|
76
|
+
s.add_dependency(%q<shoulda>, ["= 2.11.3"])
|
66
77
|
s.add_dependency(%q<shoulda>, [">= 2.11.3"])
|
67
78
|
s.add_dependency(%q<mocha>, [">= 0.9.8"])
|
68
79
|
s.add_dependency(%q<httparty>, [">= 0.6.1"])
|
data/test/test_mush.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
3
|
class TestMush < Test::Unit::TestCase
|
4
|
-
|
4
|
+
|
5
5
|
context "Mush::Service class" do
|
6
6
|
should "include HTTParty module" do
|
7
7
|
assert Mush::Service.include? HTTParty
|
@@ -25,7 +25,7 @@ class TestMush < Test::Unit::TestCase
|
|
25
25
|
context "All Services" do
|
26
26
|
setup do
|
27
27
|
s = Mush::Services
|
28
|
-
@services = [s::IsGd, s::Bitly
|
28
|
+
@services = [s::IsGd, s::Bitly]
|
29
29
|
end
|
30
30
|
|
31
31
|
should "be subclasses of Mush::Service" do
|
@@ -48,13 +48,14 @@ class TestMush < Test::Unit::TestCase
|
|
48
48
|
setup do
|
49
49
|
@long_url = "http://www.a_very_long_url.com"
|
50
50
|
@shortened_url = "http://is.gd/test"
|
51
|
-
@httparty_response = stub('HTTParty::
|
51
|
+
@httparty_response = stub('HTTParty::Response', :body => @shortened_url)
|
52
52
|
end
|
53
53
|
|
54
54
|
context "not authorizable" do
|
55
55
|
|
56
56
|
setup do
|
57
|
-
@httparty_response = stub('HTTParty::
|
57
|
+
@httparty_response = stub('HTTParty::Response', :body => @shortened_url)
|
58
|
+
@custom_shortener = 'http://is.gd/api.php?longurl={{url}}'
|
58
59
|
end
|
59
60
|
|
60
61
|
context "IsGd" do
|
@@ -67,21 +68,21 @@ class TestMush < Test::Unit::TestCase
|
|
67
68
|
|
68
69
|
assert_equal @shortened_url, isgd_result
|
69
70
|
end
|
70
|
-
|
71
71
|
end
|
72
|
-
|
73
|
-
context "
|
72
|
+
|
73
|
+
context "Custom" do
|
74
74
|
should "return a shortened url" do
|
75
|
-
Mush::Services::
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
75
|
+
Mush::Services::Custom.any_instance.stubs(:get).with(instance_of(String), instance_of(Hash)).returns(@httparty_response)
|
76
|
+
|
77
|
+
custom = Mush::Services::Custom.new
|
78
|
+
custom.set_service @custom_shortener
|
79
|
+
custom_result = custom.shorten(@long_url)
|
80
|
+
|
81
|
+
assert_equal @shortened_url, custom_result
|
81
82
|
end
|
82
83
|
end
|
83
84
|
end
|
84
|
-
|
85
|
+
|
85
86
|
context "authorizable" do
|
86
87
|
setup do
|
87
88
|
@response = @shortened_url
|
@@ -108,6 +109,26 @@ class TestMush < Test::Unit::TestCase
|
|
108
109
|
assert_equal @shortened_url, bitly.shorten(@long_url)
|
109
110
|
end
|
110
111
|
end
|
112
|
+
|
113
|
+
context "Owly" do
|
114
|
+
should "has authentication credentials to return a shortened url" do
|
115
|
+
|
116
|
+
httparty_response = stub('HTTParty::Response', :[] => @shortened_url)
|
117
|
+
owly = Mush::Services::Owly.new
|
118
|
+
|
119
|
+
assert_raise Mush::InvalidAuthorizationData do
|
120
|
+
owly.shorten(@long_url)
|
121
|
+
end
|
122
|
+
|
123
|
+
owly.apikey = "apikey"
|
124
|
+
|
125
|
+
assert_nothing_raised do
|
126
|
+
owly.shorten(@long_url)
|
127
|
+
end
|
128
|
+
|
129
|
+
Mush::Services::Owly.any_instance.stubs(:get).with(instance_of(String), instance_of(Hash)).returns(httparty_response)
|
130
|
+
end
|
131
|
+
end
|
111
132
|
end
|
112
133
|
end
|
113
134
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mush
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
- 1
|
9
8
|
- 2
|
10
|
-
|
9
|
+
- 1
|
10
|
+
version: 0.2.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- "Rafael Maga\xC3\xB1a"
|
@@ -15,13 +15,60 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2011-01-17 00:00:00 -06:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - "="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 5
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
- 6
|
32
|
+
- 1
|
33
|
+
version: 0.6.1
|
34
|
+
name: httparty
|
35
|
+
requirement: *id001
|
36
|
+
type: :runtime
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - "="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
hash: 43
|
45
|
+
segments:
|
46
|
+
- 0
|
47
|
+
- 9
|
48
|
+
- 8
|
49
|
+
version: 0.9.8
|
50
|
+
name: mocha
|
51
|
+
requirement: *id002
|
52
|
+
type: :development
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
prerelease: false
|
55
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
58
|
+
- - "="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
hash: 37
|
61
|
+
segments:
|
62
|
+
- 2
|
63
|
+
- 11
|
64
|
+
- 3
|
65
|
+
version: 2.11.3
|
22
66
|
name: shoulda
|
67
|
+
requirement: *id003
|
68
|
+
type: :development
|
69
|
+
- !ruby/object:Gem::Dependency
|
23
70
|
prerelease: false
|
24
|
-
|
71
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
25
72
|
none: false
|
26
73
|
requirements:
|
27
74
|
- - ">="
|
@@ -32,12 +79,12 @@ dependencies:
|
|
32
79
|
- 11
|
33
80
|
- 3
|
34
81
|
version: 2.11.3
|
82
|
+
name: shoulda
|
83
|
+
requirement: *id004
|
35
84
|
type: :development
|
36
|
-
version_requirements: *id001
|
37
85
|
- !ruby/object:Gem::Dependency
|
38
|
-
name: mocha
|
39
86
|
prerelease: false
|
40
|
-
|
87
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
41
88
|
none: false
|
42
89
|
requirements:
|
43
90
|
- - ">="
|
@@ -48,12 +95,12 @@ dependencies:
|
|
48
95
|
- 9
|
49
96
|
- 8
|
50
97
|
version: 0.9.8
|
98
|
+
name: mocha
|
99
|
+
requirement: *id005
|
51
100
|
type: :development
|
52
|
-
version_requirements: *id002
|
53
101
|
- !ruby/object:Gem::Dependency
|
54
|
-
name: httparty
|
55
102
|
prerelease: false
|
56
|
-
|
103
|
+
version_requirements: &id006 !ruby/object:Gem::Requirement
|
57
104
|
none: false
|
58
105
|
requirements:
|
59
106
|
- - ">="
|
@@ -64,38 +111,43 @@ dependencies:
|
|
64
111
|
- 6
|
65
112
|
- 1
|
66
113
|
version: 0.6.1
|
114
|
+
name: httparty
|
115
|
+
requirement: *id006
|
67
116
|
type: :runtime
|
68
|
-
|
69
|
-
description: A gem to shorten URLs using different services, it has one command-line utility for each supported service.
|
117
|
+
description: A gem to shorten URLs using different services, it has one command-line utility for each supported service and one for custom shorteners called 'shorten'.
|
70
118
|
email: raf.magana@gmail.com
|
71
119
|
executables:
|
72
|
-
- bitly
|
73
120
|
- isgd
|
74
121
|
- mush
|
75
|
-
-
|
122
|
+
- bitly
|
123
|
+
- shorten
|
124
|
+
- owly
|
76
125
|
extensions: []
|
77
126
|
|
78
127
|
extra_rdoc_files:
|
79
128
|
- LICENSE
|
80
|
-
- README.
|
129
|
+
- README.md
|
81
130
|
files:
|
82
131
|
- .document
|
83
|
-
-
|
132
|
+
- Gemfile
|
133
|
+
- Gemfile.lock
|
84
134
|
- LICENSE
|
85
|
-
- README.
|
135
|
+
- README.md
|
86
136
|
- Rakefile
|
87
137
|
- VERSION
|
88
138
|
- bin/bitly
|
89
139
|
- bin/isgd
|
90
140
|
- bin/mush
|
91
|
-
- bin/
|
141
|
+
- bin/owly
|
142
|
+
- bin/shorten
|
92
143
|
- lib/mush.rb
|
93
144
|
- lib/mush/authenticated_service.rb
|
94
145
|
- lib/mush/errors.rb
|
95
146
|
- lib/mush/service.rb
|
96
147
|
- lib/mush/services/bitly.rb
|
148
|
+
- lib/mush/services/custom.rb
|
97
149
|
- lib/mush/services/isgd.rb
|
98
|
-
- lib/mush/services/
|
150
|
+
- lib/mush/services/owly.rb
|
99
151
|
- mush.gemspec
|
100
152
|
- test/helper.rb
|
101
153
|
- test/test_mush.rb
|
@@ -104,8 +156,8 @@ homepage: http://github.com/rafmagana/mush
|
|
104
156
|
licenses: []
|
105
157
|
|
106
158
|
post_install_message:
|
107
|
-
rdoc_options:
|
108
|
-
|
159
|
+
rdoc_options: []
|
160
|
+
|
109
161
|
require_paths:
|
110
162
|
- lib
|
111
163
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -132,7 +184,7 @@ rubyforge_project:
|
|
132
184
|
rubygems_version: 1.3.7
|
133
185
|
signing_key:
|
134
186
|
specification_version: 3
|
135
|
-
summary: A multiple service URL shortener gem with command-line
|
187
|
+
summary: A multiple service URL shortener gem with command-line utilities
|
136
188
|
test_files:
|
137
189
|
- test/helper.rb
|
138
190
|
- test/test_mush.rb
|
data/.gitignore
DELETED
data/README.rdoc
DELETED
@@ -1,74 +0,0 @@
|
|
1
|
-
= MUSh
|
2
|
-
|
3
|
-
A multiple service URL shortener gem with command-line utilities
|
4
|
-
|
5
|
-
NOTE: This gem only supports url shortening, nothing else, no stats, no info, no expand and it won't support any of them.
|
6
|
-
|
7
|
-
== Installation
|
8
|
-
|
9
|
-
MUSh depends on HTTParty
|
10
|
-
|
11
|
-
sudo gem install httparty
|
12
|
-
sudo gem install mush
|
13
|
-
|
14
|
-
== Supported services
|
15
|
-
|
16
|
-
* bit.ly
|
17
|
-
* is.gd
|
18
|
-
* u.nu
|
19
|
-
|
20
|
-
== Usage as a command line utility
|
21
|
-
|
22
|
-
$ bitly -l login -l apikey -u http://foo.raflabs.com
|
23
|
-
|
24
|
-
$ isgd http://foo.raflabs.com
|
25
|
-
|
26
|
-
$ unu foo.raflabs.com
|
27
|
-
|
28
|
-
Sorry, but at this moment, if you want to use the bitly command line without -l and -k do this:
|
29
|
-
|
30
|
-
Add the following alias to your ~/.bash_profile or ~/.bashrc
|
31
|
-
|
32
|
-
alias bitly='bitly -l your_login -k your_apikey'
|
33
|
-
|
34
|
-
then use it this way (you won't need the -u)
|
35
|
-
|
36
|
-
$ bitly http://google.com
|
37
|
-
|
38
|
-
== Usage as a Gem
|
39
|
-
|
40
|
-
require 'mush'
|
41
|
-
|
42
|
-
bitly = Mush::Services::Bitly.new
|
43
|
-
|
44
|
-
bitly.login = "login"
|
45
|
-
bitly.apikey = "apikey"
|
46
|
-
|
47
|
-
bitly.shorten "http://foo.raflabs.com"
|
48
|
-
|
49
|
-
isgd = Mush::Services::IsGd.new
|
50
|
-
isgd.shorten "http://foo.raflabs.com"
|
51
|
-
|
52
|
-
unu = Mush::Services:Unu.new
|
53
|
-
unu.shorten "http://foo.raflabs.com"
|
54
|
-
|
55
|
-
== ToDo
|
56
|
-
|
57
|
-
* Use bitly commmand without -l and -k, save config in home folder (.mush file)
|
58
|
-
* Make shorten method to accept multiple URLs
|
59
|
-
* add j.mp and maybe other services
|
60
|
-
* Cache
|
61
|
-
|
62
|
-
== Note on Patches/Pull Requests
|
63
|
-
|
64
|
-
* Fork the project.
|
65
|
-
* Make your feature/service addition or bug fix.
|
66
|
-
* Add tests for it. This is important so I don't break it in a
|
67
|
-
future version unintentionally.
|
68
|
-
* Commit, do not mess with rakefile, version, or history.
|
69
|
-
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
70
|
-
* Send me a pull request. Bonus points for topic branches.
|
71
|
-
|
72
|
-
== Copyright
|
73
|
-
|
74
|
-
Copyright (c) 2010 Rafael Magana. See LICENSE for details.
|
data/lib/mush/services/unu.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
module Mush
|
2
|
-
|
3
|
-
module Services
|
4
|
-
|
5
|
-
class Unu < Service
|
6
|
-
base_uri 'http://u.nu/'
|
7
|
-
|
8
|
-
def shorten(url)
|
9
|
-
raise InvalidURI.new("Please provide a valid URI") if url.empty?
|
10
|
-
|
11
|
-
options = {}
|
12
|
-
options[:query] = {:url => url}
|
13
|
-
get('/unu-api-simple', options).body.chomp
|
14
|
-
end
|
15
|
-
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|