appengine-apis 0.0.17 → 0.0.18

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.
data/Rakefile CHANGED
@@ -15,6 +15,19 @@ begin
15
15
  rescue Exception
16
16
  end
17
17
 
18
+ def find_sdk_version
19
+ labs = Dir.glob("lib/appengine-api-labs-*")
20
+ if labs.size < 1
21
+ puts "Unable to determine SKD version."
22
+ puts "You must first package the App Engine SDK."
23
+ exit 1
24
+ else
25
+ return labs[0].split(/\.|-/)[-4..-2].join('.')
26
+ end
27
+ end
28
+
29
+ sdk_version = find_sdk_version
30
+
18
31
  GEM = "appengine-apis"
19
32
  GEM_VERSION = AppEngine::VERSION
20
33
  AUTHOR = "Ryan Brown"
@@ -29,13 +42,15 @@ spec = Gem::Specification.new do |s|
29
42
  s.has_rdoc = true
30
43
  s.extra_rdoc_files = ["README.rdoc", "COPYING"]
31
44
  s.summary = SUMMARY
32
- s.description = s.summary
33
45
  s.author = AUTHOR
34
46
  s.email = EMAIL
35
47
  s.homepage = HOMEPAGE
36
-
48
+ s.description = <<-EOF
49
+ This gem includes the JRuby API wrappers for App Engine, as well as the
50
+ required jar files from Google App Engine SDK for Java. Version #{sdk_version}
51
+ is included in this release.
52
+ EOF
37
53
  s.add_dependency("appengine-rack")
38
-
39
54
  s.require_path = 'lib'
40
55
  s.files = %w(COPYING README.rdoc Rakefile) +
41
56
  Dir.glob("spec/**/*.rb") + Dir.glob("lib/**/*")
@@ -49,7 +64,6 @@ Spec::Rake::SpecTask.new do |t|
49
64
  t.spec_opts = %w(-fs --color)
50
65
  end
51
66
 
52
-
53
67
  Rake::GemPackageTask.new(spec) do |pkg|
54
68
  pkg.gem_spec = spec
55
69
  end
@@ -19,5 +19,5 @@ $:.unshift(File.dirname(__FILE__)) unless
19
19
  $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
20
20
 
21
21
  module AppEngine
22
- VERSION = '0.0.17'
22
+ VERSION = '0.0.18'
23
23
  end
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/ruby1.8 -w
2
+ #
3
+ # Copyright:: Copyright 2009 Google Inc.
4
+ # Original Author:: John Wang (mailto:jwang392@gmail.com)
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ module AppEngine
20
+ # OAuth protocol provides information useful for granting permissions, and
21
+ # retrieving information about the user who is currently logged-in.
22
+ module OAuth
23
+ import com.google.appengine.api.users.User
24
+ import com.google.appengine.api.oauth.OAuthRequestException;
25
+ import com.google.appengine.api.oauth.OAuthService;
26
+ import com.google.appengine.api.oauth.OAuthServiceFactory;
27
+ import com.google.appengine.api.oauth.OAuthServiceFailureException;
28
+
29
+ Service = OAuthServiceFactory.getOAuthService
30
+
31
+ class << self
32
+
33
+ # If the user is logged in, this method will return a User that contains
34
+ # information about them. Note that repeated calls may not necessarily
35
+ # return the same User object.
36
+ def current_user
37
+ Service.current_user
38
+ end
39
+
40
+ # Returns the oauth_consumer_key OAuth parameter from the request.
41
+ # Throws:
42
+ # OAuthRequestException - If the request was not a valid OAuth request.
43
+ # OAuthServiceFailureException - If an unknown OAuth error occurred.
44
+ def oauth_consumer_key
45
+ Service.get_oauth_consumer_key
46
+ end
47
+
48
+ # Returns true if the user making this request is an admin for this
49
+ # application, false otherwise.
50
+ #
51
+ # This is a separate function, and not a member function of the User
52
+ # class, because admin status is not persisted in the datastore. It
53
+ # only exists for the user making this request right now.
54
+ def admin?
55
+ Service.is_user_admin?
56
+ end
57
+ end
58
+
59
+ end
60
+ end
@@ -50,9 +50,11 @@ module AppEngine
50
50
  testing::LocalImagesServiceTestConfig.new,
