appengine-apis 0.0.4 → 0.0.5

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.
@@ -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.4'
22
+ VERSION = '0.0.5'
23
23
  end
@@ -209,17 +209,23 @@ module Datastore
209
209
  retries -= 1
210
210
  tx = begin_transaction
211
211
  begin
212
- result = yield
213
- tx.commit
214
- return result
212
+ convert_exceptions do
213
+ result = yield
214
+ tx.commit
215
+ return result
216
+ end
215
217
  rescue Rollback
216
- tx.rollback
217
- return nil
218
- rescue TransactionFailed
218
+ convert_exceptions do
219
+ tx.rollback
220
+ return nil
221
+ end
222
+ rescue TransactionFailed => ex
219
223
  raise ex unless retries >= 0
220
224
  ensure
221
225
  begin
222
- tx.rollback
226
+ convert_exceptions do
227
+ tx.rollback
228
+ end
223
229
  rescue java.lang.IllegalStateException
224
230
  # already commited/rolled back. ignore
225
231
  rescue java.util.NoSuchElementException
@@ -490,6 +496,22 @@ module Datastore
490
496
  options
491
497
  end
492
498
 
499
+ def inspect
500
+ output = "<Query("
501
+ query = java_query
502
+ output << query.kind if query.kind
503
+ output << ", " if query.ancestor && query.kind
504
+ output << query.ancestor.inspect if query.ancestor
505
+ output << ")"
506
+ query.filter_predicates.each do |pred|
507
+ output << " (#{pred.property_name.inspect} #{pred.operator.name} #{pred.value.inspect})"
508
+ end
509
+ query.sort_predicates.each do |pred|
510
+ output << " (ORDER BY #{pred.property_name.inspect} #{pred.direction.name})"
511
+ end
512
+ output
513
+ end
514
+
493
515
  private
494
516
  def clear_cache
495
517
  @pquery = nil
@@ -23,7 +23,7 @@ require 'java'
23
23
 
24
24
  class Time
25
25
  def to_java
26
- java.util.Date.new(to_i * 1000)
26
+ java.util.Date.new(tv_sec * 1000 + tv_usec / 1000)
27
27
  end
28
28
 
29
29
  def self.new_from_java(date)
@@ -21,7 +21,7 @@ require 'appengine-apis/datastore_types'
21
21
  module AppEngine
22
22
 
23
23
  # The Ruby API for the App Engine Memcache service. This offers a fast
24
- # distrubted cache for commonly-used data. The cache is limited both in
24
+ # distributed cache for commonly-used data. The cache is limited both in
25
25
  # duration and also in total space, so objects stored in it may be discarded
26
26
  # at any time.
27
27
  #
@@ -19,11 +19,25 @@
19
19
  require 'java'
20
20
 
21
21
  module AppEngine
22
+
23
+ DEV_APPSERVER = 'com.google.appengine.tools.development.DevAppServerMain'
22
24
 
23
25
  # Helper methods to locate the App Engine SDK and add it to the class path.
24
26
  module SDK
25
27
  class << self
26
28
 
29
+ # Tries to load the Kickstart class.
30
+ def load_kickstart
31
+ tools = %w{lib appengine-tools-api.jar}
32
+ cp = java.lang.System.get_property('java.class.path')
33
+ jar = sdk_path(*tools)
34
+ sep = java.io.File::pathSeparator
35
+ java.lang.System.set_property('java.class.path', "#{jar}#{sep}#{cp}")
36
+ with_jars(tools) do
37
+ return Java.ComGoogleAppengineTools.KickStart
38
+ end
39
+ end
40
+
27
41
  # Tries to load the ApiProxy class.
28
42
  def load_apiproxy
29
43
  with_jars(%w{lib impl appengine-api.jar}) do
@@ -41,6 +55,12 @@ module AppEngine
41
55
  end
42
56
  end
43
57
 
58
+ def load_appcfg
59
+ with_jars(%w{lib appengine-tools-api.jar}) do
60
+ return Java.ComGoogleAppengineToolsAdmin.AppCfg
61
+ end
62
+ end
63
+
44
64
  def with_jars(*jars) # :nodoc:
45
65
  begin
46
66
  failed = false
@@ -93,4 +113,4 @@ module AppEngine
93
113
  end
94
114
  end
95
115
  end
96
- end
116
+ end
@@ -37,13 +37,15 @@ module AppEngine
37
37
 
38
38
  attr_writer :appid, :version, :email, :admin
39
39
  attr_writer :auth_domain, :request_namespace, :default_namespace
40
+ attr_reader :attributes
40
41
 
41
42
  def initialize
42
43
  @appid = "test"
43
44
  @version = "1.0"
44
- @auth_domain = @request_namespace = "gmail.com"
45
- @default_namespace = ""
45
+ @auth_domain= "gmail.com"
46
+ @default_namespace = @request_namespace = ""
46
47
  @email = ""
48
+ @attributes = java.util.HashMap.new
47
49
  end
48
50
 
49
51
  def getAppId
@@ -82,6 +84,10 @@ module AppEngine
82
84
  @default_namespace = s
83
85
  end
84
86
 
87
+ def getAttributes
88
+ @attributes
89
+ end
90
+
85
91
  def inspect
86
92
  "#<TestEnv>"
87
93
  end
@@ -139,7 +139,7 @@ module AppEngine
139
139
  end
140
140
 
141
141
  if payload
142
- request.set_payload(payload.as_java_bytes)
142
+ request.set_payload(payload.to_java_bytes)
143
143
  end
144
144
 
145
145
  return request
@@ -59,37 +59,33 @@ describe AppEngine::Datastore do
59
59
  end
60
60
 
61
61
  it "should support failed transactions" do
62
- pending("Real local transactions") do
63
- a = Datastore::Entity.new("A")
64
- a[:a] = 0
65
- Datastore.put(a)
66
- p = lambda do
67
- Datastore.transaction do
68
- a2 = Datastore.get(a.key)
69
- a[:a] += 1
70
- Datastore.put(nil, a)
71
- Datastore.put(a2)
72
- end
62
+ a = Datastore::Entity.new("A")
63
+ a[:a] = 0
64
+ Datastore.put(a)
65
+ p = lambda do
66
+ Datastore.transaction do
67
+ a2 = Datastore.get(a.key)
68
+ a[:a] += 1
69
+ Datastore.put(nil, a)
70
+ Datastore.put(a2)
73
71
  end
74
- p.should raise_error Datastore::TransactionFailed
75
72
  end
73
+ p.should raise_error Datastore::TransactionFailed
76
74
  end
77
75
 
78
76
  it "should retry transactions" do
79
- pending("Real local transactions") do
80
- a = Datastore::Entity.new("A")
81
- a[:a] = 0
82
- Datastore.put(a)
83
- Datastore.transaction(3) do
84
- a2 = Datastore.get(a.key)
85
- a[:a] += 1
86
- Datastore.put(nil, a) if a[:a] < 3
87
- a2[:a] = "2: #{a2[:a]}"
88
- Datastore.put(a2)
89
- end
90
-
91
- Datastore.get(a.key)[:a].should == '2: 2'
77
+ a = Datastore::Entity.new("A")
78
+ a[:a] = 0
79
+ Datastore.put(a)
80
+ Datastore.transaction(3) do
81
+ a2 = Datastore.get(a.key)
82
+ a[:a] += 1
83
+ Datastore.put(nil, a) if a[:a] < 3
84
+ a2[:a] = "2: #{a2[:a]}"
85
+ Datastore.put(a2)
92
86
  end
87
+
88
+ Datastore.get(a.key)[:a].should == '2: 2'
93
89
  end
94
90
 
95
91
  it "should close transactions" do
@@ -126,7 +122,7 @@ describe AppEngine::Datastore::Query do
126
122
  end
127
123
 
128
124
  it 'should support symbol ops' do
129
- q = Query.new("Foo")
125
+ q = Query.new("A")
130
126
  q.set_ancestor(@a.key).sort('name').filter(
131
127
  'name', :==, 'aa')
132
128
  q.fetch.to_a.should == [@aa]
