Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

New version

  • Loading branch information...
commit a5740baf4ae1c2e8bb121189eb308295d4523809 1 parent 5fe2d39
Rodrigo Alves Vieira authored
View
1  README.rdoc
@@ -15,6 +15,7 @@ Or in the Gemfile
From the command-line:
$ tiny_url http://accidentalchinesehipsters.tumblr.com/
+ $ tiny_url -o http://accidentalchinesehipsters.tumbler.com/ - Opens the page in the browser
Anywhere else in Ruby:
View
19 bin/tiny_url
@@ -3,10 +3,23 @@
$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
help = <<HELP
-A gem for tinifying urls
-Basic Command Line Usage:
+NAME
+
+A command line tool for tinifying urls
+
+BASIC USAGE
+
+tiny_url [OPTIONS].. [URL]
+
+OPTIONS:
+ --open
+ -o # Opens the web site in the browser immediately after getting the tiny url.
+
+EXAMPLES:
+
tiny_url http://accidentalchinesehipsters.tumblr.com/ # Returns the tinified version of the url, copies it to the clipboard and opens the webpage in your browser.
+ tiny_url -o http://google.com
HELP
@@ -14,6 +27,8 @@ require 'tiny_url'
if ARGV.size.zero?
puts help
+elsif ARGV[0] == "-o" || ARGV[0] == "--open"
+ TinyUrl.tinify(ARGV[0], op="o")
else
TinyUrl.tinify(ARGV[0])
end
View
12 lib/tiny_url.rb
@@ -3,7 +3,7 @@
require "clipboard"
module TinyUrl
- def self.tinify(url)
+ def self.tinify(url, op=nil)
uri = URI.parse "http://tinyurl.com/api-create.php?url=http://#{url}"
http = Net::HTTP.new(uri.host, uri.port)
@@ -14,9 +14,13 @@ def self.tinify(url)
Clipboard.copy tiny_url
puts "Copied tiny url to clipboard!"
- puts "The generated tiny url is #{tiny_url}, you're gonna see the page..."
- sleep 1
- `open #{tiny_url}`
+ puts "The generated tiny url is #{tiny_url}" if op.nil?
+
+ if op
+ puts "The generated tiny url is #{tiny_url}, you're gonna see the page..."
+ sleep 1
+ `open #{tiny_url}`
+ end
end
def self.silently_tinify(url)
View
2  lib/tiny_url/version.rb
@@ -1,3 +1,3 @@
module TinyUrl
- VERSION = "0.0.2"
+ VERSION = "0.0.3"
end
Please sign in to comment.
Something went wrong with that request. Please try again.