Hey,
I wanted to run the following command in a Shoes app and display the
output in a window. But I never get any output back from it.
-------------------
$bugabuga=" "
IO.popen (["ruby","-v"]) do |fd|
until fd.eof?
$bugabuga << "#{fd.readline}"
end
end
puts "BUGABUGA #{$bugabuga}"
-------------------
Running this code in 'normal' ruby works as expected, producing:
-------------------
BUGABUGA ruby 1.9.2p180 (2011-02-18) [i386-mingw32]
-------------------
But, when I add this code to a Shoes app, I always get EOF straight off the bat.
My code:
-------------------
class Teste < Shoes
url '/', :index
def index
$bugabuga << "testes"
para "Testando (#{$bugabuga})"
begin
IO.popen (["ruby","-v"]) do |fd|
debug 'lendo!'
$bugabuga << fd.readline until fd.eof?
fd.close
end
rescue Exception => e
debug e.message
end
para "Teste (#{$bugabuga})"
end
end
Teste.app
-------------------
Could someone please point out my mistake(s)?
TIA,
--
Khristian Alexander Schönrock
Hello
this work with gs
output go to ruby console with red shoes (windows)
require "green_shoes"
require "open3"
Shoes.app do
$bugabuga = ["testes"]
stack do
para "Testando (#{$bugabuga})"
begin
Open3.popen3("ruby.exe","-e","STDOUT.sync=true;
[1,2,3,4,5,6].each { |g| p g*g ; sleep 0.3} ") do |a,fd,d|
para ">>start"
para ">>"+fd.gets.chomp until fd.eof?
para ">>end"
end
rescue Exception => e
alert e.message+ " " + e.backtrace[0]
end
para "Teste (#{$bugabuga})"
end
end
2011/9/8 Khristian <der.kosak@gmail.com>
> Hey,
>
> I wanted to run the following command in a Shoes app and display the
> output in a window. But I never get any output back from it.
> -------------------
> $bugabuga=" "
> IO.popen (["ruby","-v"]) do |fd|
> until fd.eof?
> $bugabuga << "#{fd.readline}"
> end
> end
>
> puts "BUGABUGA #{$bugabuga}"
> -------------------
>
> Running this code in 'normal' ruby works as expected, producing:
> -------------------
> BUGABUGA ruby 1.9.2p180 (2011-02-18) [i386-mingw32]
> -------------------
>
> But, when I add this code to a Shoes app, I always get EOF straight off the
> bat.
> My code:
>
> -------------------
> class Teste < Shoes
> url '/', :index
>
> def index
> $bugabuga << "testes"
> para "Testando (#{$bugabuga})"
> begin
> IO.popen (["ruby","-v"]) do |fd|
> debug 'lendo!'
> $bugabuga << fd.readline until fd.eof?
> fd.close
> end
> rescue Exception => e
> debug e.message
> end
> para "Teste (#{$bugabuga})"
> end
> end
>
> Teste.app
> -------------------
>
> Could someone please point out my mistake(s)?
>
> TIA,
>
> --
> Khristian Alexander Schönrock
>
--
- - - - - - - - - - - - - - - - -
__ ___ __ . __
|__) |__ / _` | /__`
| \ |___ \__> L| .__/
http://regisaubarede.posterous.com/
- - - - - - - - - - - - - - - - -
Interesting, I tried running this code on Shoes HEAD. Using Shoes.app do … end works fine, but subclassing Shoes and using the index url fails with an error like this: wrong argument type UnboundMethod (expected Data) gently.rb:9:in `app' gently.rb:9:in `<main>' /Users/eric/code/shoes/Shoes.app/Contents/MacOS/lib/shoes.rb:435:in `eval' /Users/eric/code/shoes/Shoes.app/Contents/MacOS/lib/shoes.rb:435:in `visit' /Users/eric/code/shoes/Shoes.app/Contents/MacOS/lib/shoes.rb:124:in `show_selector' (eval):1:in `<main>' I've posted a minimal case as a github issue. Eric
Thanks a lot, Régis and Cecil! I got it working with green shoes (though I did not know about these other colors). Em 08/09/2011 18:12, Régis d'Aubarède escreveu: > Hello > > this work with gs > output go to ruby console with red shoes (windows) > > require "green_shoes" > require "open3" > Shoes.app do > $bugabuga = ["testes"] > stack do > para "Testando (#{$bugabuga})" > begin > Open3.popen3("ruby.exe","-e","STDOUT.sync=true; > [1,2,3,4,5,6].each { |g| p g*g ; sleep 0.3} ") do |a,fd,d| > para ">>start" > para ">>"+fd.gets.chomp until fd.eof? > para ">>end" > end > rescue Exception => e > alert e.message+ " " + e.backtrace[0] > end > para "Teste (#{$bugabuga})" > end > end > > > 2011/9/8 Khristian <der.kosak@gmail.com <mailto:der.kosak@gmail.com>> > > Hey, > > I wanted to run the following command in a Shoes app and display the > output in a window. But I never get any output back from it. > ------------------- > $bugabuga=" " > IO.popen (["ruby","-v"]) do |fd| > until fd.eof? > $bugabuga << "#{fd.readline}" > end > end > > puts "BUGABUGA #{$bugabuga}" > ------------------- > > Running this code in 'normal' ruby works as expected, producing: > ------------------- > BUGABUGA ruby 1.9.2p180 (2011-02-18) [i386-mingw32] > ------------------- > > But, when I add this code to a Shoes app, I always get EOF > straight off the bat. > My code: > > ------------------- > class Teste < Shoes > url '/', :index > > def index > $bugabuga << "testes" > para "Testando (#{$bugabuga})" > begin > IO.popen (["ruby","-v"]) do |fd| > debug 'lendo!' > $bugabuga << fd.readline until fd.eof? > fd.close > end > rescue Exception => e > debug e.message > end > para "Teste (#{$bugabuga})" > end > end > > Teste.app > ------------------- > > Could someone please point out my mistake(s)? > > TIA, > > -- > Khristian Alexander Schönrock > > > > > -- > - - - - - - - - - - - - - - - - - > __ ___ __ . __ > |__) |__ / _` | /__` > | \ |___ \__> L| .__/ > > http://regisaubarede.posterous.com/ > - - - - - - - - - - - - - - - - - > > >
> I got it working with green shoes (though I did not know about these other > colors). Quick rundown: Red Shoes is the reference implementation by _why, green shoes is ashbb's all-ruby implementation. There are a few other Shoes, but they're mostly theoretical at this point. :)
On Thu, 2011-09-08 at 16:48 -0300, Khristian wrote: > $bugabuga << "testes" > That line gets an error on the shoes console. The following line works. $bugabuga = "testes"
Yes, the code I pasted was supposed to have a [$bugabuga=" "] at the top, sorry about that. But did the rest of it work for you? I have Shoes 3 from http://shoesrb.com/. On Thu, Sep 8, 2011 at 5:42 PM, Cecil Coupe <ccoupe@cableone.net> wrote: > On Thu, 2011-09-08 at 16:48 -0300, Khristian wrote: >> $bugabuga << "testes" >> > > That line gets an error on the shoes console. The following line > works. > $bugabuga = "testes" > > > > -- -- Khristian Alexander Schönrock http://derkosak.blogspot.com - Meu blógue!
All the text is shown on the Shoes window, so it works on ubuntu linux Shoes3. On Thu, 2011-09-08 at 17:52 -0300, Khristian wrote: > Yes, the code I pasted was supposed to have a [$bugabuga=" "] at the > top, sorry about that. But did the rest of it work for you? > I have Shoes 3 from http://shoesrb.com/. > > On Thu, Sep 8, 2011 at 5:42 PM, Cecil Coupe <ccoupe@cableone.net> wrote: > > On Thu, 2011-09-08 at 16:48 -0300, Khristian wrote: > >> $bugabuga << "testes" > >> > > > > That line gets an error on the shoes console. The following line > > works. > > $bugabuga = "testes" > > > > > > > > > > >