librevox 1.1.0 → 1.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 741f63e510f82a40cfbb818d889405e46327bda536843c891767d21fafc7032d
4
- data.tar.gz: be1b2346b673120f343d2cfea7c6eb71fcc085a3e1bdcdcaa86989dd97705b8a
3
+ metadata.gz: 95b27fda8c58322356ee1de25475e8a2d7a5f97de44bbed9b96e9a2bbf6b343f
4
+ data.tar.gz: ccc204e2ce431158e6522f00af68dc05ca1c830be38cfe72f062d351e70472a3
5
5
  SHA512:
6
- metadata.gz: 77ed21f1951ea0061315850c0222ac422bedd25baa1e18b3e73bc983d9be1cfd94c6d3f9628ddc2e1461405d6623c248bd72e2a9a2bb1f898df035b0303962ed
7
- data.tar.gz: 53fde0404e9b427820018c805d15f1bbb65fe9108384db699702130fb6c0aecefd89a3865e06193b75a5bc04fb06e7d47957e3e179f80f0f16a1edd414e479be
6
+ metadata.gz: bc30c9591747be4b1b86aa7c6107b8f367ef972c221271959a5c81f5b6bdead29cf6ebdc0d0162b00f899a41f0bbf6fcc1629b2000799179ca91495b54c3c796
7
+ data.tar.gz: 63e37d5c3792564c720340acd8c8c8f622f1e77a539d537cc5384f87753208efeb32ac6a8914fa4025113455012ae3f1f36517973bb4e3136cd64d79a21c9894
@@ -150,9 +150,7 @@ module Librevox
150
150
  args = [min, max, tries, timeout, terminators, file, invalid_file,
151
151
  variable, regexp].join " "
152
152
 
153
- params = {variable: variable}
154
-
155
- application "play_and_get_digits", args, params
153
+ application "play_and_get_digits", args, variable: variable
156
154
  end
157
155
 
158
156
  # Plays a sound file on the current channel.
@@ -182,9 +180,7 @@ module Librevox
182
180
  arg_string = "%s %s %s %s %s %s" % [min, max, file, variable, timeout,
183
181
  terminators]
184
182
 
185
- params = {variable: variable}
186
-
187
- application "read", arg_string, params
183
+ application "read", arg_string, variable: variable
188
184
  end
189
185
 
190
186
  # Records a message, with an optional limit on the maximum duration of the
@@ -37,11 +37,17 @@ module Librevox
37
37
  end
38
38
  end
39
39
 
40
- def application(uuid, app, args = nil)
41
- parts = ["sendmsg #{uuid}", "call-command: execute", "execute-app-name: #{app}"]
42
- parts << "execute-app-arg: #{args}" if args && !args.empty?
43
- parts << "event-lock: true"
44
- send_message parts.join("\n")
40
+ def application(uuid, app, args = nil, **params)
41
+ headers = params
42
+ .merge(
43
+ event_lock: true,
44
+ call_command: "execute",
45
+ execute_app_name: app,
46
+ execute_app_arg: args,
47
+ )
48
+ .map { |key, value| "#{key.to_s.tr('_', '-')}: #{value}" }
49
+
50
+ send_message "sendmsg #{uuid}\n#{headers.join("\n")}"
45
51
  end
46
52
 
47
53
  def close
@@ -45,7 +45,6 @@ module Librevox
45
45
  end
46
46
 
47
47
  connection_completed
48
- sleep # keep session alive for event hooks and child tasks
49
48
  end
50
49
 
51
50
  def connection_completed
@@ -13,16 +13,24 @@ module Librevox
13
13
  barrier.async { server.run }
14
14
  end
15
15
 
16
- def application(app, args = nil, params = {})
17
- parts = ["sendmsg", "call-command: execute", "execute-app-name: #{app}"]
18
- parts << "execute-app-arg: #{args}" if args && !args.empty?
19
- parts << "event-lock: true"
16
+ def application(app, args = nil, **params)
17
+ variable_name = params.delete(:variable)
18
+
19
+ headers = params
20
+ .merge(
21
+ event_lock: true,
22
+ call_command: "execute",
23
+ execute_app_name: app,
24
+ execute_app_arg: args,
25
+ )
26
+ .map { |key, value| "#{key.to_s.tr('_', '-')}: #{value}" }
27
+
28
+ send_message "sendmsg\n#{headers.join("\n")}"
20
29
 
21
- send_message parts.join("\n")
22
30
  response = @app_complete_queue.dequeue
23
31
  @session = response.content
24
32
 
25
- params[:variable] ? variable(params[:variable]) : nil
33
+ variable(variable_name) if variable_name
26
34
  end
27
35
 
28
36
  attr_accessor :session
@@ -42,7 +50,6 @@ module Librevox
42
50
  send_message "myevents"
43
51
  send_message "linger"
44
52
  session_initiated
45
- sleep # keep session alive for event hooks and child tasks
46
53
  end
47
54
 
48
55
  def handle_response
@@ -27,7 +27,10 @@ module Librevox
27
27
  end
28
28
 
29
29
  def run
30
- @endpoint.accept(&method(:accept))
30
+ Async do |task|
31
+ @endpoint.accept(&method(:accept))
32
+ task.children.each(&:wait)
33
+ end
31
34
  end
32
35
  end
33
36
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Librevox
4
- VERSION = "1.1.0"
4
+ VERSION = "1.3.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: librevox
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Harry Vangberg