Module: Homey::PathHelpers

Included in:
Tasks
Defined in:
lib/homey/path_helpers.rb

Instance Method Summary collapse

Instance Method Details

#absolutize_paths(*paths) ⇒ Object



18
19
20
# File 'lib/homey/path_helpers.rb', line 18

def absolutize_paths(*paths)
  paths.map { |path| Pathname.new(path).expand_path(dotfiles_path) }
end

#dotfiles_pathObject



3
4
5
# File 'lib/homey/path_helpers.rb', line 3

def dotfiles_path
  @dotfiles_path ||= File.open("#{ENV['HOME']}/.homey", 'rb').read
end

#home_fileObject



7
8
9
10
11
12
# File 'lib/homey/path_helpers.rb', line 7

def home_file
  @home_file ||= begin
    path = File.join dotfiles_path, "home.yml"
    home = YAML.load_file(path)
  end
end

#prepare_paths(*paths) ⇒ Object



14
15
16
# File 'lib/homey/path_helpers.rb', line 14

def prepare_paths(*paths)
  absolutize_paths(*replace_home_char(*paths))
end

#replace_home_char(*strings) ⇒ Object



22
23
24
# File 'lib/homey/path_helpers.rb', line 22

def replace_home_char(*strings)
  strings.map { |string| string.sub(/^~\//, "#{ENV['HOME']}/") }
end