dm-appengine 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -5,7 +5,7 @@ require 'date'
5
5
  require 'spec/rake/spectask'
6
6
 
7
7
  GEM = "dm-appengine"
8
- GEM_VERSION = "0.0.4"
8
+ GEM_VERSION = "0.0.5"
9
9
  AUTHOR = "Ryan Brown"
10
10
  EMAIL = "ribrdb@gmail.com"
11
11
  HOMEPAGE = "http://code.google.com/p/appengine-jruby"
@@ -24,12 +24,14 @@ spec = Gem::Specification.new do |s|
24
24
  s.homepage = HOMEPAGE
25
25
 
26
26
  s.add_dependency("appengine-apis", ["~> 0.0.3"])
27
- s.add_dependency(%q<dm-core>, ["~> 0.10.0"])
27
+ s.add_dependency("dm-core", ["~> 0.10.0"])
28
+ s.add_dependency("addressable")
29
+ s.add_dependency("extlib")
28
30
 
29
31
  s.require_path = 'lib'
30
32
  s.autorequire = GEM
31
- s.files = %w(LICENSE README.rdoc Rakefile lib/appengine_adapter.rb) +
32
- Dir.glob("spec/**/*")
33
+ s.files = %w(LICENSE README.rdoc Rakefile) + Dir.glob("spec/**/*") +
34
+ %w(lib/appengine_adapter.rb lib/dm-appengine/types.rb)
33
35
  end
34
36
 
35
37
  task :default => :spec
@@ -55,4 +57,4 @@ task :make_spec do
55
57
  File.open("#{GEM}.gemspec", "w") do |file|
56
58
  file.puts spec.to_ruby
57
59
  end
58
- end
60
+ end
@@ -23,6 +23,7 @@ require 'time'
23
23
 
24
24
  require 'appengine-apis/datastore'
25
25
  require 'dm-core'
26
+ require 'dm-appengine/types'
26
27
 
27
28
  module DataMapper
28
29
  module Adapters
@@ -85,8 +86,8 @@ module DataMapper
85
86
  Datastore.put(entities)
86
87
  resources.zip(entities) do |resource, entity|
87
88
  key = entity.key
88
- if serial = resource.model.serial(name)
89
- serial.set!(resource, key.get_id)
89
+ if id = resource.model.serial(name)
90
+ id.set!(resource, key.get_id)
90
91
  end
91
92
  resource.instance_variable_set :@__entity__, entity
92
93
  end
@@ -208,6 +209,8 @@ module DataMapper
208
209
 
209
210
  def parse_conditions(conditions)
210
211
  case conditions
212
+ when NullOperation then
213
+ return
211
214
  when NotOperation then
212
215
  raise NotImplementedError, "NOT operator is not supported"
213
216
  when AbstractComparison then
@@ -245,7 +248,7 @@ module DataMapper
245
248
  when OrOperation then
246
249
  parse_or(op)
247
250
  when EqualToComparison then
248
- key = parse_key(op.property, op.value)
251
+ key = parse_key(op.subject, op.value)
249
252
  @keys << key
250
253
  when InclusionComparison then
251
254
  parse_key_inclusion(op)
@@ -258,7 +261,7 @@ module DataMapper
258
261
  def parse_key_inclusion(op)
259
262
  raise NotImplementedError unless op.value.kind_of? Array
260
263
  op.value.each do |value|
261
- @keys << parse_key(op.property, value)
264
+ @keys << parse_key(op.subject, value)
262
265
  end
263
266
  end
264
267
 
@@ -271,8 +274,11 @@ module DataMapper
271
274
  parse_conditions(conditions)
272
275
  end
273
276
  end
274
-
277
+
275
278
  def parse_comparison(op)
279
+ if op.subject.kind_of?(Associations::Relationship)
280
+ return foreign_key_conditions(op)
281
+ end
276
282
  property = op.subject
277
283
  value = op.value
278
284
  if @maybe_get
@@ -308,7 +314,7 @@ module DataMapper
308
314
  def parse_range(op)
309
315
  range = op.value
310
316
  raise NotImplementedError unless range.is_a? Range
311
- name = property_name(op.property)
317
+ name = property_name(op.subject)
312
318
  begin_op = GREATER_THAN_OR_EQUAL
313
319
  end_op = if range.exclude_end?
314
320
  LESS_THAN
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/ruby1.8 -w
2
+ #
3
+ # Copyright:: Copyright 2009 Google Inc.
4
+ # Original Author:: Ryan Brown (mailto:ribrdb@google.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
+ # Custom types for App Engine
19
+
20
+ require 'dm-core/type'
21
+
22
+ module DataMapper
23
+ module Types
24
+ class List < Type
25
+ primitive ::Object
26
+
27
+ def self.dump(value, property)
28
+ value
29
+ end
30
+
31
+ def self.load(value, property)
32
+ value.to_a if value
33
+ end
34
+
35
+ def self._type=(type)
36
+ @type = type
37
+ end
38
+ end
39
+
40
+ class Blob < Type
41
+ primitive String
42
+ size 1024 * 1024
43
+
44
+ def self.dump(value, property)
45
+ AppEngine::Datastore::Blob.new(value) if value
46
+ end
47
+
48
+ def self.load(value, property)
49
+ value
50
+ end
51
+ end
52
+ end
53
+ end
@@ -35,6 +35,9 @@ class TypeTest
35
35
  property :bigd, BigDecimal
36
36
  property :flower, Object
37
37
  property :klass, Class
38
+ $stderr.puts "list: #{List.primitive.ancestors})"
39
+ property :list, List
40
+ property :blob, Blob
38
41
  end
39
42
 
40
43
  class Flower
@@ -162,5 +165,20 @@ describe DataMapper::Adapters::AppEngineAdapter do
162
165
  a.reload
163
166
  a.klass.should == Flower
164
167
  end
168
+
169
+ it 'should support List' do
170
+ a = TypeTest.new(:name => 'list', :list => [1, 2, 3])
171
+ a.save
172
+ a.reload
173
+ a.list.should == [1, 2, 3]
174
+ TypeTest.all(:list => 2).should == [a]
175
+ end
176
+
177
+ it 'should support Blob' do
178
+ a = TypeTest.new(:name => 'blob', :blob => '\0')
179
+ a.save
180
+ a.reload
181
+ a.blob.should == '\0'
182
+ end
165
183
  end
166
184
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dm-appengine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Brown
@@ -9,7 +9,7 @@ autorequire: dm-appengine
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-09-15 00:00:00 -07:00
12
+ date: 2009-10-05 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -32,6 +32,26 @@ dependencies:
32
32
  - !ruby/object:Gem::Version
33
33
  version: 0.10.0
34
34
  version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: addressable
37
+ type: :runtime
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: "0"
44
+ version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: extlib
47
+ type: :runtime
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: "0"
54
+ version:
35
55
  description: A DataMapper adapter for Google App Engine
36
56
  email: ribrdb@gmail.com
37
57
  executables: []
@@ -45,9 +65,10 @@ files:
45
65
  - LICENSE
46
66
  - README.rdoc
47
67
  - Rakefile
48
- - lib/appengine_adapter.rb
49
68
  - spec/dm-appengine_spec.rb
50
69
  - spec/spec_helper.rb
70
+ - lib/appengine_adapter.rb
71
+ - lib/dm-appengine/types.rb
51
72
  has_rdoc: true
52
73
  homepage: http://code.google.com/p/appengine-jruby
53
74
  licenses: []