jimmy_jukebox 0.5.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,7 +8,7 @@ module Artists
8
8
  bh: { genre: 'JAZZ', name: "billie_holiday"},
9
9
  bb: { genre: 'JAZZ', name: "bix_beiderbecke"},
10
10
  bm: { genre: 'JAZZ', name: "bennie_moten"},
11
- c: { genre: 'CLASSICAL', name: "chopin"},
11
+ fc: { genre: 'CLASSICAL', name: "chopin"},
12
12
  cc: { genre: 'JAZZ', name: "charlie_christian"},
13
13
  cp: { genre: 'JAZZ', name: "charlie_parker"},
14
14
  ch: { genre: 'JAZZ', name: "coleman_hawkins"},
@@ -0,0 +1,18 @@
1
+ module JimmyJukebox
2
+
3
+ module DisplayOptions
4
+
5
+ def display_options
6
+ puts "'p' = (un)pause, 'q' = quit, 'r' = replay previous song, 's' = skip this song, 'e' = erase this song"
7
+ end
8
+
9
+ def display_options_after_delay
10
+ # pause to let song display song info and begin playing before displaying user options
11
+ sleep 1
12
+ display_options
13
+ end
14
+
15
+ end
16
+
17
+ end
18
+
@@ -1,7 +1,11 @@
1
+ require_relative "display_options"
2
+
1
3
  module JimmyJukebox
2
4
 
3
5
  class Song
4
6
 
7
+ include JimmyJukebox::DisplayOptions
8
+
5
9
  class InvalidSongFormatException < Exception; end
6
10
  class NoPlayingPidException < Exception; end
7
11
  class UnsupportedSongFormatException < Exception; end
@@ -121,9 +125,9 @@ module JimmyJukebox
121
125
  end
122
126
 
123
127
  def play_with_player
124
- puts "Now playing '#{music_file}'"
125
- puts "Press Ctrl-C to stop the music and exit this program"
126
128
  run_command(player, music_file)
129
+ puts "Now playing '#{music_file}'"
130
+ display_options_after_delay
127
131
  Process.waitpid(playing_pid) # Waits for a child process to exit, returns its process id, and sets $? to a Process::Status object
128
132
  $? # return Process::Status object with instance methods .stopped?, .exited?, .exitstatus
129
133
  end
@@ -141,9 +141,9 @@ module JimmyJukebox
141
141
  # puts "ARGV: " + ARGV.inspect + " (" + ARGV.class.to_s + ")"
142
142
  if ARGV.empty?
143
143
  music_directories << default_music_dir
144
- elsif ARGV[0].strip =~ /^jazz$/i
144
+ elsif ARGV[0].strip =~ /^j$/i || ARGV[0].strip =~ /^jazz$/i
145
145
  music_directories << jazz_dir
146
- elsif ARGV[0].strip =~ /^classical$/i
146
+ elsif ARGV[0].strip =~ /^c$/i || ARGV[0].strip =~ /^classical$/i
147
147
  music_directories << classical_dir
148
148
  elsif ARTISTS.keys.include?(ARGV[0].to_sym)
149
149
  music_directories << default_music_dir + artist_key_to_subdir_name(ARGV[0].to_sym)
@@ -18,21 +18,10 @@ end
18
18
 
19
19
  user_input_thread = Thread.new do
20
20
 
21
- def display_options
22
- puts "'p' = (un)pause, 'q' = quit, 'r' = replay previous song, 's' = skip this song, 'e' = erase this song"
23
- end
24
-
25
- def display_options_after_delay
26
- # pause to let song display song info and begin playing before displaying user options
27
- sleep 1
28
- display_options
29
- end
30
-
31
21
  class NoPlayLoopThreadException < Exception; end
32
22
 
33
23
  begin
34
24
  loop do
35
- display_options_after_delay
36
25
  if $running_jruby
37
26
  char = STDIN.getch
38
27
  else
@@ -1,4 +1,4 @@
1
1
  module JimmyJukebox
2
- VERSION = '0.5.2'
2
+ VERSION = '0.5.3'
3
3
  DATE = '2013-03-01'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jimmy_jukebox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -123,6 +123,7 @@ files:
123
123
  - lib/jimmy_jukebox/artists.rb
124
124
  - lib/jimmy_jukebox/song.rb
125
125
  - lib/jimmy_jukebox/jukebox.rb
126
+ - lib/jimmy_jukebox/display_options.rb
126
127
  - lib/jimmy_jukebox/user_config.rb
127
128
  - lib/jimmy_jukebox/user_interface.rb
128
129
  - lib/jimmy_jukebox/song_loader.rb