muzak 0.2.6 → 0.2.7

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: 684cfddb194c4ee5a540002d298a9a2cfbf58103
4
- data.tar.gz: e6ce386617717a7ded0ed2f8f736f2a68052f805
3
+ metadata.gz: b64a222cbd2a691404714a63b195ee2a78bb82b3
4
+ data.tar.gz: 8d5547a8facf37798f822e53c97d9070dd29b6aa
5
5
  SHA512:
6
- metadata.gz: 196bc4a565223cc1d49b7876c959ac2e806869e80c9bf5bf89c4ceb7f802f26a91fe92454ca348b89ac8114ce01e641a6388652bb961e8218c16a046d064bfa3
7
- data.tar.gz: '09d1c8cd2349ae4d6c2e91829a0c02bb9140cf20eb66537116dd280dad593acf4e533fa09e7ca8f5031cb1372c406135646696ee1b1159314c28386931c61b40'
6
+ metadata.gz: 999969bedb0fb6d2ea42fa856266702f2464207d6e3480eaccf8cad09f69b260e7981e8c7dc119cf0e02dfba0a9bf821230c1f8eb199137f9739e1d8866fa772
7
+ data.tar.gz: db562a2611427925e9c2a1621b5d294f6597dba8813647d9035ef7ecc57d8293b90f4f30c53f055b5b22a684ba418e0e2ecf9a5606c1a3268af47bb0d3144cf6
@@ -10,17 +10,13 @@ module Muzak
10
10
  # @return [String] the path to the album's cover art
11
11
  attr_reader :cover_art
12
12
 
13
- # @note instead of passing an album hash directly from the index, this
14
- # should really just take a title and an array of Song objects.
15
- def initialize(title, album_hash)
13
+ # @param title [String] the album's title
14
+ # @param songs [Array<Song>] the album's songs
15
+ # @param cover_art [String] the album's cover art
16
+ def initialize(title, songs, cover_art = nil)
16
17
  @title = title
17
- @cover_art = album_hash["cover"]
18
-
19
- unless album_hash["deep-songs"].empty?
20
- @songs = album_hash["deep-songs"]
21
- else
22
- @songs = album_hash["songs"].map { |s| Song.new(s) }
23
- end
18
+ @songs = songs
19
+ @cover_art = cover_art
24
20
  end
25
21
  end
26
22
  end
@@ -1,6 +1,6 @@
1
1
  module Muzak
2
2
  # Muzak's current version
3
- VERSION = "0.2.6".freeze
3
+ VERSION = "0.2.7".freeze
4
4
 
5
5
  # The root directory for all user configuration, data, etc
6
6
  CONFIG_DIR = File.expand_path("~/.config/muzak").freeze
@@ -19,6 +19,8 @@ module Muzak
19
19
 
20
20
  # @param index_file [String] the path of the index data file
21
21
  def initialize(file: INDEX_FILE)
22
+ debug "loading index from '#{INDEX_FILE}'..."
23
+
22
24
  @hash = Marshal.load(File.read file)
23
25
  end
24
26
 
@@ -45,7 +47,12 @@ module Muzak
45
47
 
46
48
  artists.each do |a|
47
49
  @hash["artists"][a]["albums"].each do |title, album_hash|
48
- albums_hash[title] = Album.new(title, album_hash)
50
+ if deep?
51
+ songs = album_hash["deep-songs"]
52
+ else
53
+ songs = album_hash["songs"].map { |s| Song.new(s) }
54
+ end
55
+ albums_hash[title] = Album.new(title, songs, album_hash["cover"])
49
56
  end
50
57
  end
51
58
 
@@ -64,7 +71,14 @@ module Muzak
64
71
  # @return [Array<Album>] all albums by the given artist
65
72
  def albums_by(artist)
66
73
  if artists.include?(artist)
67
- @hash["artists"][artist]["albums"].map { |title, album| Album.new(title, album) }
74
+ @hash["artists"][artist]["albums"].map do |title, album_hash|
75
+ if deep?
76
+ songs = album_hash["deep-songs"]
77
+ else
78
+ songs = album_hash["songs"].map { |s| Song.new(s) }
79
+ end
80
+ Album.new(title, songs, album_hash["cover"])
81
+ end
68
82
  else
69
83
  error "no such artist: '#{artist}'" unless @hash["artists"].key?(artist)
70
84
  []
@@ -170,8 +170,6 @@ module Muzak
170
170
  # Get mpv's currently loaded song.
171
171
  # @return [Song, nil] the currently loaded song
172
172
  def now_playing
173
- path = @mpv.get_property "path"
174
- return if path&.empty?
175
173
  @_now_playing ||= Song.new(@mpv.get_property "path")
176
174
  end
177
175
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: muzak
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Woodruff
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-15 00:00:00.000000000 Z
11
+ date: 2017-01-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: taglib-ruby