mac_setup 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/mac_setup/configuration.rb +4 -0
- data/lib/mac_setup/symlink_installer.rb +61 -0
- data/lib/mac_setup/version.rb +1 -1
- data/lib/mac_setup.rb +12 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d61d6b8d5f046d9b1d0bcf705c295a2357578214
|
4
|
+
data.tar.gz: d3ac96244790173f91ddd947ed43c25266f87b89
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9358b9466dafbb8c77c16ea89d60ed189042827756e646f4c7d671f981653734cfd28852ecdd1f54eb41fd9c91622e5f6106d8585c05378f83ec97e2b6fb6c51
|
7
|
+
data.tar.gz: ce6b0e39e5ba19d77c78b671757d4cac0bd0ac09b3d5a1cd6ee590021b875c0e8c71427c133bf69aa93b9a5bc8510e9ff470b6b5e4e5f5bd4074acf9b241926d
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module MacSetup
|
2
|
+
class SymlinkInstaller
|
3
|
+
def self.run(config)
|
4
|
+
install_dotfiles
|
5
|
+
install_symlinks(config)
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.install_dotfiles
|
9
|
+
dotfiles.each do |file_name|
|
10
|
+
source = File.expand_path(file_name, DOTFILES_PATH)
|
11
|
+
create_link(source, file_name)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.install_symlinks(config)
|
16
|
+
config.symlinks.each do |file|
|
17
|
+
file_name = File.basename(file)
|
18
|
+
source = File.expand_path(file)
|
19
|
+
|
20
|
+
create_link(source, file_name)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.install_dotfile(name)
|
25
|
+
dotfile = dotfiles.find { |file| file =~ /#{Regexp.escape(name)}/ }
|
26
|
+
source = File.expand_path(dotfile, DOTFILES_PATH)
|
27
|
+
|
28
|
+
create_link(source, dotfile)
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.dotfiles
|
32
|
+
Dir.entries(DOTFILES_PATH).reject { |entry| entry.start_with?('.') }
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.create_link(source, file_name)
|
36
|
+
target = File.join(ENV['HOME'], ".#{file_name}")
|
37
|
+
|
38
|
+
if File.exist?(target)
|
39
|
+
replace(source, target, name)
|
40
|
+
else
|
41
|
+
FileUtils.ln_s(source, target)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.replace(source, target, dotfile)
|
46
|
+
if File.symlink?(target)
|
47
|
+
replace_symlink(source, target, dotfile)
|
48
|
+
else
|
49
|
+
puts "File already exists at #{target}. Skipping..."
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.replace_symlink(source, target, dotfile)
|
54
|
+
if File.readlink(target) == source
|
55
|
+
puts "#{dotfile} already linked. Skipping..."
|
56
|
+
else
|
57
|
+
FileUtils.ln_sf(source, target)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
data/lib/mac_setup/version.rb
CHANGED
data/lib/mac_setup.rb
CHANGED
@@ -9,6 +9,7 @@ require 'mac_setup/cask_installer'
|
|
9
9
|
require 'mac_setup/launch_agent_installer'
|
10
10
|
require 'mac_setup/git_repo_installer'
|
11
11
|
require 'mac_setup/script_installer'
|
12
|
+
require 'mac_setup/symlink_installer'
|
12
13
|
|
13
14
|
module MacSetup
|
14
15
|
DOTFILES_PATH = File.expand_path('~/.dotfiles')
|
@@ -24,10 +25,21 @@ module MacSetup
|
|
24
25
|
LaunchAgentInstaller.run(config, status)
|
25
26
|
GitRepoInstaller.run(config)
|
26
27
|
ScriptInstaller.run(config)
|
28
|
+
SymlinkInstaller.run(config)
|
27
29
|
end
|
28
30
|
|
29
31
|
def self.bootstrap(dotfiles_repo)
|
32
|
+
check_brew_install_path
|
33
|
+
|
30
34
|
GitRepoInstaller.install_repo(dotfiles_repo, DOTFILES_PATH)
|
31
35
|
CommandLineToolsInstaller.run
|
36
|
+
SymlinkInstaller.install_dotfile('mac_setup')
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.check_brew_install_path
|
40
|
+
return if Dir.exist?('/usr/local')
|
41
|
+
|
42
|
+
puts '/usr/local does not exist.'
|
43
|
+
puts 'Read this to fix: https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/El_Capitan_and_Homebrew.md#if-usrlocal-does-not-exist'
|
32
44
|
end
|
33
45
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mac_setup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Wean
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -112,6 +112,7 @@ files:
|
|
112
112
|
- lib/mac_setup/launch_agent_installer.rb
|
113
113
|
- lib/mac_setup/script_installer.rb
|
114
114
|
- lib/mac_setup/shell.rb
|
115
|
+
- lib/mac_setup/symlink_installer.rb
|
115
116
|
- lib/mac_setup/system_status.rb
|
116
117
|
- lib/mac_setup/tap_installer.rb
|
117
118
|
- lib/mac_setup/version.rb
|