• Stars
    star
    106
  • Rank 325,871 (Top 7 %)
  • Language
    Ruby
  • Created over 13 years ago
  • Updated about 13 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

(proof-of-concept) Awesome V8 JavaScript engine embedded into Ruby's shiny body.

Mustang development is proudly sponsored by Cubox, Agile Rails Devshop

Mustang - V8 engine in Ruby's body

Mustang is ruby proxy library for awesome Google V8 JavaScript engine.

Motivation

JavaScript integration testing suite which contains more than 4000 steps and running time more that 2 hours... I think that's enough. There is lot of different ways to handle headless testing, but they all have lot of issues as well. They are super slow (Selenium, Watir), or they are not working with ruby 1.9 (Johsnon), or they requires tricky external stuff (Culerity/Celerity, Zombie). Our goal is to create fast javascript engine working fine on all popular ruby implementations (1.8.x, 1.9.x, ree, rubinius), and make it core element of headless, virtual browser for testing purposes (of course integrated with capybara and cucubmer).

TheRubyRacer and PyV8 influence...

Yeap, TheRubyRacer from Charles Lowell and PyV8 made big influence on our Mustang code, so let say now big thanks to the authors...

You can of course ask why we wrote library which seems to be very similar to TheRubyRacer... yeah it seems, but there are a lot of differences. Here is short comparison of TheRubyRacer and Mustang:

Similarities:

  • Both are using similar integration with ruby's garbage collector. Actually, Mustang's code which handles that references is just improved version of TheRubyRacer's code (check the ext/v8/v8_ref.cpp).
  • Both are reflecting JS objects to ruby and vice-versa.

Diffs:

  • Mustang reflects all JavaScript objects and values properly. Properly, means all values from within V8 are reflected to Mustang::V8::* objects, regarding V8 inheritance tree which you can find here.
  • Once reflected ruby object (and vice-versa) is always the same object in ruby world.
  • All reflected V8 objects acts exacltly the same as ruby natives. For example you can deal with Mustang::V8::Array exactly the same as with native Ruby arrays (eg. they are comparable with ruby objects, etc).
  • Functions are reflected more accurately. Ruby objects' methods are represented properly.
  • Classes are converted to V8 function templates, so you can deal with them as with prototypes.
  • Different approach to deal with contexts, compiling JS scripts and exceptions handling.
  • Support for regexp reflections.
  • Way more friendly ruby api.
  • A very thorough test suite (over 250 tests passing on all ruby versions)
  • Clean codebase, less magic, fully documented.
  • Lower memory usage.

And the most important, like i said before, Mustang is used as core element of our bigger idea, so it have to exactly fit to our needs.

Installation

Before you install mustang gem make sure you have scons installed.

$ sudo apt-get install scons # on debian
$ sudo pacman -S scons       # on archlinux
$ brew install scons         # on mac...

Using rubygems:

$ gem install mustang

Manually:

$ git clone git://github.com/nu7hatch/mustang.git
$ cd mustang
$ rake compile
$ rake install

Usage

For now it's only proof of concept. It implements very simple evaluation of javascript code:

require 'mustang'

cxt = Mustang::Context.new
cxt.eval("'Hello' + ' World!';") # => 'Hello World!'
cxt.eval("var a=1;")
cxt.eval("a+5;") # => 6

cxt[:puts] = method(:puts)
cxt.eval("puts(a)") # displays "1" on the screen
cxt[:a] # => 1

Advanced

TODO: coming soon...

Note on Patches/Pull Requests

  • Fork the project.
  • Make your feature addition or bug fix.
  • Add tests for it. This is important so I don't break it in a future version unintentionally.
  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
  • Send me a pull request. Bonus points for topic branches.

Copyright

Copyright (c) 2010 Kriss 'nu7hatch' Kowalik. See LICENSE for details.

More Repositories

1

gmail

A Rubyesque interface to Gmail, with all the tools you'll need.
Ruby
664
star
2

gouuid

Go binding for libuuid
Go
417
star
3

desantapp

Desant is an open source landing page system
JavaScript
210
star
4

aclatraz

Flexible access control mechanism!
Ruby
110
star
5

rails3-ujs-example

Very simple and quick example of rails 3 app with jquery UJS
Ruby
46
star
6

konfigurator

Small and flexible configuration toolkit inspired i.a. by Sinatra settings.
Ruby
35
star
7

angular-foundation-on-yeoman

AngularJS powered by Zurb Foundation, running on Yeoman
JavaScript
31
star
8

