botbase-module-conversation 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8d005c23c51d8e6f3ba761e6e8881c8d6f71a776
4
+ data.tar.gz: f863b3723552bee5ae56828d59986214074044c6
5
+ SHA512:
6
+ metadata.gz: 74afc40363e091f8a68b067e5f0a72a7aa9ce3918e55fb43a0a51ec7bb022a042248a75a30d1f540d6972b94e961064c7867c72dbe0685e4b7e02da93958072e
7
+ data.tar.gz: dbba3f5836ada48b5cc47dda85bd3c2e5419e2d9d0e88329a8cc739992a0f495670d07f2044b5044c5941e7dbd36277d01c42cce38d14ea42ec09b4c735716ce
checksums.yaml.gz.sig ADDED
Binary file
data.tar.gz.sig ADDED
Binary file
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # file: botbase-module-conversation.rb
4
+
5
+ # A service module used by the BotBase gem
6
+
7
+
8
+ require 'rsc'
9
+ require 'rexle-builder'
10
+
11
+
12
+ class BotBaseModuleConversation
13
+
14
+ def initialize(host: nil, package_src: nil,
15
+ default_package: nil, default_job: nil)
16
+
17
+
18
+ @rsc = RSC.new host, package_src
19
+
20
+ a = run(default_package, default_job)
21
+
22
+ header = a.shift
23
+
24
+ a2 = a.inject([]) do |r, x|
25
+ r << {conversation: {user: x[0], bot: x[-1]}}
26
+ end
27
+
28
+ a3 = RexleBuilder.new({converstions: a2}).to_a
29
+ doc = Rexle.new(a3[3])
30
+ doc.root.attributes['id'] = header.first
31
+
32
+ @phrases = doc.root.xpath('//conversation').map do |e|
33
+ %w(user bot).map {|x| e.text x}
34
+ end
35
+
36
+ end
37
+
38
+ def query(sender='user01', said)
39
+
40
+ found = @phrases.detect {|pattern, _| said =~ /#{pattern}/i }
41
+
42
+ if found then
43
+
44
+ package, job = found.last.split
45
+ h = said.match(/#{found.first}/).named_captures
46
+ r = run(package, job)
47
+ else
48
+ # do or say nothing
49
+ ''
50
+ end
51
+
52
+ end
53
+
54
+ private
55
+
56
+ def run(package, job, args=[])
57
+ @rsc.send(package.to_sym).method(job.to_sym).call(*args)
58
+ end
59
+
60
+ end
metadata ADDED
@@ -0,0 +1,109 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: botbase-module-conversation
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - James Robertson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIDljCCAn6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQDDAlnZW1t
14
+ YXN0ZXIxHjAcBgoJkiaJk/IsZAEZFg5qYW1lc3JvYmVydHNvbjESMBAGCgmSJomT
15
+ 8ixkARkWAmV1MB4XDTE3MDQwOTE5MTIyNloXDTE4MDQwOTE5MTIyNlowSDESMBAG
16
+ A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXNyb2JlcnRzb24x
17
+ EjAQBgoJkiaJk/IsZAEZFgJldTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
18
+ ggEBAMvQn8SWhW0mgCMTQiNCg67ii6XIpA+pIL/U8cflCKa02vSNA6//YyySmk54
19
+ Cld6yqD70cwXRoANC+Ejoc3/EEkm/EW+puohigkUguELrM63tt2b/xAItSCjuJkI
20
+ boQsDeWA3p8kJ0pdZx8LzqXI4DXOmTb7MtNJ7puAGMrJAPj+p+s4xaLdEdACbI3p
21
+ 3/MED6NplF4JzNFOW5nE28I4P8JLRJRMSz7Niz2Zzy+uf6wEvddbtPAQ5qn0bKNs
22
+ zBdcWNYPCcGBKlGh0DtBgvC08X3Z8a13CbxYyDLK6P/8QPb6TBbB9bx5Ra/KQsxu
23
+ D8rQZNLyjW1NRLjYucDCfCHjWiECAwEAAaOBijCBhzAJBgNVHRMEAjAAMAsGA1Ud
24
+ DwQEAwIEsDAdBgNVHQ4EFgQUF9TD7XacqMi/BfG6aEfVS86KVgkwJgYDVR0RBB8w
25
+ HYEbZ2VtbWFzdGVyQGphbWVzcm9iZXJ0c29uLmV1MCYGA1UdEgQfMB2BG2dlbW1h
26
+ c3RlckBqYW1lc3JvYmVydHNvbi5ldTANBgkqhkiG9w0BAQUFAAOCAQEAePphndx2
27
+ +u80h86lt/MSonX9zbr9J6v805UJTWf+EWW39UKN4W/eeg0ZXNCkkyk8oZB2zvef
28
+ mRe+llzRqfjSB3FDfZLKzj5ZOp3C4pe+gJwEhiu9sgpOc3Z7e8f/cEFSXxB0bp41
29
+ E7wC49pGNVab+Y7xgvholbhHCULteEqS9kPRM50dnBY5scwFj63CkT7sC9GBpYj8
30
+ 66fZJWc2rmk7hOi6RAbriJo5rB/qjUojYY76GPtEWe3xbRWOI5faKyi4ZBzzeOws
31
+ aNO/RQYUa1Pqx9RMIGgZIeQPtuaxxfqQ6uiq/S5GWoIKIDOmES69g981bASbOtYs
32
+ geN7Uzk3bTsKxA==
33
+ -----END CERTIFICATE-----
34
+ date: 2017-04-09 00:00:00.000000000 Z
35
+ dependencies:
36
+ - !ruby/object:Gem::Dependency
37
+ name: rsc
38
+ requirement: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: '0.2'
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: 0.2.2
46
+ type: :runtime
47
+ prerelease: false
48
+ version_requirements: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - "~>"
51
+ - !ruby/object:Gem::Version
52
+ version: '0.2'
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: 0.2.2
56
+ - !ruby/object:Gem::Dependency
57
+ name: rexle-builder
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '0.3'
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: 0.3.7
66
+ type: :runtime
67
+ prerelease: false
68
+ version_requirements: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - "~>"
71
+ - !ruby/object:Gem::Version
72
+ version: '0.3'
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: 0.3.7
76
+ description:
77
+ email: james@jamesrobertson.eu
78
+ executables: []
79
+ extensions: []
80
+ extra_rdoc_files: []
81
+ files:
82
+ - lib/botbase-module-conversation.rb
83
+ homepage: https://github.com/jrobertson/botbase-module-conversation
84
+ licenses:
85
+ - MIT
86
+ metadata: {}
87
+ post_install_message:
88
+ rdoc_options: []
89
+ require_paths:
90
+ - lib
91
+ required_ruby_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ requirements: []
102
+ rubyforge_project:
103
+ rubygems_version: 2.6.8
104
+ signing_key:
105
+ specification_version: 4
106
+ summary: A botbase module intended for holding a conversation between the user and
107
+ the bot. Relies upon a dRB service for responding to the user's statements. Used
108
+ by the botbase gem.
109
+ test_files: []
metadata.gz.sig ADDED
Binary file