Class: Sibilant::Compiler

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

Instance Method Summary collapse

Instance Method Details

#package_jsonObject



14
15
16
# File 'lib/sibilant.rb', line 14

def package_json
  JSON.parse package_json_file.read
end

#package_json_fileObject



10
11
12
# File 'lib/sibilant.rb', line 10

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

#sibilant_cliObject



22
23
24
# File 'lib/sibilant.rb', line 22

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

#sibilant_js_rootObject



6
7
8
# File 'lib/sibilant.rb', line 6

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

#translate(sibilant_code) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/sibilant.rb', line 26

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



18
19
20
# File 'lib/sibilant.rb', line 18

def version
  package_json[:version]
end