prolog_mqi 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1dec293caa1b54a261cf73751e98851919ca9a7333e009f66ea773156b0881f2
4
- data.tar.gz: 07c7cc80fafeb347f8a0556cd28df349cf042e2ddc670cea88fbbfe7d6e2d1b2
3
+ metadata.gz: 99e2b28148e4e4474d3d766819b5108ac91524473c4f97174ff9672211154c5a
4
+ data.tar.gz: 9f942857b402ae8fd1e8a752b71257d8d3d08b3385cbe5684d5bdbe7773ff7ed
5
5
  SHA512:
6
- metadata.gz: ebd83c3a190c45558926a57d4c98318294e017ad5ae34f2f46ab4b132edb72996bfb9896f3d10cfe0fc16534d0d681aeb06138d39b36d49a3e35731b1c79e0be
7
- data.tar.gz: 98decf4439ef0aa4f92063dc8c0274de84f845b8657396ab46926e7058cff7c9af1ea1e622abfb24ef5886fa43b5b3174b3560408915369fc8df44625d344ec0
6
+ metadata.gz: 405e5b1d96b387a0cb9d51a92d33a171131b6642d7d420b937f4a9b626a2a8fa11e7f85419df69f719001ad09331907247032cba0748cc2aca0490a4c3e96e5d
7
+ data.tar.gz: 698bbfe5957bd4bdcba32055bd1f3acd5cc7dd586efd12f8663fc47c7704017a792ebad73b7ef2a166d6d63a39914f3de5380f2a5de7fff0d24b84cd889ec1ad
data/.rubocop.yml CHANGED
File without changes
data/CODE_OF_CONDUCT.md CHANGED
File without changes
data/Gemfile CHANGED
File without changes
data/LICENSE CHANGED
File without changes
data/README.md CHANGED
File without changes
data/Rakefile CHANGED
File without changes
File without changes
File without changes
@@ -51,6 +51,31 @@ module PrologMQI
51
51
  read
52
52
  end
53
53
 
54
+ def query_async(value, find_all: true)
55
+ timeout_str = @timeout.nil? ? '_' : @timeout.to_s
56
+ find_all_str = find_all ? 'true' : 'false'
57
+ write("run_async(#{value}, #{timeout_str}, #{find_all_str})")
58
+ read
59
+ end
60
+
61
+ def cancel_query_async
62
+ write('cancel_async')
63
+ read
64
+ end
65
+
66
+ def query_async_result
67
+ timeout_str = @timeout.nil? ? '-1' : @timeout.to_s
68
+ write("async_result(#{timeout_str})")
69
+ read
70
+ end
71
+
72
+ def halt_server
73
+ write('quit')
74
+ read
75
+ end
76
+
77
+ private
78
+
54
79
  def read
55
80
  bytesize = @socket.gets.chomp(".\n").to_i
56
81
  result = @socket.read(bytesize)
@@ -67,6 +92,8 @@ module PrologMQI
67
92
  end
68
93
 
69
94
  def stop
95
+ halt_server
96
+ ensure
70
97
  @socket.close
71
98
  @stdin.close
72
99
  @stdout.close
@@ -29,6 +29,8 @@ module PrologMQI
29
29
  end
30
30
 
31
31
  def args
32
+ return nil unless @term.is_a?(Hash) && @term.key?('args')
33
+
32
34
  @term['args'].map do |arg|
33
35
  next nil if arg == 'nil'
34
36
  next arg.to_i if arg.is_a?(String) && arg.to_i.to_s == arg
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PrologMQI
4
- VERSION = '0.1.3'
4
+ VERSION = '0.2.0'
5
5
  end
data/lib/prolog_mqi.rb CHANGED
File without changes
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prolog_mqi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Delton Ding
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-07-02 00:00:00.000000000 Z
11
+ date: 2023-12-12 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A PrologMQI implementation in Ruby.
14
14
  email:
@@ -21,7 +21,6 @@ files:
21
21
  - CODE_OF_CONDUCT.md
22
22
  - Gemfile
23
23
  - LICENSE
24
- - LICENSE.txt
25
24
  - README.md
26
25
  - Rakefile
27
26
  - lib/prolog_mqi.rb
@@ -30,7 +29,6 @@ files:
30
29
  - lib/prolog_mqi/prolog_mqi.rb
31
30
  - lib/prolog_mqi/term.rb
32
31
  - lib/prolog_mqi/version.rb
33
- - prolog_mqi.gemspec
34
32
  homepage: https://github.com/yet-another-ai/prologmqi.rb
35
33
  licenses:
36
34
  - MIT
@@ -38,7 +36,7 @@ metadata:
38
36
  homepage_uri: https://github.com/yet-another-ai/prologmqi.rb
39
37
  source_code_uri: https://github.com/yet-another-ai/prologmqi.rb
40
38
  rubygems_mfa_required: 'true'
41
- post_install_message:
39
+ post_install_message:
42
40
  rdoc_options: []
43
41
  require_paths:
44
42
  - lib
@@ -54,7 +52,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
54
52
  version: '0'
55
53
  requirements: []
56
54
  rubygems_version: 3.4.10
57
- signing_key:
55
+ signing_key:
58
56
  specification_version: 4
59
57
  summary: Yet Another Prolog Interface for Ruby.
60
58
  test_files: []
data/LICENSE.txt DELETED
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2023 TODO: Write your name
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
13
- all 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 NONINFRINGEMENT. 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
21
- THE SOFTWARE.
data/prolog_mqi.gemspec DELETED
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative 'lib/prolog_mqi/version'
4
-
5
- Gem::Specification.new do |spec|
6
- spec.name = 'prolog_mqi'
7
- spec.version = PrologMQI::VERSION
8
- spec.authors = ['Delton Ding']
9
- spec.email = ['shenghao.ding@yetanother.ai']
10
-
11
- spec.summary = 'Yet Another Prolog Interface for Ruby.'
12
- spec.description = 'A PrologMQI implementation in Ruby.'
13
- spec.homepage = 'https://github.com/yet-another-ai/prologmqi.rb'
14
- spec.license = 'MIT'
15
- spec.required_ruby_version = '>= 3.0.0'
16
-
17
- spec.metadata['homepage_uri'] = spec.homepage
18
- spec.metadata['source_code_uri'] = 'https://github.com/yet-another-ai/prologmqi.rb'
19
-
20
- # Specify which files should be added to the gem when it is released.
21
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
- spec.files = Dir.chdir(__dir__) do
23
- `git ls-files -z`.split("\x0").reject do |f|
24
- (File.expand_path(f) == __FILE__) || f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor])
25
- end
26
- end
27
- spec.bindir = 'exe'
28
- spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
29
- spec.require_paths = ['lib']
30
-
31
- # Uncomment to register a new dependency of your gem
32
- # spec.add_dependency "example-gem", "~> 1.0"
33
-
34
- # For more information and examples about making a new gem, check out our
35
- # guide at: https://bundler.io/guides/creating_gem.html
36
- spec.metadata['rubygems_mfa_required'] = 'true'
37
- end