Class: MacSetup::GitRepoInstaller

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repo, install_path, tracking_key: nil, status: nil) ⇒ GitRepoInstaller

Returns a new instance of GitRepoInstaller.



22
23
24
25
26
27
# File 'lib/mac_setup/git_repo_installer.rb', line 22

def initialize(repo, install_path, tracking_key: nil, status: nil)
  @repo         = repo
  @install_path = install_path
  @tracking_key = tracking_key
  @status       = status
end

Instance Attribute Details

#install_pathObject (readonly)

Returns the value of attribute install_path.



5
6
7
# File 'lib/mac_setup/git_repo_installer.rb', line 5

def install_path
  @install_path
end

#repoObject (readonly)

Returns the value of attribute repo.



5
6
7
# File 'lib/mac_setup/git_repo_installer.rb', line 5

def repo
  @repo
end

#statusObject (readonly)

Returns the value of attribute status.



5
6
7
# File 'lib/mac_setup/git_repo_installer.rb', line 5

def status
  @status
end

#tracking_keyObject (readonly)

Returns the value of attribute tracking_key.



5
6
7
# File 'lib/mac_setup/git_repo_installer.rb', line 5

def tracking_key
  @tracking_key
end

Class Method Details

.install_repo(repo, install_path, track: nil, status: nil) ⇒ Object



18
19
20
# File 'lib/mac_setup/git_repo_installer.rb', line 18

def self.install_repo(repo, install_path, track: nil, status: nil)
  new(repo, install_path, tracking_key: track, status: status).install_or_update
end

.run(config, _status) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/mac_setup/git_repo_installer.rb', line 7

def self.run(config, _status)
  repos = config.git_repos
  return if repos.none?

  MacSetup.log "Installing Git Repos..."

  repos.each do |repo, install_path|
    new(repo, File.expand_path(install_path)).install_or_update
  end
end

Instance Method Details

#install_or_updateObject



29
30
31
32
33
34
35
# File 'lib/mac_setup/git_repo_installer.rb', line 29

def install_or_update
  if Dir.exist?(install_path)
    MacSetup.log("#{repo} Already Installed. Updating") { update }
  else
    MacSetup.log("Installing #{repo}") { install }
  end
end