Class: KuberKit::Tools::FilePresenceChecker

Inherits:
Object
  • Object
show all
Defined in:
lib/kuber_kit/tools/file_presence_checker.rb

Constant Summary collapse

FileNotFound =
Class.new(KuberKit::Error)

Instance Method Summary collapse

Instance Method Details

#check_dir!(dir_path) ⇒ Object



15
16
17
18
19
20
# File 'lib/kuber_kit/tools/file_presence_checker.rb', line 15

def check_dir!(dir_path)
  unless dir_exists?(dir_path)
    raise FileNotFound, "Directory not found at path: #{dir_path}"
  end
  true
end

#check_file!(file_path) ⇒ Object



4
5
6
7
8
9
# File 'lib/kuber_kit/tools/file_presence_checker.rb', line 4

def check_file!(file_path)
  unless file_exists?(file_path)
    raise FileNotFound, "File not found at path: #{file_path}"
  end
  true
end

#dir_exists?(dir_path) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/kuber_kit/tools/file_presence_checker.rb', line 22

def dir_exists?(dir_path)
  Dir.exists?(dir_path)
end

#file_exists?(file_path) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/kuber_kit/tools/file_presence_checker.rb', line 11

def file_exists?(file_path)
  File.exists?(file_path)
end