rmpd 1.1.13 → 1.1.15

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bb4988929e39ec902157e3f0cc7bbdd5f84620d7
4
- data.tar.gz: df089ffe90ceb7121317eaa749466adba80628c6
3
+ metadata.gz: 0b9c7230c97e3cbfe65f19e3384b1de83457ac72
4
+ data.tar.gz: e33c538d3f9e14964fecd306f34d356245cefa21
5
5
  SHA512:
6
- metadata.gz: 45b1d3ec4b78bcfc4499c54e33c3f6d827b7e6b2e87c1ef7bd1c36f4e45b2a6ce548b9ee6afd3c57ed79f41b69a95b7388b8f01f4772b3b6bfbc2a35ad392ee7
7
- data.tar.gz: 9f246fef27256d620ab5e48142b8c835a41d55987e8bc5af6c1aa1095cf499a393a1f22dd04bca305a4f020f4ba080de727c6a05ff550668d8ef9a4c13053122
6
+ metadata.gz: 85c9e1503c810b455ba4b40df7f7e4bc970ba3d3f1b4f89d4a7d6487d1ddf0ec16b8fbdab235c88413ec9f09cb234cf6ecd414423a9f6f8548684e02c23c7f99
7
+ data.tar.gz: e6820320c75a8879894e64a7dd2809790f58b12099687acffa0078d7a29754ee8324d1d1f90a032d05485c502283bd17bbe5614ed2eaf0363ca15dff5d6329fb
@@ -10,20 +10,6 @@ module Rmpd
10
10
 
11
11
  private
12
12
 
13
- def receive_response
14
- lines = []
15
-
16
- while lines << @socket.readline do
17
- puts "recv: #{lines.last.strip}" if $DEBUG
18
- case lines.last
19
- when ACK_RE, OK_RE
20
- break
21
- end
22
- end
23
-
24
- lines
25
- end
26
-
27
13
  def send_command(command, *args)
28
14
  if in_command_list?
29
15
  @command_list << [command, args]
@@ -35,7 +21,7 @@ module Rmpd
35
21
  when /^command_list.*begin$/
36
22
  @command_list = [command, args]
37
23
  else
38
- send_command_now(command, *args)
24
+ connection.send_command(command, *args)
39
25
  end
40
26
  end
41
27
  end
@@ -44,40 +30,5 @@ module Rmpd
44
30
  !@command_list.nil?
45
31
  end
46
32
 
47
- def send_command_now(command, *args)
48
- connect
49
- @socket.puts("#{command} #{args.join(" ")}".strip)
50
- rescue Errno::EPIPE, EOFError
51
- @socket.close
52
- if (tries += 1) < 5
53
- retry
54
- else
55
- raise MpdError.new("Retry count exceeded")
56
- end
57
- end
58
-
59
- def send_command_old(command, *args)
60
- tries = 0
61
-
62
- if $DEBUG
63
- a = command == "password" ? args.map{|x| "*" * 8} : args
64
- Kernel.puts "send: #{command.strip} #{a.join(" ")}".strip
65
- end
66
-
67
- begin
68
- connect
69
- @socket.puts("#{command} #{args.join(" ")}".strip)
70
- rescue Errno::EPIPE, EOFError
71
- @socket.close
72
- if (tries += 1) < 5
73
- retry
74
- else
75
- raise MpdError.new("Retry count exceeded")
76
- end
77
- end
78
-
79
- receive_response unless @in_command_list
80
- end
81
-
82
33
  end
83
34
  end
@@ -6,13 +6,15 @@ module Rmpd
6
6
  simple_command :disableoutput
7
7
  simple_command :enableoutput
8
8
  simple_command :update
9
- simple_command :_kill
10
9
 
11
10
  def kill
12
- _kill
11
+ send_command_without_reconnect("kill")
13
12
  @socket_mu.lock
14
- @socket.close
15
- @socket_mu.unlock
13
+ begin
14
+ @socket.close
15
+ ensure
16
+ @socket_mu.unlock
17
+ end
16
18
  end
17
19
 
18
20
  alias_method :disable_output, :disableoutput
@@ -11,11 +11,10 @@ module Rmpd
11
11
  simple_command :ping
12
12
  simple_command :stats
13
13
  simple_command :status
14
- simple_command :_close
15
14
 
16
15
  def close
17
- _close
18
- @socket.close
16
+ send_command_without_reconnect("close")
17
+ @socket.synchronize {@socket.close}
19
18
  end
20
19
 
21
20
  simple_command :command_list
@@ -76,22 +76,28 @@ module Rmpd
76
76
  def send_command(command, *args)
77
77
  tries = 0
78
78
 
79
- connect
80
- @socket_mu.lock
81
79
  begin
82
- @socket.puts("#{command} #{quote(args).join(" ")}".strip)
80
+ connect
81
+ send_command_without_reconnect(command, *args)
83
82
  rescue Errno::EPIPE, EOFError
84
- @socket.close
85
83
  if (tries += 1) < MAX_RETRIES
86
84
  retry
87
85
  else
88
86
  raise MpdError.new("Retry count exceeded")
89
87
  end
90
- ensure
91
- @socket_mu.unlock
92
88
  end
93
89
  end
94
90
 
91
+ def send_command_without_reconnect(command, *args)
92
+ @socket_mu.lock
93
+ @socket.puts("#{command} #{quote(args).join(" ")}".strip)
94
+ rescue => e
95
+ @socket.close
96
+ raise e
97
+ ensure
98
+ @socket_mu.unlock
99
+ end
100
+
95
101
  def read_response
96
102
  response = []
97
103
 
@@ -1,3 +1,3 @@
1
1
  module Rmpd
2
- VERSION = "1.1.13"
2
+ VERSION = "1.1.15"
3
3
  end
@@ -62,14 +62,12 @@ describe Rmpd::Commands do
62
62
  end
63
63
 
64
64
  describe "kill" do
65
- before(:each) do
66
- set_password
67
- end
68
-
69
65
  it "should kill the daemon" do
66
+ set_password
70
67
  @socket.should_receive(:puts).with("kill")
71
68
  @socket.stub!(:readline).and_return(*connect_and_auth_responses)
72
69
  @socket.should_receive(:close)
70
+ @conn.connect
73
71
  @conn.kill
74
72
  end
75
73
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rmpd
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.13
4
+ version: 1.1.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Wollesen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-02 00:00:00.000000000 Z
11
+ date: 2016-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec