Class: Awestruct::Commands::Manifest::MkDir

Inherits:
Object
  • Object
show all
Defined in:
lib/awestruct/commands/manifest.rb

Instance Method Summary (collapse)

Constructor Details

- (MkDir) initialize(path)

A new instance of MkDir



91
92
93
# File 'lib/awestruct/commands/manifest.rb', line 91

def initialize(path)
  @path = path
end

Instance Method Details

- (Object) perform(dir)



95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/awestruct/commands/manifest.rb', line 95

def perform(dir)
  p = File.join( dir, @path ) 
  if ( File.exist?( p ) )
    $stderr.puts "Exists: #{p}"
    return
  end
  if ( ! File.directory?( File.dirname( p ) ) )
    $stderr.puts "Does not exist: #{File.dirname(p)}"
    return
  end
  $stderr.puts "Create directory: #{p}"
  FileUtils.mkdir( p )
end

- (Object) unperform(dir)



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/awestruct/commands/manifest.rb', line 109

def unperform(dir)
  p = File.join( dir, @path ) 
  if ( ! File.exist?( p ) )
    $stderr.puts "Does not exist: #{p}"
    return
  end
  if ( ! File.directory?( p ) )
    $stderr.puts "Not a directory: #{p}"
    return
  end
  if ( Dir.entries( p ) != 2 )
    $stderr.puts "Not empty: #{p}"
    return
  end
  $stderr.puts "Remove: #{p}"
  FileUtils.rmdir( p )
end