qcmd 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,36 +1,157 @@
1
1
  require 'qcmd'
2
2
  require 'osc-ruby'
3
3
 
4
+ #
5
+ # This test file requires a running QLab instance with at least one cue. It is
6
+ # *strongly* recommended you open a new QLab workspace and close all others
7
+ # before running the tests.
8
+ #
9
+
10
+ def test_log msg=''
11
+ # puts msg
12
+ end
13
+
14
+ class DeadHandler
15
+ def self.handle response
16
+ # do nothing :P
17
+ end
18
+ end
19
+
4
20
  describe Qcmd::Commands do
5
- describe 'cue commands' do
21
+ describe 'when sending messages' do
6
22
  before do
7
23
  Qcmd.context = Qcmd::Context.new
8
- Qcmd.context.machine = Qcmd::Machine.new('machine', '1.1.1.1', 1000)
9
- Qcmd.context.workspace_connected = true
24
+ Qcmd.context.machine = Qcmd::Machine.new('test machine', 'localhost', 53000)
25
+ Qcmd.context.connect_to_qlab DeadHandler
26
+
27
+ # make sure alwaysReply is turned on
28
+ Qcmd.context.qlab.send(OSC::Message.new('/alwaysReply', 1))
29
+
30
+ @thread = nil
31
+ end
32
+
33
+ after do
34
+ if !@thread.nil? && @thread.alive?
35
+ @thread.join
36
+ end
37
+ end
38
+
39
+ describe 'machine commands' do
40
+ it 'should not raise errors' do
41
+ test_log
42
+
43
+ Qcmd::Commands::MACHINE.each do |machine_command|
44
+ expect {
45
+ osc_message = OSC::Message.new "/#{ machine_command }"
46
+
47
+ reply = nil
48
+
49
+ # should be able to instantiate all OSC message reponses as QLab replies
50
+ Qcmd.context.qlab.send(osc_message) do |response|
51
+ reply = Qcmd::QLab::Reply.new(response)
52
+ # test_log "[machine command] #{ reply.address } got #{ reply.to_s }"
53
+ end
54
+
55
+ test_log reply.address
56
+ reply.should_not be_nil
57
+ }.to_not raise_error
58
+ end
59
+ end
10
60
  end
11
61
 
12
- describe 'cue command always needing reply' do
62
+ describe 'workspace commands' do
13
63
  before do
14
- @address = '/workspace/TEST/cue/1/isRunning'
64
+ # make sure alwaysReply is turned on
65
+ Qcmd.context.qlab.send(OSC::Message.new('/alwaysReply', 1))
66
+
67
+ # load workspaces
68
+ osc_message = OSC::Message.new '/workspaces'
69
+ Qcmd.context.qlab.send(osc_message) do |response|
70
+ reply = Qcmd::QLab::Reply.new(response)
71
+ Qcmd.context.machine.workspaces = reply.data.map {|ws| Qcmd::QLab::Workspace.new(ws)}
72
+ end
15
73
  end
16
74
 
17
- describe 'with args' do
18
- before do
19
- @message = OSC::Message.new(@address, 123)
75
+ it 'should not raise errors' do
76
+ test_log
77
+
78
+ workspace = Qcmd.context.machine.workspaces.first
79
+
80
+ Qcmd::Commands::WORKSPACE.each do |workspace_command|
81
+ expect {
82
+ osc_message = OSC::Message.new "/workspace/#{workspace.id}/#{ workspace_command }"
83
+
84
+ osc_response = nil
85
+ reply = nil
86
+
87
+ begin
88
+ Qcmd.context.qlab.send(osc_message) do |response|
89
+ osc_response = response
90
+ reply = Qcmd::QLab::Reply.new(response)
91
+ # test_log "[workspace command] #{ reply.address } got #{ reply.to_s }"
92
+ end
93
+ rescue => ex
94
+ puts "sender fail: #{ ex.message }"
95
+ raise
96
+ end
97
+
98
+ begin
99
+ test_log reply.address
100
+ reply.should_not(be_nil)
101
+ rescue => ex
102
+ puts "reply access fail '#{ ex.message }' on response #{ osc_response.inspect }"
103
+ raise
104
+ end
105
+
106
+ }.to_not raise_error
20
107
  end
21
108
 
