Sha256: 525009b4d45b11d35d743abe2e981c36a15d74f856483759573756002dbaf44c

Contents?: true

Size: 1.9 KB

Versions: 1

Compression:

Stored size: 1.9 KB

Contents

#!/usr/bin/env ruby

require 'fileutils'
require 'optparse'
require 'methadone'
require 'methadone/cli'

include FileUtils
include Methadone::Main
include Methadone::CLI

main do |app_name|
  check_and_prepare_basedir!(app_name,options[:force])
  using_readme = options[:readme]

  gemname = File.basename(app_name)
  module_name = gemname.split(/_/).map(&:capitalize).join('')

  debug "Creating project for gem #{gemname}"

  chdir File.dirname(app_name)

  %x[bundle gem #{gemname}]

  chdir gemname

  template_dirs_in(:full).each  { |dir| mkdir_p dir }

  ["Rakefile", ".gitignore", "test/tc_something.rb", "features/support/env.rb"].each do |file|
    copy_file file, :binding => binding
  end

  license = options[:license]
  if license
    if license == 'NONE'
      license = nil
    else
      copy_file "#{options[:license]}_LICENSE.txt", :as => "LICENSE.txt"
    end
  else
    warn "warning: your app has no license"
  end


  if using_readme
    copy_file "README.rdoc", :binding => binding 
  end

  copy_file "features/executable.feature", :as => "#{gemname}.feature", :binding => binding
  copy_file "features/step_definitions/executable_steps.rb", :as => "#{gemname}_steps.rb"
  copy_file "bin/executable", :as => gemname, :executable => true, :binding => binding

  add_to_file "#{gemname}.gemspec", [
    "  s.add_development_dependency('rdoc')",
    "  s.add_development_dependency('aruba')",
    "  s.add_development_dependency('rake','~> 0.9.2')",
    "  s.add_dependency('methadone')",
  ], :before => /^end\s*$/
end

options[:readme] = true

description "Kick the bash habit by bootstrapping your Ruby command-line apps"

on("--force","Overwrite files if they exist")
on("--[no-]readme","[Do not ]produce a README file")

licenses = %w(mit apache custom NONE)
on("-l LICENSE","--license",licenses,"Specify the license for your project (#{licenses.join('|')})")

arg :app_name, :required

version Methadone::VERSION

go!

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
methadone-0.5.1 bin/methadone