Sha256: 1648005310033a1ff34079e27504177090a5c8423a5df6780b0ce85c88b22ed9
Contents?: true
Size: 1.16 KB
Versions: 1
Compression:
Stored size: 1.16 KB
Contents
require 'ostruct' require 'yaml' require 'uri' require 'user_config' module SearchKit module Configuration def configure yield(config) if block_given? end def config return @config if @config root = UserConfig.new(".search-kit") yaml = root['config.yml'] config = OpenStruct.new yaml.each { |key, value| config.send("#{key}=", value) } @config = config end def set_config(key, value) root = UserConfig.new(".search-kit") yaml = root['config.yml'] yaml[key] = value yaml.save end def show_config(key) root = UserConfig.new(".search-kit") root['config.yml'][key] end def fetch(key) ENV.fetch(key, show_config(key.downcase) || default(key.to_sym)) end private def default(key) default_table = { APP_URI: "http://localhost:8080", APP_ENV: "development", APP_DIR: File.expand_path("../../", __dir__), APP_VERBOSE: true, LOG_DIR: default_log_dir }.fetch(key, nil) end def default_log_dir Dir.mkdir('log') unless Dir.exist?('log') 'log' end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
search-kit-0.0.2 | lib/search_kit/configuration.rb |