factbase 0.0.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.
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ #
4
+ # Copyright (c) 2024 Yegor Bugayenko
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ # of this software and associated documentation files (the 'Software'), to deal
8
+ # in the Software without restriction, including without limitation the rights
9
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ # copies of the Software, and to permit persons to whom the Software is
11
+ # furnished to do so, subject to the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be included in all
14
+ # copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
19
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ # SOFTWARE.
23
+
24
+ require 'minitest/autorun'
25
+ require_relative '../lib/factbase'
26
+
27
+ # Factbase main module test.
28
+ # Author:: Yegor Bugayenko (yegor256@gmail.com)
29
+ # Copyright:: Copyright (c) 2024 Yegor Bugayenko
30
+ # License:: MIT
31
+ class TestFactbase < Minitest::Test
32
+ def test_simple_setting
33
+ fb = Factbase.new
34
+ fb.insert
35
+ fb.insert
36
+ found = 0
37
+ fb.query('(exists id)').each do |f|
38
+ assert(42, f.id.positive?)
39
+ f.foo = 42
40
+ assert_equal(42, f.foo)
41
+ found += 1
42
+ end
43
+ assert_equal(2, found)
44
+ end
45
+
46
+ def test_serialize_and_deserialize
47
+ f1 = Factbase.new
48
+ f2 = Factbase.new
49
+ f1.insert.foo = 42
50
+ Tempfile.open do |f|
51
+ File.write(f.path, f1.export)
52
+ f2.import(File.read(f.path))
53
+ end
54
+ assert_equal(1, f2.query('(eq foo 42)').to_a.count)
55
+ end
56
+ end
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: factbase
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Yegor Bugayenko
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2024-05-10 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Fact base in memory and on disc
14
+ email: yegor256@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files:
18
+ - README.md
19
+ - LICENSE.txt
20
+ files:
21
+ - ".0pdd.yml"
22
+ - ".gitattributes"
23
+ - ".github/workflows/actionlint.yml"
24
+ - ".github/workflows/codecov.yml"
25
+ - ".github/workflows/markdown-lint.yml"
26
+ - ".github/workflows/pdd.yml"
27
+ - ".github/workflows/rake.yml"
28
+ - ".github/workflows/xcop.yml"
29
+ - ".github/workflows/yamllint.yml"
30
+ - ".gitignore"
31
+ - ".pdd"
32
+ - ".rubocop.yml"
33
+ - ".rultor.yml"
34
+ - ".simplecov"
35
+ - ".yamllint.yml"
36
+ - Gemfile
37
+ - LICENSE.txt
38
+ - README.md
39
+ - Rakefile
40
+ - factbase.gemspec
41
+ - lib/factbase.rb
42
+ - lib/factbase/fact.rb
43
+ - lib/factbase/query.rb
44
+ - lib/factbase/syntax.rb
45
+ - lib/factbase/term.rb
46
+ - renovate.json
47
+ - test/factbase/test_fact.rb
48
+ - test/factbase/test_query.rb
49
+ - test/factbase/test_syntax.rb
50
+ - test/factbase/test_term.rb
51
+ - test/test__helper.rb
52
+ - test/test_factbase.rb
53
+ homepage: http://github.com/yegor256/factbase.rb
54
+ licenses:
55
+ - MIT
56
+ metadata:
57
+ rubygems_mfa_required: 'true'
58
+ post_install_message:
59
+ rdoc_options:
60
+ - "--charset=UTF-8"
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '2.3'
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ requirements: []
74
+ rubygems_version: 3.4.10
75
+ signing_key:
76
+ specification_version: 4
77
+ summary: Factbase
78
+ test_files: []