factbase 0.10.0 → 0.10.2

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: b91c02657bba3cc0c5d801a273b49c9fd18f0faeb94bf366f5e5f7f224dd703b
4
- data.tar.gz: c6a77ef66e2a6b06d6e072c229b1b90f602adc8769f3434239d08b02f119b9c4
3
+ metadata.gz: 6fd3c455b06a6b4ef8b25495c251b040b32ad8bbffd668452ba0ea5aac492cd5
4
+ data.tar.gz: c90678471389952b279788986431ae1a760aeadfac1de3dca398f83cac411c24
5
5
  SHA512:
6
- metadata.gz: 50d3c7680612b0a02bec34b560581b3e1575e95d30511ec61bc7fa1504a42566116960532e2c9f9b0bb1ee6441d0c4eeed3a1b7e9076a7436af7a0a2c3e077ab
7
- data.tar.gz: 69d6fb049f6631fbc9d17ee24d414cfa7c3acd6d3789f73f4613cb10230c0a697c2427eaf8a028db6f61ea1c2e08fb61cf51c34e79cd722c235c0a6127f3c06a
6
+ metadata.gz: 92491db37e79d3585c42c77be9b34ba3fa571d7b2edb2013d3b400946789a8affa01c189b62908a4dc6f98e29446b1175dded6378f18e6efcdc1a9c875294a91
7
+ data.tar.gz: 56a04945eff49360290f349dd110f504dddd1708ad1b6708097c402a5403ba7984b7a59c29ee3cb6525bdeec61b73e90028fa11d65d660fe777bcaa80bfbbd20
@@ -43,6 +43,7 @@ jobs:
43
43
  rm stdout.txt
44
44
  - uses: peter-evans/create-pull-request@v7
45
45
  with:
46
+ sign-commits: true
46
47
  branch: benchmark-results
47
48
  commit-message: 'new benchmarking results'
48
49
  delete-branch: true
@@ -0,0 +1,19 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2024-2025 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
3
+ ---
4
+ # yamllint disable rule:line-length
5
+ name: typos
6
+ 'on':
7
+ push:
8
+ branches:
9
+ - master
10
+ pull_request:
11
+ branches:
12
+ - master
13
+ jobs:
14
+ typos:
15
+ timeout-minutes: 15
16
+ runs-on: ubuntu-24.04
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+ - uses: crate-ci/typos@v1.32.0
data/.gitignore CHANGED
@@ -1,8 +1,8 @@
1
- *.gem
2
- .DS_Store
3
1
  .bundle/
2
+ .DS_Store
4
3
  .idea/
5
4
  .yardoc/
5
+ *.gem
6
6
  coverage/
7
7
  doc/
8
8
  node_modules/
data/.rubocop.yml CHANGED
@@ -46,3 +46,4 @@ Security/MarshalLoad:
46
46
  Enabled: false
47
47
  Layout/MultilineAssignmentLayout:
48
48
  Enabled: true
49
+ require: []
data/Gemfile.lock CHANGED
@@ -26,36 +26,37 @@ GEM
26
26
  elapsed (0.0.1)
27
27
  loog (> 0)
28
28
  tago (> 0)
29
- json (2.10.2)
30
- language_server-protocol (3.17.0.4)
29
+ json (2.12.0)
30
+ language_server-protocol (3.17.0.5)
31
31
  lint_roller (1.1.0)
32
32
  logger (1.7.0)
33
- loog (0.6.0)
33
+ loog (0.6.1)
34
+ logger (~> 1.0)
34
35
  minitest (5.25.5)
35
36
  minitest-reporters (1.7.1)
36
37
  ansi
37
38
  builder
38
39
  minitest (>= 5.0)
39
40
  ruby-progressbar
40
- nokogiri (1.18.6-arm64-darwin)
41
+ nokogiri (1.18.8-arm64-darwin)
41
42
  racc (~> 1.4)
42
- nokogiri (1.18.6-x64-mingw-ucrt)
43
+ nokogiri (1.18.8-x64-mingw-ucrt)
43
44
  racc (~> 1.4)
44
- nokogiri (1.18.6-x86_64-darwin)
45
+ nokogiri (1.18.8-x86_64-darwin)
45
46
  racc (~> 1.4)
46
- nokogiri (1.18.6-x86_64-linux-gnu)
47
+ nokogiri (1.18.8-x86_64-linux-gnu)
47
48
  racc (~> 1.4)
48
49
  os (1.1.4)
49
50
  others (0.0.3)
50
- parallel (1.26.3)
51
- parser (3.3.7.4)
51
+ parallel (1.27.0)
52
+ parser (3.3.8.0)
52
53
  ast (~> 2.4.1)
53
54
  racc
54
55
  prism (1.4.0)
55
- psych (5.2.3)
56
+ psych (5.2.6)
56
57
  date
57
58
  stringio
58
- qbash (0.4.0)
59
+ qbash (0.4.5)
59
60
  backtrace (> 0)
60
61
  elapsed (> 0)
61
62
  loog (> 0)
@@ -67,7 +68,7 @@ GEM
67
68
  psych (>= 4.0.0)
68
69
  regexp_parser (2.10.0)
69
70
  rexml (3.4.1)
70
- rubocop (1.75.2)
71
+ rubocop (1.75.6)
71
72
  json (~> 2.3)
72
73
  language_server-protocol (~> 3.17.0.2)
73
74
  lint_roller (~> 1.1.0)
@@ -78,7 +79,7 @@ GEM
78
79
  rubocop-ast (>= 1.44.0, < 2.0)
79
80
  ruby-progressbar (~> 1.7)
80
81
  unicode-display_width (>= 2.4.0, < 4.0)
81
- rubocop-ast (1.44.0)
82
+ rubocop-ast (1.44.1)
82
83
  parser (>= 3.3.7.2)