webrocket

(under-development) Evented WebSocket server in Go
Go
31
star
9

gochanio

Go package which allows to bind channel with any IO reader or writer interface.
Go
26
star
10

golaroid

Simple assets server with ability to apply filters to the images
Go
25
star
11

egoistat

Website statistics from the most popular social networks
JavaScript
23
star
12

shaven

(proof-of-concept) Templating without mustaches!
Ruby
22
star
13

padrino-responders

This component is used to create slim controllers without unnecessery and repetitive code.
Ruby
16
star
14

gonetbench

Small TCP benchmarking tool in Go-lang
Go
15
star
15

gopqueue

Simple priority queue in Go
Go
14
star
16

redis-aid

First aid with Redis!
Ruby
13
star
17

areyoufuckingcoding.me

Ruby
10
star
18

padrino-form-errors

Form validation errors helper for Padrino
Ruby
7
star
19

persival

Programatic, persistent, pseudo key-value storage in Go
Go
7
star
20

authtools

Usefull stuff for unique tokens and secured password hashes generation.
Ruby
5
star
21

weedwarelicense.org

Weedware license website.
Ruby
5
star
22

wtf

WTF toolkit extracted from WebKit
C++
5
star
23

etoile

Etoile source code mirror. Etoile is a user environment designed from the ground up around the things people do with computers: create, collaborate, and learn.
Objective-C
5
star
24

rspec-jasmine

Jasmine runner and reporter for RSpec
JavaScript
4
star
25

objectpool

Magical thread pool implementation
Ruby
4
star
26

gotrail

Yet another super simple go logging...
Go
3
star
27

awesome_country_select

Provides a advanced helper to get an HTML select list of countries. The list of countries comes from the ISO 3166 standard. While it is a relatively neutral source of country names, it will still offend some users.
Ruby
3
star
28

gocolor

Simple colorizing at top of fmt package
Go
3
star
29

cgoecho

Example app using cgo interface to extend go with C code.
Go
3
star
30

no-logic-in-your-views-startechconf-2011

My talk on StarTechConf 2011 in Chile
Ruby
2
star
31

react

Redis based remote command executor.
Ruby
2
star
32

krug-redis-presentation

Presentation about Redis at Kraków Ruby User Group meeting
2
star
33

ryori

Projects generator and recipes compiler.
Ruby
2
star
34

exoteric

Website statistics from the most popular social networks (prototype in ruby)
Ruby
2
star
35

gostepper

Small helper for dealing with setup steps
Go
2
star
36

haml-magic-translations

Provides automaticaly translations in haml templates
Ruby
2
star
37

telegraph

Telegraph is DSL for quickly creating TCP servers in Ruby. It's running on EventMachine and is very similar to sinatra.
Ruby
2
star
38

nu7macs

Emacs configuration for nu7s!
Emacs Lisp
1
star
39

krug-padrino-presentation

Presentation about Padrino at Kraków Ruby User Group meeting
1
star
40

distributed-hell-wrocloverb-2012

JavaScript
1
star
41

mad-macs

...
Emacs Lisp
1
star
42

nu7hat.ch

nu7hatch's piece of web...
CSS
1
star
43

hop

Hop in the project!
Shell
1
star
44

cgoecho2

Modular version of the cgo echo example
1
star
45

go-web-services-london-go-meetup

Slides for my talk about web-services in Go at London Go Meetup
Ruby
1
star
46

rails-block-labels

Hack for using i18n powered block labels in rails3 app!
Ruby
1
star
47

i-hate-ruby-rubyconfuy-2011

Slides from the lightning talk at RubyConf Uruguay 2011
Ruby
1
star
48

rubykaigi2011

Presentation for RubyKaigi 2011
1
star
49

jagger

Jagger is your frontman!
Ruby
1
star
50

rage

Rage against the browsers!
JavaScript
1
star
51

agile-git-hooks

A set of git hooks improving work in agile teams.
Shell
1
star
52

trolley

High performence background jobs broker
Ruby
1
star
53

aur-packages

My packages submitted to AUR
1
star
54

selenium-webdriver

git clone of http://selenium.googlecode.com/svn/trunk/rb/
Ruby
1
star
55

leech

Simple TCP client/server framework with commands handling
Ruby
1
star
56

grapcha

Captcha reinvented!
Ruby
1
star
57

freebsd-dell-vostro

FreeBSD Dell Vostro 3300 Configuration...
Shell
1
star
58

webrocket-client-py

(under-development) WebRocket client library for Python
Python
1
star