Win32console 1.3.0.beta2 Released

win32console version 1.3.0.beta2 has been released!

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:

http://rubyforge.org/projects/win32console

How to install:

Since this is a prerelease gem, you need updated version of RubyGems
(greater than 1.3.4)

gem install win32console --prerelease

This will install the latest available version from RubyGems.org

Changes:

1.3.0.beta2 / 2010-03-07

  • Enhancements
    • Redirect STDERR to be processed also for ANSI codes. Closes GH-4
    • Allow ECHO to be displayed [jloveces]

On Sun, Mar 7, 2010 at 11:20 PM, Luis L. [email protected]
wrote:

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 here
http://www.xav.com/perl/site/lib/Win32/Console.html ?

thanks and best regards -botp

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)>’

Any guess as to who’s to blame there?
Thanks.
-rp

E:\dev\ruby\old\spork\test_rails\spec>cat spec.opts
–colour
–format progress
–loadby mtime
–reverse

On Mar 8, 9:27Â pm, Roger P. [email protected] wrote:

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)>’

Any guess as to who’s to blame there?

Are you using autospec? If so, is not win32console, as I mentioned to
you before.

This as proven to work for standard Windows prompt without any issue,
and I use it for “rake spec” in rake-compiler:

C:\Users\Luis\Projects\oss\rake-compiler>type spec\spec.opts
–colour
–format nested
–loadby mtime

On 09/03/2010 07:30, Luis L. wrote:

Are you using autospec? If so, is not win32console, as I mentioned to
you before.

The RSpec people seem to think it might be a win32console problem:

http://j.mp/a4XYT3

Charles

On Mar 8, 2:10 am, botp [email protected] wrote:

On Sun, Mar 7, 2010 at 11:20 PM, Luis L. [email protected] wrote:

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:

http://rubyforge.org/projects/win32console/

Which is a direct port from Perl.

That means API-wise should be pretty similar.

However, I’ve asked before what is the usage of win32console here:

http://blog.mmediasys.com/2009/12/17/win32console-upcoming-changes-and-feedback/

And people responded that they mainly use to mimic ANSI coloring in
the terminal, not all the Win32::Console functionality.

Also, in this release it no longer automates the codepage conversion,
which will need to be done manually. See here:

http://github.com/luislavena/win32console/blob/master/History.txt#L16-24

HTH,

On Mar 9, 9:28 am, Charles R. [email protected] wrote:

On 09/03/2010 07:30, Luis L. wrote:

Are you using autospec? If so, is not win32console, as I mentioned to
you before.

The RSpec people seem to think it might be a win32console problem:

http://j.mp/a4XYT3

No, is not win32console, I’ve emailed rspec team before on this:

http://rubyforge.org/pipermail/rspec-devel/2010-January/005341.html

No answer. I’ve described there what could be the root of the issue.

Does a previous version of win32console result in the same issue?

If so, then is not win32console.

No, is not win32console, I’ve emailed rspec team before on this:

http://rubyforge.org/pipermail/rspec-devel/2010-January/005341.html

Thanks for the link.
Appears it is a bug with spec since autospec doesn’t show colors but
normal “spec” does.

Thanks for your work on this.
-rp

On Tue, Mar 9, 2010 at 7:49 AM, Roger P. [email protected]
wrote:

-rp

Posted via http://www.ruby-forum.com/.

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.

I hope that makes sense.

On 09/03/2010 08:45, Luis L. wrote:

No, is not win32console, I’ve emailed rspec team before on this:

http://rubyforge.org/pipermail/rspec-devel/2010-January/005341.html

No answer. I’ve described there what could be the root of the issue.

Does a previous version of win32console result in the same issue?

If so, then is not win32console.

Thanks for the confirmation, Luis. I’ve updated the ticket:

http://j.mp/a4XYT3

Charles

On Wed, Mar 10, 2010 at 2:35 AM, Luis L. [email protected]
wrote:

dev maybe my english wasn’t good enough.

Ah! I see the problem now. I’m afraid it is in win32console[1], and
I’m afraid I wrote it.
This code will reproduce the bug:

ruby -e “require ‘rubygems’; require ‘win32console’; %Q{\e[31mred\e[0m
\e[32mgreen\e[0m}.each_byte{|i| putc
i }”

ruby 1.8.6 (2009-08-04 patchlevel 383) [i386-mingw32]
red green

in color

ruby 1.8.7 (2010-01-10 patchlevel 249) [i386-mingw32]
red green

in color

ruby 1.9.1p243 (2009-07-16 revision 24175) [i386-mingw32]
e[31mrede[0m e[32mgreene[0m

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.

[1]
http://github.com/luislavena/win32console/blob/master/lib/Win32/Console/ANSI.rb#L103

On Mar 10, 5:34 am, Gordon T. [email protected] wrote:

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:

#ruby
ruby 1.8.6 (2010-02-04 patchlevel 398) [i386-mingw32]

#gem list:

win32console (1.3.0.beta2, 1.3.0.beta1)
rspec (1.3.0)
ZenTest (4.2.1)

~/.autotest

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.

Regards,

On Mar 10, 3:40 pm, Gordon T. [email protected] wrote:

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.

[1]http://github.com/luislavena/win32console/blob/master/lib/Win32/Conso

Gordon, your patch fix the issue with red/green sample, but still
generates ANSI codes when running under 1.9.1 with autospec.

I just cleared all the previous versions of win32console due buggy
load path of 1.9 and still see the same issue.

The positive side is that the specs now completes instead of
prematurely terminate itself.

Adding this to either project .autospec file or ~/.autospec file:

%Q{\e[31mred\e[0m \e[32mgreen\e[0m}.each_byte{|i| putc i }

Produces colored output, while adding to spec_helper.rb or any of the
files being evaluated inside autospec returns ANSI color codes.

On Mar 11, 4:24 am, Gordon T. [email protected] wrote:

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 :wink:

Thank you.

On Wed, Mar 10, 2010 at 6:00 PM, Luis L. [email protected]
wrote:

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.

On Fri, Mar 12, 2010 at 2:40 AM, Luis L. [email protected]
wrote:

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 :wink:

Thank you.

Luis L.

It looks good to me. Thanks, Luis.

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 :wink:

Interesting.
For some reason on my box, if I run “autospec”, it runs this command:

E:\installs\ruby191p376\bin\ruby
E:/installs/ruby191p376/lib/ruby/gems/1.9.1/gems/rspec-1.3.0/bin/spec
–autospec E:/dev/ruby/old/spork/test_rails/spec/models/abc_spec.rb
E:/dev/ruby/old/spork/test_rails/spec/views/abcs/edit.html.erb_spec.rb
E:/dev/ruby/old/spork/test_rails/spec/views/abcs/index.html.erb_spec.rb
E:/dev/ruby/old/spork/test_rails/spec/views/abcs/new.html.erb_spec.rb
E:/dev/ruby/old/spork/test_rails/spec/views/abcs/show.html.erb_spec.rb
E:/dev/ruby/old/spork/test_rails/spec/controllers/abcs_controller_spec.rb
E:/dev/ruby/old/spork/test_rails/spec/helpers/abcs_helper_spec.rb
E:/dev/ruby/old/spork/test_rails/spec/routing/abcs_routing_spec.rb -O
spec/spec.opts

which outputs, for colors:

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.

| Privacy Policy | Terms of Service | Remote Ruby Jobs