lib/rna/task.rb in rna-0.3.8 vs lib/rna/task.rb in rna-0.4.0

- old
+ new

@@ -1,20 +1,26 @@ module Rna class Task - def self.init(project_root=".",options={}) - puts "Settin up rna project" unless options[:quiet] - FileUtils.mkdir("#{project_root}/config") unless File.exist?("#{project_root}/config") - %w/rna.rb s3.yml Guardfile/.each do |name| - source = File.expand_path("../../files/#{name}", __FILE__) - dest = "#{project_root}/config/#{File.basename(source)}" - dest = "#{project_root}/#{File.basename(source)}" if name == 'Guardfile' - if File.exist?(dest) + def self.init(options={}) + project_root = options[:project_root] || '.' + puts "Setting up lono project" unless options[:quiet] + source_root = File.expand_path("../../starter_project", __FILE__) + paths = Dir.glob("#{source_root}/**/*"). + select {|p| File.file?(p) } + paths.each do |src| + dest = src.gsub(%r{.*starter_project/},'') + dest = "#{project_root}/#{dest}" + + if File.exist?(dest) and !options[:force] puts "already exists: #{dest}" unless options[:quiet] else puts "creating: #{dest}" unless options[:quiet] - FileUtils.cp(source, dest) + dirname = File.dirname(dest) + FileUtils.mkdir_p(dirname) unless File.exist?(dirname) + FileUtils.cp(src, dest) end end + puts "Starter lono project created" end def self.generate(options) new(options).generate end \ No newline at end of file