spotify-dbus 0.3 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/bin/spotify-dbus +11 -6
  2. data/lib/spotify-dbus.rb +14 -12
  3. metadata +4 -4
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'spotify-dbus'
3
3
 
4
- def error msg
4
+ def die msg
5
5
  puts msg
6
6
  exit false
7
7
  end
@@ -9,15 +9,20 @@ end
9
9
  if ARGV.size > 0
10
10
  begin
11
11
  cmd = ARGV.pop
12
- if Spotify.player.methods[cmd]
13
- Spotify.player.send(cmd)
12
+ player = SpotifyDBus.player
13
+
14
+ if player.methods[cmd]
15
+ player.send(cmd)
16
+
14
17
  else
15
- error "Invalid command!"
18
+ die "Invalid command!"
19
+
16
20
  end
17
21
  rescue
18
- error "Spotify is not running!"
22
+ die "Spotify is not running!"
19
23
  end
24
+
20
25
  else
21
- error "No command given!"
26
+ die "No command given!"
22
27
  end
23
28
 
@@ -1,18 +1,20 @@
1
1
  require 'dbus'
2
2
 
3
- module Spotify
3
+ module SpotifyDBus
4
4
  def self.player
5
- @player ||= player_object
6
- end
5
+ @player ||= find_dbus_object
6
+ end
7
7
 
8
- protected
9
-
10
- def self.player_object
11
- dbus = DBus::SessionBus.instance
12
- service = dbus.service('org.mpris.MediaPlayer2.spotify')
13
- object = service.object('/org/mpris/MediaPlayer2')
14
- object.introspect
8
+ class << self
9
+ def find_dbus_object
10
+ dbus = DBus::SessionBus.instance
11
+ service = dbus.service('org.mpris.MediaPlayer2.spotify')
12
+ object = service.object('/org/mpris/MediaPlayer2')
13
+ object.introspect
15
14
 
16
- object['org.mpris.MediaPlayer2.Player']
17
- end
15
+ object['org.mpris.MediaPlayer2.Player']
16
+ end
17
+
18
+ protected :find_dbus_object
19
+ end
18
20
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spotify-dbus
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.3'
4
+ version: 0.3.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,12 +9,12 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-07-15 00:00:00.000000000 -04:00
12
+ date: 2011-08-10 00:00:00.000000000 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: ruby-dbus
17
- requirement: &24723220 !ruby/object:Gem::Requirement
17
+ requirement: &7672320 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,7 +22,7 @@ dependencies:
22
22
  version: 0.6.0
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *24723220
25
+ version_requirements: *7672320
26
26
  description: Simple module and bin for Spotify DBus interfacing
27
27
  email: mikeycgto@gmail.com
28
28
  executables: