Sha256: a7b751c9785e2bb973865eca1bf867c7ea1cc3f37a4b80ed0f3577f32969225e
Contents?: true
Size: 1.29 KB
Versions: 2
Compression:
Stored size: 1.29 KB
Contents
require 'logger' module Sym # # This module is responsible for installing Sym BASH extensions. # module Constants BASH_FILES = Dir.glob("#{File.expand_path('../../bin', __dir__)}/sym.*.bash").freeze class << self attr_reader :user_home def user_home=(value) @user_home = value register_bash_files! end def config @config ||= {} end def sym_key_file "#{user_home}/.sym.key" end def register_bash_files! BASH_FILES.each do |bash_file| register_bash_extension bash_file end end private def register_bash_extension(bash_file) return unless user_home && Dir.exist?(user_home) source_file = File.basename(bash_file) home_file = "#{user_home}/.#{source_file}" config_key = source_file.gsub(/sym\./, '').gsub(/\.bash/, '').to_sym config[config_key] = { dest: home_file, source: bash_file, script: "[[ -f #{home_file} ]] && source #{home_file}" } end end self.user_home ||= ::Dir.home rescue nil self.user_home ||= '/tmp' self.register_bash_files! module Log NIL = Logger.new(nil).freeze # empty logger LOG = Logger.new($stderr).freeze end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sym-3.0.2 | lib/sym/constants.rb |
sym-3.0.1 | lib/sym/constants.rb |