lib/clementine/clojurescript_engine.rb in clementine-0.0.1 vs lib/clementine/clojurescript_engine.rb in clementine-0.0.2
- old
+ new
@@ -1,49 +1,10 @@
-%w{RT Keyword PersistentHashMap}.each do |name|
- java_import "clojure.lang.#{name}"
-end
+CLOJURESCRIPT_HOME = File.join(File.dirname(__FILE__), "../../ext/clojure-clojurescript-bef56a7")
+CLOJURESCRIPT_LIB = File.join(File.dirname(__FILE__), "../")
-module Clementine
-
- class ClojureScriptEngine
- def initialize(file, options)
- @file = file
- @options = options
- end
-
- def compile
- @options = Clementine.options if @options.empty?
- cl_opts = PersistentHashMap.create(convert_options(@options))
- RT.loadResourceScript("cljs/closure.clj")
- builder = RT.var("cljs.closure", "build")
- builder.invoke(@file, cl_opts)
- end
-
- #private
- def convert_options(options)
- opts = {}
- options = options.empty? ? default_opts : options
- options.each do |k, v|
- cl_key = Keyword.intern(Clementine.ruby2clj(k.to_s))
- case
- when (v.kind_of? Symbol)
- cl_value = Keyword.intern(Clementine.ruby2clj(v.to_s))
- else
- cl_value = v
- end
- opts[cl_key] = cl_value
- end
- opts
- end
-
- 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
- end
-end
\ No newline at end of file
+if defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby"
+ require "clementine/clojurescript_engine/jruby"
+elsif defined?(RUBY_ENGINE) && RUBY_ENGINE == "ruby"
+ require "clementine/clojurescript_engine/mri"
+else
+ raise LoadError, "No ClojureScriptEngine implementation for this ruby."
+end