odba 1.1.0 → 1.1.1
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.
- checksums.yaml +7 -0
- data/.gitignore +4 -0
- data/.travis.yml +25 -0
- data/Gemfile +17 -0
- data/History.txt +5 -0
- data/Manifest.txt +38 -0
- data/Rakefile +23 -23
- data/lib/odba.rb +0 -4
- data/lib/odba/cache.rb +1 -0
- data/lib/odba/cache_entry.rb +1 -0
- data/lib/odba/version.rb +5 -0
- data/odba.gemspec +29 -0
- data/test/suite.rb +4 -0
- data/test/test_array.rb +18 -11
- data/test/test_cache.rb +7 -9
- data/test/test_cache_entry.rb +5 -2
- data/test/test_connection_pool.rb +5 -5
- data/test/test_drbwrapper.rb +3 -3
- data/test/test_hash.rb +13 -10
- data/test/test_id_server.rb +7 -6
- data/test/test_index.rb +14 -11
- data/test/test_marshal.rb +6 -3
- data/test/test_persistable.rb +87 -155
- data/test/test_storage.rb +46 -27
- data/test/test_stub.rb +46 -102
- metadata +98 -50
- data/.gemtest +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8d7feacfaca66cd9d136d8a6b1d0d35e0a26c046
|
4
|
+
data.tar.gz: 540b6e0e36cfbff7206bb7d84aafd7677c2852b0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9038775f0f5c6f3402f258c5032c5ea5e3d64cae9f96cbde6de5a541c3a7721580e084050d6b1d6984168c259741485b47a0f3a7d6415b6ddb2da23594de1ace
|
7
|
+
data.tar.gz: 3e8711cf9e9ccc07d073bbf56f98afd1300e636cfdac25b294b1a7cae0c1c37593f38308be88045cc26ef69048a89d284714a5b47acf7454c8942a5cc2845f6a
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
language: ruby
|
2
|
+
cache: bundler
|
3
|
+
sudo: false
|
4
|
+
before_install:
|
5
|
+
- gem install bundler
|
6
|
+
|
7
|
+
install:
|
8
|
+
- bundle install --without debugger
|
9
|
+
|
10
|
+
script:
|
11
|
+
- bundle exec ruby test/suite.rb
|
12
|
+
|
13
|
+
notifications:
|
14
|
+
email:
|
15
|
+
- ngiger@ywesee.com
|
16
|
+
rvm:
|
17
|
+
- ruby-head
|
18
|
+
- 2.2.3
|
19
|
+
- 2.1.7
|
20
|
+
- 2.0.0
|
21
|
+
- 1.9.3
|
22
|
+
matrix:
|
23
|
+
allow_failures:
|
24
|
+
- rvm: ruby-head
|
25
|
+
- 1.8.7
|
data/Gemfile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
gemspec
|
4
|
+
|
5
|
+
group 'test' do
|
6
|
+
gem 'flexmock', "~> 1.3.0"
|
7
|
+
gem 'test-unit'
|
8
|
+
gem 'minitest'
|
9
|
+
end
|
10
|
+
|
11
|
+
group 'debugger' do
|
12
|
+
gem 'pry'
|
13
|
+
gem 'pry-nav'
|
14
|
+
gem 'pry-rescue'
|
15
|
+
gem 'pry-stack_explorer'
|
16
|
+
gem 'pry-doc'
|
17
|
+
end
|
data/History.txt
CHANGED
data/Manifest.txt
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
Guide.txt
|
2
|
+
History.txt
|
3
|
+
LICENSE.txt
|
4
|
+
README.txt
|
5
|
+
Rakefile
|
6
|
+
install.rb
|
7
|
+
lib/odba.rb
|
8
|
+
lib/odba/18_19_loading_compatibility.rb
|
9
|
+
lib/odba/cache.rb
|
10
|
+
lib/odba/cache_entry.rb
|
11
|
+
lib/odba/connection_pool.rb
|
12
|
+
lib/odba/drbwrapper.rb
|
13
|
+
lib/odba/id_server.rb
|
14
|
+
lib/odba/index.rb
|
15
|
+
lib/odba/index_definition.rb
|
16
|
+
lib/odba/marshal.rb
|
17
|
+
lib/odba/odba.rb
|
18
|
+
lib/odba/odba_error.rb
|
19
|
+
lib/odba/persistable.rb
|
20
|
+
lib/odba/storage.rb
|
21
|
+
lib/odba/stub.rb
|
22
|
+
sql/collection.sql
|
23
|
+
sql/create_tables.sql
|
24
|
+
sql/object.sql
|
25
|
+
sql/object_connection.sql
|
26
|
+
test/suite.rb
|
27
|
+
test/test_array.rb
|
28
|
+
test/test_cache.rb
|
29
|
+
test/test_cache_entry.rb
|
30
|
+
test/test_connection_pool.rb
|
31
|
+
test/test_drbwrapper.rb
|
32
|
+
test/test_hash.rb
|
33
|
+
test/test_id_server.rb
|
34
|
+
test/test_index.rb
|
35
|
+
test/test_marshal.rb
|
36
|
+
test/test_persistable.rb
|
37
|
+
test/test_storage.rb
|
38
|
+
test/test_stub.rb
|
data/Rakefile
CHANGED
@@ -1,30 +1,30 @@
|
|
1
|
-
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
lib = File.expand_path('../lib', __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'odba/version'
|
6
|
+
require "bundler/gem_tasks"
|
7
|
+
require 'rake/testtask'
|
2
8
|
|
3
|
-
|
4
|
-
require 'hoe'
|
9
|
+
# dependencies are now declared in odba.gemspec
|
5
10
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
# Hoe.plugin :gem_prelude_sucks
|
11
|
-
# Hoe.plugin :inline
|
12
|
-
# Hoe.plugin :inline
|
13
|
-
# Hoe.plugin :manifest
|
14
|
-
# Hoe.plugin :newgem
|
15
|
-
# Hoe.plugin :racc
|
16
|
-
# Hoe.plugin :rubyforge
|
17
|
-
# Hoe.plugin :rubyforge
|
18
|
-
# Hoe.plugin :website
|
19
|
-
|
20
|
-
Hoe.spec 'odba' do
|
21
|
-
# HEY! If you fill these out in ~/.hoe_template/Rakefile.erb then
|
22
|
-
# you'll never have to touch them again!
|
23
|
-
# (delete this comment too, of course)
|
11
|
+
desc 'Offer a gem task like hoe'
|
12
|
+
task :gem => :build do
|
13
|
+
Rake::Task[:build].invoke
|
14
|
+
end
|
24
15
|
|
25
|
-
|
16
|
+
desc "Run tests"
|
17
|
+
task :default => :test
|
26
18
|
|
27
|
-
|
19
|
+
desc 'Run odba with all commonly used combinations'
|
20
|
+
task :test do
|
21
|
+
log_file = 'suite.log'
|
22
|
+
res = system("bash -c 'set -o pipefail && bundle exec ruby test/suite.rb 2>&1 | tee #{log_file}'")
|
23
|
+
puts "Running test/suite.rb returned #{res.inspect}. Output was redirected to #{log_file}"
|
24
|
+
exit 1 unless res
|
28
25
|
end
|
29
26
|
|
27
|
+
require 'rake/clean'
|
28
|
+
CLEAN.include FileList['pkg/*.gem']
|
29
|
+
|
30
30
|
# vim: syntax=ruby
|
data/lib/odba.rb
CHANGED
data/lib/odba/cache.rb
CHANGED
data/lib/odba/cache_entry.rb
CHANGED
@@ -45,6 +45,7 @@ module ODBA
|
|
45
45
|
odba_id && ODBA.cache.include?(odba_id) && ODBA.cache.fetch(odba_id)
|
46
46
|
end
|
47
47
|
def odba_add_reference(object)
|
48
|
+
return unless object.respond_to?(:odba_id)
|
48
49
|
@cache_entry_mutex.synchronize do
|
49
50
|
@accessed_by.store(object.object_id, object.odba_id)
|
50
51
|
end
|
data/lib/odba/version.rb
ADDED
data/odba.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'odba/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "odba"
|
8
|
+
spec.version = Odba::VERSION
|
9
|
+
spec.author = "Masaomi Hatakeyama, Zeno R.R. Davatz"
|
10
|
+
spec.email = "mhatakeyama@ywesee.com, zdavatz@ywesee.com"
|
11
|
+
spec.description = "Object Database Access"
|
12
|
+
spec.summary = "Ruby Software for ODDB.org Memory Management"
|
13
|
+
spec.homepage = "https://github.com/zdavatz/odba"
|
14
|
+
spec.license = "GPL-v2"
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
# spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_dependency 'ydbi','>=0.5.0'
|
21
|
+
spec.add_dependency 'dbd-pg', '0.3.9'
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
spec.add_development_dependency "flexmock"
|
26
|
+
spec.add_development_dependency "simplecov"
|
27
|
+
spec.add_development_dependency "minitest" if /^1\./.match(RUBY_VERSION)
|
28
|
+
end
|
29
|
+
|
data/test/suite.rb
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
2
3
|
# suite.rb -- oddb -- 20.11.2002 -- hwyss@ywesee.com
|
3
4
|
|
4
5
|
$: << File.expand_path(File.dirname(__FILE__))
|
6
|
+
require 'minitest'
|
7
|
+
require 'simplecov'
|
8
|
+
SimpleCov.start
|
5
9
|
|
6
10
|
Dir.foreach(File.dirname(__FILE__)) { |file|
|
7
11
|
require file if /^test_.*\.rb$/o.match(file)
|
data/test/test_array.rb
CHANGED
@@ -4,28 +4,35 @@
|
|
4
4
|
$: << File.dirname(__FILE__)
|
5
5
|
$: << File.expand_path('../lib', File.dirname(__FILE__))
|
6
6
|
|
7
|
-
require '
|
7
|
+
require 'minitest/autorun'
|
8
8
|
require 'flexmock'
|
9
9
|
require 'odba/persistable'
|
10
10
|
require 'odba/stub'
|
11
11
|
require 'odba/odba'
|
12
12
|
|
13
13
|
module ODBA
|
14
|
-
class TestArray < Test
|
14
|
+
class TestArray < Minitest::Test
|
15
15
|
include FlexMock::TestCase
|
16
|
-
class
|
16
|
+
class ODBAContainerInArrayInArray
|
17
17
|
include ODBA::Persistable
|
18
18
|
attr_accessor :non_replaceable, :replaceable, :array, :odba_id
|
19
19
|
end
|
20
|
-
class
|
20
|
+
class ContainerInArray
|
21
21
|
attr_accessor :content
|
22
22
|
end
|
23
23
|
def setup
|
24
24
|
@array = Array.new
|
25
25
|
ODBA.storage = flexmock("storage")
|
26
|
-
ODBA.marshaller = flexmock("
|
26
|
+
ODBA.marshaller = flexmock("marshaller_array")
|
27
27
|
ODBA.cache = flexmock("cache")
|
28
28
|
end
|
29
|
+
def teardown
|
30
|
+
ODBA.storage = nil
|
31
|
+
ODBA.marshaller = nil
|
32
|
+
ODBA.cache = nil
|
33
|
+
load = File.expand_path(File.join(File.dirname(__FILE__), '../lib/odba/storage.rb'))
|
34
|
+
super
|
35
|
+
end
|
29
36
|
def test_odba_cut_connection
|
30
37
|
remove_obj = Object
|
31
38
|
remove_obj.extend(ODBA::Persistable)
|
@@ -36,8 +43,8 @@ module ODBA
|
|
36
43
|
assert_equal(0, array.odba_cut_connection(remove_obj).size)
|
37
44
|
end
|
38
45
|
def test_odba_unsaved_neighbors_array
|
39
|
-
rep1 =
|
40
|
-
rep2 =
|
46
|
+
rep1 = ODBAContainerInArrayInArray.new
|
47
|
+
rep2 = ODBAContainerInArrayInArray.new
|
41
48
|
@array.push(rep1)
|
42
49
|
@array.push(rep2)
|
43
50
|
result = @array.odba_unsaved_neighbors(1)
|
@@ -85,18 +92,18 @@ module ODBA
|
|
85
92
|
assert_equal(reloaded, modified)
|
86
93
|
end
|
87
94
|
def test_odba_target_ids
|
88
|
-
o =
|
95
|
+
o = ODBAContainerInArrayInArray.new
|
89
96
|
o.odba_id = 1
|
90
|
-
p =
|
97
|
+
p = ODBAContainerInArrayInArray.new
|
91
98
|
p.odba_id = 2
|
92
|
-
q =
|
99
|
+
q = ODBAContainerInArrayInArray.new
|
93
100
|
q.odba_id = 3
|
94
101
|
@array.push(p, q)
|
95
102
|
@array.instance_variable_set('@foo', o)
|
96
103
|
assert_equal([1,2,3], @array.odba_target_ids)
|
97
104
|
end
|
98
105
|
def test_stubize
|
99
|
-
item =
|
106
|
+
item = ODBAContainerInArrayInArray.new
|
100
107
|
@array.push(item)
|
101
108
|
@array.odba_stubize(item)
|
102
109
|
first = @array.first
|
data/test/test_cache.rb
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
$: << File.dirname(__FILE__)
|
6
6
|
$: << File.expand_path('../lib/', File.dirname(__FILE__))
|
7
7
|
|
8
|
-
require '
|
8
|
+
require 'minitest/autorun'
|
9
9
|
require 'flexmock'
|
10
10
|
require 'odba/cache'
|
11
11
|
require 'odba/cache_entry'
|
@@ -24,9 +24,9 @@ module ODBA
|
|
24
24
|
attr_writer :indices
|
25
25
|
public :load_object
|
26
26
|
end
|
27
|
-
class TestCache < Test
|
27
|
+
class TestCache < Minitest::Test
|
28
28
|
include FlexMock::TestCase
|
29
|
-
class
|
29
|
+
class ODBAContainerInCache
|
30
30
|
include ODBA::Persistable
|
31
31
|
attr_accessor :odba_connection, :odba_id
|
32
32
|
end
|
@@ -345,9 +345,7 @@ module ODBA
|
|
345
345
|
[[2, foo]]
|
346
346
|
}
|
347
347
|
prepare_bulk_restore([foo])
|
348
|
-
|
349
|
-
@cache.prefetch
|
350
|
-
}
|
348
|
+
@cache.prefetch
|
351
349
|
end
|
352
350
|
def test_fill_index
|
353
351
|
foo = flexmock("foo")
|
@@ -448,9 +446,9 @@ module ODBA
|
|
448
446
|
}
|
449
447
|
end
|
450
448
|
def test_delete
|
451
|
-
delete_item =
|
449
|
+
delete_item = ODBAContainerInCache.new
|
452
450
|
delete_item.odba_id = 1
|
453
|
-
origin_obj =
|
451
|
+
origin_obj = ODBAContainerInCache.new
|
454
452
|
origin_obj.odba_id = 2
|
455
453
|
origin_obj.odba_connection = delete_item
|
456
454
|
@cache.fetched.store(1, delete_item)
|
@@ -656,7 +654,7 @@ module ODBA
|
|
656
654
|
.times(1).and_return(o1)
|
657
655
|
@marshal.should_receive(:load).with('dump2')\
|
658
656
|
.times(1).and_return(o2)
|
659
|
-
assert_equal([o1, o2], @cache.extent(
|
657
|
+
assert_equal([o1, o2], @cache.extent(ODBAContainerInCache, clr))
|
660
658
|
end
|
661
659
|
def test_fetch_collection
|
662
660
|
obj = flexmock('Object')
|
data/test/test_cache_entry.rb
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
$: << File.dirname(__FILE__)
|
5
5
|
$: << File.expand_path("../lib", File.dirname(__FILE__))
|
6
6
|
|
7
|
-
require '
|
7
|
+
require 'minitest/autorun'
|
8
8
|
require 'flexmock'
|
9
9
|
require 'odba/cache_entry'
|
10
10
|
require 'odba/odba'
|
@@ -14,7 +14,7 @@ module ODBA
|
|
14
14
|
class CacheEntry
|
15
15
|
attr_accessor :accessed_by
|
16
16
|
end
|
17
|
-
class TestCacheEntry < Test
|
17
|
+
class TestCacheEntry < Minitest::Test
|
18
18
|
include FlexMock::TestCase
|
19
19
|
def setup
|
20
20
|
@mock = flexmock
|
@@ -26,6 +26,9 @@ module ODBA
|
|
26
26
|
ODBA.cache.should_receive(:retire_age).and_return(0.9)
|
27
27
|
ODBA.cache.should_receive(:destroy_age).and_return(0.9)
|
28
28
|
end
|
29
|
+
def teardown
|
30
|
+
super
|
31
|
+
end
|
29
32
|
def test_retire_check
|
30
33
|
@mock.should_receive(:odba_unsaved?).and_return { false }
|
31
34
|
@mock.should_receive(:odba_unsaved?).and_return { false }
|
@@ -3,17 +3,17 @@
|
|
3
3
|
|
4
4
|
$: << File.expand_path('../lib', File.dirname(__FILE__))
|
5
5
|
|
6
|
-
require '
|
6
|
+
require 'minitest/autorun'
|
7
7
|
require 'flexmock'
|
8
8
|
require 'odba/connection_pool'
|
9
9
|
## connection_pool requires 'dbi', which unshifts the site_ruby dir
|
10
10
|
# to the first position in $LOAD_PATH ( == $: ). As a result, files are
|
11
11
|
# loaded from site_ruby if they are installed there, and thus ignored
|
12
12
|
# by rcov. Workaround:
|
13
|
-
$:.shift
|
13
|
+
# $:.shift
|
14
14
|
|
15
15
|
module ODBA
|
16
|
-
class TestConnectionPool < Test
|
16
|
+
class TestConnectionPool < Minitest::Test
|
17
17
|
include FlexMock::TestCase
|
18
18
|
def test_survive_error
|
19
19
|
flexstub(DBI).should_receive(:connect).times(10).and_return {
|
@@ -28,7 +28,7 @@ module ODBA
|
|
28
28
|
## after the first error is raised, ConnectionPool reconnects.
|
29
29
|
}
|
30
30
|
}
|
31
|
-
|
31
|
+
pool.execute('statement')
|
32
32
|
end
|
33
33
|
def test_multiple_errors__give_up
|
34
34
|
flexstub(DBI).should_receive(:connect).times(20).and_return {
|
@@ -71,7 +71,7 @@ module ODBA
|
|
71
71
|
conn
|
72
72
|
}
|
73
73
|
pool = ConnectionPool.new()
|
74
|
-
|
74
|
+
pool.disconnect
|
75
75
|
end
|
76
76
|
end
|
77
77
|
end
|
data/test/test_drbwrapper.rb
CHANGED
@@ -3,12 +3,12 @@
|
|
3
3
|
|
4
4
|
$: << File.expand_path('../lib', File.dirname(__FILE__))
|
5
5
|
|
6
|
-
require '
|
6
|
+
require 'minitest/autorun'
|
7
7
|
require 'odba/drbwrapper'
|
8
8
|
require 'flexmock'
|
9
9
|
|
10
10
|
module ODBA
|
11
|
-
class TestDRbWrapper < Test
|
11
|
+
class TestDRbWrapper < Minitest::Test
|
12
12
|
include FlexMock::TestCase
|
13
13
|
def test_include
|
14
14
|
obj = FlexMock.new
|
@@ -52,7 +52,7 @@ module ODBA
|
|
52
52
|
}
|
53
53
|
end
|
54
54
|
end
|
55
|
-
class TestDRbIdConv < Test
|
55
|
+
class TestDRbIdConv < Minitest::Test
|
56
56
|
include FlexMock::TestCase
|
57
57
|
def setup
|
58
58
|
ODBA.cache = flexmock('cache')
|