Sha256: 7b3b57d416d0411c22e1dff5cda8358cb3e6920b27849844620d0287b4adfe87
Contents?: true
Size: 931 Bytes
Versions: 1
Compression:
Stored size: 931 Bytes
Contents
require 'yaml' class Jobim::Settings attr_reader :options def initialize load end def options @options ||= { :Daemonize => false, :Dir => Dir.pwd, :Host => '0.0.0.0', :Port => 5634, :Prefix => '/', :Quiet => false } end def load_file(file) opts = YAML.load_file(file) opts.keys.each do |key| opts[(key.to_s.capitalize.to_sym rescue key) || key] = opts.delete(key) end if opts[:Dir] unless Pathname.new(opts[:Dir]).absolute? opts[:Dir] = File.expand_path("../#{opts[:Dir]}", file) end end options.merge!(opts) end def load dir = Pathname('.').realpath files = [] loop do file = File.expand_path('.jobim.yaml', dir) files.unshift(file) if File.exists? file break if dir.root? dir = dir.parent end files.each {|file| self.load_file(file)} options end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
jobim-0.5.0 | lib/jobim/settings.rb |