factbase 0.10.2 → 0.11.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 +4 -4
- data/.github/publish-benchmark.sh +24 -0
- data/.github/workflows/benchmark.yml +1 -17
- data/.github/workflows/copyrights.yml +1 -1
- data/.github/workflows/markdown-lint.yml +1 -1
- data/.github/workflows/typos.yml +1 -1
- data/.gitignore +1 -0
- data/.rubocop.yml +2 -0
- data/Gemfile +5 -6
- data/Gemfile.lock +18 -18
- data/README.md +25 -25
- data/factbase.gemspec +2 -1
- data/lib/factbase/fact_as_yaml.rb +41 -0
- data/lib/factbase/logged.rb +1 -1
- data/lib/factbase/terms/logical.rb +2 -2
- data/lib/factbase/terms/strings.rb +2 -2
- data/lib/factbase.rb +1 -1
- data/test/factbase/cached/test_cached_factbase.rb +9 -0
- data/test/factbase/test_fact_as_yaml.rb +77 -0
- metadata +19 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e27fe11aa944dcd02303229649c86810bd2585e18c86ec227b113d2a50633ec4
|
4
|
+
data.tar.gz: a3fad9da51b5201a84f71177475a8b768bb037f6f7dc9fbc01f61b076e9a6559
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cef5dbc22c5692f7e3219cfc11802ba7b114cdd5d30ae65e20960186b919ff69b6a5015e7fc5985644713dd852b624e9575784496b62e8155c254871dac9b3d4
|
7
|
+
data.tar.gz: ed05d5bf86469a9c30c7f66c03222b65ec4b3a02ac9a403bda966914538c83e27be9d4ffc6a0e7e8890dc00a57d2e21810cc3b6ac8b98bd66a28d9dcefcbe469
|
@@ -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
|
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/.github/workflows/typos.yml
CHANGED
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
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', '
|
12
|
-
gem 'qbash', '
|
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', '
|
17
|
-
gem 'rubocop-performance', '
|
18
|
-
gem 'rubocop-rake', '
|
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,7 +18,7 @@ GEM
|
|
17
18
|
specs:
|
18
19
|
ansi (1.5.0)
|
19
20
|
ast (2.4.3)
|
20
|
-
backtrace (0.4.
|
21
|
+
backtrace (0.4.1)
|
21
22
|
builder (3.3.0)
|
22
23
|
concurrent-ruby (1.3.5)
|
23
24
|
date (3.4.1)
|
@@ -26,7 +27,9 @@ GEM
|
|
26
27
|
elapsed (0.0.1)
|
27
28
|
loog (> 0)
|
28
29
|
tago (> 0)
|
29
|
-
|
30
|
+
ellipsized (0.3.0)
|
31
|
+
erb (5.0.1)
|
32
|
+
json (2.12.2)
|
30
33
|
language_server-protocol (3.17.0.5)
|
31
34
|
lint_roller (1.1.0)
|
32
35
|
logger (1.7.0)
|
@@ -47,7 +50,7 @@ GEM
|
|
47
50
|
nokogiri (1.18.8-x86_64-linux-gnu)
|
48
51
|
racc (~> 1.4)
|
49
52
|
os (1.1.4)
|
50
|
-
others (0.
|
53
|
+
others (0.1.1)
|
51
54
|
parallel (1.27.0)
|
52
55
|
parser (3.3.8.0)
|
53
56
|
ast (~> 2.4.1)
|
@@ -63,12 +66,13 @@ GEM
|
|
63
66
|
tago (> 0)
|
64
67
|
racc (1.8.1)
|
65
68
|
rainbow (3.1.1)
|
66
|
-
rake (13.
|
67
|
-
rdoc (6.
|
69
|
+
rake (13.3.0)
|
70
|
+
rdoc (6.14.1)
|
71
|
+
erb
|
68
72
|
psych (>= 4.0.0)
|
69
73
|
regexp_parser (2.10.0)
|
70
74
|
rexml (3.4.1)
|
71
|
-
rubocop (1.
|
75
|
+
rubocop (1.77.0)
|
72
76
|
json (~> 2.3)
|
73
77
|
language_server-protocol (~> 3.17.0.2)
|
74
78
|
lint_roller (~> 1.1.0)
|
@@ -76,13 +80,13 @@ GEM
|
|
76
80
|
parser (>= 3.3.0.2)
|
77
81
|
rainbow (>= 2.2.2, < 4.0)
|
78
82
|
regexp_parser (>= 2.9.3, < 3.0)
|
79
|
-
rubocop-ast (>= 1.
|
83
|
+
rubocop-ast (>= 1.45.1, < 2.0)
|
80
84
|
ruby-progressbar (~> 1.7)
|
81
85
|
unicode-display_width (>= 2.4.0, < 4.0)
|
82
|
-
rubocop-ast (1.
|
86
|
+
rubocop-ast (1.45.1)
|
83
87
|
parser (>= 3.3.7.2)
|
84
88
|
prism (~> 1.4)
|
85
|
-
rubocop-minitest (0.38.
|
89
|
+
rubocop-minitest (0.38.1)
|
86
90
|
lint_roller (~> 1.1)
|
87
91
|
rubocop (>= 1.75.0, < 2.0)
|
88
92
|
rubocop-ast (>= 1.38.0, < 2.0)
|
@@ -93,9 +97,6 @@ GEM
|
|
93
97
|
rubocop-rake (0.7.1)
|
94
98
|
lint_roller (~> 1.1)
|
95
99
|
rubocop (>= 1.72.1)
|
96
|
-
rubocop-rspec (3.6.0)
|
97
|
-
lint_roller (~> 1.1)
|
98
|
-
rubocop (~> 1.72, >= 1.72.1)
|
99
100
|
ruby-progressbar (1.13.0)
|
100
101
|
simplecov (0.22.0)
|
101
102
|
docile (~> 1.1)
|
@@ -130,15 +131,14 @@ DEPENDENCIES
|
|
130
131
|
factbase!
|
131
132
|
minitest (~> 5.25)
|
132
133
|
minitest-reporters (~> 1.7)
|
133
|
-
os (
|
134
|
-
qbash (
|
134
|
+
os (~> 1.1)
|
135
|
+
qbash (~> 0.4)
|
135
136
|
rake (~> 13.2)
|
136
137
|
rdoc (~> 6.13)
|
137
138
|
rubocop (~> 1.74)
|
138
|
-
rubocop-minitest (
|
139
|
-
rubocop-performance (
|
140
|
-
rubocop-rake (
|
141
|
-
rubocop-rspec (> 0)
|
139
|
+
rubocop-minitest (~> 0.38)
|
140
|
+
rubocop-performance (~> 1.25)
|
141
|
+
rubocop-rake (~> 0.7)
|
142
142
|
simplecov (~> 0.22)
|
143
143
|
simplecov-cobertura (~> 2.1)
|
144
144
|
threads (~> 0.4)
|
data/README.md
CHANGED
@@ -209,34 +209,34 @@ This is the result of the benchmark:
|
|
209
209
|
|
210
210
|
<!-- benchmark_begin -->
|
211
211
|
```text
|
212
|
-
user
|
213
|
-
insert 20000 facts 0.
|
214
|
-
export 20000 facts 0.
|
215
|
-
import
|
216
|
-
insert 10 facts 0.
|
217
|
-
query 10 times w/txn 1.
|
218
|
-
query 10 times w/o txn 0.
|
219
|
-
modify 10 attrs w/txn 1.
|
220
|
-
delete 10 facts w/txn 1.
|
221
|
-
(and (eq what 'issue-was-closed') (exists... -> 200 2.
|
222
|
-
(and (eq what 'issue-was-closed') (exists... -> 200/txn 1.
|
223
|
-
(and (eq what 'issue-was-closed') (exists... -> zero 2.
|
224
|
-
(and (eq what 'issue-was-closed') (exists... -> zero/txn 1.
|
225
|
-
(gt time '2024-03-23T03:21:43Z') 0.
|
226
|
-
(gt cost 50) 0.
|
227
|
-
(eq title 'Object Thinking 5000') 0.
|
228
|
-
(and (eq foo 42.998) (or (gt bar 200) (absent zzz))) 0.
|
229
|
-
(eq id (agg (always) (max id))) 0.
|
230
|
-
(join "c<=cost,b<=bar" (eq id (agg (always) (max id)))) 0.
|
231
|
-
delete! 0.
|
232
|
-
Taped.append() x50000 0.
|
233
|
-
Taped.each() x125 1.
|
234
|
-
Taped.delete_if() x375 0.
|
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
|
235
235
|
```
|
236
236
|
|
237
237
|
The results were calculated in [this GHA job][benchmark-gha]
|
238
|
-
on 2025-
|
238
|
+
on 2025-06-03 at 09:54,
|
239
239
|
on Linux with 4 CPUs.
|
240
240
|
<!-- benchmark_end -->
|
241
241
|
|
242
|
-
[benchmark-gha]: https://github.com/yegor256/factbase/actions/runs/
|
242
|
+
[benchmark-gha]: https://github.com/yegor256/factbase/actions/runs/15414210508
|
data/factbase.gemspec
CHANGED
@@ -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 = '
|
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'
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 Yegor Bugayenko
|
4
|
+
# SPDX-License-Identifier: MIT
|
5
|
+
|
6
|
+
require 'ellipsized'
|
7
|
+
require 'yaml'
|
8
|
+
require_relative '../factbase'
|
9
|
+
|
10
|
+
# Single fact to YAML converter.
|
11
|
+
#
|
12
|
+
# This class helps converting a single fact to YAML format, for example:
|
13
|
+
#
|
14
|
+
# require 'factbase/fact_as_yaml'
|
15
|
+
# fb = Factbase.new
|
16
|
+
# f = fb.query('(eq foo 42)').to_a.first
|
17
|
+
# puts Factbase::FactAsYaml.new(f).to_s
|
18
|
+
#
|
19
|
+
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
20
|
+
# Copyright:: Copyright (c) 2024-2025 Yegor Bugayenko
|
21
|
+
# License:: MIT
|
22
|
+
class Factbase::FactAsYaml
|
23
|
+
# Constructor.
|
24
|
+
def initialize(fact)
|
25
|
+
@fact = fact
|
26
|
+
end
|
27
|
+
|
28
|
+
# Convert the fact to YAML.
|
29
|
+
# @return [String] The fact in YAML format
|
30
|
+
def to_s
|
31
|
+
props = @fact.all_properties
|
32
|
+
hash = {}
|
33
|
+
props.each do |p|
|
34
|
+
v = @fact[p]
|
35
|
+
hash[p] = v.is_a?(Array) ? v : [v]
|
36
|
+
end
|
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")
|
40
|
+
end
|
41
|
+
end
|
data/lib/factbase/logged.rb
CHANGED
@@ -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
|
@@ -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
|
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
|
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
|
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
|
20
|
+
ops = (1..(@operands.length - 1)).map { |i| _values(i, fact, maps, fb)&.first }
|
21
21
|
format(*([fmt] + ops))
|
22
22
|
end
|
23
23
|
|
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.
|
85
|
+
VERSION = '0.11.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
|
@@ -32,4 +32,13 @@ class TestCachedFactbase < Factbase::Test
|
|
32
32
|
refute_empty(origin.query('(exists bar)').each.to_a)
|
33
33
|
refute_empty(fb.query('(exists bar)').each.to_a)
|
34
34
|
end
|
35
|
+
|
36
|
+
def test_prints_fact_correctly
|
37
|
+
fb = Factbase::CachedFactbase.new(Factbase.new)
|
38
|
+
f1 = fb.insert
|
39
|
+
f1.foo = 42
|
40
|
+
assert_equal('[ foo: [42] ]', f1.to_s)
|
41
|
+
f2 = fb.query('(always)').each.to_a.first
|
42
|
+
assert_equal('[ foo: [42] ] + {}', f2.to_s)
|
43
|
+
end
|
35
44
|
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 Yegor Bugayenko
|
4
|
+
# SPDX-License-Identifier: MIT
|
5
|
+
|
6
|
+
require 'yaml'
|
7
|
+
require_relative '../../lib/factbase'
|
8
|
+
require_relative '../../lib/factbase/fact_as_yaml'
|
9
|
+
require_relative '../test__helper'
|
10
|
+
|
11
|
+
# Test.
|
12
|
+
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
13
|
+
# Copyright:: Copyright (c) 2024-2025 Yegor Bugayenko
|
14
|
+
# License:: MIT
|
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
|
+
|
31
|
+
def test_simple_rendering
|
32
|
+
fb = Factbase.new
|
33
|
+
f = fb.insert
|
34
|
+
f._id = 1
|
35
|
+
f.foo = 42
|
36
|
+
f.bar = 'hello'
|
37
|
+
yaml_str = Factbase::FactAsYaml.new(f).to_s
|
38
|
+
yaml = YAML.load(yaml_str)
|
39
|
+
assert_equal(1, yaml['_id'][0])
|
40
|
+
assert_equal('hello', yaml['bar'][0])
|
41
|
+
assert_equal(42, yaml['foo'][0])
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_multiple_values
|
45
|
+
fb = Factbase.new
|
46
|
+
f = fb.insert
|
47
|
+
f.foo = 42
|
48
|
+
f.foo = 256
|
49
|
+
f.foo = 512
|
50
|
+
yaml_str = Factbase::FactAsYaml.new(f).to_s
|
51
|
+
yaml = YAML.load(yaml_str)
|
52
|
+
assert_equal([42, 256, 512], yaml['foo'])
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_sorted_keys
|
56
|
+
fb = Factbase.new
|
57
|
+
f = fb.insert
|
58
|
+
f.c = 3
|
59
|
+
f.a = 1
|
60
|
+
f.b = 2
|
61
|
+
yaml_str = Factbase::FactAsYaml.new(f).to_s
|
62
|
+
assert_operator(yaml_str.index('a:'), :<, yaml_str.index('b:'))
|
63
|
+
assert_operator(yaml_str.index('b:'), :<, yaml_str.index('c:'))
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_usage_example_from_issue
|
67
|
+
fb = Factbase.new
|
68
|
+
f = fb.insert
|
69
|
+
f._id = 1
|
70
|
+
f.name = 'test'
|
71
|
+
f = fb.query('(eq _id 1)').each.to_a.first
|
72
|
+
yaml_str = Factbase::FactAsYaml.new(f).to_s
|
73
|
+
assert(yaml_str)
|
74
|
+
assert_includes(yaml_str, '_id')
|
75
|
+
assert_includes(yaml_str, 'name')
|
76
|
+
end
|
77
|
+
end
|
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.
|
4
|
+
version: 0.11.1
|
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"
|
@@ -201,6 +216,7 @@ files:
|
|
201
216
|
- lib/factbase/cached/cached_term.rb
|
202
217
|
- lib/factbase/churn.rb
|
203
218
|
- lib/factbase/fact.rb
|
219
|
+
- lib/factbase/fact_as_yaml.rb
|
204
220
|
- lib/factbase/flatten.rb
|
205
221
|
- lib/factbase/indexed/indexed_fact.rb
|
206
222
|
- lib/factbase/indexed/indexed_factbase.rb
|
@@ -256,6 +272,7 @@ files:
|
|
256
272
|
- test/factbase/test_accum.rb
|
257
273
|
- test/factbase/test_churn.rb
|
258
274
|
- test/factbase/test_fact.rb
|
275
|
+
- test/factbase/test_fact_as_yaml.rb
|
259
276
|
- test/factbase/test_flatten.rb
|
260
277
|
- test/factbase/test_inv.rb
|
261
278
|
- test/factbase/test_logged.rb
|
@@ -272,7 +289,7 @@ files:
|
|
272
289
|
- test/factbase/test_to_yaml.rb
|
273
290
|
- test/test__helper.rb
|
274
291
|
- test/test_factbase.rb
|
275
|
-
homepage:
|
292
|
+
homepage: https://github.com/yegor256/factbase.rb
|
276
293
|
licenses:
|
277
294
|
- MIT
|
278
295
|
metadata:
|