Class: MacSetup::SymlinkInstaller

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

Class Method Summary collapse

Class Method Details

.dotfilesObject



117
118
119
# File 'lib/mac_setup/symlink_installer.rb', line 117

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

.install_dotfile(name) ⇒ Object



110
111
112
113
114
115
# File 'lib/mac_setup/symlink_installer.rb', line 110

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

  source.link
end

.install_dotfilesObject



96
97
98
99
100
101
# File 'lib/mac_setup/symlink_installer.rb', line 96

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


103
104
105
106
107
108
# File 'lib/mac_setup/symlink_installer.rb', line 103

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



91
92
93
94
# File 'lib/mac_setup/symlink_installer.rb', line 91

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