factbase 0.11.0 → 0.11.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: 474551d14c160969e1361d2518458de199c6777865aedf1a34f5a4de00f22542
4
- data.tar.gz: ae437f74a4422631c9f3fa3c4a1752b42eadbef4c0c3a2339829d3417a928441
3
+ metadata.gz: be29589dd79cd9d1737bc03dc28e3e4dc6c3115fc09c3369e8d4b617f8a57829
4
+ data.tar.gz: 57283b8114c03feaf19bbbae3a2b117ab1399026c0b5b9af2059af3356978717
5
5
  SHA512:
6
- metadata.gz: cc63686b69eb970b104a748be486d3e254f8ac919b9e171e801c77e6a02645c3e8daac33ea5807d3f37fe1d1e7f9d7744326f44155ad36d18cf1f498ade75cff
7
- data.tar.gz: 7c5d8f8aa98f68fa5a96d6f387cfe892fd43026ad2c51c418b0dccda72f3cdebac2ca24e9c1b9a3d205576c96888bb7ca03adab925c6533abc18de5e51769424
6
+ metadata.gz: afad81287f3b28820595f309a6f538a4415541fb212c2df31b034b0fa512698703db6c8be4c3c4389ec6cf355a944b6dc069ebf68b53fe085648d55a0cf1c10c
7
+ data.tar.gz: a566f40422aeb136517330c70c88348dbd3ea21786ab999de532a709ccdd09394f22cb64da490c0ccba0ef483ba46d2e2416865b4b66856e626904ac05b0809c
@@ -0,0 +1,24 @@
1
+ #!/bin/bash
2
+ # SPDX-FileCopyrightText: Copyright (c) 2024-2025 Yegor Bugayenko
3
+ # SPDX-License-Identifier: MIT
4
+
5
+ set -x
6
+
7
+ sum=$(
8
+ echo '```text'
9
+ cut -c -71 < stdout.txt
10
+ echo '```'
11
+ echo
12
+ echo "The results were calculated in [this GHA job][benchmark-gha]"
13
+ echo "on $(date +'%Y-%m-%d') at $(date +'%H:%M'),"
14
+ echo "on $(uname) with $(nproc --all) CPUs."
15
+ )
16
+
17
+ export sum
18
+
19
+ perl -i -0777 -pe 's/(?<=<!-- benchmark_begin -->).*(?=<!-- benchmark_end -->)/\n$ENV{sum}\n/gs;' README.md
20
+ url=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}
21
+
22
+ export url
23
+ perl -i -0777 -pe 's/(?<=\[benchmark-gha\]: )[^\n]+(?=\n)/$ENV{url}/gs;' README.md
24
+ rm stdout.txt
@@ -24,23 +24,7 @@ jobs:
24
24
  - run: bundle config set --global path "$(pwd)/vendor/bundle"
25
25
  - run: bundle install --no-color
26
26
  - run: bundle exec rake benchmark > stdout.txt
27
- - run: |
28
- set -x
29
- sum=$(
30
- echo '```text'
31
- cat stdout.txt | cut -c -71
32
- echo '```'
33
- echo
34
- echo "The results were calculated in [this GHA job][benchmark-gha]"
35
- echo "on $(date +'%Y-%m-%d') at $(date +'%H:%M'),"
36
- echo "on $(uname) with $(nproc --all) CPUs."
37
- )
38
- export sum
39
- perl -i -0777 -pe 's/(?<=<!-- benchmark_begin -->).*(?=<!-- benchmark_end -->)/\n$ENV{sum}\n/gs;' README.md
40
- url=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}
41
- export url
42
- perl -i -0777 -pe 's/(?<=\[benchmark-gha\]: )[^\n]+(?=\n)/$ENV{url}/gs;' README.md
43
- rm stdout.txt
27
+ - run: .github/publish-benchmark.sh
44
28
  - uses: peter-evans/create-pull-request@v7
45
29
  with:
