appengine-apis 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +6 -0
- data/Manifest.txt +6 -0
- data/README.rdoc +11 -1
- data/Rakefile +8 -0
- data/lib/appengine-apis.rb +1 -1
- data/lib/appengine-apis/apiproxy.rb +2 -2
- data/lib/appengine-apis/datastore.rb +10 -11
- data/lib/appengine-apis/datastore_types.rb +11 -3
- data/lib/appengine-apis/local_boot.rb +29 -0
- data/lib/appengine-apis/mail.rb +160 -0
- data/lib/appengine-apis/memcache.rb +580 -0
- data/lib/appengine-apis/merb-logger.rb +1 -0
- data/lib/appengine-apis/sdk.rb +93 -0
- data/lib/appengine-apis/testing.rb +55 -10
- data/lib/appengine-apis/urlfetch.rb +7 -2
- data/spec/datastore_types_spec.rb +12 -1
- data/spec/mail_spec.rb +179 -0
- data/spec/memcache_spec.rb +385 -0
- data/spec/spec.opts +1 -1
- data/spec/spec_helper.rb +75 -0
- metadata +15 -7
data/spec/spec.opts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
--colour
|
1
|
+
--colour
|
data/spec/spec_helper.rb
CHANGED
@@ -9,3 +9,78 @@ end
|
|
9
9
|
$:.unshift(File.dirname(__FILE__) + '/../lib')
|
10
10
|
require 'appengine-apis/testing'
|
11
11
|
AppEngine::Testing.install_test_env
|
12
|
+
|
13
|
+
class ProtoMatcher
|
14
|
+
def compare(hash, proto, prefix='')
|
15
|
+
hash.each do |key, value|
|
16
|
+
name = "#{prefix}#{key}"
|
17
|
+
case value
|
18
|
+
when Array
|
19
|
+
if value[0].kind_of? Hash
|
20
|
+
count = proto.send("#{key}_size")
|
21
|
+
compare_value("#{name}.size", value.size, count)
|
22
|
+
value.each_with_index do |item, index|
|
23
|
+
break if index == count
|
24
|
+
compare(item, proto.send(key, index), "#{name}[#{index}].")
|
25
|
+
end
|
26
|
+
else
|
27
|
+
actual = proto.send("#{key}s").to_a
|
28
|
+
compare_value(name, value, actual)
|
29
|
+
end
|
30
|
+
when Hash
|
31
|
+
compare(value, proto.send(key), "#{name}.")
|
32
|
+
else
|
33
|
+
compare_value(name, value, proto.send(key))
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def compare_value(label, expected, actual)
|
39
|
+
if expected != actual
|
40
|
+
@failures << "%s differs. expected: %s actual: %s" %
|
41
|
+
[label, expected.inspect, actual.inspect]
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def initialize(klass, expected)
|
46
|
+
@klass = klass
|
47
|
+
@expected = expected
|
48
|
+
end
|
49
|
+
|
50
|
+
def matches(bytes)
|
51
|
+
@failures = []
|
52
|
+
@proto = @klass.new
|
53
|
+
@proto.parse_from(bytes)
|
54
|
+
compare(@expected, @proto)
|
55
|
+
@failures.empty?
|
56
|
+
end
|
57
|
+
|
58
|
+
def ==(bytes)
|
59
|
+
Spec::Expectations.fail_with(failure_message) unless matches(bytes)
|
60
|
+
true
|
61
|
+
end
|
62
|
+
|
63
|
+
def failure_message
|
64
|
+
@failures.join("\n")
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
module ProtoMethods
|
69
|
+
def proto(klass, hash)
|
70
|
+
ProtoMatcher.new(klass, hash)
|
71
|
+
end
|
72
|
+
alias be_proto proto
|
73
|
+
|
74
|
+
def mock_delegate
|
75
|
+
delegate = mock("apiproxy")
|
76
|
+
delegate.instance_eval do
|
77
|
+
class << self
|
78
|
+
include AppEngine::ApiProxy::Delegate
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
Spec::Runner.configure do |config|
|
85
|
+
config.include(ProtoMethods)
|
86
|
+
end
|
metadata
CHANGED
@@ -26,11 +26,13 @@ autorequire:
|
|
26
26
|
rubyforge_project: appengine-jruby
|
27
27
|
executables: []
|
28
28
|
|
29
|
-
description: 'APIs and utilities for using JRuby on Google App Engine.
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
AppEngine::
|
29
|
+
description: 'APIs and utilities for using JRuby on Google App Engine. To load the
|
30
|
+
API stubs in IRB simply require ''rubygems'' require ''appengine-apis/local_boot'' This
|
31
|
+
will configure access to the same Datastore as running $ dev_appserver.sh . See
|
32
|
+
these classes for an overview of each API: - AppEngine::Logger - AppEngine::Testing
|
33
|
+
- AppEngine::Users - AppEngine::Mail - AppEngine::Memcache - AppEngine::URLFetch
|
34
|
+
- AppEngine::Datastore Unless you''re implementing your own ORM, you probably want
|
35
|
+
to use the DataMapper API instead of the lower level AppEngine::Datastore API.'
|
34
36
|
specification_version: 2
|
35
37
|
default_executable:
|
36
38
|
files:
|
@@ -43,8 +45,12 @@ files:
|
|
43
45
|
- lib/appengine-apis/apiproxy.rb
|
44
46
|
- lib/appengine-apis/datastore.rb
|
45
47
|
- lib/appengine-apis/datastore_types.rb
|
48
|
+
- lib/appengine-apis/local_boot.rb
|
46
49
|
- lib/appengine-apis/logger.rb
|
50
|
+
- lib/appengine-apis/mail.rb
|
51
|
+
- lib/appengine-apis/memcache.rb
|
47
52
|
- lib/appengine-apis/merb-logger.rb
|
53
|
+
- lib/appengine-apis/sdk.rb
|
48
54
|
- lib/appengine-apis/testing.rb
|
49
55
|
- lib/appengine-apis/urlfetch.rb
|
50
56
|
- lib/appengine-apis/users.rb
|
@@ -54,6 +60,8 @@ files:
|
|
54
60
|
- spec/datastore_spec.rb
|
55
61
|
- spec/datastore_types_spec.rb
|
56
62
|
- spec/logger_spec.rb
|
63
|
+
- spec/mail_spec.rb
|
64
|
+
- spec/memcache_spec.rb
|
57
65
|
- spec/spec.opts
|
58
66
|
- spec/spec_helper.rb
|
59
67
|
- spec/urlfetch_spec.rb
|
@@ -72,12 +80,12 @@ requirements: []
|
|
72
80
|
|
73
81
|
authors:
|
74
82
|
- Ryan Brown
|
75
|
-
date: 2009-04-
|
83
|
+
date: 2009-04-25 07:00:00 +00:00
|
76
84
|
platform: ruby
|
77
85
|
test_files: []
|
78
86
|
|
79
87
|
version: !ruby/object:Gem::Version
|
80
|
-
version: 0.0.
|
88
|
+
version: 0.0.3
|
81
89
|
require_paths:
|
82
90
|
- lib
|
83
91
|
dependencies:
|