Module: RubyNext::Language::Runtime
- Extended by:
- Utils
- Defined in:
- lib/ruby-next/language/runtime.rb
Overview
Module responsible for runtime transformations
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Utils
refine_modules?, resolve_feature_path, source_with_lines
Class Method Details
.feature_path(path) ⇒ Object
37
38
39
40
41
42
43
|
# File 'lib/ruby-next/language/runtime.rb', line 37
def feature_path(path)
path = resolve_feature_path(path)
return if path.nil?
return if File.extname(path) != ".rb"
return unless Language.transformable?(path)
path
end
|
.load(path, wrap: false) ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/ruby-next/language/runtime.rb', line 21
def load(path, wrap: false)
raise "RubyNext cannot handle `load(smth, wrap: true)`" if wrap
contents = File.read(path)
new_contents = transform contents
RubyNext.debug_source new_contents, path
evaluate(new_contents, path)
true
end
|
33
34
35
|
# File 'lib/ruby-next/language/runtime.rb', line 33
def transform(contents, **options)
Language.transform(contents, rewriters: Language.current_rewriters, **options)
end
|
Instance Method Details
#evaluate(code, filepath) ⇒ Object
46
47
48
|
# File 'lib/ruby-next/language/runtime.rb', line 46
def evaluate(code, filepath)
new_toplevel.eval(code, filepath)
end
|
#new_toplevel ⇒ Object
50
51
52
53
54
|
# File 'lib/ruby-next/language/runtime.rb', line 50
def new_toplevel
eval "proc{binding}.call", TOPLEVEL_BINDING, __FILE__, __LINE__
end
|