catsay 0.1.1 → 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: 474c13400af219856921605b1cc1d9afd699c75f
4
- data.tar.gz: ab379ebecf1bdad6fe6f784e9479d330adaade02
3
+ metadata.gz: 93a5d637c07c2ae8bc1d5d07fbcfa417702c144b
4
+ data.tar.gz: 9a74009b463c835aac43e641585f457aa7cfa392
5
5
  SHA512:
6
- metadata.gz: cb012f5b5852b4aed31e005d1190a1b8fa31c9728f9064b33bf587b04b590ebc7d2c3f5f08d6970fc82beff0e0fb131d162a1872a887e11b696a57c1afeeb3e3
7
- data.tar.gz: 7fcd9f9dd3b30ab9337f70f7d70dd3c4ce4c81acec4236df79eb5bc4412a38eec96e93de3006214dc22785555b404748611749ae410ed8866084034429be1e7d
6
+ metadata.gz: 57441b1cf910522f3d62bce6bb379c39d5bbbd14da93fe0c46d9f48e95695ba6526abeb304528d91e9b716998a63b74713158f39087510cf837373e1731d15eb
7
+ data.tar.gz: 13d76da5db221cef8c33cf40a00094efddc07a4e112614efa07c738f208404257e59fae0228a3a13a4a6f1259e2d583f3e4b62a643112918e13fc6614570621e
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/catsay.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'erb'
2
+ require 'set'
2
3
 
3
4
  $:.unshift File.expand_path(File.dirname(__FILE__))
4
5
 
@@ -21,6 +22,20 @@ module Catsay
21
22
  p @options
22
23
  end
23
24
 
25
+ # list cats and exits 0 if there are cats, 1 if not.
26
+ if @options[:list]
27
+ puts 'these are the cats I know:'
28
+ cats.each do |cat|
29
+ puts "- #{cat}"
30
+ end
31
+
32
+ if cats.size == 0
33
+ exit 1 # oh noes!
34
+ else
35
+ exit 0
36
+ end
37
+ end
38
+
24
39
  if @options[:cat] == :random
25
40
  @options[:cat] = cats.sample
26
41
  end
@@ -92,7 +107,7 @@ module Catsay
92
107
 
93
108
  def cats
94
109
  catfiles = Dir[File.join(File.expand_path(File.dirname(__FILE__)), '..', 'cats', '*.erb')]
95
- catfiles.map! { |x| File.basename(x, '.erb') }
110
+ catfiles.map! { |x| File.basename(x, '.erb') }.to_set
96
111
  end
97
112
 
98
113
  # fetches the input by first looking for
@@ -126,6 +141,10 @@ module Catsay
126
141
  options[:input] = input
127
142
  end
128
143
 
144
+ opts.on('-l', '--list', 'List cats and exit') do |list|
145
+ options[:list] = true
146
+ end
147
+
129
148
  opts.on('-e', '--verbose', 'Annoying kitty') do |verbose|
130
149
  options[:verbose] = verbose
131
150
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: catsay
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Austin G. Davis-Richardson
metadata.gz.sig CHANGED
Binary file