Permalink
Browse files

Clean re-write

  • Loading branch information...
1 parent d98d083 commit c074ee51519725349d328325fa6c3f61ace701d9 tim committed Jul 6, 2003
Showing with 6 additions and 15 deletions.
  1. +6 −15 post-clean.rb
View
@@ -1,21 +1,12 @@
# delete RMagick documentation created by post-setup.rb
# doc/*.rb.html
# doc/ex/* (!rb)
-
-require 'find'
require 'ftools'
-Dir.foreach('doc') do |entry|
- next if FileTest.directory? 'doc'+File::SEPARATOR+entry
- next unless /\.rb\.html?/.match(entry)
-# puts "deleting #{'doc'+File::SEPARATOR+entry}"
- File.delete('doc'+File::SEPARATOR+entry)
-end
+targets = Dir['doc/*.rb.html']
+File.safe_unlink(*targets) unless targets.empty?
+
+targets = Dir['doc/ex/*']
+targets.delete_if { |entry| !File.file?(entry) || %r{\.rb\z}.match(entry) }
+File.safe_unlink(*targets) unless targets.empty?
-dir = 'doc'+File::SEPARATOR+'ex'
-Dir.foreach(dir) do |entry|
- next if FileTest.directory? dir+File::SEPARATOR+entry
- next if /\.rb?/.match(entry)
-# puts "deleting #{dir+File::SEPARATOR+entry}"
- File.delete(dir+File::SEPARATOR+entry)
-end

0 comments on commit c074ee5

Please sign in to comment.