catsay 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/catsay.rb +20 -1
- data.tar.gz.sig +0 -0
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 93a5d637c07c2ae8bc1d5d07fbcfa417702c144b
|
4
|
+
data.tar.gz: 9a74009b463c835aac43e641585f457aa7cfa392
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
metadata.gz.sig
CHANGED
Binary file
|