Class: Bullring::RacerWorker
- Inherits:
-
Worker
- Object
- Worker
- Bullring::RacerWorker
show all
- Defined in:
- lib/bullring/workers/racer_worker.rb
Instance Attribute Summary
Attributes inherited from Worker
#libraries
Instance Method Summary
collapse
Methods inherited from Worker
#add_library, #discard, #refresh
Constructor Details
Returns a new instance of RacerWorker.
5
6
7
|
# File 'lib/bullring/workers/racer_worker.rb', line 5
def initialize
super
end
|
Instance Method Details
#_discard ⇒ Object
38
|
# File 'lib/bullring/workers/racer_worker.rb', line 38
def _discard; end
|
#alive? ⇒ Boolean
34
35
36
|
# File 'lib/bullring/workers/racer_worker.rb', line 34
def alive?
true
end
|
#check(script, options) ⇒ Object
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/bullring/workers/racer_worker.rb', line 9
def check(script, options)
context = V8::Context.new
context_wrapper {context.load(File.expand_path("../../js/jslint.min.js", __FILE__))}
call = Bullring::Helper::jslint_call(script)
duration, result = context_wrapper {context.eval(call)}
result = result.collect{|obj| obj.respond_to?(:to_h) ? obj.to_h : obj}
end
|
#run(script, options) ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/bullring/workers/racer_worker.rb', line 20
def run(script, options)
context = V8::Context.new
(options['library_names'] || []).each do |library_name|
library = libraries[library_name]
context_wrapper {context.eval(library)}
end
duration, result = context_wrapper {context.eval(script)}
result = result.respond_to?(:to_h) ? result.to_h : result
end
|