-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 8709387
Showing
8 changed files
with
192 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# The list of files that should be ignored by Mr Bones. | ||
# Lines that start with '#' are comments. | ||
# | ||
# A .gitignore file can be used instead by setting it as the ignore | ||
# file in your Rakefile: | ||
# | ||
# Bones { | ||
# ignore_file '.gitignore' | ||
# } | ||
# | ||
# For a project with a C extension, the following would be a good set of | ||
# exclude patterns (uncomment them if you want to use them): | ||
# *.[oa] | ||
# *~ | ||
announcement.txt | ||
coverage | ||
doc | ||
pkg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
== 1.0.0 / 2010-06-23 | ||
|
||
* 1 Shortr is born! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
shortr | ||
by Herval Freire | ||
hervalicio.us | ||
|
||
== DESCRIPTION: | ||
|
||
Shortr is a wrapper around different URL shortening sites. It shortens stuff. | ||
|
||
== FEATURES/PROBLEMS: | ||
|
||
* Support for migre.me | ||
|
||
== SYNOPSIS: | ||
|
||
You can shorten any url by calling: | ||
|
||
Shortr.for("http://yourstuffhere.com") | ||
|
||
The default (and only implemented) shortening service right now is http://migre.me - it's simple, doesn't require any API keys and it's what we're using anyway. | ||
|
||
== REQUIREMENTS: | ||
|
||
* None, really... An Internet connection is a nice to have, though :-) | ||
|
||
== INSTALL: | ||
|
||
* "gem install shortr" and you're good to go! | ||
|
||
== LICENSE: | ||
|
||
(The MIT License) | ||
|
||
Copyright (c) 2009 FIXME (different license?) | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
'Software'), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
begin | ||
require 'bones' | ||
rescue LoadError | ||
abort '### Please install the "bones" gem ###' | ||
end | ||
|
||
ensure_in_path 'lib' | ||
require 'shortr' | ||
|
||
task :default => 'test:run' | ||
task 'gem:release' => 'test:run' | ||
|
||
Bones { | ||
name 'shortr' | ||
authors 'Herval Freire, BlooBox' | ||
email 'hervalfreire@gmail.com' | ||
url 'http://hervalicio.us' | ||
version Shortr::VERSION | ||
} | ||
|
||
# EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
require 'net/http' | ||
require 'cgi' | ||
|
||
module Shortr | ||
module MigreMe | ||
def self.encode(url) | ||
Net::HTTP.get(URI.parse("http://migre.me/api.txt?url=#{CGI::escape(url)}")) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
require 'services/migre_me' | ||
|
||
module Shortr | ||
|
||
# :stopdoc: | ||
VERSION = '0.0.1' | ||
LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR | ||
PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR | ||
# :startdoc: | ||
|
||
def self.version | ||
VERSION | ||
end | ||
|
||
SERVICE = Shortr::MigreMe | ||
|
||
# fetches a shortened version for the given url | ||
def self.for(url, alt_service = nil) | ||
(SERVICE || alt_service).encode(url) | ||
end | ||
|
||
|
||
# Returns the library path for the module. If any arguments are given, | ||
# they will be joined to the end of the libray path using | ||
# <tt>File.join</tt>. | ||
# | ||
def self.libpath( *args ) | ||
args.empty? ? LIBPATH : ::File.join(LIBPATH, args.flatten) | ||
end | ||
|
||
# Returns the lpath for the module. If any arguments are given, | ||
# they will be joined to the end of the path using | ||
# <tt>File.join</tt>. | ||
# | ||
def self.path( *args ) | ||
args.empty? ? PATH : ::File.join(PATH, args.flatten) | ||
end | ||
|
||
# Utility method used to require all files ending in .rb that lie in the | ||
# directory below this file that has the same name as the filename passed | ||
# in. Optionally, a specific _directory_ name can be passed in such that | ||
# the _filename_ does not have to be equivalent to the directory. | ||
# | ||
def self.require_all_libs_relative_to( fname, dir = nil ) | ||
dir ||= ::File.basename(fname, '.*') | ||
search_me = ::File.expand_path( | ||
::File.join(::File.dirname(fname), dir, '**', '*.rb')) | ||
|
||
Dir.glob(search_me).sort.each {|rb| require rb} | ||
end | ||
|
||
end # module Shortr | ||
|
||
Shortr.require_all_libs_relative_to(__FILE__) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
require File.join(File.dirname(__FILE__), %w[spec_helper]) | ||
|
||
describe Shortr do | ||
|
||
describe "migre.me" do | ||
it "should use migre.me as default service" do | ||
Shortr::SERVICE.should be(Shortr::MigreMe) | ||
end | ||
|
||
it "should shorten with migre.me" do | ||
Shortr.for("http://hervalicio.us").should == "http://migre.me/REwf" | ||
end | ||
end | ||
|
||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
require File.expand_path( | ||
File.join(File.dirname(__FILE__), %w[.. lib shortr])) | ||
|
||
Spec::Runner.configure do |config| | ||
# == Mock Framework | ||
# | ||
# RSpec uses it's own mocking framework by default. If you prefer to | ||
# use mocha, flexmock or RR, uncomment the appropriate line: | ||
# | ||
# config.mock_with :mocha | ||
# config.mock_with :flexmock | ||
# config.mock_with :rr | ||
end | ||
|