odba 1.1.8 → 1.2.0

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.
data/test/test_stub.rb CHANGED
@@ -1,175 +1,187 @@
1
1
  #!/usr/bin/env ruby
2
- # encoding: utf-8
3
2
  # ODBA::TestStub -- odba -- 08.12.2011 -- mhatakeyama@ywesee.com
4
-
5
- $: << File.expand_path('../lib/', File.dirname(__FILE__))
6
- $: << File.dirname(__FILE__)
7
- require 'minitest/autorun'
8
- require 'flexmock/test_unit'
9
- require 'flexmock'
10
- require 'odba/stub'
11
- require 'odba/persistable'
12
- require 'odba/odba'
13
- require 'yaml'
3
+ require_relative "helper"
4
+ require "odba/stub"
5
+ require "odba/persistable"
6
+ require "odba/odba"
7
+ require "yaml"
14
8
 
15
9
  module ODBA
16
- class Stub
17
- attr_accessor :receiver, :odba_class
18
- end
19
- class TestStub < Minitest::Test
10
+ class Stub
11
+ attr_accessor :receiver, :odba_class
12
+ end
13
+
14
+ class TestStub < Test::Unit::TestCase
20
15
  include FlexMock::TestCase
21
- def setup
22
- @odba_container = flexmock("odba_container")
23
- @cache = ODBA.cache = flexmock("cache")
24
- @receiver = flexmock("receiver")
25
- @stub = Stub.new(9, @odba_container, @receiver)
26
- end
16
+ def setup
17
+ @odba_container = flexmock("odba_container")
18
+ @cache = ODBA.cache = flexmock("cache")
19
+ @receiver = flexmock("receiver")
20
+ @stub = Stub.new(9, @odba_container, @receiver)
21
+ end
22
+
27
23
  def teardown
28
24
  @cache = ODBA.cache = nil
29
- super
30
25
  end
31
- def test_method_missing
32
- receiver = flexmock
26
+
27
+ def test_method_missing
28
+ receiver = flexmock
33
29
  @cache.should_receive(:fetch).with(9, FlexMock.any).once.and_return(receiver)
34
30
  receiver.should_receive(:foo_method).with(3)
35
31
  @odba_container.should_receive(:odba_replace_stubs).with(9, FlexMock.any).and_return(@stub)
36
- @stub.foo_method(3)
37
- receiver.flexmock_verify
38
- @odba_container.flexmock_verify
39
- end
40
- def test_method_missing_receiver_nil
41
- @stub.receiver = nil
42
- cache = ODBA.cache
43
- receiver = flexmock
32
+ @stub.foo_method(3)
33
+ receiver.flexmock_verify
34
+ @odba_container.flexmock_verify
35
+ end
36
+
37
+ def test_method_missing_receiver_nil
38
+ @stub.receiver = nil
39
+ cache = ODBA.cache
40
+ receiver = flexmock
44
41
  @cache.should_receive(:fetch).with(FlexMock.any, FlexMock.any).once.and_return(receiver)
45
42
  receiver.should_receive(:foo_method).with(3)
46
43
  @odba_container.should_receive(:odba_replace_stubs).with(FlexMock.any, FlexMock.any).and_return(@stub)
47
- @stub.foo_method(3)
48
- @odba_container.flexmock_verify
49
- cache.flexmock_verify
50
- end
51
- def test_method_missing__odba_class_nil # backward-compatibility
52
- @stub.odba_class = nil
53
- receiver = flexmock
44
+ @stub.foo_method(3)
45
+ @odba_container.flexmock_verify
46
+ cache.flexmock_verify
47
+ end
48
+
49
+ def test_method_missing__odba_class_nil # backward-compatibility
50
+ @stub.odba_class = nil
51
+ receiver = flexmock
54
52
  @cache.should_receive(:fetch).with(FlexMock.any, FlexMock.any).once.and_return(receiver)
55
53
  receiver.should_receive(:foo_method).with(3)
