anyplayer 1.1.3 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -13
- data/CHANGELOG.md +41 -0
- data/Gemfile.lock +2 -2
- data/README.md +4 -15
- data/Rakefile +9 -0
- data/lib/anyplayer.rb +8 -1
- data/lib/anyplayer/command_line.rb +57 -26
- data/lib/anyplayer/player.rb +9 -3
- data/lib/anyplayer/players/amarok.rb +9 -7
- data/lib/anyplayer/players/itunes_mac.rb +4 -3
- data/lib/anyplayer/players/itunes_windows.rb +4 -3
- data/lib/anyplayer/players/mpd.rb +2 -0
- data/lib/anyplayer/players/noplayer.rb +2 -1
- data/lib/anyplayer/players/rdio_mac.rb +6 -4
- data/lib/anyplayer/players/rhythmbox.rb +4 -3
- data/lib/anyplayer/players/spotify_mac.rb +5 -3
- data/lib/anyplayer/players/xmms2.rb +18 -10
- data/lib/anyplayer/selector.rb +29 -29
- data/lib/anyplayer/version.rb +1 -1
- data/test/anyplayer_test.rb +12 -6
- data/test/command_line_test.rb +151 -0
- data/test/player_test.rb +46 -2
- data/test/players/mpd_test.rb +1 -1
- data/test/selector_test.rb +1 -1
- data/test/test_helper.rb +0 -1
- metadata +17 -14
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
MmQzNjhkNzViN2I0NDJhYzQ1MTU3ODhlMTc3MDg1NDJkMTU2NzQ5Mw==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c7c0e8833c889429188b5c5ff92bd15ce9d97986
|
4
|
+
data.tar.gz: 7db1340983fa012cb778bad3ccb86975d0be6ebb
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
NGZhYTA0YTY2NWM1MTAzMDA5MjM5YWRkMjQxM2E3OTQ2YjUyN2NhMmI4OTg5
|
11
|
-
ZTgzNzBkOGRiYWY3ZDg1NDI3NmE1MmMxZjJhNzM1MzYxYzhiMDE=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
NmIzNmFjZTE2OWNhNzBmMThlZjgwNzY3MWIzMWFkZTE1MTZlNzI4YzBhMWNh
|
14
|
-
OGI0ZjIzYzVmYzIyMWNkNzRkODBjNzJlODFjN2IyMzJjNzQxOTU3MWViZGNm
|
15
|
-
YjNjNGE5M2NiZDIxM2EwYjM0ZmRjNmNhY2RmZTUzNzg0MmI0YzA=
|
6
|
+
metadata.gz: 0723be193d651281e960aa660bf0fa58a732470866225b5cccb578d9ef469549c2fc3d9ad4f1fc3eab50db825df9e08bb27efad5b89d98cdc6c03ae2d78f6cb9
|
7
|
+
data.tar.gz: 72929df7fd5b6e422174a97377261531dd99a0f5ce65a595e08b5fedbc1f3b5d886fa98d63e9b4344798678e78a304bd331b6b016bc8cc222dbd01ec52e7c127
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
Changelog
|
2
|
+
---------
|
3
|
+
|
4
|
+
Anyplayer tries its best to follow Semantic Versioning.
|
5
|
+
|
6
|
+
## v1.1.4 (2014-07-07)
|
7
|
+
|
8
|
+
Bugfixes:
|
9
|
+
|
10
|
+
- Fix iTunes Windows support by moving iTunes first
|
11
|
+
- New developement task "rake console"
|
12
|
+
- Refactorisations & tests
|
13
|
+
|
14
|
+
## v1.1.3 (2014-01-27)
|
15
|
+
|
16
|
+
Bugfixes:
|
17
|
+
|
18
|
+
- xmms2.0.8 support (thanks @ofa-)
|
19
|
+
|
20
|
+
## v1.1.2 (2013-12-18)
|
21
|
+
|
22
|
+
Bugfixes:
|
23
|
+
|
24
|
+
- MIT License
|
25
|
+
|
26
|
+
## v1.1.1 (2013-12-18)
|
27
|
+
|
28
|
+
Bugfixes:
|
29
|
+
|
30
|
+
- Better MPD support (thanks @nkoehring)
|
31
|
+
- Encoding fixes
|
32
|
+
|
33
|
+
## v1.1.0 (2013-10-27)
|
34
|
+
|
35
|
+
Features:
|
36
|
+
|
37
|
+
- Add Rdio Mac support (thanks @irosenb)
|
38
|
+
|
39
|
+
## v1.0.0 (2013-07-26)
|
40
|
+
|
41
|
+
First major release.
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -65,22 +65,11 @@ With the [So Nice](https://github.com/sunny/so-nice/) Web interface:
|
|
65
65
|
Development
|
66
66
|
-----------
|
67
67
|
|
68
|
-
Use the `anyplayer` binary from source:
|
69
|
-
|
70
|
-
```sh
|
71
|
-
$ ruby -Ilib bin/anyplayer
|
72
|
-
```
|
73
|
-
|
74
|
-
Launch tests:
|
75
|
-
|
76
|
-
```sh
|
77
|
-
$ bundle exec rake test
|
78
|
-
```
|
79
|
-
|
80
|
-
Install from source:
|
81
|
-
|
82
68
|
```sh
|
83
|
-
$
|
69
|
+
$ ruby -Ilib bin/anyplayer # Use the anyplayer command-line from source
|
70
|
+
$ bundle exec rake test # Launch tests
|
71
|
+
$ bundle exec rake install # Install from source
|
72
|
+
$ bundle exec rake console # Launch console
|
84
73
|
```
|
85
74
|
|
86
75
|
All contributions are welcome! Head to the [Github issues](https://github.com/sunny/anyplayer/issues) to report bugs, questions or code.
|
data/Rakefile
CHANGED
@@ -10,3 +10,12 @@ Rake::TestTask.new do |t|
|
|
10
10
|
t.pattern = "test/**/*_test.rb"
|
11
11
|
t.verbose = true
|
12
12
|
end
|
13
|
+
|
14
|
+
# Via http://erniemiller.org/2014/02/05/7-lines-every-gems-rakefile-should-have/
|
15
|
+
task :console do
|
16
|
+
require 'irb'
|
17
|
+
require 'irb/completion'
|
18
|
+
require 'anyplayer'
|
19
|
+
ARGV.clear
|
20
|
+
IRB.start
|
21
|
+
end
|
data/lib/anyplayer.rb
CHANGED
@@ -1,13 +1,20 @@
|
|
1
1
|
require "timeout"
|
2
2
|
|
3
3
|
module Anyplayer
|
4
|
+
# Ordering of the players should put the most-used players and the fastest to
|
5
|
+
# test at the top.
|
6
|
+
#
|
7
|
+
# iTunes Windows has been placed at the top because of some linux false
|
8
|
+
# positives.
|
9
|
+
# https://github.com/sunny/anyplayer/issues/8
|
10
|
+
|
4
11
|
PLAYERS = %w(
|
12
|
+
itunes_windows
|
5
13
|
rhythmbox
|
6
14
|
mpd
|
7
15
|
xmms2
|
8
16
|
amarok
|
9
17
|
itunes_mac
|
10
|
-
itunes_windows
|
11
18
|
spotify_mac
|
12
19
|
rdio_mac
|
13
20
|
)
|
@@ -4,12 +4,31 @@ require "anyplayer"
|
|
4
4
|
module Anyplayer::CommandLine
|
5
5
|
extend self
|
6
6
|
|
7
|
+
COMMANDS = %w(
|
8
|
+
playpause
|
9
|
+
play
|
10
|
+
pause
|
11
|
+
next
|
12
|
+
prev
|
13
|
+
voldown
|
14
|
+
volup
|
15
|
+
volume
|
16
|
+
track
|
17
|
+
artist
|
18
|
+
album
|
19
|
+
vote
|
20
|
+
name
|
21
|
+
launched
|
22
|
+
paused
|
23
|
+
playing
|
24
|
+
)
|
25
|
+
|
7
26
|
def parse(argv)
|
8
27
|
# Create a selector
|
9
28
|
selector = Anyplayer::Selector.new
|
10
29
|
if argv.first == "-v"
|
11
30
|
selector.verbose = true
|
12
|
-
argv.
|
31
|
+
argv.shift
|
13
32
|
|
14
33
|
$stderr.puts "anyplayer v#{Anyplayer::VERSION}"
|
15
34
|
end
|
@@ -18,36 +37,48 @@ module Anyplayer::CommandLine
|
|
18
37
|
player = selector.player
|
19
38
|
abort "Error: no player connected.\n" + selector.errors.join("\n") if !player
|
20
39
|
|
21
|
-
# Call
|
22
|
-
|
23
|
-
|
24
|
-
when "play" then player.play
|
25
|
-
when "pause" then player.pause
|
26
|
-
when "next" then player.next
|
27
|
-
when "prev" then player.next
|
28
|
-
when "voldown" then player.voldown
|
29
|
-
when "volup" then player.volup
|
30
|
-
when "volume" then puts player.volume
|
31
|
-
when "track" then puts player.track
|
32
|
-
when "artist" then puts player.artist
|
33
|
-
when "album" then puts player.album
|
34
|
-
when "vote" then player.vote
|
35
|
-
when "name" then puts player.name
|
36
|
-
when "launched" then exit(player.launched? ? 0 : 1)
|
37
|
-
when "playing" then exit(player.playing? ? 0 : 1)
|
38
|
-
when "paused" then exit(player.playing? ? 0 : 1)
|
40
|
+
# Call a command
|
41
|
+
if argv.empty?
|
42
|
+
usage(player)
|
39
43
|
else
|
40
|
-
|
41
|
-
|
44
|
+
command(player, argv.first)
|
45
|
+
end
|
46
|
+
end
|
42
47
|
|
43
|
-
Where command is one of: playpause, play, pause, next, prev, voldown, volup,
|
44
|
-
volume, track, artist, album, vote, name, launched.
|
45
48
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
+
private
|
50
|
+
|
51
|
+
# Call
|
52
|
+
def command(player, command)
|
53
|
+
response = call(player, command)
|
54
|
+
|
55
|
+
case response
|
56
|
+
when :undefined_command then usage(player)
|
57
|
+
when true then exit(0)
|
58
|
+
when false then exit(1)
|
59
|
+
when String, Numeric then puts response
|
49
60
|
end
|
61
|
+
end
|
50
62
|
|
63
|
+
# Call the method on the player
|
64
|
+
# Tries the boolean method as well
|
65
|
+
def call(player, command)
|
66
|
+
[command, "#{command}?"].each do |method|
|
67
|
+
method = method.to_sym
|
68
|
+
return player.send(method) if player.respond_to?(method)
|
69
|
+
end
|
70
|
+
|
71
|
+
:undefined_command
|
51
72
|
end
|
52
73
|
|
74
|
+
def usage(player)
|
75
|
+
$stderr.puts <<USAGE
|
76
|
+
Usage: anyplayer [-v] [command]
|
77
|
+
|
78
|
+
Where command is one of: #{COMMANDS.join(', ')}.
|
79
|
+
|
80
|
+
Player connected: #{player.name}.
|
81
|
+
USAGE
|
82
|
+
exit(1)
|
83
|
+
end
|
53
84
|
end
|
data/lib/anyplayer/player.rb
CHANGED
@@ -34,6 +34,11 @@ class Anyplayer::Player
|
|
34
34
|
self.class.to_s.gsub(/^.*::/, '')
|
35
35
|
end
|
36
36
|
|
37
|
+
# Default paused is not playing
|
38
|
+
def paused?
|
39
|
+
!playing?
|
40
|
+
end
|
41
|
+
|
37
42
|
# Tells the player to toggle the pause state
|
38
43
|
def playpause
|
39
44
|
paused? ? play : pause
|
@@ -65,11 +70,12 @@ class Anyplayer::Player
|
|
65
70
|
reset_votes
|
66
71
|
end
|
67
72
|
|
73
|
+
|
68
74
|
private
|
69
75
|
|
70
|
-
|
71
|
-
|
72
|
-
|
76
|
+
def reset_votes
|
77
|
+
@votes = 0
|
78
|
+
end
|
73
79
|
|
74
80
|
end
|
75
81
|
|
@@ -46,16 +46,18 @@ class Anyplayer::Amarok < Anyplayer::Player
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def launched?
|
49
|
-
not %x(qdbus org.kde.amarok 2>&1).match(/does not exist|command not found/)
|
49
|
+
not %x(qdbus org.kde.amarok 2>&1).match(/does not exist|command not found|cannot find the path specified/)
|
50
50
|
end
|
51
51
|
|
52
|
+
|
52
53
|
private
|
53
|
-
def amarok(command)
|
54
|
-
%x(qdbus org.kde.amarok /Player org.freedesktop.MediaPlayer.#{command}).rstrip
|
55
|
-
end
|
56
54
|
|
57
|
-
|
58
|
-
|
59
|
-
|
55
|
+
def amarok(command)
|
56
|
+
%x(qdbus org.kde.amarok /Player org.freedesktop.MediaPlayer.#{command}).rstrip
|
57
|
+
end
|
58
|
+
|
59
|
+
def amarok_get_meta(name)
|
60
|
+
amarok('GetMetadata').match(/#{name}: (\S.*)/)[1] rescue nil
|
61
|
+
end
|
60
62
|
end
|
61
63
|
|
@@ -60,7 +60,8 @@ class Anyplayer::ItunesMac < Anyplayer::Player
|
|
60
60
|
end
|
61
61
|
|
62
62
|
private
|
63
|
-
|
64
|
-
|
65
|
-
|
63
|
+
|
64
|
+
def itunes(command)
|
65
|
+
%x(osascript -e 'tell app "iTunes" to #{command}').rstrip
|
66
|
+
end
|
66
67
|
end
|
@@ -59,10 +59,11 @@ class Anyplayer::ItunesWindows < Anyplayer::Player
|
|
59
59
|
"iTunes Windows"
|
60
60
|
end
|
61
61
|
|
62
|
+
|
62
63
|
private
|
63
64
|
|
64
|
-
|
65
|
-
|
66
|
-
|
65
|
+
def itunes
|
66
|
+
itunes ||= WIN32OLE.new("iTunes.Application")
|
67
|
+
end
|
67
68
|
end
|
68
69
|
|
@@ -59,8 +59,10 @@ class Anyplayer::RdioMac < Anyplayer::Player
|
|
59
59
|
"Rdio Mac"
|
60
60
|
end
|
61
61
|
|
62
|
+
|
62
63
|
private
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
end
|
64
|
+
|
65
|
+
def rdio(command)
|
66
|
+
%x(osascript -e 'tell app "rdio" to #{command}').rstrip
|
67
|
+
end
|
68
|
+
end
|
@@ -50,8 +50,9 @@ class Anyplayer::Rhythmbox < Anyplayer::Player
|
|
50
50
|
end
|
51
51
|
|
52
52
|
private
|
53
|
-
|
54
|
-
|
55
|
-
|
53
|
+
|
54
|
+
def rhythmbox(command)
|
55
|
+
%x(rhythmbox-client --no-start --#{command}).rstrip
|
56
|
+
end
|
56
57
|
end
|
57
58
|
|
@@ -59,8 +59,10 @@ class Anyplayer::SpotifyMac < Anyplayer::Player
|
|
59
59
|
"Spotify Mac"
|
60
60
|
end
|
61
61
|
|
62
|
+
|
62
63
|
private
|
63
|
-
|
64
|
-
|
65
|
-
|
64
|
+
|
65
|
+
def spotify(command)
|
66
|
+
%x(osascript -e 'tell app "spotify" to #{command}').rstrip
|
67
|
+
end
|
66
68
|
end
|
@@ -22,20 +22,16 @@ class Anyplayer::Xmms2 < Anyplayer::Player
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def voldown
|
25
|
-
|
26
|
-
new_volume = (current < 11 ? 0 : current - 10)
|
27
|
-
xmms2 "server volume #{new_volume}"
|
25
|
+
set_volume volume - 10
|
28
26
|
end
|
29
27
|
|
30
28
|
def volup
|
31
|
-
|
32
|
-
new_volume = (current > 89 ? 100 : current + 10)
|
33
|
-
xmms2 "server volume #{new_volume}"
|
29
|
+
set_volume volume + 10
|
34
30
|
end
|
35
31
|
|
36
32
|
def volume
|
37
33
|
# currently just the first (left?) channel
|
38
|
-
xmms2('server volume').split("\n").first.sub(/([^0-9]*)/, '')
|
34
|
+
xmms2('server volume').split("\n").first.sub(/([^0-9]*)/, '').to_i
|
39
35
|
end
|
40
36
|
|
41
37
|
def track
|
@@ -68,10 +64,22 @@ class Anyplayer::Xmms2 < Anyplayer::Player
|
|
68
64
|
ENV['XMMS_PATH'] || super
|
69
65
|
end
|
70
66
|
|
67
|
+
|
71
68
|
private
|
72
|
-
|
73
|
-
|
74
|
-
|
69
|
+
|
70
|
+
def xmms2(command)
|
71
|
+
ret = %x(xmms2 #{command}).split("\n").first
|
72
|
+
ret ? ret.strip : ""
|
73
|
+
end
|
74
|
+
|
75
|
+
def set_volume(num)
|
76
|
+
num = if num < 0
|
77
|
+
0
|
78
|
+
elsif num > 100
|
79
|
+
100
|
75
80
|
end
|
81
|
+
|
82
|
+
xmms2 "server volume #{num}"
|
83
|
+
end
|
76
84
|
end
|
77
85
|
|
data/lib/anyplayer/selector.rb
CHANGED
@@ -30,39 +30,39 @@ class Anyplayer::Selector
|
|
30
30
|
|
31
31
|
private
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
33
|
+
def players_for_this_platform
|
34
|
+
players = Anyplayer::PLAYERS
|
35
|
+
players.reject! { |player| player =~ /_mac$/ } if RUBY_PLATFORM !~ /darwin/
|
36
|
+
players.reject! { |player| player =~ /_windows$/ } if RUBY_PLATFORM !~ /cygwin|mswin|mingw|bccwin|wince|emx/
|
37
|
+
players
|
38
|
+
end
|
39
39
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
end
|
40
|
+
def player_load(player)
|
41
|
+
begin
|
42
|
+
require "anyplayer/players/#{player}"
|
43
|
+
$stderr.puts "Loaded #{player}" if verbose
|
44
|
+
true
|
45
|
+
rescue LoadError => e
|
46
|
+
$stderr.puts "Could not load #{player}" if verbose
|
47
|
+
@errors << "Error loading #{player}: #{e.message}"
|
48
|
+
false
|
50
49
|
end
|
50
|
+
end
|
51
51
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
52
|
+
def player_class(player)
|
53
|
+
camelized = player.to_s.split(/_/).map{ |word| word.capitalize }.join
|
54
|
+
Anyplayer::const_get(camelized)
|
55
|
+
end
|
56
56
|
|
57
|
-
|
58
|
-
|
57
|
+
def player_launched(player)
|
58
|
+
$stderr.puts "#{player.name} launched?" if verbose
|
59
59
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
end
|
60
|
+
seconds = 5
|
61
|
+
begin
|
62
|
+
Timeout::timeout(seconds) { player.launched? }
|
63
|
+
rescue Timeout::Error
|
64
|
+
$stderr.puts "Timed out after #{seconds} seconds" if verbose
|
65
|
+
false
|
67
66
|
end
|
67
|
+
end
|
68
68
|
end
|
data/lib/anyplayer/version.rb
CHANGED
data/test/anyplayer_test.rb
CHANGED
@@ -1,9 +1,15 @@
|
|
1
1
|
require "test_helper"
|
2
2
|
|
3
|
-
class AnyplayerTest <
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
class AnyplayerTest < Minitest::Test
|
4
|
+
def test_loading_all_players_does_not_explode
|
5
|
+
PLAYERS.each do |player|
|
6
|
+
require "anyplayer/players/#{player}"
|
7
|
+
end
|
8
|
+
rescue LoadError
|
9
|
+
# Allow LoadErrors that depend on Windows
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_launched
|
13
|
+
assert_kind_of Anyplayer::Player, Anyplayer.launched
|
14
|
+
end
|
9
15
|
end
|
@@ -0,0 +1,151 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
require "anyplayer/command_line"
|
3
|
+
|
4
|
+
class CommandLineTest < Minitest::Test
|
5
|
+
include FlexMock::TestCase
|
6
|
+
|
7
|
+
USAGE = "Usage: anyplayer [-v] [command]
|
8
|
+
|
9
|
+
Where command is one of: playpause, play, pause, next, prev, voldown, volup, volume, track, artist, album, vote, name, launched, paused, playing.
|
10
|
+
|
11
|
+
Player connected: Fake Player.
|
12
|
+
"
|
13
|
+
|
14
|
+
def setup
|
15
|
+
@player = flexmock(:player)
|
16
|
+
@selector = flexmock(:selector)
|
17
|
+
@selector.should_receive(:player).and_return(@player)
|
18
|
+
flexmock(Anyplayer::Selector).should_receive(:new).and_return(@selector)
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_no_command
|
22
|
+
flexmock(@player).should_receive(:name).once.and_return("Fake Player")
|
23
|
+
flexmock($stderr).should_receive(:puts).once.with(USAGE)
|
24
|
+
flexmock(Anyplayer::CommandLine).should_receive(:exit).once.with(1)
|
25
|
+
Anyplayer::CommandLine.parse(%w())
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_wrong_command
|
29
|
+
flexmock(@player).should_receive(:name).once.and_return("Fake Player")
|
30
|
+
flexmock($stderr).should_receive(:puts).once.with(USAGE)
|
31
|
+
flexmock(Anyplayer::CommandLine).should_receive(:exit).once.with(1)
|
32
|
+
Anyplayer::CommandLine.parse(%w(err))
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_verbose
|
36
|
+
# flexmock(@player).should_receive(:name).once.and_return("Foo")
|
37
|
+
flexmock(@player).should_receive(:play).once
|
38
|
+
flexmock(@selector).should_receive(:verbose=).once.with(true)
|
39
|
+
flexmock($stderr).should_receive(:puts).once.with(/^anyplayer v[0-9.]+$/)
|
40
|
+
Anyplayer::CommandLine.parse(%w(-v play))
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
# Actions
|
45
|
+
|
46
|
+
def test_playpause
|
47
|
+
flexmock(@player).should_receive(:playpause).once
|
48
|
+
Anyplayer::CommandLine.parse(%w(playpause))
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_play
|
52
|
+
flexmock(@player).should_receive(:play).once
|
53
|
+
Anyplayer::CommandLine.parse(%w(play))
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_pause
|
57
|
+
flexmock(@player).should_receive(:pause).once
|
58
|
+
Anyplayer::CommandLine.parse(%w(pause))
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_next
|
62
|
+
flexmock(@player).should_receive(:next).once
|
63
|
+
Anyplayer::CommandLine.parse(%w(next))
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_prev
|
67
|
+
flexmock(@player).should_receive(:prev).once
|
68
|
+
Anyplayer::CommandLine.parse(%w(prev))
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_voldown
|
72
|
+
flexmock(@player).should_receive(:voldown).once
|
73
|
+
Anyplayer::CommandLine.parse(%w(voldown))
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_volup
|
77
|
+
flexmock(@player).should_receive(:volup).once
|
78
|
+
Anyplayer::CommandLine.parse(%w(volup))
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_vote
|
82
|
+
flexmock(@player).should_receive(:vote).once
|
83
|
+
Anyplayer::CommandLine.parse(%w(vote))
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_volume
|
87
|
+
flexmock(@player).should_receive(:volume).once.and_return(42)
|
88
|
+
flexmock($stdout).should_receive(:puts).once.with(42)
|
89
|
+
Anyplayer::CommandLine.parse(%w(volume))
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_track
|
93
|
+
flexmock(@player).should_receive(:track).once.and_return("Foo")
|
94
|
+
flexmock($stdout).should_receive(:puts).once.with("Foo")
|
95
|
+
Anyplayer::CommandLine.parse(%w(track))
|
96
|
+
end
|
97
|
+
|
98
|
+
def test_artist
|
99
|
+
flexmock(@player).should_receive(:artist).once.and_return("Foo")
|
100
|
+
flexmock($stdout).should_receive(:puts).once.with("Foo")
|
101
|
+
Anyplayer::CommandLine.parse(%w(artist))
|
102
|
+
end
|
103
|
+
|
104
|
+
def test_album
|
105
|
+
flexmock(@player).should_receive(:album).once.and_return("Foo")
|
106
|
+
flexmock($stdout).should_receive(:puts).once.with("Foo")
|
107
|
+
Anyplayer::CommandLine.parse(%w(album))
|
108
|
+
end
|
109
|
+
|
110
|
+
def test_name
|
111
|
+
flexmock(@player).should_receive(:name).once.and_return("Foo")
|
112
|
+
flexmock($stdout).should_receive(:puts).once.with("Foo")
|
113
|
+
Anyplayer::CommandLine.parse(%w(name))
|
114
|
+
end
|
115
|
+
|
116
|
+
|
117
|
+
# Booleans
|
118
|
+
|
119
|
+
def test_launched_true
|
120
|
+
flexmock(Anyplayer::CommandLine).should_receive(:exit)#.with(1)
|
121
|
+
flexmock(@player).should_receive(:launched?).once.and_return(true)
|
122
|
+
Anyplayer::CommandLine.parse(%w(launched))
|
123
|
+
end
|
124
|
+
def test_launched_false
|
125
|
+
flexmock(Anyplayer::CommandLine).should_receive(:exit)#.with(0)
|
126
|
+
flexmock(@player).should_receive(:launched?).once.and_return(false)
|
127
|
+
Anyplayer::CommandLine.parse(%w(launched))
|
128
|
+
end
|
129
|
+
|
130
|
+
def test_playing_true
|
131
|
+
flexmock(Anyplayer::CommandLine).should_receive(:exit).once#.with(1)
|
132
|
+
flexmock(@player).should_receive(:playing?).once.and_return(true)
|
133
|
+
Anyplayer::CommandLine.parse(%w(playing))
|
134
|
+
end
|
135
|
+
def test_playing_false
|
136
|
+
flexmock(Anyplayer::CommandLine).should_receive(:exit).once#.with(0)
|
137
|
+
flexmock(@player).should_receive(:playing?).once.and_return(false)
|
138
|
+
Anyplayer::CommandLine.parse(%w(playing))
|
139
|
+
end
|
140
|
+
|
141
|
+
def test_paused_true
|
142
|
+
flexmock(Anyplayer::CommandLine).should_receive(:exit).once#.with(1)
|
143
|
+
flexmock(@player).should_receive(:paused?).once.and_return(true)
|
144
|
+
Anyplayer::CommandLine.parse(%w(paused))
|
145
|
+
end
|
146
|
+
def test_paused_false
|
147
|
+
flexmock(Anyplayer::CommandLine).should_receive(:exit).once#.with(0)
|
148
|
+
flexmock(@player).should_receive(:paused?).once.and_return(false)
|
149
|
+
Anyplayer::CommandLine.parse(%w(paused))
|
150
|
+
end
|
151
|
+
end
|
data/test/player_test.rb
CHANGED
@@ -1,12 +1,57 @@
|
|
1
1
|
require "test_helper"
|
2
2
|
|
3
|
-
class PlayerTest <
|
3
|
+
class PlayerTest < Minitest::Test
|
4
4
|
include FlexMock::TestCase
|
5
5
|
|
6
6
|
def setup
|
7
7
|
@player = Noplayer.new
|
8
8
|
end
|
9
9
|
|
10
|
+
|
11
|
+
# Default name
|
12
|
+
|
13
|
+
def test_default_name
|
14
|
+
assert_equal "Noplayer", @player.name
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_default_name_should_remove_namespace
|
18
|
+
flexmock(@player).should_receive(:class).and_return("Foo::Bar")
|
19
|
+
assert_equal "Bar", @player.name
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
# Default paused?
|
24
|
+
|
25
|
+
def test_paused_is_false_if_not_playing
|
26
|
+
flexmock(@player).should_receive(:playing?).once.and_return(false)
|
27
|
+
assert @player.paused?
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_paused_is_true_if_not_paused
|
31
|
+
flexmock(@player).should_receive(:playing?).once.and_return(true)
|
32
|
+
assert !@player.paused?
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
# Default playpause
|
37
|
+
|
38
|
+
def test_playpause_toggles_play
|
39
|
+
flexmock(@player).should_receive(:paused?).once.and_return(true)
|
40
|
+
flexmock(@player).should_receive(:play).once
|
41
|
+
|
42
|
+
@player.playpause
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_playpause_toggles_pause
|
46
|
+
flexmock(@player).should_receive(:paused?).once.and_return(false)
|
47
|
+
flexmock(@player).should_receive(:pause).once
|
48
|
+
|
49
|
+
@player.playpause
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
# Votes
|
54
|
+
|
10
55
|
def test_votes
|
11
56
|
Player::DEFAULT_VOTES_TO_SKIP.times do |i|
|
12
57
|
@player.vote
|
@@ -49,5 +94,4 @@ class PlayerTest < MiniTest::Unit::TestCase
|
|
49
94
|
end
|
50
95
|
end
|
51
96
|
|
52
|
-
|
53
97
|
end
|
data/test/players/mpd_test.rb
CHANGED
data/test/selector_test.rb
CHANGED
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: anyplayer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sunny Ripert
|
@@ -9,48 +9,48 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-07-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ruby-mpd
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - ~>
|
18
|
+
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: 0.3.0
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- - ~>
|
25
|
+
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: 0.3.0
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: minitest
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- -
|
32
|
+
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '0'
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- -
|
39
|
+
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: flexmock
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- -
|
46
|
+
- - ">="
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: '0'
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- -
|
53
|
+
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '0'
|
56
56
|
description: Play/pause/skip songs in iTunes Mac, iTunes Windows, Spotify Mac, Rdio
|
@@ -63,9 +63,10 @@ executables:
|
|
63
63
|
extensions: []
|
64
64
|
extra_rdoc_files: []
|
65
65
|
files:
|
66
|
-
- .envrc
|
67
|
-
- .gitignore
|
68
|
-
- .travis.yml
|
66
|
+
- ".envrc"
|
67
|
+
- ".gitignore"
|
68
|
+
- ".travis.yml"
|
69
|
+
- CHANGELOG.md
|
69
70
|
- Gemfile
|
70
71
|
- Gemfile.lock
|
71
72
|
- MIT-LICENSE
|
@@ -88,6 +89,7 @@ files:
|
|
88
89
|
- lib/anyplayer/selector.rb
|
89
90
|
- lib/anyplayer/version.rb
|
90
91
|
- test/anyplayer_test.rb
|
92
|
+
- test/command_line_test.rb
|
91
93
|
- test/player_test.rb
|
92
94
|
- test/players/mpd_test.rb
|
93
95
|
- test/selector_test.rb
|
@@ -102,22 +104,23 @@ require_paths:
|
|
102
104
|
- lib
|
103
105
|
required_ruby_version: !ruby/object:Gem::Requirement
|
104
106
|
requirements:
|
105
|
-
- -
|
107
|
+
- - ">="
|
106
108
|
- !ruby/object:Gem::Version
|
107
109
|
version: '0'
|
108
110
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
111
|
requirements:
|
110
|
-
- -
|
112
|
+
- - ">="
|
111
113
|
- !ruby/object:Gem::Version
|
112
114
|
version: '0'
|
113
115
|
requirements: []
|
114
116
|
rubyforge_project:
|
115
|
-
rubygems_version: 2.
|
117
|
+
rubygems_version: 2.1.11
|
116
118
|
signing_key:
|
117
119
|
specification_version: 4
|
118
120
|
summary: Interact with the running music player
|
119
121
|
test_files:
|
120
122
|
- test/anyplayer_test.rb
|
123
|
+
- test/command_line_test.rb
|
121
124
|
- test/player_test.rb
|
122
125
|
- test/players/mpd_test.rb
|
123
126
|
- test/selector_test.rb
|