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_active_job_initializerObject


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

def create_active_job_initializer
  template("active_job_initializer.rb",
           File.join("config/initializers/active_job.rb"))
end

#create_application_controllerObject


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

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

#create_application_helperObject


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

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

#create_cache_sweeper_initializerObject


74
75
76
77
78
# File 'lib/rails/generators/pages_core/install/install_generator.rb', line 74

def create_cache_sweeper_initializer
  read_configuration!
  template("cache_sweeper_initializer.rb",
           File.join("config/initializers/cache_sweeper.rb"))
end

#create_default_templateObject


53
54
55
56
# File 'lib/rails/generators/pages_core/install/install_generator.rb', line 53

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

#create_delayed_job_initializerObject


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

def create_delayed_job_initializer
  template("delayed_job_initializer.rb",
           File.join("config/initializers/delayed_job.rb"))
end

#create_delayed_job_scriptObject


58
59
60
61
# File 'lib/rails/generators/pages_core/install/install_generator.rb', line 58

def create_delayed_job_script
  template "delayed_job", File.join("script/delayed_job")
  File.chmod(0o755, Rails.root.join("script", "delayed_job"))
end

#create_frontend_controllerObject


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

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

#create_frontend_helperObject


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

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

#create_gitignoreObject


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

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

#create_initializer_fileObject


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

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

#create_pages_controllerObject


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

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

#create_template_initializerObject


80
81
82
83
84
# File 'lib/rails/generators/pages_core/install/install_generator.rb', line 80

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

#default_app_nameObject


7
8
9
# File 'lib/rails/generators/pages_core/install/install_generator.rb', line 7

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

#read_configuration!Object


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

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?",
    "[email protected]#{@domain_name}"
  )
  nil
end