tiny_url 0.0.2 → 0.0.3
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/README.rdoc +3 -1
- data/bin/tiny_url +25 -2
- data/lib/tiny_url/version.rb +1 -1
- data/lib/tiny_url.rb +8 -4
- data/spec/spec_helper.rb +2 -0
- data/spec/tiny_url_spec.rb +13 -0
- metadata +12 -8
data/README.rdoc
CHANGED
data/bin/tiny_url
CHANGED
@@ -2,10 +2,33 @@
|
|
2
2
|
|
3
3
|
$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
|
4
4
|
|
5
|
+
help = <<HELP
|
6
|
+
|
7
|
+
NAME
|
8
|
+
|
9
|
+
A command line tool for tinifying urls
|
10
|
+
|
11
|
+
BASIC USAGE
|
12
|
+
|
13
|
+
tiny_url [OPTIONS].. [URL]
|
14
|
+
|
15
|
+
OPTIONS:
|
16
|
+
--open
|
17
|
+
-o # Opens the web site in the browser immediately after getting the tiny url.
|
18
|
+
|
19
|
+
EXAMPLES:
|
20
|
+
|
21
|
+
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.
|
22
|
+
tiny_url -o http://google.com
|
23
|
+
|
24
|
+
HELP
|
25
|
+
|
5
26
|
require 'tiny_url'
|
6
27
|
|
7
|
-
if ARGV.size
|
8
|
-
puts
|
28
|
+
if ARGV.size.zero?
|
29
|
+
puts help
|
30
|
+
elsif ARGV[0] == "-o" || ARGV[0] == "--open"
|
31
|
+
TinyUrl.tinify(ARGV[0], op="o")
|
9
32
|
else
|
10
33
|
TinyUrl.tinify(ARGV[0])
|
11
34
|
end
|
data/lib/tiny_url/version.rb
CHANGED
data/lib/tiny_url.rb
CHANGED
@@ -3,7 +3,7 @@ require "net/http"
|
|
3
3
|
require "clipboard"
|
4
4
|
|
5
5
|
module TinyUrl
|
6
|
-
def self.tinify(url)
|
6
|
+
def self.tinify(url, op=nil)
|
7
7
|
|
8
8
|
uri = URI.parse "http://tinyurl.com/api-create.php?url=http://#{url}"
|
9
9
|
http = Net::HTTP.new(uri.host, uri.port)
|
@@ -14,9 +14,13 @@ module TinyUrl
|
|
14
14
|
Clipboard.copy tiny_url
|
15
15
|
|
16
16
|
puts "Copied tiny url to clipboard!"
|
17
|
-
puts "The generated tiny url is #{tiny_url}
|
18
|
-
|
19
|
-
|
17
|
+
puts "The generated tiny url is #{tiny_url}" if op.nil?
|
18
|
+
|
19
|
+
if op
|
20
|
+
puts "The generated tiny url is #{tiny_url}, you're gonna see the page..."
|
21
|
+
sleep 1
|
22
|
+
`open #{tiny_url}`
|
23
|
+
end
|
20
24
|
end
|
21
25
|
|
22
26
|
def self.silently_tinify(url)
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require File.expand_path('spec/spec_helper')
|
2
|
+
|
3
|
+
describe TinyUrl do
|
4
|
+
|
5
|
+
it "has a version" do
|
6
|
+
TinyUrl::VERSION.should =~ /^\d+\.\d+\.\d+$/
|
7
|
+
end
|
8
|
+
|
9
|
+
it "can tinify url" do
|
10
|
+
url = TinyUrl.silently_tinify "google.com"
|
11
|
+
url.should_not be_nil
|
12
|
+
end
|
13
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tiny_url
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2012-01-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: clipboard
|
16
|
-
requirement: &
|
16
|
+
requirement: &70107717076440 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70107717076440
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rspec
|
27
|
-
requirement: &
|
27
|
+
requirement: &70107717075940 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '2'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70107717075940
|
36
36
|
description: A gem for tinifying urls. With a command-line interface.
|
37
37
|
email:
|
38
38
|
- rodrigovieira1994@gmail.com
|
@@ -48,6 +48,8 @@ files:
|
|
48
48
|
- bin/tiny_url
|
49
49
|
- lib/tiny_url.rb
|
50
50
|
- lib/tiny_url/version.rb
|
51
|
+
- spec/spec_helper.rb
|
52
|
+
- spec/tiny_url_spec.rb
|
51
53
|
- tiny_url.gemspec
|
52
54
|
homepage: http://rodrigoalvesvieira.com/tiny_url
|
53
55
|
licenses: []
|
@@ -69,8 +71,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
69
71
|
version: '0'
|
70
72
|
requirements: []
|
71
73
|
rubyforge_project: tiny_url
|
72
|
-
rubygems_version: 1.8.
|
74
|
+
rubygems_version: 1.8.13
|
73
75
|
signing_key:
|
74
76
|
specification_version: 3
|
75
77
|
summary: A gem for tinifying urls
|
76
|
-
test_files:
|
78
|
+
test_files:
|
79
|
+
- spec/spec_helper.rb
|
80
|
+
- spec/tiny_url_spec.rb
|