Class: Dotstrap::Configuration

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repos = nil) ⇒ Configuration

Returns a new instance of Configuration.



103
104
105
106
# File 'lib/dotstrap.rb', line 103

def initialize(repos = nil)
  @repos = repos unless repos.nil?
  FileUtils.mkdir_p(Dotstrap.config_home)
end

Instance Attribute Details

#reposObject

Returns the value of attribute repos.



101
102
103
# File 'lib/dotstrap.rb', line 101

def repos
  @repos
end

Instance Method Details

#configure(dest_dir = Dotstrap.config_home, repos = @repos) ⇒ Object



118
119
120
121
122
123
124
125
# File 'lib/dotstrap.rb', line 118

def configure(dest_dir = Dotstrap.config_home, repos = @repos)
  initialize_fish_dirs if Dotstrap.shell_name == 'fish'
  Parallel.map(repos, in_threads: 16) do |r|
    path = Dotstrap::Git.new(r, dest_dir).repo_path
    puts path
    load_configs([path]) if path
  end
end

#install(dest_dir = Dotstrap.config_home, repos = @repos) ⇒ Object



108
109
110
111
112
113
114
115
116
# File 'lib/dotstrap.rb', line 108

def install(dest_dir = Dotstrap.config_home, repos = @repos)
  initialize_fish_dirs if Dotstrap.shell_name == 'fish'
  Parallel.map(repos, in_threads: 16) do |r|
    bundle = Dotstrap::Git.new(r, dest_dir)
    path = bundle.clone
    puts path
    load_configs([path]) if path
  end
end

#list(repos = @repos) ⇒ Object

TODO: return a data-structure from ‘list`, do not print out



137
138
139
140
141
142
143
144
145
146
147
# File 'lib/dotstrap.rb', line 137

def list(repos = @repos)
  repos.each do |repo|
    bundle = Dotstrap::Git.new(repo)
    next unless Dir.exist?(bundle.repo_path)
    puts "#{'=>'.colorize(:blue)} #{repo}"
    puts bundle.url
    puts bundle.repo_path
    # TODO: only output all associated files on --verbose
    puts "\n"
  end
end

#load_configs(repo_path) ⇒ Object



149
150
151
152
153
# File 'lib/dotstrap.rb', line 149

def load_configs(repo_path)
  repo_path.each do |r|
    Dotstrap::Shell.new(r).configure(repo_path)
  end
end

#remove(repos = @repos) ⇒ Object



127
128
129
130
131
132
133
134
# File 'lib/dotstrap.rb', line 127

def remove(repos = @repos)
  repos.each do |repo|
    bundle = Dotstrap::Git.new(repo)
    repo_path = bundle.repo_path
    shell = Dotstrap::Shell.new(repo_path)
    shell.unconfigure(repo_path)
  end
end