therubyracer-xcode 0.12.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +23 -0
  3. data/.travis.yml +14 -0
  4. data/Changelog.md +263 -0
  5. data/Gemfile +12 -0
  6. data/README.md +227 -0
  7. data/Rakefile +42 -0
  8. data/benchmarks.rb +218 -0
  9. data/ext/v8/accessor.cc +181 -0
  10. data/ext/v8/array.cc +26 -0
  11. data/ext/v8/backref.cc +45 -0
  12. data/ext/v8/constants.cc +34 -0
  13. data/ext/v8/constraints.cc +52 -0
  14. data/ext/v8/context.cc +130 -0
  15. data/ext/v8/date.cc +18 -0
  16. data/ext/v8/exception.cc +38 -0
  17. data/ext/v8/extconf.rb +34 -0
  18. data/ext/v8/external.cc +43 -0
  19. data/ext/v8/function.cc +58 -0
  20. data/ext/v8/gc.cc +43 -0
  21. data/ext/v8/handles.cc +34 -0
  22. data/ext/v8/heap.cc +35 -0
  23. data/ext/v8/init.cc +39 -0
  24. data/ext/v8/invocation.cc +86 -0
  25. data/ext/v8/locker.cc +77 -0
  26. data/ext/v8/message.cc +51 -0
  27. data/ext/v8/object.cc +335 -0
  28. data/ext/v8/primitive.cc +8 -0
  29. data/ext/v8/rr.cc +83 -0
  30. data/ext/v8/rr.h +934 -0
  31. data/ext/v8/script.cc +115 -0
  32. data/ext/v8/signature.cc +18 -0
  33. data/ext/v8/stack.cc +76 -0
  34. data/ext/v8/string.cc +47 -0
  35. data/ext/v8/template.cc +175 -0
  36. data/ext/v8/trycatch.cc +87 -0
  37. data/ext/v8/v8.cc +87 -0
  38. data/ext/v8/value.cc +239 -0
  39. data/lib/therubyracer.rb +1 -0
  40. data/lib/v8/access/indices.rb +40 -0
  41. data/lib/v8/access/invocation.rb +47 -0
  42. data/lib/v8/access/names.rb +65 -0
  43. data/lib/v8/access.rb +5 -0
  44. data/lib/v8/array.rb +26 -0
  45. data/lib/v8/context.rb +258 -0
  46. data/lib/v8/conversion/array.rb +11 -0
  47. data/lib/v8/conversion/class.rb +119 -0
  48. data/lib/v8/conversion/code.rb +38 -0
  49. data/lib/v8/conversion/fixnum.rb +11 -0
  50. data/lib/v8/conversion/fundamental.rb +11 -0
  51. data/lib/v8/conversion/hash.rb +11 -0
  52. data/lib/v8/conversion/indentity.rb +31 -0
  53. data/lib/v8/conversion/method.rb +26 -0
  54. data/lib/v8/conversion/object.rb +28 -0
  55. data/lib/v8/conversion/primitive.rb +7 -0
  56. data/lib/v8/conversion/proc.rb +5 -0
  57. data/lib/v8/conversion/reference.rb +16 -0
  58. data/lib/v8/conversion/string.rb +12 -0
  59. data/lib/v8/conversion/symbol.rb +7 -0
  60. data/lib/v8/conversion/time.rb +13 -0
  61. data/lib/v8/conversion.rb +36 -0
  62. data/lib/v8/error.rb +169 -0
  63. data/lib/v8/function.rb +28 -0
  64. data/lib/v8/object.rb +79 -0
  65. data/lib/v8/stack.rb +85 -0
  66. data/lib/v8/version.rb +3 -0
  67. data/lib/v8/weak.rb +82 -0
  68. data/lib/v8.rb +30 -0
  69. data/spec/c/array_spec.rb +19 -0
  70. data/spec/c/constants_spec.rb +22 -0
  71. data/spec/c/exception_spec.rb +28 -0
  72. data/spec/c/external_spec.rb +11 -0
  73. data/spec/c/function_spec.rb +48 -0
  74. data/spec/c/handles_spec.rb +31 -0
  75. data/spec/c/locker_spec.rb +36 -0
  76. data/spec/c/object_spec.rb +47 -0
  77. data/spec/c/script_spec.rb +30 -0
  78. data/spec/c/string_spec.rb +18 -0
  79. data/spec/c/template_spec.rb +31 -0
  80. data/spec/c/trycatch_spec.rb +52 -0
  81. data/spec/mem/blunt_spec.rb +42 -0
  82. data/spec/redjs_spec.rb +10 -0
  83. data/spec/spec_helper.rb +41 -0
  84. data/spec/threading_spec.rb +64 -0
  85. data/spec/v8/context_spec.rb +19 -0
  86. data/spec/v8/conversion_spec.rb +52 -0
  87. data/spec/v8/error_spec.rb +167 -0
  88. data/spec/v8/function_spec.rb +9 -0
  89. data/spec/v8/object_spec.rb +15 -0
  90. data/thefrontside.png +0 -0
  91. data/therubyracer.gemspec +22 -0
  92. metadata +186 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0648e002ee82460ca2d2573675f00dde30742b83
