rmpd 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.rvmrc +1 -0
- data/lib/rmpd/commands/generators.rb +14 -1
- data/lib/rmpd/commands/miscellaneous.rb +6 -1
- data/lib/rmpd/commands/playlist.rb +8 -3
- data/lib/rmpd/multi_response.rb +2 -2
- data/lib/rmpd/version.rb +1 -1
- data/rmpd.gemspec +1 -1
- data/spec/models/commands_spec.rb +11 -0
- data/spec/spec_helper.rb +5 -0
- metadata +6 -5
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm --create use ruby-1.8.7-p330@global > /dev/null
|
@@ -21,11 +21,24 @@ module Rmpd
|
|
21
21
|
server_version_at_least(*args[:min_version])
|
22
22
|
end
|
23
23
|
send_command(name.to_s.gsub(/^_*/, ""), *quote(a))
|
24
|
-
|
24
|
+
if @in_command_list
|
25
|
+
append_command_list_regexp(args[:regexp])
|
26
|
+
else
|
27
|
+
read_responses(args[:regexp])
|
28
|
+
end
|
25
29
|
end
|
26
30
|
send(:define_method, name, &block)
|
27
31
|
end
|
28
32
|
|
33
|
+
def append_command_list_regexp(regexp)
|
34
|
+
if @in_command_list_response_regexp
|
35
|
+
@in_command_list_response_regexp = \
|
36
|
+
Regexp.union(@in_command_list_response_regexp, regexp)
|
37
|
+
else
|
38
|
+
@in_command_list_response_regexp = regexp
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
29
42
|
def quote(args)
|
30
43
|
args.collect {|arg| "\"#{arg.to_s.gsub(/"/, "\\\"")}\""}
|
31
44
|
end
|
@@ -25,9 +25,14 @@ module Rmpd
|
|
25
25
|
@in_command_list = true
|
26
26
|
yield self
|
27
27
|
send_command("command_list_end")
|
28
|
-
|
28
|
+
if @in_command_list_response_regexp
|
29
|
+
read_responses(@in_command_list_response_regexp)
|
30
|
+
else
|
31
|
+
read_response
|
32
|
+
end
|
29
33
|
ensure
|
30
34
|
@in_command_list = false
|
35
|
+
@in_command_list_response_regexp = nil
|
31
36
|
end
|
32
37
|
end
|
33
38
|
end
|
@@ -32,12 +32,17 @@ module Rmpd
|
|
32
32
|
simple_command :swapid
|
33
33
|
|
34
34
|
|
35
|
-
# must be a file only, cannot use with a
|
35
|
+
# must be a file only, cannot use with a directory
|
36
36
|
def addid(path, pos=nil)
|
37
37
|
# pos is only for r7153+, but what version is that?
|
38
38
|
server_version_at_least(0, 14, 0) if pos
|
39
|
-
send_command("addid #{quote(path)} #{pos.to_s}")
|
40
|
-
|
39
|
+
send_command("addid #{quote(path)} #{pos ? pos.to_s : nil}")
|
40
|
+
@add_id_response_regex ||= /(^Id: )/i
|
41
|
+
if @in_command_list
|
42
|
+
append_command_list_regexp(@add_id_response_regex)
|
43
|
+
else
|
44
|
+
read_responses(@add_id_response_regex)
|
45
|
+
end
|
41
46
|
end
|
42
47
|
|
43
48
|
alias_method :add_id, :addid
|
data/lib/rmpd/multi_response.rb
CHANGED
data/lib/rmpd/version.rb
CHANGED
data/rmpd.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.platform = Gem::Platform::RUBY
|
9
9
|
s.authors = ["Eric Wollesen"]
|
10
10
|
s.email = ["ericw@xmtp.net"]
|
11
|
-
s.homepage = ""
|
11
|
+
s.homepage = "http://github.com/ewollesen/rmpd"
|
12
12
|
s.summary = %q{Music Player Daemon client in Ruby}
|
13
13
|
s.description = %q{Music Player Daemon client in Ruby}
|
14
14
|
|
@@ -131,5 +131,16 @@ describe Rmpd::Commands do
|
|
131
131
|
c.stats
|
132
132
|
end
|
133
133
|
end
|
134
|
+
|
135
|
+
it "should handle multi responses" do
|
136
|
+
@responses = connect_and_auth_responses + playlist_id_response + ok
|
137
|
+
@socket.stub!(:readline).and_return(*@responses)
|
138
|
+
@socket.stub!(:puts).and_return(@socket.puts)
|
139
|
+
@socket.stub!(:eof?).and_return(false)
|
140
|
+
|
141
|
+
@conn.command_list do |c|
|
142
|
+
c.addid("foo")
|
143
|
+
end
|
144
|
+
end
|
134
145
|
end
|
135
146
|
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: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 2
|
10
|
+
version: 1.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Eric Wollesen
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-07-01 00:00:00 -06:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -60,6 +60,7 @@ extra_rdoc_files: []
|
|
60
60
|
files:
|
61
61
|
- .gitignore
|
62
62
|
- .rspec
|
63
|
+
- .rvmrc
|
63
64
|
- Gemfile
|
64
65
|
- Rakefile
|
65
66
|
- lib/rmpd.rb
|
@@ -92,7 +93,7 @@ files:
|
|
92
93
|
- spec/spec_helper.rb
|
93
94
|
- spec/spec_rcov.opts
|
94
95
|
has_rdoc: true
|
95
|
-
homepage:
|
96
|
+
homepage: http://github.com/ewollesen/rmpd
|
96
97
|
licenses: []
|
97
98
|
|
98
99
|
post_install_message:
|