mirror of
https://github.com/edgecase/ruby_koans.git
synced 2026-04-15 07:23:19 -04:00
Updated for JRuby
This commit is contained in:
@@ -6,8 +6,14 @@ require 'test/unit/assertions'
|
||||
class FillMeInError < StandardError
|
||||
end
|
||||
|
||||
def in_ruby_version(version)
|
||||
yield if RUBY_VERSION =~ /^#{version}/
|
||||
def ruby_version?(version)
|
||||
RUBY_VERSION =~ /^#{version}/ ||
|
||||
(version == 'jruby' && defined?(JRUBY_VERSION)) ||
|
||||
(version == 'mri' && ! defined?(JRUBY_VERSION))
|
||||
end
|
||||
|
||||
def in_ruby_version(*versions)
|
||||
yield if versions.any? { |v| ruby_version?(v) }
|
||||
end
|
||||
|
||||
def __(value="FILL ME IN", value19=:mu)
|
||||
@@ -162,7 +168,7 @@ module EdgeCase
|
||||
print Color.green('.'*happy_steps)
|
||||
if failed?
|
||||
print Color.red('X')
|
||||
print Color.blue('_'*(bar_width-1-happy_steps))
|
||||
print Color.cyan('_'*(bar_width-1-happy_steps))
|
||||
end
|
||||
print Color.green(']')
|
||||
print " #{pass_count}/#{total_tests}"
|
||||
@@ -211,13 +217,13 @@ ENDTEXT
|
||||
def encourage
|
||||
puts
|
||||
puts "The Master says:"
|
||||
puts Color.blue(" You have not yet reached enlightenment.")
|
||||
puts Color.cyan(" You have not yet reached enlightenment.")
|
||||
if ((recents = progress.last(5)) && recents.size == 5 && recents.uniq.size == 1)
|
||||
puts Color.blue(" I sense frustration. Do not be afraid to ask for help.")
|
||||
puts Color.cyan(" I sense frustration. Do not be afraid to ask for help.")
|
||||
elsif progress.last(2).size == 2 && progress.last(2).uniq.size == 1
|
||||
puts Color.blue(" Do not lose hope.")
|
||||
puts Color.cyan(" Do not lose hope.")
|
||||
elsif progress.last.to_i > 0
|
||||
puts Color.blue(" You are progressing. Excellent. #{progress.last} completed.")
|
||||
puts Color.cyan(" You are progressing. Excellent. #{progress.last} completed.")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -242,12 +248,13 @@ ENDTEXT
|
||||
first_line = false
|
||||
Color.red(t)
|
||||
else
|
||||
Color.blue(t)
|
||||
Color.cyan(t)
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
def indent(text)
|
||||
text = text.split(/\n/) if text.is_a?(String)
|
||||
text.collect{|t| " #{t}"}
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user