module Dotstrap
Constants
- AUTHOR
- DESCRIPTION
- DOC_URL
- EXE_NAME
- HOMEPAGE
- NAME
- SOURCE_URL
- SUMMARY
- VERSION
Public Class Methods
config_file(shell = shell_name)
click to toggle source
# File lib/dotstrap.rb, line 79 def config_file(shell = shell_name) File.join(config_home, "config.#{shell}") end
config_home()
click to toggle source
# File lib/dotstrap.rb, line 25 def config_home return ENV['DOTSTRAP_CONFIG_DIR'] if ENV.has_key?('DOTSTRAP_CONFIG_DIR') config_dir = ENV.fetch('XDG_CONFIG_HOME', Dir.home) if config_dir == Dir.home File.join(config_dir, '.config', 'dotstrap') else File.join(config_dir, 'dotstrap') end end
installed_repo_paths()
click to toggle source
# File lib/dotstrap.rb, line 83 def installed_repo_paths Dir[File.join(config_home, '**')] end
installed_repos()
click to toggle source
# File lib/dotstrap.rb, line 87 def installed_repos repos = [] installed_repo_paths.each do |repo_path| # next unless repo_path.include?('-') && File.directory?(repo_path) repo = File.basename(repo_path) repos << repo.sub(/-/,'/') end repos end
shell_config_home(shell = shell_name)
click to toggle source
# File lib/dotstrap.rb, line 73 def shell_config_home(shell = shell_name) h = Pathname.new(shell_profile(shell)).parent $LOG.debug { "SHELL_CONFIG_HOME:#{h}" } h end
shell_name()
click to toggle source
# File lib/dotstrap.rb, line 36 def shell_name # FIXME: bad to rely on SHELL environment variable to determine shell? shell = case ENV['SHELL'] when %r{/(ba)?sh} then 'bash' when %r{/zsh} then 'zsh' when %r{/fish} then 'fish' else raise RuntimeError, ENV['SHELL'] end $LOG.debug { "SHELL_NAME:#{shell}" } shell end
shell_profile(shell = shell_name)
click to toggle source
# File lib/dotstrap.rb, line 53 def shell_profile(shell = shell_name) profile = case shell when 'bash' then bash_profile = '' ['.bash_profile' '.profile'].each do |file| bash_profile = File.join(Dir.home, file) break if File.exist?(bash_profile) end bash_profile when 'zsh' then File.join(Dir.home, '.zshrc') when 'fish' then File.join(Dir.home, '.config', 'fish', 'config.fish') # File.exist?(file) ? file : fail ShellProfileError, "Fish shell config file not found end $LOG.debug { "SHELL_PROFILE:#{profile}" } profile.strip unless profile.nil? end