Class: PagesCore::Generators::InstallGenerator

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

Instance Method Summary collapse

Instance Method Details

#create_application_controllerObject



25
26
27
28
# File 'lib/rails/generators/pages_core/install/install_generator.rb', line 25

def create_application_controller
  template("application_controller.rb",
           File.join("app/controllers/application_controller.rb"))
end

#create_application_helperObject



30
31
32
33
# File 'lib/rails/generators/pages_core/install/install_generator.rb', line 30

def create_application_helper
  template("application_helper.rb",
           File.join("app/helpers/application_helper.rb"))
end

#create_default_templateObject



50
51
52
53
# File 'lib/rails/generators/pages_core/install/install_generator.rb', line 50

def create_default_template
  copy_file("default_page_template.html.erb",
            File.join("app/views/pages/templates/index.html.erb"))
end

#create_frontend_controllerObject



35
36
37
38
# File 'lib/rails/generators/pages_core/install/install_generator.rb', line 35

def create_frontend_controller
  template("frontend_controller.rb",
           File.join("app/controllers/frontend_controller.rb"))
end

#create_frontend_helperObject



40
41
42
43
# File 'lib/rails/generators/pages_core/install/install_generator.rb', line 40

def create_frontend_helper
  template("frontend_helper.rb",
           File.join("app/helpers/frontend_helper.rb"))
end

#create_gitignoreObject



67
68
69
# File 'lib/rails/generators/pages_core/install/install_generator.rb', line 67

def create_gitignore
  template "gitignore.erb", File.join(".gitignore")
end

#create_initializer_fileObject



55
56
57
58
59
# File 'lib/rails/generators/pages_core/install/install_generator.rb', line 55

def create_initializer_file
  read_configuration!
  template("pages_initializer.rb",
           File.join("config/initializers/pages.rb"))
end

#create_pages_controllerObject



45
46
47
48
# File 'lib/rails/generators/pages_core/install/install_generator.rb', line 45

def create_pages_controller
  template("pages_controller.rb",
           File.join("app/controllers/pages_controller.rb"))
end

#create_template_initializerObject



61
62
63
64
65
# File 'lib/rails/generators/pages_core/install/install_generator.rb', line 61

def create_template_initializer
  read_configuration!
  template("page_templates_initializer.rb",
           File.join("config/initializers/page_templates.rb"))
end

#default_app_nameObject



9
10
11
# File 'lib/rails/generators/pages_core/install/install_generator.rb', line 9

def default_app_name
  Rails.root.to_s.split("/").last
end

#read_configuration!Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/rails/generators/pages_core/install/install_generator.rb', line 13

def read_configuration!
  @app_name ||= ask_with_fallback("App name?", default_app_name)
  @site_name ||= ask_with_fallback("Site name?", @app_name.humanize)
  @domain_name ||= ask_with_fallback("Domain name?", "#{@app_name}.no")

  @default_sender ||= ask_with_fallback(
    "Default sender?",
    "no-reply@#{@domain_name}"
  )
  nil
end