Class: Rockstart::FrontendHelpersGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/rockstart/frontend_helpers/frontend_helpers_generator.rb

Instance Method Summary collapse

Instance Method Details

#add_application_urls_concernObject



29
30
31
32
33
34
35
36
37
38
# File 'lib/generators/rockstart/frontend_helpers/frontend_helpers_generator.rb', line 29

def add_application_urls_concern
  if force_url_helpers? || !File.exist?(Rails.root.join(application_urls_concern_path))
    copy_file "application_urls.rb", application_urls_concern_path
  else
    say "Skipping #{application_urls_concern_path}"
  end
  inject_into_file "app/controllers/application_controller.rb",
                   "  include ApplicationUrls\n",
                   before: /^end$/
end

#add_application_urls_helperObject



40
41
42
43
44
45
46
# File 'lib/generators/rockstart/frontend_helpers/frontend_helpers_generator.rb', line 40

def add_application_urls_helper
  if force_url_helpers? || !File.exist?(Rails.root.join(application_urls_helper_path))
    copy_file "application_urls_helper.rb", application_urls_helper_path
  else
    say "Skipping #{application_urls_helper_path}"
  end
end

#install_simple_formObject



10
11
12
13
14
15
16
17
18
# File 'lib/generators/rockstart/frontend_helpers/frontend_helpers_generator.rb', line 10

def install_simple_form
  gem "simple_form"

  Bundler.with_clean_env do
    run "bundle install --quiet"

    generate "simple_form:install"
  end
end

#install_titlesObject



20
21
22
23
24
25
26
27
# File 'lib/generators/rockstart/frontend_helpers/frontend_helpers_generator.rb', line 20

def install_titles
  gem "title", github: "calebthompson/title"

  template "titles.en.yml.tt", "config/locales/titles.en.yml"

  gsub_file "app/views/layouts/application.html.erb", %r{\<title(.+)\</title},
            "<title><%= title %></title"
end