sq_mini_racer 0.2.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 2288096de854ca36d63ed01c0901fd4eef5b9a9c0b8c882975d0bb3de0983278
4
+ data.tar.gz: ced3d1d34911253004a311d99ab9f94eb2034804ffd85cc32a537f051e6f2afb
5
+ SHA512:
6
+ metadata.gz: 947ba757775b66d43cb156422fc70cf08b105ad8728307317e558023c789b6797d2540fa293fe55c14efb28c4176796d7824bd39a7325707706dfd5499483901
7
+ data.tar.gz: 5722647ea94b06e29c0048c96a47906e7007d6e0b621a739cc5695b9d812f0ef710b1bfb3566f19ff3dbdf6634757b0011123e39d5fc9c0601d1c8fa8e074cec
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ lib/*.so
11
+ /lib/sq_mini_racer/
12
+ /ext/mini_racer_extension/mini_racer.creator.*
13
+ *.bundle
@@ -0,0 +1,16 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9
4
+ - 2.0
5
+ - 2.1
6
+ - 2.2
7
+ - 2.3
8
+ - 2.4
9
+ - 2.5
10
+ - ruby-head
11
+ dist: trusty
12
+ sudo: true
13
+ before_install:
14
+ - gem update --system
15
+ - gem install bundler -v 1.16.2
16
+ cache: bundler
@@ -0,0 +1,113 @@
1
+ - 06-07-2018
2
+
3
+ - 0.2.0
4
+ - FEATURE: context#call to allow for cheaper invocation of functions
5
+ - FIX: rare memory leak when terminating a long running attached function
6
+ - FIX: rare segfault when terminating a long running attached function
7
+ - FIX: Reimplement Isolate#idle_notification using idle_notification_deadline, API remains the same @ignisf
8
+ - Account for changes in the upstream V8 API @ignisf
9
+ - Support for libv8 6.7
10
+
11
+ 23-08-2017
12
+
13
+ - 0.1.15
14
+
15
+ - bump dependency of libv8 to 6.3
16
+
17
+ 23-08-2017
18
+
19
+ - 0.1.14
20
+
21
+ - libv8 erronuously bumped to beta, reverted change
22
+
23
+ 23-08-2017
24
+
25
+ - 0.1.13
26
+
27
+ - Fix: amend array buffer allocator to use v8 6.0 compatible allocator @ignisf
28
+
29
+ 18-07-2017
30
+
31
+ - 0.1.12
32
+
33
+ - Feature: upgrade libv8 to 5.9
34
+ - Fix: warning when runnin with ruby warnings enabled (missed @disposed initialize)
35
+
36
+ 18-07-2017
37
+
38
+ - 0.1.11
39
+
40
+ - Feature: upgrade libv8 to 5.7
41
+
42
+ 13-07-2017
43
+
44
+ - 0.1.10
45
+
46
+ - Fix leak: memory leak when disposing a context (20 bytes per context)
47
+ - Feature: added #heap_stats so you can get visibility from context to actual memory usage of isolate
48
+ - Feature: added #dispose so you reclaim all v8 memory right away as opposed to waiting for GC
49
+ - Feature: you can now specify filename in an eval eg: eval('a = 1', filename: 'my_awesome.js')
50
+
51
+ 09-03-2017
52
+
53
+ - 0.1.9
54
+
55
+ - Perf: speed up ruby/node boundary performance when moving large objects
56
+
57
+ 06-02-2017
58
+
59
+ - 0.1.8
60
+
61
+ - Fix: Include math.h to fix use of undeclared identifier floor with rbx. See #51
62
+
63
+ 02-11-2016
64
+
65
+ - 0.1.7
66
+
67
+ - Fix: if for some reason an isolate was forked don't free it and raise a warning instead to avoid hanging process
68
+
69
+ 25-10-2016
70
+
71
+ - 0.1.6
72
+
73
+ - Fix: timeout behavior was incorrect, in some cases stop could be called on already stopped contexts
74
+
75
+ 10-10-2016
76
+
77
+ - 0.1.5
78
+
79
+ - Support for snapshots, shared isolates, runtime flags thanks to @wk8
80
+ - Fix timeout behavior when it occurs in an attached Ruby method
81
+
82
+ 19-05-2016
83
+
84
+ - 0.1.4
85
+
86
+ - Set upper bound for libv8 inclusion @ignisf
87
+ - Support conversion of Date, Time and DateTime from Ruby to JS @seanmakesgames
88
+ - Support conversion of large numbers back from Ruby to JS @seanmakesgames
89
+
90
+ - 0.1.3
91
+
92
+ - Support more conversions from Ruby back to JS (Hash, Symbol, Array)
93
+ - Support attaching nested objects
94
+
95
+
96
+ 17-05-2016
97
+
98
+ - 0.1.2
99
+
100
+ - Gemspec specifies minimal version of Ruby (2.0)
101
+ - Implement #load on Context to load files
102
+
103
+ 17-05-2016
104
+
105
+ - 0.1.1
106
+
107
+ - Added unblock function so SIGINT does not lead to a crash
108
+
109
+ 14-05-2016
110
+
111
+ - 0.1.1.beta.1
112
+
113
+ - First release
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at sam.saffron@gmail.com. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in mini_racer.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 TODO: Write your name
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,435 @@
1
+ # Sqreen's fork of mini\_racer
2
+
3
+ This is a fork of [`mini_racer`](https://github.com/discourse/mini_racer), changed to allow coexistence with other versions of mainline mini\_racer and with therubyracer, and to improve compatibility with old versions of Ruby. Otherwise, it should track mainstream mini\_racer. It provides extra functionality to the [`sqreen`](https://rubygems.org/gems/sqreen/) gem.
4
+
5
+ # MiniRacer
6
+
7
+ [![Build Status](https://travis-ci.org/sqreen/mini_racer.svg?branch=master)](https://travis-ci.org/sqreen/mini_racer)
8
+
9
+ Minimal, modern embedded V8 for Ruby.
10
+
11
+ MiniRacer provides a minimal two way bridge between the V8 JavaScript engine and Ruby.
12
+
13
+ It was created as an alternative to the excellent [therubyracer](https://github.com/cowboyd/therubyracer). Unlike therubyracer, mini\_racer only implements a minimal bridge. This reduces the surface area making upgrading v8 much simpler and exhaustive testing simpler.
14
+
15
+ MiniRacer has an adapter for [execjs](https://github.com/rails/execjs) so it can be used directly with Rails projects to minify assets, run babel or compile CoffeeScript.
16
+
17
+ ### A note about Ruby version Support
18
+
19
+ MiniRacer only supports non-EOL versions of Ruby. See [Ruby](https://www.ruby-lang.org/en/downloads) to see the list of non-EOL Rubies.
20
+
21
+ If you require support for older versions of Ruby install an older version of the gem.
22
+
23
+ ## Features
24
+
25
+ ### Simple eval for JavaScript
26
+
27
+ You can simply eval one or many JavaScript snippets in a shared context
28
+
29
+ ```ruby
30
+ context = MiniRacer::Context.new
31
+ context.eval 'var adder = (a,b)=>a+b;'
32
+ puts context.eval 'adder(20,22)'
33
+ # => 42
34
+ ```
35
+
36
+ ### Attach global Ruby functions to your JavaScript context
37
+
38
+ You can attach one or many ruby proc that can be accessed via JavaScript
39
+
40
+ ```ruby
41
+ context = MiniRacer::Context.new
42
+ context.attach("math.adder", proc{|a,b| a+b})
43
+ puts context.eval 'math.adder(20,22)'
44
+ # => 42
45
+ ```
46
+
47
+ ```ruby
48
+ context = MiniRacer::Context.new
49
+ context.attach("array_and_hash", proc{{a: 1, b: [1, {a: 1}]}})
50
+ puts context.eval 'array_and_hash()'
51
+ # => {"a" => 1, "b" => [1, {"a" => 1}]}
52
+ ```
53
+
54
+ ### GIL free JavaScript execution
55
+
56
+ The Ruby Global interpreter lock is released when scripts are executing
57
+
58
+ ```ruby
59
+ context = MiniRacer::Context.new
60
+ Thread.new do
61
+ sleep 1
62
+ context.stop
63
+ end
64
+ context.eval 'while(true){}'
65
+ # => exception is raised
66
+ ```
67
+
68
+ This allows you to execute multiple scripts in parallel.
69
+
70
+ ### Timeout support
71
+
72
+ Contexts can specify a default timeout for scripts
73
+
74
+ ```ruby
75
+ # times out after 1 second (1000 ms)
76
+ context = MiniRacer::Context.new(timeout: 1000)
77
+ context.eval 'while(true){}'
78
+ # => exception is raised
79
+ ```
80
+
81
+ ### Memory softlimit support
82
+
83
+ Contexts can specify a memory softlimit for scripts
84
+
85
+ ```ruby
86
+ # terminates script if heap usage exceeds 200mb after V8 garbage collection has run
87
+ context = MiniRacer::Context.new(max_memory: 200000000)
88
+ context.eval 'var a = new Array(10000); while(true) {a = a.concat(new Array(10000)); print("loop " + a.length);}'
89
+ # => V8OutOfMemoryError is raised
90
+ ```
91
+
92
+ ### Rich debugging with "filename" support
93
+
94
+ ```ruby
95
+
96
+ context = MiniRacer::Context.new
97
+ context.eval('var foo = function() {bar();}', filename: 'a/foo.js')
98
+ context.eval('bar()', filename: 'a/bar.js')
99
+
100
+ # MiniRacer::RuntimeError is raised containing the filenames you specified for evals in backtrace
101
+
102
+ ```
103
+
104
+
105
+ ### Threadsafe
106
+
107
+ Context usage is threadsafe
108
+
109
+ ```ruby
110
+
111
+ context = MiniRacer::Context.new
112
+ context.eval('counter=0; plus=()=>counter++;')
113
+
114
+ (1..10).map do
115
+ Thread.new {
116
+ context.eval("plus()")
117
+ }
118
+ end.each(&:join)
119
+
120
+ puts context.eval("counter")
121
+ # => 10
122
+
123
+ ```
124
+
125
+ ### Snapshots
126
+
127
+ Contexts can be created with pre-loaded snapshots:
128
+
129
+ ```ruby
130
+
131
+ snapshot = MiniRacer::Snapshot.new('function hello() { return "world!"; }')
132
+
133
+ context = MiniRacer::Context.new(snapshot: snapshot)
134
+
135
+ context.eval("hello()")
136
+ # => "world!"
137
+
138
+ ```
139
+
140
+ Snapshots can come in handy for example if you want your contexts to be pre-loaded for effiency. It uses [V8 snapshots](http://v8project.blogspot.com/2015/09/custom-startup-snapshots.html) under the hood; see [this link](http://v8project.blogspot.com/2015/09/custom-startup-snapshots.html) for caveats using these, in particular:
141
+
142
+ ```
143
+ There is an important limitation to snapshots: they can only capture V8’s
144
+ heap. Any interaction from V8 with the outside is off-limits when creating the
145
+ snapshot. Such interactions include:
146
+
147
+ * defining and calling API callbacks (i.e. functions created via v8::FunctionTemplate)
148
+ * creating typed arrays, since the backing store may be allocated outside of V8
149
+
150
+ And of course, values derived from sources such as `Math.random` or `Date.now`
151
+ are fixed once the snapshot has been captured. They are no longer really random
152
+ nor reflect the current time.
153
+ ```
154
+
155
+ Also note that snapshots can be warmed up, using the `warmup!` method, which allows you to call functions which are otherwise lazily compiled to get them to compile right away; any side effect of your warm up code being then dismissed. [More details on warming up here](https://github.com/electron/electron/issues/169#issuecomment-76783481), and a small example:
156
+
157
+ ```ruby
158
+
159
+ snapshot = MiniRacer::Snapshot.new('var counter = 0; function hello() { counter++; return "world! "; }')
160
+
161
+ snapshot.warmup!('hello()')
162
+
163
+ context = MiniRacer::Context.new(snapshot: snapshot)
164
+
165
+ context.eval('hello()')
166
+ # => "world! 1"
167
+ context.eval('counter')
168
+ # => 1
169
+
170
+ ```
171
+
172
+ ### Shared isolates
173
+
174
+ By default, MiniRacer's contexts each have their own isolate (V8 runtime). For efficiency, it is possible to re-use an isolate across contexts:
175
+
176
+ ```ruby
177
+
178
+ isolate = MiniRacer::Isolate.new
179
+
180
+ context1 = MiniRacer::Context.new(isolate: isolate)
181
+ context2 = MiniRacer::Context.new(isolate: isolate)
182
+
183
+ context1.isolate == context2.isolate
184
+ # => true
185
+ ```
186
+
187
+ The main benefit of this is avoiding creating/destroying isolates when not needed (for example if you use a lot of contexts).
188
+
189
+ The caveat with this is that a given isolate can only execute one context at a time, so don't share isolates across contexts that you want to run concurrently.
190
+
191
+ Also, note that if you want to use shared isolates together with snapshots, you need to first create an isolate with that snapshot, and then create contexts from that isolate:
192
+
193
+ ```ruby
194
+ snapshot = MiniRacer::Snapshot.new('function hello() { return "world!"; }')
195
+
196
+ isolate = MiniRacer::Isolate.new(snapshot)
197
+
198
+ context = MiniRacer::Context.new(isolate: isolate)
199
+
200
+ context.eval("hello()")
201
+ # => "world!"
202
+ ```
203
+
204
+ Re-using the same isolate over and over again means V8's garbage collector will have to run to clean it up every now and then; it's possible to trigger a _blocking_ V8 GC run inside your isolate by running the `idle_notification` method on it, which takes a single argument: the amount of time (in milliseconds) that V8 should use at most for garbage collecting:
205
+
206
+ ```ruby
207
+ isolate = MiniRacer::Isolate.new
208
+
209
+ context = MiniRacer::Context.new(isolate: isolate)
210
+
211
+ # do stuff with that context...
212
+
213
+ # give up to 100ms for V8 garbage collection
214
+ isolate.idle_notification(100)
215
+
216
+ ```
217
+
218
+ This can come in handy to force V8 GC runs for example in between requests if you use MiniRacer on a web application.
219
+
220
+ Note that this method maps directly to [`v8::Isolate::IdleNotification`](http://bespin.cz/~ondras/html/classv8_1_1Isolate.html#aea16cbb2e351de9a3ae7be2b7cb48297), and that in particular its return value is the same (true if there is no further garbage to collect, false otherwise) and the same caveats apply, in particular that `there is no guarantee that the [call will return] within the time limit.`
221
+
222
+ ### V8 Runtime flags
223
+
224
+ It is possible to set V8 Runtime flags:
225
+
226
+ ```ruby
227
+ MiniRacer::Platform.set_flags! :noconcurrent_recompilation, max_inlining_levels: 10
228
+ ```
229
+
230
+ This can come in handy if you want to use MiniRacer with Unicorn, which doesn't seem to alwatys appreciate V8's liberal use of threading:
231
+ ```ruby
232
+ MiniRacer::Platform.set_flags! :noconcurrent_recompilation, :noconcurrent_sweeping
233
+ ```
234
+
235
+ Or else to unlock experimental features in V8, for example tail recursion optimization:
236
+ ```ruby
237
+ MiniRacer::Platform.set_flags! :harmony
238
+
239
+ js = <<-JS
240
+ 'use strict';
241
+ var f = function f(n){
242
+ if (n <= 0) {
243
+ return 'foo';
244
+ }
245
+ return f(n - 1);
246
+ }
247
+
248
+ f(1e6);
249
+ JS
250
+
251
+ context = MiniRacer::Context.new
252
+
253
+ context.eval js
254
+ # => "foo"
255
+ ```
256
+ The same code without the harmony runtime flag results in a `MiniRacer::RuntimeError: RangeError: Maximum call stack size exceeded` exception.
257
+ Please refer to http://node.green/ as a reference on other harmony features.
258
+
259
+ A list of all V8 runtime flags can be found using `node --v8-options`, or else by perusing [the V8 source code for flags (make sure to use the right version of V8)](https://github.com/v8/v8/blob/master/src/flag-definitions.h).
260
+
261
+ Note that runtime flags must be set before any other operation (e.g. creating a context, a snapshot or an isolate), otherwise an exception will be thrown.
262
+
263
+ Flags:
264
+
265
+ - :expose_gc : Will expose `gc()` which you can run in JavaScript to issue a gc
266
+ - :max_old_space_size : defaults to 1400 (megs) on 64 bit, you can restric memory usage by limiting this.
267
+ - **NOTE TO READER** our documentation could be awesome we could be properly documenting all the flags, they are hugely useful, if you feel like documenting a few more, PLEASE DO, PRs are welcome.
268
+
269
+ ## Controlling memory
270
+
271
+ When hosting v8 you may want to keep track of memory usage, use #heap_stats to get memory usage:
272
+
273
+ ```ruby
274
+ context = MiniRacer::Context.new(timeout: 5)
275
+ context.eval("let a='testing';")
276
+ p context.heap_stats
277
+ # {:total_physical_size=>1280640,
278
+ # :total_heap_size_executable=>4194304,
279
+ # :total_heap_size=>3100672,
280
+ # :used_heap_size=>1205376,
281
+ # :heap_size_limit=>1501560832}
282
+ ```
283
+
284
+ If you wish to dispose of a context before waiting on the GC use
285
+
286
+ ```ruby
287
+ context = MiniRacer::Context.new(timeout: 5)
288
+ context.eval("let a='testing';")
289
+ context.dispose
290
+ context.eval("a = 2")
291
+ # MiniRacer::ContextDisposedError
292
+
293
+ # nothing works on the context from now on, its a shell waiting to be disposed
294
+ ```
295
+
296
+ ### Function call
297
+
298
+ This calls the function passed as first argument:
299
+
300
+ ```ruby
301
+ context = MiniRacer::Context.new
302
+ context.eval('function hello(name) { return "Hello, " + name + "!" }')
303
+ context.call('hello', 'George')
304
+ # "Hello, George!"
305
+ ```
306
+
307
+ Performance is slightly better than running `eval('hello("George")')` since:
308
+
309
+ - compilation of eval'd string is avoided
310
+ - function arguments don't need to be converted to JSON
311
+
312
+ ## Performance
313
+
314
+ The `bench` folder contains benchmark.
315
+
316
+ ### Benchmark minification of Discourse application.js (both minified and unminified)
317
+
318
+ MiniRacer outperforms node when minifying assets via execjs.
319
+
320
+ - MiniRacer version 0.1.9
321
+ - node version 6.10
322
+ - therubyracer version 0.12.2
323
+
324
+ ```
325
+
326
+ $ bundle exec ruby bench.rb mini_racer
327
+ Benching with mini_racer
328
+ mini_racer minify discourse_app.js 9292.72063ms
329
+ mini_racer minify discourse_app_minified.js 11799.850171ms
330
+ mini_racer minify discourse_app.js twice (2 threads) 10269.570797ms
331
+
332
+ sam@ubuntu exec_js_uglify % bundle exec ruby bench.rb node
333
+ Benching with node
334
+ node minify discourse_app.js 13302.715484ms
335
+ node minify discourse_app_minified.js 18100.761243ms
336
+ node minify discourse_app.js twice (2 threads) 14383.600207000001ms
337
+
338
+ sam@ubuntu exec_js_uglify % bundle exec ruby bench.rb therubyracer
339
+ Benching with therubyracer
340
+ therubyracer minify discourse_app.js 171683.01867700001ms
341
+ therubyracer minify discourse_app_minified.js 143138.88492ms
342
+ therubyracer minify discourse_app.js twice (2 threads) NEVER FINISH
343
+
344
+ Killed: 9
345
+ ```
346
+
347
+ The huge performance disparity (MiniRacer is 10x faster) is due to MiniRacer running latest version of V8. In July 2016 there is a queued upgrade to therubyracer which should bring some of the perf inline.
348
+
349
+ Note how the global interpreter lock release leads to 2 threads doing the same work taking the same wall time as 1 thread.
350
+
351
+ As a rule MiniRacer strives to always support and depend on the latest stable version of libv8.
352
+
353
+ ## Installation
354
+
355
+ Add this line to your application's Gemfile:
356
+
357
+ ```ruby
358
+ gem 'mini_racer'
359
+ ```
360
+
361
+ And then execute:
362
+
363
+ $ bundle
364
+
365
+ Or install it yourself as:
366
+
367
+ $ gem install mini_racer
368
+
369
+
370
+ **Note** using v8.h and compiling MiniRacer requires a C++11 standard compiler, more specifically clang 3.5 (or later) or gcc 4.8 (or later).
371
+
372
+
373
+ ## Travis-ci
374
+
375
+ To install `mini-racer` you will need a version of gcc that supports C++11 (gcc 4.8) this is included by default in ubuntu trusty based images.
376
+
377
+ Travis today ships by default with a precise based image. Precise Pangolin (12.04 LTS) was first released in August 2012. Even though you can install GCC 4.8 on precise the simpler approach is to opt for the trusty based image.
378
+
379
+ Add this to your .travis.yml file:
380
+
381
+ ```
382
+ - sudo: required
383
+ - dist: trusty
384
+ ```
385
+
386
+ ## Similar Projects
387
+
388
+ ### therubyracer
389
+
390
+ - https://github.com/cowboyd/therubyracer
391
+ - Most comprehensive bridge available
392
+ - Provides the ability to "eval" JavaScript
393
+ - Provides the ability to invoke Ruby code from JavaScript
394
+ - Hold references to JavaScript objects and methods in your Ruby code
395
+ - Hold references to Ruby objects and methods in JavaScript code
396
+ - Uses libv8, so installation is fast
397
+ - Supports timeouts for JavaScript execution
398
+ - Does not release global interpreter lock, so performance is constrained to a single thread
399
+ - Currently (May 2016) only supports v8 version 3.16.14 (Released approx November 2013), plans to upgrade by July 2016
400
+ - Supports execjs
401
+
402
+
403
+ ### v8eval
404
+
405
+ - https://github.com/sony/v8eval
406
+ - Provides the ability to "eval" JavaScript using the latest V8 engine
407
+ - Does not depend on the [libv8](https://github.com/cowboyd/libv8) gem, installation can take 10-20 mins as V8 needs to be downloaded and compiled.
408
+ - Does not release global interpreter lock when executing JavaScript
409
+ - Does not allow you to invoke Ruby code from JavaScript
410
+ - Multi runtime support due to SWIG based bindings
411
+ - Supports a JavaScript debugger
412
+ - Does not support timeouts for JavaScript execution
413
+ - No support for execjs (can not be used with Rails uglifier and coffeescript gems)
414
+
415
+
416
+ ### therubyrhino
417
+
418
+ - https://github.com/cowboyd/therubyrhino
419
+ - API compatible with therubyracer
420
+ - Uses Mozilla's Rhino engine https://github.com/mozilla/rhino
421
+ - Requires JRuby
422
+ - Support for timeouts for JavaScript execution
423
+ - Concurrent cause .... JRuby
424
+ - Supports execjs
425
+
426
+
427
+ ## Contributing
428
+
429
+ Bug reports and pull requests are welcome on GitHub at https://github.com/discourse/mini_racer. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
430
+
431
+
432
+ ## License
433
+
434
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
435
+