therubyracer 0.5.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of therubyracer might be problematic. Click here for more details.

@@ -1,3 +1,7 @@
1
+ === 0.5.3 2010-03-01
2
+ * 1 major enhancement
3
+ * added full back trace to javascript code
4
+
1
5
  === 0.5.2 2010-02-26
2
6
  * 1 major enhancement
3
7
  * added javascript shell (bin/therubyracer)
data/Rakefile CHANGED
@@ -9,7 +9,7 @@ begin
9
9
  require 'jeweler'
10
10
  Jeweler::Tasks.new do |gemspec|
11
11
  gemspec.name = gemspec.rubyforge_project = "therubyracer"
12
- gemspec.version = "0.5.2"
12
+ gemspec.version = "0.5.3"
13
13
  gemspec.summary = "Embed the V8 Javascript interpreter into Ruby"
14
14
  gemspec.description = "Call javascript code and manipulate javascript objects from ruby. Call ruby code and manipulate ruby objects from javascript."
15
15
  gemspec.email = "cowboyd@thefrontside.net"
@@ -57,6 +57,8 @@ V8::Context.open(:with => V8::Shell.new) do |cxt|
57
57
  result = cxt.eval(line)
58
58
  puts(result) unless result.nil?
59
59
 
60
+ rescue V8::JavascriptError => e
61
+ puts e.javascript_stacktrace
60
62
  rescue StandardError => e
61
63
  puts e
62
64
  end
@@ -58,6 +58,15 @@ VALUE v8_cxt_open(VALUE self) {
58
58
  }
59
59
  }
60
60
 
61
+ VALUE Racer_Error_Message(TryCatch& exception) {
62
+ VALUE msg = V8_Ref_Create(V8_C_Message, exception.Message());
63
+ Local<Value> stack = exception.StackTrace();
64
+ if (!stack.IsEmpty()) {
65
+ rb_iv_set(msg,"@stack",V82RB(stack));
66
+ }
67
+ return msg;
68
+ }
69
+
61
70
  VALUE v8_cxt_eval(VALUE self, VALUE source, VALUE filename) {
62
71
  HandleScope handles;
63
72
  TryCatch exceptions;
@@ -66,12 +75,12 @@ VALUE v8_cxt_eval(VALUE self, VALUE source, VALUE filename) {
66
75
  Local<Value> source_str = RB2V8(source);
67
76
  Local<Value> source_name = RTEST(filename) ? RB2V8(filename) : *String::New("<eval>");
68
77
  Local<Script> script = Script::Compile(source_str->ToString(), source_name);
69
- if (exceptions.HasCaught()) {
70
- return V8_Ref_Create(V8_C_Message, exceptions.Message());
71
- }
78
+ if (exceptions.HasCaught()) {
79
+ return Racer_Error_Message(exceptions);
80
+ }
72
81
  Local<Value> result = script->Run();
73
82
  if (exceptions.HasCaught()) {
74
- return V8_Ref_Create(V8_C_Message, exceptions.Message());
83
+ return Racer_Error_Message(exceptions);
75
84
  } else {
76
85
  return V82RB(result);
77
86
  }
data/lib/v8.rb CHANGED
@@ -2,7 +2,7 @@ $:.unshift(File.dirname(__FILE__)) unless
2
2
  $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
3
 
4
4
  module V8
5
- VERSION = '0.5.2'
5
+ VERSION = '0.5.3'
6
6
  require 'v8/v8' #native glue
7
7
  require 'v8/to'
8
8
  require 'v8/context'
@@ -95,7 +95,17 @@ module V8
95
95
  @native.GetLineNumber()
96
96
  end
97
97
 
98
+ def javascript_stacktrace
99
+ @native.stack
100
+ end
101
+
98
102
  end
99
103
  class RunawayScriptError < ContextError
100
104
  end
105
+
106
+ module C
107
+ class Message
108
+ attr_reader :stack
109
+ end
110
+ end
101
111
  end
@@ -373,7 +373,12 @@ EOJS
373
373
  it "is enumenable" do
374
374
  @cxt.open do
375
375
  evaljs("o.foo = 'bar'; o.bang = 'baz'; o[5] = 'flip'")
376
- @o.inject({}) {|i,p| k,v = p; i.tap {i[k] = v}}.should == {"foo" => 'bar', "bang" => 'baz', 5 => 'flip'}
376
+ {}.tap do |h|
377
+ @o.each do |k,v|
378
+ h[k] = v
379
+ end
380
+ h.should == {"foo" => 'bar', "bang" => 'baz', 5 => 'flip'}
381
+ end
377
382
  end
378
383
  end
379
384
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{therubyracer}
8
- s.version = "0.5.2"
8
+ s.version = "0.5.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Charles Lowell", "Bill Robertson"]
12
- s.date = %q{2010-02-26}
12
+ s.date = %q{2010-03-01}
13
13
  s.default_executable = %q{therubyracer}
14
14
  s.description = %q{Call javascript code and manipulate javascript objects from ruby. Call ruby code and manipulate ruby objects from javascript.}
15
15
  s.email = %q{cowboyd@thefrontside.net}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: therubyracer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Charles Lowell
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2010-02-26 00:00:00 -06:00
13
+ date: 2010-03-01 00:00:00 -06:00
14
14
  default_executable: therubyracer
15
15
  dependencies: []
16
16