From 6fd8668b7029b34b6c6354b58e217ede44bc415e Mon Sep 17 00:00:00 2001 From: ahmed80dz Date: Tue, 23 Aug 2011 02:24:10 +0200 Subject: [PATCH 1/7] using windows32console gem for colors --- koans/edgecase.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/koans/edgecase.rb b/koans/edgecase.rb index ba49956..8d9646b 100644 --- a/koans/edgecase.rb +++ b/koans/edgecase.rb @@ -107,7 +107,9 @@ module EdgeCase def use_colors? return false if ENV['NO_COLOR'] if ENV['ANSI_COLOR'].nil? - ! using_windows? + if using_windows? + using_win32console + end else ENV['ANSI_COLOR'] =~ /^(t|y)/i end @@ -116,6 +118,13 @@ module EdgeCase def using_windows? File::ALT_SEPARATOR end + def using_win32console + begin + !! Win32::Console::ANSI + rescue + return false + end + end end class Sensei From 4be16207596f41f0eaccd7fdf2252a706419179a Mon Sep 17 00:00:00 2001 From: ahmed80dz Date: Tue, 23 Aug 2011 02:34:01 +0200 Subject: [PATCH 2/7] forgot requires --- koans/edgecase.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/koans/edgecase.rb b/koans/edgecase.rb index 8d9646b..091dbda 100644 --- a/koans/edgecase.rb +++ b/koans/edgecase.rb @@ -2,7 +2,8 @@ # -*- ruby -*- require 'test/unit/assertions' - +require 'rubygems' +require 'win32console' # -------------------------------------------------------------------- # Support code for the Ruby Koans. # -------------------------------------------------------------------- From 0032cee9a6a037408282058af3a44e8ee1265651 Mon Sep 17 00:00:00 2001 From: ahmed80dz Date: Tue, 23 Aug 2011 14:28:00 +0200 Subject: [PATCH 3/7] Edited koans/edgecase.rb via GitHub --- koans/edgecase.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/koans/edgecase.rb b/koans/edgecase.rb index 091dbda..82159ba 100644 --- a/koans/edgecase.rb +++ b/koans/edgecase.rb @@ -2,7 +2,6 @@ # -*- ruby -*- require 'test/unit/assertions' -require 'rubygems' require 'win32console' # -------------------------------------------------------------------- # Support code for the Ruby Koans. From dd36e171b0e51a522539f38dc5e958a3f1c1d470 Mon Sep 17 00:00:00 2001 From: ahmed80dz Date: Fri, 7 Oct 2011 22:18:59 +0200 Subject: [PATCH 4/7] testing for win32console --- koans/edgecase.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/koans/edgecase.rb b/koans/edgecase.rb index 82159ba..8a0c988 100644 --- a/koans/edgecase.rb +++ b/koans/edgecase.rb @@ -2,7 +2,12 @@ # -*- ruby -*- require 'test/unit/assertions' -require 'win32console' +begin + require 'win32console' + @using_win32console = true +rescue LoadError + @using_win32console = false +end # -------------------------------------------------------------------- # Support code for the Ruby Koans. # -------------------------------------------------------------------- @@ -120,7 +125,7 @@ module EdgeCase end def using_win32console begin - !! Win32::Console::ANSI + @using_win32console rescue return false end From 176de995b85765b240b1af91edac1e6702da65af Mon Sep 17 00:00:00 2001 From: ahmed80dz Date: Fri, 7 Oct 2011 22:34:53 +0200 Subject: [PATCH 5/7] Edited koans/edgecase.rb via GitHub --- koans/edgecase.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/koans/edgecase.rb b/koans/edgecase.rb index 8a0c988..dca38ac 100644 --- a/koans/edgecase.rb +++ b/koans/edgecase.rb @@ -124,11 +124,7 @@ module EdgeCase File::ALT_SEPARATOR end def using_win32console - begin @using_win32console - rescue - return false - end end end From 595f2af341e51fcb4dddb812a51587f43cdefdb0 Mon Sep 17 00:00:00 2001 From: ahmed80dz Date: Fri, 7 Oct 2011 23:13:32 +0200 Subject: [PATCH 6/7] finally it worked well --- koans/edgecase.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/koans/edgecase.rb b/koans/edgecase.rb index dca38ac..03c8f29 100644 --- a/koans/edgecase.rb +++ b/koans/edgecase.rb @@ -4,9 +4,9 @@ require 'test/unit/assertions' begin require 'win32console' - @using_win32console = true + USING_WIN32CONSOLE = true rescue LoadError - @using_win32console = false + USING_WIN32CONSOLE = false end # -------------------------------------------------------------------- # Support code for the Ruby Koans. @@ -124,7 +124,7 @@ module EdgeCase File::ALT_SEPARATOR end def using_win32console - @using_win32console + USING_WIN32CONSOLE end end From ad3b4f76aadf53ec12b51ee2072123ada2ddedde Mon Sep 17 00:00:00 2001 From: ahmed80dz Date: Fri, 7 Oct 2011 23:55:12 +0200 Subject: [PATCH 7/7] as suggested by sunaku --- koans/edgecase.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/koans/edgecase.rb b/koans/edgecase.rb index 03c8f29..d727cd7 100644 --- a/koans/edgecase.rb +++ b/koans/edgecase.rb @@ -4,9 +4,7 @@ require 'test/unit/assertions' begin require 'win32console' - USING_WIN32CONSOLE = true rescue LoadError - USING_WIN32CONSOLE = false end # -------------------------------------------------------------------- # Support code for the Ruby Koans. @@ -124,7 +122,7 @@ module EdgeCase File::ALT_SEPARATOR end def using_win32console - USING_WIN32CONSOLE + defined? Win32::Console end end