googl 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem "httparty", "~> 0.6.1"
4
+
5
+ group :development do
6
+ gem "rspec", "~> 2.3.0"
7
+ gem "bundler", "~> 1.0.0"
8
+ gem "jeweler", "~> 1.5.2"
9
+ gem "rcov", ">= 0"
10
+ gem "fakeweb", "~> 1.3.0"
11
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,34 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ crack (0.1.8)
5
+ diff-lcs (1.1.2)
6
+ fakeweb (1.3.0)
7
+ git (1.2.5)
8
+ httparty (0.6.1)
9
+ crack (= 0.1.8)
10
+ jeweler (1.5.2)
11
+ bundler (~> 1.0.0)
12
+ git (>= 1.2.5)
13
+ rake
14
+ rake (0.8.7)
15
+ rcov (0.9.9)
16
+ rspec (2.3.0)
17
+ rspec-core (~> 2.3.0)
18
+ rspec-expectations (~> 2.3.0)
19
+ rspec-mocks (~> 2.3.0)
20
+ rspec-core (2.3.1)
21
+ rspec-expectations (2.3.0)
22
+ diff-lcs (~> 1.1.2)
23
+ rspec-mocks (2.3.0)
24
+
25
+ PLATFORMS
26
+ ruby
27
+
28
+ DEPENDENCIES
29
+ bundler (~> 1.0.0)
30
+ fakeweb (~> 1.3.0)
31
+ httparty (~> 0.6.1)
32
+ jeweler (~> 1.5.2)
33
+ rcov
34
+ rspec (~> 2.3.0)
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2010 Zigotto®. http://www.zigotto.com.br
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,30 @@
1
+ = googl
2
+
3
+ Google URL Shortener API in Ruby
4
+
5
+ == Basic Usage
6
+
7
+ === Shorten a long URL
8
+
9
+ url = Googl.shorten('http://www.zigotto.com')
10
+
11
+ url.short_url
12
+ => "http://goo.gl/ump4S"
13
+
14
+ url.long_url
15
+ => "http://www.zigotto.com/"
16
+
17
+ === Expand a short URL
18
+
19
+ url = Googl.expand('http://goo.gl/ump4S')
20
+
21
+ url.long_url
22
+ => "http://www.zigotto.com/"
23
+
24
+ == Installation
25
+
26
+ gem install googl
27
+
28
+ == License
29
+
30
+ MIT License. Copyright 2010 Zigotto®. http://www.zigotto.com.br
data/Rakefile CHANGED
@@ -1,48 +1,50 @@
1
1
  require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
2
10
  require 'rake'
3
- require 'rake/rdoctask'
4
- require 'rake/gempackagetask'
5
-
6
- require 'rspec/core/rake_task'
7
11
 
8
- RSpec::Core::RakeTask.new :spec do |t|
9
- t.rspec_opts = %w(-fp --color)
12
+ require 'jeweler'
13
+ Jeweler::Tasks.new do |gem|
14
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
15
+ gem.name = "googl"
16
+ gem.homepage = "http://github.com/zigotto/googl"
17
+ gem.license = "MIT"
18
+ gem.summary = %Q{Wrapper for Google URL Shortener API}
19
+ gem.description = %Q{Small library for Google URL Shortener API}
20
+ gem.email = "jlopes@zigotto.com.br"
21
+ gem.authors = ["Jesus Lopes"]
22
+ # Include your dependencies below. Runtime dependencies are required when using your gem,
23
+ # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
24
+ gem.add_dependency 'httparty', '> 0.6.1'
10
25
  end
26
+ Jeweler::RubygemsDotOrgTasks.new
11
27
 
