xsay 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/exe/xsay +5 -0
  3. data/lib/xsay.rb +18 -16
  4. data/lib/xsay/render.rb +56 -0
  5. data/lib/xsay/templates/ant.template +10 -0
  6. data/lib/xsay/templates/banana.template +4 -0
  7. data/lib/xsay/templates/bear.template +15 -15
  8. data/lib/xsay/templates/beaver.template +10 -0
  9. data/lib/xsay/templates/bee.template +10 -0
  10. data/lib/xsay/templates/beetle.template +15 -0
  11. data/lib/xsay/templates/bison.template +12 -0
  12. data/lib/xsay/templates/buffalo.template +12 -12
  13. data/lib/xsay/templates/bull.template +8 -0
  14. data/lib/xsay/templates/butterfly.template +11 -11
  15. data/lib/xsay/templates/cactus.template +41 -0
  16. data/lib/xsay/templates/cat.template +5 -5
  17. data/lib/xsay/templates/caterpillar.template +3 -0
  18. data/lib/xsay/templates/cow.template +18 -0
  19. data/lib/xsay/templates/coyote.template +25 -25
  20. data/lib/xsay/templates/crab.template +14 -0
  21. data/lib/xsay/templates/dinosaur.template +19 -0
  22. data/lib/xsay/templates/dolphin.template +17 -0
  23. data/lib/xsay/templates/door.template +13 -0
  24. data/lib/xsay/templates/dragon.template +19 -19
  25. data/lib/xsay/templates/elephant.template +12 -12
  26. data/lib/xsay/templates/frog.template +17 -0
  27. data/lib/xsay/templates/giraffe.template +23 -23
  28. data/lib/xsay/templates/gorilla.template +10 -10
  29. data/lib/xsay/templates/grassphopper.template +4 -4
  30. data/lib/xsay/templates/hamster.template +12 -0
  31. data/lib/xsay/templates/hedgehog.template +25 -25
  32. data/lib/xsay/templates/kangaroo.template +22 -22
  33. data/lib/xsay/templates/koala.template +15 -15
  34. data/lib/xsay/templates/leopard.template +18 -18
  35. data/lib/xsay/templates/monkey.template +35 -35
  36. data/lib/xsay/templates/moose.template +23 -23
  37. data/lib/xsay/templates/penguin.template +21 -21
  38. data/lib/xsay/templates/pig.template +10 -10
  39. data/lib/xsay/templates/porcupine.template +10 -10
  40. data/lib/xsay/templates/robot.template +23 -23
  41. data/lib/xsay/templates/shark.template +25 -25
  42. data/lib/xsay/templates/skunk.template +29 -0
  43. data/lib/xsay/templates/sloth.template +17 -0
  44. data/lib/xsay/templates/snail.template +14 -0
  45. data/lib/xsay/templates/snake.template +16 -16
  46. data/lib/xsay/templates/vulture.template +13 -0
  47. data/lib/xsay/templates/whale.template +10 -10
  48. data/lib/xsay/templates/wolf.template +22 -22
  49. data/lib/xsay/version.rb +1 -1
  50. data/xsay.gemspec +1 -0
  51. metadata +37 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: da403ee03507c6166b8e37febef799b2c0f9aea3fc410ea62141fe2616b01dd6
4
- data.tar.gz: a791a342b414ce587290ef8ce888a448d61b88dced992bcff5917ddc832aa8a2
3
+ metadata.gz: d0231aa2358f33b0120bc830711cb8cc0dfb04cba272599a83cb7260cf5f7441
4
+ data.tar.gz: b0c35281b531aac3d0878d69aeae79cb7d06759ea276ee7141d7051c8246d703
5
5
  SHA512:
6
- metadata.gz: 84334bdc4466855689dd6db479a8df0c969437e716d6d9943f2b0052b7ad006c8ff8671fe1435da1a15f94cd2f663043018714df770ada87febc47ee8e78322d
7
- data.tar.gz: ecf1d4fe18be44db9ec5b7f320fa98277b3d3de454820a35a907797e51cc0430c31ce3fc8725f4865dec3dbf05839bd734badf3e68d95f3620aa9c73d72ab6c3
6
+ metadata.gz: b6fc8dc14a943b01f5fac7b6d8a65a0833769262140e217e4ea5715d25fd35a7d6eaf8498863511faca1266f99e773e2a1e5b27b854bb347f61bb065f74db81a
7
+ data.tar.gz: 8585c6d4dd76b43102c088283d018b7b4a4322e549da99f495651b763798b496f640276b61ce2b04f1cf5023872f84a0ece08a5b603b188337ebeabb6aac3b4e
data/exe/xsay CHANGED
@@ -2,4 +2,9 @@
2
2
 
3
3
  require "xsay"
4
4
 
5
+ trap :SIGINT do
6
+ puts "Good bye!"
7
+ exit 0
8
+ end
9
+
5
10
  Xsay::CLI.start(ARGV)
