From 4db815e0825443bf342ae9d23859114742d8877c Mon Sep 17 00:00:00 2001 From: John Bintz Date: Wed, 18 May 2011 09:32:31 -0400 Subject: [PATCH] rails 3.1 asset support --- README.md | 32 ++++++++++++++++++++++++++++++-- backbone-rails.gemspec | 11 +++++------ lib/backbone-rails.rb | 10 ++++++---- lib/backbone-rails/engine.rb | 7 +++++++ lib/backbone-rails/railtie.rb | 10 ++++++++++ lib/backbone-rails/version.rb | 3 --- 6 files changed, 58 insertions(+), 15 deletions(-) create mode 100644 lib/backbone-rails/engine.rb create mode 100644 lib/backbone-rails/railtie.rb delete mode 100644 lib/backbone-rails/version.rb diff --git a/README.md b/README.md index 515586c..0c72b8c 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,31 @@ -Easily get Backbone.js and its dependencies into your app. Maybe it can even work with Rails 3.1 and that fancy -asset pipeline thing soon? +Easily get Backbone.js and its dependencies into your app. + +## Rails 3.1 + +*BAM!* + + //= require json2 + //= require underscore + //= require backbone + +Minified? + + //= require underscore-min + //= require backbone-min + +## Rails 3.0 + +Slightly quieter *BAM!* + + rails g backbone:install + +You'll get these: + + public/javascripts/json2.js + public/javascripts/underscore.js + public/javascripts/underscore-min.js + public/javascripts/backbone.js + public/javascripts/backbone-min.js + +The version number of the gem is the same as the version number of Backbone. diff --git a/backbone-rails.gemspec b/backbone-rails.gemspec index c14c114..026a96d 100644 --- a/backbone-rails.gemspec +++ b/backbone-rails.gemspec @@ -1,16 +1,15 @@ # -*- encoding: utf-8 -*- $:.push File.expand_path("../lib", __FILE__) -require "backbone-rails/version" Gem::Specification.new do |s| s.name = "backbone-rails" - s.version = BackboneRails::VERSION + s.version = File.readlines('vendor/assets/javascripts/backbone.js').first[%r{[0-9\.]{5,}}] s.platform = Gem::Platform::RUBY - s.authors = ["TODO: Write your name"] - s.email = ["TODO: Write your email address"] + s.authors = ["John Bintz"] + s.email = ["john@coswellproductions.com"] s.homepage = "" - s.summary = %q{TODO: Write a gem summary} - s.description = %q{TODO: Write a gem description} + s.summary = %q{Easily get Backbone.js and its dependencies into your Rails app.} + s.description = %q{Easily get Backbone.js and its dependencies into your Rails app.} s.rubyforge_project = "backbone-rails" diff --git a/lib/backbone-rails.rb b/lib/backbone-rails.rb index 4f31971..8574bbd 100644 --- a/lib/backbone-rails.rb +++ b/lib/backbone-rails.rb @@ -1,9 +1,11 @@ require 'rails' -module BackboneRails - class Railtie < ::Rails::Railtie - generators do - require 'backbone-rails/generators' +module Backbone + module Rails + if ::Rails.version < "3.1" + require 'backbone-rails/railtie' + else + require 'backbone-rails/engine' end end end diff --git a/lib/backbone-rails/engine.rb b/lib/backbone-rails/engine.rb new file mode 100644 index 0000000..f0f7828 --- /dev/null +++ b/lib/backbone-rails/engine.rb @@ -0,0 +1,7 @@ +require 'rails' + +module Backbone + class Engine < ::Rails::Engine + end +end + diff --git a/lib/backbone-rails/railtie.rb b/lib/backbone-rails/railtie.rb new file mode 100644 index 0000000..ec6df2d --- /dev/null +++ b/lib/backbone-rails/railtie.rb @@ -0,0 +1,10 @@ +require 'rails' + +module Backbone + class Railtie < ::Rails::Railtie + generators do + require 'backbone-rails/generators' + end + end +end + diff --git a/lib/backbone-rails/version.rb b/lib/backbone-rails/version.rb deleted file mode 100644 index 3c3b7dd..0000000 --- a/lib/backbone-rails/version.rb +++ /dev/null @@ -1,3 +0,0 @@ -module BackboneRails - VERSION = "0.0.1" -end