goopr 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -0,0 +1,5 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ rdoc
5
+ pkg
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Marcelo de Moraes Serpa
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.
@@ -0,0 +1,22 @@
1
+ = goopr
2
+
3
+ GooPR is an alpha project that aims to eventually evolve to provide a full abstraction over the Google Provisioning API.
4
+
5
+ It is pretty simple as of now, and uses a RPC-style architecture. It will evolve to a RESTful architecture and probably support method-missing requests.
6
+
7
+ Right now it only supports changing passwords.
8
+
9
+ == Note on Patches/Pull Requests
10
+
11
+ * Fork the project.
12
+ * Make your feature addition or bug fix.
13
+ * Add tests for it. This is important so I don't break it in a
14
+ future version unintentionally.
15
+ * Commit, do not mess with rakefile, version, or history.
16
+ (if you want to have your own version, that is fine but
17
+ bump version in a commit by itself I can ignore when I pull)
18
+ * Send me a pull request. Bonus points for topic branches.
19
+
20
+ == Copyright
21
+
22
+ Copyright (c) 2010 Marcelo de Moraes Serpa. See LICENSE for details.
@@ -0,0 +1,57 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "goopr"
8
+ gem.summary = %Q{GooPR Google Provisioning for Rails (alpha)}
9
+ gem.description = %Q{An attempt to abstract the code needed to manage the prov. API}
10
+ gem.email = "fullofcaffeine@gmail.com"
11
+ gem.homepage = "http://github.com/celoserpa/goopr"
12
+ gem.authors = ["Marcelo de Moraes Serpa"]
13
+ gem.add_dependency("httparty",">= 0.6.1")
14
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
15
+ end
16
+ Jeweler::GemcutterTasks.new
17
+ rescue LoadError
18
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
19
+ end
20
+
21
+ require 'rake/testtask'
22
+ Rake::TestTask.new(:test) do |test|
23
+ test.libs << 'lib' << 'test'
24
+ test.pattern = 'test/**/*_test.rb'
25
+ test.verbose = true
26
+ end
27
+
28
+ begin
29
+ require 'rcov/rcovtask'
30
+ Rcov::RcovTask.new do |test|
31
+ test.libs << 'test'
32
+ test.pattern = 'test/**/*_test.rb'
33
+ test.verbose = true
34
+ end
35
+ rescue LoadError
36
+ task :rcov do
37
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
38
+ end
39
+ end
40
+
41
+ task :test => :check_dependencies
42
+
43
+ task :default => :test
44
+
45
+ require 'rake/rdoctask'
46
+ Rake::RDocTask.new do |rdoc|
47
+ if File.exist?('VERSION')
48
+ version = File.read('VERSION')
49
+ else
50
+ version = ""
51
+ end
52
+
53
+ rdoc.rdoc_dir = 'rdoc'
54
+ rdoc.title = "goopr #{version}"
55
+ rdoc.rdoc_files.include('README*')
56
+ rdoc.rdoc_files.include('lib/**/*.rb')
57
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.2.0
@@ -0,0 +1,29 @@
1
+ module GooPR
2
+ module AccountActions
3
+ class Base
4
+ attr_accessor :goopr,:url,:params
5
+ end
6
+
7
+ class ChangePassword < Base
8
+ def initialize(params = {})
9
+ self.params = params
10
+ self.params.merge!(:url => "https://apps-apis.google.com/a/feeds/#{params[:domain]}/user/2.0/#{params[:user_name]}")
11
+ end
12
+
13
+ def run
14
+ body = <<-EOF
15
+ <?xml version="1.0" encoding="UTF-8"?>
16
+ <atom:entry xmlns:atom="http://www.w3.org/2005/Atom"
17
+ xmlns:apps="http://schemas.google.com/apps/2006">
18
+ <atom:category scheme="http://schemas.google.com/g/2005#kind"
19
+ term="http://schemas.google.com/apps/2006#user"/>
20
+ <apps:login password="testtest"/>
21
+ </atom:entry>
22
+ EOF
23
+
24
+ self.goopr.class.put(self.params[:url], :body => body )
25
+ end
26
+
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,2 @@
1
+ require 'goopr/base'
2
+ require 'account_actions'
@@ -0,0 +1,31 @@
1
+ require 'httparty'
2
+ require 'cgi'
3
+
4
+ module GooPR
5
+ class Base
6
+ include HTTParty
7
+
8
+ def initialize(domain,email,password)
9
+ auth_params = {:accountType => 'HOSTED',
10
+ :service => 'apps',
11
+ :Email => CGI.escape(email),
12
+ :Passwd => CGI.escape(password)}
13
+
14
+ authenticate(auth_params)
15
+ end
16
+
17
+ def run(action)
18
+ action.goopr = self
19
+ action.run
20
+ end
21
+
22
+ private
23
+
24
+ def authenticate(params)
25
+ body = "&Email=#{params[:Email]}&Passwd=#{params[:Passwd]}&accountType=HOSTED&service=apps"
26
+ @r = self.class.post('https://www.google.com/accounts/ClientLogin',:body => body, :headers => {'Content-Type' => 'application/x-www-form-urlencoded'})
27
+ auth = @r.parsed_response.match(/Auth=(.*)/)[1]
28
+ self.class.default_options[:headers] = {'Content-Type'=>'application/atom+xml', 'Authorization'=>"GoogleLogin auth=#{auth}"}
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,13 @@
1
+ class goopr_parsers < HttpParty::Parser
2
+
3
+ SupportedFormats.merge!(
4
+ {"text/plain" > :goopr}
5
+ )
6
+
7
+ def goopr
8
+
9
+
10
+
11
+ end
12
+
13
+ end
@@ -0,0 +1,15 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+ require 'goopr'
5
+ require 'ruby-debug'
6
+
7
+ class GooPRTest < Test::Unit::TestCase
8
+
9
+ context 'first test' do
10
+ should 'authenticate to the API' do
11
+ goopr = GooPR::Base.new('onelog.in','marcelo@onelog.in','xxxx')
12
+ goopr.run(GooPR::AccountActions::ChangePassword.new(:domain => 'onelog.in',:user_name => 'marcelo', :password => 'blah'))
13
+ end
14
+ end
15
+ end
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: goopr
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 1
7
+ - 2
8
+ - 0
9
+ version: 1.2.0
10
+ platform: ruby
11
+ authors:
12
+ - Marcelo de Moraes Serpa
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-08-18 00:00:00 -05:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: httparty
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ - 6
30
+ - 1
31
+ version: 0.6.1
32
+ type: :runtime
33
+ version_requirements: *id001
34
+ description: An attempt to abstract the code needed to manage the prov. API
35
+ email: fullofcaffeine@gmail.com
36
+ executables: []
37
+
38
+ extensions: []
39
+
40
+ extra_rdoc_files:
41
+ - LICENSE
42
+ - README.rdoc
43
+ files:
44
+ - .document
45
+ - .gitignore
46
+ - LICENSE
47
+ - README.rdoc
48
+ - Rakefile
49
+ - VERSION
50
+ - lib/account_actions.rb
51
+ - lib/goopr.rb
52
+ - lib/goopr/base.rb
53
+ - lib/goopr/parsers.rb
54
+ - test/goopr_test.rb
55
+ has_rdoc: true
56
+ homepage: http://github.com/celoserpa/goopr
57
+ licenses: []
58
+
59
+ post_install_message:
60
+ rdoc_options:
61
+ - --charset=UTF-8
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ segments:
69
+ - 0
70
+ version: "0"
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ segments:
76
+ - 0
77
+ version: "0"
78
+ requirements: []
79
+
80
+ rubyforge_project:
81
+ rubygems_version: 1.3.6
82
+ signing_key:
83
+ specification_version: 3
84
+ summary: GooPR Google Provisioning for Rails (alpha)
85
+ test_files:
86
+ - test/goopr_test.rb