22
- it 'is detected' do
23
- Qcmd::Commands.expects_reply?(@message).should eql(true)
109
+ # spawn thread to shrink screen back down
110
+ @thread = Thread.new do
111
+ sleep 2
112
+ Qcmd.context.qlab.send(OSC::Message.new("/workspace/#{workspace.id}/toggleFullScreen"))
24
113
  end
25
114
  end
26
115
 
27
- describe 'without args' do
116
+ describe 'cue commands' do
28
117
  before do
29
- @message = OSC::Message.new(@address, *@args)
118
+ @cue = nil
119
+
120
+ osc_message = OSC::Message.new "/workspace/#{ Qcmd.context.machine.workspaces.first.id }/cueLists"
121
+
122
+ Qcmd.context.qlab.send(osc_message) do |response|
123
+ reply = Qcmd::QLab::Reply.new(response)
124
+ @cue = Qcmd::QLab::Cue.new(reply.data.first['cues'].first)
125
+ end
30
126
  end
31
127
 
32
- it 'is detected' do
33
- Qcmd::Commands.expects_reply?(@message).should eql(true)
128
+ it 'should not raise errors' do
129
+ test_log
130
+
131
+ workspace = Qcmd.context.machine.workspaces.first
132
+
133
+ Qcmd::Commands::CUE.each do |cue_command|
134
+ expect {
135
+ osc_message = OSC::Message.new "/workspace/#{workspace.id}/cue/#{ @cue.number }/#{ cue_command }"
136
+
137
+ osc_response = nil
138
+ reply = nil
139
+
140
+ Qcmd.context.qlab.send(osc_message) do |response|
141
+ osc_response = response
142
+ reply = Qcmd::QLab::Reply.new(response)
143
+ end
144
+
145
+ begin
146
+ test_log reply.address
147
+ reply.should_not be_nil
148
+ rescue => ex
149
+ puts "reply access fail '#{ ex.message }' on response #{ osc_response.inspect }"
150
+ raise
151
+ end
152
+
153
+ }.to_not raise_error
154
+ end
34
155
  end
35
156
  end
36
157
  end
@@ -3,26 +3,57 @@ require 'qcmd'
3
3
  describe Qcmd::Parser do
4
4
  it "should parse simple commands" do
5
5
  tokens = Qcmd::Parser.parse "go"
6
- tokens.should eql(['go'])
6
+ tokens.should eql([:go])
7
7
  end
8
8
 
9
9
  it "should parse embedded strings" do
10
10
  tokens = Qcmd::Parser.parse 'go "word word"'
11
- tokens.should eql(['go', 'word word'])
11
+ tokens.should eql([:go, 'word word'])
12
12
  end
13
13
 
14
14
  it "should parse integers" do
15
15
  tokens = Qcmd::Parser.parse 'go "word word" 10'
16
- tokens.should eql(['go', 'word word', 10])
16
+ tokens.should eql([:go, 'word word', 10])
17
17
  end
18
18
 
19
19
  it "should parse floats" do
20
20
  tokens = Qcmd::Parser.parse 'go "word word" 10 -12.3'
21
- tokens.should eql(['go', 'word word', 10, -12.3])
21
+ tokens.should eql([:go, 'word word', 10, -12.3])
22
22
  end
23
23
 
24
24
  it "should parse nested quotes" do
25
25
  tokens = Qcmd::Parser.parse 'go "word word" 10 -12.3 "life \"is good\" yeah"'
26
- tokens.should eql(['go', 'word word', 10, -12.3, 'life "is good" yeah'])
26
+
27
+ tokens.should eql([:go, 'word word', 10, -12.3, 'life "is good" yeah'])
28
+ end
29
+
30
+ it "should parse nested commands" do
31
+ tokens = Qcmd::Parser.parse 'cue 10 name (cue 3 name)'
32
+ tokens.should eql([:cue, 10, :name, [:cue, 3, :name]])
33
+ end
34
+
35
+ it "should parse alias commands" do
36
+ tokens = Qcmd::Parser.parse 'alias copy-name (cue 10 name (cue 3 name))'
37
+ tokens.should eql([:alias, :'copy-name', [:cue, 10, :name, [:cue, 3, :name]]])
38
+ end
39
+
40
+ it "should parse non alphanumeric commands" do
41
+ tokens = Qcmd::Parser.parse '..'
42
+ tokens.should eql([:'..'])
43
+ end
44
+
45
+ it "should parse leading slash commands" do
46
+ tokens = Qcmd::Parser.parse '/alwaysReply 1'
47
+ tokens.should eql([:'/alwaysReply', 1])
48
+ end
49
+
50
+ it 'should parse commands containing slashes' do
51
+ tokens = Qcmd::Parser.parse 'workspace/124/connect'
52
+ tokens.should eql([:'workspace/124/connect'])
53
+ end
54
+
55
+ it 'should parse strings with parens' do
56
+ tokens = Qcmd::Parser.parse %[cue 1 name "this is (not good)"]
57
+ tokens.should eql([:cue, 1, :name, 'this is (not good)'])
27
58
  end
