h8 0.4.10 → 0.4.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/h8/h8.cpp +3 -0
- data/lib/h8/errors.rb +11 -3
- data/lib/h8/version.rb +1 -1
- data/spec/coffee_spec.rb +0 -34
- data/spec/context_spec.rb +8 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0948d18a5d505eae5dea20a665f08c4e585fa128
|
4
|
+
data.tar.gz: b3ff10f56ff8952278e3a255901d761fd86c48c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 626e81dd8d1552775252869f5fed2c7c4c02ab6544e3edc232851d60bebb532ce20a67bd0c5a577446432f2e2eb78ffa608bd411b0602927f24d5fcaac4d0d0d
|
7
|
+
data.tar.gz: 50edb3ade915b7016cfd67be0879fa77ec2805ee5fa19384cd5237a874a41486f8aec7aa3aabfeaedd4b99dd47e3acd749af9335d132284225114372c7aa4a9f
|
data/ext/h8/h8.cpp
CHANGED
@@ -30,6 +30,9 @@ void h8::JsError::raise() const {
|
|
30
30
|
rb_iv_set(ruby_exception, "@message", h8->to_ruby(s));
|
31
31
|
rb_iv_set(ruby_exception, "@javascript_error",
|
32
32
|
h8->to_ruby(jsx));
|
33
|
+
rb_iv_set(ruby_exception, "@origin_name", h8->to_ruby(m->GetScriptResourceName()));
|
34
|
+
rb_iv_set(ruby_exception, "@origin_line", INT2FIX(m->GetLineNumber()));
|
35
|
+
rb_iv_set(ruby_exception, "@origin_column", INT2FIX(m->GetEndColumn()));
|
33
36
|
}
|
34
37
|
}
|
35
38
|
rb_exc_raise(ruby_exception);
|
data/lib/h8/errors.rb
CHANGED
@@ -10,7 +10,7 @@ module H8
|
|
10
10
|
class JsError < Error
|
11
11
|
|
12
12
|
# Javascript Error object. May be nil
|
13
|
-
attr :javascript_error
|
13
|
+
attr :javascript_error, :origin_name, :origin_line, :origin_column
|
14
14
|
|
15
15
|
# Error name
|
16
16
|
def name
|
@@ -19,7 +19,15 @@ module H8
|
|
19
19
|
|
20
20
|
# String that represents stack trace if any as multiline string (\n separated)
|
21
21
|
def javascript_backtrace
|
22
|
-
|
22
|
+
if @javascript_error
|
23
|
+
s = @javascript_error.stack
|
24
|
+
if s !~ /at\s+.*\d+/
|
25
|
+
s += "\n\tat #{@origin_name}:#{@origin_line}:#{@origin_column}\n"
|
26
|
+
end
|
27
|
+
s
|
28
|
+
else
|
29
|
+
@message
|
30
|
+
end
|
23
31
|
end
|
24
32
|
|
25
33
|
def to_s
|
@@ -36,7 +44,7 @@ module H8
|
|
36
44
|
def initialize message
|
37
45
|
super
|
38
46
|
@message = message
|
39
|
-
@source
|
47
|
+
@source = nil
|
40
48
|
end
|
41
49
|
end
|
42
50
|
|
data/lib/h8/version.rb
CHANGED
data/spec/coffee_spec.rb
CHANGED
@@ -40,40 +40,6 @@ describe 'coffeescript' do
|
|
40
40
|
}).to raise_error(H8::JsError) { |e| e.to_s.should =~ /test.coffee\:4/ }
|
41
41
|
end
|
42
42
|
|
43
|
-
it 'should report exceptions' do
|
44
|
-
src = <<-END
|
45
|
-
fnb = ->
|
46
|
-
throw new Error 'lets check'
|
47
|
-
fna = ->
|
48
|
-
fnb()
|
49
|
-
CoffeeScript.getSourceMap = (name) ->
|
50
|
-
puts "DUMMUY \#{name}"
|
51
|
-
undefined
|
52
|
-
|
53
|
-
# fna()
|
54
|
-
# puts globalsIncluded
|
55
|
-
END
|
56
|
-
script = <<-END
|
57
|
-
function require(name) {
|
58
|
-
puts("REQ! "+name);
|
59
|
-
}
|
60
|
-
var res = CoffeeScript.compile(src, {sourceMap: true, filename: 'inner.coffee'});
|
61
|
-
//var sourceMaps = { 'inner.coffee' : res.sourceMap }
|
62
|
-
// puts("Compiled ok",JSON.stringify(CoffeeScript.sourceMaps));
|
63
|
-
// CoffeeScript.sourceMaps['inner'] = res.sourceMap
|
64
|
-
eval(res.js);
|
65
|
-
END
|
66
|
-
cxt = H8::Coffee.new.context
|
67
|
-
cxt[:puts] = -> (*args) { puts args.join(' ') }
|
68
|
-
cxt[:src] = src
|
69
|
-
# cxt[:src] = 'return "hello"'
|
70
|
-
begin
|
71
|
-
res = cxt.eval script, file_name: 'extest.coffee'
|
72
|
-
rescue Exception => e
|
73
|
-
puts e
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
43
|
context 'realword' do
|
78
44
|
class Room
|
79
45
|
end
|
data/spec/context_spec.rb
CHANGED
@@ -148,9 +148,14 @@ describe 'context' do
|
|
148
148
|
|
149
149
|
it 'should report syntax errors source' do
|
150
150
|
c = H8::Context.new
|
151
|
-
|
152
|
-
|
153
|
-
|
151
|
+
script = <<-END
|
152
|
+
var x = 0;
|
153
|
+
throw new Error("shit happens!");
|
154
|
+
END
|
155
|
+
expect(-> { c.eval script })
|
156
|
+
.to raise_error { |e|
|
157
|
+
(e.javascript_backtrace =~ /\:\d/).should > 0
|
158
|
+
}
|
154
159
|
end
|
155
160
|
|
156
161
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: h8
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sergeych
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-02-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|