Class: Sibilant::Compiler
- Inherits:
-
Object
- Object
- Sibilant::Compiler
- Defined in:
- lib/sibilant.rb
Instance Method Summary collapse
- #package_json ⇒ Object
- #package_json_file ⇒ Object
- #sibilant_cli ⇒ Object
- #sibilant_js_root ⇒ Object
- #translate(sibilant_code) ⇒ Object
- #version ⇒ Object
Instance Method Details
#package_json ⇒ Object
23 24 25 |
# File 'lib/sibilant.rb', line 23 def package_json JSON.parse package_json_file.read end |
#package_json_file ⇒ Object
19 20 21 |
# File 'lib/sibilant.rb', line 19 def package_json_file File.open File.join(sibilant_js_root, 'package.json') end |
#sibilant_cli ⇒ Object
31 32 33 |
# File 'lib/sibilant.rb', line 31 def sibilant_cli File.join sibilant_js_root, 'bin', 'sibilant' end |
#sibilant_js_root ⇒ Object
15 16 17 |
# File 'lib/sibilant.rb', line 15 def sibilant_js_root File.join File.dirname(__FILE__), '..', 'js', 'sibilant' end |
#translate(sibilant_code) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/sibilant.rb', line 35 def translate(sibilant_code) Open3.popen3 sibilant_cli, '-i' do |i,o,e,t| i.puts sibilant_code i.close_write if t.value.success? o.read.strip else raise Sibilant::CompilationError.new(e.read.strip) end end end |
#version ⇒ Object
27 28 29 |
# File 'lib/sibilant.rb', line 27 def version package_json[:version] end |