Sha256: bd7be5ef7fafca3a7f88b4f2400a35f77f15c9bea154ba1869cfa57339a14977
Contents?: true
Size: 1.31 KB
Versions: 1
Compression:
Stored size: 1.31 KB
Contents
# frozen_string_literal: true module RubyJard ## # Another reinvent-the-wheel configuration class Config class << self def smart_load config = RubyJard::Config.new path = File.expand_path(File.join(Dir.pwd, CONFIG_FILE_NAME)) load_config(config, path) if File.exist?(path) path = File.expand_path(File.join('~/', CONFIG_FILE_NAME)) load_config(config, path) if File.exist?(path) config rescue StandardError => e # Fallback to default setting STDOUT.puts "Fail to load jard configurations at #{path}. Error: #{e}" RubyJard::Config.new end private def load_config(config, path) config_content = File.read(path) config.instance_eval(config_content) config end end attr_accessor :color_scheme, :alias_to_debugger, :layout, :enabled_screens CONFIG_FILE_NAME = '.jardrc' DEFAULTS = [ DEFAULT_COLOR_SCHEME = '256', DEFAULT_ALIAS_TO_DEBUGGER = false, DEFAULT_LAYOUT = nil # Pick layout automatically ].freeze def initialize @color_scheme = DEFAULT_COLOR_SCHEME @alias_to_debugger = DEFAULT_ALIAS_TO_DEBUGGER @layout = DEFAULT_LAYOUT @enabled_screens = RubyJard::Screens.names end def config self end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ruby_jard-0.2.3 | lib/ruby_jard/config.rb |