class Dotman::DotfileCollection
Attributes
yaml[RW]
Public Class Methods
all_aliases()
click to toggle source
# File lib/dotman/dotfile_collection.rb, line 44 def self.all_aliases ensure_default_dotfile_configuration_exists dotfiles_yaml.collect {|dfy| dfy.first } end
change_alias(old_alias, new_alias)
click to toggle source
# File lib/dotman/dotfile_collection.rb, line 49 def self.change_alias(old_alias, new_alias) dotfiles_yaml[new_alias] = dotfiles_yaml[old_alias] dotfiles_yaml.delete(old_alias) if Dotman::User.current_user_alias == old_alias Dotman::User.set_current_user(new_alias) end save_dotfile_yaml end
delete(alias_name)
click to toggle source
# File lib/dotman/dotfile_collection.rb, line 13 def self.delete(alias_name) if dotfiles_yaml[alias_name] && dotfiles_yaml[alias_name]['folder_name'] FileUtils.rm_rf(File.join(Dotman::Base.dotman_folder, dotfiles_yaml[alias_name]['folder_name'])) dotfiles_yaml.delete(alias_name) save_dotfile_yaml else Dotman::Notification.dotfile_collection_not_found(alias_name) end end
dotfiles_yaml()
click to toggle source
# File lib/dotman/dotfile_collection.rb, line 23 def self.dotfiles_yaml @dotfiles_yaml ||= File.exist?(DOTFILES_PATH) ? YAML::load_file(DOTFILES_PATH) : Hash.new end
find_by_alias(alias_name)
click to toggle source
# File lib/dotman/dotfile_collection.rb, line 27 def self.find_by_alias(alias_name) ensure_default_dotfile_configuration_exists if found = dotfiles_yaml[alias_name] new(found) else Dotman::Notification.dotfile_collection_not_found(alias_name) end end
new(yaml)
click to toggle source
# File lib/dotman/dotfile_collection.rb, line 7 def initialize(yaml) @yaml = yaml end
new_configuration(folder_name, alias_name = nil)
click to toggle source
# File lib/dotman/dotfile_collection.rb, line 36 def self.new_configuration(folder_name, alias_name = nil) alias_name = folder_name unless alias_name dotfiles_yaml.store(alias_name, { 'folder_name' => folder_name }) save_dotfile_yaml end
Private Class Methods
ensure_default_dotfile_configuration_exists()
click to toggle source
# File lib/dotman/dotfile_collection.rb, line 64 def self.ensure_default_dotfile_configuration_exists unless dotfiles_yaml && dotfiles_yaml['default'] new_configuration('default') end end
save_dotfile_yaml()
click to toggle source
# File lib/dotman/dotfile_collection.rb, line 70 def self.save_dotfile_yaml File.open(DOTFILES_PATH, 'w') { |f| f.write dotfiles_yaml.to_yaml } end
Public Instance Methods
all_dotfiles()
click to toggle source
# File lib/dotman/dotfile_collection.rb, line 58 def all_dotfiles Dir.entries("#{Dotman::Base.dotman_folder}/#{@yaml['folder_name']}").select{|x| x =~ /\.{1}\w+[^git]/ } end