[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

[ANN] RubyJS - Convert Ruby to Javascript

Michael Neumann

1/14/2007 1:11:00 AM

Hi all,

Long time since I announced my last project....

With RubyJS you can transform a subset of Ruby into Javascript code.

What works?

* Classes, modules, inheritance
* Instance methods, class methods
* Exceptions (rescue/ensure)
* Meta-programming stuff like 'attr_reader'
(any meta-programming stuff works that does not appear inside methods)
* Iterators, yield
* "require" (with platform-specific extension ala Google Webtoolkit)
* Inline Javascript code
* Some kind of compile-time method lookup ;-)
* Numbers, String, Array, Hash, Proc (a lot of functionallity is missing!)
* Testing with Rhino-JS
* A lot more :)

There is a lots of room for optimizations and improvement :)

Best take a look at sample/demo.rb or test/*.rb.

DOWNLOAD
=========

It's available from here:

http://ntecs.de/hg-projec...

Best use Mercurial (www.selenic.com/mercurial) to check it out:

hg clone static-http://ntecs.de/hg-projec...

Requires ParseTree 1.6.3 as rubygem.

Have fun with it!

Regards,

Michael

8 Answers

Daniel Finnie

1/14/2007 1:22:00 AM

0

Is there a way to download it without installing Mercurial? I looked
around the website given but didn't see anything. I am interested in
seeing the code it produces.

Thanks,
Dan

Michael Neumann wrote:
> Hi all,
>
> Long time since I announced my last project....
>
> With RubyJS you can transform a subset of Ruby into Javascript code.
>
> What works?
>
> * Classes, modules, inheritance
> * Instance methods, class methods
> * Exceptions (rescue/ensure)
> * Meta-programming stuff like 'attr_reader'
> (any meta-programming stuff works that does not appear inside methods)
> * Iterators, yield
> * "require" (with platform-specific extension ala Google Webtoolkit)
> * Inline Javascript code
> * Some kind of compile-time method lookup ;-)
> * Numbers, String, Array, Hash, Proc (a lot of functionallity is missing!)
> * Testing with Rhino-JS
> * A lot more :)
>
> There is a lots of room for optimizations and improvement :)
>
> Best take a look at sample/demo.rb or test/*.rb.
>
> DOWNLOAD
> =========
>
> It's available from here:
>
> http://ntecs.de/hg-projec...
>
> Best use Mercurial (www.selenic.com/mercurial) to check it out:
>
> hg clone static-http://ntecs.de/hg-projec...
>
> Requires ParseTree 1.6.3 as rubygem.
>
> Have fun with it!
>
> Regards,
>
> Michael
>
>

Ezra Zygmuntowicz

1/14/2007 1:47:00 AM

0



On Jan 13, 2007, at 5:22 PM, Daniel Finnie wrote:

> Is there a way to download it without installing Mercurial? I
> looked around the website given but didn't see anything. I am
> interested in seeing the code it produces.
>
> Thanks,
> Dan

Yeah could you please post a tarball somewhere? I don't have
mercurial but I am interested in playing with this project.

Thanks

-- Ezra Zygmuntowicz
-- Lead Rails Evangelist
-- ez@engineyard.com
-- Engine Yard, Serious Rails Hosting
-- (866) 518-YARD (9273)



unbewusst.sein

1/14/2007 8:02:00 AM

0

Michael Neumann <mneumann@ntecs.de> wrote:

>
> With RubyJS you can transform a subset of Ruby into Javascript code.

yes but how to interact with the browser window, for example, say i have
a :

<pre id="STDOUT"></pre> in the html document and i want to redefine ruby
puts like this :

def puts(str)
document.getElementById('STDOUT')['inneHTML'] += str + "\n"
end

if i do that into your HelloWorld class i get errors :

method_generator.rb:1040:in `method_missing': Not implemented
(RuntimeError)
[...]

is their a way to let RubyJS knows that "document.getElementById..." is
allready JS ???
--
Artaban de Médée

Michael Neumann

1/14/2007 10:54:00 AM

0

Am Sonntag, 14. Januar 2007 02:22 schrieb Daniel Finnie:
> Is there a way to download it without installing Mercurial? I looked
> around the website given but didn't see anything. I am interested in
> seeing the code it produces.

Uploaded a temporary tarball here: http://ntecs.de/hg-projects/rub...

You can also see a sample of the produced code here:
http://ntecs.de/hg-projec...samp...

or try the demo:


>
> Thanks,
> Dan
>
> Michael Neumann wrote:
> > Hi all,
> >
> > Long time since I announced my last project....
> >
> > With RubyJS you can transform a subset of Ruby into Javascript code.
> >
> > What works?
> >
> > * Classes, modules, inheritance
> > * Instance methods, class methods
> > * Exceptions (rescue/ensure)
> > * Meta-programming stuff like 'attr_reader'
> > (any meta-programming stuff works that does not appear inside
> > methods) * Iterators, yield
> > * "require" (with platform-specific extension ala Google Webtoolkit)
> > * Inline Javascript code
> > * Some kind of compile-time method lookup ;-)
> > * Numbers, String, Array, Hash, Proc (a lot of functionallity is
> > missing!) * Testing with Rhino-JS
> > * A lot more :)
> >
> > There is a lots of room for optimizations and improvement :)
> >
> > Best take a look at sample/demo.rb or test/*.rb.
> >
> > DOWNLOAD
> > =========
> >
> > It's available from here:
> >
> > http://ntecs.de/hg-projec...
> >
> > Best use Mercurial (www.selenic.com/mercurial) to check it out:
> >
> > hg clone static-http://ntecs.de/hg-projec...
> >
> > Requires ParseTree 1.6.3 as rubygem.
> >
> > Have fun with it!
> >
> > Regards,
> >
> > Michael

Michael Neumann

1/14/2007 11:00:00 AM

0

Am Sonntag, 14. Januar 2007 09:05 schrieb Une Bévue:
> Michael Neumann <mneumann@ntecs.de> wrote:
> > With RubyJS you can transform a subset of Ruby into Javascript code.
>
> yes but how to interact with the browser window, for example, say i have
> a :
>
> <pre id="STDOUT"></pre> in the html document and i want to redefine ruby
> puts like this :
>
> def puts(str)
> document.getElementById('STDOUT')['inneHTML'] += str + "\n"
> end
>
> if i do that into your HelloWorld class i get errors :

Well, does it work in Ruby? NO! So it doesn't work in RubyJS as well :)
It's a bit more advanced than converting "document" from Ruby plainly
into "document" in Javascript.

If you want to insert Javascript code directly into your Ruby code, use
backticks:

def puts(str)
`document.getElemementById('STDOUT')['innerHTML'] += str + "\n"`
end

In the next step, I've planned to port Google's Webtoolkit (or Python Pyjamas)
to RubyJS.

> method_generator.rb:1040:in `method_missing': Not implemented
> (RuntimeError)
> [...]
>
> is their a way to let RubyJS knows that "document.getElementById..." is
> allready JS ???

See above :)

Regards,

Michael

unbewusst.sein

1/14/2007 12:56:00 PM

0

Michael Neumann <mneumann@ntecs.de> wrote:

>
> If you want to insert Javascript code directly into your Ruby code, use
> backticks:
>
> def puts(str)
> `document.getElemementById('STDOUT')['innerHTML'] += str + "\n"`
> end
>
> In the next step, I've planned to port Google's Webtoolkit (or Python Pyjamas)
> to RubyJS.

fine thanks a lot, same syntax as using command line shell tools...

great job !
--
Artaban de Médée

Mark Volkmann

1/14/2007 6:12:00 PM

0

On Jan 14, 2007, at 4:59 AM, Michael Neumann wrote:

> In the next step, I've planned to port Google's Webtoolkit (or
> Python Pyjamas)
> to RubyJS.

Very cool! I'm played with Google Web Toolkit and really like it ...
except for the part where you have to code in Java to use it. A Ruby
equivalent would be wonderful!

unbewusst.sein

1/15/2007 8:05:00 AM

0

Michael Neumann <mneumann@ntecs.de> wrote:

> If you want to insert Javascript code directly into your Ruby code, use
> backticks:
>
> def puts(str)
> `document.getElemementById('STDOUT')['innerHTML'] += str + "\n"`
> end

I got the same error with that writing :
.../bin/../lib/rubyjs/method_generator.rb:1040:in `method_missing': Not
implemented (RuntimeError)
[...]
from ../bin/rubyjs_gen:82

--
Artaban de Médée