tasks/copyright.rake in deathsyn-seedling-0.0.1 vs tasks/copyright.rake in deathsyn-seedling-0.0.5

- old
+ new

@@ -1,21 +1,38 @@ -desc "add copyright to all .rb files in the distribution" -task :copyright do - ignore = File.readlines('doc/LEGAL'). - select{|line| line.strip!; File.exist?(line)}. - map{|file| File.expand_path(file)} +# Copyright (c) 2008-2009 The Rubyists, LLC (effortless systems) <rubyists@rubyists.com> +# Distributed under the terms of the MIT license. +# See the LICENSE file that accompanied this software for the full MIT License text +# +require "pathname" +task :legal do + license = Pathname("LICENSE") + license.open("w+") do |f| + f.puts PROJECT_COPYRIGHT + end unless license.file? and license.read == PROJECT_COPYRIGHT + doc = Pathname("doc/LEGAL") + doc.open("w+") do |f| + f.puts "LICENSE" + end unless doc.file? +end - puts "adding copyright to files that don't have it currently" - puts PROJECT_COPYRIGHT +desc "add copyright summary to all .rb files in the distribution" +task :copyright => [:legal] do + doc = Pathname("doc/LEGAL") + ignore = doc.readlines. + select { |line| line.strip!; Pathname(line).file? }. + map { |file| Pathname(file).expand_path } + + puts "adding copyright summary to files that don't have it currently" + puts PROJECT_COPYRIGHT_SUMMARY puts - Dir['{lib,test}/**/*{.rb}'].each do |file| - file = File.expand_path(file) - next if ignore.include? file - lines = File.readlines(file).map{|l| l.chomp} - unless lines.first(PROJECT_COPYRIGHT.size) == PROJECT_COPYRIGHT - puts "#{file} seems to need attention, first 4 lines:" - puts lines[0..3] - puts + (Pathname.glob('{controller,model,app,lib,test,spec}/**/*{.rb}') + + Pathname.glob("tasks/*.rake") + + Pathname.glob("Rakefile")).each do |file| + next if ignore.include? file.expand_path + lines = file.readlines.map{ |l| l.chomp } + unless lines.first(PROJECT_COPYRIGHT_SUMMARY.size) == PROJECT_COPYRIGHT_SUMMARY + oldlines = file.readlines + file.open("w+") { |f| f.puts PROJECT_COPYRIGHT_SUMMARY + oldlines } end end end