Module: Talks
- Extended by:
- Talks
- Included in:
- Talks
- Defined in:
- lib/talks.rb,
lib/talks/hooks.rb,
lib/talks/version.rb,
lib/talks/hooks/base.rb,
lib/talks/hooks/voice.rb,
lib/talks/configuration.rb,
lib/talks/hooks/after_notify.rb,
lib/talks/hooks/after_message.rb,
lib/talks/hooks/before_notify.rb,
lib/talks/hooks/before_message.rb
Defined Under Namespace
Modules: Hooks
Classes: Configuration
Constant Summary
collapse
- VOICES =
{
:say => %w(
agnes albert alex bad bahh bells boing bruce bubbles cellos
deranged fred good hysterical junior kathy pipe princess ralph
trinoids vicki victoria whisper zarvox
),
:espeak => %w(en+m1 en+m2 en+m3 en+m4 en+m5 en+m6 en+m7
en+f1 en+f2 en+f3 en+f4 en+f5 en+f6 en+f7
)
}
- TYPES =
[:info, :warn, :success, :error]
- VERSION =
'0.4.1'
Instance Attribute Summary collapse
Instance Method Summary
collapse
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
22
23
24
|
# File 'lib/talks.rb', line 22
def config
@config
end
|
Instance Method Details
#add_hooks(command) ⇒ Object
69
70
71
|
# File 'lib/talks.rb', line 69
def add_hooks(command)
Talks::Hooks.create command
end
|
24
25
26
|
# File 'lib/talks.rb', line 24
def configure(options)
@config = Talks::Configuration.new(options)
end
|
#engine ⇒ Object
32
33
34
|
# File 'lib/talks.rb', line 32
def engine
config.engine
end
|
#execute(command) ⇒ Object
62
63
64
65
66
67
|
# File 'lib/talks.rb', line 62
def execute(command)
before_notify, command, after_notify = command
Talks.notify before_notify if before_notify
system command
Talks.notify after_notify if after_notify
end
|
#notify(message, options = {}) ⇒ Object
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/talks.rb', line 48
def notify(message, options = {})
opts = \
{
:message => message,
:title => 'Talks',
:image => ''
}
opts.merge! config.notifier_options if config.notifier_options
opts.merge!(options)
Notifier.notify opts
end
|
#say(message, options = {}) ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/talks.rb', line 36
def say(message, options = {})
abort "Undefined engine: #{engine}" unless ["say","espeak"].include? engine
type = options[:type] || :default
notify(message) if options[:notify] || config.notify_by_default
command = [engine, '-v', say_voice(type, options), "#{message}"]
command << '&' if options[:detach] || config.detach
system command.join(' ')
end
|
#voices ⇒ Object
28
29
30
|
# File 'lib/talks.rb', line 28
def voices
VOICES
end
|