wongi-engine 0.3.7 → 0.3.8

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: bf30142950fccfa0c3ecd20d55e5ac211c74c1fde464507725f262da6734f8b7
4
- data.tar.gz: efd0a8acae7aef2510854d240e5fbe491ffcbf73986cd4e6d201cf662e912c0a
3
+ metadata.gz: 8d4c949466ca4e0cdc187b571ebc8d406ee36c06b135216355b791ecb20c78ab
4
+ data.tar.gz: 44b91d4d18f9fb1c7f87b8a837a67d8489e255803f68e25be87b636d620de113
5
5
  SHA512:
6
- metadata.gz: ba4e0818dff5b8d61b693e8a2974c0e2fa531736459e95aa788b7a3b79c56c0be5c1a3d5e9edd36cd0c71ce55a0bce31b41f1d39e2515c057753df873f288318
7
- data.tar.gz: b0e6d77fa743e6d74340bc75478ce0178a72ce7e99df7cf5cebe0d60438acd779627fb1f68652ecdd3904054784c385e8684245e54dc66de6485d7e66e1a7a7a
6
+ metadata.gz: 4a1534278af39a9a0449c812483706fe552ec72b63ef38d59eed3899e38c88c8988b5e6eed860fb43a24d0913b97819978034426fc9ac3e2f1b623fee1ae0c53
7
+ data.tar.gz: 9a7457a55a61cdd825b929d9aac2fd3a8f4b3b56609492c2dc124ea96dffd1348cdb23e957a404fec320eab12aeebbe3746c81d1f52e221cf6912761c458db8d
@@ -0,0 +1,24 @@
1
+ name: Test
2
+
3
+ on:
4
+ - push
5
+ - pull_request
6
+
7
+ jobs:
8
+ test:
9
+
10
+ runs-on: ubuntu-latest
11
+
12
+ strategy:
13
+ matrix:
14
+ ruby-version: ["3.1", "3.0", "2.7", "2.6", "jruby-head"]
15
+
16
+ steps:
17
+ - uses: actions/checkout@v2
18
+ - name: Set up Ruby ${{ matrix.ruby-version }}
19
+ uses: ruby/setup-ruby@v1
20
+ with:
21
+ ruby-version: ${{ matrix.ruby-version }}
22
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
23
+ - name: Run tests
24
+ run: bundle exec rake
@@ -8,7 +8,7 @@ module Wongi::Engine
8
8
  @map = options[:map]
9
9
  @function = options[:function]
10
10
  @assign = options[:assign]
11
- @map ||= -> { _1.send(member) }
11
+ @map ||= ->(wme) { wme.send(member) }
12
12
  super
13
13
  end
14
14
 
@@ -101,7 +101,7 @@ module Wongi::Engine::DSL
101
101
 
102
102
  clause :count
103
103
  body { |s, p, o, opts|
104
- aggregate s, p, o, map: ->(_) { 1 }, function: -> { _1.inject(&:+) }, assign: opts[:assign]
104
+ aggregate s, p, o, map: ->(_) { 1 }, function: ->(collection) { collection.inject(&:+) }, assign: opts[:assign]
105
105
  }
106
106
 
107
107
  clause :assert, :dynamic
@@ -14,16 +14,12 @@ module Wongi::Engine
14
14
  return
15
15
  end
16
16
 
17
- @io = io
17
+ io.puts "digraph {"
18
18
 
19
- @io.puts "digraph {"
19
+ dump_alphas(io) unless opts[:alpha] == false
20
+ dump_betas(io, opts)
20
21
 
21
- dump_alphas(opts) unless opts[:alpha] == false
22
- dump_betas(opts)
23
-
24
- @io.puts "}"
25
- ensure
26
- @io = nil
22
+ io.puts "}"
27
23
  end
28
24
 
29
25
  private
@@ -32,34 +28,34 @@ module Wongi::Engine
32
28
  h.to_s.gsub(/-/, '_')
33
29
  end
34
30
 
35
- def dump_alphas(_opts)
36
- @io.puts "subgraph cluster_alphas {"
31
+ def dump_alphas(io)
32
+ io.puts "subgraph cluster_alphas {"
37
33
  @rete.alphas.reject { |alpha| alpha.betas.empty? }.each do |alpha|
38
- @io.puts "node#{print_hash alpha.object_id} [shape=box label=\"#{alpha.template.to_s.gsub(/"/, '"')}\"];"
34
+ io.puts "node#{print_hash alpha.object_id} [shape=box label=\"#{alpha.template.to_s.gsub(/"/, '"')}\"];"
39
35
  end
40
- @io.puts "};"
36
+ io.puts "};"
41
37
  end
42
38
 
43
- def dump_betas(opts)
44
- dump_beta @rete.beta_top, opts
39
+ def dump_betas(io, opts)
40
+ dump_beta(io, @rete.beta_top, opts)
45
41
  end
46
42
 
47
- def dump_beta(beta, opts)
43
+ def dump_beta(io, beta, opts)
48
44
  return if @seen_betas.include? beta
49
45
 
50
46
  @seen_betas << beta
51
- @io.puts "node#{print_hash beta.object_id} [label=\"#{beta.class.name.split('::').last}\"];"
47
+ io.puts "node#{print_hash beta.object_id} [label=\"#{beta.class.name.split('::').last}\"];"
52
48
  if beta.is_a? NccNode
53
- @io.puts "node#{print_hash beta.partner.object_id} -> node#{print_hash beta.object_id};"
54
- @io.puts "{ rank=same; node#{print_hash beta.partner.object_id} node#{print_hash beta.object_id} }"
49
+ io.puts "node#{print_hash beta.partner.object_id} -> node#{print_hash beta.object_id};"
50
+ io.puts "{ rank=same; node#{print_hash beta.partner.object_id} node#{print_hash beta.object_id} }"
55
51
  end
56
52
  if beta.respond_to?(:alpha) && opts[:alpha] != false
57
53
  alpha = beta.alpha
58
- @io.puts "node#{print_hash alpha.object_id} -> node#{print_hash beta.object_id};" if alpha
54
+ io.puts "node#{print_hash alpha.object_id} -> node#{print_hash beta.object_id};" if alpha
59
55
  end
60
56
  beta.children.each do |child|
61
- @io.puts "node#{print_hash beta.object_id} -> node#{print_hash child.object_id};"
62
- dump_beta child, opts
57
+ io.puts "node#{print_hash beta.object_id} -> node#{print_hash child.object_id};"
58
+ dump_beta(io, child, opts)
63
59
  end
64
60
  end
65
61
  end
@@ -1,5 +1,5 @@
1
1
  module Wongi
2
2
  module Engine
3
- VERSION = "0.3.7".freeze
3
+ VERSION = "0.3.8".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wongi-engine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.7
4
+ version: 0.3.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Valeri Sokolov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-03 00:00:00.000000000 Z
11
+ date: 2022-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry
@@ -73,6 +73,7 @@ executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
+ - ".github/workflows/test.yml"
76
77
  - ".gitignore"
77
78
  - ".hgtags"
78
79
  - ".rubocop.yml"