muzak 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9a2a198cce10bc3f66a9c3c532433f30c4264b30
4
- data.tar.gz: 2e021ffbcbc1d2b16696f010690389c1854b5890
3
+ metadata.gz: b6b8176c9db706a3a44a3bcdd0531cbf4f4bfc06
4
+ data.tar.gz: cc31f821a39863d88a98e3605102e4720e091609
5
5
  SHA512:
6
- metadata.gz: 6fe05e1fb8c85576a9b270144447f45e6c03d7b499f6569290f42c047a878d58c637ae36b8adcad3c8176c048136670ecf1079c6ccc4fa0dd2b09e67c77f17e2
7
- data.tar.gz: cb384c8a927cd5ef336f6eb113c115d7a1d5a7f6e1adf66c16de2fe1559b056192b51d7f63f23478a01ffcf55b9cc67a57cb05981b272b2564906a71cabaadff
6
+ metadata.gz: b2713fafa4ebd9f793c32a33040d021dd78aa475c283b101a141032de2865ca36423832b19432562bddc64f7699e55b489be40e8d7af4a4faad713d4eb163685
7
+ data.tar.gz: 177e33819737a1e629640b721f0540cc9ff7d7f44ebce31bda4acf42d30abaf697b862d2a8afc079c392b1d4b08f79529b631a405f8d5d90a7409c08cf9c3133
data/bin/muzak CHANGED
@@ -18,7 +18,7 @@ COMMANDS = Muzak::Cmd.commands
18
18
  CONFIG_REGEX = /^config-(get)|(set)|(del)/
