spotify_osx_controller 2.0.1 → 2.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b8c09b2e7939824e408a91b99bdb58a8ceaa3c2d
4
- data.tar.gz: 007311e989e00a18310408ef994b158133f4c730
3
+ metadata.gz: 472671d88cff5d0ba3919bc94641e730dde3a966
4
+ data.tar.gz: 1ed10f8288b908033b19fc228708c4af6fbe4e63
5
5
  SHA512:
6
- metadata.gz: c6718440324ca8d12ea1d60c206c63e568d3c9cff2a468fbcef9dedcf883761793371cbae05cee0805f98278625ebcaa2a61b8805f7bcae81a9dfc3a679856a2
7
- data.tar.gz: b254ce9cc76bb18f4ec5f4a8c9984a405631212176775f23bbf79230e5b5b28fd059591ea621df5e9c9c30e2a4d5d6019374ca5747569cba45db0bbdf8b0aed9
6
+ metadata.gz: 6dabf9970dd4f0f6fff2749807d41dace3603544ca76bc10a9ef3000d3f79a716a555716564f31f658176f1a2900e2040980d36e634d76863bae387a61719068
7
+ data.tar.gz: 12ba5c342ab4277a71a1a913b314941e2d4a73d93f46678e54367472ed1da5cf3a64ff3593b271576dc477654c72547c88694ae055bf4fb1cdd6a0bb24b6c1c8
@@ -47,16 +47,27 @@ def global_cmds (opts)
47
47
  end
48
48
  end
49
49
 
50
+ def parse (array)
51
+ array.join('+') if array
52
+ end
53
+
54
+
50
55
 
51
56
  cmd = ARGV.shift
52
57
  case cmd
53
58
  when "play"
54
59
  cmd_opts = Trollop::options do
55
- opt :track, "Track to play", type: :strings, short: 't', default: []
56
- opt :artist, "Artist to play", type: :strings, short: 'a', default: []
57
- opt :album, "Album to play", type: :strings, short: 'A', default: []
60
+ opt :track, "Track to play", type: :strings, short: 't', default: nil
61
+ opt :artist, "Artist to play", type: :strings, short: 'a', default: nil
62
+ opt :album, "Album to play", type: :strings, short: 'A', default: nil
58
63
  end
59
- SpotifyOsxController.play track: cmd_opts[:track], artist: cmd_opts[:artist], album: cmd_opts[:album]
64
+
65
+ params = Hash.new
66
+ params[:track] = parse(cmd_opts[:track]) if cmd_opts[:track]
67
+ params[:artist] = parse(cmd_opts[:artist]) if cmd_opts[:artist]
68
+ params[:album] = parse(cmd_opts[:album]) if cmd_opts[:album]
69
+
70
+ SpotifyOsxController.play params
60
71
  when "play-pause"
61
72
  SpotifyOsxController.play_pause
62
73
  when "stop"
@@ -5,9 +5,9 @@ module SpotifyOsxController
5
5
  class Search
6
6
 
7
7
  def initialize (parameters = {})
8
- @track = parse parameters[:track]
9
- @artist = parse parameters[:artist]
10
- @album = parse parameters[:album]
8
+ @track = parameters[:track]
9
+ @artist = parameters[:artist]
10
+ @album = parameters[:album]
11
11
  @query = construct_query
12
12
  @results = run_query
13
13
  end
@@ -23,22 +23,18 @@ module SpotifyOsxController
23
23
  private
24
24
 
25
25
  def run_query ()
26
- if @track.empty?
26
+ if !@track
27
27
  RSpotify::Album.search @query
28
28
  else
29
29
  RSpotify::Track.search @query
30
30
  end
31
31
  end
32
32
 
33
- def parse (array)
34
- array.join('+') if array
35
- end
36
-
37
33
  def construct_query
38
34
  query = ""
39
- query += "artist:#{@artist} " if !@artist.empty?
40
- query += "track:#{@track} " if !@track.empty?
41
- query += "album:#{@album}" if !@album.empty?
35
+ query += "artist:#{@artist} " if @artist
36
+ query += "track:#{@track} " if @track
37
+ query += "album:#{@album}" if @album
42
38
  query
43
39
  end
44
40
  end
@@ -1,3 +1,3 @@
1
1
  module SpotifyOsxController
2
- VERSION = "2.0.1"
2
+ VERSION = "2.0.2"
3
3
  end
@@ -4,10 +4,11 @@ require "spotify_osx_controller/search.rb"
4
4
  module SpotifyOsxController
5
5
 
6
6
  def self.play(parameters = {})
7
- if !parameters.values.all? &:empty?
7
+ if !parameters.empty?
8
8
  search = Search.new(parameters)
9
9
 
10
10
  if search.any?
11
+ puts search.first
11
12
  uri = search.first.uri
12
13
  buildScript "tell application \"Spotify\" to play track \"#{uri}\"\n"
13
14
  else
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spotify_osx_controller
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Swensson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-21 00:00:00.000000000 Z
11
+ date: 2016-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: trollop