Sha256: 0447a069f3d2fd60f5dee9461c1b2ea6d84bf0396440cfa61bea8cdedd7f8d54

Contents?: true

Size: 1.43 KB

Versions: 1

Compression:

Stored size: 1.43 KB

Contents

require 'generators/ember/generator_helpers'

module Ember
  module Generators
    class BootstrapGenerator < ::Rails::Generators::Base
      include Ember::Generators::GeneratorHelpers

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

      desc "Creates a default Ember.js folder layout in app/assets/javascripts/ember"

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

      def inject_ember
        application_file = "app/assets/javascripts/application.js"

        inject_into_file(application_file, :before => "//= require_tree") do
          dependencies = [
            "//= require ember",
            "//= require ember-data",
            "//= require_self",
            "//= require #{application_name.underscore}",
            "#{application_name.camelize} = Ember.Application.create();"
          ]
          dependencies.join("\n").concat("\n")
        end
      end

      def create_dir_layout
        %W{models controllers views states helpers templates}.each do |dir|
          empty_directory "#{ember_path}/#{dir}"
          create_file "#{ember_path}/#{dir}/.gitkeep" unless options[:skip_git]
        end
      end

      def create_app_file
        template "app.js", "#{ember_path}/#{application_name.underscore}.js"
      end

      def create_state_manager_file
        template "states.js", "#{ember_path}/states/app_states.js"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ember-rails-0.5.0 lib/generators/ember/bootstrap_generator.rb