@@ -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
- ANIMALS.each do |filename|
20
- render(args, IO.read(filename))
21
- end
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
- render(args, IO.read(ANIMALS.shuffle.sample))
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 render(message, template)
32
- message = message.join(' ') if message.respond_to?(:join)
33
- line_break = "-" * message.length
34
- say <<-MESSAGE
35
- #{line_break}
36
- < #{message} >
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
@@ -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
@@ -0,0 +1,10 @@
1
+ \ /
2
+ \ /
3
+ \.-./
4
+ (o\^/o) _ _ _ __
5
+ ./ \.\ ( )-( )-( ) .-' '-.
6
+ {-} \(// || \\/ ( )) '-.
7
+ //-__||__.-\\. .-'
8
+ (/ () \)'-._.-'
9
+ || || \\
10
+ MJP (' (' ')
@@ -0,0 +1,4 @@
1
+ ". ,#
2
+ \ `-._____,-'=/
3
+ ____`._ ----- _,'_____PhS
4
+ `-----'
@@ -1,15 +1,15 @@
1
- ( )___( )
2
- /__oo \
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,10 @@
1
+ _,--""--,_
2
+ _,,-" \
3
+ ,-e" ;
4
+ (* \ |
5
+ \o\ __,-" ) |
6
+ `,_ (((__,-" L___,,--,,__
7
+ ) ,---\ /\ / -- '' -'-' )
8
+ _/ / )_|| /---,,___ __/
9
+ """" """"|_ / ""
10
+ """"
@@ -0,0 +1,10 @@
1
+ __/ _
2
+ .__ __. \__/ __
3
+ .-`'-. / \__/
4
+ .-.( oo ).-. _/ \__/
5
+ __ : \".~~."/ ; \__/
6
+ / \_`. Y`--'Y .' _/ \__
7
+ __/ `./======\.' \__/ \_
8
+ / \__/ \======/ \__/ \__/
9
+ \__/ (_`----'_) \__/ \ (PS)
10
+ """""""""""""""""""""""""""""""""
@@ -0,0 +1,15 @@
1
+ ,_ /) (\ _,
2
+ >> <<,_,>> <<
3
+ // _0.-.0_ \\
4
+ \'._/ \_.'/
5
+ '-.\.--.--./.-'
6
+ __/ : :Y: : \ _
7
+ ';, .-(_| : : | : : |_)-. ,:'
8
+ \\/.' |: : :|: : :| `.\//
9
+ (/ |: : :|: : :| \)
10
+ |: : :|: : :;
11
+ /\ : : | : : /\
12
+ (_/'.: :.: :.'\_)
13
+ \\ `""`""` //
14
+ jgs \\ //
15
+ ':. .:'
@@ -0,0 +1,12 @@
1
+ _.-````'-,_
2
+ _,.,_ ,-'` `'-.,_
3
+ /) (\ '``-.
4
+ (( ) ) `\
5
+ \) (_/ )\
6
+ | /) ' ,' / \
7
+ `\ ^' ' ( / ))
8
+ | _/\ , / ,,`\ ( "`
9
+ \Y, | \ \ | ````| / \_ \
10
+ `)_/ \ \ ) ( > ( >
11
+ \( \( |/ |/
12
+ /_(/_( /_( /_(
@@ -1,12 +1,12 @@
1
- _.-````'-,_
2
- _,.,_ ,-'` `'-.,_
3
- /) (\ '``-.
4
- (( ) ) `\
5
- \) (_/ )\
6
- | /) ' ,' / \
7
- `\ ^' ' ( / ))
8
- | _/\ , / ,,`\ ( "`
9
- \Y, | \ \ | ````| / \_ \
10
- `)_/ \ \ ) ( > ( >
11
- \( \( |/ |/
12
- /_(/_( /_( /_(
1
+ _.-````'-,_
2
+ _,.,_ ,-'` `'-.,_
3
+ /) (\ '``-.
4
+ (( ) ) `\
5
+ \) (_/ )\
6
+ | /) ' ,' / \
7
+ `\ ^' ' ( / ))
8
+ | _/\ , / ,,`\ ( "`
9
+ \Y, | \ \ | ````| / \_ \
10
+ `)_/ \ \ ) ( > ( >
11
+ \( \( |/ |/
12
+ /_(/_( /_( /_(
@@ -0,0 +1,8 @@
1
+ ,/ \,
2
+ ((__,-"""-,__))
3
+ `--)~ ~(--`
4
+ .-'( )`-,
5
+ `~~`d\ /b`~~`
6
+ | |
7
+ jgs (6___6)
8
+ `---`
@@ -1,11 +1,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
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
- `6_ 6 ) `-. ( ).`-.__.`)
3
- (_Y_.)' ._ ) `._ `. ``-..-'
4
- _..`--'_..-_/ /--'_.' ,'
5
- (il),-'' (li),' ((!.-'
1
+ ("`-''-/").___..--''"`-._
2
+ `6_ 6 ) `-. ( ).`-.__.`)
3
+ (_Y_.)' ._ ) `._ `. ``-..-'
4
+ _..`--'_..-_/ /--'_.' ,'
5
+ (il),-'' (li),' ((!.-'
@@ -0,0 +1,3 @@
1
+ \_/-.--.--.--.--.--.
2
+ (")__)__)__)__)__)__)
3
+ jgs ^ "" "" "" "" "" ""
@@ -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
- _.=='''--,/ '/_.--._\'V'/_.--._\' \,--'''--._
15
- .' _'-.__0_;\ /;_0__.-' _' '.
16
- / ,____..-'\'. """ -'/'--..____, \
17
- / ' \ .=. / ` \
18
- | __ '-. .-=-. .-' __ |
19
- \ _.--'' ''---'. .-=-. .'---'' ''--._ /
20
- '----' .-' ___ '-. `----'
21
- jgs ( ' ' )
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
+ \_/
@@ -0,0 +1,14 @@
1
+ ___ ___
2
+ .i .-' `-. i.
3
+ .' `/ \' _`.
4
+ |,-../ o o \.' `|
5
+ (| | / _\ /_ \ | |)
6
+ \\\ (_.'.'"`.`._) ///
7
+ \\`._(..: :..)_.'//
8
+ \`.__\ .:-:. /__.'/
9
+ `-i-->.___.<--i-'
10
+ .'.-'/.=^=.\`-.`.
11
+ /.' // \\ `.\
12
+ || || || ||
13
+ \) || || (/
14
+ \) (/ hjw