Skip to content
Browse files

Replace 'johnson' with ExecJS for Ruby 1.9.2 compatibility and runtim…

…e flexibility
  • Loading branch information...
1 parent 3a54946 commit ce8b7f4737d6be36a8c621bb8fc2ff7489b9c1eb @ArthurN committed
Showing with 12 additions and 13 deletions.
  1. +3 −2 Gemfile
  2. +4 −2 Gemfile.lock
  3. +5 −9 lib/isotope/isotope.rb
View
5 Gemfile
@@ -1,5 +1,6 @@
-source :rubygemss
+source :rubygems
source :gemcutter
source "http://gems.github.com"
-gem "johnson"
+gem 'json'
+gem 'execjs'
View
6 Gemfile.lock
@@ -2,10 +2,12 @@ GEM
remote: http://rubygems.org/
remote: http://gems.github.com/
specs:
- johnson (1.2.0)
+ execjs (1.2.0)
+ multi_json (~> 1.0)
+ multi_json (1.0.3)
PLATFORMS
ruby
DEPENDENCIES
- johnson
+ execjs
View
14 lib/isotope/isotope.rb
@@ -1,5 +1,5 @@
require 'rubygems'
-require 'johnson'
+require 'execjs'
require 'json'
require 'yaml'
require 'erb'
@@ -38,15 +38,11 @@ def self.render_partial(view_file, options = {})
isotope_file_path = File.join(File.dirname(__FILE__), "isotope.js")
view_file_content = template_file_content(view_file)
-
- script = "
- #{included_scripts_source}
- Johnson.runtime.load('#{isotope_file_path}');
- Isotope(#{view_file_content.to_json}, #{options[:locals].to_json});
- "
- output = Johnson.evaluate(script)
-
+ context = ExecJS.compile(included_scripts_source + " " + IO.read(isotope_file_path))
+ script = "Isotope(#{view_file_content.to_json}, #{options[:locals].to_json})"
+ output = context.eval(script)
+
output
end

0 comments on commit ce8b7f4

Please sign in to comment.
Something went wrong with that request. Please try again.