56
54
  @odba_container.should_receive(:odba_replace_stubs).with(FlexMock.any, FlexMock.any)
57
- @stub.foo_method(3)
58
- @odba_container.flexmock_verify
59
- ODBA.cache.flexmock_verify
60
- end
61
- def test_odba_receiver
62
- @cache.should_receive(:fetch).with(9, @odba_container).and_return('odba_instance')
63
- @odba_container.should_receive(:odba_replace_stubs).with(@stub.odba_id, 'odba_instance').and_return(true)
64
- @stub.odba_receiver
65
- end
66
- def test_send_instance_methods
67
- receiver = 'odba_instance'
68
- @odba_container.should_ignore_missing
55
+ @stub.foo_method(3)
56
+ @odba_container.flexmock_verify
57
+ ODBA.cache.flexmock_verify
58
+ end
59
+
60
+ def test_odba_receiver
61
+ @cache.should_receive(:fetch).with(9, @odba_container).and_return("odba_instance")
62
+ @odba_container.should_receive(:odba_replace_stubs).with(@stub.odba_id, "odba_instance").and_return(true)
63
+ @stub.odba_receiver
64
+ end
65
+
66
+ def test_send_instance_methods
67
+ receiver = "odba_instance"
68
+ @odba_container.should_ignore_missing
69
69
  @cache.should_receive(:fetch).with(9, FlexMock.any).once.and_return(receiver)
70
- @stub.taint
71
- skip('Why does this fail')
72
- assert_equal(true, receiver.tainted?)
73
- end
74
- def test_instance_method_not_sent
75
- assert_equal(true, @stub.is_a?(Persistable))
76
- end
77
- def test_send_class
78
- receiver = flexmock
70
+ omit("Why does this fail")
71
+ @stub.taint
72
+ assert_equal(true, receiver.tainted?)
73
+ end
74
+
75
+ def test_instance_method_not_sent
76
+ assert_equal(true, @stub.is_a?(Persistable))
77
+ end
78
+
79
+ def test_send_class
80
+ flexmock
79
81
  @odba_container.should_receive(:odba_replace_stubs).with(FlexMock.any, FlexMock.any)
80
- assert_equal(FlexMock, @stub.class)
81
- end
82
- def test_respond_to
83
- receiver = flexmock('receiver')
82
+ assert_equal(FlexMock, @stub.class)
83
+ end
84
+
85
+ def test_respond_to
86
+ receiver = flexmock("receiver")
84
87
  @odba_container.should_receive(:odba_replace_stubs).with(FlexMock.any, FlexMock.any)
85
88
  @cache.should_receive(:fetch).with(FlexMock.any, FlexMock.any).once.and_return(receiver)
86
- receiver.flexmock_verify
87
- assert_equal(false, @stub.respond_to?(:odba_replace))
88
- end
89
- def test_array_methods
90
- stub = Stub.new(9, [], [])
89
+ receiver.flexmock_verify
90
+ assert_equal(false, @stub.respond_to?(:odba_replace))
91
+ end
92
+
93
+ def test_array_methods
94
+ stub = Stub.new(9, [], [])
91
95
  @cache.should_receive(:fetch).with(FlexMock.any, FlexMock.any).and_return([])