@@ -25,20 +25,16 @@ describe AppEngine::Datastore::Key do
25
25
  a1.should == a2
26
26
  a2.should.eql? a1
27
27
  a1.hash.should == a2.hash
28
- pending("Key.compareTo") do
29
- (a1 <=> a2).should == 0
30
- end
28
+ (a1 <=> a2).should == 0
31
29
  end
32
30
 
33
31
  it "should support <=>" do
34
- pending("Key.compareTo") do
35
- a1 = Key.from_path("A", 1)
36
- a2 = Key.from_path("A", 2)
37
- a1.should < a2
38
- a2.should > a1
39
- (a1 <=> a2).should == -1
40
- (a2 <=> a1).should == 1
41
- end
32
+ a1 = Key.from_path("A", 1)
33
+ a2 = Key.from_path("A", 2)
34
+ a1.should < a2
35
+ a2.should > a1
36
+ (a1 <=> a2).should == -1
37
+ (a2 <=> a1).should == 1
42
38
  end
43
39
 
44
40
  it "should create from id" do
@@ -308,10 +308,8 @@ describe AppEngine::Memcache do
308
308
  @cache.get(:a).should == 4
309
309
  @cache.decr(:a, 4).should == 0
310
310
  @cache.get(:a).should == 0
311
- pending 'local decrement wrapping' do
312
- @cache.decr(:a, 6).should == 0
313
- @cache.get(:a).should == 0
314
- end
311
+ @cache.decr(:a, 6).should == 0
312
+ @cache.get(:a).should == 0
315
313
  end
316
314
  end
317
315
 
metadata CHANGED
@@ -21,18 +21,21 @@ name: appengine-apis
21
21
  rdoc_options:
22
22
  - --main
23
23
  - README.rdoc
24
- autorequire:
25
24
  rubyforge_project: appengine-jruby
25
+ autorequire:
26
+ licenses: []
27
+
26
28
  executables: []
27
29
 
28
- description: 'APIs and utilities for using JRuby on Google App Engine. To load the
29
- API stubs in IRB simply require ''rubygems'' require ''appengine-apis/local_boot'' This
30
- will configure access to the same Datastore as running $ dev_appserver.sh . See
31
- these classes for an overview of each API: - AppEngine::Logger - AppEngine::Testing
32
- - AppEngine::Users - AppEngine::Mail - AppEngine::Memcache - AppEngine::URLFetch
33
- - AppEngine::Datastore Unless you''re implementing your own ORM, you probably want
34
- to use the DataMapper API instead of the lower level AppEngine::Datastore API.'
35
- specification_version: 2
30
+ description: "APIs and utilities for using JRuby on Google App Engine.\n\nTo load \
31
+ the API stubs in IRB simply\n require 'rubygems'\n require 'appengine-apis/local_boot'\n\
32
+ \nThis will configure access to the same Datastore as running\n\n $ dev_appserver.sh \
33
+ .\n\nSee these classes for an overview of each API:\n- AppEngine::Logger\n- AppEngine::Testing\n\
34
+ - AppEngine::Users\n- AppEngine::Mail\n- AppEngine::Memcache\n- AppEngine::URLFetch\n\
35
+ - AppEngine::Datastore\n\nUnless you're implementing your own ORM, you probably \
36
+ want to use the\nDataMapper API instead of the lower level AppEngine::Datastore \
37
+ API."
38
+ specification_version: 3
36
39
  default_executable:
37
40
  files:
38
41
  - History.txt
@@ -73,17 +76,17 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
76
  version:
74
77
  extensions: []
75
78
 
76
- rubygems_version: 1.3.1
79
+ rubygems_version: 1.3.3
77
80
  requirements: []
78
81
 
79
82
  authors:
80
83
  - Ryan Brown
81
- date: 2009-05-06 07:00:00 +00:00
84
+ date: 2009-07-20 07:00:00 +00:00
82
85
  platform: ruby
83
86
  test_files: []
84
87
 
85
88
  version: !ruby/object:Gem::Version
86
- version: 0.0.4
89
+ version: 0.0.5
87
90
  require_paths:
88
91
  - lib
89
92
  dependencies: