factbase 0.0.15 → 0.0.16

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: 8ea11eaa2c72f162214fffedf64db4674ef27aef158f613ecea3304e35d528c3
4
- data.tar.gz: b2c11cab690d59314a866a668b18913df9856ff8dcd8e0fd1ff906dc6601bd41
3
+ metadata.gz: a8038d22144d137a5f6681fc6d87305b6266613317109c8303477a0ef5deffa8
4
+ data.tar.gz: d22085de542559b452f7a368418a821e83643658ff940fdfecbe698ffe16aa65
5
5
  SHA512:
6
- metadata.gz: d8a5a44265b0f9c6e32e669802831fec089e04049e2871167bbda0361ea99ad3b464f16cda94c5fd7b32b2cc539379b5e33acfc8e26c2488cfe605c61d3fe537
7
- data.tar.gz: 010122d90a6564bc5d7041ed1d3107449062810e494504bc14bb6c64df71f0e7bbf077fc0300301e31d2078a3efc34ce8b5c0b722eefeb288befd465b139eb27
6
+ metadata.gz: aa35c8dd802f4622842cc2c486cc26f3032dfc3ff525f6d97d8185ec6297b8fb5ad45a7dcf010bd7ce5b12b6aae2eb5721f1352f16666513818c2b30470ade17
7
+ data.tar.gz: f4cfcaa303d1c74485760b56b93112003230f955f0b589921beb43d3a8ff83e7b9cfab07d6e4d42cd514b3d1100393611a40f37c287357b99408696e6caa7b6b
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.15'
29
+ s.version = '0.0.16'
30
30
  s.license = 'MIT'
31
31
  s.summary = 'Factbase'
32
32
  s.description = 'Fact base in memory and on disc'
@@ -99,7 +99,7 @@ class Factbase::Syntax
99
99
  list << :open
100
100
  when ')'
101
101
  list << :close
102
- when ' '
102
+ when ' ', "\n", "\t", "\r"
103
103
  # ignore it
104
104
  else
105
105
  acc += c
data/lib/factbase.rb CHANGED
@@ -35,6 +35,12 @@ class Factbase
35
35
  @mutex = Mutex.new
36
36
  end
37
37
 
38
+ # Is it empty?
39
+ # @return [Boolean] TRUE if there are no facts inside
40
+ def empty?
41
+ @maps.empty?
42
+ end
43
+
38
44
  # Size.
39
45
  # @return [Integer] How many facts are in there
40
46
  def size
@@ -50,12 +50,12 @@ class TestQuery < Minitest::Test
50
50
  '(eq num 444)' => 0,
51
51
  '(eq time 0)' => 0,
52
52
  '(gt num 60)' => 1,
53
- '(and (lt pi 100) (gt num 1000))' => 0,
53
+ "(and (lt pi 100) \n\n (gt num 1000))" => 0,
54
54
  '(exists pi)' => 1,
55
55
  '(not (exists hello))' => 3,
56
56
  '(absent time)' => 2,
57
57
  '(and (absent time) (exists pi))' => 1,
58
- '(and (exists time) (not (exists pi)))' => 1,
58
+ "(and (exists time) (not (\t\texists pi)))" => 1,
59
59
  "(or (eq num 66) (lt time #{(Time.now - 200).utc.iso8601}))" => 1
60
60
  }.each do |q, r|
61
61
  assert_equal(r, Factbase::Query.new(maps, Mutex.new, q).each.to_a.size, q)
@@ -44,8 +44,8 @@ class TestSyntax < Minitest::Test
44
44
  '()',
45
45
  '(foo)',
46
46
  '(foo (bar) (zz 77) )',
47
- "(eq foo 'Hello, world!')",
48
- "(or ( a 4) (b 5) () (and () (c 5) (r 7 8s 8is 'Foo')))"
47
+ "(eq foo \n\n 'Hello, world!'\n)\n",
48
+ "(or ( a 4) (b 5) () (and () (c 5) \t\t(r 7 8s 8is 'Foo')))"
49
49
  ].each do |q|
50
50
  Factbase::Syntax.new(q).to_term
51
51
  end
@@ -57,6 +57,13 @@ class TestFactbase < Minitest::Test
57
57
  assert_equal(1, f2.query('(eq foo 42)').each.to_a.count)
58
58
  end
59
59
 
60
+ def test_empty_or_not
61
+ fb = Factbase.new
62
+ assert(fb.empty?)
63
+ fb.insert
64
+ assert(!fb.empty?)
65
+ end
66
+
60
67
  def test_to_json
61
68
  fb = Factbase.new
62
69
  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.0.15
4
+ version: 0.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko