alexgregianin-knock-knock 0.1.0

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.
Files changed (6) hide show
  1. data/README +10 -0
  2. data/Rakefile +15 -0
  3. data/knock-knock.gemspec +29 -0
  4. data/lib/hash.rb +7 -0
  5. data/lib/knock.rb +56 -0
  6. metadata +65 -0
data/README ADDED
@@ -0,0 +1,10 @@
1
+ Knock-Knock!
2
+
3
+ Get to use Google APIS!Are you having a hard time to authenticate your plugin/gem on any of the google apis currently released?
4
+
5
+
6
+ use knock-knock the easiest the way go to google and let them open the door for you!
7
+
8
+ Knock-knock is brought to you by Bubble :) Fun coding for free!
9
+
10
+
@@ -0,0 +1,15 @@
1
+ # Rakefile
2
+ require 'rubygems'
3
+ require 'rake'
4
+ require 'echoe'
5
+
6
+ Echoe.new('knock-knock', '0.1.0') do |p|
7
+ p.description = "Google Data Api ClientLogin Auth in Ruby"
8
+ p.url = "http://github.com/alexgregianin/knock-knock"
9
+ p.author = "Alex Gregianin"
10
+ p.email = "alexandre@bubble.com.br"
11
+ p.development_dependencies = []
12
+ end
13
+
14
+ Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
15
+
@@ -0,0 +1,29 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = %q{knock-knock}
3
+ s.version = "0.1.0"
4
+
5
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
6
+ s.authors = ["Alex Gregianin"]
7
+ s.date = %q{2008-12-02}
8
+ s.description = %q{Google Data Api ClientLogin Auth in Ruby}
9
+ s.email = %q{alexandre@bubble.com.br}
10
+ s.extra_rdoc_files = ["lib/hash.rb", "lib/knock.rb", "README"]
11
+ s.files = ["lib/hash.rb", "lib/knock.rb", "Rakefile", "README", "Manifest", "knock-knock.gemspec"]
12
+ s.has_rdoc = true
13
+ s.homepage = %q{http://github.com/alexgregianin/knock-knock}
14
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Knock-knock", "--main", "README"]
15
+ s.require_paths = ["lib"]
16
+ s.rubyforge_project = %q{knock-knock}
17
+ s.rubygems_version = %q{1.2.0}
18
+ s.summary = %q{Google Data Api ClientLogin Auth in Ruby}
19
+
20
+ if s.respond_to? :specification_version then
21
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
22
+ s.specification_version = 2
23
+
24
+ if current_version >= 3 then
25
+ else
26
+ end
27
+ else
28
+ end
29
+ end
@@ -0,0 +1,7 @@
1
+ class Hash
2
+
3
+ def to_get
4
+ "?" + self.collect { |k,v| "#{k.to_s}=#{v}" }.join("&")
5
+ end
6
+
7
+ end
@@ -0,0 +1,56 @@
1
+ require 'uri'
2
+ require 'net/https'
3
+ require 'net/http'
4
+ require 'hash'
5
+
6
+ class Knock
7
+
8
+ GOOGLE = "https://www.google.com:443/accounts/ClientLogin"
9
+ APP_NAME = "Knock-Knock Ruby Gem"
10
+
11
+ def self.connect user,password,serv
12
+ @confs = { 'accountType' => 'GOOGLE',
13
+ 'Email' => user,
14
+ 'Passwd' => password,
15
+ 'service' => serv,
16
+ 'source' => APP_NAME }
17
+
18
+ @@token = login
19
+ end
20
+
21
+ def self.login
22
+ url = URI.parse(GOOGLE)
23
+ req = Net::HTTP::Post.new(url.path)
24
+ req.set_form_data(@confs)
25
+ res = Net::HTTP.new(url.host, url.port)
26
+ res.use_ssl = true
27
+ body = res.start {|http| http.request(req) }
28
+ body.body.split("\n").last.gsub("Auth=",'')
29
+ end
30
+
31
+ ## ClientLogin Authentication requires the Auth property not the SID or LSID ones.
32
+ ## Along with the Content-Lenght(that must exists!) goes the Auth on the header of every request the library does
33
+ ## to Google.
34
+ def self.header
35
+ {'Cookie' => "Name=#{@@token};Auth=#{@@token};Domain=.google.com;Path=/;Expires=160000000000",
36
+ 'Content-length' => '0',
37
+ 'Authorization' => "GoogleLogin auth=#{@@token}"}
38
+ end
39
+
40
+ def self.token
41
+ @@token
42
+ end
43
+
44
+ def self.get url,params
45
+ uri = URI.parse(url)
46
+ res = Net::HTTP::Get.new(uri.request_uri,header)
47
+ http = Net::HTTP.new(uri.host, uri.port)
48
+ http.use_ssl = true
49
+ result = http.start() { |conn| conn.request(res) }
50
+ result.body
51
+ end
52
+
53
+ end
54
+
55
+
56
+
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: alexgregianin-knock-knock
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Alex Gregianin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-12-02 00:00:00 -08:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: Google Data Api ClientLogin Auth in Ruby
17
+ email: alexandre@bubble.com.br
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - lib/hash.rb
24
+ - lib/knock.rb
25
+ - README
26
+ files:
27
+ - lib/hash.rb
28
+ - lib/knock.rb
29
+ - Rakefile
30
+ - README
31
+ - Manifest
32
+ - knock-knock.gemspec
33
+ has_rdoc: true
34
+ homepage: http://github.com/alexgregianin/knock-knock
35
+ post_install_message:
36
+ rdoc_options:
37
+ - --line-numbers
38
+ - --inline-source
39
+ - --title
40
+ - Knock-knock
41
+ - --main
42
+ - README
43
+ require_paths:
44
+ - lib
45
+ required_ruby_version: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: "0"
50
+ version:
51
+ required_rubygems_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: "1.2"
56
+ version:
57
+ requirements: []
58
+
59
+ rubyforge_project: knock-knock
60
+ rubygems_version: 1.2.0
61
+ signing_key:
62
+ specification_version: 2
63
+ summary: Google Data Api ClientLogin Auth in Ruby
64
+ test_files: []
65
+