Permalink
Browse files

Merge pull request #96 from duncanbeevers/asset_pipeline

Expose Juggernaut gem to Rails asset pipeline
  • Loading branch information...
2 parents 7a10171 + 8111c33 commit 54747ee7a0a9fce7d39d9f41218bc96ea1795529 @maccman maccman committed Sep 22, 2011
View
@@ -1,11 +1,14 @@
require "tempfile"
require "yui/compressor"
require "fileutils"
+require "sprockets"
APP_PATH = File.expand_path("./public/application.js")
task :build do
- `sprocketize -I public/ public/juggernaut.js > #{APP_PATH}`
+ env = Sprockets::Environment.new
+ env.append_path 'client/vendor/assets/javascripts'
+ File.open(APP_PATH, 'w') { |f| f << env['juggernaut.js'].to_s }
end
task :compress do
@@ -23,4 +26,4 @@ task :compress do
FileUtils.mv(tempfile.path, APP_PATH)
end
-task :default => [:build, :compress]
+task :default => [:build, :compress]
@@ -22,7 +22,11 @@ Gem::Specification.new do |s|
"examples/juggernaut_observer.rb",
"examples/roster.rb",
"juggernaut.gemspec",
- "lib/juggernaut.rb"
+ "lib/juggernaut.rb",
+ "lib/juggernaut/rails/engine.rb",
+ "vendor/assets/javascripts/juggernaut.js",
+ "vendor/assets/javascripts/json.js",
+ "vendor/assets/javascripts/socket_io.js"
]
s.homepage = %q{http://github.com/maccman/juggernaut}
s.rdoc_options = ["--charset=UTF-8"]
View
@@ -1,6 +1,9 @@
require "redis"
require "json"
+# Attempt to provide Engine to Rails
+require "juggernaut/rails/engine"
+
module Juggernaut
EVENTS = [
"juggernaut:subscribe",
@@ -0,0 +1,7 @@
+module Juggernaut
+ begin
+ class Engine < ::Rails::Engine
+ end
+ rescue NameError
+ end
+end
File renamed without changes.
@@ -1,7 +1,7 @@
// For sprockets:
//
-//= require <json>
-//= require <socket_io>
+//= require json
+//= require socket_io
var Juggernaut = function(options){
this.options = options || {};
@@ -136,4 +136,4 @@ Juggernaut.Message.prototype.toJSON = function(){
object[key] = this[key];
}
return(JSON.stringify(object));
-};
+};
File renamed without changes.

0 comments on commit 54747ee

Please sign in to comment.