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 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
- read_responses(args[:regexp]) unless @in_command_list
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
- read_response
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 director
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
- read_response
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
@@ -13,7 +13,7 @@ module Rmpd
13
13
  end
14
14
 
15
15
  def ok?
16
- self.all? {|x| x.ok?}
16
+ self.all?(&:ok?)
17
17
  end
18
18
 
19
19
  def ack?
@@ -21,7 +21,7 @@ module Rmpd
21
21
  end
22
22
 
23
23
  def error
24
- self.find(nil) {|x| x.error}
24
+ self.map(&:error).compact.first
25
25
  end
26
26
 
27
27
 
data/lib/rmpd/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rmpd
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
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
@@ -34,6 +34,11 @@ def connect_and_auth_responses
34
34
  connect_response + ok
35
35
  end
36
36
 
37
+ def playlist_id_response
38
+ @id ||= 0
39
+ ["Id: #{@id += 1}"]
40
+ end
41
+
37
42
  def ok(txt="")
38
43
  txt ? ["OK #{txt}\n"] : ["OK\n"]
39
44
  end
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: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 1
10
- version: 1.0.1
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-06-23 00:00:00 -06:00
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: