Class: Homey::Tasks

Inherits:
Thor
  • Object
show all
Includes:
PathHelpers
Defined in:
lib/homey/tasks.rb

Instance Method Summary collapse

Methods included from PathHelpers

#absolutize_paths, #dotfiles_path, #home_file, #prepare_paths, #replace_home_char

Instance Method Details



22
23
24
25
26
27
28
29
30
# File 'lib/homey/tasks.rb', line 22

def create_symlinks
  opts = { flavor: options[:flavor], flavorized_attributes: %w(target) }
  symlinks = Flavorizer::flavorize_group(home_file["sym_links"], opts)
  symlinks.each do |sym|
    target, link = prepare_paths(sym['target'], sym['link'])
    FileUtils.rm_rf(link) if options[:force]
    File.symlink target, link
  end
end

#dotfiles(repo) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/homey/tasks.rb', line 9

def dotfiles(repo)
  path = replace_home_char(options.fetch("path", "~/.dotfiles")).first
  if !options[:local]
    FileUtils.rm_rf(path) if options["force"]
    command = "git clone [email protected]:#{repo}.git #{path}"
    system command
  end
  File.open("#{ENV['HOME']}/.homey", 'w') { |f| f.write(path) }
end

#setupObject



33
34
35
# File 'lib/homey/tasks.rb', line 33

def setup
  home_file["commands"].each { |command| system command }
end