46
30
  sign-commits: true
data/.rubocop.yml CHANGED
@@ -14,6 +14,8 @@ plugins:
14
14
  - rubocop-minitest
15
15
  - rubocop-performance
16
16
  - rubocop-rake
17
+ Naming/PredicateMethod:
18
+ Enabled: false
17
19
  Minitest/EmptyLineBeforeAssertionMethods:
18
20
  Enabled: false
19
21
  Gemspec/RequiredRubyVersion:
data/.rultor.yml CHANGED
@@ -1,3 +1,4 @@
1
+
1
2
  # SPDX-FileCopyrightText: Copyright (c) 2024-2025 Yegor Bugayenko
2
3
  # SPDX-License-Identifier: MIT
3
4
  ---
@@ -16,8 +17,8 @@ release:
16
17
  [[ "${tag}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || exit -1
17
18
  bundle exec rake
18
19
  rm -rf *.gem
19
- sed -i "s/0\.0\.0/${tag}/g" lib/factbase.rb
20
- git add lib/factbase.rb
20
+ sed -i "s/0\.0\.0/${tag}/g" lib/factbase/version.rb
21
+ git add lib/factbase/version.rb
21
22
  git commit -m "version set to ${tag}"
22
23
  gem build factbase.gemspec
23
24
  chmod 0600 ../rubygems.yml
data/Gemfile CHANGED
@@ -8,15 +8,14 @@ gemspec
8
8
 
9
9
  gem 'minitest', '~>5.25', require: false
10
10
  gem 'minitest-reporters', '~>1.7', require: false
11
- gem 'os', '>0', require: false
12
- gem 'qbash', '>0', require: false
11
+ gem 'os', '~>1.1', require: false
12
+ gem 'qbash', '~>0.4', require: false
13
13
  gem 'rake', '~>13.2', require: false
14
14
  gem 'rdoc', '~>6.13', require: false
15
15
  gem 'rubocop', '~>1.74', require: false
16
- gem 'rubocop-minitest', '>0', require: false
17
- gem 'rubocop-performance', '>0', require: false
18
- gem 'rubocop-rake', '>0', require: false
19
- gem 'rubocop-rspec', '>0', require: false
16
+ gem 'rubocop-minitest', '~>0.38', require: false
17
+ gem 'rubocop-performance', '~>1.25', require: false
18
+ gem 'rubocop-rake', '~>0.7', require: false
20
19
  gem 'simplecov', '~>0.22', require: false
21
20
  gem 'simplecov-cobertura', '~>2.1', require: false
22
21
  gem 'threads', '~>0.4', require: false
data/Gemfile.lock CHANGED
@@ -4,6 +4,7 @@ PATH
4
4
  factbase (0.0.0)
5
5
  backtrace (~> 0.4)
6
6
  decoor (~> 0.0)
7
+ ellipsized (~> 0.3)
7
8
  json (~> 2.7)
8
9
  logger (~> 1.0)
9
10
  loog (~> 0.6)
@@ -17,15 +18,16 @@ GEM
17
18
  specs:
18
19
  ansi (1.5.0)
19
20
  ast (2.4.3)
20
- backtrace (0.4.0)
21
+ backtrace (0.4.1)
21
22
  builder (3.3.0)
22
23
  concurrent-ruby (1.3.5)
23
24
  date (3.4.1)
24
- decoor (0.0.1)
25
+ decoor (0.1.0)
25
26
  docile (1.4.1)
26
27
  elapsed (0.0.1)
27
28
  loog (> 0)
28
29
  tago (> 0)
30
+ ellipsized (0.3.0)
29
31
  erb (5.0.1)
30
32
  json (2.12.2)
31
33
  language_server-protocol (3.17.0.5)
@@ -48,7 +50,7 @@ GEM
48
50
  nokogiri (1.18.8-x86_64-linux-gnu)
49
51
  racc (~> 1.4)
50
52
  os (1.1.4)
51
- others (0.0.3)
53
+ others (0.1.1)
52
54
  parallel (1.27.0)
53
55
  parser (3.3.8.0)
54
56
  ast (~> 2.4.1)
@@ -65,12 +67,12 @@ GEM
65
67
  racc (1.8.1)
66
68
  rainbow (3.1.1)
67
69
  rake (13.3.0)
68
- rdoc (6.14.0)
70
+ rdoc (6.14.1)
69
71
  erb
70
72
  psych (>= 4.0.0)
71
73
  regexp_parser (2.10.0)
72
74
  rexml (3.4.1)
73
- rubocop (1.75.8)
75
+ rubocop (1.77.0)
74
76
  json (~> 2.3)
75
77
  language_server-protocol (~> 3.17.0.2)
76
78
  lint_roller (~> 1.1.0)
@@ -78,10 +80,10 @@ GEM
78
80
  parser (>= 3.3.0.2)
79
81
  rainbow (>= 2.2.2, < 4.0)
80
82
  regexp_parser (>= 2.9.3, < 3.0)
81
- rubocop-ast (>= 1.44.0, < 2.0)
83
+ rubocop-ast (>= 1.45.1, < 2.0)
82
84
  ruby-progressbar (~> 1.7)
83
85
  unicode-display_width (>= 2.4.0, < 4.0)
84
- rubocop-ast (1.44.1)
86
+ rubocop-ast (1.45.1)
85
87
  parser (>= 3.3.7.2)
86
88
  prism (~> 1.4)
87
89
  rubocop-minitest (0.38.1)
@@ -95,9 +97,6 @@ GEM
95
97
  rubocop-rake (0.7.1)
96
98
  lint_roller (~> 1.1)
97
99
  rubocop (>= 1.72.1)
98
- rubocop-rspec (3.6.0)
99
- lint_roller (~> 1.1)
100
- rubocop (~> 1.72, >= 1.72.1)
101
100
  ruby-progressbar (1.13.0)
102
101
  simplecov (0.22.0)
103
102
  docile (~> 1.1)
@@ -132,15 +131,14 @@ DEPENDENCIES
132
131
  factbase!
133
132
  minitest (~> 5.25)
134
133
  minitest-reporters (~> 1.7)
135
- os (> 0)
136
- qbash (> 0)
134
+ os (~> 1.1)
135
+ qbash (~> 0.4)
137
136
  rake (~> 13.2)
138
137
  rdoc (~> 6.13)
139
138
  rubocop (~> 1.74)
140
- rubocop-minitest (> 0)
141
- rubocop-performance (> 0)
142
- rubocop-rake (> 0)
143
- rubocop-rspec (> 0)
139
+ rubocop-minitest (~> 0.38)
140
+ rubocop-performance (~> 1.25)
141
+ rubocop-rake (~> 0.7)
144
142
  simplecov (~> 0.22)
145
143
  simplecov-cobertura (~> 2.1)
146
144
  threads (~> 0.4)
data/README.md CHANGED
@@ -210,33 +210,33 @@ This is the result of the benchmark:
210
210
  <!-- benchmark_begin -->
211
211
  ```text
212
212
  user
213
- insert 20000 facts 0.606861
214
- export 20000 facts 0.029288
215
- import 410768 bytes (20000 facts) 0.029856
216
- insert 10 facts 0.042954
217
- query 10 times w/txn 1.951537
218
- query 10 times w/o txn 0.038436
219
- modify 10 attrs w/txn 1.815854
220
- delete 10 facts w/txn 1.023006
221
- (and (eq what 'issue-was-closed') (exists... -> 200 2.130857
222
- (and (eq what 'issue-was-closed') (exists... -> 200/txn 1.146039
223
- (and (eq what 'issue-was-closed') (exists... -> zero 2.424541
224
- (and (eq what 'issue-was-closed') (exists... -> zero/txn 1.297135
225
- (gt time '2024-03-23T03:21:43Z') 0.109071
226
- (gt cost 50) 0.092356
227
- (eq title 'Object Thinking 5000') 0.002707
228
- (and (eq foo 42.998) (or (gt bar 200) (absent zzz))) 0.024449
229
- (eq id (agg (always) (max id))) 0.257526
230
- (join "c<=cost,b<=bar" (eq id (agg (always) (max id)))) 0.650843
231
- delete! 0.075867
232
- Taped.append() x50000 0.038991
233
- Taped.each() x125 1.321896
234
- Taped.delete_if() x375 0.830375
213
+ insert 20000 facts 0.618307
214
+ export 20000 facts 0.021391
215
+ import 410726 bytes (20000 facts) 0.030150
216
+ insert 10 facts 0.045651
217
+ query 10 times w/txn 1.970434
218
+ query 10 times w/o txn 0.039459
219
+ modify 10 attrs w/txn 1.819769
220
+ delete 10 facts w/txn 1.056563
221
+ (and (eq what 'issue-was-closed') (exists... -> 200 2.125753
222
+ (and (eq what 'issue-was-closed') (exists... -> 200/txn 1.135618
223
+ (and (eq what 'issue-was-closed') (exists... -> zero 2.422668
224
+ (and (eq what 'issue-was-closed') (exists... -> zero/txn 1.288236
225
+ (gt time '2024-03-23T03:21:43Z') 0.108849
226
+ (gt cost 50) 0.090092
227
+ (eq title 'Object Thinking 5000') 0.002640
228
+ (and (eq foo 42.998) (or (gt bar 200) (absent zzz))) 0.023785
229
+ (eq id (agg (always) (max id))) 0.252980
230
+ (join "c<=cost,b<=bar" (eq id (agg (always) (max id)))) 0.655997
231
+ delete! 0.075510
232
+ Taped.append() x50000 0.042923
233
+ Taped.each() x125 1.343819
234
+ Taped.delete_if() x375 0.830124
235
235
  ```
236
236
 
237
237
  The results were calculated in [this GHA job][benchmark-gha]
238
- on 2025-06-03 at 09:54,
238
+ on 2025-06-21 at 08:24,
239
239
  on Linux with 4 CPUs.
240
240
  <!-- benchmark_end -->
241
241
 
242
- [benchmark-gha]: https://github.com/yegor256/factbase/actions/runs/15414210508
242
+ [benchmark-gha]: https://github.com/yegor256/factbase/actions/runs/15793882855
data/factbase.gemspec CHANGED
@@ -4,7 +4,7 @@
4
4
  # SPDX-License-Identifier: MIT
5
5
 
6
6
  require 'English'
7
- require_relative 'lib/factbase'
7
+ require_relative 'lib/factbase/version'
8
8
 
9
9
  Gem::Specification.new do |s|
10
10
  s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
@@ -21,12 +21,13 @@ Gem::Specification.new do |s|
21
21
  'An entire factbase may be exported to a binary file and imported back.'
22
22
  s.authors = ['Yegor Bugayenko']
23
23
  s.email = 'yegor256@gmail.com'
24
- s.homepage = 'http://github.com/yegor256/factbase.rb'
24
+ s.homepage = 'https://github.com/yegor256/factbase.rb'
25
25
  s.files = `git ls-files`.split($RS)
26
26
  s.rdoc_options = ['--charset=UTF-8']
27
27
  s.extra_rdoc_files = ['README.md', 'LICENSE.txt']
28
28
  s.add_dependency 'backtrace', '~>0.4'
29
29
  s.add_dependency 'decoor', '~>0.0'
30
+ s.add_dependency 'ellipsized', '~>0.3'
30
31
  s.add_dependency 'json', '~>2.7'
31
32
  s.add_dependency 'logger', '~>1.0'
32
33
  s.add_dependency 'loog', '~>0.6'
@@ -3,6 +3,7 @@
3
3
  # SPDX-FileCopyrightText: Copyright (c) 2024-2025 Yegor Bugayenko
4
4
  # SPDX-License-Identifier: MIT
5
5
 
6
+ require 'ellipsized'
6
7
  require 'yaml'
7
8
  require_relative '../factbase'
8
9
 
@@ -33,6 +34,8 @@ class Factbase::FactAsYaml
33
34
  v = @fact[p]
34
35
  hash[p] = v.is_a?(Array) ? v : [v]
35
36
  end
36
- hash.sort.to_h.to_yaml
37
+ hash.sort.to_h.map do |k, vv|
38
+ "#{k}: [#{vv.map { |v| v.is_a?(String) ? v.ellipsized : v }.map(&:inspect).join(', ')}]"
39
+ end.join("\n")
37
40
  end
38
41
  end
@@ -114,7 +114,7 @@ class Factbase::Logged
114
114
  v = args[1]
115
115
  s = v.is_a?(Time) ? v.utc.iso8601 : v.to_s
116
116
  s = v.to_s.inspect if v.is_a?(String)
117
- s = "#{s[0..MAX_LENGTH / 2]}...#{s[-MAX_LENGTH / 2..]}" if s.length > MAX_LENGTH
117
+ s = "#{s[0..(MAX_LENGTH / 2)]}...#{s[(-MAX_LENGTH / 2)..]}" if s.length > MAX_LENGTH
118
118
  @tube.say(start, "Set '#{k[0..-2]}' to #{s} (#{v.class})") if k.end_with?('=')
119
119
  r
120
120
  end
data/lib/factbase/term.rb CHANGED
@@ -118,9 +118,9 @@ class Factbase::Term
118
118
  def evaluate(fact, maps, fb)
119
119
  send(@op, fact, maps, fb)
120
120
  rescue NoMethodError => e
121
- raise "Probably the term '#{@op}' is not defined at #{self}:\n#{Backtrace.new(e)}"
121
+ raise "Probably the term '#{@op}' is not defined at #{self}: #{e.message}"
122
122
  rescue StandardError => e
123
- raise "#{e.message} at #{self}:\n#{Backtrace.new(e)}"
123
+ raise "#{e.message} at #{self}"
124
124
  end
125
125
 
126
126
  # Simplify it if possible.
@@ -43,7 +43,7 @@ module Factbase::Logical
43
43
  # @param [Array<Factbase::Fact>] maps All maps available
44
44
  # @return [Boolean] True if any operand evaluates to true, false otherwise
45
45
  def or(fact, maps, fb)
46
- (0..@operands.size - 1).each do |i|
46
+ (0..(@operands.size - 1)).each do |i|
47
47
  return true if _only_bool(_values(i, fact, maps, fb), i)
48
48
  end
49
49
  false
@@ -54,7 +54,7 @@ module Factbase::Logical
54
54
  # @param [Array<Factbase::Fact>] maps All maps available
55
55
  # @return [Boolean] True if all operands evaluate to true, false otherwise
56
56
  def and(fact, maps, fb)
57
- (0..@operands.size - 1).each do |i|
57
+ (0..(@operands.size - 1)).each do |i|
58
58
  return false unless _only_bool(_values(i, fact, maps, fb), i)
59
59
  end
60
60
  true
@@ -12,12 +12,12 @@ require_relative '../../factbase'
12
12
  # License:: MIT
13
13
  module Factbase::Strings
14
14
  def concat(fact, maps, fb)
15
- (0..@operands.length - 1).map { |i| _values(i, fact, maps, fb)&.first }.join
15
+ (0..(@operands.length - 1)).map { |i| _values(i, fact, maps, fb)&.first }.join
16
16
  end
17
17
 
18
18
  def sprintf(fact, maps, fb)
19
19
  fmt = _values(0, fact, maps, fb)[0]
20
- ops = (1..@operands.length - 1).map { |i| _values(i, fact, maps, fb)&.first }
20
+ ops = (1..(@operands.length - 1)).map { |i| _values(i, fact, maps, fb)&.first }
21
21
  format(*([fmt] + ops))
22
22
  end
23
23
 
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ # SPDX-FileCopyrightText: Copyright (c) 2024-2025 Yegor Bugayenko
4
+ # SPDX-License-Identifier: MIT
5
+
6
+ # Just version.
7
+ # Author:: Yegor Bugayenko (yegor256@gmail.com)
8
+ # Copyright:: Copyright (c) 2024-2025 Yegor Bugayenko
9
+ # License:: MIT
10
+ class Factbase
11
+ # Current version of the gem (changed by .rultor.yml on every release)
12
+ VERSION = '0.11.2' unless const_defined?(:VERSION)
13
+ end
data/lib/factbase.rb CHANGED
@@ -81,8 +81,7 @@ require 'yaml'
81
81
  # Copyright:: Copyright (c) 2024-2025 Yegor Bugayenko
82
82
  # License:: MIT
83
83
  class Factbase
84
- # Current version of the gem (changed by .rultor.yml on every release)
85
- VERSION = '0.11.0' unless const_defined?(:VERSION)
84
+ require_relative 'factbase/version'
86
85
 
87
86
  # An exception that may be thrown in a transaction, to roll it back.
88
87
  class Rollback < StandardError; end
@@ -13,6 +13,21 @@ require_relative '../test__helper'
13
13
  # Copyright:: Copyright (c) 2024-2025 Yegor Bugayenko
14
14
  # License:: MIT
15
15
  class TestFactAsYaml < Factbase::Test
16
+ def test_prints_exactly
17
+ fb = Factbase.new
18
+ f = fb.insert
19
+ f._id = 1
20
+ f.foo = 42
21
+ f.foo = 33
22
+ f.bar = 'hello, world! how are you?'
23
+ assert_equal(
24
+ "_id: [1]\n" \
25
+ "bar: [\"hello, world! how are you?\"]\n" \
26
+ 'foo: [42, 33]',
27
+ Factbase::FactAsYaml.new(f).to_s
28
+ )
29
+ end
30
+
16
31
  def test_simple_rendering
17
32
  fb = Factbase.new
18
33
  f = fb.insert
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: factbase
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.11.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
@@ -37,6 +37,20 @@ dependencies:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
39
  version: '0.0'
40
+ - !ruby/object:Gem::Dependency
41
+ name: ellipsized
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '0.3'
47
+ type: :runtime
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '0.3'
40
54
  - !ruby/object:Gem::Dependency
41
55
  name: json
42
56
  requirement: !ruby/object:Gem::Requirement
@@ -149,6 +163,7 @@ extra_rdoc_files:
149
163
  files:
150
164
  - ".0pdd.yml"
151
165
  - ".gitattributes"
166
+ - ".github/publish-benchmark.sh"
152
167
  - ".github/workflows/actionlint.yml"
153
168
  - ".github/workflows/benchmark.yml"
154
169
  - ".github/workflows/codecov.yml"
@@ -234,6 +249,7 @@ files:
234
249
  - lib/factbase/to_json.rb
235
250
  - lib/factbase/to_xml.rb
236
251
  - lib/factbase/to_yaml.rb
252
+ - lib/factbase/version.rb
237
253
  - renovate.json
238
254
  - test/factbase/cached/test_cached_factbase.rb
239
255
  - test/factbase/cached/test_cached_query.rb
@@ -274,7 +290,7 @@ files:
274
290
  - test/factbase/test_to_yaml.rb
275
291
  - test/test__helper.rb
276
292
  - test/test_factbase.rb
277
- homepage: http://github.com/yegor256/factbase.rb
293
+ homepage: https://github.com/yegor256/factbase.rb
278
294
  licenses:
279
295
  - MIT
280
296
  metadata: