Sha256: 984e7c223810fe5dccf119c1a86fe995dfba02c06a549d7d2a9a71f640aba4ce
Contents?: true
Size: 766 Bytes
Versions: 7
Compression:
Stored size: 766 Bytes
Contents
require 'rubygems' require 'yaml' require 'json' module Rid CONFIG_FILENAME = ".ridrc" def self.root @root ||= find_root end def self.database @database ||= config["database"] end def self.id @id ||= File.read(File.join(root, '_id')).strip end def self.rev @rev ||= File.read(File.join(root, '_rev')).strip rescue nil end private def self.config @config ||= YAML.load(File.open config_file) end 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
7 entries across 7 versions & 1 rubygems
Version | Path |
---|---|
rid-0.5.2 | lib/rid.rb |
rid-0.5.1 | lib/rid.rb |
rid-0.5.0 | lib/rid.rb |
rid-0.4.1 | lib/rid.rb |
rid-0.4.0 | lib/rid.rb |
rid-0.3.1 | lib/rid.rb |
rid-0.3.0 | lib/rid.rb |