12
- Rake::RDocTask.new(:rdoc) do |rdoc|
13
- rdoc.rdoc_dir = 'rdoc'
14
- rdoc.title = 'googl'
15
- rdoc.options << '--line-numbers' << '--inline-source'
16
- rdoc.rdoc_files.include('README.rdoc')
17
- rdoc.rdoc_files.include('lib/**/*.rb')
28
+ require 'rspec/core'
29
+ require 'rspec/core/rake_task'
30
+ RSpec::Core::RakeTask.new(:spec) do |spec|
31
+ spec.pattern = FileList['spec/**/*_spec.rb']
32
+ spec.rspec_opts = %w(-fp --color)
18
33
  end
19
34
 
20
- spec = Gem::Specification.new do |s|
21
- s.name = "googl"
22
- s.version = "0.0.1"
23
- s.summary = "Wrapper for Google URL Shortener API"
24
- s.description = "Small library for Google URL Shortener API"
25
- s.files = FileList['lib/**/*', '[A-Z]*'].to_a
26
- s.author = "Jésus Lopes"
27
- s.email = "jlopes@zigotto.com"
28
- s.homepage = "http://zigotto.com"
29
- s.add_dependency('httparty', '>= 0.6.1')
30
- s.add_development_dependency "rspec", ">= 2.0.0"
31
- s.add_development_dependency "fakeweb"
35
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
36
+ spec.pattern = 'spec/**/*_spec.rb'
37
+ spec.rcov = true
32
38
  end
33
39
 
34
- Rake::GemPackageTask.new(spec) do |pkg|
35
- pkg.gem_spec = spec
36
- end
40
+ task :default => :spec
37
41
 
38
- desc "Install the gem #{spec.name}-#{spec.version}.gem"
39
- task :install do
40
- system("gem install pkg/#{spec.name}-#{spec.version}.gem --no-ri --no-rdoc")
41
- end
42
+ require 'rake/rdoctask'
43
+ Rake::RDocTask.new do |rdoc|
44
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
42
45
 
43
- desc "Create a gemspec file"
44
- task :make_spec do
45
- File.open("#{spec.name}.gemspec", "w") do |file|
46
- file.puts spec.to_ruby
47
- end
46
+ rdoc.rdoc_dir = 'rdoc'
47
+ rdoc.title = "googl #{version}"
48
+ rdoc.rdoc_files.include('README*')
49
+ rdoc.rdoc_files.include('lib/**/*.rb')
48
50
  end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
