Sha256: 6b1223c0bd2f2a904055d680c1f532338d354ca3552818f45221f182e3cf6be1
Contents?: true
Size: 1.22 KB
Versions: 1
Compression:
Stored size: 1.22 KB
Contents
require 'yaml' require 'ostruct' module Ginatra def self.config @config ||= OpenStruct.new load_config end # Loads the configuration and merges it with # custom configuration if necessary. # # @return [Hash] config a hash of the configuration options def self.load_config current_path = File.expand_path(File.dirname(__FILE__)) custom_config_file = File.expand_path("~/.ginatra/config.yml") default_config_file = File.expand_path("#{current_path}/../../config.yml") # Our own file should be there and we don't need to check its syntax abort 'ginatra config file #{default_config_file} is missing.' unless File.exists?(default_config_file) final_config = YAML.load_file(default_config_file) # User config file may not exist or be broken if File.exists?(custom_config_file) begin custom_config = YAML.load_file(custom_config_file) rescue Psych::SyntaxError => ex puts "Cannot parse your config file #{ex.message}." custom_config = {} end final_config.merge!(custom_config) else puts "User config file #{custom_config_file} absent. Will only see repos in #{final_config["git_dirs"].join(", ")}." end final_config end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ginatra-4.1.0 | lib/ginatra/config.rb |