51
51
  testing::LocalMailServiceTestConfig.new,
52
52
  testing::LocalMemcacheServiceTestConfig.new,
53
- testing::LocalTaskQueueTestConfig.new,
53
+ # TODO: need a flag to optionally enable this
54
+ # testing::LocalTaskQueueTestConfig.new,
54
55
  testing::LocalURLFetchServiceTestConfig.new,
55
56
  testing::LocalUserServiceTestConfig.new,
57
+ testing::LocalOAuthServiceTestConfig.new,
56
58
  testing::LocalXMPPServiceTestConfig.new,
57
59
  ].to_java(testing::LocalServiceTestConfig)
58
60
  testing::LocalServiceTestHelper.new(configs)
@@ -0,0 +1,43 @@
1
+ # Copyright:: Copyright 2009 Google Inc.
2
+ # Original Author:: John Wang (mailto:jwang392@gmail.com)
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ require File.dirname(__FILE__) + '/spec_helper.rb'
17
+ require 'appengine-apis/oauth'
18
+
19
+ describe AppEngine::OAuth do
20
+ before :all do
21
+ AppEngine::Testing::setup
22
+ end
23
+
24
+ before :each do
25
+ @env = AppEngine::Testing::helper
26
+ @env.set_env_consumer_key '0685bd9184jfhq22'
27
+ end
28
+
29
+ it "should get current user" do
30
+ user = AppEngine::OAuth.current_user
31
+ end
32
+
33
+ it 'should read consumer key' do
34
+ AppEngine::OAuth.oauth_consumer_key.should == '0685bd9184jfhq22'
35
+ end
36
+
37
+ it 'should read admin' do
38
+ AppEngine::OAuth.admin?.should == false
39
+ @env.set_env_is_admin true
40
+ AppEngine::OAuth.admin?.should == true
41
+ end
42
+
43
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 17
9
- version: 0.0.17
8
+ - 18
9
+ version: 0.0.18
10
10
  platform: ruby
11
11
  authors:
12
12
  - Ryan Brown
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-06-09 00:00:00 -04:00
17
+ date: 2010-07-14 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -29,7 +29,11 @@ dependencies:
29
29
  version: "0"
30
30
  type: :runtime
31
31
  version_requirements: *id001
32
- description: Ruby API wrappers for App Engine
32
+ description: |
33
+ This gem includes the JRuby API wrappers for App Engine, as well as the
34
+ required jar files from Google App Engine SDK for Java. Version 1.3.5
35
+ is included in this release.
36
+
33
37
  email: ribrdb@gmail.com
34
38
  executables: []
35
39
 
@@ -47,13 +51,14 @@ files:
47
51
  - spec/logger_spec.rb
48
52
  - spec/mail_spec.rb
49
53
  - spec/memcache_spec.rb
54
+ - spec/oauth_spec.rb
50
55
  - spec/spec_helper.rb
51
56
  - spec/taskqueue_spec.rb
52
57
  - spec/urlfetch_spec.rb
53
58
  - spec/users_spec.rb
54
59
  - spec/xmpp_spec.rb
55
- - lib/appengine-api-1.0-sdk-1.3.4.jar
56
- - lib/appengine-api-labs-1.3.4.jar
60
+ - lib/appengine-api-1.0-sdk-1.3.5.jar
61
+ - lib/appengine-api-labs-1.3.5.jar
57
62
  - lib/appengine-apis/apiproxy.rb
58
63
  - lib/appengine-apis/datastore.rb
59
64
  - lib/appengine-apis/datastore_types.rb
@@ -64,6 +69,7 @@ files:
64
69
  - lib/appengine-apis/mail.rb
65
70
  - lib/appengine-apis/memcache.rb
66
71
  - lib/appengine-apis/merb-logger.rb
72
+ - lib/appengine-apis/oauth.rb
67
73
  - lib/appengine-apis/runtime.rb
68
74
  - lib/appengine-apis/sdk.rb
69
75
  - lib/appengine-apis/tempfile.rb