factbase 0.9.10 → 0.10.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eda6e3c356b973e7cb4ce6c10d709a94a7e5f390168a3e72818ce57b705401ac
4
- data.tar.gz: 6e9712aea64f66a65fe8870213889576ab510c908f413bc84f3b1c9c352ecc04
3
+ metadata.gz: cddb3957ecbb2cce6a0957e00759aa8c54edc2b6ce1dae45509968cf22894c7a
4
+ data.tar.gz: 880d4fdde6788b80ee1db1a94fdfeed15d98b8fe7a0d8c3c4c0b6611a5cfdf79
5
5
  SHA512:
6
- metadata.gz: 33032268ae5f9be44b9360234960efd89bdc424d65e21543d75a50a95f9fe0628608319e29719ac836b72f0592b362fc3792e2fc364233ef73593f6111c22eb6
7
- data.tar.gz: c7e3621f05a28492e8c756d44ecd5312aea97e0d7990d08408d5d30d481bbd76bb28615f78be44ac7875508133961d200b677a887c9b129b8c7dad425348d96b
6
+ metadata.gz: ddd8fce247c59e80ab719451fca226e0598459557cdd33cbcaf21fd8e12b6ae23b82e3cf3173d638414ad2654a6e3a40d6cc586a1d8804df9111a68474e87489
7
+ data.tar.gz: 3ef80c4d7e05cc7daa9f8a4e9c38a47c7555693416ab521b2ef589b9abab6ba592e7484171b92df96e77333eae8f36bb85a19e4c9fb63cc2ae06cd3e7d4e2b72
data/Gemfile.lock CHANGED
@@ -26,7 +26,7 @@ GEM
26
26
  elapsed (0.0.1)
27
27
  loog (> 0)
28
28
  tago (> 0)
29
- json (2.10.2)
29
+ json (2.11.3)
30
30
  language_server-protocol (3.17.0.4)
31
31
  lint_roller (1.1.0)
32
32
  logger (1.7.0)
@@ -37,18 +37,18 @@ GEM
37
37
  builder
38
38
  minitest (>= 5.0)
39
39
  ruby-progressbar
40
- nokogiri (1.18.6-arm64-darwin)
40
+ nokogiri (1.18.8-arm64-darwin)
41
41
  racc (~> 1.4)
42
- nokogiri (1.18.6-x64-mingw-ucrt)
42
+ nokogiri (1.18.8-x64-mingw-ucrt)
43
43
  racc (~> 1.4)
44
- nokogiri (1.18.6-x86_64-darwin)
44
+ nokogiri (1.18.8-x86_64-darwin)
45
45
  racc (~> 1.4)
46
- nokogiri (1.18.6-x86_64-linux-gnu)
46
+ nokogiri (1.18.8-x86_64-linux-gnu)
47
47
  racc (~> 1.4)
48
48
  os (1.1.4)
49
49
  others (0.0.3)
50
- parallel (1.26.3)
51
- parser (3.3.7.3)
50
+ parallel (1.27.0)
51
+ parser (3.3.8.0)
52
52
  ast (~> 2.4.1)
53
53
  racc
54
54
  prism (1.4.0)
@@ -67,7 +67,7 @@ GEM
67
67
  psych (>= 4.0.0)
68
68
  regexp_parser (2.10.0)
69
69
  rexml (3.4.1)
70
- rubocop (1.75.1)
70
+ rubocop (1.75.4)
71
71
  json (~> 2.3)
72
72
  language_server-protocol (~> 3.17.0.2)
73
73
  lint_roller (~> 1.1.0)
@@ -75,24 +75,24 @@ GEM
75
75
  parser (>= 3.3.0.2)
76
76
  rainbow (>= 2.2.2, < 4.0)
77
77
  regexp_parser (>= 2.9.3, < 3.0)
78
- rubocop-ast (>= 1.43.0, < 2.0)
78
+ rubocop-ast (>= 1.44.0, < 2.0)
79
79
  ruby-progressbar (~> 1.7)
80
80
  unicode-display_width (>= 2.4.0, < 4.0)
81
- rubocop-ast (1.43.0)
81
+ rubocop-ast (1.44.1)
82
82
  parser (>= 3.3.7.2)
83
83
  prism (~> 1.4)
84
- rubocop-minitest (0.37.1)
84
+ rubocop-minitest (0.38.0)
85
85
  lint_roller (~> 1.1)
86
- rubocop (>= 1.72.1, < 2.0)
86
+ rubocop (>= 1.75.0, < 2.0)
87
87
  rubocop-ast (>= 1.38.0, < 2.0)
