Class: HappySeed::Generators::BootstrapGenerator

Inherits:
HappySeedGenerator
  • Object
show all
Defined in:
lib/generators/happy_seed/bootstrap/bootstrap_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.fingerprintObject



8
9
10
# File 'lib/generators/happy_seed/bootstrap/bootstrap_generator.rb', line 8

def self.fingerprint
  gem_available? 'bootstrap-sass'
end

Instance Method Details

#install_bootstrapObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/generators/happy_seed/bootstrap/bootstrap_generator.rb', line 12

def install_bootstrap
  return if already_installed

  gem 'bootstrap-sass'
  gem 'modernizr-rails'
  gem 'meta-tags', :require => 'meta_tags'
  gem 'responders', '~> 2.0'
  gem 'bh'
  gem 'simple_form'

  Bundler.with_clean_env do
    run "bundle install --without production"
    run "rails generate simple_form:install --bootstrap"
  end

  remove_file 'app/views/layouts/application.html.erb'
  remove_file 'app/assets/javascripts/application.js'
  remove_file 'app/helpers/application_helper.rb'
  remove_file 'app/assets/stylesheets/application.css'
  directory 'app'
  directory 'lib'
  directory 'docs'

  inject_into_file 'app/views/setup/index.html.haml', after: "%body\n" do <<-'HAML'
    = render partial: "application/header"
    = render partial: "application/flashes"
HAML
  end

  inject_into_file 'config/application.rb', before: "  end\nend\n" do <<-'RUBY'
    config.action_view.field_error_proc = Proc.new { |html_tag, instance| html_tag }
    config.generators do |g|
g.stylesheets = false
g.scaffold_controller "scaffold_controller"
g.test_framework :rspec, fixture: true, fixture_replacement: :factory_girl, helper_specs: false, view_specs: false, routing_specs: false, controller_specs: false
    end
  
RUBY
  end
  if File.exists?( File.join( destination_root, ".env" ) )
    add_env "GOOGLE_ANALYTICS_SITE_ID"
  end
end