rmpd 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rmpd.rb +1 -0
- data/lib/rmpd/commands.rb +4 -1
- data/lib/rmpd/commands/miscellaneous.rb +35 -3
- data/lib/rmpd/config.rb +1 -1
- data/lib/rmpd/response.rb +2 -2
- data/lib/rmpd/version.rb +1 -1
- data/spec/models/commands_spec.rb +16 -0
- data/spec/models/multi_response_spec.rb +1 -1
- data/spec/spec_helper.rb +4 -0
- metadata +14 -16
data/lib/rmpd.rb
CHANGED
data/lib/rmpd/commands.rb
CHANGED
@@ -15,11 +15,14 @@ module Rmpd
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def receive_server_response
|
18
|
+
@last_response = nil
|
18
19
|
lines = []
|
19
20
|
while lines << @socket.readline do
|
20
21
|
puts "recv: #{lines.last.strip} (#{OK_RE === lines.last})" if $DEBUG
|
21
22
|
case lines.last
|
22
|
-
when ACK_RE, OK_RE
|
23
|
+
when ACK_RE, OK_RE, LIST_OK_RE
|
24
|
+
@last_response = lines.last
|
25
|
+
break
|
23
26
|
end
|
24
27
|
end
|
25
28
|
return lines.join
|
@@ -25,14 +25,46 @@ module Rmpd
|
|
25
25
|
@in_command_list = true
|
26
26
|
yield self
|
27
27
|
send_command("command_list_end")
|
28
|
+
handle_command_list_response
|
29
|
+
ensure
|
30
|
+
@in_command_list = false
|
31
|
+
@in_command_list_response_regexp = nil
|
32
|
+
end
|
33
|
+
|
34
|
+
def command_list_ok
|
35
|
+
send_command("command_list_ok_begin")
|
36
|
+
@in_command_list = true
|
37
|
+
yield self
|
38
|
+
send_command("command_list_end")
|
39
|
+
read_command_list_ok_responses do |responses|
|
40
|
+
handle_command_list_response.tap do |res|
|
41
|
+
responses << res unless res.empty?
|
42
|
+
end
|
43
|
+
end
|
44
|
+
ensure
|
45
|
+
@in_command_list = false
|
46
|
+
@in_command_list_response_regexp = nil
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def handle_command_list_response
|
28
53
|
if @in_command_list_response_regexp
|
29
54
|
read_responses(@in_command_list_response_regexp)
|
30
55
|
else
|
31
56
|
read_response
|
32
57
|
end
|
33
|
-
|
34
|
-
|
35
|
-
|
58
|
+
end
|
59
|
+
|
60
|
+
def read_command_list_ok_responses
|
61
|
+
responses = []
|
62
|
+
|
63
|
+
begin
|
64
|
+
yield responses
|
65
|
+
end while LIST_OK_RE === @last_response
|
66
|
+
|
67
|
+
responses
|
36
68
|
end
|
37
69
|
end
|
38
70
|
end
|
data/lib/rmpd/config.rb
CHANGED
data/lib/rmpd/response.rb
CHANGED
@@ -4,7 +4,7 @@ module Rmpd
|
|
4
4
|
|
5
5
|
KEY_VALUE_RE = /^([^:]+):\s*(.*)$/
|
6
6
|
KNOWN_INT_FIELDS = [:pos, :id, :track, :playlistlength, :playlist,
|
7
|
-
:xfade, :repeat, :random, :queued, :volume, :song]
|
7
|
+
:xfade, :repeat, :random, :queued, :volume, :song, :songid]
|
8
8
|
KNOWN_COMPLEX_FIELDS = [:time,]
|
9
9
|
|
10
10
|
class Response < DelegateClass(Hash)
|
@@ -39,7 +39,7 @@ module Rmpd
|
|
39
39
|
data.split("\n").each do |line|
|
40
40
|
case line
|
41
41
|
when KEY_VALUE_RE; register_key_val_pair($~)
|
42
|
-
when OK_RE; @error = nil
|
42
|
+
when LIST_OK_RE, OK_RE; @error = nil
|
43
43
|
when ACK_RE; @error = MpdAckError.new($~.values_at(0..-1))
|
44
44
|
end
|
45
45
|
end
|
data/lib/rmpd/version.rb
CHANGED
@@ -143,4 +143,20 @@ describe Rmpd::Commands do
|
|
143
143
|
end
|
144
144
|
end
|
145
145
|
end
|
146
|
+
|
147
|
+
describe "command_list_ok" do
|
148
|
+
it "should return a list of multi responses" do
|
149
|
+
@responses = connect_response + command_list_ok_responses + ok
|
150
|
+
@socket.stub!(:readline).and_return(*@responses)
|
151
|
+
@socket.stub!(:puts).and_return(@socket.puts)
|
152
|
+
@socket.stub!(:eof?).and_return(false)
|
153
|
+
|
154
|
+
results = @conn.command_list_ok do |c|
|
155
|
+
c.list("album")
|
156
|
+
c.list("artist")
|
157
|
+
end
|
158
|
+
|
159
|
+
results.should have(2).items, results.pretty_inspect
|
160
|
+
end
|
161
|
+
end
|
146
162
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rmpd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 29
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 5
|
10
|
+
version: 1.0.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Eric Wollesen
|
@@ -15,13 +15,11 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
19
|
-
default_executable:
|
18
|
+
date: 2012-08-17 00:00:00 Z
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
22
21
|
name: rspec
|
23
|
-
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
22
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
25
23
|
none: false
|
26
24
|
requirements:
|
27
25
|
- - ~>
|
@@ -33,11 +31,11 @@ dependencies:
|
|
33
31
|
- 0
|
34
32
|
version: 2.6.0
|
35
33
|
type: :development
|
36
|
-
|
34
|
+
requirement: *id001
|
35
|
+
prerelease: false
|
37
36
|
- !ruby/object:Gem::Dependency
|
38
37
|
name: ruby-debug
|
39
|
-
|
40
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
41
39
|
none: false
|
42
40
|
requirements:
|
43
41
|
- - ">="
|
@@ -47,11 +45,11 @@ dependencies:
|
|
47
45
|
- 0
|
48
46
|
version: "0"
|
49
47
|
type: :development
|
50
|
-
|
48
|
+
requirement: *id002
|
49
|
+
prerelease: false
|
51
50
|
- !ruby/object:Gem::Dependency
|
52
51
|
name: rake
|
53
|
-
|
54
|
-
requirement: &id003 !ruby/object:Gem::Requirement
|
52
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
55
53
|
none: false
|
56
54
|
requirements:
|
57
55
|
- - ">="
|
@@ -61,7 +59,8 @@ dependencies:
|
|
61
59
|
- 0
|
62
60
|
version: "0"
|
63
61
|
type: :development
|
64
|
-
|
62
|
+
requirement: *id003
|
63
|
+
prerelease: false
|
65
64
|
description: Music Player Daemon client in Ruby
|
66
65
|
email:
|
67
66
|
- ericw@xmtp.net
|
@@ -106,7 +105,6 @@ files:
|
|
106
105
|
- spec/spec.opts
|
107
106
|
- spec/spec_helper.rb
|
108
107
|
- spec/spec_rcov.opts
|
109
|
-
has_rdoc: true
|
110
108
|
homepage: http://github.com/ewollesen/rmpd
|
111
109
|
licenses: []
|
112
110
|
|
@@ -136,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
134
|
requirements: []
|
137
135
|
|
138
136
|
rubyforge_project:
|
139
|
-
rubygems_version: 1.
|
137
|
+
rubygems_version: 1.8.24
|
140
138
|
signing_key:
|
141
139
|
specification_version: 3
|
142
140
|
summary: Music Player Daemon client in Ruby
|