88
- rubocop-performance (1.24.0)
88
+ rubocop-performance (1.25.0)
89
89
  lint_roller (~> 1.1)
90
- rubocop (>= 1.72.1, < 2.0)
90
+ rubocop (>= 1.75.0, < 2.0)
91
91
  rubocop-ast (>= 1.38.0, < 2.0)
92
92
  rubocop-rake (0.7.1)
93
93
  lint_roller (~> 1.1)
94
94
  rubocop (>= 1.72.1)
95
- rubocop-rspec (3.5.0)
95
+ rubocop-rspec (3.6.0)
96
96
  lint_roller (~> 1.1)
97
97
  rubocop (~> 1.72, >= 1.72.1)
98
98
  ruby-progressbar (1.13.0)
@@ -105,7 +105,7 @@ GEM
105
105
  simplecov (~> 0.19)
106
106
  simplecov-html (0.13.1)
107
107
  simplecov_json_formatter (0.1.4)
108
- stringio (3.1.6)
108
+ stringio (3.1.7)
109
109
  tago (0.1.0)
110
110
  threads (0.4.1)
111
111
  backtrace (~> 0)
data/README.md CHANGED
@@ -1,13 +1,13 @@
1
1
  # Single-Table NoSQL-ish In-Memory Database
2
2
 
