rmpd 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/lib/rmpd.rb CHANGED
@@ -8,7 +8,7 @@ module Rmpd
8
8
  ACK_RE = /^ACK \[(\d+)@(\d+)\] \{([^}]*)\} (.*)$/
9
9
  OK_RE = /^OK.*$/
10
10
 
11
- class MpdError < Exception ; end
11
+ class MpdError < StandardError ; end
12
12
 
13
13
  class MpdConnRefusedError < MpdError ; end
14
14
 
data/lib/rmpd/response.rb CHANGED
@@ -3,8 +3,9 @@ require "delegate"
3
3
  module Rmpd
4
4
 
5
5
  KEY_VALUE_RE = /^([^:]+):\s*(.*)$/
6
- KNOWN_INT_FIELDS = [:time, :pos, :id, :track, :playlistlength, :playlist,
6
+ KNOWN_INT_FIELDS = [:pos, :id, :track, :playlistlength, :playlist,
7
7
  :xfade, :repeat, :random, :queued, :volume, :song]
8
+ KNOWN_COMPLEX_FIELDS = [:time,]
8
9
 
9
10
  class Response < DelegateClass(Hash)
10
11
 
@@ -29,6 +30,7 @@ module Rmpd
29
30
  def register_key_val_pair(r)
30
31
  key, val = r[1].downcase.to_sym, r[2]
31
32
  val = val.to_i if KNOWN_INT_FIELDS.include?(key)
33
+ val = send("parse_complex_#{key}", val) if KNOWN_COMPLEX_FIELDS.include?(key)
32
34
  self[key] = include?(key) ? ([self[key]] << val).flatten : val
33
35
  self.class.send(:define_method, key) {self[key]}
34
36
  end
@@ -43,5 +45,14 @@ module Rmpd
43
45
  end
44
46
  end
45
47
 
48
+ # time can be either an integer (playlistinfo) or elapsed:total (status)
49
+ def parse_complex_time(value)
50
+ if /:/ === value
51
+ value.split(":", 2).map(&:to_i)
52
+ else
53
+ value.to_i
54
+ end
55
+ end
56
+
46
57
  end
47
58
  end
data/lib/rmpd/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rmpd
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  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: 23
5
- prerelease: false
4
+ hash: 21
5
+ prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 0
10
- version: 1.0.0
9
+ - 1
10
+ version: 1.0.1
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-12 00:00:00 -06:00
18
+ date: 2011-06-23 00:00:00 -06:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -121,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
121
  requirements: []
122
122
 
123
123
  rubyforge_project:
124
- rubygems_version: 1.3.7
124
+ rubygems_version: 1.6.2
125
125
  signing_key:
126
126
  specification_version: 3
127
127
  summary: Music Player Daemon client in Ruby