candelabra 1.1.1 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile.lock +1 -1
- data/candelabra.gemspec +2 -2
- data/lib/candelabra/event_cmd.rb +0 -9
- data/lib/candelabra/installer.rb +6 -3
- data/lib/candelabra/osx.rb +1 -1
- data/lib/candelabra/pianobar.rb +5 -3
- data/lib/candelabra/remote.rb +24 -10
- data/lib/candelabra/runner.rb +3 -1
- data/lib/candelabra/templates/banner.erb +7 -5
- data/lib/candelabra/version.rb +1 -1
- metadata +10 -8
data/Gemfile.lock
CHANGED
data/candelabra.gemspec
CHANGED
@@ -5,8 +5,8 @@ Gem::Specification.new do |s|
|
|
5
5
|
s.name = "candelabra"
|
6
6
|
s.version = Candelabra::VERSION
|
7
7
|
s.platform = Gem::Platform::RUBY
|
8
|
-
s.authors = []
|
9
|
-
s.email = []
|
8
|
+
s.authors = ['cajun']
|
9
|
+
s.email = ['zac@kleinpeter.org']
|
10
10
|
s.homepage = "http://rubygems.org/gems/candelabra"
|
11
11
|
s.summary = "Wrapper for pianobar"
|
12
12
|
s.description = "initial wrapper for pianobar"
|
data/lib/candelabra/event_cmd.rb
CHANGED
@@ -20,17 +20,8 @@ module Candelabra
|
|
20
20
|
Remote.flush
|
21
21
|
when 'userlogin'
|
22
22
|
unless @pRet.to_i == 1
|
23
|
-
`notify-send Bad Username`
|
24
23
|
`ps a | grep 'candelabra install' | cut -c1-5`.split("\n").each{|id| `kill #{id}` unless Process.pid == id.to_i }
|
25
24
|
end
|
26
|
-
|
27
|
-
else
|
28
|
-
#`notify-send #{@pRet}`
|
29
|
-
#`notify-send #{command}`
|
30
|
-
#`notify-send #{command}`
|
31
|
-
#instance_variables.each do |i|
|
32
|
-
# `notify-send #{i}`
|
33
|
-
#end
|
34
25
|
end
|
35
26
|
end
|
36
27
|
|
data/lib/candelabra/installer.rb
CHANGED
@@ -89,6 +89,9 @@ module Candelabra
|
|
89
89
|
end
|
90
90
|
|
91
91
|
def start_pianobar
|
92
|
+
Remote.flush
|
93
|
+
Remote.flush_input
|
94
|
+
|
92
95
|
if Pianobar.running?
|
93
96
|
print "Restarting Pianobar with Autostation".ljust(CONSOLE_WIDTH + 20, '.')
|
94
97
|
Pianobar.restart
|
@@ -113,13 +116,13 @@ module Candelabra
|
|
113
116
|
|
114
117
|
if Pianobar.running?
|
115
118
|
`echo '0' > #{Installer.input_path}` # forcing auto selection of the first station
|
116
|
-
sleep(
|
119
|
+
sleep( 5 )
|
117
120
|
puts ''
|
118
121
|
puts "Select Auto station".center( CONSOLE_WIDTH + 20, ' ' )
|
119
|
-
stations = Remote.stations
|
120
|
-
stations.each { |s| puts s }
|
121
122
|
|
122
123
|
begin
|
124
|
+
stations = Remote.stations
|
125
|
+
stations.each { |s| puts s }
|
123
126
|
result = ask 'Select Station and press ENTER:'
|
124
127
|
raise "You must enter the number of a valid station" unless result == result.to_i.to_s
|
125
128
|
raise "That is not a valid station it must be a number between 0 and #{stations.size - 1}" unless (0..stations.size - 1).include? result.to_i
|
data/lib/candelabra/osx.rb
CHANGED
@@ -56,7 +56,7 @@ module Candelabra
|
|
56
56
|
|
57
57
|
# Notify the user using growl
|
58
58
|
def notify
|
59
|
-
%x[growlnotify --image #{art_work} -t "Pianobar - #{stationName}" -m "Now Playing: #{artist} - #{title}"]
|
59
|
+
%x[growlnotify --image #{art_work} -t "Pianobar - #{stationName}" -m "Now Playing: #{artist} - #{title}"] if notify?
|
60
60
|
end
|
61
61
|
|
62
62
|
end
|
data/lib/candelabra/pianobar.rb
CHANGED
@@ -92,13 +92,14 @@ module Candelabra
|
|
92
92
|
|
93
93
|
def initialize
|
94
94
|
@commands = {
|
95
|
-
:start
|
95
|
+
:start => Start.new,
|
96
96
|
:stop_all => StopAll.new,
|
97
|
-
:pid
|
97
|
+
:pid => PID.new
|
98
98
|
}
|
99
99
|
end
|
100
100
|
|
101
101
|
def command(command)
|
102
|
+
Remote.flush_all
|
102
103
|
@commands[command].go if @commands[command]
|
103
104
|
end
|
104
105
|
end
|
@@ -107,7 +108,8 @@ module Candelabra
|
|
107
108
|
class Start
|
108
109
|
def go
|
109
110
|
pid = fork do
|
110
|
-
$stdin
|
111
|
+
[$stdin, $stdout].each {|st| st.close}
|
112
|
+
$stdin.reopen File.open( Installer.input_path , 'r+' )
|
111
113
|
$stdout.reopen File.open( Installer.output_path, 'w+' )
|
112
114
|
exec 'pianobar'
|
113
115
|
end
|
data/lib/candelabra/remote.rb
CHANGED
@@ -42,6 +42,7 @@ module Candelabra
|
|
42
42
|
#
|
43
43
|
# Returns command you passed in
|
44
44
|
def execute_command cmd
|
45
|
+
return nil unless Candelabra::Pianobar.running?
|
45
46
|
if commands.include? cmd
|
46
47
|
%x[ echo #{commands[cmd]} > #{Candelabra::Installer.ctl_path} ]
|
47
48
|
else
|
@@ -123,7 +124,7 @@ module Candelabra
|
|
123
124
|
# Returns an array of stations
|
124
125
|
def stations
|
125
126
|
list = []
|
126
|
-
execute_command( :
|
127
|
+
execute_command( :stations )
|
127
128
|
output do |io|
|
128
129
|
io.lines.each do |line|
|
129
130
|
/(\[\?\])/ =~ line
|
@@ -134,16 +135,19 @@ module Candelabra
|
|
134
135
|
list
|
135
136
|
end
|
136
137
|
|
138
|
+
def flush_all
|
139
|
+
flush
|
140
|
+
flush_input
|
141
|
+
end
|
142
|
+
|
137
143
|
def flush
|
138
|
-
output
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
end
|
146
|
-
end
|
144
|
+
output { |io| loop { io.read_nonblock(1) } }
|
145
|
+
rescue # TODO put the correct exception
|
146
|
+
end
|
147
|
+
|
148
|
+
def flush_input
|
149
|
+
input { |io| loop { io.read_nonblock(1) } }
|
150
|
+
rescue # TODO put the correct exception
|
147
151
|
end
|
148
152
|
|
149
153
|
# The out put file for the commands
|
@@ -152,6 +156,16 @@ module Candelabra
|
|
152
156
|
# Yields and IO reader for pianobar's output
|
153
157
|
def output
|
154
158
|
File.open( Candelabra::Installer.output_path, 'r+' ) do |io|
|
159
|
+
yield(io)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
# The out put file for the commands
|
164
|
+
# This contains all the output from pianobar
|
165
|
+
#
|
166
|
+
# Yields and IO reader for pianobar's output
|
167
|
+
def input
|
168
|
+
File.open( Candelabra::Installer.input_path, 'r+' ) do |io|
|
155
169
|
yield( io )
|
156
170
|
end
|
157
171
|
end
|
data/lib/candelabra/runner.rb
CHANGED
@@ -69,9 +69,11 @@ module Candelabra
|
|
69
69
|
when 'start'
|
70
70
|
Candelabra::Pianobar.start
|
71
71
|
when 'stop'
|
72
|
-
Candelabra::Pianobar.
|
72
|
+
Candelabra::Pianobar.stop_all
|
73
73
|
when 'restart'
|
74
74
|
Candelabra::Pianobar.restart
|
75
|
+
when 'flush' # Force flushing of the fifo files
|
76
|
+
Candelabra::Remote.flush_all
|
75
77
|
when 'install'
|
76
78
|
Candelabra::Installer.run
|
77
79
|
when *cmds.keys
|
@@ -1,16 +1,18 @@
|
|
1
1
|
usage: candelabra [command] [data]
|
2
2
|
|
3
3
|
Base Commands:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
install # installs pianobar and sets up the configuration files
|
5
|
+
start
|
6
|
+
stop
|
7
|
+
restart
|
8
|
+
flush # flushs out all of the fifo files
|
8
9
|
|
9
10
|
Controlling Pianobar
|
10
11
|
n(ext)
|
11
12
|
p(ause)
|
12
13
|
co(continue)
|
13
|
-
ch(change_station) # of station
|
14
|
+
ch(change_station) [ # of station ]
|
15
|
+
s(tations)
|
14
16
|
t(ired)
|
15
17
|
u(pcomming)
|
16
18
|
q(ick_mix)
|
data/lib/candelabra/version.rb
CHANGED
metadata
CHANGED
@@ -1,19 +1,20 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: candelabra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
prerelease: !!null
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
|
+
- cajun
|
8
9
|
autorequire: !!null
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2011-02-
|
12
|
+
date: 2011-02-20 00:00:00.000000000 -06:00
|
12
13
|
default_executable: !!null
|
13
14
|
dependencies:
|
14
15
|
- !ruby/object:Gem::Dependency
|
15
16
|
name: bundler
|
16
|
-
requirement: &
|
17
|
+
requirement: &2153649260 !ruby/object:Gem::Requirement
|
17
18
|
none: false
|
18
19
|
requirements:
|
19
20
|
- - ~>
|
@@ -21,10 +22,10 @@ dependencies:
|
|
21
22
|
version: 1.0.0
|
22
23
|
type: :development
|
23
24
|
prerelease: false
|
24
|
-
version_requirements: *
|
25
|
+
version_requirements: *2153649260
|
25
26
|
- !ruby/object:Gem::Dependency
|
26
27
|
name: minitest
|
27
|
-
requirement: &
|
28
|
+
requirement: &2153648800 !ruby/object:Gem::Requirement
|
28
29
|
none: false
|
29
30
|
requirements:
|
30
31
|
- - ! '>='
|
@@ -32,9 +33,10 @@ dependencies:
|
|
32
33
|
version: 2.0.2
|
33
34
|
type: :development
|
34
35
|
prerelease: false
|
35
|
-
version_requirements: *
|
36
|
+
version_requirements: *2153648800
|
36
37
|
description: initial wrapper for pianobar
|
37
|
-
email:
|
38
|
+
email:
|
39
|
+
- zac@kleinpeter.org
|
38
40
|
executables:
|
39
41
|
- candelabra
|
40
42
|
extensions: []
|