Class: Venus::Generators::DeployGenerator

Inherits:
Base
  • Object
show all
Defined in:
lib/generators/venus/deploy/deploy_generator.rb

Instance Method Summary collapse

Methods inherited from Base

next_migration_number, source_root

Instance Method Details

#asksObject



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/generators/venus/deploy/deploy_generator.rb', line 10

def asks
  @use_rvm = ask?('use rvm?', true)
  @use_assets_pipline = ask?('use assets pipline?', true)
  @use_passenger = ask?('use passenger?', true)
  @use_puma = ask?('use puma server?', true) unless @use_passenger
  @git_uri = ask?('your git repository url?', '[email protected]:foo/myapp.git')
  @stage = ask_stage_infomation
  if ask?('has staging server?', true)
    @staging = ask_stage_infomation('staging')
  end
end

#capfileObject



33
34
35
36
37
# File 'lib/generators/venus/deploy/deploy_generator.rb', line 33

def capfile
  if @use_assets_pipline
    uncomment_lines('Capfile', 'deploy/assets')
  end
end

#copy_configsObject



39
40
41
42
43
44
45
46
47
48
# File 'lib/generators/venus/deploy/deploy_generator.rb', line 39

def copy_configs
  @app_name = app_name
  @whenever = has_gem?('whenever')
  template 'deploy.erb', 'config/deploy.rb'
  template 'stage.erb', 'config/deploy/production.rb'
  if @staging
    @stage = @staging
    template 'stage.erb', 'config/deploy/staging.rb'
  end
end

#deploy_setupObject



50
51
52
53
54
55
# File 'lib/generators/venus/deploy/deploy_generator.rb', line 50

def deploy_setup
  if ask?('setup servers deployment?', true)
    bundle_exec('cap production deploy:setup')
    bundle_exec('cap staging deploy:setup') if @staging
  end
end

#gemfileObject



22
23
24
25
26
27
28
29
30
31
# File 'lib/generators/venus/deploy/deploy_generator.rb', line 22

def gemfile
  @is_append = !file_has_content?('Gemfile','group :development do')
  if @is_append
    concat_template('Gemfile', 'gemfile.erb')
  else
    insert_template('Gemfile', 'gemfile.erb', :after => 'group :development do')
  end
  bundle_install
  bundle_exec('capify .')
end

#nameObject



6
7
8
# File 'lib/generators/venus/deploy/deploy_generator.rb', line 6

def name
  "capistrano"
end

#pumaObject



57
58
59
60
61
# File 'lib/generators/venus/deploy/deploy_generator.rb', line 57

def puma
  if @use_puma
    generate "venus:puma"
  end
end