Class: Clementine::ClojureScriptEngine
- Inherits:
-
ClojureScriptEngineBase
- Object
- ClojureScriptEngineBase
- Clementine::ClojureScriptEngine
- Defined in:
- lib/clementine/clojurescript_engine/mri.rb,
lib/clementine/clojurescript_engine/jruby.rb
Instance Method Summary collapse
- #command ⇒ Object
- #compile ⇒ Object
-
#convert_options(options) ⇒ Object
private.
-
#initialize(file, options) ⇒ ClojureScriptEngine
constructor
A new instance of ClojureScriptEngine.
- #nailgun_prefix ⇒ Object
- #setup_classpath_for_ng ⇒ Object
Methods inherited from ClojureScriptEngineBase
Constructor Details
#initialize(file, options) ⇒ ClojureScriptEngine
Returns a new instance of ClojureScriptEngine.
11 12 13 14 15 |
# File 'lib/clementine/clojurescript_engine/mri.rb', line 11 def initialize(file, ) @file = file @options = @classpath = CLASSPATH end |
Instance Method Details
#command ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/clementine/clojurescript_engine/mri.rb', line 45 def command if defined? Nailgun setup_classpath_for_ng [nailgun_prefix, 'clojure.main', "#{CLOJURESCRIPT_HOME}/bin/cljsc.clj"].flatten.join(' ') else ["java", '-cp', "\"#{@classpath.join ":"}\"", 'clojure.main', "#{CLOJURESCRIPT_HOME}/bin/cljsc.clj"].flatten.join(' ') end end |
#compile ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/clementine/clojurescript_engine/mri.rb', line 17 def compile @options = default_opts.merge(Clementine.) if Clementine. begin cmd = %Q{#{command} #{@file} '#{(@options)}' 2>&1} result = `#{cmd}` rescue Exception raise Error, "compression failed: #{result || $!}" end unless $?.exitstatus.zero? raise Error, result end result end |
#convert_options(options) ⇒ Object
private
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/clementine/clojurescript_engine/mri.rb', line 55 def () opts = "" .each do |k, v| cl_key = ":" + Clementine.ruby2clj(k.to_s) case when (v.kind_of? Symbol) cl_value = ":" + Clementine.ruby2clj(v.to_s) when v.is_a?(TrueClass) || v.is_a?(FalseClass) cl_value = v.to_s else cl_value = "\"" + v + "\"" end opts += cl_key + " " + cl_value + " " end "{" + opts.chop! + "}" end |
#nailgun_prefix ⇒ Object
31 32 33 34 35 |
# File 'lib/clementine/clojurescript_engine/mri.rb', line 31 def nailgun_prefix server_address = Nailgun::NailgunConfig.[:server_address] port_no = Nailgun::NailgunConfig.[:port_no] "#{Nailgun::NgCommand::NGPATH} --nailgun-port #{port_no} --nailgun-server #{server_address}" end |
#setup_classpath_for_ng ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/clementine/clojurescript_engine/mri.rb', line 37 def setup_classpath_for_ng current_cp = `#{nailgun_prefix} ng-cp` unless current_cp.include? "clojure.jar" puts "Initializing nailgun classpath, required clementine dependencies missing" `#{nailgun_prefix} ng-cp #{@classpath.join " "}` end end |