lib/dev/Environment.rb in dev-1.0.244 vs lib/dev/Environment.rb in dev-1.0.245

- old
+ new

@@ -5,9 +5,26 @@ class Environment def self.replace_text_in_glob(glob,search,replace) Dir.glob(glob).each{ |f| replace_text_in_file(f,search,replace) } end + def copy_from_template(source_directory,target_directory,glob_pattern,search,replace) + Dir.chdir(source_directory) do + Dir.glob("**/*") {|f| + if(!File.directory?(f)) + target_file = target_directory + "/" + f.gsub(search,replace) + if(!File.exist?(target_file)) + FileUtils.mkdir_p(File.dirname(target_file)) if(!Dir.exist?(File.dirname(target_file))) + FileUtils.cp(f,target_file) + end + end + } + end + Dir.glob(glob_pattern) { |f| + Dev::Environment::replace_text_in_file(f,search,replace) + } + end + def self.replace_text_in_file(filename,search,replace) puts_debug "replace_text_in_file(#{filename},#{search.to_s},#{replace.to_s})" text1 = File.read(filename) text2 = text1.gsub(search) { |str| str=replace } unless text1==text2