lib/talks/configuration.rb in talks-0.2.0 vs lib/talks/configuration.rb in talks-0.3.0
- old
+ new
@@ -9,25 +9,25 @@
:warn => 'whisper',
:success => 'vicki',
:error => 'bad'
},
:espeak => {
- :info => 'english',
- :warn => 'english',
- :success => 'english',
- :error => 'english'
+ :info => 'en+f3',
+ :warn => 'en+m1',
+ :success => 'en+f3',
+ :error => 'en+m3'
}
}
DEFAULT_MESSAGES = {
:info => 'Information note',
:warn => 'Warning',
:success => 'Success',
:error => 'Error'
}
- attr_accessor :voices, :messages, :default_voice, :options, :engine
+ attr_accessor :voices, :messages, :default_voice, :options, :engine, :notifier
def initialize(opts)
@options = symbolize_hash_keys(opts)
@engine = options[:engine] || default_engine_for_os
@default_voice = options[:default_voice] || default_voice_for(engine)
@@ -57,10 +57,23 @@
command = command_name.to_sym
options[command] &&
options[command][(position == :before ? :before_message : :after_message)]
end
+ def notifier_for(command_name)
+ command = command_name.to_sym
+ (options[:notifier] != 'off') &&
+ options[command] &&
+ (options[command][:notifier] != 'off')
+ end
+
+ def notify_message_for(command_name, position = :after)
+ command = command_name.to_sym
+ options[command] &&
+ options[command][(position == :before ? :before_notify : :after_notify)]
+ end
+
def voice_for(command_name)
command = command_name.to_sym
options[command] &&
options[command][:voice]
end
@@ -82,10 +95,10 @@
if RUBY_PLATFORM =~ /darwin/i
'say'
elsif !(`which espeak`.empty?)
'espeak'
else
- abort 'Now talks can work only on MacOS X, you can help with support other OS'
+ abort 'Talks is supported on Mac OS X and linux only, but you can help with support for other OSes'
end
end
def symbolize_hash_keys(opts)
sym_opts = {}