factbase 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/pdd.yml +20 -1
- data/.github/workflows/rake.yml +19 -0
- data/.github/workflows/xcop.yml +20 -1
- data/factbase.gemspec +3 -1
- data/lib/factbase/fact.rb +4 -3
- data/lib/factbase.rb +25 -0
- data/test/factbase/test_fact.rb +0 -1
- data/test/factbase/test_query.rb +0 -1
- data/test/factbase/test_spy.rb +0 -1
- data/test/factbase/test_syntax.rb +0 -1
- data/test/factbase/test_term.rb +0 -1
- data/test/factbase/test_white_list.rb +0 -1
- data/test/test__helper.rb +0 -1
- data/test/test_factbase.rb +12 -1
- metadata +31 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 453a090310ef10ace85c3ee099b85bd8744d24428923f1e896626b996d3124ca
|
4
|
+
data.tar.gz: 0236a9f6bb4b4dacca29bd1d61da395a8dadb084b81e915b7694a763ecf0985b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00312f424b58cfda7eee00a7fba6792da9a5b439eab34e29745cdd481913df87afc016944387e95356ece05feddbc444d90ddb52bdf2a20d3bc4ac38e7224a79
|
7
|
+
data.tar.gz: 224a5b63c85cf5fc604da26f8f4205a35fe6b3ace5f8fb959b6a2a3fd71f08dc79a2804215dab823c1143e02a8ddd06de0df3154912e116de04da97233ff8795
|
data/.github/workflows/pdd.yml
CHANGED
@@ -1,6 +1,25 @@
|
|
1
|
+
# Copyright (c) 2024 Yegor Bugayenko
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the 'Software'), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in all
|
11
|
+
# copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
# SOFTWARE.
|
1
20
|
---
|
2
21
|
name: pdd
|
3
|
-
on:
|
22
|
+
'on':
|
4
23
|
push:
|
5
24
|
branches:
|
6
25
|
- master
|
data/.github/workflows/rake.yml
CHANGED
@@ -1,3 +1,22 @@
|
|
1
|
+
# Copyright (c) 2024 Yegor Bugayenko
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the 'Software'), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in all
|
11
|
+
# copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
# SOFTWARE.
|
1
20
|
---
|
2
21
|
name: rake
|
3
22
|
on:
|
data/.github/workflows/xcop.yml
CHANGED
@@ -1,6 +1,25 @@
|
|
1
|
+
# Copyright (c) 2024 Yegor Bugayenko
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the 'Software'), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in all
|
11
|
+
# copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
# SOFTWARE.
|
1
20
|
---
|
2
21
|
name: xcop
|
3
|
-
on:
|
22
|
+
'on':
|
4
23
|
push:
|
5
24
|
pull_request:
|
6
25
|
jobs:
|
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.
|
29
|
+
s.version = '0.0.7'
|
30
30
|
s.license = 'MIT'
|
31
31
|
s.summary = 'Factbase'
|
32
32
|
s.description = 'Fact base in memory and on disc'
|
@@ -37,5 +37,7 @@ Gem::Specification.new do |s|
|
|
37
37
|
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
38
38
|
s.rdoc_options = ['--charset=UTF-8']
|
39
39
|
s.extra_rdoc_files = ['README.md', 'LICENSE.txt']
|
40
|
+
s.add_runtime_dependency 'json', '~> 2.7'
|
41
|
+
s.add_runtime_dependency 'nokogiri', '~> 1.10'
|
40
42
|
s.metadata['rubygems_mfa_required'] = 'true'
|
41
43
|
end
|
data/lib/factbase/fact.rb
CHANGED
@@ -35,10 +35,11 @@ class Factbase::Fact
|
|
35
35
|
def method_missing(*args)
|
36
36
|
k = args[0].to_s
|
37
37
|
if k.end_with?('=')
|
38
|
-
|
38
|
+
kk = k[0..-2]
|
39
|
+
raise "Invalid prop name '#{kk}'" unless kk.match?(/^[a-z][a-zA-Z0-9]+$/)
|
39
40
|
@mutex.synchronize do
|
40
|
-
@map[
|
41
|
-
@map[
|
41
|
+
@map[kk] = [] if @map[kk].nil?
|
42
|
+
@map[kk] << args[1]
|
42
43
|
end
|
43
44
|
nil
|
44
45
|
elsif k == '[]'
|
data/lib/factbase.rb
CHANGED
@@ -20,6 +20,9 @@
|
|
20
20
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
21
|
# SOFTWARE.
|
22
22
|
|
23
|
+
require 'json'
|
24
|
+
require 'nokogiri'
|
25
|
+
|
23
26
|
# Factbase.
|
24
27
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
25
28
|
# Copyright:: Copyright (c) 2024 Yegor Bugayenko
|
@@ -82,7 +85,29 @@ class Factbase
|
|
82
85
|
# rubocop:enable Security/MarshalLoad
|
83
86
|
end
|
84
87
|
|
88
|
+
# Convert the entire factbase into JSON.
|
89
|
+
# @return [String] The factbase in JSON format
|
85
90
|
def to_json(_ = nil)
|
86
91
|
@maps.to_json
|
87
92
|
end
|
93
|
+
|
94
|
+
# Convert the entire factbase into XML.
|
95
|
+
# @return [String] The factbase in XML format
|
96
|
+
def to_xml
|
97
|
+
Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
|
98
|
+
xml.fb do
|
99
|
+
@maps.each do |m|
|
100
|
+
xml.f do
|
101
|
+
m.each do |k, vv|
|
102
|
+
xml.send(:"#{k}") do
|
103
|
+
vv.each do |v|
|
104
|
+
xml.send(:v, v)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end.to_xml
|
112
|
+
end
|
88
113
|
end
|
data/test/factbase/test_fact.rb
CHANGED
data/test/factbase/test_query.rb
CHANGED
data/test/factbase/test_spy.rb
CHANGED
data/test/factbase/test_term.rb
CHANGED
data/test/test__helper.rb
CHANGED
data/test/test_factbase.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
4
3
|
# Copyright (c) 2024 Yegor Bugayenko
|
5
4
|
#
|
6
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
@@ -23,6 +22,7 @@
|
|
23
22
|
|
24
23
|
require 'minitest/autorun'
|
25
24
|
require 'json'
|
25
|
+
require 'nokogiri'
|
26
26
|
require_relative '../lib/factbase'
|
27
27
|
|
28
28
|
# Factbase main module test.
|
@@ -64,4 +64,15 @@ class TestFactbase < Minitest::Test
|
|
64
64
|
json = JSON.parse(fb.to_json)
|
65
65
|
assert(42, json[0]['foo'][1])
|
66
66
|
end
|
67
|
+
|
68
|
+
def test_to_xml
|
69
|
+
fb = Factbase.new
|
70
|
+
f = fb.insert
|
71
|
+
f.foo = 42
|
72
|
+
f.foo = 256
|
73
|
+
fb.insert
|
74
|
+
xml = Nokogiri::XML.parse(fb.to_xml)
|
75
|
+
assert(!xml.xpath('/fb[count(f) = 2]').empty?)
|
76
|
+
assert(!xml.xpath('/fb/f/foo[v="42"]').empty?)
|
77
|
+
end
|
67
78
|
end
|
metadata
CHANGED
@@ -1,15 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: factbase
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
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-
|
12
|
-
dependencies:
|
11
|
+
date: 2024-05-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: json
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.7'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: nokogiri
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.10'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.10'
|
13
41
|
description: Fact base in memory and on disc
|
14
42
|
email: yegor256@gmail.com
|
15
43
|
executables: []
|