data/googl.gemspec ADDED
@@ -0,0 +1,77 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{googl}
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Jesus Lopes"]
12
+ s.date = %q{2011-01-11}
13
+ s.description = %q{Small library for Google URL Shortener API}
14
+ s.email = %q{jlopes@zigotto.com.br}
15
+ s.extra_rdoc_files = [
16
+ "README.rdoc"
17
+ ]
18
+ s.files = [
19
+ "Gemfile",
20
+ "Gemfile.lock",
21
+ "MIT-LICENSE",
22
+ "README.rdoc",
23
+ "Rakefile",
24
+ "VERSION",
25
+ "googl.gemspec",
26
+ "lib/googl.rb",
27
+ "lib/googl/expand.rb",
28
+ "lib/googl/request.rb",
29
+ "lib/googl/shorten.rb",
30
+ "spec/expand_spec.rb",
31
+ "spec/fixtures/expand.json",
32
+ "spec/fixtures/shorten.json",
33
+ "spec/shorten_spec.rb",
34
+ "spec/spec_helper.rb"
35
+ ]
36
+ s.homepage = %q{http://github.com/zigotto/googl}
37
+ s.licenses = ["MIT"]
38
+ s.require_paths = ["lib"]
39
+ s.rubygems_version = %q{1.4.2}
40
+ s.summary = %q{Wrapper for Google URL Shortener API}
41
+ s.test_files = [
42
+ "spec/expand_spec.rb",
43
+ "spec/shorten_spec.rb",
44
+ "spec/spec_helper.rb"
45
+ ]
46
+
47
+ if s.respond_to? :specification_version then
48
+ s.specification_version = 3
49
+
50
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
51
+ s.add_runtime_dependency(%q<httparty>, ["~> 0.6.1"])
52
+ s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
53
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
54
+ s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
55
+ s.add_development_dependency(%q<rcov>, [">= 0"])
56
+ s.add_development_dependency(%q<fakeweb>, ["~> 1.3.0"])
57
+ s.add_runtime_dependency(%q<httparty>, ["> 0.6.1"])
58
+ else
59
+ s.add_dependency(%q<httparty>, ["~> 0.6.1"])
60
+ s.add_dependency(%q<rspec>, ["~> 2.3.0"])
61
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
62
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
63
+ s.add_dependency(%q<rcov>, [">= 0"])
64
+ s.add_dependency(%q<fakeweb>, ["~> 1.3.0"])
65
+ s.add_dependency(%q<httparty>, ["> 0.6.1"])
66
+ end
67
+ else
68
+ s.add_dependency(%q<httparty>, ["~> 0.6.1"])
69
+ s.add_dependency(%q<rspec>, ["~> 2.3.0"])
70
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
71
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
72
+ s.add_dependency(%q<rcov>, [">= 0"])
73
+ s.add_dependency(%q<fakeweb>, ["~> 1.3.0"])
74
+ s.add_dependency(%q<httparty>, ["> 0.6.1"])
75
+ end
76
+ end
77
+
data/lib/googl.rb CHANGED
@@ -4,3 +4,15 @@ require 'httparty'
4
4
  require 'googl/request'
5
5
  require 'googl/shorten'
6
6
  require 'googl/expand'
7
+
8
+ module Googl
9
+
10
+ def self.shorten(url)
11
+ Googl::Shorten.new(url)
12
+ end
13
+
14
+ def self.expand(url)
15
+ Googl::Expand.new(url)
16
+ end
17
+
18
+ end
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ describe Googl::Expand do
4
+
5
+ before :each do
6
+ fake_urls
7
+ end
8
+
9
+ context "when expand any goo.gl short URL" do
10
+
11
+ it { Googl.should respond_to(:expand) }
12
+
13
+ subject { Googl.expand('http://goo.gl/7lob') }
14
+
15
+ describe "#long_url" do
16
+ it "should return a long url" do
17
+ subject.long_url.should == 'http://jlopes.zigotto.com.br/'
18
+ end
19
+ end
20
+
21
+ end
22
+
23
+
24
+ end
@@ -0,0 +1,18 @@
1
+ HTTP/1.1 200 OK
2
+ ETag: "EEZ1AD443JkEgW3KJFaymzTd26A/wKW1RiLjLbyUh3AbmrhLHKj0R24"
3
+ Expires: Tue, 11 Jan 2011 21:49:04 GMT
4
+ Date: Tue, 11 Jan 2011 21:44:04 GMT
5
+ Cache-Control: public, max-age=300, must-revalidate, no-transform
6
+ Content-Type: application/json; charset=UTF-8
7
+ X-Content-Type-Options: nosniff
8
+ X-Frame-Options: SAMEORIGIN
9
+ X-XSS-Protection: 1; mode=block
10
+ Server: GSE
11
+ Transfer-Encoding: chunked
12
+
13
+ {
14
+ "kind": "urlshortener#url",
15
+ "id": "http://goo.gl/7lob",
16
+ "longUrl": "http://jlopes.zigotto.com.br/",
17
+ "status": "OK"
18
+ }
@@ -0,0 +1,18 @@
1
+ HTTP/1.1 200 OK
2
+ ETag: "EEZ1AD443JkEgW3KJFaymzTd26A/1axClUUG_6eCdLbWHvqnOKYu85E"
3
+ Cache-Control: no-cache, no-store, max-age=0, must-revalidate
4
+ Pragma: no-cache
5
+ Expires: Fri, 01 Jan 1990 00:00:00 GMT
6
+ Date: Tue, 11 Jan 2011 21:26:33 GMT
7
+ Content-Type: application/json; charset=UTF-8
8
+ X-Content-Type-Options: nosniff
9
+ X-Frame-Options: SAMEORIGIN
10
+ X-XSS-Protection: 1; mode=block
11
+ Server: GSE
12
+ Transfer-Encoding: chunked
13
+
14
+ {
15
+ "kind": "urlshortener#url",
16
+ "id": "http://goo.gl/ump4S",
17
+ "longUrl": "http://www.zigotto.com/"
18
+ }
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ describe Googl::Shorten do
4
+
5
+ before :each do
6
+ fake_urls
7
+ end
8
+
9
+ context "when request new short url" do
10
+
11
+ it { Googl.should respond_to(:shorten) }
12
+
13
+ subject { Googl.shorten('http://www.zigotto.com') }
14
+
15
+ describe "#short_url" do
16
+ it "should return a short URL" do
17
+ subject.short_url.should == 'http://goo.gl/ump4S'
18
+ end
19
+ end
20
+
21
+ describe "#long_url" do
22
+ it "should return a long url" do
23
+ subject.long_url.should == 'http://www.zigotto.com/'
24
+ end
25
+ end
26
+
27
+ end
28
+
29
+ end
@@ -0,0 +1,27 @@
1
+ require "rubygems"
2
+ require "rspec"
3
+ require 'fakeweb'
4
+
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__)))
6
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
7
+
8
+ require 'googl'
9
+
10
+ def load_fixture(name)
11
+ File.join(File.expand_path(File.dirname(__FILE__)), '/fixtures', name)
12
+ end
13
+
14
+ def fake_urls
15
+
16
+ FakeWeb.allow_net_connect = false
17
+
18
+ # Shorten
19
+ url = "https://www.googleapis.com/urlshortener/v1/url"
20
+ options = {"longUrl" => "http://www.zigotto.com"}.inspect
21
+ FakeWeb.register_uri(:post, url, :response => load_fixture('shorten.json'), :body => options)
22
+
23
+ # Expand
24
+ url = "https://www.googleapis.com/urlshortener/v1/url?shortUrl=http://goo.gl/7lob"
25
+ FakeWeb.register_uri(:get, url, :response => load_fixture('expand.json'))
26
+
27
+ end
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: googl
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
5
- prerelease: false
4
+ hash: 27
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
- - 0
9
8
  - 1
