Permalink
Browse files

Merge pull request #4 from kares/gemified

gemified + remastered some version history
  • Loading branch information...
2 parents 1ebcd2a + 19bfa1c commit f4b1ba71274e2edfbc6c9bba5708d26cee0df01f @cowboyd committed Apr 13, 2012
View
@@ -0,0 +1,64 @@
+# RedJS
+
+https://github.com/cowboyd/redjs
+
+Shared specs for a Ruby interface to JavaScript.
+
+
+Useful for different JavaScript interpreters wanting to present a unified
+interface to Ruby.
+
+Currently used by :
+
+* The Ruby Rhino: http://github.com/cowboyd/therubyrhino
+* The Ruby Racer: http://github.com/cowboyd/therubyracer
+
+## Usage
+
+You'll need [RSpec](http://rspec.info/) to use the specs RedJS provides.
+
+add this your *spec_helper.rb* :
+
+```ruby
+require 'redjs'
+module RedJS
+ Context = MyJS::Context # e.g. V8::Context or Rhino::Context
+end
+```
+
+add *spec/redjs_spec.rb* similar to this :
+
+```ruby
+require File.expand_path('../spec_helper', File.dirname(__FILE__))
+
+require 'redjs/load_specs'
+
+describe MyJS::Context do
+
+ it_behaves_like 'RedJS::Context'
+
+end
+```
+
+## API Requirements
+
+### RedJS::Context
+
+* should be instantiable using `new` without arguments or with a hash of options
+* desired options passed to `Context.new` :
+ * `:with` emulates JavaScript's with statement (provides a shorthand for writing
+ recurring accesses to the passed objects)
+* if a block is provided should yield the context instance
+* contexts provide an `eval` method for evaluating JavaScript code
+* context instances implement [] for exposing Ruby instances to JavaScript
+
+```ruby
+MyJS::Context.new do |context|
+ context["math"] = MyMath.new
+ context.eval("math.plus(20, 22)") #=> 42
+end
+```
+
+### RedJS::Error
+
+* common error class for propagating errors that occur in JS into the Ruby side
View
@@ -1,8 +0,0 @@
-Rspecs for a Ruby interface to javascript.
-
-This is useful for different javascript interpreters wanting to present a unified interface to ruby.
-
-Currently used by
- The Ruby Rhino: http://github.com/cowboyd/therubyrhino
- The Ruby Racer: http://github.com/cowboyd/therubyracer
-
View
@@ -0,0 +1,4 @@
+# -*- encoding: utf-8 -*-
+module RedJS
+ VERSION = "0.4.1".freeze
+end
View
@@ -0,0 +1 @@
+load 'redjs/spec/context_spec.rb'
Oops, something went wrong.

0 comments on commit f4b1ba7

Please sign in to comment.