factbase 0.0.21 → 0.0.23

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: dd8e28cf7e8e84fc0364bb8780775592aa86c415a05a49d4edd88bbc9a717a80
4
- data.tar.gz: ba7c821a3d229cb5f8b0e9fd1e632cd6d2e69c33eacb6b49751a5dd92902a23a
3
+ metadata.gz: 27e9aaa353b400d0004ccefcb53fda8fa0d1ac8f2a6d2f4eae8892dbbf2b503f
4
+ data.tar.gz: 746387ad73281024c9f41c3b444c8986e0a064af0bb0531b12777ef1637d0e3c
5
5
  SHA512:
6
- metadata.gz: 897308019e1fb3e05bad6e47ac06c39ec91250981e1b0206600a9a5620cb03b29c9dac866640994ac077e6bc3c418b5ea8aec7878e1e2b4587bab6d77b2cffb7
7
- data.tar.gz: 50172f65e3b8e40a30ec37155264c464b6a2849152ff9752270a38e8610c022506cd4b69cc1ed6869b2b8ecaa6056e3976d48a73642b067ffaedfc28ad887959
6
+ metadata.gz: b96169f610fc86f97ea99e646f4bbe7a5cb76b0b693699df75186327172b102f892db91f677bfd55dbddbc6c6c3bf9bd2e3481d6331bdc5197c7f7fb4c184454
7
+ data.tar.gz: c002777263b5e57350c0365b10033284aa6bff207b8f03e0d8d9f65504dd5a79f94aa2cdf1df5a2e4f28f840e3d27d703b3740927c7514e064aeb57411031511
@@ -31,7 +31,8 @@ jobs:
31
31
  - uses: ruby/setup-ruby@v1
32
32
  with:
33
33
  ruby-version: 3.2
34
- - run: bundle update
34
+ bundler-cache: true
35
+ - run: bundle install
35
36
  - run: bundle exec rake
36
37
  - uses: codecov/codecov-action@v4.0.0-beta.3
37
38
  with:
@@ -19,7 +19,7 @@
19
19
  # SOFTWARE.
20
20
  ---
21
21
  name: rake
22
- on:
22
+ 'on':
23
23
  push:
24
24
  branches:
25
25
  - master
@@ -31,7 +31,7 @@ jobs:
31
31
  name: test
32
32
  strategy:
33
33
  matrix:
34
- os: [ubuntu-20.04, macos-12]
34
+ os: [ubuntu-20.04, macos-12, windows-2022]
35
35
  ruby: [3.2]
36
36
  runs-on: ${{ matrix.os }}
37
37
  steps:
@@ -39,5 +39,6 @@ jobs:
39
39
  - uses: ruby/setup-ruby@v1
40
40
  with:
41
41
  ruby-version: ${{ matrix.ruby }}
42
- - run: bundle update
42
+ bundler-cache: true
43
+ - run: bundle install
43
44
  - run: bundle exec rake
data/.gitignore CHANGED
@@ -1,5 +1,4 @@
1
1
  coverage/
2
- Gemfile.lock
3
2
  .idea/
4
3
  *.gem
5
4
  .bundle/
data/.rubocop.yml CHANGED
@@ -22,6 +22,7 @@ AllCops:
22
22
  Exclude:
23
23
  - 'bin/**/*'
24
24
  - 'assets/**/*'
25
+ - 'vendor/**/**'
25
26
  DisplayCopNames: true
26
27
  TargetRubyVersion: 3.2
27
28
  SuggestExtensions: false
@@ -47,3 +48,5 @@ Layout/EmptyLineAfterGuardClause:
47
48
  Enabled: false
48
49
  Naming/MethodParameterName:
49
50
  MinNameLength: 2
51
+ Layout/EndOfLine:
52
+ EnforcedStyle: lf
data/Gemfile CHANGED
@@ -23,10 +23,11 @@
23
23
  source 'https://rubygems.org'
24
24
  gemspec
25
25
 
26
- gem 'minitest', '5.22.3', require: false
26
+ gem 'minitest', '5.23.0', require: false
27
27
  gem 'rake', '13.2.1', require: false
