muzak 0.3.6 → 0.3.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/muzak.rb +1 -1
- data/lib/muzak/index.rb +20 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77d8a106e1b6479194813a854372b1623f3bac7b
|
4
|
+
data.tar.gz: 4eb72201a9378ba5ee92c43668009ab314c1e1ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e94f921353d774220411452b8ecd4a49003792d0f0a7a3a96d8cbda3d6d92518e6b50a2c46d1afaf8a7050136ffadc0a069c08857ee0e717bc589e9613262f5d
|
7
|
+
data.tar.gz: 8bb4da0e3c69ad6e319b46db29a21031aec4d55ce6aef2b4ae33dca91dd4d44c7ec488f151b382485a29da7cdfa1e7be96fb1dca5135c5602c0412e3d6a397c9
|
data/lib/muzak.rb
CHANGED
data/lib/muzak/index.rb
CHANGED
@@ -23,6 +23,15 @@ module Muzak
|
|
23
23
|
debug "loading index from '#{Config::INDEX_FILE}'..."
|
24
24
|
|
25
25
|
@hash = Marshal.load(File.read file)
|
26
|
+
|
27
|
+
# create some frequently accessed collections
|
28
|
+
@all_albums = @hash["artists"].map { |_, a| a["albums"] }.flatten
|
29
|
+
|
30
|
+
if deep?
|
31
|
+
@all_deep_songs = @all_albums.map { |aa| aa.map { |_, a| a["deep-songs"] } }.flatten
|
32
|
+
else
|
33
|
+
@all_songs = @all_albums.map { |aa| aa.map { |_, a| a["songs"] } }.flatten
|
34
|
+
end
|
26
35
|
end
|
27
36
|
|
28
37
|
# @return [Boolean] whether or not the current index is deep
|
@@ -61,6 +70,17 @@ module Muzak
|
|
61
70
|
end
|
62
71
|
end
|
63
72
|
|
73
|
+
# @return [Array<Song>] a list of all Song objects in the index
|
74
|
+
# @note This method **requires** a deep index.
|
75
|
+
def songs
|
76
|
+
unless deep?
|
77
|
+
danger "tried to call a deep-index-only method with a shallow index"
|
78
|
+
return []
|
79
|
+
end
|
80
|
+
|
81
|
+
@all_deep_songs
|
82
|
+
end
|
83
|
+
|
64
84
|
# @return [Array<String>] a list of all albums in the index
|
65
85
|
# @note albums with the same name will appear, but can't be disambiguated
|
66
86
|
# from here
|
@@ -90,13 +110,9 @@ module Muzak
|
|
90
110
|
# @param count [Integer] the number of random songs to return
|
91
111
|
# @return [Array<Song>] an array of randomly chosen songs
|
92
112
|
def jukebox(count = 50)
|
93
|
-
@all_albums ||= @hash["artists"].map { |_, a| a["albums"] }.flatten
|
94
|
-
|
95
113
|
if deep?
|
96
|
-
@all_deep_songs ||= @all_albums.map { |aa| aa.map { |_, a| a["deep-songs"] } }.flatten
|
97
114
|
@all_deep_songs.sample(count)
|
98
115
|
else
|
99
|
-
@all_songs ||= @all_albums.map { |aa| aa.map { |_, a| a["songs"] } }.flatten
|
100
116
|
@all_songs.sample(count).map { |s| Song.new(s) }
|
101
117
|
end
|
102
118
|
end
|
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.3.
|
4
|
+
version: 0.3.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-
|
11
|
+
date: 2017-02-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: taglib-ruby
|