knock-knock 0.1.5 → 0.1.6

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.
@@ -1,3 +1,8 @@
1
+ == 0.1.6 2008-12-24
2
+ * Refatoring
3
+ * New features
4
+ * Added Services module with Google Services code shortcuts
5
+
1
6
  == 0.1.5 2008-12-24
2
7
  * New features
3
8
  * Connection with any Google Accounts, even Hosted Google Accounts
@@ -6,7 +6,7 @@ KnockKnock was made to turn login with Google Authentication API easier.
6
6
  * Singleton class for connection with Google.
7
7
  * Simple authentication and clear code.
8
8
  * GET, POST, PUT, DELETE method implemented
9
- * Connection with any Google Account, even (Hosted Google Accounts)[http://google.com/a]
9
+ * Connection with any Google Account, even Hosted Google Accounts[http://google.com/a]
10
10
 
11
11
  == Synopsis
12
12
 
@@ -15,16 +15,20 @@ KnockKnock was made to turn login with Google Authentication API easier.
15
15
 
16
16
  include Bubble::KnockKnock
17
17
 
18
- Connection.instance.connect('email@gmail.com', 'password', 'cp')
18
+ Connection.connect('email@gmail.com', 'password', Services::GoogleContacts)
19
19
 
20
20
  print Request.get('http://www.google.com/m8/feeds/contacts/email%40gmail.com/full')
21
21
 
22
+ == Services
23
+
24
+ All the API for any Google Service works with KnockKnock. You can check the Services[http://knock-knock.rubyforge.org/rdoc/classes/Bubble/KnockKnock/Services.html] module to see some examples.
25
+
22
26
  == Install
23
27
 
24
28
  sudo gem install knock-knock
25
29
 
26
30
  == Contributors
27
- * (Jonathan Towell)[http://moxiemachine.com/blog]
31
+ * Jonathan Towell (http://moxiemachine.com/blog)
28
32
 
29
33
  == License
30
34
 
@@ -26,6 +26,16 @@ module Bubble
26
26
  # require 'knock_knock'
27
27
  #
28
28
  # Bubble::KnockKnock::Connection.connect('email@gmail.com', 'password', 'cp')
29
+ def self.connect(email, password, service)
30
+ instance.connect(email, password, service)
31
+ end
32
+
33
+ # Retrieve the Auth Token required for authentications on all Google Services.
34
+ def self.auth
35
+ instance.auth
36
+ end
37
+
38
+ # This method creates the connection, but internally. To create the connection you must use Connection.connect() method.
29
39
  def connect(email, password, service)
30
40
  @email = email
31
41
  @password = password
@@ -34,14 +44,8 @@ module Bubble
34
44
  setup
35
45
  stablish
36
46
  end
37
-
38
- # Retrieve the Auth Token required for authentications on all Google Services.
39
- def auth
40
- @auth
41
- end
42
47
 
43
48
  protected
44
-
45
49
  # It gives the correct values to attributes and variables required to make the connection.
46
50
  # You can connect with any Google Account, even it's a hosted account (thanks, Jonathan Towell)
47
51
  def setup
@@ -9,13 +9,11 @@ module Bubble
9
9
 
10
10
  # Finds the Singleton Connection and creates the header structure to requesting informations.
11
11
  def initialize
12
- raise UnstablishedConnection if Connection.instance.auth.nil?
13
-
14
- connection = Connection.instance
15
- @header = {'Cookie' => "Name=#{connection.auth};Auth=#{connection.auth};Domain=.google.com;Path=/;Expires=160000000000",
12
+ raise UnstablishedConnection if Connection.auth.nil?
13
+
14
+ @header = {'Cookie' => "Name=#{Connection.auth};Auth=#{Connection.auth};Domain=.google.com;Path=/;Expires=160000000000",
16
15
  'Content-length' => '0',
17
- 'Authorization' => "GoogleLogin auth=#{connection.auth}"
18
- }
16
+ 'Authorization' => "GoogleLogin auth=#{Connection.auth}" }
19
17
  end
20
18
 
21
19
  # Get the data from any Google Service.
@@ -0,0 +1,36 @@
1
+ module Bubble
2
+ module KnockKnock
3
+
4
+ # This module helps the developer to use many Google Services
5
+ module Services
6
+
7
+ # http://code.google.com/apis/contacts/docs/2.0/developers_guide_protocol.html#client_login
8
+ GoogleContacts = 'cp'
9
+
10
+ # http://code.google.com/apis/calendar/docs/2.0/developers_guide_protocol.html#AuthClientLogin
11
+ GoogleCalendar = 'cl'
12
+
13
+ # http://code.google.com/apis/apps/gdata_provisioning_api_v2.0_reference.html#Authentication
14
+ GoogleApps = 'apps'
15
+
16
+ # http://code.google.com/apis/finance/developers_guide_protocol.html#ClientLogin
17
+ GoogleFinance = 'finance'
18
+
19
+ # http://code.google.com/apis/spreadsheets/docs/2.0/developers_guide_protocol.html#Authenticating
20
+ GoogleSpreadsheets = 'wise'
21
+
22
+ # http://code.google.com/apis/documents/docs/2.0/developers_guide_protocol.html#AuthClientLogin
23
+ GoogleDocuments = 'writely'
24
+
25
+ # http://code.google.com/apis/blogger/docs/2.0/developers_guide_protocol.html#ClientLogin
26
+ Blogger = 'blogger'
27
+
28
+ # http://code.google.com/apis/youtube/2.0/developers_guide_protocol_clientlogin.html#ClientLogin_Authentication
29
+ Youtube = 'youtube'
30
+
31
+ # http://code.google.com/apis/picasaweb/developers_guide_protocol.html#ClientLogin
32
+ Picasa = 'picasa'
33
+
34
+ end
35
+ end
36
+ end
@@ -9,12 +9,13 @@ module Bubble
9
9
 
10
10
  # For more information take a look at the README
11
11
  module KnockKnock
12
- VERSION = '0.1.5'
12
+ VERSION = '0.1.6'
13
13
  APP_NAME = 'KnockKnock Ruby Gem'
14
14
  end
15
15
  end
16
16
 
17
17
  require File.dirname(__FILE__) + '/bubble/knock_knock/exceptions'
18
+ require File.dirname(__FILE__) + '/bubble/knock_knock/services'
18
19
  require File.dirname(__FILE__) + '/bubble/knock_knock/hash'
19
20
  require File.dirname(__FILE__) + '/bubble/knock_knock/connection'
20
21
  require File.dirname(__FILE__) + '/bubble/knock_knock/request'
@@ -4,19 +4,15 @@ class TestKnockKnock < Test::Unit::TestCase # :nodoc:
4
4
  include Bubble::KnockKnock
5
5
  include Bubble::KnockKnock::Exceptions
6
6
 
7
- def setup
8
- @kk = Connection.instance
9
- end
10
-
11
7
  def test_stablish_connection
12
- assert_raise(BadLogin) { @kk.connect('test@gmail.com', 'password', 'xapi') }
8
+ assert_raise(BadLogin) { Connection.connect('test@gmail.com', 'password', 'xapi') }
13
9
 
14
- @kk.connect('bubble.testing@gmail.com', 'bubblerocks', 'cp')
15
- assert google = @kk.auth
10
+ Connection.connect('bubble.testing@gmail.com', 'bubblerocks', Services::GoogleContacts)
11
+ assert google = Connection.auth
16
12
 
17
13
  # Test with a hosted Google Account
18
- @kk.connect('test@bubble.com.br', 'B48938', 'cp')
19
- assert @kk.auth
20
- assert @kk.auth != google
14
+ Connection.connect('test@bubble.com.br', 'B48938', Services::GoogleApps)
15
+ assert Connection.auth
16
+ assert Connection.auth != google
21
17
  end
22
18
  end
@@ -45,7 +45,7 @@ class Bubble::KnockKnock::TestRequest < Test::Unit::TestCase # :nodoc: #
45
45
 
46
46
  private
47
47
  def authenticate
48
- Connection.instance.connect('bubble.testing@gmail.com', 'bubblerocks', 'cp')
48
+ Connection.connect('bubble.testing@gmail.com', 'bubblerocks', 'cp')
49
49
  end
50
50
 
51
51
  def create_contact
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knock-knock
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bruno Azisaka Maciel
@@ -61,23 +61,16 @@ extensions: []
61
61
 
62
62
  extra_rdoc_files:
63
63
  - History.txt
64
- - Manifest.txt
65
64
  - README.rdoc
66
65
  files:
67
66
  - History.txt
68
- - Manifest.txt
69
67
  - README.rdoc
70
- - Rakefile
71
68
  - lib/knock_knock.rb
72
69
  - lib/bubble/knock_knock/connection.rb
73
70
  - lib/bubble/knock_knock/exceptions.rb
74
71
  - lib/bubble/knock_knock/hash.rb
75
72
  - lib/bubble/knock_knock/request.rb
76
- - script/console
77
- - script/destroy
78
- - script/generate
79
- - test/test_helper.rb
80
- - test/test_knock_knock.rb
73
+ - lib/bubble/knock_knock/services.rb
81
74
  has_rdoc: true
82
75
  homepage: KnockKnock was made to turn login with Google Authentication API easier.
83
76
  post_install_message:
@@ -1,14 +0,0 @@
1
- History.txt
2
- Manifest.txt
3
- README.rdoc
4
- Rakefile
5
- lib/knock_knock.rb
6
- lib/bubble/knock_knock/connection.rb
7
- lib/bubble/knock_knock/exceptions.rb
8
- lib/bubble/knock_knock/hash.rb
9
- lib/bubble/knock_knock/request.rb
10
- script/console
11
- script/destroy
12
- script/generate
13
- test/test_helper.rb
14
- test/test_knock_knock.rb
data/Rakefile DELETED
@@ -1,29 +0,0 @@
1
- %w[rubygems rake rake/clean fileutils newgem rubigen].each { |f| require f }
2
- require File.dirname(__FILE__) + '/lib/knock_knock'
3
-
4
- # Generate all the Rake tasks
5
- # Run 'rake -T' to see list of generated tasks (from gem root directory)
6
- $hoe = Hoe.new('knock-knock', Bubble::KnockKnock::VERSION) do |p|
7
- p.developer('Bruno Azisaka Maciel', 'bruno@dookie.com.br')
8
- p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
9
- # p.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
10
- p.rubyforge_name = 'knock-knock' # TODO this is default value
11
- p.extra_deps = [
12
- ['activesupport','>= 2.0.2']
13
- ]
14
- p.extra_dev_deps = [
15
- ['newgem', ">= #{::Newgem::VERSION}"],
16
- ['xml-object', '>= 0.9.8']
17
- ]
18
-
19
- p.clean_globs |= %w[**/.DS_Store tmp *.log]
20
- path = (p.rubyforge_name == p.name) ? p.rubyforge_name : "\#{p.rubyforge_name}/\#{p.name}"
21
- p.remote_rdoc_dir = File.join(path.gsub(/^#{p.rubyforge_name}\/?/,''), 'rdoc')
22
- p.rsync_args = '-av --delete --ignore-errors'
23
- end
24
-
25
- require 'newgem/tasks' # load /tasks/*.rake
26
- Dir['tasks/**/*.rake'].each { |t| load t }
27
-
28
- # TODO - want other tests/tasks run by default? Add them to the list
29
- # task :default => [:spec, :features]
@@ -1,10 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # File: script/console
3
- irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
4
-
5
- libs = " -r irb/completion"
6
- # Perhaps use a console_lib to store any extra methods I may want available in the cosole
7
- # libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
8
- libs << " -r #{File.dirname(__FILE__) + '/../lib/knock_knock.rb'}"
9
- puts "Loading knock_knock gem"
10
- exec "#{irb} #{libs} --simple-prompt"
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
- APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
-
4
- begin
5
- require 'rubigen'
6
- rescue LoadError
7
- require 'rubygems'
8
- require 'rubigen'
9
- end
10
- require 'rubigen/scripts/destroy'
11
-
12
- ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
- RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
- RubiGen::Scripts::Destroy.new.run(ARGV)
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
- APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
-
4
- begin
5
- require 'rubigen'
6
- rescue LoadError
7
- require 'rubygems'
8
- require 'rubigen'
9
- end
10
- require 'rubigen/scripts/generate'
11
-
12
- ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
- RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
- RubiGen::Scripts::Generate.new.run(ARGV)