Module: Core

Includes:
FileSystem, Get, Install, Response, Sudo
Included in:
Options
Defined in:
lib/dotfiles/core.rb

Class Method Summary collapse

Methods included from Install

scripts, wallpapers

Methods included from FileSystem

contents, mkdir, rglob

Methods included from Sudo

copy

Methods included from Get

answer, exists, name, path

Class Method Details

.delete(name) ⇒ Object



113
114
115
116
117
# File 'lib/dotfiles/core.rb', line 113

def self.delete(name)
  path = Get.exists(name)

  FileUtils.rm_rf(path)
end

.help(command = nil) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/dotfiles/core.rb', line 38

def self.help(command=nil)
  if command == nil
    Response.help
    exit
  end

  case command.downcase
    when 'install'
      Response.install
    when 'use'
      Response.use
    when 'save'
      Response.save
    when 'delete'
      Response.delete
    else
      Response.help
  end
  exit
end

.install(link) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/dotfiles/core.rb', line 59

def self.install(link)
  name = Get.name
  path = Get.path(name)

  begin
    Git.clone(link, path)
  rescue Exception => e
    puts "#{"Error".red}: Could not clone the repository"
    puts
    puts e.message
    exit
  end

  puts "#{name.cyan} #{"successfully installed".green}"
  puts "Path: #{path}"

  print 'Do you want to use the installed dotfiles? (Y/n) '
  use = Get.answer

  if use
    use(name)
  end
end

.saveObject



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/dotfiles/core.rb', line 96

def self.save
  name = Get.name
  path = Get.path(name)

  init(path)

  config(path)
  tools(path)

  print 'Do you also want to backup your /etc directory? (Y/n) '
  backup = Get.answer
  
  if backup
    etc(path)
  end
end

.use(name) ⇒ Object



83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/dotfiles/core.rb', line 83

def self.use(name)
  path = Get.exists(name)

  print 'Backup current dotfiles? (Y/n) '
  save = Get.answer

  if save
    save()
  end

  scan(name, path)
end