Class: Sibilant::Compiler

Inherits:
Object
  • Object
show all
Defined in:
lib/sibilant.rb

Instance Method Summary collapse

Instance Method Details

#package_jsonObject



20
21
22
# File 'lib/sibilant.rb', line 20

def package_json
  JSON.parse package_json_file.read
end

#package_json_fileObject



16
17
18
# File 'lib/sibilant.rb', line 16

def package_json_file
  File.open File.join(sibilant_js_root, 'package.json')
end

#sibilant_cliObject



28
29
30
# File 'lib/sibilant.rb', line 28

def sibilant_cli
  File.join sibilant_js_root, 'bin', 'sibilant'
end

#sibilant_js_rootObject



12
13
14
# File 'lib/sibilant.rb', line 12

def sibilant_js_root
  File.join File.dirname(__FILE__), '..', 'js', 'sibilant'
end

#translate(sibilant_code) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/sibilant.rb', line 32

def translate(sibilant_code)
  IO.popen("#{sibilant_cli} -i", 'r+') do |sibilant|
    sibilant.puts sibilant_code
    sibilant.close_write
    sibilant.read
  end.strip
end

#versionObject



24
25
26
# File 'lib/sibilant.rb', line 24

def version
  package_json[:version]
end