Permalink
Browse files

Adding ember:install generator

  • Loading branch information...
1 parent cb06eda commit 78608486a80547fdb209cd88061c423924c264c4 Francesco Rodriguez committed Feb 4, 2012
@@ -0,0 +1,34 @@
+module Ember
+ module Generators
+ class InstallGenerator < Rails::Generators::Base
+ source_root File.expand_path("../templates", __FILE__)
+
+ desc "Installs ember.js with a default folder layout in app/assets/javascripts/ember"
+
+ class_option :skip_git, :type => :boolean, :aliases => "-g",
+ :default => false, :desc => "Skip Git keeps"
+
+ def inject_ember
+ inject_into_file("app/assets/javascripts/application.js",
+ before: "//= require_tree") do
+ dependencies = [
+ "//= require ember",
+ "//= require ember/app"
+ ]
+ dependencies.join("\n").concat("\n")
+ end
+ end
+
+ def create_dir_layout
+ %W{models controllers views helpers templates}.each do |dir|
+ empty_directory "app/assets/javascripts/ember/#{dir}"
+ create_file "app/assets/javascripts/ember/#{dir}/.gitkeep" unless options[:skip_git]
+ end
+ end
+
+ def create_app_file
+ template "app.coffee", "app/assets/javascripts/ember/app.js.coffee"
+ end
+ end
+ end
+end
@@ -0,0 +1,8 @@
+#= require_self
+#= require_tree ./models
+#= require_tree ./controllers
+#= require_tree ./views
+#= require_tree ./helpers
+#= require_tree ./templates
+
+window.App = Ember.Application.create()

0 comments on commit 7860848

Please sign in to comment.