28
28
  gem 'rspec-rails', '6.1.2', require: false
29
29
  gem 'rubocop', '1.63.5', require: false
30
+ gem 'rubocop-performance', '1.21.0', require: false
30
31
  gem 'rubocop-rspec', '2.29.2', require: false
31
32
  gem 'simplecov', '0.22.0', require: false
32
33
  gem 'simplecov-cobertura', '2.1.0', require: false
data/Gemfile.lock ADDED
@@ -0,0 +1,195 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ factbase (0.0.0)
5
+ json (~> 2.7)
6
+ loog (~> 0.2)
7
+ nokogiri (~> 1.10)
8
+ yaml (~> 0.3)
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ actionpack (7.1.3.3)
14
+ actionview (= 7.1.3.3)
15
+ activesupport (= 7.1.3.3)
16
+ nokogiri (>= 1.8.5)
17
+ racc
18
+ rack (>= 2.2.4)
19
+ rack-session (>= 1.0.1)
20
+ rack-test (>= 0.6.3)
21
+ rails-dom-testing (~> 2.2)
22
+ rails-html-sanitizer (~> 1.6)
23
+ actionview (7.1.3.3)
24
+ activesupport (= 7.1.3.3)
25
+ builder (~> 3.1)
26
+ erubi (~> 1.11)
27
+ rails-dom-testing (~> 2.2)
28
+ rails-html-sanitizer (~> 1.6)
29
+ activesupport (7.1.3.3)
30
+ base64
31
+ bigdecimal
32
+ concurrent-ruby (~> 1.0, >= 1.0.2)
33
+ connection_pool (>= 2.2.5)
34
+ drb
35
+ i18n (>= 1.6, < 2)
36
+ minitest (>= 5.1)
37
+ mutex_m
38
+ tzinfo (~> 2.0)
39
+ ast (2.4.2)
40
+ base64 (0.2.0)
41
+ bigdecimal (3.1.8)
42
+ builder (3.2.4)
43
+ concurrent-ruby (1.2.3)
44
+ connection_pool (2.4.1)
45
+ crass (1.0.6)
46
+ diff-lcs (1.5.1)
47
+ docile (1.4.0)
48
+ drb (2.2.1)
49
+ erubi (1.12.0)
50
+ i18n (1.14.5)
51
+ concurrent-ruby (~> 1.0)
52
+ io-console (0.7.2)
53
+ irb (1.13.1)
54
+ rdoc (>= 4.0.0)
55
+ reline (>= 0.4.2)
56
+ json (2.7.2)
57
+ language_server-protocol (3.17.0.3)
58
+ loofah (2.22.0)
59
+ crass (~> 1.0.2)
60
+ nokogiri (>= 1.12.0)
61
+ loog (0.5.1)
62
+ minitest (5.23.0)
63
+ mutex_m (0.2.0)
64
+ nokogiri (1.16.5-arm64-darwin)
65
+ racc (~> 1.4)
66
+ nokogiri (1.16.5-x64-mingw-ucrt)
67
+ racc (~> 1.4)
68
+ nokogiri (1.16.5-x86_64-darwin)
69
+ racc (~> 1.4)
70
+ nokogiri (1.16.5-x86_64-linux)
71
+ racc (~> 1.4)
72
+ parallel (1.24.0)
73
+ parser (3.3.1.0)
74
+ ast (~> 2.4.1)
75
+ racc
76
+ psych (5.1.2)
77
+ stringio
78
+ racc (1.7.3)
79
+ rack (3.0.11)
80
+ rack-session (2.0.0)
81
+ rack (>= 3.0.0)
82
+ rack-test (2.1.0)
83
+ rack (>= 1.3)
84
+ rackup (2.1.0)
85
+ rack (>= 3)
86
+ webrick (~> 1.8)
87
+ rails-dom-testing (2.2.0)
88
+ activesupport (>= 5.0.0)
89
+ minitest
90
+ nokogiri (>= 1.6)
91
+ rails-html-sanitizer (1.6.0)
92
+ loofah (~> 2.21)
93
+ nokogiri (~> 1.14)
94
+ railties (7.1.3.3)
95
+ actionpack (= 7.1.3.3)
96
+ activesupport (= 7.1.3.3)
97
+ irb
98
+ rackup (>= 1.0.0)
99
+ rake (>= 12.2)
100
+ thor (~> 1.0, >= 1.2.2)
101
+ zeitwerk (~> 2.6)
102
+ rainbow (3.1.1)
103
+ rake (13.2.1)
104
+ rdoc (6.6.3.1)
105
+ psych (>= 4.0.0)
106
+ regexp_parser (2.9.2)
107
+ reline (0.5.7)
108
+ io-console (~> 0.5)
109
+ rexml (3.2.8)
110
+ strscan (>= 3.0.9)
111
+ rspec-core (3.13.0)
112
+ rspec-support (~> 3.13.0)
113
+ rspec-expectations (3.13.0)
114
+ diff-lcs (>= 1.2.0, < 2.0)
115
+ rspec-support (~> 3.13.0)
116
+ rspec-mocks (3.13.1)
117
+ diff-lcs (>= 1.2.0, < 2.0)
118
+ rspec-support (~> 3.13.0)
119
+ rspec-rails (6.1.2)
120
+ actionpack (>= 6.1)
121
+ activesupport (>= 6.1)
122
+ railties (>= 6.1)
123
+ rspec-core (~> 3.13)
124
+ rspec-expectations (~> 3.13)
125
+ rspec-mocks (~> 3.13)
126
+ rspec-support (~> 3.13)
127
+ rspec-support (3.13.1)
128
+ rubocop (1.63.5)
129
+ json (~> 2.3)
130
+ language_server-protocol (>= 3.17.0)
131
+ parallel (~> 1.10)
132
+ parser (>= 3.3.0.2)
133
+ rainbow (>= 2.2.2, < 4.0)
134
+ regexp_parser (>= 1.8, < 3.0)
135
+ rexml (>= 3.2.5, < 4.0)
136
+ rubocop-ast (>= 1.31.1, < 2.0)
137
+ ruby-progressbar (~> 1.7)
138
+ unicode-display_width (>= 2.4.0, < 3.0)
139
+ rubocop-ast (1.31.3)
140
+ parser (>= 3.3.1.0)
141
+ rubocop-capybara (2.20.0)
142
+ rubocop (~> 1.41)
143
+ rubocop-factory_bot (2.25.1)
144
+ rubocop (~> 1.41)
145
+ rubocop-performance (1.21.0)
146
+ rubocop (>= 1.48.1, < 2.0)
147
+ rubocop-ast (>= 1.31.1, < 2.0)
148
+ rubocop-rspec (2.29.2)
149
+ rubocop (~> 1.40)
150
+ rubocop-capybara (~> 2.17)
151
+ rubocop-factory_bot (~> 2.22)
152
+ rubocop-rspec_rails (~> 2.28)
153
+ rubocop-rspec_rails (2.28.3)
154
+ rubocop (~> 1.40)
155
+ ruby-progressbar (1.13.0)
156
+ simplecov (0.22.0)
157
+ docile (~> 1.1)
158
+ simplecov-html (~> 0.11)
159
+ simplecov_json_formatter (~> 0.1)
160
+ simplecov-cobertura (2.1.0)
161
+ rexml
162
+ simplecov (~> 0.19)
163
+ simplecov-html (0.12.3)
164
+ simplecov_json_formatter (0.1.4)
165
+ stringio (3.1.0)
166
+ strscan (3.1.0)
167
+ thor (1.3.1)
168
+ tzinfo (2.0.6)
169
+ concurrent-ruby (~> 1.0)
170
+ unicode-display_width (2.5.0)
171
+ webrick (1.8.1)
172
+ yaml (0.3.0)
173
+ yard (0.9.36)
174
+ zeitwerk (2.6.14)
175
+
176
+ PLATFORMS
177
+ arm64-darwin-22
178
+ x64-mingw-ucrt
179
+ x86_64-darwin-20
180
+ x86_64-linux
181
+
182
+ DEPENDENCIES
183
+ factbase!
184
+ minitest (= 5.23.0)
185
+ rake (= 13.2.1)
186
+ rspec-rails (= 6.1.2)
187
+ rubocop (= 1.63.5)
188
+ rubocop-performance (= 1.21.0)
189
+ rubocop-rspec (= 2.29.2)
190
+ simplecov (= 0.22.0)
191
+ simplecov-cobertura (= 2.1.0)
192
+ yard (= 0.9.36)
193
+
194
+ BUNDLED WITH
195
+ 2.4.22
data/factbase.gemspec CHANGED
@@ -26,7 +26,7 @@ Gem::Specification.new do |s|
26
26
  s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
