Module: Ginatra
- Defined in:
- lib/ginatra.rb,
lib/ginatra/repo.rb,
lib/ginatra/config.rb,
lib/ginatra/errors.rb,
lib/ginatra/logger.rb,
lib/ginatra/helpers.rb,
lib/ginatra/version.rb,
lib/ginatra/repo_list.rb,
lib/ginatra/repo_stats.rb
Defined Under Namespace
Modules: Helpers, Logger Classes: App, Error, InvalidRef, Repo, RepoList, RepoNotFound, RepoStats
Constant Summary collapse
- VERSION =
"4.1.0"
- RELEASE_NAME =
"Baku"
Class Method Summary collapse
- .config ⇒ Object
-
.load_config ⇒ Hash
Loads the configuration and merges it with custom configuration if necessary.
Class Method Details
.config ⇒ Object
5 6 7 |
# File 'lib/ginatra/config.rb', line 5 def self.config @config ||= OpenStruct.new load_config end |
.load_config ⇒ Hash
Loads the configuration and merges it with custom configuration if necessary.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/ginatra/config.rb', line 13 def self.load_config current_path = File.(File.dirname(__FILE__)) custom_config_file = File.("~/.ginatra/config.yml") default_config_file = File.("#{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.}." 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 |