Sha256: bd766219629d8acfd6f8543689c544deb81c8bb0e874a814b1c6d27b4abb9a80

Contents?: true

Size: 596 Bytes

Versions: 2

Compression:

Stored size: 596 Bytes

Contents

require 'rubygems'
require 'yaml'
require 'json'

module Couch
  CONFIG_FILENAME = ".couchrc"

  def self.root
    @root ||= find_root
  end

  def self.database
    config["database"]
  end

  def self.config
    @config ||= YAML.load(File.open config_file)
  end

  private

  def self.config_file
    File.join root, CONFIG_FILENAME
  end

  def self.find_root
    cwd = Dir.pwd
    return cwd if File.exists?(File.join(cwd, CONFIG_FILENAME))
    Dir.chdir("..") do
      find_root unless cwd == Dir.pwd
    end
  rescue SystemCallError
    # could not chdir, no problem just return
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
couch-0.1.2 lib/couch.rb
couch-0.1.1 lib/couch.rb