27
27
  s.required_ruby_version = '>=2.3'
28
28
  s.name = 'factbase'
29
- s.version = '0.0.21'
29
+ s.version = '0.0.23'
30
30
  s.license = 'MIT'
31
31
  s.summary = 'Factbase'
32
32
  s.description = 'Fact base in memory and on disc'
@@ -42,7 +42,7 @@ class Factbase::Looged
42
42
 
43
43
  def insert
44
44
  f = @fb.insert
45
- @loog.debug("Inserted fact ##{f.id}")
45
+ @loog.debug('Inserted new fact')
46
46
  Fact.new(f, @loog)
47
47
  end
48
48
 
@@ -0,0 +1,72 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright (c) 2024 Yegor Bugayenko
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the 'Software'), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
22
+
23
+ require 'loog'
24
+
25
+ # A decorator of a Factbase, that runs a provided block on every +insert+.
26
+ # Author:: Yegor Bugayenko (yegor256@gmail.com)
27
+ # Copyright:: Copyright (c) 2024 Yegor Bugayenko
28
+ # License:: MIT
29
+ class Factbase::Pre
30
+ def initialize(fb, &block)
31
+ @fb = fb
32
+ @block = block
33
+ end
34
+
35
+ def empty?
36
+ @fb.empty?
37
+ end
38
+
39
+ def size
40
+ @fb.size
41
+ end
42
+
43
+ def insert
44
+ f = @fb.insert
45
+ @block.call(f)
46
+ f
47
+ end
48
+
49
+ def query(query)
50
+ @fb.query(query)
51
+ end
52
+
53
+ def export
54
+ @fb.export
55
+ end
56
+
57
+ def import(bytes)
58
+ @fb.import(bytes)
59
+ end
60
+
61
+ def to_json(opt = nil)
62
+ @fb.to_json(opt)
63
+ end
64
+
65
+ def to_xml
66
+ @fb.to_xml
67
+ end
68
+
69
+ def to_yaml
70
+ @fb.to_yaml
71
+ end
72
+ end
data/lib/factbase.rb CHANGED
@@ -53,8 +53,6 @@ class Factbase
53
53
  require_relative 'factbase/fact'
