Sha256: 9efed0bbe4eef01c37301d5205c461224bb96623d957a92b4361faa5ce6a13cd

Contents?: true

Size: 1.49 KB

Versions: 20

Compression:

Stored size: 1.49 KB

Contents

module Negroku::Bootstrap
  extend self

  def install

    data = {}
    data[:application_name] = ask_name
    data[:repo_url] = select_repo

    custom_capify data

  end


  private

  # This code was exatracted from capistrano to be used with our own templates
  # https://github.com/capistrano/capistrano/blob/68e7632c5f16823a09c324d556a208e096abee62/lib/capistrano/tasks/install.rake
  def custom_capify(data={})
    # defaults
    data[:server_url] = ""
    data[:branch] = "master"

    FileUtils.mkdir_p AppDirectory.deploy

    deploy_rb = AppDirectory.config.join('deploy.rb')
    capfile = AppDirectory.root.join('Capfile')
    build_template("negroku/deploy.rb.erb", deploy_rb, binding)
    build_template('negroku/Capfile.erb', capfile, binding)

    FileUtils.mkdir_p AppDirectory.tasks


    puts I18n.t :capified, scope: :negroku

  end

  # Ask the application name
  def ask_name
    question = I18n.t :application_name, scope: :negroku
    Ask.input question, default: File.basename(Dir.getwd)
  end

  # Get git remotes from current git and ask to select one
  def select_repo
    remote_urls = %x(git remote -v 2> /dev/null | awk '{print $2}' | uniq).split("\n")
    remote_urls << (I18n.t :other, scope: :negroku)

    question = I18n.t :choose_repo_url, scope: :negroku
    selected_idx = Ask.list question, remote_urls

    if selected_idx == remote_urls.length - 1
      question = I18n.t :type_repo_url, scope: :negroku
      Ask.input question
    else remote_urls[selected_idx] end
  end

end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
negroku-2.4.2 lib/negroku/cli/bootstrap.rb
negroku-2.4.1 lib/negroku/cli/bootstrap.rb
negroku-2.4.0 lib/negroku/cli/bootstrap.rb
negroku-2.3.5 lib/negroku/cli/bootstrap.rb
negroku-2.3.4 lib/negroku/cli/bootstrap.rb
negroku-2.3.3 lib/negroku/cli/bootstrap.rb
negroku-2.3.2 lib/negroku/cli/bootstrap.rb
negroku-2.3.1 lib/negroku/cli/bootstrap.rb
negroku-2.3.0 lib/negroku/cli/bootstrap.rb
negroku-2.2.0 lib/negroku/cli/bootstrap.rb
negroku-2.1.0 lib/negroku/cli/bootstrap.rb
negroku-2.0.3 lib/negroku/cli/bootstrap.rb
negroku-2.0.2 lib/negroku/cli/bootstrap.rb
negroku-2.0.1 lib/negroku/cli/bootstrap.rb
negroku-2.0.0 lib/negroku/cli/bootstrap.rb
negroku-2.0.0.pre7 lib/negroku/cli/bootstrap.rb
negroku-2.0.0.pre6 lib/negroku/cli/bootstrap.rb
negroku-2.0.0.pre5 lib/negroku/cli/bootstrap.rb
negroku-2.0.0.pre4 lib/negroku/cli/bootstrap.rb
negroku-2.0.0.pre3 lib/negroku/cli/bootstrap.rb