Module: Talks

Extended by:
Talks
Included in:
Talks
Defined in:
lib/talks.rb,
lib/talks/hooks.rb,
lib/talks/version.rb,
lib/talks/configuration.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.3.0'

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



21
22
23
# File 'lib/talks.rb', line 21

def config
  @config
end

Instance Method Details

#add_hooks(command) ⇒ Object



54
55
56
# File 'lib/talks.rb', line 54

def add_hooks(command)
  Talks::Hooks.create command
end

#configure(options) ⇒ Object



23
24
25
# File 'lib/talks.rb', line 23

def configure(options)
  @config = Talks::Configuration.new(options)
end

#execute(command) ⇒ Object



47
48
49
50
51
52
# File 'lib/talks.rb', line 47

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



43
44
45
# File 'lib/talks.rb', line 43

def notify(message, options = {})
  Notifier.notify message: message, title: 'Talks', image: ''
end

#say(message, options = {}) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/talks.rb', line 31

def say(message, options = {})
  type = options[:type] || :default
  case config.engine
  when 'say'
    `say -v #{say_voice(type, options)} '#{message}'`
  when 'espeak'
    `espeak -v #{say_voice(type, options)} '#{message}'`
  else
    abort "Undefined engine: #{config.engine}"
  end
end

#voicesObject



27
28
29
# File 'lib/talks.rb', line 27

def voices
  VOICES
end