Class: MacSetup::SymlinkInstaller

Inherits:
Object
  • Object
show all
Defined in:
lib/mac_setup/symlink_installer.rb

Class Method Summary collapse

Class Method Details

.dotfilesObject



119
120
121
# File 'lib/mac_setup/symlink_installer.rb', line 119

def self.dotfiles
  Dir.entries(DOTFILES_PATH).reject { |entry| entry.start_with?(".") }
end

.install_dotfile(name) ⇒ Object



112
113
114
115
116
117
# File 'lib/mac_setup/symlink_installer.rb', line 112

def self.install_dotfile(name)
  dotfile = dotfiles.find { |file| file =~ /#{Regexp.escape(name)}/ }
  source = Symlink.new(name: dotfile)

  source.link
end

.install_dotfilesObject



98
99
100
101
102
103
# File 'lib/mac_setup/symlink_installer.rb', line 98

def self.install_dotfiles
  dotfiles.each do |file_name|
    source = Symlink.new(name: file_name)
    source.link
  end
end


105
106
107
108
109
110
# File 'lib/mac_setup/symlink_installer.rb', line 105

def self.install_symlinks(config)
  config.symlinks.each do |source_path|
    source = Symlink.new(source_path: File.expand_path(source_path))
    source.link
  end
end

.run(config, _status) ⇒ Object



93
94
95
96
# File 'lib/mac_setup/symlink_installer.rb', line 93

def self.run(config, _status)
  install_dotfiles
  install_symlinks(config)
end