anyplayer 1.1.1 → 1.2.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 1a9384589559bf8cb5d5296227003b72bbb33ca5970577a35d947cc6edbf7f9c
4
+ data.tar.gz: 2efd1d446b28792bace849ff9860a64150d20884b2e4624f7cc66aa74da8bfc7
5
+ SHA512:
6
+ metadata.gz: 42d4c7c05065c140bc28d77c45e30efb07868f7292d78e676b651314ddefe00204c0f0d9e2c7cc828d06408a3c0d7a1da57fbb3ba89b90c961420d7a7ea8064a
7
+ data.tar.gz: 4eafc888d550338ce4bad1792a1b0b83368463640c4cc28de49e5491a99a374d080c757420128d7647c8aa351b9ec84538323e48f96f91a3d9dd93b27f2bb5b4
data/.gitignore CHANGED
@@ -1,4 +1,4 @@
1
1
  pkg/*
2
2
  *.gem
3
3
  *.bundle
4
-
4
+ Gemfile.lock
@@ -0,0 +1 @@
1
+ 2.7.1
@@ -1,4 +1,3 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.9.3
4
- - 2.0.0
3
+ - 2.7.0
@@ -0,0 +1,76 @@
1
+ Changelog
2
+ ---------
3
+
4
+ Anyplayer tries its best to follow Semantic Versioning.
5
+
6
+ ## Unreleased
7
+
8
+ ## v1.2.0 (2020-10-08)
9
+
10
+ Features:
11
+
12
+ - When using mpd, fallback to the file name if there is no track name.
13
+
14
+ Dependencies:
15
+
16
+ - Drop Ruby 1.9.3 and 2.0.0 support.
17
+
18
+ ## v1.1.5 (2014-07-07)
19
+
20
+ Bugfixes:
21
+
22
+ - Better platform detection by letting players list the platforms
23
+ they are intended to work on (thanks @inspire22)
24
+
25
+ ## v1.1.4 (2014-07-07)
26
+
27
+ Bugfixes:
28
+
29
+ - Fix iTunes Windows support by moving iTunes first
30
+ - New developement task "rake console"
31
+ - Refactorisations & tests
32
+
33
+ ## v1.1.3 (2014-01-27)
34
+
35
+ Bugfixes:
36
+
37
+ - xmms2.0.8 support (thanks @ofa-)
38
+
39
+ ## v1.1.2 (2013-12-18)
40
+
41
+ Bugfixes:
42
+
43
+ - MIT License
44
+
45
+ ## v1.1.1 (2013-12-18)
46
+
47
+ Bugfixes:
48
+
49
+ - Better MPD support (thanks @nkoehring)
50
+ - Encoding fixes
51
+
52
+ ## v1.1.0 (2013-10-27)
53
+
54
+ Features:
55
+
56
+ - Add Rdio Mac support (thanks @irosenb)
57
+
58
+ ## v1.0.0 (2013-07-26)
59
+
60
+ First major release.
61
+
62
+ ## v0.0.4
63
+
64
+ Unstable version.
65
+
66
+ ## v0.0.3
67
+
68
+ Unstable version.
69
+
70
+ ## v0.0.2
71
+
72
+ Unstable version.
73
+
74
+ ## v0.0.1
75
+
76
+ Unstable version.
@@ -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
@@ -1,7 +1,5 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- gem "rake"
4
-
5
3
  # Gem dependencies in anyplayer.gemspec
6
4
  gemspec
7
5
 
@@ -0,0 +1,20 @@
1
+ Copyright 2013 Sunny Ripert
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -43,8 +43,17 @@ a player is running
43
43
  Or in Ruby
44
44
  ----------
45
45
 
46
+ In your Gemfile:
47
+
48
+ ```rb
49
+ # Interact with the current music player
50
+ gem "anyplayer"
51
+ ```
52
+
53
+ In your code:
54
+
46
55
  ```ruby
47
- require 'anyplayer'
56
+ require "anyplayer"
48
57
  player = Anyplayer::Selector.new.player
49
58
 
50
59
  player.launched? # => true
@@ -62,25 +71,22 @@ With the [So Nice](https://github.com/sunny/so-nice/) Web interface:
62
71
  ![So Nice Screenshot](https://github.com/sunny/so-nice/raw/gh-pages/screenshot.png)
63
72
 
64
73
 
65
- Development
74
+ Contribute!
66
75
  -----------
67
76
 
68
- Depending on your configuration you may need to add `bundle exec` to the following commands.
77
+ 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
78
 
70
- Terminal binary from source:
79
+ Here a few useful commands while developping:
71
80
 
72
81
  ```sh
73
- $ ruby -Ilib bin/anyplayer
82
+ $ ruby -Ilib bin/anyplayer # Use the anyplayer command-line from source
83
+ $ bin/rake test # Launch tests
84
+ $ bin/rake install # Install from source
85
+ $ bin/rake console # Launch console
74
86
  ```
75
87
 
76
- Tests:
77
-
78
- ```sh
79
- $ rake test
80
- ```
81
88
 
82
- Install from source:
89
+ License
90
+ -------
83
91
 
84
- ```sh
85
- $ rake install
86
- ```
92
+ MIT
data/Rakefile CHANGED
@@ -7,6 +7,16 @@ task :default => :test
7
7
 
8
8
  Rake::TestTask.new do |t|
9
9
  t.libs << "test"
10
+ t.libs << "lib"
10
11
  t.pattern = "test/**/*_test.rb"
