Sha256: 5c71a5ac5722e38fffb899a59c871e86ace9a80d59518e3b91785c4a9bddc072
Contents?: true
Size: 1.65 KB
Versions: 1
Compression:
Stored size: 1.65 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, :filter, :filter_included, :filter_excluded CONFIG_FILE_NAME = '.jardrc' DEFAULTS = [ DEFAULT_COLOR_SCHEME = '256', DEFAULT_ALIAS_TO_DEBUGGER = false, DEFAULT_LAYOUT = nil, # Pick layout automatically DEFAULT_FILTER = RubyJard::PathFilter::FILTER_APPLICATION, DEFAULT_FILTER_INCLUDED = [].freeze, DEFAULT_FILTER_EXCLUDED = [].freeze ].freeze def initialize @color_scheme = DEFAULT_COLOR_SCHEME @alias_to_debugger = DEFAULT_ALIAS_TO_DEBUGGER @layout = DEFAULT_LAYOUT @enabled_screens = RubyJard::Screens.names @filter = DEFAULT_FILTER @filter_included = DEFAULT_FILTER_INCLUDED.dup @filter_excluded = DEFAULT_FILTER_EXCLUDED.dup end def config self end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ruby_jard-0.3.0 | lib/ruby_jard/config.rb |