class Dotman::User

Attributes

alias[R]
collection[R]
folder_name[R]

Public Class Methods

current() click to toggle source
# File lib/dotman/user.rb, line 50
def self.current
  new(current_user_alias)
end
current_user_alias() click to toggle source
# File lib/dotman/user.rb, line 67
def self.current_user_alias
  File.open(Dotman::Base.current_dotman).read.strip
end
move_default_back_to_home() click to toggle source
# File lib/dotman/user.rb, line 19
def self.move_default_back_to_home
  $default_user.collection.all_dotfiles.each do |file|
    FileUtils.mv(Dotman::Base.default_folder + '/' + file, ENV['HOME'] )
  end
end
new(shortcut) click to toggle source
# File lib/dotman/user.rb, line 3
def initialize(shortcut)
  @alias = shortcut
  @collection = Dotman::DotfileCollection.find_by_alias(shortcut)
  @folder_name = @collection.yaml['folder_name']
end
set(shortcut) click to toggle source
# File lib/dotman/user.rb, line 39
def self.set(shortcut)
  current.remove_symlink_dotfiles
  move_default_back_to_home
  set_user = new(shortcut)
  set_user.move_home_files_to_default
  set_user.symlink_dotfiles
  set_user.set_current_user
end
set_current_user(alias_name) click to toggle source
# File lib/dotman/user.rb, line 60
def self.set_current_user(alias_name)
  File.open(Dotman::Base.current_dotman, 'w') do |f|
    f.write(alias_name)
  end
end

Public Instance Methods

move_home_files_to_default() click to toggle source
# File lib/dotman/user.rb, line 11
def move_home_files_to_default
  @collection.all_dotfiles.each do |file|
    if File.exist?("#{ENV['HOME']}/#{file}")
      FileUtils.mv("#{ENV['HOME']}/#{file}", Dotman::Base.default_folder)
    end
  end
end
set_current_user() click to toggle source
# File lib/dotman/user.rb, line 54
def set_current_user
  File.open(Dotman::Base.current_dotman, 'w') do |f|
    f.write(@alias)
  end
end