Module: SeleniumPrep::System::Folder
Instance Method Summary collapse
- #create_directory ⇒ Object
- #directory_exists? ⇒ Boolean
- #downloads_exist? ⇒ Boolean
- #empty_directory ⇒ Object
- #prompt_user ⇒ Object
Instance Method Details
#create_directory ⇒ Object
15 16 17 |
# File 'lib/selenium-prep/system/folder.rb', line 15 def create_directory FileUtils.mkdir_p(ENV['SE_DOWNLOAD_LOCATION']) end |
#directory_exists? ⇒ Boolean
7 8 9 |
# File 'lib/selenium-prep/system/folder.rb', line 7 def directory_exists? File.directory?(ENV['SE_DOWNLOAD_LOCATION']) end |
#downloads_exist? ⇒ Boolean
11 12 13 |
# File 'lib/selenium-prep/system/folder.rb', line 11 def downloads_exist? !Dir.glob("#{ENV['SE_DOWNLOAD_LOCATION']}/*").empty? end |
#empty_directory ⇒ Object
19 20 21 |
# File 'lib/selenium-prep/system/folder.rb', line 19 def empty_directory FileUtils.rm_rf Dir.glob("#{ENV['SE_DOWNLOAD_LOCATION']}/*") end |
#prompt_user ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/selenium-prep/system/folder.rb', line 23 def prompt_user puts 'Your downloads directory is not empty. This will overwrite files of the same name.' print 'Proceed? [Y/N]: ' case $stdin.gets.chomp.downcase when "y" puts "Proceeding with download." when "n" raise 'Aborting download.' end end |