stealth 2.0.0.beta1 → 2.0.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/Gemfile.lock +11 -12
- data/VERSION +1 -1
- data/lib/stealth/base.rb +23 -19
- data/lib/stealth/configuration.rb +6 -0
- data/lib/stealth/controller/replies.rb +5 -1
- data/lib/stealth/generators/builder/Gemfile +1 -1
- data/lib/stealth/logger.rb +1 -1
- data/lib/stealth/services/base_reply_handler.rb +8 -0
- data/spec/configuration_spec.rb +33 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: acde4522ee0154ec5557379bfd1fa928e89771637e4c3dd99880adb624b7c2f7
|
4
|
+
data.tar.gz: f30cc740eb9c40fb90c19cbe35a27cf12ce24209245813d338db25df61ca238a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 63ad339fe8d1473ab1118eef9279cf66f1a895748fe61ca7671d49ca8de635fe27f9e4f200c1ae05523501f62e135eb4147d3609f9550c920311498a7abfa26c
|
7
|
+
data.tar.gz: cbcc9083bb56acc3d30aedbcc6a853fb71cf5a57b0586e81b586c36d1f186c5bc39cf5acf6d03768c86c486c7a6ff987ca5e151248cf43c34b70b21778c285ef
|
data/CHANGELOG.md
CHANGED
@@ -49,6 +49,8 @@
|
|
49
49
|
* [Replies] Added support for sub-state replies. `step_to` can now take a `pos` argument that will force any resulting `send_replies` to be sent starting at the `pos` specified. `pos` can also be negative, for example, `-1` will force `send_replies` to send replies starting at (only) the last reply.
|
50
50
|
* [Replies] Dynamic delays are automatically sent before each reply. This can be disabled by setting `Stealth.config.auto_insert_delays` to `false`. If a delay is already included, the auto-delay is skipped.
|
51
51
|
* [Controllers] `handle_message` now supports `Regexp` keys.
|
52
|
+
* [Configuration] `database.yml` is now parsed with ERB in order to support environment variables. Thanks @malkovro.
|
53
|
+
* [Replies] Speech and SSML replies now use `speech` and `ssml` as keys, respectively, instead of `text`
|
52
54
|
|
53
55
|
## Bug Fixes
|
54
56
|
|
@@ -64,6 +66,7 @@
|
|
64
66
|
* [Sessions] previous_session now respects session_ttl values.
|
65
67
|
* [Catch All] Log output from all catch_all logging now includes the session_id so they can be included in log searches.
|
66
68
|
* [NLP] Strip out values from single element arrays in the case of custom LUIS List entities.
|
69
|
+
* [Config] Attempting to overwrite default config values with `nil` or `false` now correctly sets those config values.
|
67
70
|
|
68
71
|
## Deprecations
|
69
72
|
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
stealth (2.0.0.
|
4
|
+
stealth (2.0.0.beta2)
|
5
5
|
activesupport (~> 6.0)
|
6
6
|
multi_json (~> 1.12)
|
7
7
|
puma (>= 4.2, < 5.0)
|
@@ -12,12 +12,12 @@ PATH
|
|
12
12
|
GEM
|
13
13
|
remote: https://rubygems.org/
|
14
14
|
specs:
|
15
|
-
activesupport (6.0
|
15
|
+
activesupport (6.1.0)
|
16
16
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
17
|
-
i18n (>=
|
18
|
-
minitest (
|
19
|
-
tzinfo (~>
|
20
|
-
zeitwerk (~> 2.
|
17
|
+
i18n (>= 1.6, < 2)
|
18
|
+
minitest (>= 5.1)
|
19
|
+
tzinfo (~> 2.0)
|
20
|
+
zeitwerk (~> 2.3)
|
21
21
|
concurrent-ruby (1.1.7)
|
22
22
|
connection_pool (2.2.3)
|
23
23
|
diff-lcs (1.3)
|
@@ -30,14 +30,14 @@ GEM
|
|
30
30
|
ruby2_keywords (~> 0.0.1)
|
31
31
|
nio4r (2.5.4)
|
32
32
|
oj (3.10.6)
|
33
|
-
puma (4.3.
|
33
|
+
puma (4.3.7)
|
34
34
|
nio4r (~> 2.0)
|
35
35
|
rack (2.2.3)
|
36
36
|
rack-protection (2.1.0)
|
37
37
|
rack
|
38
38
|
rack-test (1.1.0)
|
39
39
|
rack (>= 1.0, < 3)
|
40
|
-
redis (4.2.
|
40
|
+
redis (4.2.5)
|
41
41
|
rspec (3.9.0)
|
42
42
|
rspec-core (~> 3.9.0)
|
43
43
|
rspec-expectations (~> 3.9.0)
|
@@ -64,11 +64,10 @@ GEM
|
|
64
64
|
rack-protection (= 2.1.0)
|
65
65
|
tilt (~> 2.0)
|
66
66
|
thor (1.0.1)
|
67
|
-
thread_safe (0.3.6)
|
68
67
|
tilt (2.0.10)
|
69
|
-
tzinfo (
|
70
|
-
|
71
|
-
zeitwerk (2.4.
|
68
|
+
tzinfo (2.0.3)
|
69
|
+
concurrent-ruby (~> 1.0)
|
70
|
+
zeitwerk (2.4.2)
|
72
71
|
|
73
72
|
PLATFORMS
|
74
73
|
ruby
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0.0.
|
1
|
+
2.0.0.beta2
|
data/lib/stealth/base.rb
CHANGED
@@ -63,17 +63,20 @@ module Stealth
|
|
63
63
|
end
|
64
64
|
|
65
65
|
def self.set_config_defaults(config)
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
66
|
+
defaults = {
|
67
|
+
dynamic_delay_muliplier: 1.0, # values > 1 increase, values < 1 decrease delay
|
68
|
+
session_ttl: 0, # 0 seconds; don't expire sessions
|
69
|
+
lock_autorelease: 30, # 30 seconds
|
70
|
+
transcript_logging: false, # show user replies in the logs
|
71
|
+
hot_reload: Stealth.env.development?, # hot reload bot files on change (dev only)
|
72
|
+
eager_load: Stealth.env.production?, # eager load bot files for performance (prod only)
|
73
|
+
autoload_paths: Stealth.default_autoload_paths, # array of autoload paths used in eager and hot reloading
|
74
|
+
autoload_ignore_paths: [], # paths to exclude from eager and hot reloading
|
75
|
+
nlp_integration: nil, # NLP service to use, defaults to none
|
76
|
+
log_all_nlp_results: false, # log NLP service requests; useful for debugging/improving NLP models
|
77
|
+
auto_insert_delays: true # automatically insert delays/typing indicators between all replies
|
78
|
+
}
|
79
|
+
defaults.each { |option, default| config.set_default(option, default) }
|
77
80
|
end
|
78
81
|
|
79
82
|
# Loads the services.yml configuration unless one has already been loaded
|
@@ -126,8 +129,9 @@ module Stealth
|
|
126
129
|
if ENV['DATABASE_URL'].present?
|
127
130
|
ActiveRecord::Base.establish_connection(ENV['DATABASE_URL'])
|
128
131
|
else
|
132
|
+
database_config = File.read(File.join(Stealth.root, 'config', 'database.yml'))
|
129
133
|
ActiveRecord::Base.establish_connection(
|
130
|
-
YAML
|
134
|
+
YAML.load(ERB.new(database_config).result)[Stealth.env]
|
131
135
|
)
|
132
136
|
end
|
133
137
|
end
|
@@ -141,15 +145,15 @@ module Stealth
|
|
141
145
|
for_each_file_in(directory) { |file| require_relative(file) }
|
142
146
|
end
|
143
147
|
|
144
|
-
|
148
|
+
private
|
145
149
|
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
+
def self.for_each_file_in(directory, &blk)
|
151
|
+
directory = directory.to_s.gsub(%r{(\/|\\)}, File::SEPARATOR)
|
152
|
+
directory = Pathname.new(Dir.pwd).join(directory).to_s
|
153
|
+
directory = File.join(directory, '**', '*.rb') unless directory =~ /(\*\*)/
|
150
154
|
|
151
|
-
|
152
|
-
|
155
|
+
Dir.glob(directory).sort.each(&blk)
|
156
|
+
end
|
153
157
|
|
154
158
|
end
|
155
159
|
|
@@ -257,8 +257,12 @@ module Stealth
|
|
257
257
|
|
258
258
|
def log_reply(reply)
|
259
259
|
message = case reply.reply_type
|
260
|
-
when 'text'
|
260
|
+
when 'text'
|
261
261
|
reply['text']
|
262
|
+
when 'speech'
|
263
|
+
reply['speech']
|
264
|
+
when 'ssml'
|
265
|
+
reply['ssml']
|
262
266
|
when 'delay'
|
263
267
|
'<typing indicator>'
|
264
268
|
else
|
data/lib/stealth/logger.rb
CHANGED
data/spec/configuration_spec.rb
CHANGED
@@ -57,4 +57,37 @@ describe "Stealth::Configuration" do
|
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
+
describe "configuring with default values" do
|
61
|
+
let(:config) {
|
62
|
+
Stealth::Configuration.new(
|
63
|
+
{ 'a' => nil, 'x' => 0, 'y' => false, 'z' => '' }
|
64
|
+
)
|
65
|
+
}
|
66
|
+
|
67
|
+
it 'should replace a nil value' do
|
68
|
+
config.set_default('a', 99)
|
69
|
+
expect(config.a).to eq 99
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'should NOT replace a zero value' do
|
73
|
+
config.set_default('x', 99)
|
74
|
+
expect(config.x).to eq 0
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'should NOT replace a false value' do
|
78
|
+
config.set_default('y', 99)
|
79
|
+
expect(config.y).to be false
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'should NOT replace a blank string value' do
|
83
|
+
config.set_default('z', 99)
|
84
|
+
expect(config.z).to eq ''
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'should replace a not-set key' do
|
88
|
+
config.set_default('zz', 99)
|
89
|
+
expect(config.zz).to eq 99
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
60
93
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stealth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0.
|
4
|
+
version: 2.0.0.beta2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mauricio Gomes
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-09
|
12
|
+
date: 2020-12-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sinatra
|