lib/reap/task/fileperm.rb in reap-5.0.0 vs lib/reap/task/fileperm.rb in reap-5.10.10
- old
+ new
@@ -1,42 +1,29 @@
-# NOTE This task needs work!
-# It needs to generalize more to give greater control
-# over which files get what permissions.
-# It also might be extended to do copyright tagging.
-
require 'reap/task'
-# ___ _ _ _____ _
-# | _ \___ _ _ _ __ (_)_____(_)___ _ _ ___ |_ _|_ _ __| |__
-# | _/ -_) '_| ' \| (_-<_-< / _ \ ' \(_-< | |/ _` (_-< / /
-# |_| \___|_| |_|_|_|_/__/__/_\___/_||_/__/ |_|\__,_/__/_\_\
#
-
-# = File Permissions Task
-
+# File Permissions Task
+#
class Reap::Perm < Reap::Task
- task_desc "Normalize ownership and permissions of files."
+ attr_accessor :user, :group, :filemod, :dirmod
- task_help %{
+ section_required true
- Normalizes file permissions.
+ def task_desc
+ "Normalize ownership and permissions of package files."
+ end
- user user name to use
- group group name to use
+ def init
+ @user = section['user']
+ @group ||= @user
+ @filemod ||= 644
+ @dirmod ||= 755
+ end
- }
-
- task_attr :perm
-
def run
-
- perm.group ||= perm.user
- perm.filemod ||= 644
- perm.dirmod ||= 755
-
puts "Reap is shelling out work to chmod..."
# misc
misc = FileList.new
misc.include('[A-Z]*')
@@ -66,19 +53,15 @@
def chmod( file_list, file_mode=644, dir_mode=755 )
dirs, files = file_list.partition{ |l| File.directory?(l) }
unless files.empty?
fstr = '"' + files.join('" "') + '"'
- #sh %{chmod #{file_mode} #{fstr}}
- tell %{chmod #{file_mode} #{fstr}}
- File.chmod( file_mode, fstr ) unless $PRETEND
+ sh %{chmod #{file_mode} #{fstr}}
end
unless dirs.empty?
fstr = '"' + dirs.join('" "') + '"'
- #sh %{chmod #{dir_mode} #{fstr}}
- tell %{chmod #{dir_mode} #{fstr}}
- File.chmod( dir_mode, fstr ) unless $PRETEND
+ sh %{chmod #{dir_mode} #{fstr}}
end
end
def run_chown
puts "NOT YET IMPLEMENTED"
@@ -94,19 +77,6 @@
# end
# end
end
-
-# Rake interface.
-
-if defined?(Rake)
-
- #require 'reap/rake/adapter'
-
- module Rake
- ReapPerm = ::Reap::RakeAdapter( ::Reap::Perm )
- end
-
-end
-
-
+#Reap.register( Reap::Perm )