Class: HappySeed::Generators::AngularInstallGenerator

Inherits:
HappySeedGenerator
  • Object
show all
Defined in:
lib/generators/happy_seed/angular_install/angular_install_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.fingerprintObject



8
9
10
# File 'lib/generators/happy_seed/angular_install/angular_install_generator.rb', line 8

def self.fingerprint
  File.exists? 'app/controllers/angular_controller.rb'
end

Instance Method Details

#install_angularObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/generators/happy_seed/angular_install/angular_install_generator.rb', line 12

def install_angular
  return if already_installed

  gem 'angularjs-rails'

  Bundler.with_clean_env do
    run "bundle install --without production"
  end

  directory "app"
  directory "docs"
  append_to_file 'app/assets/javascripts/application.js', <<-'JS'

//= require angular
//= require angular-animate
//= require angular-resource
//= require angular-route
//= require angular_app
//= require_tree ./controllers
JS
  gsub_file "config/routes.rb", /\s*root.*\n/, "\n"
  route "root 'angular#index'"
  generate 'happy_seed:angular_view landing'
end