Sha256: 7d5ade04a2d799d46b1b51a72ac6f11b185314bc3bc98542ae2e18a7631fe049
Contents?: true
Size: 1.39 KB
Versions: 4
Compression:
Stored size: 1.39 KB
Contents
using Ahnnotate::Refinement::Dig module Ahnnotate class Config def self.load(root:) config_path = root.join(".ahnnotate.yml") if !config_path.exist? return new({}) end loaded_config = YAML.safe_load(File.read(config_path)) new(loaded_config) end def self.default @default ||= { "boot" => nil, "rake_db_autorun" => false, "annotate" => { "models" => { "enabled" => true, "path" => "app/models", "extension" => ".rb", }, }, } end def self.rails_additions @rails_additions ||= { "boot" => %(require File.expand_path("config/environment").to_s), "rake_db_autorun" => true, } end def self.effective_default if @effective_default return @effective_default end @effective_default ||= YAML.load(YAML.dump(default)) # deep dup if Gem.loaded_specs.key?("rails") @effective_default.merge!(rails_additions) end @effective_default end def initialize(config) @config = if config.is_a?(Hash) config else {} end end def [](*args) specified_config = @config.dig(*args) if specified_config.nil? self.class.effective_default.dig(*args) else specified_config end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
ahnnotate-0.5.1 | lib/ahnnotate/config.rb |
ahnnotate-0.5.0 | lib/ahnnotate/config.rb |
ahnnotate-0.4.0 | lib/ahnnotate/config.rb |
ahnnotate-0.3.0 | lib/ahnnotate/config.rb |