Skip to content

Commit

Permalink
Add support for emoji themes! 🐮
Browse files Browse the repository at this point in the history
  • Loading branch information
sentientmonkey committed Nov 14, 2013
1 parent 95fbc99 commit 386b481
Show file tree
Hide file tree
Showing 10 changed files with 106 additions and 9 deletions.
7 changes: 7 additions & 0 deletions Manifest.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 8 additions & 0 deletions lib/minitest/emoji/themes/apples.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module Minitest
Emoji.add_theme :apples, {
'.' => "\u{1f34f} ",
'E' => "\u{1f34e} ",
'F' => "\u{1f34a} ",
'S' => "\u{1f34b} ",
}
end
8 changes: 8 additions & 0 deletions lib/minitest/emoji/themes/default.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module Minitest
Emoji.add_theme :default, {
'.' => "\u{1F49A} ",
'E' => "\u{1f525} ",
'F' => "\u{1f4a9} ",
'S' => "\u{1f633} ",
}
end
8 changes: 8 additions & 0 deletions lib/minitest/emoji/themes/hearts.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module Minitest
Emoji.add_theme :hearts, {
'.' => "\u{1f49a} ",
'E' => "\u{1f49b} ",
'F' => "\u{1f494} ",
'S' => "\u{1f499} ",
}
end
8 changes: 8 additions & 0 deletions lib/minitest/emoji/themes/kitties.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module Minitest
Emoji.add_theme :kitties, {
'.' => "\u{1f63b} ",
'E' => "\u{1F63F} ",
'F' => "\u{1f640} ",
'S' => "\u{1F63D} ",
}
end
8 changes: 8 additions & 0 deletions lib/minitest/emoji/themes/similies.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module Minitest
Emoji.add_theme :similies, {
'.' => "\u{1F60D} ",
'E' => "\u{1F631} ",
'F' => "\u{1F621} ",
'S' => "\u{1F61C} ",
}
end
8 changes: 8 additions & 0 deletions lib/minitest/emoji/themes/weather.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module Minitest
Emoji.add_theme :weather, {
'.' => "\u{2600} ",
'E' => "\u{2614} ",
'F' => "\u{26a1} ",
'S' => "\u{2601} ",
}
end
8 changes: 8 additions & 0 deletions lib/minitest/emoji/themes/xoxo.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module Minitest
Emoji.add_theme :xoxo, {
'.' => "\u{2b55} ",
'E' => "\u{2049} ",
'F' => "\u{274c} ",
'S' => "\u{2753} ",
}
end
46 changes: 37 additions & 9 deletions lib/minitest/emoji_plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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!
Expand All @@ -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
Expand All @@ -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 }
6 changes: 6 additions & 0 deletions test/test_minitest_emoji.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.