cli-talky-talk 0.1.0 → 0.2.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: edd93c185b1359d17eb42c2016bda31262160139
4
- data.tar.gz: b9cd0898da65f652b6797907b34c3278998baee4
3
+ metadata.gz: 76dcd913db3f96743a0436b6a10294d3d9ea026c
4
+ data.tar.gz: 35f5808942746b3826925b539af1af5475d2e12b
5
5
  SHA512:
6
- metadata.gz: 7f6dbcd675ee0aa6a4624e8101c21a0143886b44c0bc940527b0a578fdd665cec528db6d1ba0fed8424631d94efa3f6ccbf6d359f6d0bd47eac064922de52414
7
- data.tar.gz: ddd520c2aafb9c563eec1793f9daa086e7f3ba4e77d42d8c85489159e822039272950285b58ba0ea3f1e0f088cb15c6b47e97c2fde8e111b157231bda03e638e
6
+ metadata.gz: 60ec7e91d34a5af615fb42388b6ed993c313a8288e2c28c9a1396d931dd57635403efeb478908e5b2009fbb066b1ae9ed540d5857ba45e2f6edc21e1b126db91
7
+ data.tar.gz: ad0fbb9375a4ba31545c7e79203f58c365831a839a40bb5270ac7600a7fb15d07f5e54b6e48d8623a3d7616eb5a00d22dcc66222d7d1643586b89375adc42cb3
data/README.md CHANGED
@@ -12,6 +12,12 @@ cli-talky-talk is very easy to use. All you need to do is add `&& speak` at the
12
12
  > <some terminal command that will take a while> && speak
13
13
  ```
14
14
 
15
+ For all options:
16
+
17
+ ```
18
+ speak --help
19
+ ```
20
+
15
21
  ## Installation
16
22
 
17
23
  Add this line to your application's Gemfile:
data/bin/speak CHANGED
@@ -4,6 +4,7 @@ require 'optparse'
4
4
  require 'ostruct'
5
5
  require 'bundler/setup'
6
6
  require 'cli-talky-talk'
7
+ require 'fileutils'
7
8
 
8
9
  options = OpenStruct.new
9
10
 
@@ -26,7 +27,31 @@ OptionParser.new do |opts|
26
27
  options.voice = voice
27
28
  end
28
29
 
30
+ opts.on('--install') do
31
+ source_path = File.expand_path('../../', __FILE__) + '/config/preferences.yml'
32
+ target_path = Dir.home + '/.cli-talky-talk.yml'
33
+ FileUtils.cp source_path, target_path
34
+ puts "Preferences file copied to: #{target_path}"
35
+ exit 0
36
+ end
37
+
38
+ opts.on('--list-voices') do
39
+ talker = CliTalkyTalk.new
40
+ blacklist = talker.preferences['options']['voice']['blacklist'] || []
41
+ puts talker.voices - blacklist
42
+ if blacklist
43
+ puts "-" * 30
44
+ puts "blacklisted: \n#{blacklist}"
45
+ end
46
+ exit 0
47
+ end
48
+
29
49
  end.parse!
30
50
 
31
51
  talker = CliTalkyTalk.new(options)
32
- talker.speak
52
+ begin
53
+ talker.speak
54
+ rescue RuntimeError => e
55
+ puts "Error: #{e}"
56
+ exit 1
57
+ end
@@ -0,0 +1,51 @@
1
+ # This file is used with the cli-talky-talk gem
2
+ options:
3
+ voice:
4
+ whitelist:
5
+ blacklist:
6
+ - Trinoids
7
+ - Good News
8
+ - Bad News
9
+ - Bubbles
10
+ - Veena
11
+ - Boing
12
+ - Pipe Organ
13
+ - Albert
14
+ - Tessa
15
+ - Bahh
16
+ - Deranged
17
+ - Hysterical
18
+ - Whisper
19
+ - Bells
20
+
21
+ segments:
22
+ greetings:
23
+ - ahoy
24
+ - greeting
25
+ - saalutations
26
+ - waazame
27
+ - bleep booop
28
+ - exceslior
29
+ - land hoe
30
+ - hail
31
+
32
+ names:
33
+ - WHOAMI
34
+ - Govna
35
+ - captain
36
+ - boss
37
+ - cheef
38
+ - over loard
39
+ - dragon commander
40
+ - your excellence
41
+ - exhaulted one
42
+
43
+ statuses:
44
+ - all done here
45
+ - works done
46
+ - bingo!
47
+ - hazaa
48
+ - flip Yeah
49
+ - get back to work
50
+ - all systems go
51
+
@@ -1,61 +1,40 @@
1
1
  require 'pry'
2
+ require 'yaml'
3
+
2
4
  class CliTalkyTalk
3
5
 
4
- attr_accessor :options
6
+ attr_accessor :options, :preferences
5
7
 
6
- def initialize(options)
8
+ def initialize(options=nil)
7
9
  @options = options || OpenStruct.new
10
+ begin
11
+ personal_pref_path = Dir.home + '/.cli-talky-talk.yml'
12
+ default_path = File.expand_path('../../', __FILE__) + '/config/preferences.yml'
13
+ [personal_pref_path, default_path].each do |path|
14
+ if File.exist? path
15
+ @preferences = YAML.load_file(path)
16
+ log "using preferences from: #{path}"
17
+ break
18
+ end
19
+ end
20
+ raise "unable to load preferences" unless @preferences
21
+ rescue Psych::SyntaxError => e
22
+ raise "There was an error parsing the config file: #{e}"
23
+ end
8
24
  end
9
25
 
10
- VOICES = `say -v \?`.split("\n").select { |v| v =~ /en_/ }.map { |v| v.gsub(/\s+en_US.*$/,"")}
11
-
12
- GREETINGS = [
13
- 'ahoy',
14
- 'greeting',
15
- 'saalutations',
16
- 'waazame',
17
- 'bleep booop',
18
- 'exceslior',
19
- 'land hoe',
20
- 'hail',
21
- ]
22
-
23
- NAMES = [
24
- `whoami`.chomp,
25
- 'Govna',
26
- 'captain',
27
- 'boss',
28
- 'cheef',
29
- 'over loard',
30
- 'dragon commander',
31
- 'your excellence',
32
- 'exhaulted one',
33
- ]
34
-
35
- STATUSES = [
36
- 'all done here',
37
- 'works done',
38
- 'bingo!',
39
- 'hazaa',
40
- 'flip Yeah',
41
- 'get back to work',
42
- 'all systems go',
43
- ]
44
-
45
26
  def rand(arr)
46
27
  arr.sample
47
28
  end
48
29
 
49
30
  def speak
50
- voice = options.voice || rand(VOICES)
51
- log "voice: #{voice}"
52
31
  sentence = options.sentence || random_sentence
53
32
  log "sentence: #{sentence}"
54
33
  `say -v#{voice} #{sentence}`
