diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..fba837c --- /dev/null +++ b/.travis.yml @@ -0,0 +1,9 @@ +rvm: + - 1.9.2 + - 1.9.3 + - 1.8.7 +notifications: + recipients: + - cowboyd@thefrontside.net +script: bundle exec rake compile spec +before_install: git submodule update --init diff --git a/README.md b/README.md index 7a31d2c..bf37423 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ embed a ruby object into your scope and access its properties/methods from javas lhs + rhs end end - + cxt['math'] = MyMath.new cxt.eval("math.plus(20,22)") #=> 42 @@ -59,7 +59,7 @@ make a ruby object *be* your global javascript scope. cxt.eval("plus(20,22)") #=> 42 end -you can do the same thing with Object#eval_js +you can do the same thing with Object#eval_js math.eval_js("plus(20,22)") @@ -96,14 +96,14 @@ exposed by default. E.g. super end end - + class B < A def b "b" end end - - + + V8::Context.new do |cxt| cxt['a'] = A.new cxt['b'] = B.new @@ -138,6 +138,9 @@ To use the ruby racer in rails, or any application using Bundler to manage gems, bundle install rake compile +## Sponsored by +![The Frontside](http://github.com/cowboyd/therubyracer/raw/master/thefrontside.png) + ## LICENSE: (The MIT License) diff --git a/ext/v8/extconf.rb b/ext/v8/extconf.rb index 9e23984..dae2c60 100755 --- a/ext/v8/extconf.rb +++ b/ext/v8/extconf.rb @@ -18,8 +18,8 @@ $CPPFLAGS += " -Wall" unless $CPPFLAGS.split.include? "-Wall" $CPPFLAGS += " -g" unless $CPPFLAGS.split.include? "-g" $CPPFLAGS += " -rdynamic" unless $CPPFLAGS.split.include? "-rdynamic" -$DEFLIBPATH.unshift(Libv8.library_path) -$LIBS << ' -lv8 -lpthread' +$LDFLAGS.insert 0, "#{Libv8.library_path}/libv8.#{$LIBEXT} " +$LIBS << ' -lpthread' CONFIG['LDSHARED'] = '$(CXX) -shared' unless RUBY_PLATFORM =~ /darwin/ diff --git a/lib/v8/cli.rb b/lib/v8/cli.rb index af69280..fbadcc7 100644 --- a/lib/v8/cli.rb +++ b/lib/v8/cli.rb @@ -3,7 +3,7 @@ require 'ostruct' module V8 module CLI - def self.run(exename = 'v8', args = []) + def self.run(exename = 'v8', args = []) options = OpenStruct.new options.libs = [] options.libdirs = [] @@ -30,12 +30,12 @@ module V8 puts "V8 Version #{Libv8::V8_VERSION}" exit elsif options.selftest - self.test + self.test end Context.new(:with => Shell.new) do |cxt| for libfile in options.libs do load(cxt,libfile) - end + end if options.interactive repl(cxt, exename) elsif options.execute @@ -60,35 +60,36 @@ module V8 puts e end end - + def self.test begin - require 'rubygems' require 'rspec' + specs = File.expand_path('../../../spec', __FILE__) + $:.unshift specs ARGV.clear - ARGV << File.dirname(__FILE__) + '/../../spec/' + ARGV << specs ::RSpec::Core::Runner.autorun exit(0) rescue LoadError => e puts "selftest requires rspec to be installed (gem install rspec)" exit(1) end - + end def self.repl(cxt, exename) require 'readline' puts "help() for help. quit() to quit." puts "The Ruby Racer #{V8::VERSION}" - puts "Vroom Vroom!" + puts "Vroom Vroom!" trap("SIGINT") do puts "^C" - end + end loop do line = Readline.readline("#{exename}> ", true) begin result = cxt.eval(line, '') - puts(result) unless result.nil? + puts(result) unless result.nil? rescue V8::JSError => e puts e.message puts e.backtrace(:javascript) @@ -96,9 +97,9 @@ module V8 puts e puts e.backtrace.join("\n") end - end - end - + end + end + class Shell def to_s "[object Shell]" @@ -111,18 +112,18 @@ module V8 def exit(status = 0) Kernel.exit(status) end - + alias_method :quit, :exit - + def help(*args) <<-HELP print(msg) - print msg to STDOUT - + print msg to STDOUT + exit(status = 0) exit the shell also: quit() - + evalrb(source) evaluate some ruby source HELP diff --git a/lib/v8/context.rb b/lib/v8/context.rb index 3e0d78e..2da4c4f 100644 --- a/lib/v8/context.rb +++ b/lib/v8/context.rb @@ -84,6 +84,10 @@ module V8 [] end end + + def self.passes_this_argument? + true + end end module C diff --git a/lib/v8/portal/proxies.rb b/lib/v8/portal/proxies.rb index 16a1c71..3e47b02 100644 --- a/lib/v8/portal/proxies.rb +++ b/lib/v8/portal/proxies.rb @@ -74,7 +74,7 @@ module V8 if id = @rb_proxies_js2rb[object] ObjectSpace._id2ref id end - rescue RangeError => e + rescue RangeError # sometimes, the Ruby proxy has been garbage collected, but # the finalizer which runs has not been called. That's OK # we just clear out the entry, and return nil so that a new diff --git a/thefrontside.png b/thefrontside.png new file mode 100644 index 0000000..e8d5867 Binary files /dev/null and b/thefrontside.png differ