sonic-pi-cli 0.1.1 → 0.1.3
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 +5 -5
- data/bin/sonic_pi +26 -2
- data/lib/sonic_pi.rb +7 -4
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 56c7ffafe6adcba49b7448fbf712920476cb7c1cec31a0e117b4fa9b466c015c
|
4
|
+
data.tar.gz: aaef39b5888f51b5889d6860b5759c2118668f600bff6c2ed23598482198b060
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f27cf2472303f9fd0458370da7947aa812ac2e150bd2db7b618286baf750b65d014eb6a749fe16ea1eb95da5a13eb1114ace445ee64177a8f7713f98bed018db
|
7
|
+
data.tar.gz: 49877b80ce03c869ccbf126c72f65e043d011b9b1e81461750bbb853b7aed10d1496b1c9d7cb30a9ee0d370e6519a0b1af1c12f74f4b335885fe3268043e0d51
|
data/bin/sonic_pi
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
3
|
+
require "sonic_pi"
|
4
|
+
|
5
|
+
PORT_LOG_REGEX = Regexp.compile(/Listen port:\s+(?<port>\d+)/)
|
4
6
|
|
5
7
|
def stdin
|
6
8
|
unless STDIN.tty?
|
@@ -8,6 +10,28 @@ def stdin
|
|
8
10
|
end
|
9
11
|
end
|
10
12
|
|
13
|
+
def find_port
|
14
|
+
port = 4557
|
15
|
+
|
16
|
+
begin
|
17
|
+
log_path = File.join(Dir.home, ".sonic-pi", "log", "server-output.log")
|
18
|
+
|
19
|
+
File.open(log_path, 'r') do |f|
|
20
|
+
port_log_entry =
|
21
|
+
f.each_line
|
22
|
+
.lazy
|
23
|
+
.map { |line| line[PORT_LOG_REGEX, "port"] }
|
24
|
+
.find { |match| !!match }
|
25
|
+
|
26
|
+
port = port_log_entry.to_i if port_log_entry
|
27
|
+
end
|
28
|
+
rescue Errno::ENOENT
|
29
|
+
# not to worry if the file doesn't exist
|
30
|
+
end
|
31
|
+
|
32
|
+
port
|
33
|
+
end
|
34
|
+
|
11
35
|
def args
|
12
36
|
ARGV.join(' ')
|
13
37
|
end
|
@@ -43,7 +67,7 @@ HELP
|
|
43
67
|
end
|
44
68
|
|
45
69
|
def run
|
46
|
-
app = SonicPi.new
|
70
|
+
app = SonicPi.new(find_port)
|
47
71
|
|
48
72
|
case args_and_stdin
|
49
73
|
when '--help', '-h', ''
|
data/lib/sonic_pi.rb
CHANGED
@@ -4,10 +4,13 @@ require 'osc-ruby'
|
|
4
4
|
require 'securerandom'
|
5
5
|
|
6
6
|
class SonicPi
|
7
|
+
def initialize(port=4557)
|
8
|
+
@port=port
|
9
|
+
end
|
10
|
+
|
7
11
|
RUN_COMMAND = "/run-code"
|
8
12
|
STOP_COMMAND = "/stop-all-jobs"
|
9
13
|
SERVER = 'localhost'
|
10
|
-
PORT = 4557
|
11
14
|
GUI_ID = 'SONIC_PI_CLI'
|
12
15
|
|
13
16
|
def run(command)
|
@@ -21,8 +24,8 @@ class SonicPi
|
|
21
24
|
def test_connection!
|
22
25
|
begin
|
23
26
|
socket = UDPSocket.new
|
24
|
-
socket.bind(nil,
|
25
|
-
abort("ERROR: Sonic Pi is not listening on #{
|
27
|
+
socket.bind(nil, @port)
|
28
|
+
abort("ERROR: Sonic Pi is not listening on #{@port} - is it running?")
|
26
29
|
rescue
|
27
30
|
# everything is good
|
28
31
|
end
|
@@ -31,7 +34,7 @@ class SonicPi
|
|
31
34
|
private
|
32
35
|
|
33
36
|
def client
|
34
|
-
@client ||= OSC::Client.new(SERVER,
|
37
|
+
@client ||= OSC::Client.new(SERVER, @port)
|
35
38
|
end
|
36
39
|
|
37
40
|
def send_command(call_type, command=nil)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sonic-pi-cli
|
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
|
- Nick Johnstone
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: osc-ruby
|
@@ -52,8 +52,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
52
52
|
- !ruby/object:Gem::Version
|
53
53
|
version: '0'
|
54
54
|
requirements: []
|
55
|
-
|
56
|
-
rubygems_version: 2.5.1
|
55
|
+
rubygems_version: 3.0.3
|
57
56
|
signing_key:
|
58
57
|
specification_version: 4
|
59
58
|
summary: Sonic Pi CLI
|