Skip to content
This repository has been archived by the owner on Jul 6, 2020. It is now read-only.

Commit

Permalink
add rails 3.0 support, just copy the files over to the junk drawer
Browse files Browse the repository at this point in the history
  • Loading branch information
johnbintz committed May 23, 2011
1 parent 8245256 commit 20e6f1d
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 4 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ With pure javascript, the lines would look like `app/assets/javascripts/applicat
//= require underscore //= require underscore
//= require backbone //= require backbone


### Rails 3.0 generator

In Rails 3.0, you can also vendor Backbone into your public/javascripts directory with `rails g backbone:install`

## Versioning ## Versioning


The gem will follow backbone versioning. The gem will follow backbone versioning.
2 changes: 1 addition & 1 deletion backbone-rails.gemspec
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Gem::Specification.new do |s|


s.required_rubygems_version = ">= 1.3.6" s.required_rubygems_version = ">= 1.3.6"


s.add_dependency "railties", "~> 3.1.0.beta1" s.add_dependency "rails", ">= 3.0.0"


s.files = Dir.glob("{lib,vendor}/**/*") + %w(MIT-LICENSE README.md) s.files = Dir.glob("{lib,vendor}/**/*") + %w(MIT-LICENSE README.md)
s.require_path = 'lib' s.require_path = 'lib'
Expand Down
8 changes: 5 additions & 3 deletions lib/backbone-rails.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,9 +1,11 @@
require 'rails'


module Backbone module Backbone
module Rails module Rails

if ::Rails.version < "3.1"
class Engine < ::Rails::Engine require 'backbone-rails/railtie'
else
require 'backbone-rails/engine'
end end

end end
end end
9 changes: 9 additions & 0 deletions lib/backbone-rails/engine.rb
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,9 @@
require 'rails'

module Backbone
module Rails
class Engine < ::Rails::Engine
end
end
end

19 changes: 19 additions & 0 deletions lib/backbone-rails/generators.rb
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,19 @@
require 'rails/generators'

module Backbone
class Install < ::Rails::Generators::Base
JAVASCRIPTS = File.expand_path('../../../vendor/assets/javascripts', __FILE__)

def self.source_root
@source_root ||= JAVASCRIPTS
end

def copy_backbone
Dir[File.join(JAVASCRIPTS, '*.js')].each do |file|
file = File.split(file).last
copy_file file, "public/javascripts/#{file}"
end
end
end
end

12 changes: 12 additions & 0 deletions lib/backbone-rails/railtie.rb
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,12 @@
require 'rails'

module Backbone
module Rails
class Railtie < ::Rails::Railtie
generators do
require 'backbone-rails/generators'
end
end
end
end

0 comments on commit 20e6f1d

Please sign in to comment.