anyplayer 1.1.4 → 1.1.5
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 +4 -4
- data/CHANGELOG.md +7 -0
- data/CONTRIBUTING.md +22 -0
- data/Gemfile +0 -2
- data/Gemfile.lock +4 -4
- data/README.md +5 -2
- data/anyplayer.gemspec +1 -0
- data/lib/anyplayer/player.rb +6 -1
- data/lib/anyplayer/players/amarok.rb +7 -1
- data/lib/anyplayer/players/itunes_mac.rb +6 -2
- data/lib/anyplayer/players/itunes_windows.rb +5 -1
- data/lib/anyplayer/players/mpd.rb +1 -2
- data/lib/anyplayer/players/rdio_mac.rb +5 -2
- data/lib/anyplayer/players/rhythmbox.rb +1 -0
- data/lib/anyplayer/players/spotify_mac.rb +6 -3
- data/lib/anyplayer/players/xmms2.rb +4 -0
- data/lib/anyplayer/selector.rb +78 -45
- data/lib/anyplayer/version.rb +1 -1
- data/test/selector_test.rb +1 -1
- metadata +29 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ce9982f42d4ae01c721cf82f4fc09a4fc61740c
|
4
|
+
data.tar.gz: ea519d8ba4bde8f84b3e2ad253ce6e276c98673e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e488e5dca3e611699ffea03d075cd25a6c5376325974e2be1eabdc714cdc4e18b77f612dcbb2e0465e1508498d83f9b9b3e06c35a8f38de40c7c5926e526f619
|
7
|
+
data.tar.gz: 73788384a220e2b6434c7f966f3475ac281408c054af4de10e13e98f96b98e547dbb4aebfbfbf1d4c03bcdc4e8d3b3b9e0ddc2e005829d7fabc71a71c9d7a227
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,13 @@ Changelog
|
|
3
3
|
|
4
4
|
Anyplayer tries its best to follow Semantic Versioning.
|
5
5
|
|
6
|
+
## v1.1.5 (2014-07-07)
|
7
|
+
|
8
|
+
Bugfixes:
|
9
|
+
|
10
|
+
- Better platform detection by letting players list the platforms
|
11
|
+
they are intended to work on.
|
12
|
+
|
6
13
|
## v1.1.4 (2014-07-07)
|
7
14
|
|
8
15
|
Bugfixes:
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Contributing
|
2
|
+
============
|
3
|
+
|
4
|
+
All contributions are welcome! Head to the [Github issues](https://github.com/sunny/anyplayer/issues) to report bugs, questions or code.
|
5
|
+
|
6
|
+
|
7
|
+
Submit code
|
8
|
+
-----------
|
9
|
+
|
10
|
+
1. Fork the repository on Github
|
11
|
+
1. Create a topic branch
|
12
|
+
1. Implement your feature and the accompanying tests
|
13
|
+
1. Run `rake test` to make sure the tests are passing
|
14
|
+
1. Add documentation for your feature or bug fix
|
15
|
+
1. Add, commit, and push your changes
|
16
|
+
1. Submit a pull request
|
17
|
+
|
18
|
+
|
19
|
+
Versionning
|
20
|
+
-----------
|
21
|
+
|
22
|
+
This library aims to adhere to [Semantic Versioning 2.0](http://semver.org/).
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
anyplayer (1.1.
|
4
|
+
anyplayer (1.1.5)
|
5
5
|
ruby-mpd (~> 0.3.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: http://rubygems.org/
|
9
9
|
specs:
|
10
10
|
flexmock (1.3.3)
|
11
|
-
minitest (5.
|
12
|
-
rake (
|
13
|
-
ruby-mpd (0.3.
|
11
|
+
minitest (5.4.1)
|
12
|
+
rake (10.3.2)
|
13
|
+
ruby-mpd (0.3.2)
|
14
14
|
|
15
15
|
PLATFORMS
|
16
16
|
ruby
|
data/README.md
CHANGED
@@ -62,9 +62,13 @@ With the [So Nice](https://github.com/sunny/so-nice/) Web interface:
|
|
62
62
|

|
63
63
|
|
64
64
|
|
65
|
-
|
65
|
+
Contribute!
|
66
66
|
-----------
|
67
67
|
|
68
|
+
All contributions are welcome! Head to the [Github issues](https://github.com/sunny/anyplayer/issues) to report bugs, questions or code. Also, check out `CONTRIBUTING.md`.
|
69
|
+
|
70
|
+
Here a few useful commands while developping:
|
71
|
+
|
68
72
|
```sh
|
69
73
|
$ ruby -Ilib bin/anyplayer # Use the anyplayer command-line from source
|
70
74
|
$ bundle exec rake test # Launch tests
|
@@ -72,7 +76,6 @@ $ bundle exec rake install # Install from source
|
|
72
76
|
$ bundle exec rake console # Launch console
|
73
77
|
```
|
74
78
|
|
75
|
-
All contributions are welcome! Head to the [Github issues](https://github.com/sunny/anyplayer/issues) to report bugs, questions or code.
|
76
79
|
|
77
80
|
License
|
78
81
|
-------
|
data/anyplayer.gemspec
CHANGED
data/lib/anyplayer/player.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Default Player class that is
|
1
|
+
# Default Player class that is inherited by all players.
|
2
2
|
#
|
3
3
|
# All players should override these methods:
|
4
4
|
# launched? (return bool)
|
@@ -70,6 +70,11 @@ class Anyplayer::Player
|
|
70
70
|
reset_votes
|
71
71
|
end
|
72
72
|
|
73
|
+
# Operating systems where this player should work
|
74
|
+
def platforms
|
75
|
+
[:mac, :windows, :linux, :unix]
|
76
|
+
end
|
77
|
+
|
73
78
|
|
74
79
|
private
|
75
80
|
|
@@ -46,7 +46,13 @@ class Anyplayer::Amarok < Anyplayer::Player
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def launched?
|
49
|
-
not %x(qdbus org.kde.amarok 2>&1).match(
|
49
|
+
not %x(qdbus org.kde.amarok 2>&1).match(
|
50
|
+
/does not exist|not found|cannot find the path specified/
|
51
|
+
)
|
52
|
+
end
|
53
|
+
|
54
|
+
def platforms
|
55
|
+
[:unix, :linux]
|
50
56
|
end
|
51
57
|
|
52
58
|
|
@@ -51,14 +51,18 @@ class Anyplayer::ItunesMac < Anyplayer::Player
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def launched?
|
54
|
-
|
55
|
-
nb.match(/^\d+/) and nb.to_i > 0 ? true : false
|
54
|
+
%x(osascript -e 'app "iTunes" is running').rstrip == "true"
|
56
55
|
end
|
57
56
|
|
58
57
|
def name
|
59
58
|
"iTunes Mac"
|
60
59
|
end
|
61
60
|
|
61
|
+
def platforms
|
62
|
+
[:mac]
|
63
|
+
end
|
64
|
+
|
65
|
+
|
62
66
|
private
|
63
67
|
|
64
68
|
def itunes(command)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
begin
|
2
2
|
require 'win32ole'
|
3
3
|
rescue LoadError => e
|
4
|
-
raise LoadError.new("#{e.message}
|
4
|
+
raise LoadError.new("#{e.message} - You probably aren't on Windows")
|
5
5
|
end
|
6
6
|
|
7
7
|
class Anyplayer::ItunesWindows < Anyplayer::Player
|
@@ -59,6 +59,10 @@ class Anyplayer::ItunesWindows < Anyplayer::Player
|
|
59
59
|
"iTunes Windows"
|
60
60
|
end
|
61
61
|
|
62
|
+
def platforms
|
63
|
+
[:windows]
|
64
|
+
end
|
65
|
+
|
62
66
|
|
63
67
|
private
|
64
68
|
|
@@ -2,10 +2,9 @@
|
|
2
2
|
begin
|
3
3
|
require 'ruby-mpd'
|
4
4
|
rescue LoadError => e
|
5
|
-
raise LoadError.new "#{e.message} —
|
5
|
+
raise LoadError.new "#{e.message} — Please install the ruby-mpd gem"
|
6
6
|
end
|
7
7
|
|
8
|
-
|
9
8
|
class Anyplayer::Mpd < Anyplayer::Player
|
10
9
|
def initialize
|
11
10
|
@mpc = false
|
@@ -51,14 +51,17 @@ class Anyplayer::RdioMac < Anyplayer::Player
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def launched?
|
54
|
-
|
55
|
-
nb.match(/^\d+/) and nb.to_i > 0 ? true : false
|
54
|
+
%x(osascript -e 'app "rdio" is running').rstrip == "true"
|
56
55
|
end
|
57
56
|
|
58
57
|
def name
|
59
58
|
"Rdio Mac"
|
60
59
|
end
|
61
60
|
|
61
|
+
def platforms
|
62
|
+
[:mac]
|
63
|
+
end
|
64
|
+
|
62
65
|
|
63
66
|
private
|
64
67
|
|
@@ -51,18 +51,21 @@ class Anyplayer::SpotifyMac < Anyplayer::Player
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def launched?
|
54
|
-
|
55
|
-
nb.match(/^\d+/) and nb.to_i > 0 ? true : false
|
54
|
+
%x(osascript -e 'app "Spotify" is running').rstrip == "true"
|
56
55
|
end
|
57
56
|
|
58
57
|
def name
|
59
58
|
"Spotify Mac"
|
60
59
|
end
|
61
60
|
|
61
|
+
def platforms
|
62
|
+
[:mac]
|
63
|
+
end
|
64
|
+
|
62
65
|
|
63
66
|
private
|
64
67
|
|
65
68
|
def spotify(command)
|
66
|
-
%x(osascript -e 'tell app "
|
69
|
+
%x(osascript -e 'tell app "Spotify" to #{command}').rstrip
|
67
70
|
end
|
68
71
|
end
|
data/lib/anyplayer/selector.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require "rbconfig"
|
2
|
+
|
1
3
|
# The Selector is the tool that will find you the currently running player on your platform
|
2
4
|
#
|
3
5
|
# Example:
|
@@ -7,62 +9,93 @@
|
|
7
9
|
# player = selector.player
|
8
10
|
#
|
9
11
|
# Needs the PLAYERS constant to contain a list of players.
|
12
|
+
module Anyplayer
|
13
|
+
class Selector
|
14
|
+
attr_accessor :verbose
|
15
|
+
attr_reader :errors
|
10
16
|
|
11
|
-
|
12
|
-
|
13
|
-
|
17
|
+
def initialize
|
18
|
+
@verbose = false
|
19
|
+
@errors = []
|
20
|
+
end
|
14
21
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
22
|
+
# Returns an instance of the first music player that's launched
|
23
|
+
def player
|
24
|
+
PLAYERS.each do |player|
|
25
|
+
player_load(player) or next
|
19
26
|
|
20
|
-
|
21
|
-
|
22
|
-
players_for_this_platform.each { |player|
|
23
|
-
player_load(player) or next
|
24
|
-
instance = player_class(player).new
|
25
|
-
return instance if player_launched(instance)
|
26
|
-
}
|
27
|
-
nil
|
28
|
-
end
|
27
|
+
instance = player_class(player).new
|
28
|
+
player_on_platform?(instance) or next
|
29
29
|
|
30
|
+
if player_launched?(instance)
|
31
|
+
return instance
|
32
|
+
end
|
33
|
+
end
|
34
|
+
nil
|
35
|
+
end
|
30
36
|
|
31
|
-
private
|
32
37
|
|
33
|
-
|
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
|
38
|
+
private
|
39
39
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
40
|
+
def platform
|
41
|
+
@platform ||= begin
|
42
|
+
host_os = RbConfig::CONFIG["host_os"]
|
43
|
+
case host_os
|
44
|
+
when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
|
45
|
+
:windows
|
46
|
+
when /darwin|mac os/
|
47
|
+
:mac
|
48
|
+
when /linux/
|
49
|
+
:linux
|
50
|
+
when /solaris|bsd/
|
51
|
+
:unix
|
52
|
+
else
|
53
|
+
@errors << "Unknown operating system #{host_os.inspect}"
|
54
|
+
nil
|
55
|
+
end
|
56
|
+
end
|
49
57
|
end
|
50
|
-
end
|
51
58
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
59
|
+
def player_load(player)
|
60
|
+
log "#{player}:"
|
61
|
+
begin
|
62
|
+
require "anyplayer/players/#{player}"
|
63
|
+
log " loaded"
|
64
|
+
true
|
65
|
+
rescue LoadError => e
|
66
|
+
log " #{e.message}"
|
67
|
+
@errors << "Error loading #{player}: #{e.message}"
|
68
|
+
false
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def player_on_platform?(player)
|
73
|
+
result = player.platforms.include?(platform)
|
74
|
+
log " not on platform" if !result
|
75
|
+
result
|
76
|
+
end
|
56
77
|
|
57
|
-
|
58
|
-
|
78
|
+
def player_class(player)
|
79
|
+
camelized = player.to_s.split(/_/).map{ |word| word.capitalize }.join
|
80
|
+
Anyplayer::const_get(camelized)
|
81
|
+
end
|
82
|
+
|
83
|
+
def player_launched?(player)
|
84
|
+
seconds = 5
|
85
|
+
begin
|
86
|
+
Timeout::timeout(seconds) do
|
87
|
+
launched = player.launched?
|
88
|
+
log launched ? " launched" : " not launched"
|
89
|
+
launched
|
90
|
+
end
|
91
|
+
rescue Timeout::Error
|
92
|
+
log " timed out after #{seconds} seconds"
|
93
|
+
false
|
94
|
+
end
|
95
|
+
end
|
59
96
|
|
60
|
-
|
61
|
-
|
62
|
-
Timeout::timeout(seconds) { player.launched? }
|
63
|
-
rescue Timeout::Error
|
64
|
-
$stderr.puts "Timed out after #{seconds} seconds" if verbose
|
65
|
-
false
|
97
|
+
def log(text)
|
98
|
+
$stderr.puts text if verbose
|
66
99
|
end
|
67
100
|
end
|
68
101
|
end
|
data/lib/anyplayer/version.rb
CHANGED
data/test/selector_test.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.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sunny Ripert
|
@@ -9,48 +9,62 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2015-06-28 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
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rake
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - '>='
|
54
68
|
- !ruby/object:Gem::Version
|
55
69
|
version: '0'
|
56
70
|
description: Play/pause/skip songs in iTunes Mac, iTunes Windows, Spotify Mac, Rdio
|
@@ -63,10 +77,11 @@ executables:
|
|
63
77
|
extensions: []
|
64
78
|
extra_rdoc_files: []
|
65
79
|
files:
|
66
|
-
-
|
67
|
-
-
|
68
|
-
-
|
80
|
+
- .envrc
|
81
|
+
- .gitignore
|
82
|
+
- .travis.yml
|
69
83
|
- CHANGELOG.md
|
84
|
+
- CONTRIBUTING.md
|
70
85
|
- Gemfile
|
71
86
|
- Gemfile.lock
|
72
87
|
- MIT-LICENSE
|
@@ -104,17 +119,17 @@ require_paths:
|
|
104
119
|
- lib
|
105
120
|
required_ruby_version: !ruby/object:Gem::Requirement
|
106
121
|
requirements:
|
107
|
-
- -
|
122
|
+
- - '>='
|
108
123
|
- !ruby/object:Gem::Version
|
109
124
|
version: '0'
|
110
125
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
126
|
requirements:
|
112
|
-
- -
|
127
|
+
- - '>='
|
113
128
|
- !ruby/object:Gem::Version
|
114
129
|
version: '0'
|
115
130
|
requirements: []
|
116
131
|
rubyforge_project:
|
117
|
-
rubygems_version: 2.
|
132
|
+
rubygems_version: 2.4.5
|
118
133
|
signing_key:
|
119
134
|
specification_version: 4
|
120
135
|
summary: Interact with the running music player
|