10
- version: 0.0.1
9
+ - 0
10
+ version: 0.1.0
11
11
  platform: ruby
12
12
  authors:
13
- - "J\xC3\xA9sus Lopes"
13
+ - Jesus Lopes
14
14
  autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
@@ -19,12 +19,13 @@ date: 2011-01-11 00:00:00 -02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- name: httparty
23
22
  prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
23
+ name: httparty
24
+ type: :runtime
25
+ version_requirements: &id001 !ruby/object:Gem::Requirement
25
26
  none: false
26
27
  requirements:
27
- - - ">="
28
+ - - ~>
28
29
  - !ruby/object:Gem::Version
29
30
  hash: 5
30
31
  segments:
@@ -32,28 +33,60 @@ dependencies:
32
33
  - 6
33
34
  - 1
34
35
  version: 0.6.1
35
- type: :runtime
36
- version_requirements: *id001
36
+ requirement: *id001
37
37
  - !ruby/object:Gem::Dependency
38
- name: rspec
39
38
  prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
39
+ name: rspec
40
+ type: :development
41
+ version_requirements: &id002 !ruby/object:Gem::Requirement
41
42
  none: false
42
43
  requirements:
43
- - - ">="
44
+ - - ~>
44
45
  - !ruby/object:Gem::Version
45
- hash: 15
46
+ hash: 3
46
47
  segments:
47
48
  - 2
49
+ - 3
50
+ - 0
51
+ version: 2.3.0
52
+ requirement: *id002
53
+ - !ruby/object:Gem::Dependency
54
+ prerelease: false
55
+ name: bundler
56
+ type: :development
57
+ version_requirements: &id003 !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ~>
61
+ - !ruby/object:Gem::Version
62
+ hash: 23
63
+ segments:
64
+ - 1
48
65
  - 0
