Sha256: 40dfaccdd51a2d7e3570ca56d95db83758d18ddffd58fc12a49b4faa87229174

Contents?: true

Size: 1.23 KB

Versions: 2

Compression:

Stored size: 1.23 KB

Contents

require 'generators/backbone/helpers'

module Backbone
  module Generators
    class InstallGenerator < Rails::Generators::Base
      include Backbone::Generators::Helpers
 
      source_root File.expand_path("../templates", __FILE__)

      desc "This generator installs backbone.js with a default folder layout in app/assets/javascripts/backbone"

      class_option :skip_git, :type => :boolean, :aliases => "-G", :default => false,
                              :desc => "Skip Git ignores and keeps"

      def inject_backbone
        inject_into_file "app/assets/javascripts/application.js", :before => "//= require_tree" do
"//= require underscore
//= require backbone
//= require railsy_backbone.sync
//= require railsy_backbone.datalink
//= require backbone/#{application_name.underscore}\n"
        end
      end

      def create_dir_layout
        %W{routers models views templates}.each do |dir|
          empty_directory "app/assets/javascripts/backbone/#{dir}" 
          create_file "app/assets/javascripts/backbone/#{dir}/.gitkeep" unless options[:skip_git]
        end
      end

      def create_app_file
        template "app.coffee", "app/assets/javascripts/backbone/#{application_name.underscore}.js.coffee"
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
railsy_backbone-0.0.3 lib/generators/backbone/install/install_generator.rb
railsy_backbone-0.0.2 lib/generators/backbone/install/install_generator.rb