Class: Reap::Perm

Inherits:
Task
  • Object
show all
Defined in:
lib/reap/task/fileperm.rb

Overview

File Permissions Task

Constant Summary

Constants inherited from Task

Task::RUBY

Instance Method Summary collapse

Methods inherited from Task

#ask, available?, #execute, has_section?, inherited, #initialize, #initiate, master, #master, #provide_setup_rb, #section, #sh, #task, task_attr, task_available, #task_desc, task_desc, #task_help, task_help, task_list, #task_name, task_name, #tell, #use_subsection

Constructor Details

This class inherits a constructor from Reap::Task

Instance Method Details

#chmod(file_list, file_mode = 644, dir_mode = 755) ⇒ Object

support functions



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/reap/task/fileperm.rb', line 69

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
  end
  unless dirs.empty?
    fstr = '"' + dirs.join('" "') + '"'
    #sh %{chmod #{dir_mode} #{fstr}}
    tell %{chmod #{dir_mode} #{fstr}}
    File.chmod( dir_mode, fstr ) unless $PRETEND
  end
end

#runObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/reap/task/fileperm.rb', line 34

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]*')
  misc.exclude('InstalledFiles')
  chmod( misc ) unless misc.empty?

  # lib
  libs = FileList.new
  libs.include('lib/**/*')
  libs.exclude('lib/CVS/**/*')
  libs.include('packages/*/lib/**/*')
  libs.exclude('packages/*/lib/CVS/**/*')
  libs.exclude('packages/CVS/**/*')
  chmod( libs ) unless libs.empty?

  # bin
  bins = FileList.new
  bins.include('bin/**/*')
  bins.exclude('bin/CVS/**/*')
  bins.include('packages/*/bin/**/*')
  bins.exclude('packages/*/bin/CVS/**/*')
  bins.exclude('packages/CVS/**/*')
  chmod( bins, 755 ) unless bins.empty?
end

#run_chownObject



85
86
87
# File 'lib/reap/task/fileperm.rb', line 85

def run_chown
  puts "NOT YET IMPLEMENTED"
end