Class: Ahoy::DeploymentGenerator
- Inherits:
-
Generator::Base
- Object
- Rails::Generators::Base
- Generator::Base
- Ahoy::DeploymentGenerator
- Defined in:
- lib/generators/ahoy/deployment_generator.rb
Instance Method Summary collapse
- #add_gems ⇒ Object
- #change_permissions ⇒ Object
- #copy_directory ⇒ Object
- #copy_files ⇒ Object
- #copy_templates ⇒ Object
- #create_symlinks ⇒ Object
- #modify_files ⇒ Object
- #prompt_user ⇒ Object
Methods inherited from Generator::Base
Instance Method Details
#add_gems ⇒ Object
98 99 100 101 102 103 |
# File 'lib/generators/ahoy/deployment_generator.rb', line 98 def add_gems gem_group :production do gem 'puma' gem 'rb-readline' end end |
#change_permissions ⇒ Object
115 116 117 118 |
# File 'lib/generators/ahoy/deployment_generator.rb', line 115 def FileUtils.chmod 0751, 'config/ansible/production.sh' FileUtils.chmod 0751, 'bin/puma.sh' end |
#copy_directory ⇒ Object
79 80 81 |
# File 'lib/generators/ahoy/deployment_generator.rb', line 79 def copy_directory directory 'ansible', 'config/ansible' end |
#copy_files ⇒ Object
83 84 85 86 |
# File 'lib/generators/ahoy/deployment_generator.rb', line 83 def copy_files copy_file 'env_templates/_development_env.yml', '.env/development_env.yml' copy_file 'env_templates/_test_env.yml', '.env/test_env.yml' end |
#copy_templates ⇒ Object
88 89 90 91 92 93 94 95 96 |
# File 'lib/generators/ahoy/deployment_generator.rb', line 88 def copy_templates template 'ansible_templates/_production', 'config/ansible/production' template 'ansible_templates/playbooks/_production.yml', 'config/ansible/playbooks/production.yml' template 'ansible_templates/playbooks/group_vars/_all.yml', 'config/ansible/playbooks/group_vars/all.yml' template '_puma.sh', 'bin/puma.sh' template '_puma.rb', 'config/puma.rb' template '_deploy.rb', 'config/deploy.rb' template 'env_templates/_production_env.yml', '.env/production_env.yml' end |
#create_symlinks ⇒ Object
120 121 122 |
# File 'lib/generators/ahoy/deployment_generator.rb', line 120 def create_symlinks FileUtils.ln_s '../../../../.env/production_env.yml', 'config/ansible/playbooks/group_vars/production.yml' end |
#modify_files ⇒ Object
105 106 107 108 109 110 111 112 113 |
# File 'lib/generators/ahoy/deployment_generator.rb', line 105 def modify_files append_file '.gitignore', '.env/' prepend_file 'config/environment.rb', "require 'ahoy'\n" inject_into_file 'config/environment.rb', after: "require File.expand_path('../application', __FILE__)\n\n" do <<-'RUBY' Ahoy.env RUBY end end |
#prompt_user ⇒ Object
10 11 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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/generators/ahoy/deployment_generator.rb', line 10 def prompt_user question :string do { app_name: 'What is the name of your application? [enter for default]', default: Rails.application.class.parent_name.underscore } end question :string do { server_domain: 'Which domain will you be deploying to? [enter for default]', required: true } end question :string do { server_user: 'Enter a name for your server user', required: true } end question :string do { server_ssh_port: 'What SSH port would you like to use on your server? [enter for default]', default: '22' } end question :string do { ruby_version: 'Which version of Ruby would you like to install? [enter for default]', default: '2.1.5' } end question :string do { postgresql_version: 'Which version of PostgreSQL would you like to install? [enter for default]', default: '9.3' } end question :string do { database_name: 'Enter a name for your production database', default: Rails.application.class.parent_name.underscore + '_production' } end question :string do { database_user: 'Enter a name for your production database user', required: true } end question :string do { database_password: 'Enter a password for your production database', required: true } end question :string do { app_repo: 'What is the github repository for this application?', required: true } end question :string do { app_repo_branch: 'Which repository branch will be used for deployment? [enter for default]', default: 'master' } end end |