92
- assert_equal([], stub)
93
- stub = Stub.new(9, [], [])
94
- assert([] == stub)
95
- [
96
- "&", "+", "-", "<=>", "==",
97
- "concat", "equal?", "replace", "|"
98
- ].each { |method|
99
- stub = Stub.new(9, [], [])
100
- [].send(method, stub)
101
- }
102
- end
103
- def test_hash_methods
104
- stub = Stub.new(9, [], {})
105
- @cache.should_receive(:fetch).with(FlexMock.any, FlexMock.any).times(5).and_return({} )
106
- assert_equal({}, stub)
107
- stub = Stub.new(9, [], {})
108
- assert({} == stub)
109
- [
110
- "merge", "merge!", "replace",
111
- ].each { |method|
112
- stub = Stub.new(9, [], {})
113
- {}.send(method, stub)
114
- }
115
- end
116
- def test_hash__fetch
117
- stub = Stub.new(9, [], {})
96
+ assert_equal([], stub)
97
+ stub = Stub.new(9, [], [])
98
+ assert([] == stub)
99
+ [
100
+ "&", "+", "-", "<=>", "==",
101
+ "concat", "equal?", "replace", "|"
102
+ ].each { |method|
103
+ stub = Stub.new(9, [], [])
104
+ [].send(method, stub)
105
+ }
106
+ end
107
+
108
+ def test_hash_methods
109
+ stub = Stub.new(9, [], {})
110
+ @cache.should_receive(:fetch).with(FlexMock.any, FlexMock.any).times(5).and_return({})
111
+ assert_equal({}, stub)
112
+ stub = Stub.new(9, [], {})
113
+ assert({} == stub)
114
+ [
115
+ "merge", "merge!", "replace"
116
+ ].each { |method|
117
+ stub = Stub.new(9, [], {})
118
+ {}.send(method, stub)
119
+ }
120
+ end
121
+
122
+ def test_hash__fetch
123
+ stub = Stub.new(9, [], {})
118
124
  @cache.should_receive(:include?).with(9).and_return(false)
119
- @cache.should_receive(:fetch_collection_element).with(9, 'bar').and_return('foo')
120
- assert_equal('foo', stub['bar'])
121
- end
122
- def test_hash__fetch__2
123
- stub = Stub.new(9, [], {})
125
+ @cache.should_receive(:fetch_collection_element).with(9, "bar").and_return("foo")
126
+ assert_equal("foo", stub["bar"])
127
+ end
128
+
129
+ def test_hash__fetch__2
130
+ stub = Stub.new(9, [], {})
124
131
  @cache.should_receive(:include?).with(9).and_return(false)
125
- @cache.should_receive(:fetch_collection_element).with(9, 'bar').and_return(nil)
126
- @cache.should_receive(:fetch).with(9, []).and_return({'bar' => 'foo'})
127
- assert_equal('foo', stub['bar'])
128
- end
129
- def test_hash__fetch__already_in_cache
130
- stub = Stub.new(9, [], {})
132
+ @cache.should_receive(:fetch_collection_element).with(9, "bar").and_return(nil)
133
+ @cache.should_receive(:fetch).with(9, []).and_return({"bar" => "foo"})
134
+ assert_equal("foo", stub["bar"])
135
+ end
136
+
137
+ def test_hash__fetch__already_in_cache
138
+ stub = Stub.new(9, [], {})
131
139
  @cache.should_receive(:include?).with(9).and_return(true)
132
- @cache.should_receive(:fetch).with(9, []).and_return({'bar' => 'foo'})
133
- assert_equal('foo', stub['bar'])
134
- end
135
- def test_hash_key__1
136
- stub = Stub.new(9, nil, nil)
137
- @cache.should_receive(:fetch).with(9, nil).and_return(@receiver)
138
- @cache.should_receive(:fetch).with(9, @odba_container)\
140
+ @cache.should_receive(:fetch).with(9, []).and_return({"bar" => "foo"})
141
+ assert_equal("foo", stub["bar"])
142
+ end
143
+
144
+ def test_hash_key__1
145
+ stub = Stub.new(9, nil, nil)
146
+ @cache.should_receive(:fetch).with(9, nil).and_return(@receiver)
147
+ @cache.should_receive(:fetch).with(9, @odba_container)
139
148
  .and_return(@receiver)
140
- @cache.should_receive(:fetch).with(8, nil).and_return('other')
141
- @odba_container.should_ignore_missing
142
- hash = {stub => 'success'}
143
- assert_equal('success', hash[@stub])
149
+ @cache.should_receive(:fetch).with(8, nil).and_return("other")
150
+ @odba_container.should_ignore_missing
151
+ hash = {stub => "success"}
152
+ assert_equal("success", hash[@stub])
144
153
  other = Stub.new(8, nil, nil)
