perobs 4.5.0 → 4.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +38 -0
- data/.gitignore +0 -1
- data/Gemfile +1 -0
- data/lib/perobs/Array.rb +25 -30
- data/lib/perobs/BigArray.rb +16 -29
- data/lib/perobs/BigArrayNode.rb +82 -96
- data/lib/perobs/BigHash.rb +14 -24
- data/lib/perobs/BigTree.rb +7 -17
- data/lib/perobs/BigTreeNode.rb +101 -122
- data/lib/perobs/ClassMap.rb +6 -0
- data/lib/perobs/DataBase.rb +19 -14
- data/lib/perobs/IDList.rb +2 -2
- data/lib/perobs/Store.rb +1 -1
- data/lib/perobs/version.rb +1 -1
- data/perobs.gemspec +3 -2
- data/test/Array_spec.rb +55 -59
- data/test/BTreeDB_spec.rb +5 -1
- data/test/BigTreeNode_spec.rb +5 -8
- data/test/LegacyDBs/version_4.1/class_map.json +1 -0
- data/test/LegacyDBs/version_4.1/config.json +1 -0
- data/test/LegacyDBs/version_4.1/database.blobs +0 -0
- data/test/LegacyDBs/version_4.1/database_spaces.blobs +0 -0
- data/test/LegacyDBs/version_4.1/index.blobs +0 -0
- data/test/LegacyDBs/version_4.1/log +5 -0
- data/test/LegacyDBs/version_4.1/version +1 -0
- data/test/spec_helper.rb +1 -1
- metadata +38 -9
data/test/Array_spec.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
3
|
# Copyright (c) 2015, 2016 by Chris Schlaeger <chris@taskjuggler.org>
|
4
4
|
#
|
5
5
|
# This file contains tests for Array that are similar to the tests for the
|
@@ -27,12 +27,11 @@
|
|
27
27
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
28
28
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
29
29
|
|
30
|
-
|
30
|
+
require_relative 'spec_helper'
|
31
31
|
|
32
|
-
|
32
|
+
require_relative '../lib/perobs'
|
33
33
|
|
34
34
|
class PO < PEROBS::Object
|
35
|
-
|
36
35
|
attr_persist :name
|
37
36
|
|
38
37
|
def initialize(store, name = nil)
|
@@ -43,11 +42,9 @@ class PO < PEROBS::Object
|
|
43
42
|
def get_self
|
44
43
|
self # Never do this in real user code!
|
45
44
|
end
|
46
|
-
|
47
45
|
end
|
48
46
|
|
49
47
|
describe PEROBS::Array do
|
50
|
-
|
51
48
|
before(:all) do
|
52
49
|
@db_name = generate_db_name(__FILE__)
|
53
50
|
end
|
@@ -99,14 +96,14 @@ describe PEROBS::Array do
|
|
99
96
|
a[0] = 'A'
|
100
97
|
a[1] = 'B'
|
101
98
|
a[2] = 'C'
|
102
|
-
vs =
|
99
|
+
vs = String.new
|
103
100
|
a.each { |v| vs << v }
|
104
101
|
expect(vs).to eq('ABC')
|
105
102
|
@store.exit
|
106
103
|
|
107
104
|
@store = PEROBS::Store.new(@db_name)
|
108
105
|
a = @store['a']
|
109
|
-
vs =
|
106
|
+
vs = String.new
|
110
107
|
a[3] = @store.new(PO, 'D')
|
111
108
|
a.each { |v| vs << (v.is_a?(String) ? v : v.name) }
|
112
109
|
expect(vs).to eq('ABCD')
|
@@ -127,125 +124,125 @@ describe PEROBS::Array do
|
|
127
124
|
end
|
128
125
|
|
129
126
|
it 'should support reading methods' do
|
130
|
-
expect(cpa([
|
131
|
-
expect(cpa & cpa([
|
127
|
+
expect(cpa([1, 1, 3, 5]) & cpa([1, 2, 3])).to eq([1, 3])
|
128
|
+
expect(cpa & cpa([1, 2, 3])).to eq([])
|
132
129
|
|
133
130
|
expect(cpa.empty?).to be true
|
134
|
-
expect(cpa([
|
131
|
+
expect(cpa([0]).empty?).to be false
|
135
132
|
|
136
|
-
x = cpa([
|
133
|
+
x = cpa(['it', 'came', 'to', 'pass', 'that', '...'])
|
137
134
|
x = x.sort.join(' ')
|
138
135
|
expect(x).to eq('... came it pass that to')
|
139
136
|
end
|
140
137
|
|
141
138
|
it 'should support Enumberable methods' do
|
142
|
-
x = cpa([
|
139
|
+
x = cpa([2, 5, 3, 1, 7])
|
143
140
|
expect(x.find { |e| e == 4 }).to be_nil
|
144
141
|
expect(x.find { |e| e == 3 }).to eq(3)
|
145
142
|
end
|
146
143
|
|
147
144
|
it 'should support re-writing methods' do
|
148
145
|
x = cpa([2, 5, 3, 1, 7])
|
149
|
-
x.sort!{ |a, b| a <=> b }
|
150
|
-
pcheck { expect(@store['a']).to eq([
|
151
|
-
@store['a'].sort!{ |a, b| b - a }
|
152
|
-
pcheck { expect(@store['a']).to eq([
|
146
|
+
x.sort! { |a, b| a <=> b }
|
147
|
+
pcheck { expect(@store['a']).to eq([1, 2, 3, 5, 7]) }
|
148
|
+
@store['a'].sort! { |a, b| b - a }
|
149
|
+
pcheck { expect(@store['a']).to eq([7, 5, 3, 2, 1]) }
|
153
150
|
|
154
151
|
@store['a'].clear
|
155
152
|
pcheck { expect(@store['a']).to eq([]) }
|
156
153
|
end
|
157
154
|
|
158
155
|
it 'should support <<()' do
|
159
|
-
a = cpa([
|
156
|
+
a = cpa([0, 1, 2])
|
160
157
|
a << 4
|
161
|
-
pcheck { expect(@store['a']).to eq([
|
158
|
+
pcheck { expect(@store['a']).to eq([0, 1, 2, 4]) }
|
162
159
|
end
|
163
160
|
|
164
161
|
it 'should support []=' do
|
165
|
-
a = cpa([
|
162
|
+
a = cpa([0, nil, 2])
|
166
163
|
a[1] = 1
|
167
|
-
pcheck { expect(@store['a']).to eq([
|
164
|
+
pcheck { expect(@store['a']).to eq([0, 1, 2]) }
|
168
165
|
end
|
169
166
|
|
170
167
|
it 'should support collect!()' do
|
171
|
-
a = cpa([
|
168
|
+
a = cpa([1, 'cat', 1..1])
|
172
169
|
if RUBY_VERSION < '2.2'
|
173
|
-
expect(a.collect! { |e| e.class.to_s }.to_a).to eq([
|
174
|
-
pcheck { expect(@store['a'].to_a).to eq([
|
170
|
+
expect(a.collect! { |e| e.class.to_s }.to_a).to eq(%w[Fixnum String Range])
|
171
|
+
pcheck { expect(@store['a'].to_a).to eq(%w[Fixnum String Range]) }
|
175
172
|
else
|
176
|
-
expect(a.collect! { |e| e.class.to_s }.to_a).to eq([
|
177
|
-
pcheck { expect(@store['a'].to_a).to eq([
|
173
|
+
expect(a.collect! { |e| e.class.to_s }.to_a).to eq(%w[Integer String Range])
|
174
|
+
pcheck { expect(@store['a'].to_a).to eq(%w[Integer String Range]) }
|
178
175
|
end
|
179
176
|
|
180
|
-
a = cpa([
|
181
|
-
expect(a.collect! { 99 }).to eq([
|
182
|
-
pcheck { expect(@store['a']).to eq([
|
177
|
+
a = cpa([1, 'cat', 1..1])
|
178
|
+
expect(a.collect! { 99 }).to eq([99, 99, 99])
|
179
|
+
pcheck { expect(@store['a']).to eq([99, 99, 99]) }
|
183
180
|
end
|
184
181
|
|
185
182
|
it 'should support map!()' do
|
186
|
-
a = cpa([
|
183
|
+
a = cpa([1, 'cat', 1..1])
|
187
184
|
if RUBY_VERSION < '2.2'
|
188
|
-
expect(a.map! { |e| e.class.to_s }.to_a).to eq([
|
189
|
-
pcheck { expect(@store['a'].to_a).to eq([
|
185
|
+
expect(a.map! { |e| e.class.to_s }.to_a).to eq(%w[Fixnum String Range])
|
186
|
+
pcheck { expect(@store['a'].to_a).to eq(%w[Fixnum String Range]) }
|
190
187
|
else
|
191
|
-
expect(a.map! { |e| e.class.to_s }.to_a).to eq([
|
192
|
-
pcheck { expect(@store['a'].to_a).to eq([
|
188
|
+
expect(a.map! { |e| e.class.to_s }.to_a).to eq(%w[Integer String Range])
|
189
|
+
pcheck { expect(@store['a'].to_a).to eq(%w[Integer String Range]) }
|
193
190
|
end
|
194
191
|
|
195
|
-
a = cpa([
|
196
|
-
expect(a.map! { 99 }).to eq([
|
197
|
-
pcheck { expect(@store['a']).to eq
|
192
|
+
a = cpa([1, 'cat', 1..1])
|
193
|
+
expect(a.map! { 99 }).to eq([99, 99, 99])
|
194
|
+
pcheck { expect(@store['a']).to eq([99, 99, 99]) }
|
198
195
|
end
|
199
196
|
|
200
197
|
it 'should support fill()' do
|
201
198
|
pcheck { expect(cpa([]).fill(99)).to eq([]) }
|
202
199
|
pcheck { expect(cpa([]).fill(99, 0)).to eq([]) }
|
203
|
-
pcheck { expect(cpa([]).fill(99, 0, 1)).to eq([
|
200
|
+
pcheck { expect(cpa([]).fill(99, 0, 1)).to eq([99]) }
|
204
201
|
end
|
205
202
|
|
206
203
|
it 'should support flatten!()' do
|
207
|
-
a1 = cpa([
|
208
|
-
a2 = cpa([
|
209
|
-
a3 = cpa([
|
210
|
-
a4 = cpa([
|
211
|
-
pcheck { expect(@store['a4'].flatten).to eq([
|
204
|
+
a1 = cpa([1, 2, 3], 'a1')
|
205
|
+
a2 = cpa([5, 6], 'a2')
|
206
|
+
a3 = cpa([4, a2], 'a3')
|
207
|
+
a4 = cpa([a1, a3], 'a4')
|
208
|
+
pcheck { expect(@store['a4'].flatten).to eq([1, 2, 3, 4, 5, 6]) }
|
212
209
|
end
|
213
210
|
|
214
211
|
it 'should support replace()' do
|
215
|
-
a1 = cpa([
|
212
|
+
a1 = cpa([1, 2, 3], 'a1')
|
216
213
|
a_id = a1.__id__
|
217
|
-
expect(a1.replace(cpa([4, 5, 6], 'a2'))).to eq([
|
218
|
-
pcheck { expect(@store['a1']).to eq
|
214
|
+
expect(a1.replace(cpa([4, 5, 6], 'a2'))).to eq([4, 5, 6])
|
215
|
+
pcheck { expect(@store['a1']).to eq([4, 5, 6]) }
|
219
216
|
end
|
220
217
|
|
221
218
|
it 'should support insert()' do
|
222
|
-
a = cpa([
|
219
|
+
a = cpa([0])
|
223
220
|
a.insert(1)
|
224
|
-
pcheck { expect(@store['a']).to eq([
|
221
|
+
pcheck { expect(@store['a']).to eq([0]) }
|
225
222
|
@store['a'].insert(1, 1)
|
226
|
-
pcheck { expect(@store['a']).to eq([
|
223
|
+
pcheck { expect(@store['a']).to eq([0, 1]) }
|
227
224
|
end
|
228
225
|
|
229
226
|
it 'should support push()' do
|
230
|
-
a = cpa([
|
227
|
+
a = cpa([1, 2, 3])
|
231
228
|
a.push(4, 5)
|
232
|
-
pcheck { expect(@store['a']).to eq([
|
229
|
+
pcheck { expect(@store['a']).to eq([1, 2, 3, 4, 5]) }
|
233
230
|
@store['a'].push(nil)
|
234
|
-
pcheck { expect(@store['a']).to eq([
|
231
|
+
pcheck { expect(@store['a']).to eq([1, 2, 3, 4, 5, nil]) }
|
235
232
|
end
|
236
233
|
|
237
234
|
it 'should support inspect' do
|
238
|
-
a1 = cpa([
|
239
|
-
a2 = cpa([
|
235
|
+
a1 = cpa([1], 'a1')
|
236
|
+
a2 = cpa([1, a1], 'a2')
|
240
237
|
expect(a1.inspect).to eq("<PEROBS::Array:#{a1._id}>\n[\n 1\n]\n")
|
241
238
|
expect(a2.inspect).to eq("<PEROBS::Array:#{a2._id}>\n[\n 1,\n <PEROBS::ObjectBase:#{a1._id}>\n]\n")
|
242
239
|
end
|
243
240
|
|
244
241
|
it 'should only provide POXReference objects' do
|
245
|
-
a = cpa([
|
242
|
+
a = cpa([@store.new(PO), @store.new(PO)])
|
246
243
|
expect(a[0].respond_to?(:is_poxreference?)).to be true
|
247
|
-
a.each do |
|
248
|
-
expect(
|
244
|
+
a.each do |ai|
|
245
|
+
expect(ai.respond_to?(:is_poxreference?)).to be true
|
249
246
|
end
|
250
247
|
end
|
251
248
|
|
@@ -256,5 +253,4 @@ describe PEROBS::Array do
|
|
256
253
|
expect { a[0] = o.get_self }.to raise_error(PEROBS::FatalError)
|
257
254
|
PEROBS.log.open($stderr)
|
258
255
|
end
|
259
|
-
|
260
256
|
end
|
data/test/BTreeDB_spec.rb
CHANGED
@@ -40,7 +40,7 @@ describe PEROBS::BTreeDB do
|
|
40
40
|
|
41
41
|
it 'should create database' do
|
42
42
|
@db = PEROBS::BTreeDB.new('fs_test')
|
43
|
-
expect(Dir.
|
43
|
+
expect(Dir.exist?('fs_test')).to be true
|
44
44
|
end
|
45
45
|
|
46
46
|
it 'should write and read a simple Hash' do
|
@@ -72,6 +72,10 @@ describe PEROBS::BTreeDB do
|
|
72
72
|
it 'should support most Ruby objects types' do
|
73
73
|
[ :marshal, :yaml ].each do |serializer|
|
74
74
|
@db = PEROBS::BTreeDB.new('fs_test', { :serializer => serializer })
|
75
|
+
class_map = PEROBS::ClassMap.new(@db)
|
76
|
+
@db.register_class_map(class_map)
|
77
|
+
class_map.class_to_id(Time)
|
78
|
+
class_map.class_to_id(UStruct)
|
75
79
|
expect(@db.include?(0)).to be false
|
76
80
|
h = {
|
77
81
|
'String' => 'What god has wrought',
|
data/test/BigTreeNode_spec.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
3
|
# Copyright (c) 2016, 2017 by Chris Schlaeger <chris@taskjuggler.org>
|
4
4
|
#
|
5
5
|
# MIT License
|
@@ -25,12 +25,11 @@
|
|
25
25
|
|
26
26
|
require 'fileutils'
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
28
|
+
require_relative 'spec_helper'
|
29
|
+
require_relative '../lib/perobs/Store'
|
30
|
+
require_relative '../lib/perobs/BigTree'
|
31
31
|
|
32
32
|
describe PEROBS::BigTreeNode do
|
33
|
-
|
34
33
|
before(:all) do
|
35
34
|
@db_name = generate_db_name(__FILE__)
|
36
35
|
@store = PEROBS::Store.new(@db_name)
|
@@ -148,6 +147,4 @@ describe PEROBS::BigTreeNode do
|
|
148
147
|
expect(s.leaf_nodes).to eql(3)
|
149
148
|
expect(s.branch_nodes).to eql(1)
|
150
149
|
end
|
151
|
-
|
152
150
|
end
|
153
|
-
|
@@ -0,0 +1 @@
|
|
1
|
+
{"LegacyDB::Fragment":0,"PEROBS::Hash":1,"PEROBS::Array":2}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"serializer":{"json_class":"Symbol","s":"json"}}
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,5 @@
|
|
1
|
+
# Logfile created on 2020-03-31 21:50:02 +0200 by logger.rb/61378
|
2
|
+
2020-03-31 21:50:02 +0200 INFO New FlatFile database 'test/database.blobs' created
|
3
|
+
2020-03-31 21:50:02 +0200 INFO FlatFile 'test' opened
|
4
|
+
2020-03-31 21:50:02 +0200 INFO FlatFile 'test' closed
|
5
|
+
2020-03-31 21:50:02 +0200 INFO FlatFile 'test' opened
|
@@ -0,0 +1 @@
|
|
1
|
+
4
|
data/test/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: perobs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Schlaeger
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-07-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '2.
|
19
|
+
version: '2.2'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '2.
|
26
|
+
version: '2.2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: yard
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 13.0.3
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.12'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.12'
|
55
69
|
description: Library to provide a persistent object store
|
56
70
|
email:
|
57
71
|
- chris@linux.com
|
@@ -59,6 +73,7 @@ executables: []
|
|
59
73
|
extensions: []
|
60
74
|
extra_rdoc_files: []
|
61
75
|
files:
|
76
|
+
- ".github/workflows/ruby.yml"
|
62
77
|
- ".gitignore"
|
63
78
|
- Gemfile
|
64
79
|
- LICENSE.txt
|
@@ -134,6 +149,13 @@ files:
|
|
134
149
|
- test/LegacyDBs/version_3/database_spaces.blobs
|
135
150
|
- test/LegacyDBs/version_3/index.blobs
|
136
151
|
- test/LegacyDBs/version_3/version
|
152
|
+
- test/LegacyDBs/version_4.1/class_map.json
|
153
|
+
- test/LegacyDBs/version_4.1/config.json
|
154
|
+
- test/LegacyDBs/version_4.1/database.blobs
|
155
|
+
- test/LegacyDBs/version_4.1/database_spaces.blobs
|
156
|
+
- test/LegacyDBs/version_4.1/index.blobs
|
157
|
+
- test/LegacyDBs/version_4.1/log
|
158
|
+
- test/LegacyDBs/version_4.1/version
|
137
159
|
- test/LockFile_spec.rb
|
138
160
|
- test/Object_spec.rb
|
139
161
|
- test/SpaceManager_spec.rb
|
@@ -146,7 +168,7 @@ homepage: https://github.com/scrapper/perobs
|
|
146
168
|
licenses:
|
147
169
|
- MIT
|
148
170
|
metadata: {}
|
149
|
-
post_install_message:
|
171
|
+
post_install_message:
|
150
172
|
rdoc_options: []
|
151
173
|
require_paths:
|
152
174
|
- lib
|
@@ -154,15 +176,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
154
176
|
requirements:
|
155
177
|
- - ">="
|
156
178
|
- !ruby/object:Gem::Version
|
157
|
-
version: '2.
|
179
|
+
version: '2.5'
|
158
180
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
159
181
|
requirements:
|
160
182
|
- - ">="
|
161
183
|
- !ruby/object:Gem::Version
|
162
184
|
version: '0'
|
163
185
|
requirements: []
|
164
|
-
rubygems_version: 3.
|
165
|
-
signing_key:
|
186
|
+
rubygems_version: 3.4.1
|
187
|
+
signing_key:
|
166
188
|
specification_version: 4
|
167
189
|
summary: Persistent Ruby Object Store
|
168
190
|
test_files:
|
@@ -187,6 +209,13 @@ test_files:
|
|
187
209
|
- test/LegacyDBs/version_3/database_spaces.blobs
|
188
210
|
- test/LegacyDBs/version_3/index.blobs
|
189
211
|
- test/LegacyDBs/version_3/version
|
212
|
+
- test/LegacyDBs/version_4.1/class_map.json
|
213
|
+
- test/LegacyDBs/version_4.1/config.json
|
214
|
+
- test/LegacyDBs/version_4.1/database.blobs
|
215
|
+
- test/LegacyDBs/version_4.1/database_spaces.blobs
|
216
|
+
- test/LegacyDBs/version_4.1/index.blobs
|
217
|
+
- test/LegacyDBs/version_4.1/log
|
218
|
+
- test/LegacyDBs/version_4.1/version
|
190
219
|
- test/LockFile_spec.rb
|
191
220
|
- test/Object_spec.rb
|
192
221
|
- test/SpaceManager_spec.rb
|