Module: SeleniumPrep::System::Folder

Extended by:
Folder
Included in:
Folder
Defined in:
lib/selenium-prep/system/folder.rb

Instance Method Summary collapse

Instance Method Details

#create_directoryObject



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

Returns:

  • (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

Returns:

  • (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_directoryObject



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_userObject



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