Class: Locomotive::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/locomotive/install/install_generator.rb

Instance Method Summary collapse

Instance Method Details

#copy_initializersObject



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/generators/locomotive/install/install_generator.rb', line 8

def copy_initializers
  @source_paths = nil # reset it for the find_in_source_paths method

  Locomotive::InstallGenerator.source_root(File.expand_path('../templates', __FILE__))

  template 'locomotive.rb', 'config/initializers/locomotive.rb'

  template 'devise.rb', 'config/initializers/devise.rb'

  template 'dragonfly.rb', 'config/initializers/dragonfly.rb'

  template 'mongoid.yml', 'config/mongoid.yml'
end

#enable_herokuObject



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/generators/locomotive/install/install_generator.rb', line 43

def enable_heroku
  if options.heroku?
    inject_into_file 'Gemfile', after: "source 'https://rubygems.org'\n" do "\nif ENV['HEROKU_APP_NAME']\nruby '2.2.2'\nend\n"
    end

    template 'heroku.rb', 'config/initializers/heroku.rb'
    template 'mongoid_heroku.yml', 'config/mongoid.yml', force: true

    inject_into_file 'config/environments/production.rb', after: "  # config.action_mailer.raise_delivery_errors = false\n" do "config.action_mailer.raise_delivery_errors  = true\nconfig.action_mailer.delivery_method        = :smtp\nconfig.action_mailer.smtp_settings          = {\n:address        => 'smtp.sendgrid.net',\n:port           => 25,\n:authentication => :plain,\n:user_name      => ENV['SENDGRID_USERNAME'],\n:password       => ENV['SENDGRID_PASSWORD'],\n:domain         => ENV['SENDGRID_DOMAIN']\n}\n"
    end

    gem 'platform-api', '~> 0.3.0'
  end
end

#insert_engine_routesObject



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/generators/locomotive/install/install_generator.rb', line 31

def insert_engine_routes
  route %(
  # Locomotive Back-office
  mount Locomotive::Engine => '/locomotive', as: 'locomotive' # you can change the value of the path, by default set to "/locomotive"

  # Locomotive API
  mount Locomotive::API.to_app => '/locomotive(/:site_handle)/api'

  # Render site
  mount Locomotive::Steam.to_app => '/', anchor: false)
end

#install_awsObject



22
23
24
25
26
27
28
29
# File 'lib/generators/locomotive/install/install_generator.rb', line 22

def install_aws
  if options.heroku? || yes?('Do you want to store your assets on Amazon S3?')
    template 'carrierwave_aws.rb', 'config/initializers/carrierwave.rb'
    gem 'carrierwave-aws'
  else
    template 'carrierwave.rb', 'config/initializers/carrierwave.rb'
  end
end

#remove_index_htmlObject



74
75
76
# File 'lib/generators/locomotive/install/install_generator.rb', line 74

def remove_index_html
  remove_file 'public/index.html'
end

#show_readmeObject



86
87
88
# File 'lib/generators/locomotive/install/install_generator.rb', line 86

def show_readme
  readme 'README'
end

#use_puma_as_app_serverObject



78
79
80
81
82
83
84
# File 'lib/generators/locomotive/install/install_generator.rb', line 78

def use_puma_as_app_server
  inject_into_file 'Gemfile', after: "# gem 'unicorn'\n" do "# Use Puma as the app server\ngem 'puma'\n"
  end
end