render_cow 0.2.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ef0db4905fa9e892bca2a28a1617548b626d1f9a49e357cceed69cada6c33446
4
- data.tar.gz: 5b1d30423015e220f848206814fb25b760a67585875e3f8f15d8a1f3c24cf961
3
+ metadata.gz: 0c7f9a6ae61189ba38b8e621cf17cf0fe2f93a69b2ca11c057331e180c0f669e
4
+ data.tar.gz: 06f370a02567642bfbc5a0b7b87201ed2a24cb0911297f696d53e9bc3c74e985
5
5
  SHA512:
6
- metadata.gz: 07e3b1181b51d985eb982a49097af060df035bdadfba0f70df0cb6b0aec920ea3a3bee8ebb3164fca8b31953d3186f3d49c3137c34d29d092ad3b6c0160ae89b
7
- data.tar.gz: 50f84d72a686f01974c69a725d0c9dd357a047606dbae565e76be581cc8facd90eef5ddd81bb3c62c24fe65a168c8d88267ea01ac58090a5b78258afdb5a6b63
6
+ metadata.gz: b35a83a7dffc664370f7d2d862d64d50012ab850dcf20473eae14ad3d43658e86bea1b3a6392c8435e6feb3762138f00987412e9ad93f1cef571d6110be6443b
7
+ data.tar.gz: 6d10aee2509a2a17972a267851b957374ac59d8134da5ff4278ba64019effc7247be23f1f92b26f47e4695f56b6a07198772d96c651eaac05a9db60fdb0fb8c6
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,16 @@ 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
+ Note that SpongeBob does the meme talk automatically and there is no way to turn it off.
45
+
31
46
  ## Installation
32
47
  Add this line to your application's Gemfile:
33
48
 
@@ -45,6 +60,9 @@ Or install it yourself as:
45
60
  $ gem install render_cow
46
61
  ```
47
62
 
63
+ This gem uses [cowsay](https://rubygems.org/gems/cowsay) as the cow rendering engine.
64
+ So this gem is just the Rails cow patch on the render method.
65
+
48
66
  ## Contributing
49
67
  Feel free to contribute.
50
68
 
@@ -1,22 +1,29 @@
1
+ require 'spongebobify'
1
2
  module RenderCow
2
3
  module RenderCowPatch
3
4
  def render(options = {}, args = {})
4
- options[:plain] = cowspeach(options).then { RenderCow.moo(_1) } if cow?(options)
5
+ options[:plain] = cowspeach(options).then { RenderCow.moo(_1, character) } if character?(options)
5
6
  super
6
7
  end
7
8
 
8
9
  private
9
10
 
10
- def cow?(options)
11
- options[:cow] || options[:cowsay]
11
+ def character(options = {})
12
+ options[:cow] = options.delete(:cowsay) if options.key?(:cowsay)
13
+ @character ||= options.detect do |key, _value|
14
+ RenderCow.characters.find { _1 == key }
15
+ end&.first
16
+ end
17
+
18
+ def character?(options)
19
+ return unless options.is_a?(Hash)
20
+
21
+ character(options).present?
12
22
  end
13
23
 
14
24
  def cowspeach(options = {})
15
- if options.key?(:cow)
16
- options[:cow]
17
- elsif options.key?(:cowsay)
18
- options[:cowsay]
19
- end
25
+ speach = options[character]
26
+ character == :spongebob ? speach.spongebobify : speach
20
27
  end
21
28
  end
22
29
  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.2.0'.freeze
2
+ VERSION = '0.5.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.2.0
4
+ version: 0.5.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-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cowsay
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '6.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: spongebobify
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 0.1.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 0.1.0
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: byebug
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -94,6 +108,7 @@ files:
94
108
  - lib/render_cow.rb
95
109
  - lib/render_cow/engine.rb
96
110
  - lib/render_cow/render_cow_patch.rb
111
+ - lib/render_cow/spongebob.rb
97
112
  - lib/render_cow/version.rb
98
113
  - lib/tasks/render_cow_tasks.rake
99
114
  homepage: https://github.com/sampokuokkanen/render_cow