28
59
  end
metadata CHANGED
@@ -1,133 +1,136 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: qcmd
3
- version: !ruby/object:Gem::Version
4
- hash: 21
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.8
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 1
9
- - 7
10
- version: 0.1.7
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Adam Bachman
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-11-24 00:00:00 -05:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
12
+ date: 2013-04-20 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
22
15
  name: dnssd
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
25
17
  none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 3
30
- segments:
31
- - 0
32
- version: "0"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
33
22
  type: :runtime
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
36
- name: json
37
23
  prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: json
32
+ requirement: !ruby/object:Gem::Requirement
39
33
  none: false
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- hash: 3
44
- segments:
45
- - 0
46
- version: "0"
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
47
38
  type: :runtime
48
- version_requirements: *id002
49
- - !ruby/object:Gem::Dependency
50
- name: osc-ruby
51
39
  prerelease: false
52
- requirement: &id003 !ruby/object:Gem::Requirement
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: osc-ruby
48
+ requirement: !ruby/object:Gem::Requirement
53
49
  none: false
54
- requirements:
55
- - - ">="
56
- - !ruby/object:Gem::Version
57
- hash: 3
58
- segments:
59
- - 0
60
- version: "0"
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
61
54
  type: :runtime
62
- version_requirements: *id003
63
- - !ruby/object:Gem::Dependency
64
- name: trollop
65
55
  prerelease: false
66
- requirement: &id004 !ruby/object:Gem::Requirement
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: trollop
64
+ requirement: !ruby/object:Gem::Requirement
67
65
  none: false
68
- requirements:
69
- - - ">="
70
- - !ruby/object:Gem::Version
71
- hash: 3
72
- segments:
73
- - 0
74
- version: "0"
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
75
70
  type: :runtime
76
- version_requirements: *id004
77
- - !ruby/object:Gem::Dependency
78
- name: rspec
79
71
  prerelease: false
80
- requirement: &id005 !ruby/object:Gem::Requirement
72
+ version_requirements: !ruby/object:Gem::Requirement
81
73
  none: false
82
- requirements:
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: rspec
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
83
  - - ~>
84
- - !ruby/object:Gem::Version
85
- hash: 39
86
- segments:
87
- - 2
88
- - 10
89
- - 0
84
+ - !ruby/object:Gem::Version
90
85
  version: 2.10.0
91
86
  type: :development
92
- version_requirements: *id005
93
- - !ruby/object:Gem::Dependency
94
- name: cucumber
95
87
  prerelease: false
96
- requirement: &id006 !ruby/object:Gem::Requirement
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: 2.10.0
94
+ - !ruby/object:Gem::Dependency
95
+ name: cucumber
96
+ requirement: !ruby/object:Gem::Requirement
97
97
  none: false
98
- requirements:
99
- - - ">="
100
- - !ruby/object:Gem::Version
101
- hash: 3
102
- segments:
103
- - 0
104
- version: "0"
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
105
102
  type: :development
106
- version_requirements: *id006
107
- - !ruby/object:Gem::Dependency
108
- name: aruba
109
103
  prerelease: false
110
- requirement: &id007 !ruby/object:Gem::Requirement
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: aruba
112
+ requirement: !ruby/object:Gem::Requirement
111
113
  none: false
112
- requirements:
113
- - - ">="
114
- - !ruby/object:Gem::Version
115
- hash: 3
116
- segments:
117
- - 0
118
- version: "0"
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
119
118
  type: :development
120
- version_requirements: *id007
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
121
126
  description: A simple interactive QLab 3 command line controller
122
- email:
127
+ email:
123
128
  - adam.bachman@gmail.com
124
- executables:
129
+ executables:
125
130
  - qcmd
126
131
  extensions: []
127
-
128
132
  extra_rdoc_files: []
129
-
130
- files:
133
+ files:
131
134
  - .gitignore