49
66
  - 0
50
- version: 2.0.0
67
+ version: 1.0.0
68
+ requirement: *id003
69
+ - !ruby/object:Gem::Dependency
70
+ prerelease: false
71
+ name: jeweler
51
72
  type: :development
52
- version_requirements: *id002
73
+ version_requirements: &id004 !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ~>
77
+ - !ruby/object:Gem::Version
78
+ hash: 7
79
+ segments:
80
+ - 1
81
+ - 5
82
+ - 2
83
+ version: 1.5.2
84
+ requirement: *id004
53
85
  - !ruby/object:Gem::Dependency
54
- name: fakeweb
55
86
  prerelease: false
56
- requirement: &id003 !ruby/object:Gem::Requirement
87
+ name: rcov
88
+ type: :development
89
+ version_requirements: &id005 !ruby/object:Gem::Requirement
57
90
  none: false
58
91
  requirements:
59
92
  - - ">="
@@ -62,26 +95,68 @@ dependencies:
62
95
  segments:
63
96
  - 0
64
97
  version: "0"
98
+ requirement: *id005
99
+ - !ruby/object:Gem::Dependency
100
+ prerelease: false
101
+ name: fakeweb
65
102
  type: :development
66
- version_requirements: *id003
103
+ version_requirements: &id006 !ruby/object:Gem::Requirement
104
+ none: false
105
+ requirements:
106
+ - - ~>
107
+ - !ruby/object:Gem::Version
108
+ hash: 27
109
+ segments:
110
+ - 1
111
+ - 3
112
+ - 0
113
+ version: 1.3.0
114
+ requirement: *id006
115
+ - !ruby/object:Gem::Dependency
116
+ prerelease: false
117
+ name: httparty
118
+ type: :runtime
119
+ version_requirements: &id007 !ruby/object:Gem::Requirement
120
+ none: false
121
+ requirements:
122
+ - - ">"
123
+ - !ruby/object:Gem::Version
124
+ hash: 5
125
+ segments:
126
+ - 0
127
+ - 6
128
+ - 1
129
+ version: 0.6.1
130
+ requirement: *id007
67
131
  description: Small library for Google URL Shortener API
68
- email: jlopes@zigotto.com
132
+ email: jlopes@zigotto.com.br
69
133
  executables: []
70
134
 
71
135
  extensions: []
72
136
 
73
- extra_rdoc_files: []
74
-
137
+ extra_rdoc_files:
138
+ - README.rdoc
75
139
  files:
140
+ - Gemfile
141
+ - Gemfile.lock
142
+ - MIT-LICENSE
143
+ - README.rdoc
144
+ - Rakefile
145
+ - VERSION
146
+ - googl.gemspec
147
+ - lib/googl.rb
76
148
  - lib/googl/expand.rb
77
149
  - lib/googl/request.rb
78
150
  - lib/googl/shorten.rb
79
- - lib/googl.rb
80
- - Rakefile
151
+ - spec/expand_spec.rb
152
+ - spec/fixtures/expand.json
153
+ - spec/fixtures/shorten.json
154
+ - spec/shorten_spec.rb
155
+ - spec/spec_helper.rb
81
156
  has_rdoc: true
82
- homepage: http://zigotto.com
83
- licenses: []
84
-
157
+ homepage: http://github.com/zigotto/googl
158
+ licenses:
159
+ - MIT
85
160
  post_install_message:
86
161
  rdoc_options: []
87
162
 
@@ -108,9 +183,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
183
  requirements: []
109
184
 
110
185
  rubyforge_project:
111
- rubygems_version: 1.3.7
186
+ rubygems_version: 1.4.2
112
187
  signing_key:
113
188
  specification_version: 3
114
189
  summary: Wrapper for Google URL Shortener API
115
- test_files: []
116
-
190
+ test_files:
191
+ - spec/expand_spec.rb
192
+ - spec/shorten_spec.rb
193
+ - spec/spec_helper.rb