Class: Clementine::ClojureScriptEngine
- Inherits:
-
Object
- Object
- Clementine::ClojureScriptEngine
- Defined in:
- lib/clementine/clojurescript_engine.rb,
lib/clementine/clojurescript_engine_mri.rb
Instance Method Summary collapse
- #command ⇒ Object
- #compile ⇒ Object
- #default_opts ⇒ Object
-
#initialize(file, options) ⇒ ClojureScriptEngine
constructor
A new instance of ClojureScriptEngine.
- #nailgun_prefix ⇒ Object
- #setup_classpath_for_ng ⇒ Object
Constructor Details
#initialize(file, options) ⇒ ClojureScriptEngine
Returns a new instance of ClojureScriptEngine.
8 9 10 11 |
# File 'lib/clementine/clojurescript_engine.rb', line 8 def initialize(file, ) @file = file @options = end |
Instance Method Details
#command ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/clementine/clojurescript_engine_mri.rb', line 40 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
13 14 15 16 17 18 19 |
# File 'lib/clementine/clojurescript_engine.rb', line 13 def compile @options = Clementine. if @options.empty? cl_opts = PersistentHashMap.create((@options)) RT.loadResourceScript("cljs/closure.clj") builder = RT.var("cljs.closure", "build") builder.invoke(@file, cl_opts) end |
#default_opts ⇒ Object
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/clementine/clojurescript_engine.rb', line 38 def default_opts key = "output_dir" value = "" if defined?(Rails) value = File.join(Rails.root, "app", "assets", "javascripts", "clementine") else value = Dir.pwd end {key => value} end |
#nailgun_prefix ⇒ Object
26 27 28 29 30 |
# File 'lib/clementine/clojurescript_engine_mri.rb', line 26 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
32 33 34 35 36 37 38 |
# File 'lib/clementine/clojurescript_engine_mri.rb', line 32 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 |