3
- [![DevOps By Rultor.com](http://www.rultor.com/b/yegor256/factbase)](http://www.rultor.com/p/yegor256/factbase)
3
+ [![DevOps By Rultor.com](https://www.rultor.com/b/yegor256/factbase)](https://www.rultor.com/p/yegor256/factbase)
4
4
  [![We recommend RubyMine](https://www.elegantobjects.org/rubymine.svg)](https://www.jetbrains.com/ruby/)
5
5
 
6
6
  [![rake](https://github.com/yegor256/factbase/actions/workflows/rake.yml/badge.svg)](https://github.com/yegor256/factbase/actions/workflows/rake.yml)
7
- [![PDD status](http://www.0pdd.com/svg?name=yegor256/factbase)](http://www.0pdd.com/p?name=yegor256/factbase)
8
- [![Gem Version](https://badge.fury.io/rb/factbase.svg)](http://badge.fury.io/rb/factbase)
7
+ [![PDD status](https://www.0pdd.com/svg?name=yegor256/factbase)](https://www.0pdd.com/p?name=yegor256/factbase)
8
+ [![Gem Version](https://badge.fury.io/rb/factbase.svg)](https://badge.fury.io/rb/factbase)
9
9
  [![Test Coverage](https://img.shields.io/codecov/c/github/yegor256/factbase.svg)](https://codecov.io/github/yegor256/factbase?branch=master)
10
- [![Yard Docs](http://img.shields.io/badge/yard-docs-blue.svg)](http://rubydoc.info/github/yegor256/factbase/master/frames)
10
+ [![Yard Docs](https://img.shields.io/badge/yard-docs-blue.svg)](https://rubydoc.info/github/yegor256/factbase/master/frames)
11
11
  [![Hits-of-Code](https://hitsofcode.com/github/yegor256/factbase)](https://hitsofcode.com/view/github/yegor256/factbase)
12
12
  [![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/yegor256/factbase/blob/master/LICENSE.txt)
13
13
  [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fyegor256%2Ffactbase.svg?type=shield&issueType=license)](https://app.fossa.com/projects/git%2Bgithub.com%2Fyegor256%2Ffactbase?ref=badge_shield&issueType=license)
@@ -210,33 +210,33 @@ This is the result of the benchmark:
210
210
  <!-- benchmark_begin -->
211
211
  ```text
212
212
  user system total real
213
- insert 20000 facts 0.597725 0.004012 0.601737 ( 0.601785)
214
- export 20000 facts 0.020481 0.003039 0.023520 ( 0.023523)
215
- import 410961 bytes (20000 facts) 0.021204 0.002017 0.023221 ( 0.023223)
216
- insert 10 facts 0.042456 0.002961 0.045417 ( 0.045418)
217
- query 10 times w/txn 1.594704 0.026991 1.621695 ( 1.621807)
218
- query 10 times w/o txn 0.057308 0.000013 0.057321 ( 0.057322)
219
- modify 10 attrs w/txn 1.225101 0.013972 1.239073 ( 1.239349)
220
- delete 10 facts w/txn 0.735944 0.001018 0.736962 ( 0.737102)
221
- (and (eq what 'issue-was-closed') (exists... -> 200 2.068974 0.008005 2.076979 ( 2.077134)
222
- (and (eq what 'issue-was-closed') (exists... -> 200/txn 1.094799 0.000000 1.094799 ( 1.094849)
223
- (and (eq what 'issue-was-closed') (exists... -> zero 2.384214 0.001004 2.385218 ( 2.385610)
224
- (and (eq what 'issue-was-closed') (exists... -> zero/txn 1.255267 0.001916 1.257183 ( 1.257310)
225
- (gt time '2024-03-23T03:21:43Z') 0.110972 0.002000 0.112972 ( 0.112986)
226
- (gt cost 50) 0.087402 0.000000 0.087402 ( 0.087411)
227
- (eq title 'Object Thinking 5000') 0.002488 0.000000 0.002488 ( 0.002488)
228
- (and (eq foo 42.998) (or (gt bar 200) (absent zzz))) 0.022121 0.000001 0.022122 ( 0.022123)
229
- (eq id (agg (always) (max id))) 0.237595 0.000000 0.237595 ( 0.237605)
230
- (join "c<=cost,b<=bar" (eq id (agg (always) (max id)))) 0.635953 0.003996 0.639949 ( 0.640016)
231
- delete! 0.060744 0.000997 0.061741 ( 0.061741)
232
- Taped.append() x50000 0.037044 0.002000 0.039044 ( 0.039048)
233
- Taped.each() x125 1.259629 0.002997 1.262626 ( 1.262661)
234
- Taped.delete_if() x375 0.810420 0.000005 0.810425 ( 0.810483)
213
+ insert 20000 facts 0.584619 0.003744 0.588363 ( 0.588372)
214
+ export 20000 facts 0.019872 0.004992 0.024864 ( 0.024870)
215
+ import 411135 bytes (20000 facts) 0.030978 0.004000 0.034978 ( 0.034983)
216
+ insert 10 facts 0.043662 0.002056 0.045718 ( 0.045738)
217
+ query 10 times w/txn 1.809973 0.034886 1.844859 ( 1.845456)
218
+ query 10 times w/o txn 0.039074 0.004004 0.043078 ( 0.043081)
219
+ modify 10 attrs w/txn 1.705921 0.015961 1.721882 ( 1.722316)
220
+ delete 10 facts w/txn 1.021624 0.007014 1.028638 ( 1.028692)
221
+ (and (eq what 'issue-was-closed') (exists... -> 200 2.110981 0.005000 2.115981 ( 2.116099)
222
+ (and (eq what 'issue-was-closed') (exists... -> 200/txn 1.125909 0.000000 1.125909 ( 1.125962)
223
+ (and (eq what 'issue-was-closed') (exists... -> zero 2.417743 0.000993 2.418736 ( 2.418869)
224
+ (and (eq what 'issue-was-closed') (exists... -> zero/txn 1.282409 0.003006 1.285415 ( 1.285498)
225
+ (gt time '2024-03-23T03:21:43Z') 0.092167 0.000000 0.092167 ( 0.092169)
226
+ (gt cost 50) 0.107435 0.000000 0.107435 ( 0.107438)
227
+ (eq title 'Object Thinking 5000') 0.002544 0.000000 0.002544 ( 0.002546)
228
+ (and (eq foo 42.998) (or (gt bar 200) (absent zzz))) 0.022142 0.000000 0.022142 ( 0.022143)
229
+ (eq id (agg (always) (max id))) 0.244818 0.000000 0.244818 ( 0.244835)
230
+ (join "c<=cost,b<=bar" (eq id (agg (always) (max id)))) 0.672133 0.001998 0.674131 ( 0.674186)
231
+ delete! 0.074661 0.000000 0.074661 ( 0.074663)
232
+ Taped.append() x50000 0.037757 0.004997 0.042754 ( 0.042759)
233
+ Taped.each() x125 1.283630 0.001995 1.285625 ( 1.285706)
234
+ Taped.delete_if() x375 0.819901 0.000000 0.819901 ( 0.819968)
235
235
  ```
236
236
 
237
237
  The results were calculated in [this GHA job][benchmark-gha]
238
- on 2025-03-30 at 05:03,
238
+ on 2025-04-07 at 10:33,
239
239
  on Linux with 4 CPUs.
240
240
  <!-- benchmark_end -->
241
241
 
242
- [benchmark-gha]: https://github.com/yegor256/factbase/actions/runs/14152813171
242
+ [benchmark-gha]: https://github.com/yegor256/factbase/actions/runs/14306969571
data/Rakefile CHANGED
@@ -35,7 +35,7 @@ task :picks do
35
35
  next if OS.windows?
36
36
  %w[test lib].each do |d|
37
37
  Dir["#{d}/**/*.rb"].each do |f|
38
- qbash("bundle exec ruby #{Shellwords.escape(f)}", log: $stdout)
38
+ qbash("bundle exec ruby #{Shellwords.escape(f)}", log: $stdout, env: { 'PICKS' => 'yes' })
39
39
  end
40
40
  end
41
41
  end
@@ -3,6 +3,7 @@
3
3
  # SPDX-FileCopyrightText: Copyright (c) 2024-2025 Yegor Bugayenko
4
4
  # SPDX-License-Identifier: MIT
5
5
 
6
+ require 'decoor'
6
7
  require_relative '../factbase'
7
8
 
8
9
  # A decorator of an Array with HashMaps, that records facts that have been touched,
@@ -44,7 +45,7 @@ class Factbase::Taped
44
45
  end
45
46
 
46
47
  def <<(map)
47
- @origin << (map)
48
+ @origin << map
48
49
  @inserted.append(map.object_id)
49
50
  end
50
51
 
@@ -82,6 +83,8 @@ class Factbase::Taped
82
83
 
83
84
  # Decorator of Hash.
84
85
  class TapedHash
86
+ decoor(:origin)
87
+
85
88
  def initialize(origin, added)
86
89
  @origin = origin
87
90
  @added = added
@@ -134,7 +137,7 @@ class Factbase::Taped
134
137
 
135
138
  def <<(item)
136
139
  @added.append(@oid)
137
- @origin << (item)
140
+ @origin << item
138
141
  end
139
142
 
140
143
  def uniq!
data/lib/factbase.rb CHANGED
@@ -82,7 +82,7 @@ require 'yaml'
82
82
  # License:: MIT
83
83
  class Factbase
84
84
  # Current version of the gem (changed by .rultor.yml on every release)
85
- VERSION = '0.9.10' unless const_defined?(:VERSION)
85
+ VERSION = '0.10.1' unless const_defined?(:VERSION)
86
86
 
87
87
  # An exception that may be thrown in a transaction, to roll it back.
88
88
  class Rollback < StandardError; end
@@ -176,7 +176,7 @@ class Factbase
176
176
  end
177
177
  require_relative 'factbase/taped'
178
178
  taped = Factbase::Taped.new(before)
179
- begin
179
+ catch :commit do
180
180
  require_relative 'factbase/light'
181
181
  yield Factbase::Light.new(Factbase.new(taped))
182
182
  rescue Factbase::Rollback
@@ -15,9 +15,9 @@ class TestCachedFactbase < Factbase::Test
15
15
  def test_inserts_and_queries
16
16
  fb = Factbase::CachedFactbase.new(Factbase.new)
17
17
  f = fb.insert
18
- f.foo = 1
18
+ f.foo_bar = 1
19
19
  f.bar = 'test'
20
- assert_equal(1, fb.query('(and (eq foo 1) (eq bar "test"))').each.to_a.size)
20
+ assert_equal(1, fb.query('(and (eq foo_bar 1) (eq bar "test"))').each.to_a.size)
21
21
  end
22
22
 
23
23
  def test_queries_after_update_in_txn
@@ -13,6 +13,12 @@ require_relative '../../../lib/factbase/indexed/indexed_factbase'
13
13
  # Copyright:: Copyright (c) 2024-2025 Yegor Bugayenko
14
14
  # License:: MIT
15
15
  class TestIndexedQuery < Factbase::Test
16
+ def test_converts_to_string
17
+ fb = Factbase.new
18
+ fb.insert.foo = 42
19
+ refute_nil(Factbase::IndexedQuery.new(fb.query('(exists foo)'), {}, fb).to_s)
20
+ end
21
+
16
22
  def test_queries_and_updates_origin
17
23
  fb = Factbase.new
18
24
  fb.insert.foo = 42
@@ -15,11 +15,11 @@ class TestFact < Factbase::Test
15
15
  def test_injects_data_correctly
16
16
  map = {}
17
17
  f = Factbase::Fact.new(map)
18
- f.foo = 1
18
+ f.foo_bar = 1
19
19
  f.bar = 2
20
20
  f.bar = 3
21
21
  assert_equal(2, map.size)
22
- assert_equal([1], map['foo'])
22
+ assert_equal([1], map['foo_bar'])
23
23
  assert_equal([2, 3], map['bar'])
24
24
  end
25
25
 
data/test/test__helper.rb CHANGED
@@ -6,14 +6,27 @@
6
6
  $stdout.sync = true
7
7
 
8
8
  require 'simplecov'
9
- SimpleCov.external_at_exit = true
10
- SimpleCov.start
11
-
12
9
  require 'simplecov-cobertura'
13
- SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter
10
+ unless SimpleCov.running || ENV['PICKS']
11
+ SimpleCov.command_name('test')
12
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
13
+ [
14
+ SimpleCov::Formatter::HTMLFormatter,
15
+ SimpleCov::Formatter::CoberturaFormatter
16
+ ]
17
+ )
18
+ SimpleCov.minimum_coverage 95
19
+ SimpleCov.minimum_coverage_by_file 90
20
+ SimpleCov.start do
21
+ add_filter 'test/'
22
+ add_filter 'vendor/'
23
+ add_filter 'target/'
24
+ track_files 'lib/**/*.rb'
25
+ track_files '*.rb'
26
+ end
27
+ end
14
28
 
15
29
  require 'minitest/autorun'
16
-
17
30
  require 'minitest/reporters'
18
31
  Minitest::Reporters.use! [Minitest::Reporters::SpecReporter.new]
19
32
 
@@ -134,7 +134,7 @@ class TestFactbase < Factbase::Test
134
134
  assert_raises(StandardError) do
135
135
  fb.txn do |fbt|
136
136
  fbt.insert.foo = 42
137
- throw 'intentionally'
137
+ raise 'intentionally'
138
138
  end
139
139
  end.message, 'intentionally'
140
140
  )
@@ -193,7 +193,7 @@ class TestFactbase < Factbase::Test
193
193
  assert_raises(StandardError) do
194
194
  d.txn do |fbt|
195
195
  fbt.insert
196
- throw 'oops'
196
+ raise 'oops'
197
197
  end
198
198
  end
199
199
  d.import(d.export)
@@ -476,4 +476,25 @@ class TestFactbase < Factbase::Test
476
476
  assert_equal(100, factbase.query('(eq foo 42)').each.to_a.size)
477
477
  end
478
478
  end
479
+
480
+ def test_commits_on_exit_by_throw
481
+ fb = Factbase.new
482
+ fb.txn do |fbt|
483
+ fbt.insert.foo = 1
484
+ throw :commit
485
+ end
486
+ assert_equal(1, fb.size)
487
+ end
488
+
489
+ def test_get_raise_for_empty_fact
490
+ fb = Factbase.new
491
+ fb.txn do |fbt|
492
+ f = fbt.insert
493
+ f.foo = 123
494
+ f = fbt.query('(always)').each.to_a.first
495
+ assert_equal(123, f.foo)
496
+ ex = assert_raises(RuntimeError) { f.bar }
497
+ assert_equal("Can't find 'bar' attribute out of [foo]", ex.message)
498
+ end
499
+ end
479
500
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: factbase
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.10
4
+ version: 0.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-03-30 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: backtrace
@@ -144,8 +144,8 @@ email: yegor256@gmail.com
144
144
  executables: []
145
145
  extensions: []
146
146
  extra_rdoc_files:
147
- - README.md
148
147
  - LICENSE.txt
148
+ - README.md
149
149
  files:
150
150
  - ".0pdd.yml"
151
151
  - ".gitattributes"
@@ -163,7 +163,6 @@ files:
163
163
  - ".pdd"
164
164
  - ".rubocop.yml"
165
165
  - ".rultor.yml"
166
- - ".simplecov"
167
166
  - Gemfile
168
167
  - Gemfile.lock
169
168
  - LICENSE.txt
@@ -292,7 +291,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
292
291
  - !ruby/object:Gem::Version
293
292
  version: '0'
294
293
  requirements: []
295
- rubygems_version: 3.6.2
294
+ rubygems_version: 3.6.7
296
295
  specification_version: 4
297
296
  summary: Factbase
298
297
  test_files: []
data/.simplecov DELETED
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- #
4
- # SPDX-FileCopyrightText: Copyright (c) 2024-2025 Yegor Bugayenko
5
- # SPDX-License-Identifier: MIT
6
-
7
- if Gem.win_platform?
8
- SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
9
- SimpleCov::Formatter::HTMLFormatter
10
- ]
11
- SimpleCov.start do
12
- add_filter '/test/'
13
- add_filter '/features/'
14
- end
15
- else
16
- SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
17
- [SimpleCov::Formatter::HTMLFormatter]
18
- )
19
- SimpleCov.start do
20
- add_filter '/test/'
21
- add_filter '/features/'
22
- minimum_coverage 20
23
- end
24
- end