54
54
  map = {}
55
55
  @mutex.synchronize do
56
- f = Factbase::Fact.new(Mutex.new, map)
57
- f.id = @maps.size + 1
58
56
  @maps << map
59
57
  end
60
58
  Factbase::Fact.new(@mutex, map)
@@ -34,13 +34,13 @@ class TestLooged < Minitest::Test
34
34
  fb.insert
35
35
  fb.insert.bar = 3
36
36
  found = 0
37
- fb.query('(exists id)').each do |f|
38
- assert(42, f.id.positive?)
37
+ fb.query('(exists bar)').each do |f|
38
+ assert(42, f.bar.positive?)
39
39
  f.foo = 42
40
40
  assert_equal(42, f.foo)
41
41
  found += 1
42
42
  end
43
- assert_equal(2, found)
43
+ assert_equal(1, found)
44
44
  assert_equal(2, fb.size)
45
45
  end
46
46
 
@@ -72,8 +72,7 @@ class TestLooged < Minitest::Test
72
72
  fb.query('(exists bar)').each(&:to_s)
73
73
  fb.query('(not (exists bar))').delete!
74
74
  [
75
- 'Inserted fact #1',
76
- 'Inserted fact #2',
75
+ 'Inserted new fact',
77
76
  'Set \'bar\' to "3" (Integer)',
78
77
  'Found 1 fact(s) by \'(exists bar)\'',
79
78
  'Deleted 2 fact(s) by \'(not (exists bar))\''
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright (c) 2024 Yegor Bugayenko
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the 'Software'), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
22
+
23
+ require 'minitest/autorun'
24
+ require 'loog'
25
+ require_relative '../../lib/factbase/pre'
26
+
27
+ # Test.
28
+ # Author:: Yegor Bugayenko (yegor256@gmail.com)
29
+ # Copyright:: Copyright (c) 2024 Yegor Bugayenko
30
+ # License:: MIT
31
+ class TestPre < Minitest::Test
32
+ def test_simple_setting
33
+ fb = Factbase::Pre.new(Factbase.new) { |f| f.foo = 42 }
34
+ f = fb.insert
35
+ assert_equal(42, f.foo)
36
+ end
37
+ end
@@ -33,12 +33,11 @@ class TestSpy < Minitest::Test
33
33
  fb = Factbase::Spy.new(Factbase.new, 'foo')
