muzak 0.3.8 → 0.3.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/COMMANDS.md +33 -0
- data/bin/muzakd +0 -1
- data/lib/muzak.rb +1 -1
- data/lib/muzak/cmd/index.rb +14 -0
- data/lib/muzak/config.rb +1 -1
- data/lib/muzak/index.rb +28 -8
- data/lib/muzak/instance.rb +4 -6
- data/lib/muzak/plugin.rb +4 -1
- data/lib/muzak/plugin/stub_plugin.rb +5 -0
- 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: c8e7f564cf871bb52f85bee9f9ce174955f5cb8b
|
4
|
+
data.tar.gz: 34f79d424c5d0ff80141d5b7469bbec26a8f2490
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 117f0feb185eed6a940db827d565580a4e274bfe30bc448c7ad54c0aaca8e088b349947be63c6aa3b140ec3366dda053aa525d467ea3245a1557ac5968c2bad5
|
7
|
+
data.tar.gz: 65c7640651c2bba52a89499db61da01819911d625ecddf480831cd01db6bdfdc6104467b73c33669c562ddafa466a282511cc01de173dca69670f9f68d1696b4
|
data/COMMANDS.md
CHANGED
@@ -938,6 +938,39 @@ $ muzak-cmd quit
|
|
938
938
|
}
|
939
939
|
```
|
940
940
|
|
941
|
+
## `reload-index`
|
942
|
+
|
943
|
+
Reloads muzak's in-memory index.
|
944
|
+
|
945
|
+
**Note:** This does *not* rebuild the index file - `muzak-index` is provided
|
946
|
+
as a command line utility for that.
|
947
|
+
|
948
|
+
### Syntax
|
949
|
+
|
950
|
+
`reload-index`
|
951
|
+
|
952
|
+
### Example
|
953
|
+
|
954
|
+
```bash
|
955
|
+
$ muzak-cmd reload-index
|
956
|
+
```
|
957
|
+
|
958
|
+
### Example Response
|
959
|
+
|
960
|
+
```json
|
961
|
+
{
|
962
|
+
"response" : {
|
963
|
+
"error" : null,
|
964
|
+
"data" : {
|
965
|
+
"artist_count" : 262,
|
966
|
+
"album_count" : 1161,
|
967
|
+
"deep" : true
|
968
|
+
},
|
969
|
+
"method" : "reload_index"
|
970
|
+
}
|
971
|
+
}
|
972
|
+
```
|
973
|
+
|
941
974
|
## `shuffle-queue`
|
942
975
|
|
943
976
|
Shuffles the player's playback queue.
|
data/bin/muzakd
CHANGED
data/lib/muzak.rb
CHANGED
data/lib/muzak/cmd/index.rb
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
module Muzak
|
2
2
|
module Cmd
|
3
|
+
# Reload the active index from the index file.
|
4
|
+
# @note This does *not* rebuild the index.
|
5
|
+
# @command `reload-index`
|
6
|
+
# @cmdexample `muzak> reload-index`
|
7
|
+
def reload_index
|
8
|
+
index.reload!
|
9
|
+
|
10
|
+
build_response data: {
|
11
|
+
artist_count: index.artists.size,
|
12
|
+
album_count: index.albums.size,
|
13
|
+
deep: index.deep?,
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
3
17
|
# List all artists in the index.
|
4
18
|
# @command `list-artists`
|
5
19
|
# @cmdexample `muzak> list-artists`
|
data/lib/muzak/config.rb
CHANGED
@@ -94,7 +94,7 @@ module Muzak
|
|
94
94
|
end
|
95
95
|
|
96
96
|
# @return [Boolean] whether or not the given plugin is configured
|
97
|
-
# @note the truth-value of this method is used to determine which
|
97
|
+
# @note the truth-value of this method is used in part to determine which
|
98
98
|
# plugins should be loaded.
|
99
99
|
def self.plugin?(pname)
|
100
100
|
respond_to? "plugin_#{pname}"
|
data/lib/muzak/index.rb
CHANGED
@@ -12,6 +12,9 @@ module Muzak
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
+
# @return [String] the path of the index data file
|
16
|
+
attr_accessor :file
|
17
|
+
|
15
18
|
# @return [String] the path of the root of the music tree
|
16
19
|
attr_accessor :tree
|
17
20
|
|
@@ -20,18 +23,22 @@ module Muzak
|
|
20
23
|
|
21
24
|
# @param file [String] the path of the index data file
|
22
25
|
def initialize(file: Config::INDEX_FILE)
|
23
|
-
debug "loading index from '#{
|
26
|
+
debug "loading index from '#{file}'..."
|
27
|
+
|
28
|
+
@file = file
|
24
29
|
|
25
30
|
@hash = Marshal.load(File.read file)
|
26
31
|
|
27
|
-
|
28
|
-
|
32
|
+
memoize_collections!
|
33
|
+
end
|
29
34
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
+
# Refresh the {Index} instance's state from the index data file.
|
36
|
+
# @note This method does *not* rebuild the index data file.
|
37
|
+
# @return [void]
|
38
|
+
def reload!
|
39
|
+
debug "reloading index from '#{file}'..."
|
40
|
+
@hash = Marshal.load(File.read file)
|
41
|
+
memoize_collections!
|
35
42
|
end
|
36
43
|
|
37
44
|
# @return [Boolean] whether or not the current index is deep
|
@@ -132,5 +139,18 @@ module Muzak
|
|
132
139
|
[]
|
133
140
|
end
|
134
141
|
end
|
142
|
+
|
143
|
+
# Create some frequently accessed collections to speed things up a bit.
|
144
|
+
# @return [void]
|
145
|
+
# @api private
|
146
|
+
def memoize_collections!
|
147
|
+
@all_albums = @hash["artists"].map { |_, a| a["albums"] }.flatten
|
148
|
+
|
149
|
+
if deep?
|
150
|
+
@all_deep_songs = @all_albums.map { |aa| aa.map { |_, a| a["deep-songs"] } }.flatten
|
151
|
+
else
|
152
|
+
@all_songs = @all_albums.map { |aa| aa.map { |_, a| a["songs"] } }.flatten
|
153
|
+
end
|
154
|
+
end
|
135
155
|
end
|
136
156
|
end
|
data/lib/muzak/instance.rb
CHANGED
@@ -64,12 +64,10 @@ module Muzak
|
|
64
64
|
return unless Config::PLUGIN_EVENTS.include?(type)
|
65
65
|
|
66
66
|
plugins.each do |plugin|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
error "something went wrong in #{plugin.class.plugin_name}: #{e}"
|
72
|
-
end
|
67
|
+
begin
|
68
|
+
Thread.new { plugin.send(type, *args) }
|
69
|
+
rescue => e
|
70
|
+
error "something went wrong in #{plugin.class.plugin_name}: #{e}"
|
73
71
|
end
|
74
72
|
end
|
75
73
|
end
|
data/lib/muzak/plugin.rb
CHANGED
@@ -26,7 +26,10 @@ module Muzak
|
|
26
26
|
# Instantiates all configured plugins and returns them.
|
27
27
|
# @return [Array<StubPlugin>] the instantiated plugins
|
28
28
|
def self.load_plugins!
|
29
|
-
pks = PLUGIN_CLASSES.select
|
29
|
+
pks = PLUGIN_CLASSES.select do |pk|
|
30
|
+
Config.plugin?(pk.plugin_name) && pk.available?
|
31
|
+
end
|
32
|
+
|
30
33
|
pks.map { |pk| pk.new }
|
31
34
|
end
|
32
35
|
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.9
|
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-02-
|
11
|
+
date: 2017-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: taglib-ruby
|