render_cow 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 82ce86e323ec73099b60111bee9d28c170764cee605928ebe679f91b4cf6ca43
4
- data.tar.gz: 1549fa1e53d89399a1ad4fbe2c2940ef189c90f4be8c5b5da59e4e28bf36c9f8
3
+ metadata.gz: 6d5c7313dcde9bfd0cbf7724b906a5f0c3e6e5e07bf08cf07f9f60af6f896f05
4
+ data.tar.gz: 68daaa2be57d59a898eba5223782470ebdc4e06fa2abcc6371444f8728310119
5
5
  SHA512:
6
- metadata.gz: bea9fa45f2da14d2663657681b5a3310daaa7cec6bbf0896a67bbc7a5d239acf1bcbb872f36586f8df5fa6f8475342f6c13d716919d47e6536c587a30b1a8577
7
- data.tar.gz: f183ff28444d7348e4de03b06d26bd03aa64f5030b102299d3e6763029d39e7fa47d5973dc79f35ab604d2723253fb9ac2a8df656fbc03a825e76c6ede46bd59
6
+ metadata.gz: cf75f0d43da2c17b8d93783a0d30f4cd145c7a28a105e911f19ecae9e548d824f745c2cef0d7d9cb31707c94c5d655eae8f6a8ee8e0230ecc3ffa3a62c31641e
7
+ data.tar.gz: 7d68b7a173577a1acc793b5c99a7900e4e941304c644153241aa3930cafdddbe50b62b49a72179554512f3258e16647b243af99f3d8140385723e8d645d0a2ef
data/README.md CHANGED
@@ -1,20 +1,25 @@
1
- _____
2
- | RenderCow |
3
- -----
1
+ ```bash
2
+ ______________________
3
+ | RenderCow! |
4
+ ----------------------
4
5
  \ ^__^
5
6
  \ (oo)\_______
6
7
  (__)\ )\/\
7
8
  ||----w |
8
9
  || ||
9
10
 
11
+ ```
10
12
  RenderCow cowpatches the Rails render method to allow you to directly use cowsay.
11
13
  Have you ever wanted to just render a cow?
12
14
  Well now you can!
13
15
 