55
34
  end
56
35
 
57
36
  def random_sentence
58
- "#{rand GREETINGS}, #{rand NAMES}! #{rand STATUSES}"
37
+ "#{get :greetings}, #{get :names}! #{get :statuses}"
59
38
  end
60
39
 
61
40
  def log(str)
@@ -63,4 +42,40 @@ class CliTalkyTalk
63
42
  puts str
64
43
  end
65
44
  end
45
+
46
+ def get(key)
47
+ str = rand preferences['segments'][key.to_s]
48
+ # convert for specific keyword tokens
49
+ case str
50
+ when 'WHOAMI'
51
+ `whoami`.chomp
52
+ else
53
+ str
54
+ end
55
+ end
56
+
57
+ def voice
58
+ voice_opts = preferences['options']['voice']
59
+ whitelist = voice_opts['whitelist']
60
+ blacklist = voice_opts['blacklist']
61
+
62
+ voice = if options.voice
63
+ options.voice
64
+ elsif whitelist.kind_of?(Array)
65
+ rand whitelist
66
+ else
67
+ avail_voices = voices - blacklist if blacklist.kind_of?(Array)
68
+ rand avail_voices
69
+ end
70
+ log "voice: #{voice}"
71
+ voice
72
+ end
73
+
74
+ def voices
75
+ `say -v \?`.split("\n").select { |v| v =~ /en_/ }.map { |v| v.gsub(/\s+en_[A-Z]{2}.*$/,"")}
76
+ end
77
+
78
+ def self.voices
79
+ self.new.voices
80
+ end
66
81
  end
@@ -1,3 +1,3 @@
1
1
  class CliTalkyTalk
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cli-talky-talk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean McCleary
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-01 00:00:00.000000000 Z
11
+ date: 2015-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -69,9 +69,9 @@ files:
69
69
  - Rakefile
70
70
  - bin/speak
71
71
  - cli-talky-talk.gemspec
72
+ - config/preferences.yml
72
73
  - lib/cli-talky-talk.rb
73
74
  - lib/cli_talky_talk/version.rb
74
- - speak
75
75
  homepage: https://github.com/mrinterweb/cli-talky-talk
76
76
  licenses:
77
77
  - MIT
data/speak DELETED
@@ -1,41 +0,0 @@
1
- #! /usr/bin/env ruby
2
- # Some of the words are misspelled to help the say program pronounce them right
3
- #
4
- # copy the following line and paste for fun!
5
- # curl -O https://gist.githubusercontent.com/mrinterweb/0ed2ac30a97e25e03fad/raw/e56fdb4940e0222f45cc6255c6673ffccce9acef/speak.rb && mv speak.rb talk && chmod a+x speak && ./speak
6
-
7
- # get a list of all possible voices
8
- voices = `say -v \?`.split("\n").select { |v| v =~ /en_US/ }.map { |v| v.gsub(/\s+en_US.*$/,"")}
9
- greetings = [
10
- 'ahoy',
11
- 'greeting',
12
- 'saalutations',
13
- 'waazame',
14
- 'bleep booop',
15
- 'exceslior',
16
- 'land hoe',
17
- 'hail',
18
- ]
19
- names = [
20
- `whoami`.chomp,
21
- 'Govna',
22
- 'captain',
23
- 'boss',
24
- 'cheef',
25
- 'over loard',
26
- 'dragon commander',
27
- 'your excellence',
28
- 'exhaulted one',
29
- ]
30
- statuses = [
31
- 'all done here',
32
- 'works done',
33
- 'bingo!',
34
- 'hazaa',
35
- 'flip Yeah',
36
- 'get back to work',
37
- 'all systems go',
38
- ]
39
- r = ->(arr) { arr.sample }
40
- str = "#{r[greetings]}, #{r[names]}! #{r[statuses]}"
41
- `say -v#{r[voices]} #{str}`