bin/borgify

Summary

Maintainability
Test Coverage
#!/usr/bin/env ruby
require 'fileutils'
plugin = (ARGV.count == 1 and ARGV[0] == "plugin")

if ARGV.empty? or plugin
  skeleton_dir = File.expand_path('../../skeleton', __FILE__)
  gem_name = File.basename(Dir.pwd)

  puts "Copying Skeleton"
  FileUtils.cp_r("#{skeleton_dir}/.", ".")

  puts "Creating lib/#{gem_name}.rb"
  File.open("lib/#{gem_name}.rb", 'w') do |file|
    file.write(<<-GEMRB)
Capistrano::Configuration.instance(:must_exist).load do
  assimilate "#{gem_name}"
end
    GEMRB
  end

  puts "Removing unnecessary files and folders"
  if plugin
    FileUtils.rm_r "cap/applications"
    FileUtils.rm_r "Capfile"
    FileUtils.rm_r "Gemfile"
    puts "Setting up gemspec file"
    FileUtils.mv "mygem.gemspec.skeleton", "#{gem_name}.gemspec"
  else
    FileUtils.rm_r "mygem.gemspec.skeleton"
  end

else
  # display help if parameters input
  puts <<-HELP
borgify only supports to ways of calling it.
borgify         # to setup deployment project
borgify plugin  # to setup a pluging for borg
  HELP
end