19
19
  ARTIST_REGEX = Regexp.union COMMANDS.select{ |c| c =~ /artist/ }.map { |c| /^#{c}/ }
20
20
  ALBUM_REGEX = Regexp.union COMMANDS.select{ |c| c =~ /album/ }.map { |c| /^#{c}/ }
21
- PLAYLIST_REGEX = /^playlist-(load)|(delete)/
21
+ PLAYLIST_REGEX = /^playlist-delete/
22
22
 
23
23
  comp = proc do |s|
24
24
  case Readline.line_buffer
@@ -2,6 +2,9 @@ Dir.glob(File.join(__dir__, "cmd/*")) { |f| require_relative f }
2
2
 
3
3
  module Muzak
4
4
  module Cmd
5
+ # load commands included by the user
6
+ Dir.glob(File.join(USER_COMMAND_DIR, "*")) { |file| require file }
7
+
5
8
  def self.resolve_command(cmd)
6
9
  cmd.tr "-", "_"
7
10
  end
@@ -1,7 +1,7 @@
1
1
  module Muzak
2
2
  module Cmd
3
- def _playlist_loaded?
4
- !!@playlist
3
+ def _playlists_loaded?
4
+ !!@playlists
5
5
  end
6
6
 
7
7
  def list_playlists(*args)
@@ -10,14 +10,18 @@ module Muzak
10
10
  end
11
11
  end
12
12
 
13
- def playlist_load(*args)
14
- fail_arity(args, 1)
15
- pname = args.shift
13
+ def playlists_load(*args)
14
+ # fail_arity(args, 1)
15
+ # pname = args.shift
16
+ @playlists = {}
17
+ @playlists.default_proc = proc { |h, k| h[k] = Playlist.new(k) }
16
18
 
17
- info "loading playlist '#{pname}'"
18
- @playlist = Playlist.new(pname)
19
+ Playlist.playlist_names.each do |pname|
20
+ debug "loading playlist '#{pname}'"
21
+ @playlists[pname] = Playlist.new(pname)
22
+ end
19
23
 
20
- event :playlist_loaded, @playlist
24
+ event :playlists_loaded, @playlist
21
25
  end
22
26
 
23
27
  def playlist_delete(*args)
@@ -27,18 +31,23 @@ module Muzak
27
31
  debug "deleting playist '#{pname}'"
28
32
 
29
33
  Playlist.delete!(pname)
30
- @playlist = nil
34
+ @playlist[pname] = nil
31
35
  end
32
36
 
33
37
  def enqueue_playlist(*args)
34
- return unless _playlist_loaded?
38
+ return unless _playlists_loaded?
39
+ fail_arity(args, 1)
40
+ pname = args.shift
35
41
 
36
- @player.enqueue_playlist(@playlist)
37
- event :playlist_enqueued, @playlist
42
+ @player.enqueue_playlist(@playlists[pname])
43
+ event :playlist_enqueued, @playlists[pname]
38
44
  end
39
45
 
40
46
  def playlist_add_album(*args)
41
- return unless _playlist_loaded?
47
+ return unless _playlists_loaded?
48
+
49
+ pname = args.shift
50
+ return if pname.nil?
42
51
 
43
52
  album_name = args.join(" ")
44
53
  return if album_name.nil?
@@ -46,34 +55,46 @@ module Muzak
46
55
  album = @index.albums[album_name]
47
56
  return if album.nil?
48
57
 
49
- @playlist.add(album.songs)
58
+ @playlists[pname].add(album.songs)
50
59
  end
51
60
 
52
61
  def playlist_add_artist(*args)
53
- return unless _playlist_loaded?
62
+ return unless _playlists_loaded?
63
+
64
+ pname = args.shift
65
+ return if pname.nil?
54
66
 
55
67
  artist = args.join(" ")
56
68
  return if artist.nil?
57
69
 
58
- @playlist.add(@index.songs_by(artist))
70
+ @playlists[pname].add(@index.songs_by(artist))
59
71
  end
60
72
 
61
73
  def playlist_add_current(*args)
62
- return unless @player.running? && _playlist_loaded?
74
+ return unless @player.running? && _playlists_loaded?
75
+
76
+ pname = args.shift
77
+ return if pname.nil?
63
78
 
64
- @playlist.add @player.now_playing
79
+ @playlists[pname].add @player.now_playing
65
80
  end
66
81
 
67
82
  def playlist_del_current(*args)
68
- return unless @player.running? && _playlist_loaded?
83
+ return unless @player.running? && _playlists_loaded?
69
84
 
70
- @playlist.delete @player.now_playing
85
+ pname = args.shift
86
+ return if pname.nil?
87
+
88
+ @playlists[pname].delete @player.now_playing
71
89
  end
72
90
 
73
91
  def playlist_shuffle(*args)
74
- return unless _playlist_loaded?
92
+ return unless _playlists_loaded?
93
+
94
+ pname = args.shift
95
+ return if pname.nil?
75
96
 
76
- @playlist.shuffle!
97
+ @playlists[pname].shuffle!
77
98
  end
78
99
  end
79
100
  end
@@ -1,17 +1,18 @@
1
1
  module Muzak
2
- VERSION = "0.0.7".freeze
2
+ VERSION = "0.0.8".freeze
3
3
 
4
4
  CONFIG_DIR = File.expand_path("~/.config/muzak").freeze
5
5
  CONFIG_FILE = File.join(CONFIG_DIR, "muzak.yml").freeze
6
6
  INDEX_FILE = File.join(CONFIG_DIR, "index.yml").freeze
7
7
  PLAYLIST_DIR = File.join(CONFIG_DIR, "playlists").freeze
8
8
  USER_PLUGIN_DIR = File.join(CONFIG_DIR, "plugins").freeze
9
+ USER_COMMAND_DIR = File.join(CONFIG_DIR, "commands").freeze
9
10
 
10
11
  PLUGIN_EVENTS = [
11
12
  :player_activated,
12
13
  :player_deactivated,
13
14
  :song_loaded,
14
- :playlist_loaded,
15
+ :playlists_loaded,
15
16
  :playlist_enqueued
16
17
  ]
17
18
  end
@@ -30,8 +30,8 @@ module Muzak
30
30
 
31
31
  @plugins = initialize_plugins!
32
32
 
33
- playlist_load @config["default-playlist"] if @config["default-playlist"]
34
- enqueue_playlist if _playlist_loaded? && @config["autoplay"]
33
+ playlists_load
34
+ enqueue_playlist @config["autoplay"] if @config["autoplay"]
35
35
  end
36
36
 
37
37
  def initialize_plugins!
@@ -31,6 +31,8 @@ module Muzak
31
31
  else
32
32
  @songs = []
33
33
  end
34
+
35
+ sync!
34
36
  end
35
37
 
36
38
  def name
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.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Woodruff
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-13 00:00:00.000000000 Z
11
+ date: 2016-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: taglib-ruby