Sha256: 6a50160a2f18534eb9696185aa64437b013d21c81d4e47db9f064b70003f5476

Contents?: true

Size: 1.27 KB

Versions: 22

Compression:

Stored size: 1.27 KB

Contents

require 'erb'
require 'pathname'

namespace :negroku do

  desc 'Install Negroku, cap install STAGES=staging,production'
  task :install do
    envs = ENV['STAGES'] || 'staging,production'

    tasks_dir = Pathname.new('lib/capistrano/tasks')
    config_dir = Pathname.new('config')
    deploy_dir = config_dir.join('deploy')

    deploy_rb = File.expand_path("../../templates/deploy.rb.erb", __FILE__)
    stage_rb = File.expand_path("../../templates/stage.rb.erb", __FILE__)
    capfile = File.expand_path("../../templates/Capfile", __FILE__)

    FileUtils.mkdir_p deploy_dir

    template = File.read(deploy_rb)
    file = config_dir.join('deploy.rb')
    File.open(file, 'w+') do |f|
      f.write(ERB.new(template).result(binding))
      puts I18n.t(:written_file, scope: :negroku, file: file)
    end

    template = File.read(stage_rb)
    envs.split(',').each do |stage|
      file = deploy_dir.join("#{stage}.rb")
      File.open(file, 'w+') do |f|
        f.write(ERB.new(template).result(binding))
        puts I18n.t(:written_file, scope: :negroku, file: file)
      end
    end

    FileUtils.mkdir_p tasks_dir

    FileUtils.cp(capfile, 'Capfile')


    puts I18n.t :capified, scope: :negroku
  end

  task :test do
    puts "si!!!"
    puts I18n.t :capified, scope: :negroku
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

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