stealth 2.0.0.beta1 → 2.0.0.beta2

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: 0c85085bed89600d8dfcf7741800c99c98333155316e59fb18bbc53e0fc07280
4
- data.tar.gz: c34523527fba0de8f35bc7e7de465bc3209ca735fae3acaf3e9fc4f089cb6d31
3
+ metadata.gz: acde4522ee0154ec5557379bfd1fa928e89771637e4c3dd99880adb624b7c2f7
4
+ data.tar.gz: f30cc740eb9c40fb90c19cbe35a27cf12ce24209245813d338db25df61ca238a
5
5
  SHA512:
6
- metadata.gz: cf345a282a3256914fd2c15b8139e5d1fa7b96f6f53591c675b38b6f5d5bf8fc1fd95a9db2d199abe8a4aa691e8641e27824069327ad8467b81269e7404d1cee
7
- data.tar.gz: 78bdf64b387ee7294cf51251553479aca0622d687fab25c0b14481775812b7ce59665384f3fd3af7f24eddc12f1f588aaec4ce88af5453a9658547a06f308a3a
6
+ metadata.gz: 63ad339fe8d1473ab1118eef9279cf66f1a895748fe61ca7671d49ca8de635fe27f9e4f200c1ae05523501f62e135eb4147d3609f9550c920311498a7abfa26c
7
+ data.tar.gz: cbcc9083bb56acc3d30aedbcc6a853fb71cf5a57b0586e81b586c36d1f186c5bc39cf5acf6d03768c86c486c7a6ff987ca5e151248cf43c34b70b21778c285ef
@@ -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
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- stealth (2.0.0.beta1)
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.3.3)
15
+ activesupport (6.1.0)
16
16
  concurrent-ruby (~> 1.0, >= 1.0.2)
17
- i18n (>= 0.7, < 2)
18
- minitest (~> 5.1)
19
- tzinfo (~> 1.1)
20
- zeitwerk (~> 2.2, >= 2.2.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.6)
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.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 (1.2.7)
70
- thread_safe (~> 0.1)
71
- zeitwerk (2.4.0)
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.beta1
1
+ 2.0.0.beta2
@@ -63,17 +63,20 @@ module Stealth
63
63
  end
64
64
 
65
65
  def self.set_config_defaults(config)
66
- config.dynamic_delay_muliplier ||= 1.0
67
- config.session_ttl ||= 0
68
- config.lock_autorelease ||= 30
69
- config.transcript_logging ||= false
70
- config.hot_reload ||= Stealth.env.development?
71
- config.eager_load ||= Stealth.env.production?
72
- config.autoload_paths ||= Stealth.default_autoload_paths
73
- config.autoload_ignore_paths ||= []
74
- config.nlp_integration ||= nil
75
- config.log_all_nlp_results ||= false
76
- config.auto_insert_delays ||= true
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::load_file("config/database.yml")[Stealth.env]
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
- private
148
+ private
145
149
 
146
- def self.for_each_file_in(directory, &blk)
147
- directory = directory.to_s.gsub(%r{(\/|\\)}, File::SEPARATOR)
148
- directory = Pathname.new(Dir.pwd).join(directory).to_s
149
- directory = File.join(directory, '**', '*.rb') unless directory =~ /(\*\*)/
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
- Dir.glob(directory).sort.each(&blk)
152
- end
155
+ Dir.glob(directory).sort.each(&blk)
156
+ end
153
157
 
154
158
  end
155
159
 
@@ -22,6 +22,12 @@ module Stealth
22
22
  end
23
23
  end
24
24
 
25
+ def set_default(key, default_value)
26
+ if self[key.to_s] == nil
27
+ self[key.to_s] = store(default_value)
28
+ end
29
+ end
30
+
25
31
  private
26
32
 
27
33
  def store(value)
@@ -257,8 +257,12 @@ module Stealth
257
257
 
258
258
  def log_reply(reply)
259
259
  message = case reply.reply_type
260
- when 'text', 'speech'
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
@@ -15,5 +15,5 @@ gem 'sqlite3'
15
15
 
16
16
  group :development do
17
17
  gem 'foreman'
18
- gem 'listen', '~> 3.1'
18
+ gem 'listen', '~> 3.3'
19
19
  end
@@ -45,7 +45,7 @@ module Stealth
45
45
  :blue
46
46
  when :smooch
47
47
  :magenta
48
- when :alexa, :unrecognized_message
48
+ when :alexa, :voice, :unrecognized_message
49
49
  :light_cyan
50
50
  when :nlp
51
51
  :cyan
@@ -60,6 +60,14 @@ module Stealth
60
60
  reply_format_not_supported(format: 'delay')
61
61
  end
62
62
 
63
+ def speech
64
+ reply_format_not_supported(format: 'speech')
65
+ end
66
+
67
+ def ssml
68
+ reply_format_not_supported(format: 'ssml')
69
+ end
70
+
63
71
  end
64
72
  end
65
73
  end
@@ -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.beta1
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-21 00:00:00.000000000 Z
12
+ date: 2020-12-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sinatra