16
+ [See RenderCow in Action!](https://wasurechatta.com/moo?moo=RenderCow%20in%20action!)
14
17
 
15
18
  ## Usage
16
19
 
17
20
  In your controller, replace calls with `render plain:` to `render cowsay:` or `render cow:`.
21
+ (You can still use render plain: and render partial: and others too, but you get invested cow superpowers by this gem)
22
+
18
23
 
19
24
  ```ruby
20
25
  class ApplicationController < ActionController::Base
@@ -28,6 +33,18 @@ class ApplicationController < ActionController::Base
28
33
  end
29
34
  ```
30
35
 
36
+ But that is not all!
37
+ You also have the following render-options:
38
+ ```ruby
39
+ [:spongebob, :beavis, :bunny, :cheese, :cow, :daemon, :dragon, :elephant, :frogs, :ghostbusters, :kitty, :koala, :moose, :ren, :sheep, :stegosaurus, :stimpy, :turkey, :turtle, :tux]
40
+ ```
41
+
42
+ So feel free to call `render spongebob: iS thIs A mEme?` from your controllers!
43
+
44
+ Todo:
45
+ Make Spongebob do the meme talk automatically.
46
+ There is already a gem for that.
47
+
31
48
  ## Installation
32
49
  Add this line to your application's Gemfile:
33
50
 
@@ -45,6 +62,9 @@ Or install it yourself as:
45
62
  $ gem install render_cow
46
63
  ```
47
64
 
65
+ This gem uses [cowsay](https://rubygems.org/gems/cowsay) as the cow rendering engine.
66
+ So this gem is just the Rails cow patch on the render method.
67
+
48
68
  ## Contributing
49
69
  Feel free to contribute.
50
70
 
@@ -1,24 +1,27 @@
1
1
  module RenderCow
2
2
  module RenderCowPatch
3
3
  def render(options = {}, args = {})
4
- options[:plain] = cowspeach(options).then { RenderCow.moo(_1) } if cow?(options)
4
+ options[:plain] = cowspeach(options).then { RenderCow.moo(_1, character) } if character?(options)
5
5
  super
6
6
  end
7
7
 
8
8
  private
9
9
 
10
- def cow?(options)
10
+ def character(options = {})
11
+ options[:cow] = options.delete(:cowsay) if options.key?(:cowsay)
12
+ @character ||= options.detect do |key|
13
+ RenderCow.characters.find(key)
14
+ end&.first
15
+ end
16
+
17
+ def character?(options)
11
18
  return unless options.is_a?(Hash)
12
19
 
13
- options[:cow] || options[:cowsay]
20
+ character(options).present?
14
21
  end
15
22
 
16
23
  def cowspeach(options = {})
17
- if options.key?(:cow)
18
- options[:cow]
19
- elsif options.key?(:cowsay)
20
- options[:cowsay]
21
- end
24
+ options[character]
22
25
  end
23
26
  end
24
27
  end
@@ -0,0 +1,39 @@
1
+ module Cowsay
2
+ module Character
3
+ class Spongebob < Base
4
+ def template
5
+ <<~TEMPLATE
6
+ #{@thoughts}
7
+ #{@thoughts}
8
+ ,____#{" "}
9
+ (% ..* #)#{" "}
10
+ (\\ .*\\ #{" "}
11
+ *\\ @ (.\\ #{" "}
12
+ (\\ , / , \\&#{" "}
13
+ .,,*((,.*% @@.,,,,....,,,(#(,.,..,,.##{" "}
14
+ *(,../#####//../@@#&.,,*(#(*,..,...,.,..,.(#{" "}
15
+ .(*.,,,,,.####.,/(****&(,.,/((((,.,.../.,.,...(#{" "}
16
+ #....,,.....,,.(*****/((..........,.....*...####..##{" "}
17
+ (.**..........%%(#@........*,.....,/...,.(####.., /@@#{" "}
18
+ /..,/(**.................#.,%&&@(.....,,.(#(.../ / /\\ ////#{" "}
19
+ ,& .. .,.............& ...../..,.,#*,. /, /\\ \\/ *.(#{" "}
20
+ ///(@@) *............* (/@*@),....*.,.##.,. / )/ \\ \\, .. %*&#{" "}
21
+ . .. *..............& ., @.......,,,..*(__ / &.,*,.%%#{" "}
22
+ %&%@/...&..#............(......,(....,.,,,,.##% #(((//@.#*,..&#{" "}
23
+ (@.....%..............................,..###*,,.,,.**.@, .,@&#{" "}
24
+ /......(..,/............,................,......*#/.,,..(%@@%%%@#{" "}
25
+ @............@&&&&&&&@#*........,,,.....*......,.*...@@@%%%%.#{" "}
26
+ %........./&&&#.......%@/....*//*///.....,....,,.(....&%.#{" "}
27
+ @....... (*..,@,....................*/*/.....*,**,(*(#{" "}
28
+ &....( ,%*.......................*#%%@#{" "}
29
+ #.( %%%%%%%%@ &%%@%%%%%#{" "}
30
+ *.**@@@ ..%%%,#{" "}
31
+ (*.*# ..%#{" "}
32
+ .@@@@@@&(@ @%, .*&@@@#{" "}
33
+ @@@@@@@@@ @@@@@#{" "}
34
+ *@@&@@@@#{" "}
35
+ TEMPLATE
36
+ end
37
+ end
38
+ end
39
+ end
@@ -1,3 +1,3 @@
1
1
  module RenderCow
2
- VERSION = '0.3.0'.freeze
2
+ VERSION = '0.4.0'.freeze
3
3
  end
data/lib/render_cow.rb CHANGED
@@ -1,8 +1,14 @@
1
1
  require 'render_cow/version'
2
2
  require 'render_cow/engine'
3
-
3
+ require 'render_cow/spongebob'
4
4
  module RenderCow
5
- def self.moo(mooo)
6
- Cowsay::Character::Cow.say(mooo)
5
+ class << self
6
+ def characters
7
+ @characters ||= Cowsay::Character.constants.map(&:downcase).map(&:to_sym).excluding(:base)
8
+ end
9
+
10
+ def moo(mooo, character = :cow)
11
+ Cowsay::Character.const_get(character.to_s.capitalize).say(mooo)
12
+ end
7
13
  end
8
14
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: render_cow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sampo Kuokkanen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-30 00:00:00.000000000 Z
11
+ date: 2021-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cowsay
@@ -94,6 +94,7 @@ files:
94
94
  - lib/render_cow.rb
95
95
  - lib/render_cow/engine.rb
96
96
  - lib/render_cow/render_cow_patch.rb
97
+ - lib/render_cow/spongebob.rb
97
98
  - lib/render_cow/version.rb
98
99
  - lib/tasks/render_cow_tasks.rake
99
100
  homepage: https://github.com/sampokuokkanen/render_cow