Win32::Console allows controling the windows command line terminal
thru an OO-interface. This allows you to query the terminal (find
its size, characters, attributes, etc). The interface and functionality
should be identical to Perl’s counterpart.
A port of Perl’s Win32::Console and Win32::Console::ANSI modules.
This gem packages Gonzalo G.'s Win32::Console project, and
includes
a compiled binary for speed. The Win32::Console project’s home can be
found at:
Win32::Console allows controling the windows command line terminal
thru an OO-interface. This allows you to query the terminal (find
its size, characters, attributes, etc). The interface and functionality
should be identical to Perl’s counterpart.
I noticed it doesn’t seem to do “too much” for colored specs.
â†[31mActiveRecord::StatementInvalid in ‘Abc should create a new instance
given valid attributes’
Could not find table ‘abcs’â†[0m
E:/dev/ruby/old/spork/test_rails/spec/models/abc_spec.rb:11:in `block (2
levels) in <top (required)>’
win32console version 1.3.0.beta2 has been released!
Hi Luis, thanks for this gem. I’ve been waiting something like this.
Quick q: does it implement all the features listed herehttp://www.xav.com/perl/site/lib/Win32/Console.html ?
thanks and best regards -botp
win32console gem is a wrapper around this project:
If all of this code still works the way I remember it, this is
actually easy to fix. Last time I checked, autospec relies on
autotest, so you should be able to just require win32console in your
~/.autotest file. autospec runs the rspec framework as a subprocess.
It parses the results, then spits them out on the screen. On posix
systems, the escape codes work, because posix systems are designed to
handle them. In Windows, the escape codes just get dumped to stdout,
so you have to make sure the current process knows how to handle them.
Autotest uses getc to read from stdout, and putc to write to it. I
redefined Kernel#putc to cache escape codes and write them all at
once. Otherwise, win32console won’t work. The problem in 1.9 is that
“?\e” doesn’t return the byte value, but the string. I’ll submit a
patch.
Thanks for your work on this.
handle them. In Windows, the escape codes just get dumped to stdout,
so you have to make sure the current process knows how to handle them.
I hope that makes sense.
It does, however, as I mentioned in the RSpec-dev mailing list post,
trying to recreate it just end prematurely, doesn’t complete.
Ignoring for a second that ZenTest/autospec changes the first two
lines of the autotest rubygem stub, check the following example:
STDOUT.puts “OUT: THIS IS ~/.autotest file”
STDERR.puts “ERR: THIS IS ~/.autotest file”
require ‘win32console’
puts “$stdout.redirected? #{$stdout.redirected?}”
puts “$stderr.redirected? #{$stderr.redirected?}”
rake-compiler/.autotest
STDOUT.puts “OUT: THIS IS rake-compiler/.autotest file”
STDERR.puts “ERR: THIS IS rake-compiler/.autotest file”
require ‘win32console’
puts “$stdout.redirected? #{$stdout.redirected?}”
puts “$stderr.redirected? #{$stderr.redirected?}”
Running autospec in my folder, output this:
C:\Users\Luis\Projects\oss\rake-compiler>autospec
(Not running features. To run features in autotest, set
AUTOFEATURE=true.)
loading autotest/rspec
OUT: THIS IS ~/.autotest file
ERR: THIS IS ~/.autotest file
$stdout.redirected? false
$stderr.redirected? false
OUT: THIS IS rake-compiler/.autotest file
ERR: THIS IS rake-compiler/.autotest file
$stdout.redirected? false
$stderr.redirected? false
C:\Users\Luis\Tools\Ruby\ruby-1.8.6-p398-i386-mingw32\bin\ruby C:/
Users/Luis/.gem/ruby/x86-mingw32/1.8/gems/rspec-1.3.0/bin/spec –
autospec C:/Users/Luis/Projects/oss/rake-compiler/spec/lib/rake/
javaextensiontask_spec.rb C:/Users/Luis/Projects/oss/rake-compiler/
spec/lib/rake/extensiontask_spec.rb -O spec/spec.opts
And from there beautiful colors (well, not beautiful, but seems it
works).
The following version also works:
ruby 1.8.7 (2010-01-10 patchlevel 249) [i386-mingw32]
But NOT 1.9.1:
C:\Users\Luis\Projects\oss\rake-compiler>autospec
loading autotest/rspec
OUT: THIS IS ~/.autotest file
ERR: THIS IS ~/.autotest file
$stdout.redirected? false
$stderr.redirected? false
OUT: THIS IS rake-compiler/.autotest file
ERR: THIS IS rake-compiler/.autotest file
$stdout.redirected? false
$stderr.redirected? false
C:\Users\Luis\Tools\Ruby\ruby-1.9.1-p378-i386-mingw32\bin\ruby C:/
Users/Luis/.gem/ruby/x86-mingw32/1.9.1/gems/rspec-1.3.0/bin/spec –
autospec C:/Users/Luis/Projects/oss/rake-compiler/spec/lib/rake/
extensiontask_spec.rb C:/Users/Luis/Projects/oss/rake-compiler/spec/
lib/rake/javaextensiontask_spec.rb -O spec/spec.opts
Rake::ExtensionTask #new
(basic)
WARNING: You’re cross-compiling a binary extension for JRuby, but are
using
another interpreter. If your Java classpath or extension dir settings
are not
correctly detected, then either check the appropriate environment
variables or
execute the Rake compilation task using the JRuby interpreter.
(e.g. jruby -S rake compile:java)
====
Stops there, all without colors.
Now, running rake spec or spec -c spec display all colors too, so is
something around autospec/autotest and Ruby 1.9
====
Hope I explained better this time since seems nobody answered on RSpec-
dev maybe my english wasn’t good enough.
Hope I explained better this time since seems nobody answered on RSpec-
ruby 1.8.6 (2009-08-04 patchlevel 383) [i386-mingw32]
Autotest uses getc to read from stdout, and putc to write to it. I
redefined Kernel#putc to cache escape codes and write them all at
once. Otherwise, win32console won’t work. The problem in 1.9 is that
“?\e” doesn’t return the byte value, but the string. I’ll submit a
patch.
My patch didn’t fix the whole problem. I was assuming that the
argument to putc would always be an integer, but apparently in 1.9 it
can be an integer or a string. I’ll send you another pull request. I
tested with autospec this time on 1.8.6, 1.8.7, and 1.9.1.
Change received, merged and tested.
I’ve pushed a new beta release (beta3). This closes GH-3 report about
the incorrect behavior under autospec.
Can you guys install the new prerelease and let me know? That way we
can make it official 1.3.0 and I can move to the other projects with
pending releases
generates ANSI codes when running under 1.9.1 with autospec.
Produces colored output, while adding to spec_helper.rb or any of the
files being evaluated inside autospec returns ANSI color codes.
–
Luis L.
My patch didn’t fix the whole problem. I was assuming that the
argument to putc would always be an integer, but apparently in 1.9 it
can be an integer or a string. I’ll send you another pull request. I
tested with autospec this time on 1.8.6, 1.8.7, and 1.9.1.
Can you guys install the new prerelease and let me know? That way we
can make it official 1.3.0 and I can move to the other projects with
pending releases
I’ve pushed a new beta release (beta3). This closes GH-3 report about
the incorrect behavior under autospec.
Can you guys install the new prerelease and let me know? That way we
can make it official 1.3.0 and I can move to the other projects with
pending releases
Interesting.
For some reason on my box, if I run “autospec”, it runs this command:
in prefork local.rb
E:/installs/ruby191p376/lib/ruby/gems/1.9.1/gems/rails-2.3.5/lib/rails/gem_dependency.rb:119:Warning:
Gem::Dependency#version_requirements is deprecated and will be removed
on or after August 2010. Use #requirement
â†[32m.â†[0mâ†[32m.â†[0mâ†[31mFâ†[0mâ†[31mFâ†[0mâ†[31mFâ†[0mâ†[31mFâ†[0mâ†[31mFâ†[0mâ†[32m.â†[0mâ†[31mFâ†[0mâ†[31mFâ†[0mâ†[32m.â†[0mâ†[32m.â†[0mâ†[32m.â†[0mâ†[32m.â†[0mâ†[31mFâ†[0mâ†[31mFâ†[0mâ†[32m.â†[0mâ†[32m.â†[0mâ†[31mFâ†[0mâ†[31mFâ†[0mâ†[32m.â†[0mâ†[32m.â†[0mâ†[32m.â†[0mâ†[32m.â†[0mâ†[31mFâ†[0mâ†[31mFâ†[0mâ†[31mFâ†[0mâ†[31mFâ†[0mâ†[31mFâ†[0m
(like it forgot to require win32console or something, even though
spec.opts has --color).
Any thoughts there? (spork via drb seems to do the same).
Thx.
-rp
If I run that command by itself, colors look fine.
If
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.