Module: Setup

Defined in:
lib/debot/helpers/utils.rb

Class Method Summary collapse

Class Method Details

.ask(question) ⇒ Object



22
23
24
# File 'lib/debot/helpers/utils.rb', line 22

def self.ask(question)
  process(question)
end

.ask?(question) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/debot/helpers/utils.rb', line 26

def self.ask?(question)
  %w[yes y yeah yep true].include?(process(question))
end

.runObject



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
# File 'lib/debot/helpers/utils.rb', line 30

def self.run
  puts "Kindly provide the following details:"
  puts 
  @server = ask("Your server name or IP address:")
  @application_name = ask("Your application name:")
  @user = ask("Your deployment user's name:")
  @group = ask("Our deployment user's system group ?")
  @number_of_releases = ask("How many releases would like to keep?")
  @scm = ask("Your choosen scm (git or svn)?")
  @repository = ask("Enter your repository's url/location:")
  @stage_names = []

  begin
    puts
    puts "Provide details for creating a multi-stage file:"
    puts
    @stage_name = ask("What would you like to call this stage file?")
    @stage_names << @stage_name
    @domain = ask("What is your #{@stage_name} domain name?")
    @app_parent_directory = ask("What is the parent directory for #{@stage_name} stage? (Given full path details)")
    @deploy_to = ask("Where on your server would #{@stage_name} be located? (Give file path)")
    @branch = ask("What #{@scm} branch would you like to deploy for this stage?")
    stages_directory = File.join(Rails.root, "config/deploy")

    puts "Creating stage file #{stages_directory}/#{@stage_name}.rb"

    if File.directory?(stages_directory)
      template_rake("stages.rb.erb", "#{stages_directory}/#{@stage_name}.rb")
    else 
      system "mkdir -p #{stages_directory}"
      template_rake("stages.rb.erb", "#{stages_directory}/#{@stage_name}.rb")
    end
  end while(ask?("Would you like to create a (another) stage file? (yes/no)"))

  deploy_directory = File.join(Rails.root, "config")

  puts "Creating your deploy file #{deploy_directory}/deploy.rb"

  template_rake("deploy.rb.erb", "#{deploy_directory}/deploy.rb")

end