rails 3.1 asset support

This commit is contained in:
John Bintz 2011-05-18 09:32:31 -04:00
parent 2a5e0e8eaf
commit 4db815e082
6 changed files with 58 additions and 15 deletions

View File

@ -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 Easily get Backbone.js and its dependencies into your app.
asset pipeline thing soon?
## 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.

View File

@ -1,16 +1,15 @@
# -*- encoding: utf-8 -*- # -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__) $:.push File.expand_path("../lib", __FILE__)
require "backbone-rails/version"
Gem::Specification.new do |s| Gem::Specification.new do |s|
s.name = "backbone-rails" 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.platform = Gem::Platform::RUBY
s.authors = ["TODO: Write your name"] s.authors = ["John Bintz"]
s.email = ["TODO: Write your email address"] s.email = ["john@coswellproductions.com"]
s.homepage = "" s.homepage = ""
s.summary = %q{TODO: Write a gem summary} s.summary = %q{Easily get Backbone.js and its dependencies into your Rails app.}
s.description = %q{TODO: Write a gem description} s.description = %q{Easily get Backbone.js and its dependencies into your Rails app.}
s.rubyforge_project = "backbone-rails" s.rubyforge_project = "backbone-rails"

View File

@ -1,9 +1,11 @@
require 'rails' require 'rails'
module BackboneRails module Backbone
class Railtie < ::Rails::Railtie module Rails
generators do if ::Rails.version < "3.1"
require 'backbone-rails/generators' require 'backbone-rails/railtie'
else
require 'backbone-rails/engine'
end end
end end
end end

View File

@ -0,0 +1,7 @@
require 'rails'
module Backbone
class Engine < ::Rails::Engine
end
end

View File

@ -0,0 +1,10 @@
require 'rails'
module Backbone
class Railtie < ::Rails::Railtie
generators do
require 'backbone-rails/generators'
end
end
end

View File

@ -1,3 +0,0 @@
module BackboneRails
VERSION = "0.0.1"
end