hearken 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/hearken.rb +1 -1
- data/lib/hearken/colour.rb +5 -0
- data/lib/hearken/command/list.rb +4 -1
- data/lib/hearken/command/recent.rb +9 -2
- data/lib/hearken/library.rb +0 -4
- data/lib/hearken/player.rb +4 -6
- data/lib/hearken/track.rb +1 -1
- metadata +2 -1
data/lib/hearken.rb
CHANGED
data/lib/hearken/command/list.rb
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
require 'hearken/command'
|
2
|
+
require 'hearken/colour'
|
2
3
|
|
3
4
|
class Hearken::Command::List
|
4
5
|
include Hearken::Command
|
6
|
+
include Hearken::Colour
|
7
|
+
|
5
8
|
usage '*<word>'
|
6
9
|
help <<EOF
|
7
10
|
lists the contents of the track queue
|
@@ -24,6 +27,6 @@ EOF
|
|
24
27
|
|
25
28
|
def show time, track
|
26
29
|
return unless @terms.empty? or @terms.all? {|term| track.search_string.include? term }
|
27
|
-
puts time ? "#{time.
|
30
|
+
puts time ? "#{c time.strftime("%H:%M:%S %d/%m/%Y"), :blue} #{track}" : track
|
28
31
|
end
|
29
32
|
end
|
@@ -1,13 +1,20 @@
|
|
1
1
|
require 'hearken/command'
|
2
|
+
require 'hearken/colour'
|
2
3
|
|
3
4
|
class Hearken::Command::Recent
|
4
5
|
include Hearken::Command
|
6
|
+
include Hearken::Colour
|
7
|
+
|
5
8
|
usage '<count>'
|
6
9
|
help 'lists the specified number of recently added albums'
|
7
10
|
execute do |text|
|
8
11
|
@player.library.reload unless @player.library.tracks
|
12
|
+
all_tracks = @player.library.tracks.sort do |a, b|
|
13
|
+
tc = a.timestamp <=> b.timestamp
|
14
|
+
tc == 0 ? a.id <=> b.id : tc
|
15
|
+
end
|
9
16
|
maximum, current_album, tracks, total_count = text.to_i, nil, [], 0
|
10
|
-
|
17
|
+
all_tracks.reverse.each do |track|
|
11
18
|
unless current_album
|
12
19
|
current_album = track.album
|
13
20
|
tracks = [track]
|
@@ -16,7 +23,7 @@ class Hearken::Command::Recent
|
|
16
23
|
if current_album==track.album
|
17
24
|
tracks << track
|
18
25
|
else
|
19
|
-
puts "#{
|
26
|
+
puts "#{c extract_artist(tracks), :yellow} #{c current_album, :cyan} #{tracks.size} tracks [#{tracks.last.search_id}-#{tracks.first.search_id}]"
|
20
27
|
current_album = track.album
|
21
28
|
tracks = [track]
|
22
29
|
total_count += 1
|
data/lib/hearken/library.rb
CHANGED
data/lib/hearken/player.rb
CHANGED
@@ -5,10 +5,12 @@ require 'hearken/queue'
|
|
5
5
|
require 'hearken/scrobbler'
|
6
6
|
require 'hearken/notification/growl_notifier'
|
7
7
|
require 'hearken/library'
|
8
|
+
require 'hearken/colour'
|
8
9
|
|
9
10
|
module Hearken
|
10
11
|
class Player
|
11
12
|
include Queue
|
13
|
+
include Colour
|
12
14
|
attr_reader :library, :scrobbler
|
13
15
|
|
14
16
|
def initialize preferences
|
@@ -21,16 +23,12 @@ module Hearken
|
|
21
23
|
create_paths
|
22
24
|
end
|
23
25
|
|
24
|
-
def c text,colour
|
25
|
-
text.to_s.foreground colour
|
26
|
-
end
|
27
|
-
|
28
26
|
def status
|
29
27
|
if @pid
|
30
28
|
track = self.current
|
31
|
-
puts "Since #{c Time.at(track.started), :cyan}\n\t#{track}"
|
32
29
|
played = Time.now.to_i-track.started
|
33
|
-
|
30
|
+
timing = "(#{c track.time.to_i-played, :yellow} remaining)" if track.time
|
31
|
+
puts "#{c Time.at(track.started).strftime("%H:%M:%S %d/%m/%Y"), :blue}: #{track} #{timing}"
|
34
32
|
else
|
35
33
|
puts 'not playing'.foreground(:yellow)
|
36
34
|
end
|
data/lib/hearken/track.rb
CHANGED
@@ -26,7 +26,7 @@ class Hearken::Track
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def to_s
|
29
|
-
"#{my(:search_id,:white)}
|
29
|
+
"[#{my(:search_id,:white)}] #{my(:artist, :yellow)} #{my(:album,:cyan)} #{my(:track,:magenta)} #{my(:title,:green)} (#{my(:time,:white)})"
|
30
30
|
end
|
31
31
|
|
32
32
|
def to_short_s
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: hearken
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Mark Ryall
|
@@ -128,6 +128,7 @@ files:
|
|
128
128
|
- hearken.gemspec
|
129
129
|
- lib/hearken.rb
|
130
130
|
- lib/hearken/cli.rb
|
131
|
+
- lib/hearken/colour.rb
|
131
132
|
- lib/hearken/command.rb
|
132
133
|
- lib/hearken/command/enqueue.rb
|
133
134
|
- lib/hearken/command/flush.rb
|