sonic-pi-cli 0.0.1 → 0.0.2

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/sonic_pi +44 -4
  3. data/lib/sonic_pi.rb +9 -0
  4. metadata +16 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 83650427588988d44d97af0e5ddbbc95c6e3c610
4
- data.tar.gz: ce26d97a074a0dec4211462822bbdf48b0c37fa5
3
+ metadata.gz: 43a8553e55e26d9d8524c48384d9d11ead78fa79
4
+ data.tar.gz: 3758816b1415ba22926de0e4c12125c059c20cfb
5
5
  SHA512:
6
- metadata.gz: f0ece2ce9e8f8b9be9624b3f27d2f23d6fd87b95bb6e75348194629db1be5175a848e930a4059566f2ef2ac11cbf8c3c688c6b261cf09aad818bac2bf5214c5d
7
- data.tar.gz: 31dd568366b3fcf08452c1fcd1f54b67d403091165828ca54df06c30b804e7e3675b66fe665703207eab44cf03fb76d3e20c3d5fb6f77acb55af3f143279ac08
6
+ metadata.gz: 23560119840b4fc6b1697f11acfa9faba06cdba26dda6fda00a1ecd3f485478098b8ad9b8019b9f909125d20ae786705f47371f8480af99a37d585267d665ddf
7
+ data.tar.gz: 1294baad72f65a96efe0af2311675d8c0218bf2de477f9c1671782ff6cd27d30fd24f35b1b700d31a8149f1f7126bf53d303ccb099d72a1bfdb94496d57907a9
@@ -8,11 +8,51 @@ def stdin
8
8
  end
9
9
  end
10
10
 
11
+ def args
12
+ ARGV.join(' ')
13
+ end
14
+
11
15
  def args_and_stdin
12
- [
13
- ARGV.join(' '),
16
+ @args_and_stdin ||= [
17
+ args,
14
18
  stdin,
15
- ].join("\n")
19
+ ].join("\n").strip
20
+ end
21
+
22
+ def print_help
23
+ puts <<-HELP
24
+ sonic-pi-cli
25
+
26
+ Usage:
27
+ sonic_pi <code>
28
+ sonic_pi stop
29
+ cat music.rb | sonic_pi
30
+ sonic_pi --help
31
+
32
+ Sonic Pi must be running for this utility to work.
33
+ You can pipe code to stdin to execute it.
34
+
35
+ Options:
36
+ <code> Run the given code.
37
+ stop Stop all running music.
38
+ --help Display this text.
39
+
40
+ Made by Nick Johnstone (github.com/Widdershin/sonic-pi-cli).
41
+ Thanks to Sam Aaron for creating Sonic Pi.
42
+ HELP
43
+ end
44
+
45
+ def run
46
+ app = SonicPi.new
47
+
48
+ case args_and_stdin
49
+ when '--help', ''
50
+ print_help
51
+ when 'stop'
52
+ app.stop
53
+ else
54
+ app.run(args_and_stdin)
55
+ end
16
56
  end
17
57
 
18
- SonicPi.new.run(args_and_stdin)
58
+ run
@@ -4,6 +4,7 @@ require 'osc-ruby'
4
4
 
5
5
  class SonicPi
6
6
  RUN_COMMAND = "/run-code"
7
+ STOP_COMMAND = "/stop-all-jobs"
7
8
  SERVER = 'localhost'
8
9
  PORT = 4557
9
10
 
@@ -11,6 +12,10 @@ class SonicPi
11
12
  client.send(run_command(command))
12
13
  end
13
14
 
15
+ def stop
16
+ client.send(stop_command)
17
+ end
18
+
14
19
  private
15
20
 
16
21
  def client
@@ -20,5 +25,9 @@ class SonicPi
20
25
  def run_command(command)
21
26
  OSC::Message.new(RUN_COMMAND, "#{command}")
22
27
  end
28
+
29
+ def stop_command
30
+ OSC::Message.new(STOP_COMMAND)
31
+ end
23
32
  end
24
33
 
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.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Johnstone
@@ -9,7 +9,21 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
  date: 2014-02-09 00:00:00.000000000 Z
12
- dependencies: []
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: osc-ruby
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  description: A simple command line interface for Sonic Pi
14
28
  email: ncwjohnstone@gmail.com
15
29
  executables: