bin/somadic in somadic-0.0.3 vs bin/somadic in somadic-0.0.4
- old
+ new
@@ -9,14 +9,11 @@
require 'yaml'
SOMADIC_PATH = ENV['HOME'] + '/.somadic'
base_path = File.expand_path(File.dirname(__FILE__))
-Dir["#{base_path}/curses/lib/*.rb"].each do |file|
- Somadic::Logger.debug("require #{file}")
- require file
-end
+Dir["#{base_path}/curses/lib/*.rb"].each { |file| require file }
Signal.trap("INT") do |sig|
@channel.stop
exit
end
@@ -27,12 +24,13 @@
listeners: [@display] }
@optparser = OptionParser.new do |o|
o.banner = 'Usage: somadic [options] site:channel [site:channel]'
o.separator ''
- o.separator 'The `site` parameter can be di or soma. `channel` should be'
- o.separator 'a valid channel on that site.'
+ o.separator 'The `site` parameter can be di, soma, or slayradio. `channel`'
+ o.separator "should be a valid channel on that site except when it's slayradio,"
+ o.separator 'when `channel` should also be slayradio (slayradio:slayradio).'
o.separator ''
o.separator 'DI premium channels require an environment variable: ' \
'DI_FM_PREMIUM_ID.'
o.separator ''
@@ -67,12 +65,14 @@
who, what = next_channel.split(':')
@options[:channel] = what
@options[:premium_id] = ENV['DI_FM_PREMIUM_ID']
if who == 'di'
@channel = Somadic::Channel::DI.new(@options)
- else
+ elsif who == 'soma'
@channel = Somadic::Channel::Soma.new(@options)
+ else
+ @channel = Somadic::Channel::SlayRadio.new(@options)
end
@channel.start
end
def start(channels)
@@ -149,22 +149,34 @@
who, what = channel.split(':')
Somadic::Logger.debug("goto_channel: going to #{who}:#{what}")
@options[:channel] = what
if who == 'di'
@channel = Somadic::Channel::DI.new(@options)
- else
+ elsif who == 'soma'
@channel = Somadic::Channel::Soma.new(@options)
+ else
+ @channel = Somadic::Channel::SlayRadio.new(@options)
end
@channel.start
end
def goto_next_channel
goto_channel(next_channel)
end
def goto_next_channel_random
- who = @channel.is_a?(Somadic::Channel::DI) ? 'di' : 'soma'
- what = @channel.channels.reject { |c| c[:name] == @display.channel[:name] }.sample[:name]
+ who = if @channel.is_a?(Somadic::Channel::DI)
+ 'di'
+ elsif @channel.is_a?(Somadic::Channel::Soma)
+ 'soma'
+ else
+ 'slayradio'
+ end
+ what = if who == 'slayradio'
+ 'slayradio'
+ else
+ @channel.channels.reject { |c| c[:name] == @display.channel[:name] }.sample[:name]
+ end
goto_channel("#{who}:#{what}")
end
def search
Somadic::Logger.debug("searching for '#{@channel.song}'")