render_cow 0.1.1 → 0.4.1

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: f65757949df56b4f3fc0221e5f3878c6066feffa91f42ed1f427f901c8d9fbd3
4
- data.tar.gz: 2c0c6ff6981c391daac34bb58aacb850695064df01e69f9f2d728dc4fbcb4c14
3
+ metadata.gz: 5d8d0306f6d09c9438067c27ca8b59ffd5274fa19ceaa018d6d0a5dec7866b8f
4
+ data.tar.gz: 64b7be668287af2ec38a2c786914dd3e3958c5b5d2608efaf95a9385d723d50e
5
5
  SHA512:
6
- metadata.gz: d5dd50e71aba84dfaaf7c711418f791a3aa01aa64dbfa82688cc50f11905f143ab9ea8485a39db44583a0f8fc697c186e8481af8ed194eaaee5f67a9318164f9
7
- data.tar.gz: 5d96b48571876d4cc96915fb5691e1d79ceb6dd6298fe760060ef0ef075ae6e7e594917f8ee22d097e40c5bc22c6ba2160ec184805991596ee3be9774b66cb64
6
+ metadata.gz: 864dd7a0f7eb396ea09d1846c216d2ccf002f4919bd28546fb1c778bda5b91f02400eb5803ea39238376b0805c15403797af4456b3528995504d380ae7209269
7
+ data.tar.gz: c17495a182ec24501d11f8ffed5e31f8de80e5a1f0be92fa3b6a0c344247b0353d7c898dcf0c2cf96f00157913a4f857ef8d161ddb17a2f0e2917dc2c88e5f08
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] = if cow?(options)
5
- cowspeach(options).then { RenderCow.moo(_1) }
6
- end
4
+ options[:plain] = cowspeach(options).then { RenderCow.moo(_1, character) } if character?(options)
7
5
  super
8
6
  end
9
7
 
10
8
  private
11
9
 
12
- def cow?(options)
13
- options[:cow] || options[:cowsay]
10
+ def character(options = {})
11
+ options[:cow] = options.delete(:cowsay) if options.key?(:cowsay)
12
+ @character ||= options.detect do |key, _value|
13
+ RenderCow.characters.find { _1 == key }
14
+ end&.first
15
+ end
16
+
17
+ def character?(options)
18
+ return unless options.is_a?(Hash)
19
+
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.1.1'.freeze
2
+ VERSION = '0.4.1'.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.1.1
4
+ version: 0.4.1
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