tiny_url 0.0.1 → 0.0.2

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 ADDED
@@ -0,0 +1,42 @@
1
+ = tiny_url
2
+
3
+ A gem for tinifying urls
4
+
5
+ == Installation
6
+
7
+ $ gem install tiny_url
8
+
9
+ Or in the Gemfile
10
+
11
+ gem "tiny_url"
12
+
13
+ == Usage
14
+
15
+ $ tiny_url http://accidentalchinesehipsters.tumblr.com/
16
+
17
+ On Rails:
18
+
19
+ TinyUrl.silently_tinify "http://thereifixedit.failblog.org/"
20
+
21
+ == Licence
22
+
23
+ Copyright 2011 Rodrigo Vieira. http://www.rodrigoalvesvieira.com
24
+
25
+ Permission is hereby granted, free of charge, to any person obtaining
26
+ a copy of this software and associated documentation files (the
27
+ "Software"), to deal in the Software without restriction, including
28
+ without limitation the rights to use, copy, modify, merge, publish,
29
+ distribute, sublicense, and/or sell copies of the Software, and to
30
+ permit persons to whom the Software is furnished to do so, subject to
31
+ the following conditions:
32
+
33
+ The above copyright notice and this permission notice shall be
34
+ included in all copies or substantial portions of the Software.
35
+
36
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
37
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
38
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
39
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
40
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
41
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
42
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile CHANGED
@@ -1 +1,15 @@
1
- require "bundler/gem_tasks"
1
+ #require "bundler/gem_tasks"
2
+
3
+ require 'rake'
4
+ require 'rdoc/task'
5
+ require 'fileutils'
6
+
7
+ task :test => :spec
8
+
9
+ task :default => :spec
10
+
11
+ require "rspec/core/rake_task"
12
+ RSpec::Core::RakeTask.new(:spec) do |t|
13
+ t.rspec_opts = '--backtrace --color'
14
+ end
15
+
data/bin/tiny_url ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
4
+
5
+ require 'tiny_url'
6
+
7
+ if ARGV.size != 1
8
+ puts "specify *ONE* the url to be tinified"
9
+ else
10
+ TinyUrl.tinify(ARGV[0])
11
+ end
@@ -1,3 +1,3 @@
1
1
  module TinyUrl
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/tiny_url.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require "tiny_url/version"
2
- require 'net/http'
2
+ require "net/http"
3
+ require "clipboard"
3
4
 
4
5
  module TinyUrl
5
6
  def self.tinify(url)
@@ -7,12 +8,22 @@ module TinyUrl
7
8
  uri = URI.parse "http://tinyurl.com/api-create.php?url=http://#{url}"
8
9
  http = Net::HTTP.new(uri.host, uri.port)
9
10
  request = Net::HTTP::Get.new(uri.request_uri)
10
-
11
11
  response = http.request(request)
12
-
13
12
  tiny_url = response.body
13
+
14
+ Clipboard.copy tiny_url
15
+
16
+ puts "Copied tiny url to clipboard!"
14
17
  puts "The generated tiny url is #{tiny_url}, you're gonna see the page..."
15
18
  sleep 1
16
19
  `open #{tiny_url}`
17
20
  end
21
+
22
+ def self.silently_tinify(url)
23
+ uri = URI.parse "http://tinyurl.com/api-create.php?url=http://#{url}"
24
+ http = Net::HTTP.new(uri.host, uri.port)
25
+ request = Net::HTTP::Get.new(uri.request_uri)
26
+ response = http.request(request)
27
+ tiny_url = response.body
28
+ end
18
29
  end
data/tiny_url.gemspec CHANGED
@@ -5,16 +5,18 @@ require "tiny_url/version"
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "tiny_url"
7
7
  s.version = TinyUrl::VERSION
8
- s.authors = ["Rodrigo Alves Vieira"]
8
+ s.authors = ["Rodrigo Vieira"]
9
9
  s.email = ["rodrigovieira1994@gmail.com"]
10
10
  s.homepage = "http://rodrigoalvesvieira.com/tiny_url"
11
11
  s.summary = %q{A gem for tinifying urls}
12
- s.description = %q{A gem for tinifying urls}
12
+ s.description = %q{A gem for tinifying urls. With a command-line interface.}
13
13
 
14
14
  s.rubyforge_project = "tiny_url"
15
15
 
16
16
  s.files = `git ls-files`.split("\n")
17
17
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
+ s.executables = ["tiny_url"]
19
19
  s.require_paths = ["lib"]
20
+ s.add_dependency("clipboard")
21
+ s.add_dependency("rspec", ">=2")
20
22
  end
metadata CHANGED
@@ -1,26 +1,51 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tiny_url
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
8
- - Rodrigo Alves Vieira
8
+ - Rodrigo Vieira
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
  date: 2011-12-12 00:00:00.000000000 Z
13
- dependencies: []
14
- description: A gem for tinifying urls
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: clipboard
16
+ requirement: &70095099646580 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70095099646580
25
+ - !ruby/object:Gem::Dependency
26
+ name: rspec
27
+ requirement: &70095099645760 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '2'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70095099645760
36
+ description: A gem for tinifying urls. With a command-line interface.
15
37
  email:
16
38
  - rodrigovieira1994@gmail.com
17
- executables: []
39
+ executables:
40
+ - tiny_url
18
41
  extensions: []
19
42
  extra_rdoc_files: []
20
43
  files:
21
44
  - .gitignore
22
45
  - Gemfile
46
+ - README.rdoc
23
47
  - Rakefile
48
+ - bin/tiny_url
24
49
  - lib/tiny_url.rb
25
50
  - lib/tiny_url/version.rb
26
51
  - tiny_url.gemspec