render_cow 0.1.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: e4a2989724e7c234a8e9d62f58ee931b50c9ec6ef22c8642a2dcf9f3eddaeb69
4
- data.tar.gz: d93dd4c5e4c62ceebb76b7f0b303c3ce7575941dd8bad9f1d5b58c73d62262f7
3
+ metadata.gz: 6d5c7313dcde9bfd0cbf7724b906a5f0c3e6e5e07bf08cf07f9f60af6f896f05
4
+ data.tar.gz: 68daaa2be57d59a898eba5223782470ebdc4e06fa2abcc6371444f8728310119
5
5
  SHA512:
6
- metadata.gz: 53779aaef4f66110e4a55aaed41dcd74439c069e93599de26bfcac5d4175ce2a53a1f66d3d1cd2c1ab5f2b539d71576484efe1035cf3ba1e5df0498b0bcbf4b3
7
- data.tar.gz: e93bb3b83952556b1bd1ffe56ca7c0029912c34aaf82f30cc6806a7e7dcaf6b135fde9927349eff488137411c2c0bf1b056dff3c5fcf10f552ceb19ebdf87f49
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] = 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|
13
+ RenderCow.characters.find(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.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.1.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
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: rails
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 6.1.4
33
+ version: '6.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 6.1.4
40
+ version: '6.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: byebug
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -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