11
12
  t.verbose = true
12
13
  end
14
+
15
+ # Via http://erniemiller.org/2014/02/05/7-lines-every-gems-rakefile-should-have/
16
+ task :console do
17
+ require 'irb'
18
+ require 'irb/completion'
19
+ require 'anyplayer'
20
+ ARGV.clear
21
+ IRB.start
22
+ end
@@ -11,6 +11,7 @@ Gem::Specification.new do |s|
11
11
  s.homepage = "http://github.com/sunny/anyplayer"
12
12
  s.summary = %q{Interact with the running music player}
13
13
  s.description = %q{Play/pause/skip songs in iTunes Mac, iTunes Windows, Spotify Mac, Rdio Mac, MPD, Rhythmbox, Amarok and XMMS2}
14
+ s.license = 'MIT'
14
15
 
15
16
  s.files = `git ls-files`.split("\n")
16
17
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -18,6 +19,8 @@ Gem::Specification.new do |s|
18
19
  s.require_paths = ["lib"]
19
20
 
20
21
  s.add_runtime_dependency 'ruby-mpd', '~> 0.3.0'
22
+
21
23
  s.add_development_dependency 'minitest'
22
24
  s.add_development_dependency 'flexmock'
25
+ s.add_development_dependency 'rake'
23
26
  end
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rake' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("rake", "rake")
@@ -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
  )
@@ -20,4 +27,3 @@ end
20
27
  require "anyplayer/player"
21
28
  require "anyplayer/selector"
22
29
  require "anyplayer/version"
23
-
@@ -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.pop
31
+ argv.shift
13
32
 
14
33
  $stderr.puts "anyplayer v#{Anyplayer::VERSION}"
15
34
  end
@@ -18,36 +37,47 @@ 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 it
22
- case argv.first
23
- when "playpause" then player.playpause
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
- puts <<USAGE
41
- Usage: anyplayer [-v] [command]
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.
48
+ private
45
49
 
46
- Player connected: #{player.name}.
47
- USAGE
48
- exit(1)
50
+ # Call
51
+ def command(player, command)
52
+ response = call(player, command)
53
+
54
+ case response
55
+ when :undefined_command then usage(player)
56
+ when true then exit(0)
57
+ when false then exit(1)
58
+ when String, Numeric then puts response
59
+ end
60
+ end
61
+
62
+ # Call the method on the player
63
+ # Tries the boolean method as well
64
+ def call(player, command)
65
+ [command, "#{command}?"].each do |method|
66
+ method = method.to_sym
67
+ return player.send(method) if player.respond_to?(method)
49
68
  end
50
69
 
70
+ :undefined_command
51
71
  end
52
72
 
73
+ def usage(player)
74
+ $stderr.puts <<USAGE
75
+ Usage: anyplayer [-v] [command]
76
+
77
+ Where command is one of: #{COMMANDS.join(', ')}.
78
+
79
+ Player connected: #{player.name}.
80
+ USAGE
81
+ exit(1)
82
+ end
53
83
  end
@@ -1,4 +1,4 @@
1
- # Default Player class that is inherrited by all players.
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)
@@ -31,7 +31,12 @@ class Anyplayer::Player
31
31
  # Example:
32
32
  # player.name # => iTunes
33
33
  def name
34
- self.class.to_s.gsub(/^.*::/, '')
34
+ self.class.to_s.gsub(/^.*::/, "")
35
+ end
36
+
37
+ # Default paused is not playing
38
+ def paused?
39
+ !playing?
35
40
  end
36
41
 
37
42
  # Tells the player to toggle the pause state
@@ -65,11 +70,14 @@ class Anyplayer::Player
65
70
  reset_votes
66
71
  end
67
72
 
68
- private
73
+ # Operating systems where this player should work
74
+ def platforms
75
+ [:mac, :windows, :linux, :unix]
76
+ end
69
77
 
70
- def reset_votes
71
- @votes = 0
72
- end
78
+ private
73
79
 
80
+ def reset_votes
81
+ @votes = 0
82
+ end
74
83
  end
75
-