Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make it work again, use gemspec #1

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions History.txt
@@ -1,3 +1,4 @@
* 0.2.1 - make it work again, remove hoe, tasks and scripts and add gemspec
* 0.2.0 - added ssl support for requests
* 0.1.3 - addded URI.escape around the built urls that are being requested
* 0.1.2 - added raw_data option to post method
Expand Down
3 changes: 2 additions & 1 deletion README.txt
Expand Up @@ -2,7 +2,8 @@ Google Base Class is a base for authenticating to google and making requests to

=Installation

sudo gem install googlebase
in your Gemfile
gem 'googlebase', :require => "google/base", :git => 'https://github.com/jotto/googlebase.git'

=Usage

Expand Down
71 changes: 0 additions & 71 deletions config/hoe.rb

This file was deleted.

17 changes: 0 additions & 17 deletions config/requirements.rb

This file was deleted.

17 changes: 17 additions & 0 deletions googlebase.gemspec
@@ -0,0 +1,17 @@


Gem::Specification.new do |s|
s.name = "googlebase"
s.version = "0.2.2"
s.platform = Gem::Platform::RUBY
s.authors = ["John Nunemaker"]
s.email = ["nunemaker@gmail.com"]
s.homepage = "https://github.com/jnunemaker/googlebase"
s.summary = "Base class which handles authentication and requests for google services"

s.required_rubygems_version = ">= 1.3.6"
s.rubyforge_project = "googlebase"

s.files = Dir.glob("{lib}/**/*") + %w(License.txt README.txt Manifest.txt History.txt)
s.require_path = 'lib'
end
17 changes: 12 additions & 5 deletions lib/google/base.rb
Expand Up @@ -17,8 +17,8 @@ class Base
#
# Raises Google::LoginError if login fails or if, god forbid,
# google is having issues.
def self.establish_connection(email, password)
@@connection = new(email, password)
def self.establish_connection(email, password,service="")
@@connection = new(email, password,service)
end

# Returns the current connection
Expand Down Expand Up @@ -83,8 +83,8 @@ def self.post(url, o={})

# Creates a new instance of the connection class using
# the given email and password and attempts to login
def initialize(email, password)
@email, @password = email, password
def initialize(email, password ,service)
@email, @password, @service = email, password, service
login
end

Expand All @@ -101,11 +101,13 @@ def login
'Passwd' => @password,
'source' => SOURCE,
'continue' => URL,
'service' => @service,
})
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
result = http.start() { |conn| conn.request(req) }
@sid = extract_sid(result.body)
@auth = extract_auth(result.body)
raise LoginError, "Most likely your username and password are wrong." unless logged_in?
end

Expand All @@ -116,7 +118,7 @@ def logged_in?

# Outputs the headers that are needed to make an authenticated request
def headers
{'Cookie' => "Name=#{@sid};SID=#{@sid};Domain=.google.com;Path=/;Expires=160000000000"}
{'Authorization' => "GoogleLogin auth=#{@auth}"}
end

private
Expand Down Expand Up @@ -155,5 +157,10 @@ def extract_sid(body)
matches = body.match(/SID=(.*)/)
matches.nil? ? nil : matches[0].gsub('SID=', '')
end

def extract_auth(body)
matches = body.match(/Auth=(.*)/)
matches.nil? ? nil : matches[0].gsub('Auth=', '')
end
end
end
9 changes: 0 additions & 9 deletions lib/google/version.rb

This file was deleted.

14 changes: 0 additions & 14 deletions script/destroy

This file was deleted.

14 changes: 0 additions & 14 deletions script/generate

This file was deleted.

34 changes: 0 additions & 34 deletions tasks/deployment.rake

This file was deleted.

7 changes: 0 additions & 7 deletions tasks/environment.rake

This file was deleted.

14 changes: 0 additions & 14 deletions tasks/website.rake

This file was deleted.