34
34
  fb.insert.foo = 42
35
35
  fb.insert.foo = 'hello'
36
- fb.query('(eq foo "test")').each do |f|
37
- assert(f.id.positive?)
36
+ fb.query('(eq foo "hello")').each do |f|
37
+ assert_equal('hello', f.foo)
38
38
  end
39
39
  assert_equal(3, fb.caught_keys.size)
40
40
  assert(fb.caught_keys.include?('hello'))
41
41
  assert(fb.caught_keys.include?(42))
42
- assert(fb.caught_keys.include?('test'))
43
42
  end
44
43
  end
@@ -34,15 +34,15 @@ class TestFactbase < Minitest::Test
34
34
  def test_simple_setting
35
35
  fb = Factbase.new
36
36
  fb.insert
37
- fb.insert
37
+ fb.insert.bar = 88
38
38
  found = 0
39
- fb.query('(exists id)').each do |f|
40
- assert(42, f.id.positive?)
39
+ fb.query('(exists bar)').each do |f|
40
+ assert(42, f.bar.positive?)
41
41
  f.foo = 42
42
42
  assert_equal(42, f.foo)
43
43
  found += 1
44
44
  end
45
- assert_equal(2, found)
45
+ assert_equal(1, found)
46
46
  assert_equal(2, fb.size)
47
47
  end
48
48
 
@@ -106,6 +106,5 @@ class TestFactbase < Minitest::Test
106
106
  assert_equal(2, yaml['facts'].size)
107
107
  assert_equal(42, yaml['facts'][0]['foo'][0])
108
108
  assert_equal(256, yaml['facts'][0]['foo'][1])
109
- assert_equal(2, yaml['facts'][1]['id'])
110
109
  end
111
110
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: factbase
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.21
4
+ version: 0.0.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-05-15 00:00:00.000000000 Z
11
+ date: 2024-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -90,6 +90,7 @@ files:
90
90
  - ".simplecov"
91
91
  - ".yamllint.yml"
92
92
  - Gemfile
93
+ - Gemfile.lock
93
94
  - LICENSE.txt
94
95
  - README.md
95
96
  - Rakefile
@@ -97,6 +98,7 @@ files:
97
98
  - lib/factbase.rb
98
99
  - lib/factbase/fact.rb
99
100
  - lib/factbase/looged.rb
101
+ - lib/factbase/pre.rb
100
102
  - lib/factbase/query.rb
101
103
  - lib/factbase/spy.rb
102
104
  - lib/factbase/syntax.rb
@@ -105,6 +107,7 @@ files:
105
107
  - renovate.json
106
108
  - test/factbase/test_fact.rb
107
109
  - test/factbase/test_looged.rb
110
+ - test/factbase/test_pre.rb
108
111
  - test/factbase/test_query.rb
109
112
  - test/factbase/test_spy.rb
110
113
  - test/factbase/test_syntax.rb