145
- assert_nil(hash[other])
146
- end
147
- def test_to_yaml
148
- skip "Don't know why the stub does not work for Ruby 2.x or later"
149
- flexmock(@cache, :fetch => nil)
150
- yaml = ''
154
+ assert_nil(hash[other])
155
+ end
156
+
157
+ def test_to_yaml
158
+ omit "Don't know why the stub does not work for Ruby 2.x or later"
159
+ flexmock(@cache, fetch: nil)
151
160
  yaml = @stub.odba_isolated_stub.to_yaml
152
- loaded = YAML.load(yaml)
161
+ loaded = YAML.load(yaml)
153
162
  assert(loaded.is_a?(Stub), "loading from yaml should return a Stub")
154
- assert_equal(9, loaded.odba_id)
155
- end
163
+ assert_equal(9, loaded.odba_id)
164
+ end
165
+
156
166
  def test_odba_clear_receiver
157
- @stub.instance_variable_set('@receiver', flexmock)
167
+ @stub.instance_variable_set(:@receiver, flexmock)
158
168
  @stub.odba_clear_receiver
159
- assert_nil(@stub.instance_variable_get('@receiver'))
169
+ assert_nil(@stub.instance_variable_get(:@receiver))
160
170
  end
171
+
161
172
  def test_odba_unsaved
162
173
  assert_equal(false, @stub.odba_unsaved?)
163
174
  end
164
- def test_hash_key__2
175
+
176
+ def test_hash_key__2
165
177
  receiver = Object.new
166
178
  receiver.extend(Persistable)
167
- receiver.instance_variable_set('@odba_id', 9)
179
+ receiver.instance_variable_set(:@odba_id, 9)
168
180
  stub = Stub.new(9, nil, nil)
169
181
  @cache.should_receive(:fetch).with(9, nil).and_return(receiver)
170
- hash = {stub => 'success'}
171
- assert_equal('success', hash[stub])
172
- assert_equal('success', hash[receiver])
173
- end
174
- end
182
+ hash = {stub => "success"}
183
+ assert_equal("success", hash[stub])
184
+ assert_equal("success", hash[receiver])
185
+ end
186
+ end
175
187
  end
metadata CHANGED
@@ -1,15 +1,56 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: odba
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.8
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masaomi Hatakeyama, Zeno R.R. Davatz
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2021-03-11 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: observer
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '0'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: '0'
26
+ - !ruby/object:Gem::Dependency
27
+ name: drb
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ - !ruby/object:Gem::Dependency
41
+ name: stringio
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ type: :runtime
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
13
54
  - !ruby/object:Gem::Dependency
14
55
  name: ydbi
15
56
  requirement: !ruby/object:Gem::Requirement
@@ -84,18 +125,18 @@ dependencies:
84
125
  name: flexmock
85
126
  requirement: !ruby/object:Gem::Requirement
86
127
  requirements:
87
- - - ">="
128
+ - - '='
88
129
  - !ruby/object:Gem::Version
89
- version: '0'
130
+ version: 2.4.0
90
131
  type: :development
91
132
  prerelease: false
92
133
  version_requirements: !ruby/object:Gem::Requirement
93
134
  requirements:
94
- - - ">="
135
+ - - '='
95
136
  - !ruby/object:Gem::Version
96
- version: '0'
137
+ version: 2.4.0
97
138
  - !ruby/object:Gem::Dependency
98
- name: minitest
139
+ name: test-unit
99
140
  requirement: !ruby/object:Gem::Requirement
100
141
  requirements:
101
142
  - - ">="
@@ -109,7 +150,7 @@ dependencies:
109
150
  - !ruby/object:Gem::Version
110
151
  version: '0'
111
152
  - !ruby/object:Gem::Dependency
112
- name: test-unit
153
+ name: debug
113
154
  requirement: !ruby/object:Gem::Requirement
