Class: Util::FS
- Inherits:
-
Object
- Object
- Util::FS
- Defined in:
- lib/utilities/utils.rb
Overview
B.2. FILE SYSTEM ————————————————————————————————
Instance Method Summary collapse
-
#clear_directory(path) ⇒ Object
B.2.2.
-
#delete_files(path) ⇒ Object
B.2.3.
-
#isEmpty(path) ⇒ Object
B.2.1.
-
#make_dir(dir) ⇒ Object
B.2.3.
Instance Method Details
#clear_directory(path) ⇒ Object
B.2.2. CLEAR THE ENTIRE DIRECTORY
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/utilities/utils.rb', line 127 def clear_directory(path) msg = Util::Message.new() if isEmpty(path) msg.warning("Your directory isn't empty! Konstruct can only be installed in an empty directory."); puts Paint["----------------------------------------------------------------------------", :yellow] puts "" puts Paint["DIRECTORY LISTING: #{path}", :yellow] puts "" puts Paint[Dir.entries(path), :yellow] puts "" puts Paint["----------------------------------------------------------------------------", :yellow] puts "" choice = choose("Do you want to clear your working directory?", :yes, :no) if choice == :yes `rm -rf *` msg.success("Working directory cleared: #{path}") else msg.error("Konstruct can only be installed in an empty directory.") exit(1) end end end |
#delete_files(path) ⇒ Object
B.2.3. CLEAN DIRECTORY
170 171 172 173 174 175 176 |
# File 'lib/utilities/utils.rb', line 170 def delete_files(path) msg = Util::Message.new() FileUtils.rm_rf(path) end |
#isEmpty(path) ⇒ Object
B.2.1. CHECK FOR EMPTY DIRECTORY
109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/utilities/utils.rb', line 109 def isEmpty(path) if Dir.entries(path).length > 2 result = true else result = false end end |
#make_dir(dir) ⇒ Object
B.2.3. CLEAN DIRECTORY
182 183 184 185 186 187 188 189 190 191 192 193 |
# File 'lib/utilities/utils.rb', line 182 def make_dir(dir) msg = Util::Message.new() unless Dir[dir].length > 0 FileUtils.mkdir(dir) msg.success("Created #{dir}") end end |