132
135
  - Gemfile
133
136
  - LICENSE.txt
@@ -137,13 +140,17 @@ files:
137
140
  - bin/qcmd
138
141
  - features/support/setup.rb
139
142
  - lib/qcmd.rb
143
+ - lib/qcmd/action.rb
144
+ - lib/qcmd/aliases.rb
140
145
  - lib/qcmd/cli.rb
141
146
  - lib/qcmd/commands.rb
147
+ - lib/qcmd/configuration.rb
142
148
  - lib/qcmd/context.rb
143
149
  - lib/qcmd/core_ext/array.rb
144
150
  - lib/qcmd/core_ext/osc/message.rb
145
- - lib/qcmd/core_ext/osc/stopping_server.rb
151
+ - lib/qcmd/core_ext/osc/tcp_client.rb
146
152
  - lib/qcmd/handler.rb
153
+ - lib/qcmd/history.rb
147
154
  - lib/qcmd/input_completer.rb
148
155
  - lib/qcmd/machine.rb
149
156
  - lib/qcmd/network.rb
@@ -152,60 +159,55 @@ files:
152
159
  - lib/qcmd/plaintext.rb
153
160
  - lib/qcmd/qlab.rb
154
161
  - lib/qcmd/qlab/cue.rb
162
+ - lib/qcmd/qlab/cue_list.rb
155
163
  - lib/qcmd/qlab/reply.rb
156
164
  - lib/qcmd/qlab/workspace.rb
157
- - lib/qcmd/server.rb
158
165
  - lib/qcmd/version.rb
166
+ - lib/vendor/sexpistol/LICENSE
167
+ - lib/vendor/sexpistol/sexpistol.rb
168
+ - lib/vendor/sexpistol/sexpistol/sexpistol.rb
169
+ - lib/vendor/sexpistol/sexpistol/sexpistol_parser.rb
159
170
  - qcmd.gemspec
160
171
  - sample/dnssd.rb
161
172
  - sample/simple_console.rb
173
+ - sample/tcp_qlab_connection.rb
162
174
  - spec/spec_helper.rb
175
+ - spec/unit/action_spec.rb
163
176
  - spec/unit/cli_spec.rb
164
177
  - spec/unit/commands_spec.rb
165
- - spec/unit/osc_server_spec.rb
166
178
  - spec/unit/parser_spec.rb
167
179
  - spec/unit/qcmd_spec.rb
168
180
  - spec/unit/qlab_spec.rb
169
- has_rdoc: true
170
181
  homepage: https://github.com/abachman/qcmd
171
182
  licenses: []
172
-
173
183
  post_install_message:
174
184
  rdoc_options: []
175
-
176
- require_paths:
185
+ require_paths:
177
186
  - lib
178
- required_ruby_version: !ruby/object:Gem::Requirement
187
+ required_ruby_version: !ruby/object:Gem::Requirement
179
188
  none: false
180
- requirements:
181
- - - ">="
182
- - !ruby/object:Gem::Version
183
- hash: 3
184
- segments:
185
- - 0
186
- version: "0"
187
- required_rubygems_version: !ruby/object:Gem::Requirement
189
+ requirements:
190
+ - - ! '>='
191
+ - !ruby/object:Gem::Version
192
+ version: '0'
193
+ required_rubygems_version: !ruby/object:Gem::Requirement
188
194
  none: false
189
- requirements:
190
- - - ">="
191
- - !ruby/object:Gem::Version
192
- hash: 3
193
- segments:
194
- - 0
195
- version: "0"
195
+ requirements:
196
+ - - ! '>='
197
+ - !ruby/object:Gem::Version
198
+ version: '0'
196
199
  requirements: []
197
-
198
200
  rubyforge_project:
199
- rubygems_version: 1.6.2
201
+ rubygems_version: 1.8.24
200
202
  signing_key:
201
203
  specification_version: 3
202
204
  summary: QLab 3 console
203
- test_files:
205
+ test_files:
204
206
  - features/support/setup.rb
205
207
  - spec/spec_helper.rb
208
+ - spec/unit/action_spec.rb
206
209
  - spec/unit/cli_spec.rb
207
210
  - spec/unit/commands_spec.rb
208
- - spec/unit/osc_server_spec.rb
209
211
  - spec/unit/parser_spec.rb
210
212
  - spec/unit/qcmd_spec.rb
211
213
  - spec/unit/qlab_spec.rb