Class: Hanber::Generators::BootstrapGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
GeneratorHelpers
Defined in:
lib/generators/hanber/bootstrap_generator.rb

Instance Method Summary collapse

Methods included from GeneratorHelpers

#application_name, #ember_path

Instance Method Details

#create_app_fileObject



39
40
41
# File 'lib/generators/hanber/bootstrap_generator.rb', line 39

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

#create_app_stubsObject



51
52
53
# File 'lib/generators/hanber/bootstrap_generator.rb', line 51

def create_app_stubs
  generate "ember:view", "application"
end

#create_dir_layoutObject



32
33
34
35
36
37
# File 'lib/generators/hanber/bootstrap_generator.rb', line 32

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

#create_router_fileObject



43
44
45
# File 'lib/generators/hanber/bootstrap_generator.rb', line 43

def create_router_file
  template "router.js", "#{ember_path}/router.js"
end

#create_store_fileObject



47
48
49
# File 'lib/generators/hanber/bootstrap_generator.rb', line 47

def create_store_file
  template "store.js", "#{ember_path}/store.js"
end

#inject_emberObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/generators/hanber/bootstrap_generator.rb', line 14

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

  inject_into_file(application_file, :before => "//= require_tree") do
    dependencies = [
      # this should eventually become handlebars-runtime when we remove
      # the runtime dependency on compilation
      "//= require handlebars",
      "//= require ember",
      "//= require ember-data",
      "//= require_self",
      "//= require #{application_name.underscore}",
      "#{application_name.camelize} = Ember.Application.create();"
    ]
    dependencies.join("\n").concat("\n")
  end
end