Module: Beadme::Utils

Defined in:
lib/beadme.rb

Class Method Summary collapse

Class Method Details

.get_path(*path_parts, root: File.join(__dir__, '..')) ⇒ Object

Find a file or directory in the project Raises an error if the file or directory does not exist



7
8
9
10
11
12
13
14
# File 'lib/beadme.rb', line 7

def self.get_path(*path_parts, root: File.join(__dir__, '..'))
  path = File.join(root, *path_parts)
  unless File.exist?(path)
    raise ArgumentError,
          "File or directory does not exist: #{path}"
  end
  path
end

.load_yaml(file) ⇒ Object

Load a YAML file and convert all keys to symbols



17
18
19
# File 'lib/beadme.rb', line 17

def self.load_yaml(file)
  YAML.load_file(file).transform_keys(&:to_sym)
end