83
84
  prism (~> 1.4)
84
85
  rubocop-minitest (0.38.0)
@@ -92,7 +93,7 @@ GEM
92
93
  rubocop-rake (0.7.1)
93
94
  lint_roller (~> 1.1)
94
95
  rubocop (>= 1.72.1)
95
- rubocop-rspec (3.5.0)
96
+ rubocop-rspec (3.6.0)
96
97
  lint_roller (~> 1.1)
97
98
  rubocop (~> 1.72, >= 1.72.1)
98
99
  ruby-progressbar (1.13.0)
@@ -105,7 +106,7 @@ GEM
105
106
  simplecov (~> 0.19)
106
107
  simplecov-html (0.13.1)
107
108
  simplecov_json_formatter (0.1.4)
108
- stringio (3.1.6)
109
+ stringio (3.1.7)
109
110
  tago (0.1.0)
110
111
  threads (0.4.1)
111
112
  backtrace (~> 0)
data/REUSE.toml CHANGED
@@ -4,9 +4,17 @@
4
4
  version = 1
5
5
  [[annotations]]
6
6
  path = [
7
+ ".DS_Store",
8
+ ".gitattributes",
9
+ ".gitignore",
10
+ ".pdd",
7
11
  "**.json",
8
12
  "**.md",
13
+ "**.png",
9
14
  "**.txt",
15
+ "**/.DS_Store",
16
+ "**/.gitignore",
17
+ "**/.pdd",
10
18
  "**/*.csv",
11
19
  "**/*.jpg",
12
20
  "**/*.json",
@@ -16,15 +24,8 @@ path = [
16
24
  "**/*.svg",
17
25
  "**/*.txt",
18
26
  "**/*.vm",
19
- "**/.DS_Store",
20
- "**/.gitignore",
21
- "**/.pdd",
22
27
  "**/CNAME",
23
28
  "**/Gemfile.lock",
24
- ".DS_Store",
25
- ".gitattributes",
26
- ".gitignore",
27
- ".pdd",
28
29
  "Gemfile.lock",
29
30
  "README.md",
30
31
  "renovate.json",
@@ -20,6 +20,10 @@ class Factbase::CachedFact
20
20
  @cache = cache
21
21
  end
22
22
 
23
+ def to_s
24
+ @origin.to_s
25
+ end
26
+
23
27
  # When a method is missing, this method is called.
24
28
  others do |*args|
25
29
  @cache.clear if args[0].to_s.end_with?('=')
@@ -22,9 +22,9 @@ class Factbase::CachedFactbase
22
22
  # @param [Factbase] origin Original factbase to decorate
23
23
  # @param [Hash] cache Cache to use
24
24
  def initialize(origin, cache = {})
25
- raise 'Wront type of original' unless origin.respond_to?(:query)
25
+ raise 'Wrong type of original' unless origin.respond_to?(:query)
26
26
  @origin = origin
27
- raise 'Wront type of cache' unless cache.is_a?(Hash)
27
+ raise 'Wrong type of cache' unless cache.is_a?(Hash)
28
28
  @cache = cache
29
29
  end
30
30
 
@@ -20,6 +20,10 @@ class Factbase::IndexedFact
20
20
  @idx = idx
21
21
  end
22
22
 
23
+ def to_s
24
+ @origin.to_s
25
+ end
26
+
23
27
  # When a method is missing, this method is called.
24
28
  others do |*args|
25
29
  @idx.clear if args[0].to_s.end_with?('=')
@@ -22,9 +22,9 @@ class Factbase::IndexedFactbase
22
22
  # @param [Factbase] origin Original factbase to decorate
23
23
  # @param [Hash] idx Index to use
24
24
  def initialize(origin, idx = {})
25
- raise 'Wront type of original' unless origin.respond_to?(:query)
25
+ raise 'Wrong type of original' unless origin.respond_to?(:query)
26
26
  @origin = origin
27
- raise 'Wront type of index' unless idx.is_a?(Hash)
27
+ raise 'Wrong type of index' unless idx.is_a?(Hash)
28
28
  @idx = idx
29
29
  end
30
30
 
@@ -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.10.0' unless const_defined?(:VERSION)
85
+ VERSION = '0.10.2' 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
@@ -197,7 +197,7 @@ class TestQuery < Factbase::Test
197
197
  end
198
198
  end
199
199
 
200
- def test_finds_with_subsitution
200
+ def test_finds_with_substitution
201
201
  maps = [{ 'foo' => [42] }, { 'bar' => [7] }, { 'foo' => [666] }]
202
202
  with_factbases(maps) do |badge, fb|
203
203
  assert_equal(0, fb.query('(eq 2 (agg (eq foo $foo) (count)))').each.to_a.size, "with #{badge}")
@@ -485,4 +485,16 @@ class TestFactbase < Factbase::Test
485
485
  end
486
486
  assert_equal(1, fb.size)
487
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
488
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.10.0
4
+ version: 0.10.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-04-15 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"
@@ -157,6 +157,7 @@ files:
157
157
  - ".github/workflows/pdd.yml"
158
158
  - ".github/workflows/rake.yml"
159
159
  - ".github/workflows/reuse.yml"
160
+ - ".github/workflows/typos.yml"
160
161
  - ".github/workflows/xcop.yml"
161
162
  - ".github/workflows/yamllint.yml"
162
163
  - ".gitignore"
@@ -291,7 +292,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
291
292
  - !ruby/object:Gem::Version
292
293
  version: '0'
293
294
  requirements: []
294
- rubygems_version: 3.6.2
295
+ rubygems_version: 3.6.7
295
296
  specification_version: 4
296
297
  summary: Factbase
297
298
  test_files: []