Class: Awestruct::Commands::Manifest::MkDir
- Inherits:
-
Object
- Object
- Awestruct::Commands::Manifest::MkDir
- Defined in:
- lib/awestruct/commands/manifest.rb
Instance Method Summary collapse
-
#initialize(path) ⇒ MkDir
constructor
A new instance of MkDir.
- #perform(dir) ⇒ Object
- #unperform(dir) ⇒ Object
Constructor Details
#initialize(path) ⇒ MkDir
Returns a new instance of MkDir.
90 91 92 |
# File 'lib/awestruct/commands/manifest.rb', line 90 def initialize(path) @path = path end |
Instance Method Details
#perform(dir) ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/awestruct/commands/manifest.rb', line 94 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 |
#unperform(dir) ⇒ Object
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/awestruct/commands/manifest.rb', line 108 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 |