xsay 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/xsay +5 -0
- data/lib/xsay.rb +18 -16
- data/lib/xsay/render.rb +56 -0
- data/lib/xsay/templates/ant.template +10 -0
- data/lib/xsay/templates/banana.template +4 -0
- data/lib/xsay/templates/bear.template +15 -15
- data/lib/xsay/templates/beaver.template +10 -0
- data/lib/xsay/templates/bee.template +10 -0
- data/lib/xsay/templates/beetle.template +15 -0
- data/lib/xsay/templates/bison.template +12 -0
- data/lib/xsay/templates/buffalo.template +12 -12
- data/lib/xsay/templates/bull.template +8 -0
- data/lib/xsay/templates/butterfly.template +11 -11
- data/lib/xsay/templates/cactus.template +41 -0
- data/lib/xsay/templates/cat.template +5 -5
- data/lib/xsay/templates/caterpillar.template +3 -0
- data/lib/xsay/templates/cow.template +18 -0
- data/lib/xsay/templates/coyote.template +25 -25
- data/lib/xsay/templates/crab.template +14 -0
- data/lib/xsay/templates/dinosaur.template +19 -0
- data/lib/xsay/templates/dolphin.template +17 -0
- data/lib/xsay/templates/door.template +13 -0
- data/lib/xsay/templates/dragon.template +19 -19
- data/lib/xsay/templates/elephant.template +12 -12
- data/lib/xsay/templates/frog.template +17 -0
- data/lib/xsay/templates/giraffe.template +23 -23
- data/lib/xsay/templates/gorilla.template +10 -10
- data/lib/xsay/templates/grassphopper.template +4 -4
- data/lib/xsay/templates/hamster.template +12 -0
- data/lib/xsay/templates/hedgehog.template +25 -25
- data/lib/xsay/templates/kangaroo.template +22 -22
- data/lib/xsay/templates/koala.template +15 -15
- data/lib/xsay/templates/leopard.template +18 -18
- data/lib/xsay/templates/monkey.template +35 -35
- data/lib/xsay/templates/moose.template +23 -23
- data/lib/xsay/templates/penguin.template +21 -21
- data/lib/xsay/templates/pig.template +10 -10
- data/lib/xsay/templates/porcupine.template +10 -10
- data/lib/xsay/templates/robot.template +23 -23
- data/lib/xsay/templates/shark.template +25 -25
- data/lib/xsay/templates/skunk.template +29 -0
- data/lib/xsay/templates/sloth.template +17 -0
- data/lib/xsay/templates/snail.template +14 -0
- data/lib/xsay/templates/snake.template +16 -16
- data/lib/xsay/templates/vulture.template +13 -0
- data/lib/xsay/templates/whale.template +10 -10
- data/lib/xsay/templates/wolf.template +22 -22
- data/lib/xsay/version.rb +1 -1
- data/xsay.gemspec +1 -0
- metadata +37 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d0231aa2358f33b0120bc830711cb8cc0dfb04cba272599a83cb7260cf5f7441
|
4
|
+
data.tar.gz: b0c35281b531aac3d0878d69aeae79cb7d06759ea276ee7141d7051c8246d703
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6fc8dc14a943b01f5fac7b6d8a65a0833769262140e217e4ea5715d25fd35a7d6eaf8498863511faca1266f99e773e2a1e5b27b854bb347f61bb065f74db81a
|
7
|
+
data.tar.gz: 8585c6d4dd76b43102c088283d018b7b4a4322e549da99f495651b763798b496f640276b61ce2b04f1cf5023872f84a0ece08a5b603b188337ebeabb6aac3b4e
|
data/exe/xsay
CHANGED
data/lib/xsay.rb
CHANGED
@@ -1,43 +1,45 @@
|
|
1
|
-
require "xsay/version"
|
2
1
|
require "thor"
|
2
|
+
require "colorize"
|
3
|
+
require "xsay/render"
|
4
|
+
require "xsay/version"
|
3
5
|
|
4
6
|
module Xsay
|
5
7
|
class CLI < Thor
|
6
8
|
ANIMALS=Dir[File.expand_path("xsay/templates/*.template", File.dirname(__FILE__))]
|
9
|
+
class_option :colour, default: :default, required: false
|
10
|
+
class_option :distance, default: 0, required: false, type: :numeric
|
11
|
+
class_option :speed, default: 1, required: false, type: :numeric
|
7
12
|
|
8
13
|
ANIMALS.each do |filename|
|
9
14
|
animal = File.basename(filename).split(".")[0]
|
10
15
|
|
11
16
|
desc "#{animal} <message>", "xsay #{animal} hello"
|
12
17
|
define_method animal do |*args|
|
13
|
-
render(args, IO.read(filename))
|
18
|
+
renderer.render(args, IO.read(filename))
|
14
19
|
end
|
15
20
|
end
|
16
21
|
|
17
22
|
desc "all <message>", "xsay all hello"
|
18
23
|
def all(*args)
|
19
|
-
|
20
|
-
|
21
|
-
|
24
|
+
animals = public_methods - Thor.new.methods - [:random, :all]
|
25
|
+
animals.each { |x| public_send(x, *args) }
|
26
|
+
nil
|
22
27
|
end
|
23
28
|
|
24
29
|
desc "random <message>", "xsay random hello"
|
25
30
|
def random(*args)
|
26
|
-
|
31
|
+
random_colour = (String.colors + [:rainbow]).sample
|
32
|
+
renderer.render(args, IO.read(ANIMALS.shuffle.sample), colour: random_colour)
|
27
33
|
end
|
28
34
|
|
29
35
|
private
|
30
36
|
|
31
|
-
def
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
#{line_break}
|
38
|
-
|
39
|
-
#{template}
|
40
|
-
MESSAGE
|
37
|
+
def renderer
|
38
|
+
Render.new(
|
39
|
+
colour: options[:colour].to_sym,
|
40
|
+
distance: options[:distance],
|
41
|
+
speed: options[:speed]
|
42
|
+
)
|
41
43
|
end
|
42
44
|
end
|
43
45
|
end
|
data/lib/xsay/render.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
module Xsay
|
2
|
+
class Render
|
3
|
+
attr_reader :colour, :distance, :speed
|
4
|
+
|
5
|
+
def initialize(
|
6
|
+
colour: options[:colour].to_sym,
|
7
|
+
distance: options[:distance],
|
8
|
+
speed: options[:speed]
|
9
|
+
)
|
10
|
+
@colour = colour.to_sym
|
11
|
+
@distance = distance
|
12
|
+
@speed = speed
|
13
|
+
end
|
14
|
+
|
15
|
+
def render(message, template)
|
16
|
+
message = message.join(' ') if message.respond_to?(:join)
|
17
|
+
line_break = "-" * message.length
|
18
|
+
each_frame do |frame|
|
19
|
+
draw(message, template, line_break, frame)
|
20
|
+
end
|
21
|
+
nil
|
22
|
+
end
|
23
|
+
|
24
|
+
def each_frame
|
25
|
+
return yield 0 unless move?
|
26
|
+
frames = distance.downto(0).to_a + 0.upto(distance).to_a
|
27
|
+
frames.each { |x| yield x }
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def draw(message, template, line_break, frame)
|
33
|
+
system 'clear' if move?
|
34
|
+
spaces = " " * frame
|
35
|
+
result = <<-MESSAGE
|
36
|
+
#{line_break}
|
37
|
+
< #{frame.even? ? message : ' ' * message.length} >
|
38
|
+
#{line_break}
|
39
|
+
|
40
|
+
#{template.gsub(/^/, "#{spaces}")}
|
41
|
+
MESSAGE
|
42
|
+
if colour == :rainbow
|
43
|
+
result.each_char.each_with_index do |x, i|
|
44
|
+
print x.colorize(String.colors[i % String.colors.size])
|
45
|
+
end
|
46
|
+
else
|
47
|
+
puts result.colorize(colour)
|
48
|
+
end
|
49
|
+
sleep speed if move?
|
50
|
+
end
|
51
|
+
|
52
|
+
def move?
|
53
|
+
distance > 0
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -1,15 +1,15 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
1
|
+
( )___( )
|
2
|
+
/__oo \
|
3
|
+
( \/ )
|
4
|
+
| `=/ |
|
5
|
+
/ \
|
6
|
+
/ / \ \
|
7
|
+
/ ( \ \
|
8
|
+
( ,_/_ \ \
|
9
|
+
\_ '= \ )
|
10
|
+
""' / /
|
11
|
+
; / /'?
|
12
|
+
: (((( /
|
13
|
+
`._ \ _ (
|
14
|
+
__| | /_
|
15
|
+
("__,.."'_._.)
|
@@ -0,0 +1,15 @@
|
|
1
|
+
,_ /) (\ _,
|
2
|
+
>> <<,_,>> <<
|
3
|
+
// _0.-.0_ \\
|
4
|
+
\'._/ \_.'/
|
5
|
+
'-.\.--.--./.-'
|
6
|
+
__/ : :Y: : \ _
|
7
|
+
';, .-(_| : : | : : |_)-. ,:'
|
8
|
+
\\/.' |: : :|: : :| `.\//
|
9
|
+
(/ |: : :|: : :| \)
|
10
|
+
|: : :|: : :;
|
11
|
+
/\ : : | : : /\
|
12
|
+
(_/'.: :.: :.'\_)
|
13
|
+
\\ `""`""` //
|
14
|
+
jgs \\ //
|
15
|
+
':. .:'
|
@@ -1,12 +1,12 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
1
|
+
_.-````'-,_
|
2
|
+
_,.,_ ,-'` `'-.,_
|
3
|
+
/) (\ '``-.
|
4
|
+
(( ) ) `\
|
5
|
+
\) (_/ )\
|
6
|
+
| /) ' ,' / \
|
7
|
+
`\ ^' ' ( / ))
|
8
|
+
| _/\ , / ,,`\ ( "`
|
9
|
+
\Y, | \ \ | ````| / \_ \
|
10
|
+
`)_/ \ \ ) ( > ( >
|
11
|
+
\( \( |/ |/
|
12
|
+
/_(/_( /_( /_(
|
@@ -1,11 +1,11 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
1
|
+
.==-. .-==.
|
2
|
+
\()8`-._ `. .' _.-'8()/
|
3
|
+
(88" ::. \./ .:: "88)
|
4
|
+
\_.'`-::::.(#).::::-'`._/
|
5
|
+
`._... .q(_)p. ..._.'
|
6
|
+
""-..-'|=|`-..-""
|
7
|
+
.""' .'|=|`. `"".
|
8
|
+
,':8(o)./|=|\.(o)8:`.
|
9
|
+
(O :8 ::/ \_/ \:: 8: O)
|
10
|
+
\O `::/ \::' O/
|
11
|
+
""--' `--"" hjw
|
@@ -0,0 +1,41 @@
|
|
1
|
+
_ _
|
2
|
+
/ '-' \
|
3
|
+
; ;
|
4
|
+
/'-| |-'\
|
5
|
+
| |_______K |
|
6
|
+
\ '-------' /
|
7
|
+
'.___.....___.'
|
8
|
+
| ; : ;|
|
9
|
+
_|;__;__.|_
|
10
|
+
| Y | .--.
|
11
|
+
.--. \__.'^'.__/ /; \
|
12
|
+
/ ;\ |_ ; _| | ' |
|
13
|
+
| ; | { `"""` } |; |
|
14
|
+
|' | { } | ; |
|
15
|
+
| ; | { } | |
|
16
|
+
|; | ;`-.__.'| |: ;|
|
17
|
+
| ; \ |; ; |_____/ ; |
|
18
|
+
| '.'-----' ' -_ .' /
|
19
|
+
\ '. - _ ' ; ; _ - .'
|
20
|
+
'. - - ; ; .------`
|
21
|
+
`--------. ;|
|
22
|
+
jgs |; , |
|
23
|
+
| ; |
|
24
|
+
|. ; |
|
25
|
+
| : :|
|
26
|
+
| . |
|
27
|
+
|; ; |
|
28
|
+
|; , |
|
29
|
+
| ; |
|
30
|
+
|. ; |
|
31
|
+
| : :|
|
32
|
+
| . |
|
33
|
+
|; ; |
|
34
|
+
|; , |
|
35
|
+
| ; |
|
36
|
+
| ; |
|
37
|
+
|. ; |
|
38
|
+
| : :|
|
39
|
+
| . |
|
40
|
+
|; ; |
|
41
|
+
`"-----"`
|
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
("`-''-/").___..--''"`-._
|
2
|
+
`6_ 6 ) `-. ( ).`-.__.`)
|
3
|
+
(_Y_.)' ._ ) `._ `. ``-..-'
|
4
|
+
_..`--'_..-_/ /--'_.' ,'
|
5
|
+
(il),-'' (li),' ((!.-'
|
@@ -0,0 +1,18 @@
|
|
1
|
+
. .
|
2
|
+
\'.____.'/
|
3
|
+
__'-. .-'__ .--.
|
4
|
+
'_i:'oo':i_'---...____...----i"""-.-'.-"\\
|
5
|
+
/._ _.\ : / '._ ;/ ;'-._
|
6
|
+
( o o ) '-.__.' '. '. '-."
|
7
|
+
'-.__.-' _.--. '-.:
|
8
|
+
: '-' / ; _..--, / ;
|
9
|
+
: '-._.-' ; ; : :
|
10
|
+
: ` .' '-._.' : /
|
11
|
+
\ : / ____....--\ :
|
12
|
+
'._\ :""""" '. !. :
|
13
|
+
: |: : 'www'| \ '|
|
14
|
+
| || | : | | :
|
15
|
+
| || | .' ! | |
|
16
|
+
.' !| | /__I | |
|
17
|
+
/__I.' ! .' !
|
18
|
+
/__I /__I fsc
|
@@ -1,25 +1,25 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
1
|
+
___ _...__
|
2
|
+
.-' '--._ .'_ '-.
|
3
|
+
.' .--._ '-._ .'.' \ '.
|
4
|
+
/ /__ `'. '. / / `\ \
|
5
|
+
/ / '-. `\ \ /'/' \ |
|
6
|
+
| | '. `\`\ / / _.-'| |
|
7
|
+
| | \ \ \ / / .' | /
|
8
|
+
\ / '. | |,-~-,/ / .' \ /
|
9
|
+
'--' __\ /__ '._.'
|
10
|
+
." '. .' ".
|
11
|
+
| '. .' |
|
12
|
+
\ ', '. .' .' /
|
13
|
+
/'-.""-._ \ / _.-"".-'\
|
14
|
+
_.=='''--,/ '/_.--._\'V'/_.--._\' \,--'''--._
|
15
|
+
.' _'-.__0_;\ /;_0__.-' _' '.
|
16
|
+
/ ,____..-'\'. """ -'/'--..____, \
|
17
|
+
/ ' \ .=. / ` \
|
18
|
+
| __ '-. .-=-. .-' __ |
|
19
|
+
\ _.--'' ''---'. .-=-. .'---'' ''--._ /
|
20
|
+
'----' .-' ___ '-. `----'
|
21
|
+
jgs ( ' ' )
|
22
|
+
'. _ .'
|
23
|
+
'--/ \--'
|
24
|
+
|#|
|
25
|
+
\_/
|