songbirdsh 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY.rdoc +15 -0
- data/Rakefile +2 -6
- data/lib/songbirdsh/cli.rb +1 -1
- data/lib/songbirdsh/command.rb +23 -1
- data/lib/songbirdsh/command/enqueue.rb +9 -12
- data/lib/songbirdsh/command/flush.rb +7 -0
- data/lib/songbirdsh/command/list.rb +11 -11
- data/lib/songbirdsh/command/recent.rb +31 -0
- data/lib/songbirdsh/command/reload.rb +4 -12
- data/lib/songbirdsh/command/restart.rb +4 -4
- data/lib/songbirdsh/command/scrobbling.rb +5 -10
- data/lib/songbirdsh/command/search.rb +8 -2
- data/lib/songbirdsh/command/setup_scrobbling.rb +4 -8
- data/lib/songbirdsh/command/show_properties.rb +5 -4
- data/lib/songbirdsh/command/shuffle.rb +8 -10
- data/lib/songbirdsh/command/start.rb +4 -4
- data/lib/songbirdsh/command/status.rb +4 -8
- data/lib/songbirdsh/command/stop.rb +4 -4
- data/lib/songbirdsh/player.rb +11 -8
- data/lib/songbirdsh/range_expander.rb +30 -0
- data/lib/songbirdsh/track.rb +7 -1
- data/spec/songbirdsh/command/enqueue_spec.rb +8 -10
- data/spec/songbirdsh/command/list_spec.rb +27 -0
- data/spec/songbirdsh/command/reload_spec.rb +1 -1
- data/spec/songbirdsh/command/shuffle_spec.rb +27 -0
- data/spec/songbirdsh/player_spec.rb +36 -0
- data/spec/songbirdsh/range_expander_spec.rb +28 -0
- data/spec/spec_helper.rb +3 -1
- metadata +17 -36
data/HISTORY.rdoc
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
= 0.0.5
|
2
|
+
|
3
|
+
Bug fixes, code cleanup and some colour
|
4
|
+
|
5
|
+
* Sorted out crash when listing queue while not playing
|
6
|
+
* Added help to all commands
|
7
|
+
* Added rainbow and added colour to the track display
|
8
|
+
* Changed shuffle behaviour - it now just shuffles current queue
|
9
|
+
* Added flush command
|
10
|
+
* Switched to using bundler to manage gem
|
11
|
+
|
12
|
+
= 0.0.4
|
13
|
+
|
14
|
+
Some minor bug fixes
|
15
|
+
|
1
16
|
= 0.0.3
|
2
17
|
|
3
18
|
Introduced testing, lastfm support and a few other useful commands
|
data/Rakefile
CHANGED
@@ -1,10 +1,6 @@
|
|
1
|
-
|
2
|
-
require 'gemesis/rake'
|
3
|
-
rescue Exception
|
4
|
-
puts "gemesis related tasks will only be available if you 'gem install gemesis'"
|
5
|
-
end
|
1
|
+
require 'bundler/gem_tasks'
|
6
2
|
|
7
3
|
desc 'execute specifications'
|
8
4
|
task :test do
|
9
|
-
sh 'rspec spec'
|
5
|
+
sh 'bundle exec rspec spec'
|
10
6
|
end
|
data/lib/songbirdsh/cli.rb
CHANGED
@@ -28,7 +28,7 @@ module Songbirdsh
|
|
28
28
|
with :show_properties, 'show'
|
29
29
|
with :restart, 'next'
|
30
30
|
with :enqueue, '+'
|
31
|
-
with_all *%w{reload search start stop scrobbling shuffle list setup_scrobbling}
|
31
|
+
with_all *%w{reload search start stop scrobbling shuffle list setup_scrobbling recent flush}
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
data/lib/songbirdsh/command.rb
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
module Songbirdsh
|
2
|
-
|
2
|
+
module Command
|
3
|
+
attr_reader :usage, :help
|
4
|
+
|
5
|
+
def self.included cls
|
6
|
+
cls.extend ClassMethods
|
7
|
+
end
|
8
|
+
|
3
9
|
def self.load name, *args
|
4
10
|
require "songbirdsh/command/#{name}"
|
5
11
|
classname = name.to_s.split('_').map{|s|s.capitalize}.join
|
@@ -8,6 +14,22 @@ module Songbirdsh
|
|
8
14
|
|
9
15
|
def initialize player
|
10
16
|
@player = player
|
17
|
+
@usage = ''
|
18
|
+
@help = ''
|
19
|
+
end
|
20
|
+
|
21
|
+
module ClassMethods
|
22
|
+
def usage usage
|
23
|
+
define_method(:usage) { usage }
|
24
|
+
end
|
25
|
+
|
26
|
+
def help help
|
27
|
+
define_method(:help) { help }
|
28
|
+
end
|
29
|
+
|
30
|
+
def execute &block
|
31
|
+
define_method :execute, block
|
32
|
+
end
|
11
33
|
end
|
12
34
|
end
|
13
35
|
end
|
@@ -1,16 +1,13 @@
|
|
1
1
|
require 'yaml'
|
2
|
+
require 'songbirdsh/range_expander'
|
2
3
|
require 'songbirdsh/command'
|
3
4
|
|
4
|
-
class Songbirdsh::Command::Enqueue
|
5
|
-
|
6
|
-
|
5
|
+
class Songbirdsh::Command::Enqueue
|
6
|
+
include Songbirdsh::Command
|
7
|
+
usage '*<id>'
|
8
|
+
help 'enqueues the list of songs with the specified ids'
|
9
|
+
execute do |text|
|
10
|
+
@expander ||= Songbirdsh::RangeExpander.new
|
11
|
+
@expander.expand(text).each {|id| @player.enqueue id }
|
7
12
|
end
|
8
|
-
|
9
|
-
def usage
|
10
|
-
'*<id>'
|
11
|
-
end
|
12
|
-
|
13
|
-
def help
|
14
|
-
'enqueues the list of songs with the specified ids'
|
15
|
-
end
|
16
|
-
end
|
13
|
+
end
|
@@ -1,24 +1,24 @@
|
|
1
1
|
require 'songbirdsh/command'
|
2
2
|
|
3
|
-
class Songbirdsh::Command::List
|
4
|
-
|
3
|
+
class Songbirdsh::Command::List
|
4
|
+
include Songbirdsh::Command
|
5
|
+
help 'lists the contents of the track queue (and approximate times for when each track will be played)'
|
6
|
+
execute do |text|
|
5
7
|
@terms = text.split(/\W/)
|
6
8
|
current = @player.current
|
7
|
-
|
8
|
-
|
9
|
-
|
9
|
+
if current
|
10
|
+
next_start_time = Time.at current.started
|
11
|
+
show next_start_time, current
|
12
|
+
end
|
13
|
+
next_start_time += current.duration if next_start_time
|
10
14
|
@player.each do |track|
|
11
15
|
show next_start_time, track
|
12
|
-
next_start_time += track.duration
|
16
|
+
next_start_time += track.duration if next_start_time
|
13
17
|
end
|
14
18
|
end
|
15
19
|
|
16
20
|
def show time, track
|
17
21
|
return unless @terms.empty? or @terms.all? {|term| track.search_string.include? term }
|
18
|
-
puts "#{time}\n\t#{track}"
|
19
|
-
end
|
20
|
-
|
21
|
-
def help
|
22
|
-
'lists the contents of the track queue (and approximate times for when each track will be played)'
|
22
|
+
puts time ? "#{time.to_s.foreground(:blue)}\n\t#{track}" : track
|
23
23
|
end
|
24
24
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'songbirdsh/command'
|
2
|
+
|
3
|
+
class Songbirdsh::Command::Recent
|
4
|
+
include Songbirdsh::Command
|
5
|
+
usage '<count>'
|
6
|
+
help 'lists the specified number of recently added albums'
|
7
|
+
execute do |text|
|
8
|
+
@player.library.reload unless @player.library.tracks
|
9
|
+
maximum, current_album, tracks, total_count = text.to_i, nil, [], 0
|
10
|
+
@player.library.tracks.reverse.each do |track|
|
11
|
+
unless current_album
|
12
|
+
current_album = track.album
|
13
|
+
tracks = [track]
|
14
|
+
next
|
15
|
+
end
|
16
|
+
if current_album==track.album
|
17
|
+
tracks << track
|
18
|
+
else
|
19
|
+
puts "#{current_album} - #{extract_artist tracks} - #{tracks.size} tracks (#{tracks.last.search_id}-#{tracks.first.search_id})"
|
20
|
+
current_album = track.album
|
21
|
+
tracks = [track]
|
22
|
+
total_count += 1
|
23
|
+
end
|
24
|
+
break if total_count >= maximum
|
25
|
+
end
|
26
|
+
end
|
27
|
+
private
|
28
|
+
def extract_artist tracks
|
29
|
+
tracks.map{|t| t.artist}.uniq.size == 1 ? tracks.first.artist : 'various artists'
|
30
|
+
end
|
31
|
+
end
|
@@ -1,15 +1,7 @@
|
|
1
1
|
require 'songbirdsh/command'
|
2
2
|
|
3
|
-
class Songbirdsh::Command::Reload
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
def usage
|
9
|
-
''
|
10
|
-
end
|
11
|
-
|
12
|
-
def help
|
13
|
-
'reloads the contents of the music library for fast searching'
|
14
|
-
end
|
3
|
+
class Songbirdsh::Command::Reload
|
4
|
+
include Songbirdsh::Command
|
5
|
+
help 'reloads the contents of the music library for fast searching'
|
6
|
+
execute {|ignored| @player.library.reload }
|
15
7
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'songbirdsh/command'
|
2
2
|
|
3
|
-
class Songbirdsh::Command::Restart
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
class Songbirdsh::Command::Restart
|
4
|
+
include Songbirdsh::Command
|
5
|
+
help 'stops and restarts the player (which will kill the current track)'
|
6
|
+
execute {|ignored| @player.restart }
|
7
7
|
end
|
@@ -1,19 +1,14 @@
|
|
1
1
|
require 'songbirdsh/command'
|
2
2
|
|
3
|
-
class Songbirdsh::Command::Scrobbling
|
4
|
-
|
3
|
+
class Songbirdsh::Command::Scrobbling
|
4
|
+
include Songbirdsh::Command
|
5
|
+
usage '<on|off>'
|
6
|
+
help 'turns interaction with lastfm on or off'
|
7
|
+
execute do |text|
|
5
8
|
scrobbling = (text == 'on')
|
6
9
|
return if @player.scrobbling == scrobbling
|
7
10
|
puts scrobbling ? 'Turning scrobbling on' : 'Turning scrobbling off'
|
8
11
|
@player.scrobbling = scrobbling
|
9
12
|
@player.restart
|
10
13
|
end
|
11
|
-
|
12
|
-
def usage
|
13
|
-
'<on|off>'
|
14
|
-
end
|
15
|
-
|
16
|
-
def help
|
17
|
-
'turns interaction with lastfm on or off'
|
18
|
-
end
|
19
14
|
end
|
@@ -1,7 +1,13 @@
|
|
1
1
|
require 'songbirdsh/command'
|
2
2
|
|
3
|
-
class Songbirdsh::Command::Search
|
4
|
-
|
3
|
+
class Songbirdsh::Command::Search
|
4
|
+
include Songbirdsh::Command
|
5
|
+
usage '*<word>'
|
6
|
+
help <<EOF
|
7
|
+
searches for tracks containing the specified words (in artist, title or album)
|
8
|
+
ids are placed on the clipboard for convenient use with +
|
9
|
+
EOF
|
10
|
+
execute do |text|
|
5
11
|
terms = text.split(/\W/)
|
6
12
|
matches = []
|
7
13
|
@player.library.reload unless @player.library.tracks
|
@@ -1,11 +1,7 @@
|
|
1
1
|
require 'songbirdsh/command'
|
2
2
|
|
3
|
-
class Songbirdsh::Command::SetupScrobbling
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
def help
|
9
|
-
'runs through the steps required to get lastfm scrobbling working'
|
10
|
-
end
|
3
|
+
class Songbirdsh::Command::SetupScrobbling
|
4
|
+
include Songbirdsh::Command
|
5
|
+
help 'runs through the steps required to get lastfm scrobbling working'
|
6
|
+
execute {|ignored| @player.scrobbler.setup }
|
11
7
|
end
|
@@ -1,8 +1,9 @@
|
|
1
1
|
require 'songbirdsh/command'
|
2
2
|
require 'pp'
|
3
3
|
|
4
|
-
class Songbirdsh::Command::ShowProperties
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
class Songbirdsh::Command::ShowProperties
|
5
|
+
include Songbirdsh::Command
|
6
|
+
usage '<id>'
|
7
|
+
help 'show the track details for a specified id'
|
8
|
+
execute {|id| @player.library.with_track(id.to_i(36)) {|track| pp track } }
|
8
9
|
end
|
@@ -1,15 +1,13 @@
|
|
1
1
|
require 'songbirdsh/command'
|
2
2
|
|
3
|
-
class Songbirdsh::Command::Shuffle
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
class Songbirdsh::Command::Shuffle
|
4
|
+
include Songbirdsh::Command
|
5
|
+
help 'shuffles the current queue'
|
6
|
+
execute do |ignored=nil|
|
7
|
+
ids = []
|
8
|
+
while id = @player.dequeue
|
9
|
+
ids << id
|
9
10
|
end
|
10
|
-
|
11
|
-
|
12
|
-
def help
|
13
|
-
'shuffles the results from the last search and places them on the clipboard'
|
11
|
+
ids.sort_by { rand }.each {|id| @player.enqueue id }
|
14
12
|
end
|
15
13
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'songbirdsh/command'
|
2
2
|
|
3
|
-
class Songbirdsh::Command::Start
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
class Songbirdsh::Command::Start
|
4
|
+
include Songbirdsh::Command
|
5
|
+
help 'starts the player'
|
6
|
+
execute {|ignored| @player.start }
|
7
7
|
end
|
@@ -1,12 +1,8 @@
|
|
1
1
|
require 'yaml'
|
2
2
|
require 'songbirdsh/command'
|
3
3
|
|
4
|
-
class Songbirdsh::Command::Status
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
def help
|
10
|
-
'shows the current playing status'
|
11
|
-
end
|
4
|
+
class Songbirdsh::Command::Status
|
5
|
+
include Songbirdsh::Command
|
6
|
+
help 'shows the current player status'
|
7
|
+
execute {|ignored| puts @player.status }
|
12
8
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'songbirdsh/command'
|
2
2
|
|
3
|
-
class Songbirdsh::Command::Stop
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
class Songbirdsh::Command::Stop
|
4
|
+
include Songbirdsh::Command
|
5
|
+
help 'stops the player'
|
6
|
+
execute {|ignored| @player.stop }
|
7
7
|
end
|
data/lib/songbirdsh/player.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
|
-
require 'songbirdsh/queue'
|
2
|
-
require 'songbirdsh/library'
|
3
|
-
|
4
1
|
require 'cgi'
|
5
2
|
require 'yaml'
|
6
3
|
require 'fileutils'
|
7
4
|
require 'splat'
|
8
5
|
|
6
|
+
require 'songbirdsh/queue'
|
9
7
|
require 'songbirdsh/scrobbler'
|
8
|
+
require 'songbirdsh/library'
|
10
9
|
|
11
10
|
module Songbirdsh
|
12
11
|
class Player
|
@@ -20,19 +19,23 @@ module Songbirdsh
|
|
20
19
|
@library = Library.new preferences
|
21
20
|
end
|
22
21
|
|
22
|
+
def c text,colour
|
23
|
+
text.to_s.foreground colour
|
24
|
+
end
|
25
|
+
|
23
26
|
def status
|
24
27
|
if @pid
|
25
28
|
track = self.current
|
26
|
-
puts "Since #{Time.at(track.started)}\n\t#{track}"
|
29
|
+
puts "Since #{c Time.at(track.started), :cyan}\n\t#{track}"
|
27
30
|
played = Time.now.to_i-track.started
|
28
|
-
puts "#{played} seconds (#{track.duration-played} remaining)"
|
31
|
+
puts "#{c played, :yellow} seconds (#{c track.duration-played, :yellow} remaining)"
|
29
32
|
else
|
30
|
-
puts 'not playing'
|
33
|
+
puts 'not playing'.foreground(:yellow)
|
31
34
|
end
|
32
35
|
end
|
33
36
|
|
34
|
-
def current
|
35
|
-
|
37
|
+
def current
|
38
|
+
(@pid and File.exist?('current_song')) ? YAML.load_file('current_song') : nil
|
36
39
|
end
|
37
40
|
|
38
41
|
def register track
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Songbirdsh
|
2
|
+
class RangeExpander
|
3
|
+
def expand text
|
4
|
+
text.split(/[^0-9a-z-]/).inject([]) {|acc, term| acc + expand_term(term) }
|
5
|
+
end
|
6
|
+
|
7
|
+
def expand_to_ids text
|
8
|
+
expand(text).map {|number| from_number number }
|
9
|
+
end
|
10
|
+
private
|
11
|
+
def expand_term term
|
12
|
+
words = term.split '-'
|
13
|
+
words.empty? ? [] : range(words.first, words.last)
|
14
|
+
end
|
15
|
+
|
16
|
+
def range from, to
|
17
|
+
f, t = to_number(from), to_number(to)
|
18
|
+
t = to_number(from.slice(0...from.size-to.size)+to) if t < f
|
19
|
+
(f..t).to_a
|
20
|
+
end
|
21
|
+
|
22
|
+
def from_number term
|
23
|
+
term.to_s 36
|
24
|
+
end
|
25
|
+
|
26
|
+
def to_number term
|
27
|
+
term.to_i 36
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/songbirdsh/track.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'rainbow'
|
2
|
+
|
1
3
|
module Songbirdsh
|
2
4
|
class Track
|
3
5
|
attr_accessor *%w{id track album artist duration genre number year disc disc_total track_total label started}
|
@@ -23,7 +25,11 @@ module Songbirdsh
|
|
23
25
|
end
|
24
26
|
|
25
27
|
def to_s
|
26
|
-
"#{
|
28
|
+
"#{my(:search_id,:white)}: #{my(:artist, :yellow)} - #{my(:album,:cyan)} - #{my(:number,:magenta)} #{my(:track,:green)} (#{my(:duration,:white)})"
|
29
|
+
end
|
30
|
+
|
31
|
+
def my field, colour
|
32
|
+
self.send(field).to_s.foreground(colour)
|
27
33
|
end
|
28
34
|
end
|
29
35
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require_relative '../../spec_helper'
|
2
2
|
require 'songbirdsh/command/enqueue'
|
3
3
|
|
4
4
|
describe Songbirdsh::Command::Enqueue do
|
@@ -12,15 +12,13 @@ describe Songbirdsh::Command::Enqueue do
|
|
12
12
|
@command = Songbirdsh::Command::Enqueue.new @player
|
13
13
|
end
|
14
14
|
|
15
|
-
it 'should enqueue
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
it 'should enqueue whatever is returned from the expander' do
|
16
|
+
expander = stub('expander')
|
17
|
+
Songbirdsh::RangeExpander.should_receive(:new).and_return(expander)
|
18
|
+
expander.should_receive(:expand).with('some text').and_return([1,2,3])
|
19
|
+
|
20
|
+
[1,2,3].each {|id| @player.should_receive(:enqueue).with id}
|
19
21
|
|
20
|
-
|
21
|
-
%w{1371 5370 9369}.each do |id|
|
22
|
-
@player.should_receive(:enqueue).with(id.to_i)
|
23
|
-
end
|
24
|
-
@command.execute "123 \t 456 , 789 "
|
22
|
+
@command.execute "some text"
|
25
23
|
end
|
26
24
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
require 'songbirdsh/command/list'
|
3
|
+
|
4
|
+
describe Songbirdsh::Command::List do
|
5
|
+
extend ShellShock::CommandSpec
|
6
|
+
|
7
|
+
with_help 'lists the contents of the track queue (and approximate times for when each track will be played)'
|
8
|
+
|
9
|
+
before do
|
10
|
+
@player = stub('player')
|
11
|
+
@command = Songbirdsh::Command::List.new @player
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should display nothing when there is no current track and nothing enqueued' do
|
15
|
+
@player.stub!(:current).and_return nil
|
16
|
+
@player.stub! :each
|
17
|
+
@command.execute ''
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should display queue contents with no times when there is no current track' do
|
21
|
+
track = stub 'track'
|
22
|
+
@player.stub!(:current).and_return nil
|
23
|
+
@player.stub!(:each).and_yield track
|
24
|
+
@command.should_receive(:puts).with track
|
25
|
+
@command.execute ''
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
require 'songbirdsh/command/shuffle'
|
3
|
+
|
4
|
+
describe Songbirdsh::Command::Shuffle do
|
5
|
+
extend ShellShock::CommandSpec
|
6
|
+
|
7
|
+
with_usage ''
|
8
|
+
with_help 'shuffles the current queue'
|
9
|
+
|
10
|
+
before do
|
11
|
+
@player = stub 'player'
|
12
|
+
@command = Songbirdsh::Command::Shuffle.new @player
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should dequeue all tracks, shuffle then enqueue them' do
|
16
|
+
@player.should_receive(:dequeue).and_return(1)
|
17
|
+
@player.should_receive(:dequeue).and_return(2)
|
18
|
+
@player.should_receive(:dequeue).and_return(3)
|
19
|
+
@player.should_receive(:dequeue).and_return nil
|
20
|
+
|
21
|
+
@player.should_receive(:enqueue).with 3
|
22
|
+
@player.should_receive(:enqueue).with 2
|
23
|
+
@player.should_receive(:enqueue).with 1
|
24
|
+
|
25
|
+
@command.execute
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
require 'songbirdsh/player'
|
3
|
+
|
4
|
+
describe Songbirdsh::Player do
|
5
|
+
let(:preferences) { {} }
|
6
|
+
let(:player) { Songbirdsh::Player.new preferences }
|
7
|
+
|
8
|
+
before do
|
9
|
+
scrobbler = mock 'scrobbler'
|
10
|
+
library = mock 'library'
|
11
|
+
Songbirdsh::Scrobbler.stub!(:new).and_return scrobbler
|
12
|
+
Songbirdsh::Library.stub!(:new).and_return library
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#current' do
|
16
|
+
it 'should return current_track when player has pid and file is present' do
|
17
|
+
player.instance_eval { @pid = 1 }
|
18
|
+
hash = stub 'hash'
|
19
|
+
File.stub!(:exist?).with('current_song').and_return true
|
20
|
+
YAML.stub!(:load_file).with('current_song').and_return hash
|
21
|
+
player.current.should == hash
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should return nil when player has no pid and file is present' do
|
25
|
+
player.instance_eval { @pid = nil }
|
26
|
+
File.stub!(:exist?).with('current_song').and_return true
|
27
|
+
player.current.should == nil
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should return nil when has pid and file is not present' do
|
31
|
+
player.instance_eval { @pid = 1 }
|
32
|
+
File.stub!(:exist?).with('current_song').and_return false
|
33
|
+
player.current.should == nil
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
require 'songbirdsh/range_expander'
|
3
|
+
|
4
|
+
describe Songbirdsh::RangeExpander do
|
5
|
+
before do
|
6
|
+
@expander = Songbirdsh::RangeExpander.new
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should expand single values' do
|
10
|
+
@expander.expand('123').should == [1371]
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should expand multiple values separated by any non digit' do
|
14
|
+
@expander.expand("123 \t 456 , 789 ").should == [1371, 5370, 9369]
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should expand a fully specified range' do
|
18
|
+
@expander.expand(" 456-45i ").should == (5370..5382).to_a
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should expand an abbreviated range' do
|
22
|
+
@expander.expand(" 456-i ").should == (5370..5382).to_a
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should expand ids for a range' do
|
26
|
+
@expander.expand_to_ids(" s-z ").should == %w{s t u v w x y z}
|
27
|
+
end
|
28
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: songbirdsh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 0
|
8
|
-
- 4
|
9
|
-
version: 0.0.4
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.5
|
10
6
|
platform: ruby
|
11
7
|
authors:
|
12
8
|
- Mark Ryall
|
@@ -14,7 +10,7 @@ autorequire:
|
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
12
|
|
17
|
-
date: 2011-
|
13
|
+
date: 2011-06-19 00:00:00 +10:00
|
18
14
|
default_executable:
|
19
15
|
dependencies:
|
20
16
|
- !ruby/object:Gem::Dependency
|
@@ -25,8 +21,6 @@ dependencies:
|
|
25
21
|
requirements:
|
26
22
|
- - ~>
|
27
23
|
- !ruby/object:Gem::Version
|
28
|
-
segments:
|
29
|
-
- 0
|
30
24
|
version: "0"
|
31
25
|
type: :runtime
|
32
26
|
version_requirements: *id001
|
@@ -38,8 +32,6 @@ dependencies:
|
|
38
32
|
requirements:
|
39
33
|
- - ~>
|
40
34
|
- !ruby/object:Gem::Version
|
41
|
-
segments:
|
42
|
-
- 0
|
43
35
|
version: "0"
|
44
36
|
type: :runtime
|
45
37
|
version_requirements: *id002
|
@@ -51,49 +43,40 @@ dependencies:
|
|
51
43
|
requirements:
|
52
44
|
- - ~>
|
53
45
|
- !ruby/object:Gem::Version
|
54
|
-
segments:
|
55
|
-
- 3
|
56
46
|
version: "3"
|
57
47
|
type: :runtime
|
58
48
|
version_requirements: *id003
|
59
49
|
- !ruby/object:Gem::Dependency
|
60
|
-
name:
|
50
|
+
name: sqlite3
|
61
51
|
prerelease: false
|
62
52
|
requirement: &id004 !ruby/object:Gem::Requirement
|
63
53
|
none: false
|
64
54
|
requirements:
|
65
55
|
- - ~>
|
66
56
|
- !ruby/object:Gem::Version
|
67
|
-
|
68
|
-
- 0
|
69
|
-
- 1
|
70
|
-
version: "0.1"
|
57
|
+
version: "1"
|
71
58
|
type: :runtime
|
72
59
|
version_requirements: *id004
|
73
60
|
- !ruby/object:Gem::Dependency
|
74
|
-
name:
|
61
|
+
name: simple_scrobbler
|
75
62
|
prerelease: false
|
76
63
|
requirement: &id005 !ruby/object:Gem::Requirement
|
77
64
|
none: false
|
78
65
|
requirements:
|
79
66
|
- - ~>
|
80
67
|
- !ruby/object:Gem::Version
|
81
|
-
|
82
|
-
- 1
|
83
|
-
version: "1"
|
68
|
+
version: "0"
|
84
69
|
type: :runtime
|
85
70
|
version_requirements: *id005
|
86
71
|
- !ruby/object:Gem::Dependency
|
87
|
-
name:
|
72
|
+
name: rainbow
|
88
73
|
prerelease: false
|
89
74
|
requirement: &id006 !ruby/object:Gem::Requirement
|
90
75
|
none: false
|
91
76
|
requirements:
|
92
77
|
- - ~>
|
93
78
|
- !ruby/object:Gem::Version
|
94
|
-
|
95
|
-
- 0
|
96
|
-
version: "0"
|
79
|
+
version: "1"
|
97
80
|
type: :runtime
|
98
81
|
version_requirements: *id006
|
99
82
|
- !ruby/object:Gem::Dependency
|
@@ -104,9 +87,6 @@ dependencies:
|
|
104
87
|
requirements:
|
105
88
|
- - ~>
|
106
89
|
- !ruby/object:Gem::Version
|
107
|
-
segments:
|
108
|
-
- 0
|
109
|
-
- 8
|
110
90
|
version: "0.8"
|
111
91
|
type: :development
|
112
92
|
version_requirements: *id007
|
@@ -118,8 +98,6 @@ dependencies:
|
|
118
98
|
requirements:
|
119
99
|
- - ~>
|
120
100
|
- !ruby/object:Gem::Version
|
121
|
-
segments:
|
122
|
-
- 2
|
123
101
|
version: "2"
|
124
102
|
type: :development
|
125
103
|
version_requirements: *id008
|
@@ -136,7 +114,9 @@ extra_rdoc_files: []
|
|
136
114
|
files:
|
137
115
|
- lib/songbirdsh/cli.rb
|
138
116
|
- lib/songbirdsh/command/enqueue.rb
|
117
|
+
- lib/songbirdsh/command/flush.rb
|
139
118
|
- lib/songbirdsh/command/list.rb
|
119
|
+
- lib/songbirdsh/command/recent.rb
|
140
120
|
- lib/songbirdsh/command/reload.rb
|
141
121
|
- lib/songbirdsh/command/restart.rb
|
142
122
|
- lib/songbirdsh/command/scrobbling.rb
|
@@ -153,11 +133,16 @@ files:
|
|
153
133
|
- lib/songbirdsh/player.rb
|
154
134
|
- lib/songbirdsh/preferences.rb
|
155
135
|
- lib/songbirdsh/queue.rb
|
136
|
+
- lib/songbirdsh/range_expander.rb
|
156
137
|
- lib/songbirdsh/scrobbler.rb
|
157
138
|
- lib/songbirdsh/track.rb
|
158
139
|
- lib/songbirdsh.rb
|
159
140
|
- spec/songbirdsh/command/enqueue_spec.rb
|
141
|
+
- spec/songbirdsh/command/list_spec.rb
|
160
142
|
- spec/songbirdsh/command/reload_spec.rb
|
143
|
+
- spec/songbirdsh/command/shuffle_spec.rb
|
144
|
+
- spec/songbirdsh/player_spec.rb
|
145
|
+
- spec/songbirdsh/range_expander_spec.rb
|
161
146
|
- spec/spec_helper.rb
|
162
147
|
- bin/songbirdsh
|
163
148
|
- README.rdoc
|
@@ -179,21 +164,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
179
164
|
requirements:
|
180
165
|
- - ">="
|
181
166
|
- !ruby/object:Gem::Version
|
182
|
-
segments:
|
183
|
-
- 0
|
184
167
|
version: "0"
|
185
168
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
186
169
|
none: false
|
187
170
|
requirements:
|
188
171
|
- - ">="
|
189
172
|
- !ruby/object:Gem::Version
|
190
|
-
segments:
|
191
|
-
- 0
|
192
173
|
version: "0"
|
193
174
|
requirements: []
|
194
175
|
|
195
176
|
rubyforge_project:
|
196
|
-
rubygems_version: 1.
|
177
|
+
rubygems_version: 1.6.2
|
197
178
|
signing_key:
|
198
179
|
specification_version: 3
|
199
180
|
summary: command line jukebox music player
|