Permalink
Browse files

Add support for emoji themes! ๐Ÿฎ

  • Loading branch information...
sentientmonkey committed Jun 25, 2013
1 parent 95fbc99 commit 386b48159a8415ba83968183916922da5565fe8c
View
@@ -5,4 +5,11 @@ README.rdoc
Rakefile
lib/minitest/emoji.rb
lib/minitest/emoji_plugin.rb
+lib/minitest/emoji/themes/default.rb
+lib/minitest/emoji/themes/apples.rb
+lib/minitest/emoji/themes/similies.rb
+lib/minitest/emoji/themes/kitties.rb
+lib/minitest/emoji/themes/hearts.rb
+lib/minitest/emoji/themes/weather.rb
+lib/minitest/emoji/themes/xoxo.rb
test/test_minitest_emoji.rb
@@ -0,0 +1,8 @@
+module Minitest
+ Emoji.add_theme :apples, {
+ '.' => "\u{1f34f} ",
+ 'E' => "\u{1f34e} ",
+ 'F' => "\u{1f34a} ",
+ 'S' => "\u{1f34b} ",
+ }
+end
@@ -0,0 +1,8 @@
+module Minitest
+ Emoji.add_theme :default, {
+ '.' => "\u{1F49A} ",
+ 'E' => "\u{1f525} ",
+ 'F' => "\u{1f4a9} ",
+ 'S' => "\u{1f633} ",
+ }
+end
@@ -0,0 +1,8 @@
+module Minitest
+ Emoji.add_theme :hearts, {
+ '.' => "\u{1f49a} ",
+ 'E' => "\u{1f49b} ",
+ 'F' => "\u{1f494} ",
+ 'S' => "\u{1f499} ",
+ }
+end
@@ -0,0 +1,8 @@
+module Minitest
+ Emoji.add_theme :kitties, {
+ '.' => "\u{1f63b} ",
+ 'E' => "\u{1F63F} ",
+ 'F' => "\u{1f640} ",
+ 'S' => "\u{1F63D} ",
+ }
+end
@@ -0,0 +1,8 @@
+module Minitest
+ Emoji.add_theme :similies, {
+ '.' => "\u{1F60D} ",
+ 'E' => "\u{1F631} ",
+ 'F' => "\u{1F621} ",
+ 'S' => "\u{1F61C} ",
+ }
+end
@@ -0,0 +1,8 @@
+module Minitest
+ Emoji.add_theme :weather, {
+ '.' => "\u{2600} ",
+ 'E' => "\u{2614} ",
+ 'F' => "\u{26a1} ",
+ 'S' => "\u{2601} ",
+ }
+end
@@ -0,0 +1,8 @@
+module Minitest
+ Emoji.add_theme :xoxo, {
+ '.' => "\u{2b55} ",
+ 'E' => "\u{2049} ",
+ 'F' => "\u{274c} ",
+ 'S' => "\u{2753} ",
+ }
+end
@@ -6,6 +6,15 @@ def self.plugin_emoji_options opts, options # :nodoc:
opts.on "-e", "--emoji", "Show Emoji instead of dots" do
Emoji.emoji!
end
+ opts.on "-t", "--theme [name]", "Pick an emoji theme" do |name|
+ unless name
+ puts "Choose from these themes:"
+ Emoji.themes.keys.each{|theme| puts " #{theme}" }
+ puts "...or, 'random' for a random theme"
+ exit 1
+ end
+ Emoji.theme! name
+ end
end
def self.plugin_emoji_init options # :nodoc:
@@ -22,13 +31,6 @@ class Emoji
VERSION = '1.0.0'
- DEFAULT = {
- '.' => "\u{1F49A} ",
- 'E' => "\u{1f525} ",
- 'F' => "\u{1f4a9} ",
- 'S' => "\u{1f633} ",
- }
-
attr_reader :io, :chars
def self.emoji!
@@ -39,9 +41,32 @@ def self.emoji?
@emoji ||= false
end
- def initialize io, chars = DEFAULT
+ def self.theme! name
+ if name == "random"
+ name = self.themes.keys.sample
+ end
+ unless self.themes.include? name.to_sym
+ puts "Theme #{name} not found."
+ exit 1
+ end
+ @theme ||= self.themes[name.to_sym]
+ end
+
+ def self.theme
+ @theme ||= self.themes[:default]
+ end
+
+ def self.themes
+ @themes ||= {}
+ end
+
+ def self.add_theme name, chars
+ self.themes[name.to_sym] = chars
+ end
+
+ def initialize io
@io = io
- @chars = DEFAULT
+ @chars = self.class.theme
end
def print o
@@ -54,3 +79,6 @@ def method_missing msg, *args
end
end
end
+
+# require all the themes
+Dir[File.join(File.dirname(__FILE__), 'emoji', 'themes', '*.rb')].each {|file| require file }
@@ -19,4 +19,10 @@
it 'skips things!!' do
skip "don't care!"
end
+
+ 3.times do
+ it "errors" do
+ raise "ru roh"
+ end
+ end
end

0 comments on commit 386b481

Please sign in to comment.