shanna-dm-tokyo-adapter 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ rdoc
5
+ pkg
6
+ test/tc/*
7
+ *~
8
+ *.gem
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 3
4
- :patch: 1
4
+ :patch: 2
@@ -0,0 +1,55 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{dm-tokyo-adapter}
5
+ s.version = "0.3.2"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Shane Hanna"]
9
+ s.date = %q{2009-08-09}
10
+ s.email = %q{shane.hanna@gmail.com}
11
+ s.extra_rdoc_files = [
12
+ "LICENSE",
13
+ "README.rdoc"
14
+ ]
15
+ s.files = [
16
+ ".gitignore",
17
+ "LICENSE",
18
+ "README.rdoc",
19
+ "Rakefile",
20
+ "VERSION.yml",
21
+ "dm-tokyo-adapter.gemspec",
22
+ "lib/dm-tokyo-adapter.rb",
23
+ "lib/dm-tokyo-adapter/cabinet.rb",
24
+ "lib/dm-tokyo-adapter/query.rb",
25
+ "lib/dm-tokyo-adapter/tyrant.rb",
26
+ "test/helper.rb",
27
+ "test/test_cabinet.rb",
28
+ "test/test_query.rb",
29
+ "test/test_tyrant.rb"
30
+ ]
31
+ s.homepage = %q{http://github.com/shanna/dm-tokyo-adapter}
32
+ s.rdoc_options = ["--charset=UTF-8"]
33
+ s.require_paths = ["lib"]
34
+ s.rubygems_version = %q{1.3.4}
35
+ s.summary = %q{Tokyo Cabinet/Tyrant Table DataMapper Adapter.}
36
+ s.test_files = [
37
+ "test/helper.rb",
38
+ "test/test_cabinet.rb",
39
+ "test/test_query.rb",
40
+ "test/test_tyrant.rb"
41
+ ]
42
+
43
+ if s.respond_to? :specification_version then
44
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
45
+ s.specification_version = 3
46
+
47
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
48
+ s.add_runtime_dependency(%q<dm-core>, ["~> 0.10.0"])
49
+ else
50
+ s.add_dependency(%q<dm-core>, ["~> 0.10.0"])
51
+ end
52
+ else
53
+ s.add_dependency(%q<dm-core>, ["~> 0.10.0"])
54
+ end
55
+ end
@@ -1,6 +1,6 @@
1
1
  require 'dm-core'
2
2
  require 'fileutils'
3
- require 'rufus-tokyo'
3
+ require 'rufus/tokyo'
4
4
 
5
5
  module DataMapper
6
6
  module Adapters
@@ -21,10 +21,9 @@ module DataMapper
21
21
  def create(resources)
22
22
  resources.map do |resource|
23
23
  model = resource.model
24
- identity_field = model.identity_field
25
24
 
26
25
  with_connection(resource.model) do |connection|
27
- initialize_identity_field(resource, connection.generate_unique_id) if identity_field
26
+ initialize_serial(resource, connection.generate_unique_id)
28
27
  connection[key(resource)] = attributes(resource, :field)
29
28
  end
30
29
  end.size
@@ -1,5 +1,5 @@
1
1
  require 'dm-core'
2
- require 'rufus-tokyo'
2
+ require 'rufus/tokyo'
3
3
 
4
4
  module DataMapper
5
5
  module Adapters
@@ -77,8 +77,22 @@ module DataMapper
77
77
  end
78
78
 
79
79
  def comparison_statement(statements, comparison, affirmative = true)
80
- value = comparison.value
81
- primitive = comparison.subject.primitive
80
+ subject = comparison.subject
81
+ primitive = subject.primitive
82
+ value = comparison.value.kind_of?(DataMapper::Resource) ?
83
+ comparison.value[comparison.value.class.serial.name] :
84
+ comparison.value
85
+
86
+ if subject.is_a?(DataMapper::Associations::ManyToOne::Relationship)
87
+ statements.add(subject.child_key.first.name, :numeq, quote_value(value), affirmative)
88
+ return
89
+ end
90
+
91
+ if subject.is_a?(DataMapper::Associations::OneToMany::Relationship)
92
+ value = comparison.value[subject.child_key.first.name]
93
+ statements.add(subject.target_key.first.name, :numeq, quote_value(value), affirmative)
94
+ return
95
+ end
82
96
 
83
97
  if value.kind_of?(Range) && value.exclude_end?
84
98
  operation = BooleanOperation.new(:and,
@@ -1,4 +1,5 @@
1
1
  require 'dm-tokyo-adapter/cabinet'
2
+ require 'rufus/tokyo/tyrant'
2
3
 
3
4
  module DataMapper
4
5
  module Adapters
data/test/helper.rb CHANGED
@@ -20,10 +20,18 @@ class Test::Unit::TestCase
20
20
 
21
21
  # after :teardown do
22
22
  def teardown
23
- descendants = DataMapper::Model.descendants.dup.to_a
23
+ descendants = DataMapper::Model.descendants.to_a
24
24
  while model = descendants.shift
25
- descendants.concat(model.descendants) if model.respond_to?(:descendants)
26
- Object.send(:remove_const, model.name.to_sym)
25
+ descendants.concat(model.descendants.to_a - [ model ])
26
+
27
+ parts = model.name.split('::')
28
+ constant_name = parts.pop.to_sym
29
+ base = parts.empty? ? Object : Object.full_const_get(parts.join('::'))
30
+
31
+ if base.const_defined?(constant_name)
32
+ base.send(:remove_const, constant_name)
33
+ end
34
+
27
35
  DataMapper::Model.descendants.delete(model)
28
36
  end
29
37
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shanna-dm-tokyo-adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shane Hanna
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-06-18 00:00:00 -07:00
12
+ date: 2009-08-09 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -32,10 +32,12 @@ extra_rdoc_files:
32
32
  - LICENSE
33
33
  - README.rdoc
34
34
  files:
35
+ - .gitignore
35
36
  - LICENSE
36
37
  - README.rdoc
37
38
  - Rakefile
38
39
  - VERSION.yml
40
+ - dm-tokyo-adapter.gemspec
39
41
  - lib/dm-tokyo-adapter.rb
40
42
  - lib/dm-tokyo-adapter/cabinet.rb
41
43
  - lib/dm-tokyo-adapter/query.rb
@@ -46,6 +48,7 @@ files:
46
48
  - test/test_tyrant.rb
47
49
  has_rdoc: false
48
50
  homepage: http://github.com/shanna/dm-tokyo-adapter
51
+ licenses:
49
52
  post_install_message:
50
53
  rdoc_options:
51
54
  - --charset=UTF-8
@@ -66,7 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
66
69
  requirements: []
67
70
 
68
71
  rubyforge_project:
69
- rubygems_version: 1.2.0
72
+ rubygems_version: 1.3.5
70
73
  signing_key:
71
74
  specification_version: 3
72
75
  summary: Tokyo Cabinet/Tyrant Table DataMapper Adapter.