Module: Chauffeur::Setup

Defined in:
lib/chauffeur/setup.rb

Overview

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

Class Method Summary collapse

Class Method Details

.create_config(data) ⇒ Object

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

data: hash



29
30
31
32
33
34
# 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) ⇒ Object

Initializes the folders for storing the drivers

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

to the current working directory


18
19
20
21
22
23
# 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_configObject

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



7
8
9
10
11
12
# 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