alsa_aconnect 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/alsa/aconnect.rb +26 -5
- data/lib/alsa/aconnect/config.rb +11 -0
- data/lib/alsa/aconnect/version.rb +1 -1
- metadata +2 -2
- data/lib/alsa/aconnect/cmd.rb +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da2e1f58bb84d8f28e0c8d7b9b4c8db07de4471a5401192d754ae2e1f0d635d5
|
4
|
+
data.tar.gz: f8f1826eaf299c9718ac0158add3d832d2ab99c6e92a8c8abf853a7d193b1bff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c843743897fdffde6daa16facf423d79b6f3b7baa86cf557931da88aba1af336cc1895ff8d0a9462fb32a32729606d71f6dc86198f91d87965014723d0dff547
|
7
|
+
data.tar.gz: ecec114bded1c1ec6673eb2f014f8d184e9c244d7f3c0032d0bda1b8ee2c5dcd670b49107d42457a924341d47b517b44293cf75808dabeeef18080828734e673
|
data/lib/alsa/aconnect.rb
CHANGED
@@ -1,18 +1,20 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'alsa/aconnect/version'
|
4
|
+
require 'alsa/aconnect/config'
|
4
5
|
require 'alsa/aconnect/error'
|
5
|
-
require 'alsa/aconnect/cmd'
|
6
6
|
require 'alsa/aconnect/parser'
|
7
7
|
require 'alsa/aconnect/port'
|
8
8
|
require 'alsa/aconnect/client'
|
9
9
|
|
10
|
+
require 'open3'
|
11
|
+
|
10
12
|
module ALSA
|
11
13
|
module Aconnect
|
12
14
|
module_function
|
13
15
|
|
14
16
|
def input_clients
|
15
|
-
out =
|
17
|
+
out = run('-i', '-l')
|
16
18
|
Parser.parse_clients(out).map { |text| Client.new(text, :input) }
|
17
19
|
end
|
18
20
|
|
@@ -21,7 +23,7 @@ module ALSA
|
|
21
23
|
end
|
22
24
|
|
23
25
|
def output_clients
|
24
|
-
out =
|
26
|
+
out = run('-o', '-l')
|
25
27
|
Parser.parse_clients(out).map { |text| Client.new(text, :output) }
|
26
28
|
end
|
27
29
|
|
@@ -33,14 +35,33 @@ module ALSA
|
|
33
35
|
input = "#{input.client.id}:#{input.id}" if input.is_a?(Port)
|
34
36
|
output = "#{output.client.id}:#{output.id}" if output.is_a?(Port)
|
35
37
|
|
36
|
-
|
38
|
+
run('-d', input, output)
|
37
39
|
end
|
38
40
|
|
39
41
|
def disconnect(input, output)
|
40
42
|
input = "#{input.client.id}:#{input.id}" if input.is_a?(Port)
|
41
43
|
output = "#{output.client.id}:#{output.id}" if output.is_a?(Port)
|
42
44
|
|
43
|
-
|
45
|
+
run(input, output)
|
44
46
|
end
|
47
|
+
|
48
|
+
def run(*arguments)
|
49
|
+
cmd = [config.exec_path, *arguments].compact.join(' ')
|
50
|
+
out, err, status = Open3.capture3(cmd)
|
51
|
+
code = status.exitstatus
|
52
|
+
raise Error.new code, err unless code.zero?
|
53
|
+
|
54
|
+
out
|
55
|
+
end
|
56
|
+
|
57
|
+
def config
|
58
|
+
@config ||= Config.new
|
59
|
+
end
|
60
|
+
|
61
|
+
def configure
|
62
|
+
yield config if block_given?
|
63
|
+
end
|
64
|
+
|
65
|
+
configure
|
45
66
|
end
|
46
67
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alsa_aconnect
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Denis Talakevich
|
@@ -32,7 +32,7 @@ files:
|
|
32
32
|
- examples/midi_keyboard.rb
|
33
33
|
- lib/alsa/aconnect.rb
|
34
34
|
- lib/alsa/aconnect/client.rb
|
35
|
-
- lib/alsa/aconnect/
|
35
|
+
- lib/alsa/aconnect/config.rb
|
36
36
|
- lib/alsa/aconnect/error.rb
|
37
37
|
- lib/alsa/aconnect/parser.rb
|
38
38
|
- lib/alsa/aconnect/port.rb
|
data/lib/alsa/aconnect/cmd.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'open3'
|
4
|
-
|
5
|
-
module ALSA
|
6
|
-
module Aconnect
|
7
|
-
class Cmd
|
8
|
-
EXEC = 'aconnect'
|
9
|
-
|
10
|
-
def self.run(*arguments)
|
11
|
-
new(EXEC, arguments).run
|
12
|
-
end
|
13
|
-
|
14
|
-
def initialize(exec, *arguments)
|
15
|
-
@exec = exec
|
16
|
-
@arguments = arguments
|
17
|
-
end
|
18
|
-
|
19
|
-
def run
|
20
|
-
cmd = [@exec, *@arguments].compact.join(' ')
|
21
|
-
out, err, status = Open3.capture3(cmd)
|
22
|
-
code = status.exitstatus
|
23
|
-
raise Error.new code, err.join("\n") unless code.zero?
|
24
|
-
|
25
|
-
out
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|