module Chauffeur::Setup

Initializes the folders for storing the drivers and creates config.yml file that stores the versions of installed drivers.

Public Class Methods

create_config(data) click to toggle source

Initializes the config.yml file that is used for storing the installed versions of the specific drivers

data: hash

# File lib/chauffeur/setup.rb, line 29
def self.create_config(data)
  return if File.exist?("#{Dir.pwd}/drivers/config.yml")
  File.open("#{Dir.pwd}/drivers/config.yml", 'w') do |file|
    file.puts(data.to_yaml)
  end
end
create_folders(folders) click to toggle source

Initializes the folders for storing the drivers

folders: Array(strings) - each is a folder to be created relative

to the current working directory
# File lib/chauffeur/setup.rb, line 18
def self.create_folders(folders)
  folders.each do |folder|
    full_path = "#{Dir.pwd}/#{folder}"
    FileUtils.mkdir_p(full_path) unless File.exist?(full_path)
  end
end
create_folders_and_config() click to toggle source

Initializes the folders for storing the drivers and creates config.yml file that stores the versions of installed drivers.

# File lib/chauffeur/setup.rb, line 7
def self.create_folders_and_config
  config_file_path = "#{File.dirname(__FILE__)}/config.yml"
  data = File.open(config_file_path) { |f| YAML.safe_load(f) }
  create_folders(data['folders'])
  create_config(data)
end