sonic-pi-cli 0.1.3 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/sonic_pi +1 -25
- data/lib/sonic_pi.rb +26 -2
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 69fb6262128d0b144aeb03a3135b5fa19eeed8d52a3fefab4f5c6317356983cc
|
4
|
+
data.tar.gz: e3c6d4c4ccc9cb99675dd537d7f08ae5d9b00c0b31639ea4ffba1f2cf28cb17c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99d188d6b33023baf1cab49f51615b203f3dd0b0c6c436a4893027baf2e7a95aa5b602481e7b74c58e16e65c51b657172c38ae16bd8c76f31e232fbebef42a0b
|
7
|
+
data.tar.gz: 77010bf05ef77eec503f9eb0c31a4acbed999cfc25bce50e63968031a708c220e96e6c8ffc97acb77ecef75f3715ce7c69e8ead752361b8e7c95a7c8ecd0119d
|
data/bin/sonic_pi
CHANGED
@@ -2,36 +2,12 @@
|
|
2
2
|
|
3
3
|
require "sonic_pi"
|
4
4
|
|
5
|
-
PORT_LOG_REGEX = Regexp.compile(/Listen port:\s+(?<port>\d+)/)
|
6
|
-
|
7
5
|
def stdin
|
8
6
|
unless STDIN.tty?
|
9
7
|
$stdin.read
|
10
8
|
end
|
11
9
|
end
|
12
10
|
|
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
|
-
|
35
11
|
def args
|
36
12
|
ARGV.join(' ')
|
37
13
|
end
|
@@ -67,7 +43,7 @@ HELP
|
|
67
43
|
end
|
68
44
|
|
69
45
|
def run
|
70
|
-
app = SonicPi.new
|
46
|
+
app = SonicPi.new
|
71
47
|
|
72
48
|
case args_and_stdin
|
73
49
|
when '--help', '-h', ''
|
data/lib/sonic_pi.rb
CHANGED
@@ -4,8 +4,10 @@ require 'osc-ruby'
|
|
4
4
|
require 'securerandom'
|
5
5
|
|
6
6
|
class SonicPi
|
7
|
-
|
8
|
-
|
7
|
+
PORT_LOG_REGEX = Regexp.compile(/Listen port:\s+(?<port>\d+)/)
|
8
|
+
|
9
|
+
def initialize(port=nil)
|
10
|
+
@port = port || find_port
|
9
11
|
end
|
10
12
|
|
11
13
|
RUN_COMMAND = "/run-code"
|
@@ -41,4 +43,26 @@ class SonicPi
|
|
41
43
|
prepared_command = OSC::Message.new(call_type, GUI_ID, command)
|
42
44
|
client.send(prepared_command)
|
43
45
|
end
|
46
|
+
|
47
|
+
def find_port
|
48
|
+
port = 4557
|
49
|
+
|
50
|
+
begin
|
51
|
+
log_path = File.join(Dir.home, ".sonic-pi", "log", "server-output.log")
|
52
|
+
|
53
|
+
File.open(log_path, 'r') do |f|
|
54
|
+
port_log_entry =
|
55
|
+
f.each_line
|
56
|
+
.lazy
|
57
|
+
.map { |line| line[PORT_LOG_REGEX, "port"] }
|
58
|
+
.find { |match| !!match }
|
59
|
+
|
60
|
+
port = port_log_entry.to_i if port_log_entry
|
61
|
+
end
|
62
|
+
rescue Errno::ENOENT
|
63
|
+
# not to worry if the file doesn't exist
|
64
|
+
end
|
65
|
+
|
66
|
+
port
|
67
|
+
end
|
44
68
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sonic-pi-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Johnstone
|
@@ -14,16 +14,16 @@ dependencies:
|
|
14
14
|
name: osc-ruby
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '1'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '1'
|
27
27
|
description: A simple command line interface for Sonic Pi
|
28
28
|
email: ncwjohnstone@gmail.com
|
29
29
|
executables:
|