Sha256: bc640334d2899e76a4d4923383b0a2267aa8bf06e23671d227ca3921fc9416e3

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

require 'generators/thorax/thorax_helpers'

module Thorax
  module Generators
    class InstallGenerator < Rails::Generators::Base
      include Thorax::Generators::ResourceHelpers

      source_root File.expand_path("../templates", __FILE__)

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

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

      def inject_thorax
        inject_into_file "app/assets/javascripts/application.js", :before => "//= require_tree" do
          "//= require underscore\n//= require backbone\n//= require handlebars\n//= require thorax\n"
        end
      end

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

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
thorax-rails-0.0.0 lib/generators/thorax/install/install_generator.rb