4
+ data.tar.gz: 5742afdd1b75323673779b97c0ff8fda91cb5250
5
+ SHA512:
6
+ metadata.gz: 55b4a3fea60525ff60238728a97d745d2899501bfc4fdea179af63ff20c3342e367f64050645135b27c9f95c90f062e99c4599ae8642bd065c4f153a0fea0db5
7
+ data.tar.gz: a8c868b5baa07747b876d7cd9ce0554dcf417c608496f83d6c15b8dec87735ed72058d03e9fda06220b1bea192c58763571ff53a31caa35c5cc56c4b3711684a
data/.gitignore ADDED
@@ -0,0 +1,23 @@
1
+ *.gem
2
+ *.rbc
3
+ .rbx/
4
+ .rvmrc
5
+ .bundle
6
+ .config
7
+ .yardoc
8
+ .project
9
+ .cproject
10
+ Gemfile.lock
11
+ InstalledFiles
12
+ _yardoc
13
+ coverage
14
+ doc/
15
+ lib/bundler/man
16
+ lib/v8/*.bundle
17
+ lib/v8/*.so
18
+ pkg
19
+ rdoc
20
+ spec/reports
21
+ test/tmp
22
+ test/version_tmp
23
+ tmp
data/.travis.yml ADDED
@@ -0,0 +1,14 @@
1
+ cache: bundler
2
+ rvm:
3
+ - 2.1
4
+ - 2.0.0
5
+ - 1.9.3
6
+ - 1.9.2
7
+ - 1.8.7
8
+ # - rbx-2.5.2
9
+ notifications:
10
+ recipients:
11
+ - cowboyd@thefrontside.net
12
+ before_install:
13
+ - gem update --system 2.1.11
14
+ script: bundle exec rake compile spec
data/Changelog.md ADDED
@@ -0,0 +1,263 @@
1
+ # Changelog
2
+
3
+ ## 0.12.2 2015/04/06
4
+
5
+ * fix memory leak where weak hash map entries were not being cleaned
6
+ up. Thanks to @SamSaffon
7
+
8
+ ## 0.12.1 2014/02/03
9
+
10
+ * add `timeout` option to `V8::Context` to forcibly abort long running scripts (thanks to @SamSaffron)
11
+ * allow canonical require via `require "therubyracer"` instead of oddball `require "v8"`(thanks @gaffneyc)
12
+
13
+ ## 0.12.0 2013/08/20
14
+
15
+ * upgrade v8 to 3.16.4 (thanks to @ignisf)
16
+ * enable native (and functional) weakref implementation for MRI > 2.0
17
+ * expose low level interface for `V8::C::HeapStatistics#total_physical_size`
18
+
19
+ ## 0.11.1 2013/01/04
20
+
21
+ * reintroduce the dependency on libv8
22
+ * libv8 can be disabled by installing it with the --with-system-v8 flag
23
+
24
+ ## 0.11.0 2012/12/04
25
+
26
+ * upgrade V8 version to 3.11.8
27
+ * remove dependency on libv8. enable compilation against system v8
28
+ * complete re-write of low-level C layer for dramatically increased stability and performance
29
+ * more faithful and complete coverage of the low-level C API
30
+ * ease the building of binary gems
31
+ * official support for Rubinius
32
+ * ability to query V8 for memory usage and set resource constraints
33
+ * extensible conversion framework for thunking Ruby values to V8 and vice-versa
34
+ * extensible invocation framework for calling Ruby code (Proc, Method, etc...) from JavaScript
35
+ * extensible access framework for interacting with Ruby properties from JavaScript
36
+ * provide explicit context teardown for distributed cycles of garbage.
37
+
38
+
39
+ ## 0.10.1 2012/04/05
40
+
41
+ * [bugfix] V8::Object#respond_to? did not call super
42
+
43
+ ## 0.10.0 2012/03/28
44
+
45
+ * [incompatible] embedded lambdas now take JS `this` object as first object
46
+ * add sponsorship image to the README
47
+ * enable Travis CI
48
+
49
+ ## 0.9.9 2011/11/08
50
+
51
+ * remove GCC specific C++ extension to fix llvm build.
52
+
53
+ ## 0.9.8 2011/11/07
54
+
55
+ * let Rake version float again.
56
+
57
+ ## 0.9.7 2011/10/06
58
+ * build fixes
59
+ * fix rake dependency at 0.8.7 while the Rake team sorts some shit out.
60
+
61
+ ## 0.9.6 2011/10/06
62
+
63
+ * make build compatible with Gentoo
64
+
65
+ ## 0.9.5 - 2011/10/05
66
+
67
+ * remove GCC specific code to enable build on BSD
68
+ * let Rake dependency float
69
+
70
+ ## 0.9.4 - 2011/08/22
71
+
72
+ * Fix an issue with the compilation include paths which allowed compilation against conflicting libv8's
73
+
74
+ ## 0.9.3 - 2011/08/11
75
+
76
+ * Better documentation for the C extension memory management
77
+ * Always lock V8 operations, always.
78
+ * GH-86 Context#[], Context#[]= always looks up values from the JavaScript scope, even when it's a Ruby object
79
+
80
+ ## 0.9.2 - 2011/06/23
81
+
82
+ * fix issue with 1.8.7 where object allocation inside of GC was segfaulting
83
+
84
+ ## 0.9.1 - 2011/06/17
85
+
86
+ * never perform V8 operations inside Ruby GC
87
+ * refactor locking interface
88
+ * add documentation for v8_handle
89
+
90
+ ## 0.9.0 - 2011/06/10
91
+
92
+ * extract libv8 into installable binary for most platforms
93
+ * fix numerous memory leaks
94
+ * expose the V8 debugger via V8::C::Debug::EnableAgent()
95
+ * force UTf-8 encoding on strings returned from javascript in ruby 1.9
96
+ * remove deprecated evaluate() methods
97
+ * make the currently executing JavaScript stack available via Context#stack
98
+
99
+ ## 0.8.1 - 2011/03/07
100
+
101
+ * upgrade to v8 3.1.8
102
+ * remove bin/v8 which conflicted with v8 executeable
103
+ * decruft all the crap that had accumulated in the gem
104
+ * Javascript Objects are now always mapped to the same V8::Object when read from the context
105
+
106
+ ## 0.8.0 - 2010/12/02
107
+
108
+ * every V8 Context gets its own unique access strategy
109
+ * ruby methods and procs embedded in javascript always return the same function per context.
110
+ * ruby classes and subclasses are now all connected via the javascript prototype chain
111
+ * better error reporting on syntax errors
112
+ * upgrade to rspec 2
113
+ * several bug fixes and stability fixes
114
+
115
+ ## 0.7.5 - 2010/08/03
116
+
117
+ * upgrade to V8 2.3.3
118
+ * property interceptors from ruby via [] and []=
119
+ * indexed property access via [] and []=
120
+ * property
121
+ * several bugfixes
122
+ * stability: eliminate many segfaults
123
+ * don't enumerate property setters such as foo= from javascript
124
+
125
+ ## 0.7.4 - 2010/06/15
126
+
127
+ * bug fix for rvm ruby installs incorrectly detected as 32bit
128
+
129
+ ## 0.7.3 - 2010/06/15
130
+
131
+ * don't catch SystemExit and NoMemoryError
132
+ * fix bug bundling gem
133
+
134
+ ## 0.7.2 - 2010/06/14
135
+
136
+ * embed ruby classes as constructors
137
+ * support for rubinius
138
+ * uniform backtrace() function on JSError mixes the ruby
139
+ * String::NewSymbol() is now scriptable
140
+ * InstanceTemplate(), PrototypeTemplate(), Inherit() methods on v8::FunctionTemplate now scriptable.
141
+ * reuse the standard ruby object access template
142
+ * fix a bunch of compile warnings
143
+ * Store any ruby object in V8 with V8::C::External
144
+
145
+ ## 0.7.1 - 2010/06/03
146
+
147
+ * Function#call() now uses the global scope for 'this' by default
148
+ * Function#methodcall() added to allow passing in 'this' object
149
+ * Function#new() method to invoke javascript constructor from ruby
150
+ * access javascript properties and call javascript methods from ruby
151
+ * bundled Jasmine DOM-Less browser testing framework.
152
+
153
+ * added Object::GetHiddenValue() to v8 metal
154
+ * added Handle::IsEmpty() to v8 metal
155
+ * fixed bug where iterating over arrays sometimes failed
156
+ * numerous bug /segfault fixes.
157
+
158
+ ## 0.7.0 - 2010/05/31
159
+
160
+ * upgraded to V8 2.1.10
161
+ * added low level scripting interface for V8 objects
162
+ * ruby object property/method access is now implemented in ruby
163
+ * auto-convert javascript arrays to rb arrays and vice-versa
164
+ * auto-convert ruby hashes into javascript objects
165
+ * auto-convert javascript Date into ruby Time object and vice versa.
166
+ * better exception handling when passing through multiple language boundaries
167
+ * objects maintain referential integrity when passing objects from ruby to javascript and vice-versa
168
+ * added debug compile option for getting C/C++ backtraces whenever segfaults occur.
169
+ * official support for REE 1.8.7
170
+ * fixed numerous segfaults
171
+ * implemented V8::Value#to_s
172
+ * the global scope is available to every V8::Context as the 'scope' attribute
173
+ * properly convert ruby boolean values into V8 booleans.
174
+
175
+ ## 0.6.3 - 2010/05/07
176
+
177
+ * FIX: linkage error on OSX /usr/bin/ruby
178
+
179
+ ## 0.6.2 - 2010/05/06
180
+
181
+ * FIX: linkage error on OSX 10.5
182
+
183
+ ## 0.6.1 - 2010/05/03
184
+
185
+ * call JavaScript functions from Ruby
186
+
187
+ ## 0.6.0 - 2010/03/31
188
+
189
+ * ruby 1.9 compatible
190
+ * full featured command line bin/v8 and bin/therubyracer
191
+ * self validating install (v8 --selftest)
192
+ * Only dependency to build gem from source is rubygems.
193
+
194
+ ## 0.5.5 - 2010/03/15
195
+
196
+ * fix string encoding issue that was breaking RHEL 5.x
197
+ * fix pthread linking issue on RHEL 5.2
198
+
199
+ ## 0.5.4 - 2010/03/09
200
+
201
+ * add ext directory to gem require paths which was causing problems for non-binary gems
202
+
203
+ ## 0.5.3 - 2010/03/01
204
+
205
+ * added full back trace to javascript code
206
+
207
+ ## 0.5.2 - 2010/02/26
208
+
209
+ * added javascript shell (bin/therubyracer)
210
+ * added to_s method for embedded ruby objects
211
+ * added line number and file name to error message.
212
+
213
+ ## 0.5.1 - 2010/02/17
214
+
215
+ * fix bug in 1.8.6 by creating Object#tap if it does not exist
216
+
217
+ ## 0.5.0 - 2010/02/17
218
+
219
+ * support for Linux 64 bit
220
+
221
+ ## 0.4.9 - 2010/02/16
222
+
223
+ * support for Linux 32 bit
224
+
225
+ ## 0.4.8 - 2010/02/08
226
+
227
+ * expose line number and source name on JavascriptErrors.
228
+
229
+ ## 0.4.5 - 2010/01/18
230
+
231
+ * case munging so that ruby methods(perl_case) are accessed through javascript in camelCase.
232
+ * access 0-arity ruby methods as javascript properties
233
+ * invoke ruby setters from javascript as properties
234
+ * contexts detect whether they are open or not and open when needed
235
+
236
+ ## 0.4.4 - 2010/01/14
237
+
238
+ * Ruby objects embedded into javascript are passed back to ruby as themselves and not a wrapped V8 object wrapping a ruby object.
239
+ * Use any ruby object as the scope of eval().
240
+ * quick and dirty V8.eval() method added
241
+ * native objects have a reference to the context that created them.
242
+ * context now has equality check.
243
+ * expose InContext() and GetCurrent() methods.
244
+ * fix a couple of segmentation faults
245
+
246
+ ## 0.4.3 - 2010/10/11
247
+
248
+ * access properties on Ruby objects with their camel case equivalents
249
+ * reflect JavaScript objects into Ruby and access their properties
250
+ * load JavaScript source from an IO object or by filename
251
+
252
+ ## 0.4.2 - 2010/10/10
253
+
254
+ * embed Ruby Objects into Javascript and call their methods
255
+
256
+ ## 0.4.1 - 2010/01/09
257
+
258
+ * embed bare Proc and Method objects into JavaScript and call them
259
+ * catch JavaScript exceptions from Ruby
260
+
261
+ ## 0.4.0 - 2009/12/21
262
+
263
+ * evaluate JavaScript code from inside Ruby.
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :development do
6
+ gem "rubysl", :platforms => :rbx
7
+ gem 'redjs', :git => 'https://github.com/cowboyd/redjs.git'
8
+ gem "rake"
9
+ gem "rspec", "~> 2.0"
10
+ gem "rake-compiler"
11
+ gem "gem-compiler", :platforms => :mri
12
+ end
data/README.md ADDED
@@ -0,0 +1,227 @@
1
+ # therubyracer
2
+
3
+ ## This version compiles with XCode 7.3
4
+
5
+ [![Gem Version](https://badge.fury.io/rb/therubyracer.png)](http://badge.fury.io/rb/therubyracer)
6
+ [![Build Status](https://travis-ci.org/cowboyd/therubyracer.png?branch=master)](https://travis-ci.org/cowboyd/therubyracer)
7
+ [![Build status](https://ci.appveyor.com/api/projects/status/aqw06doke164dca7?svg=true)](https://ci.appveyor.com/project/cowboyd/therubyracer)
8
+ [![Dependency Status](https://gemnasium.com/cowboyd/therubyracer.png)](https://gemnasium.com/cowboyd/therubyracer)
9
+ [![Join the chat at https://gitter.im/cowboyd/therubyracer](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/cowboyd/therubyracer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
10
+
11
+
12
+ * GitHub Project: [http://github.com/cowboyd/therubyracer](http://github.com/cowboyd/therubyracer)
13
+ * Mailing List: [http://groups.google.com/group/therubyracer](http://groups.google.com/group/therubyracer)
14
+ * Documentation: [GitHub Wiki](https://github.com/cowboyd/therubyracer/wiki) and [RubyDoc](http://rubydoc.info/gems/therubyracer)
15
+
16
+ ### DESCRIPTION
17
+
18
+ Embed the V8 JavaScript interpreter into Ruby.
19
+
20
+ ### FEATURES
21
+
22
+ * Evaluate JavaScript from within Ruby
23
+ * Embed your Ruby objects into the JavaScript world
24
+ * Manipulate JavaScript objects and call JavaScript functions from Ruby
25
+ * API compatible with the The Ruby Rhino (for JRuby: http://github.com/cowboyd/therubyrhino)
26
+
27
+ ### SYNOPSIS
28
+
29
+ gem install therubyracer
30
+
31
+ then in your Ruby code
32
+
33
+ require 'v8'
34
+
35
+ or if using bundler (as with Rails), add the following to your Gemfile
36
+
37
+ gem "therubyracer"
38
+
39
+ evaluate some simple JavaScript
40
+
41
+ cxt = V8::Context.new
42
+ cxt.eval('7 * 6') #=> 42
43
+
44
+ access values inside your JavaScript context from Ruby
45
+
46
+ cxt.eval 'var val = {num: 5, isTruthy: function (arg) { return !!arg }}'
47
+ val = cxt[:val] #=> V8::Object
48
+ cxt[:val] == cxt.scope.val #=> true
49
+ val.num #=> 5
50
+ val.isTruthy(1) #=> true
51
+
52
+ this includes references to JavaScript functions
53
+
54
+ truthy = val[:isTruthy] #=> V8::Function
55
+ truthy.call(' ') #=> true
56
+ truthy.call(0) #=> false
57
+
58
+
59
+ embed values into the scope of your context
60
+
61
+ cxt['foo'] = "bar"
62
+ cxt.eval('foo') # => "bar"
63
+
64
+ embed Ruby code into your scope and call it from JavaScript
65
+
66
+ cxt["say"] = lambda {|this, word, times| word * times}
67
+ cxt.eval("say('Hello', 3)") #=> HelloHelloHello
68
+
69
+ embed a Ruby object into your scope and access its properties/methods
70
+ from JavaScript
71
+
72
+ class MyMath
73
+ def plus(lhs, rhs)
74
+ lhs + rhs
75
+ end
76
+ end
77
+
78
+ cxt['math'] = MyMath.new
79
+ cxt.eval("math.plus(20,22)") #=> 42
80
+
81
+ make a Ruby object *be* your global JavaScript scope.
82
+
83
+ math = MyMath.new
84
+ V8::Context.new(:with => math) do |cxt|
85
+ cxt.eval("plus(20,22)") #=> 42
86
+ end
87
+
88
+ you can do the same thing with Object#eval_js
89
+
90
+ math.eval_js("plus(20,22)")
91
+
92
+ ### Different ways of loading JavaScript source
93
+
94
+ In addition to just evaluating strings, you can also use streams, such
95
+ as files.
96
+
97
+ evaluate bytes read from any File/IO object:
98
+
99
+ File.open("mysource.js") do |file|
100
+ cxt.eval(file, "mysource.js")
101
+ end
102
+
103
+ or load it by filename
104
+
105
+ cxt.load("mysource.js")
106
+
107
+ ### Safe by default, dangerous by demand
108
+
109
+ The Ruby Racer is designed to let you evaluate JavaScript as safely as
110
+ possible unless you tell it to do something more dangerous. The
111
+ default context is a hermetically sealed JavaScript environment with
112
+ only the standard JavaScript objects and functions. Nothing from the
113
+ Ruby world is accessible at all.
114
+
115
+ For Ruby objects that you explicitly embed into JavaScript, by default
116
+ only the _public_ methods _below_ `Object` are exposed by default.
117
+ E.g.
118
+
119
+ class A
120
+ def a
121
+ "a"
122
+ end
123
+
124
+ def to_s
125
+ super
126
+ end
127
+ end
128
+
129
+ class B < A
130
+ def b
131
+ "b"
132
+ end
133
+ end
134
+
135
+
136
+ V8::Context.new do |cxt|
137
+ cxt['a'] = A.new
138
+ cxt['b'] = B.new
139
+ cxt.eval("a.a") # => 'a'
140
+ cxt.eval("b.b") # => 'b'
141
+ cxt.eval("b.a") # => 'a'
142
+ cxt.eval("b.to_s") # => #<B:0x101776be8> (because A explicitly defined it)
143
+ cxt.eval("b.object_id") #=> undefined, object_id is on Object
144
+ end
145
+
146
+ If needed, you can override the [Ruby Access][access] to allow whatever
147
+ behavior you'd like.
148
+
149
+ [access]:https://github.com/cowboyd/therubyracer/blob/master/lib/v8/access.rb
150
+
151
+ More documentation can be found on the [GitHub wiki](https://github.com/cowboyd/therubyracer/wiki)
152
+
153
+ ### Protecting Your CPU cycles
154
+
155
+ When running untrusted JavaScript code, you not only have to protect
156
+ which functions it has access to, but also how much of your CPU it can
157
+ consume. Take this simple, yet thoroughly malicious script:
158
+
159
+ ```javascript
160
+ while (true) {}
161
+ ```
162
+
163
+ It will loop forever and never return control to the calling Ruby
164
+ thread. To protect against such JavaScript code that either
165
+ deliberately or accidentally runs longer that it should, you can
166
+ set an explicit timeout on your context. If the code runs longer that
167
+ the allowed timeout, then it will throw an exception. Note that this
168
+ exception could be raised at any point in the execution of the
169
+ JavaScript.
170
+
171
+ To specify the timeout (in milliseconds), pass in the `timeout` option
172
+ to the constructor.
173
+
174
+ ```ruby
175
+ cxt = V8::Context.new timeout: 700
176
+ cxt.eval "while (true);" #= exception after 700ms!
177
+ ```
178
+
179
+ ### PREREQUISITES
180
+
181
+ The Ruby Racer requires the V8 Javascript engine, but it offloads the
182
+ handling of this dependency to the
183
+ [libv8](https://github.com/cowboyd/libv8) gem. Because libv8 is now a
184
+ gem dependency, you do not need a separate libv8 entry in your
185
+ project's Gemfile.
186
+
187
+ Please see [libv8](https://github.com/cowboyd/libv8) for V8 runtime
188
+ installation options.
189
+
190
+ ### DEVELOP
191
+
192
+ git clone git://github.com/cowboyd/therubyracer.git
193
+ cd therubyracer
194
+ bundle install
195
+ rake compile
196
+
197
+ ### Sponsored by
198
+
199
+ <a href="http://thefrontside.net">![The Frontside](http://github.com/cowboyd/therubyracer/raw/master/thefrontside.png)</a>
200
+
201
+ ### LICENSE:
202
+
203
+ (The MIT License)
204
+
205
+ Copyright (c) 2009,2010,2011,2012 Charles Lowell
206
+
207
+ Permission is hereby granted, free of charge, to any person obtaining
208
+ a copy of this software and associated documentation files (the
209
+ 'Software'), to deal in the Software without restriction, including
210
+ without limitation the rights to use, copy, modify, merge, publish,
211
+ distribute, sublicense, and/or sell copies of the Software, and to
212
+ permit persons to whom the Software is furnished to do so, subject to
213
+ the following conditions:
214
+
215
+ The above copyright notice and this permission notice shall be
216
+ included in all copies or substantial portions of the Software.
217
+
218
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
219
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
220
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
221
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
222
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
223
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
224
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
225
+
226
+ [1]: https://github.com/cowboyd/libv8
227
+ [2]: http://code.google.com/p/v8/wiki/BuildingWithGYP
data/Rakefile ADDED
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/env rake
2
+ require 'bundler/setup'
3
+ require "bundler/gem_tasks"
4
+
5
+ task :clean do
6
+ sh "rm -rf lib/v8/init.bundle lib/v8/init.so"
7
+ sh "rm -rf pkg"
8
+ end
9
+
10
+ require "rake/extensiontask"
11
+ Rake::ExtensionTask.new("init", eval(File.read("therubyracer.gemspec"))) do |ext|
12
+ ext.ext_dir = "ext/v8"
13
+ ext.lib_dir = "lib/v8"
14
+ ext.source_pattern = "*.{cc,h}"
15
+ end
16
+
17
+ require 'rspec/core/rake_task'
18
+ RSpec::Core::RakeTask.new(:spec) do |task|
19
+ task.rspec_opts = '--tag ~memory --tag ~threads'
20
+ end
21
+
22
+ task :sanity => [:clean, :compile] do
23
+ sh %q{ruby -Ilib -e "require 'v8'"}
24
+ end
25
+
26
+ NativeGem = "pkg/therubyracer-#{V8::VERSION}-#{Gem::Platform.new(RUBY_PLATFORM)}.gem"
27
+ file NativeGem => :build do
28
+ require "rubygems/compiler"
29
+ compiler = Gem::Compiler.new("pkg/therubyracer-#{V8::VERSION}.gem", 'pkg')
30
+ compiler.compile
31
+ end
32
+
33
+ desc "Build #{NativeGem} into the pkg directory"
34
+ task "build:native" => NativeGem
35
+
36
+ desc "Build and install #{File.basename NativeGem} into system gems"
37
+ task "install:native" => "build:native" do
38
+ sh "gem install #{NativeGem}"
39
+ end
40
+
41
+ task :default => :spec
42
+