require 'gli' require 'fileutils' module GLI class Scaffold def self.create_scaffold(root_dir,create_test_dir,create_ext_dir,project_name,commands,force=false,dry_run=false) dirs = [File.join(root_dir,project_name,'lib')] dirs << File.join(root_dir,project_name,'bin') dirs << File.join(root_dir,project_name,'test') if create_test_dir dirs << File.join(root_dir,project_name,'ext') if create_ext_dir if mkdirs(dirs,force,dry_run) mk_binfile(root_dir,create_ext_dir,force,dry_run,project_name,commands) end end def self.mk_binfile(root_dir,create_ext_dir,force,dry_run,project_name,commands) bin_file = File.join(root_dir,project_name,'bin',project_name) if !File.exist?(bin_file) || force if !dry_run File.open(bin_file,'w') do |file| file.puts '#!/usr/bin/ruby' file.puts '$: << File.expand_path(File.dirname(__FILE__) + \'/../lib\')' file.puts '$: << File.expand_path(File.dirname(__FILE__) + \'/../ext\')' if create_ext_dir file.puts <