Commit 2800950d4eca0aa0887555a4a88203a7f53c362c

Anton Maminov 2012-07-09T15:07:58

mpd_client and mpd 0.17

diff --git a/lib/mpd_client.rb b/lib/mpd_client.rb
index 8650678..403eb50 100644
--- a/lib/mpd_client.rb
+++ b/lib/mpd_client.rb
@@ -10,6 +10,8 @@ NEXT = "list_OK"
 
 # MPD changelog: http://git.musicpd.org/cgit/master/mpd.git/plain/NEWS
 # http://mpd.wikia.com/wiki/MusicPlayerDaemonCommands
+# http://git.musicpd.org/cgit/cirrus/mpd.git/plain/doc/protocol.xml
+#
 COMMANDS = {
   # Status Commands
   "clearerror"         => "fetch_nothing",
@@ -80,6 +82,8 @@ COMMANDS = {
   "listallinfo"        => "fetch_database",
   "lsinfo"             => "fetch_database",
   "search"             => "fetch_songs",
+  "searchadd"             => "fetch_nothing",
+  "searchaddp1"             => "fetch_nothing",
   "update"             => "fetch_item",
   "rescan"             => "fetch_item",
   # Sticker Commands
@@ -120,8 +124,13 @@ class MPDClient
   end
 
   def connect(host = 'localhost', port = 6600)
-    @socket = TCPSocket.new(host, port)
-    hello
+    if host.start_with?('/')
+      @socket = UNIXSocket.new(host)
+      hello
+    else
+      @socket = TCPSocket.new(host, port)
+      hello
+    end
   end
 
   def disconnect
@@ -321,7 +330,7 @@ class MPDClient
   end
 
   def escape(text)
-    text.gsub("\\", "\\\\").gsub('"', '\\"')
+    text.to_s.gsub("\\", "\\\\").gsub('"', '\\"')
   end
 
 end
diff --git a/lib/mpd_client/version.rb b/lib/mpd_client/version.rb
index d32120a..c00860a 100644
--- a/lib/mpd_client/version.rb
+++ b/lib/mpd_client/version.rb
@@ -1,5 +1,5 @@
 # -*- encoding: utf-8 -*-
 
 class MPDClient
-  VERSION = "0.0.1"
+  VERSION = "0.0.2"
 end