anyplayer 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +1 -0
- data/Gemfile.lock +3 -1
- data/Rakefile +1 -0
- data/Readme.markdown +17 -5
- data/anyplayer.gemspec +1 -0
- data/bin/anyplayer +13 -8
- data/lib/anyplayer.rb +17 -18
- data/lib/anyplayer/player.rb +45 -39
- data/lib/anyplayer/players/amarok.rb +43 -45
- data/lib/anyplayer/players/itunes_mac.rb +53 -0
- data/lib/anyplayer/players/itunes_windows.rb +68 -0
- data/lib/anyplayer/players/mpd.rb +45 -47
- data/lib/anyplayer/players/noplayer.rb +45 -0
- data/lib/anyplayer/players/rhythmbox.rb +41 -43
- data/lib/anyplayer/players/xmms2.rb +58 -60
- data/lib/anyplayer/selector.rb +66 -0
- data/lib/anyplayer/version.rb +1 -1
- data/test/anyplayer_test.rb +10 -69
- data/test/player_test.rb +53 -0
- data/test/selector_test.rb +26 -0
- data/test/test_helper.rb +9 -0
- metadata +34 -4
- data/lib/anyplayer/players/itunes.rb +0 -66
- data/lib/anyplayer/players/ituneswindows.rb +0 -66
data/lib/anyplayer/version.rb
CHANGED
data/test/anyplayer_test.rb
CHANGED
@@ -1,75 +1,16 @@
|
|
1
|
-
require "
|
2
|
-
require "minitest/autorun"
|
3
|
-
require "anyplayer"
|
1
|
+
require "test_helper"
|
4
2
|
|
5
3
|
class AnyplayerTest < MiniTest::Unit::TestCase
|
6
|
-
def
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
def test_music_player_running
|
12
|
-
assert_kind_of Anyplayer::Player, @player
|
13
|
-
end
|
14
|
-
|
15
|
-
|
16
|
-
def test_voting
|
17
|
-
assert_equal @player.votes, 0
|
18
|
-
|
19
|
-
first_track = @player.track
|
20
|
-
|
21
|
-
Anyplayer::Player::DEFAULT_VOTES_TO_SKIP.times do |i|
|
22
|
-
@player.vote
|
23
|
-
|
24
|
-
# votes should be 0 if we've voted enough times
|
25
|
-
if i == Anyplayer::Player::DEFAULT_VOTES_TO_SKIP-1
|
26
|
-
assert_equal @player.votes, 0
|
27
|
-
else
|
28
|
-
assert_equal @player.votes, i+1
|
29
|
-
end
|
4
|
+
def test_deprecated_launched
|
5
|
+
assert_output nil, "Anyplayer.launched is deprecated: please initialize a new Selector and call player\n" do
|
6
|
+
deprecated_player = Anyplayer::launched
|
7
|
+
assert_kind_of Player, deprecated_player
|
30
8
|
end
|
31
|
-
|
32
|
-
# make sure we actually changed tracks
|
33
|
-
refute_equal @player.track, first_track
|
34
|
-
|
35
|
-
# rewind test
|
36
|
-
@player.prev
|
37
|
-
@player.play
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_vote_resets
|
41
|
-
assert_equal @player.votes, 0
|
42
|
-
|
43
|
-
@player.next
|
44
|
-
assert_equal @player.votes, 0
|
45
|
-
|
46
|
-
@player.prev
|
47
|
-
assert_equal @player.votes, 0
|
48
9
|
end
|
49
10
|
|
50
|
-
def
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
first_track = @player.track
|
56
|
-
|
57
|
-
num_votes.times do |i|
|
58
|
-
@player.vote(num_votes)
|
59
|
-
|
60
|
-
# votes should be 0 if we've voted enough times
|
61
|
-
if i == num_votes-1
|
62
|
-
assert_equal @player.votes, 0
|
63
|
-
else
|
64
|
-
assert_equal @player.votes, i+1
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
# make sure we actually changed tracks
|
69
|
-
refute_equal @player.track, first_track
|
70
|
-
|
71
|
-
# rewind test
|
72
|
-
@player.prev
|
73
|
-
@player.play
|
74
|
-
end
|
11
|
+
# def test_loading_all_players
|
12
|
+
# PLAYERS.each do |player|
|
13
|
+
# require "anyplayer/players/#{player}"
|
14
|
+
# end
|
15
|
+
# end
|
75
16
|
end
|
data/test/player_test.rb
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class PlayerTest < MiniTest::Unit::TestCase
|
4
|
+
include FlexMock::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@player = Noplayer.new
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_votes
|
11
|
+
Player::DEFAULT_VOTES_TO_SKIP.times do |i|
|
12
|
+
@player.vote
|
13
|
+
|
14
|
+
# votes should be 0 if we've voted enough times
|
15
|
+
if i == Player::DEFAULT_VOTES_TO_SKIP - 1
|
16
|
+
assert_equal @player.votes, 0
|
17
|
+
else
|
18
|
+
assert_equal @player.votes, i + 1
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_voting_changes_track
|
24
|
+
flexmock(@player).should_receive(:next).once
|
25
|
+
Player::DEFAULT_VOTES_TO_SKIP.times { @player.vote }
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_vote_resets
|
29
|
+
assert_equal @player.votes, 0
|
30
|
+
|
31
|
+
@player.vote
|
32
|
+
@player.next
|
33
|
+
assert_equal @player.votes, 0
|
34
|
+
|
35
|
+
@player.vote
|
36
|
+
@player.prev
|
37
|
+
assert_equal @player.votes, 0
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_custom_voting_quota
|
41
|
+
10.times do |i|
|
42
|
+
@player.vote(10)
|
43
|
+
|
44
|
+
if i == 9
|
45
|
+
assert_equal @player.votes, 0
|
46
|
+
else
|
47
|
+
assert_equal @player.votes, i + 1
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class AnyplayerTest < MiniTest::Unit::TestCase
|
4
|
+
def test_player
|
5
|
+
selector = Selector.new
|
6
|
+
player = selector.player
|
7
|
+
assert_kind_of Player, player
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_verbose_accessor
|
11
|
+
selector = Selector.new
|
12
|
+
assert !selector.verbose
|
13
|
+
|
14
|
+
selector.verbose = true
|
15
|
+
assert selector.verbose
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_verbose_flag_messages
|
19
|
+
selector = Selector.new
|
20
|
+
selector.verbose = true
|
21
|
+
|
22
|
+
assert_output nil, "Loaded noplayer\nNoplayer launched?\n" do
|
23
|
+
selector.player
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/test/test_helper.rb
ADDED
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: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-
|
13
|
+
date: 2013-03-13 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: minitest
|
@@ -28,6 +28,22 @@ dependencies:
|
|
28
28
|
- - ! '>='
|
29
29
|
- !ruby/object:Gem::Version
|
30
30
|
version: '0'
|
31
|
+
- !ruby/object:Gem::Dependency
|
32
|
+
name: flexmock
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
type: :development
|
40
|
+
prerelease: false
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
31
47
|
description: Play/pause/skip songs in iTunes, Rythmbox, MPD, XMMS
|
32
48
|
email:
|
33
49
|
- sunny@sunfox.org
|
@@ -48,13 +64,18 @@ files:
|
|
48
64
|
- lib/anyplayer.rb
|
49
65
|
- lib/anyplayer/player.rb
|
50
66
|
- lib/anyplayer/players/amarok.rb
|
51
|
-
- lib/anyplayer/players/
|
52
|
-
- lib/anyplayer/players/
|
67
|
+
- lib/anyplayer/players/itunes_mac.rb
|
68
|
+
- lib/anyplayer/players/itunes_windows.rb
|
53
69
|
- lib/anyplayer/players/mpd.rb
|
70
|
+
- lib/anyplayer/players/noplayer.rb
|
54
71
|
- lib/anyplayer/players/rhythmbox.rb
|
55
72
|
- lib/anyplayer/players/xmms2.rb
|
73
|
+
- lib/anyplayer/selector.rb
|
56
74
|
- lib/anyplayer/version.rb
|
57
75
|
- test/anyplayer_test.rb
|
76
|
+
- test/player_test.rb
|
77
|
+
- test/selector_test.rb
|
78
|
+
- test/test_helper.rb
|
58
79
|
homepage: http://github.com/sunny/anyplayer
|
59
80
|
licenses: []
|
60
81
|
post_install_message:
|
@@ -67,12 +88,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
67
88
|
- - ! '>='
|
68
89
|
- !ruby/object:Gem::Version
|
69
90
|
version: '0'
|
91
|
+
segments:
|
92
|
+
- 0
|
93
|
+
hash: -3141794029494105960
|
70
94
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
95
|
none: false
|
72
96
|
requirements:
|
73
97
|
- - ! '>='
|
74
98
|
- !ruby/object:Gem::Version
|
75
99
|
version: '0'
|
100
|
+
segments:
|
101
|
+
- 0
|
102
|
+
hash: -3141794029494105960
|
76
103
|
requirements: []
|
77
104
|
rubyforge_project:
|
78
105
|
rubygems_version: 1.8.23
|
@@ -81,3 +108,6 @@ specification_version: 3
|
|
81
108
|
summary: Interact with the running music player
|
82
109
|
test_files:
|
83
110
|
- test/anyplayer_test.rb
|
111
|
+
- test/player_test.rb
|
112
|
+
- test/selector_test.rb
|
113
|
+
- test/test_helper.rb
|
@@ -1,66 +0,0 @@
|
|
1
|
-
if RUBY_PLATFORM =~ /darwin/
|
2
|
-
require 'appscript'
|
3
|
-
include Appscript
|
4
|
-
end
|
5
|
-
|
6
|
-
module Anyplayer
|
7
|
-
class Itunes < Player
|
8
|
-
def playpause
|
9
|
-
@app.playpause
|
10
|
-
end
|
11
|
-
|
12
|
-
def play
|
13
|
-
@app.play
|
14
|
-
end
|
15
|
-
|
16
|
-
def pause
|
17
|
-
@app.pause
|
18
|
-
end
|
19
|
-
|
20
|
-
def prev
|
21
|
-
@app.previous_track
|
22
|
-
super
|
23
|
-
end
|
24
|
-
|
25
|
-
def next
|
26
|
-
@app.next_track
|
27
|
-
super
|
28
|
-
end
|
29
|
-
|
30
|
-
def voldown
|
31
|
-
@app.sound_volume.set(volume + 10)
|
32
|
-
end
|
33
|
-
|
34
|
-
def volup
|
35
|
-
@app.sound_volume.set(volume + 10)
|
36
|
-
end
|
37
|
-
|
38
|
-
def volume
|
39
|
-
@app.sound_volume.get
|
40
|
-
end
|
41
|
-
|
42
|
-
def track
|
43
|
-
@app.current_track.name.get
|
44
|
-
end
|
45
|
-
|
46
|
-
def artist
|
47
|
-
@app.current_track.artist.get
|
48
|
-
end
|
49
|
-
|
50
|
-
def album
|
51
|
-
@app.current_track.album.get
|
52
|
-
end
|
53
|
-
|
54
|
-
def launched?
|
55
|
-
return false unless RUBY_PLATFORM =~ /darwin/
|
56
|
-
return false unless app('System Events').processes.name.get.include? "iTunes"
|
57
|
-
@app = app('iTunes')
|
58
|
-
true
|
59
|
-
end
|
60
|
-
|
61
|
-
def name
|
62
|
-
"iTunes"
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
@@ -1,66 +0,0 @@
|
|
1
|
-
module Anyplayer
|
2
|
-
class Ituneswindows < Player
|
3
|
-
def playpause
|
4
|
-
@itunes.PlayPause()
|
5
|
-
end
|
6
|
-
|
7
|
-
def play
|
8
|
-
@itunes.Play()
|
9
|
-
end
|
10
|
-
|
11
|
-
def pause
|
12
|
-
@itunes.Pause()
|
13
|
-
end
|
14
|
-
|
15
|
-
def prev
|
16
|
-
@itunes.PreviousTrack()
|
17
|
-
super
|
18
|
-
end
|
19
|
-
|
20
|
-
def next
|
21
|
-
@itunes.NextTrack()
|
22
|
-
super
|
23
|
-
end
|
24
|
-
|
25
|
-
def voldown
|
26
|
-
@itunes.SoundVolume=@itunes.SoundVolume - 10
|
27
|
-
end
|
28
|
-
|
29
|
-
def volup
|
30
|
-
@itunes.SoundVolume=@itunes.SoundVolume + 10
|
31
|
-
end
|
32
|
-
|
33
|
-
def volume
|
34
|
-
@itunes.SoundVolume
|
35
|
-
end
|
36
|
-
|
37
|
-
def track
|
38
|
-
@itunes.CurrentTrack.name
|
39
|
-
end
|
40
|
-
|
41
|
-
def artist
|
42
|
-
@itunes.CurrentTrack.Artist
|
43
|
-
end
|
44
|
-
|
45
|
-
def album
|
46
|
-
@itunes.CurrentTrack.Album
|
47
|
-
end
|
48
|
-
|
49
|
-
def launched?
|
50
|
-
return false if RUBY_PLATFORM !~ /cygwin|mswin|mingw|bccwin|wince|emx/
|
51
|
-
|
52
|
-
begin
|
53
|
-
require 'win32ole'
|
54
|
-
@itunes = WIN32OLE.new("iTunes.Application")
|
55
|
-
return true
|
56
|
-
rescue LoadError
|
57
|
-
return false
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
def name
|
62
|
-
"iTunes Windows"
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|