Module: MacSetup

Defined in:
lib/mac_setup.rb,
lib/mac_setup/shell.rb,
lib/mac_setup/plugin.rb,
lib/mac_setup/result.rb,
lib/mac_setup/secrets.rb,
lib/mac_setup/version.rb,
lib/mac_setup/plugins/asdf.rb,
lib/mac_setup/configuration.rb,
lib/mac_setup/system_status.rb,
lib/mac_setup/homebrew_runner.rb,
lib/mac_setup/plugins/keybase.rb,
lib/mac_setup/plugins/dotfiles.rb,
lib/mac_setup/script_installer.rb,
lib/mac_setup/secrets_installer.rb,
lib/mac_setup/symlink_installer.rb,
lib/mac_setup/brewfile_installer.rb,
lib/mac_setup/defaults_installer.rb,
lib/mac_setup/git_repo_installer.rb,
lib/mac_setup/homebrew_installer.rb,
lib/mac_setup/services_installer.rb,
lib/mac_setup/symlink_path_builder.rb,
lib/mac_setup/plugins/mac_app_store.rb,
lib/mac_setup/command_line_tools_installer.rb

Defined Under Namespace

Modules: Plugins Classes: BrewfileInstaller, CommandLineToolsInstaller, Configuration, DefaultsInstaller, GitRepoInstaller, HomebrewInstaller, HomebrewRunner, Plugin, Result, ScriptInstaller, Secrets, SecretsInstaller, ServicesInstaller, Shell, Symlink, SymlinkInstaller, SymlinkPathBuilder, SystemStatus

Constant Summary collapse

DEFAULT_DOTFILES_PATH =
File.expand_path("~/.dotfiles")
DEFAULT_CONFIG_PATH =
File.join(DEFAULT_DOTFILES_PATH, "mac_setup/config.yml")
INSTALLERS =
[
  GitRepoInstaller,
  SymlinkInstaller,
  HomebrewRunner,
  ScriptInstaller,
  DefaultsInstaller
]
DEFAULT_PLUGINS =
[
  Plugins::MacAppStore,
  Plugins::Keybase,
  Plugins::Dotfiles,
  Plugins::Asdf
]
VERSION =
"0.9.0"

Class Method Summary collapse

Class Method Details

.bootstrap(dotfiles_repo) ⇒ Object



42
43
44
45
46
47
48
49
# File 'lib/mac_setup.rb', line 42

def bootstrap(dotfiles_repo)
  HomebrewInstaller.run
  GitRepoInstaller.install_repo(dotfiles_repo, dotfiles_path)

  config = Configuration.new(DEFAULT_CONFIG_PATH)

  plugins(config).each { |plugin| plugin.bootstrap(config) }
end

.dotfiles_pathObject



83
84
85
# File 'lib/mac_setup.rb', line 83

def dotfiles_path
  DEFAULT_DOTFILES_PATH
end

.encryptObject



65
66
67
# File 'lib/mac_setup.rb', line 65

def encrypt
  Secrets.encrypt(dotfiles_path)
end

.installObject

(config_path, _options)



51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/mac_setup.rb', line 51

def install # (config_path, _options)
  config = Configuration.new(DEFAULT_CONFIG_PATH)

  Shell.raw("brew update")

  config = Configuration.new(DEFAULT_CONFIG_PATH)
  plugins(config).each { |plugin| plugin.add_requirements(config) }
  config.validate!
  status = SystemStatus.new

  INSTALLERS.each { |installer| installer.run(config, status) }
  plugins(config).each { |plugin| plugin.run(config, status) }
end

.log(message) ⇒ Object



73
74
75
76
77
78
79
80
81
# File 'lib/mac_setup.rb', line 73

def log(message)
  if block_given?
    print "#{message}..."
    yield
    puts "Ok."
  else
    puts message
  end
end

.plugins(config) ⇒ Object

private



89
90
91
92
# File 'lib/mac_setup.rb', line 89

def plugins(config)
  DEFAULT_PLUGINS + config.plugins.map { |plugin_name| Plugin.load(plugin_name) }
  # @plugins ||= (DEFAULT_PLUGINS + config.plugins).map { |plugin_name| Plugin.load(plugin) }
end

.shorten_path(path) ⇒ Object



69
70
71
# File 'lib/mac_setup.rb', line 69

def shorten_path(path)
  path.to_s.sub(/#{ENV['HOME']}/, "~")
end