114
155
  requirements:
115
156
  - - ">="
@@ -123,7 +164,7 @@ dependencies:
123
164
  - !ruby/object:Gem::Version
124
165
  version: '0'
125
166
  - !ruby/object:Gem::Dependency
126
- name: debug_inspector
167
+ name: simplecov
127
168
  requirement: !ruby/object:Gem::Requirement
128
169
  requirements:
129
170
  - - ">="
@@ -142,18 +183,18 @@ executables: []
142
183
  extensions: []
143
184
  extra_rdoc_files: []
144
185
  files:
186
+ - ".github/workflows/devenv.yml"
145
187
  - ".github/workflows/ruby.yml"
146
188
  - ".gitignore"
147
189
  - Gemfile
148
- - Guide.txt
149
- - History.txt
190
+ - History.md
150
191
  - LICENSE.txt
151
- - Manifest.txt
152
192
  - README.md
153
193
  - Rakefile
154
- - install.rb
194
+ - devenv.lock
195
+ - devenv.nix
196
+ - devenv.yaml
155
197
  - lib/odba.rb
156
- - lib/odba/18_19_loading_compatibility.rb
157
198
  - lib/odba/cache.rb
158
199
  - lib/odba/cache_entry.rb
159
200
  - lib/odba/connection_pool.rb
@@ -174,6 +215,9 @@ files:
174
215
  - sql/create_tables.sql
175
216
  - sql/object.sql
176
217
  - sql/object_connection.sql
218
+ - test/example.rb
219
+ - test/helper.rb
220
+ - test/suite.rb
177
221
  - test/test_array.rb
178
222
  - test/test_cache.rb
179
223
  - test/test_cache_entry.rb
@@ -189,8 +233,8 @@ files:
189
233
  homepage: https://github.com/zdavatz/odba
190
234
  licenses:
191
235
  - GPL-v2
192
- metadata: {}
193
- post_install_message:
236
+ metadata:
237
+ changelog_uri: https://github.com/zdavatz/odba/blob/master/History.md
194
238
  rdoc_options: []
195
239
  require_paths:
196
240
  - lib
@@ -198,15 +242,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
198
242
  requirements:
199
243
  - - ">="
200
244
  - !ruby/object:Gem::Version
201
- version: '0'
245
+ version: '3.2'
202
246
  required_rubygems_version: !ruby/object:Gem::Requirement
203
247
  requirements:
204
248
  - - ">="
205
249
  - !ruby/object:Gem::Version
206
250
  version: '0'
207
251
  requirements: []
208
- rubygems_version: 3.2.4
209
- signing_key:
252
+ rubygems_version: 3.6.9
210
253
  specification_version: 4
211
254
  summary: Ruby Software for ODDB.org Memory Management
212
255
  test_files: []
data/Guide.txt DELETED
@@ -1,36 +0,0 @@
1
- = odba
2
-
3
- ODBA is an unintrusive Object Cache system. It adresses the crosscutting
4
- concern of object storage by disconnecting and serializing objects into
5
- storage. All disconnected connections are replaced by instances of
6
- ODBA::Stub, thus enabling transparent object-loading.
7
-
8
- == ODBA supports
9
-
10
- * transparent loading of connected objects
11
- * index-vectors
12
- * transactions
13
- * transparently fetches Hash-Elements without loading the entire Hash
14
-
15
- == Example
16
- include 'odba'
17
-
18
- # connect default storage manager to a relational database
19
- ODBA.storage.dbi = ODBA::ConnectionPool.new('DBI::pg::database', 'user', 'pw')
20
-
21
- class Counter
22
- include ODBA::Persistable
23
- def initialize
24
- @pos = 0
25
- end
26
- def up
27
- @pos += 1
28
- self.odba_store
29
- @pos
30
- end
31
- def down
32
- @pos -= 1
33
- self.odba_store
34
- @pos
35
- end
36
- end
data/Manifest.txt DELETED
@@ -1,38 +0,0 @@
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