Sha256: a4efd9b6b4ea61e83d76cefbb90e2b24fd57d4dc670a5d67ea58f781a043ab21
Contents?: true
Size: 1.21 KB
Versions: 2
Compression:
Stored size: 1.21 KB
Contents
require 'fileutils' require 'singleton' module DRbQS ACL_DEFAULT_PATH = 'acl.txt' ACL_SAMPLE_PATH = 'acl.txt.sample' HOST_FILE_DIRECTORY = 'host' class Config @@data = { :dir => ENV['HOME'] + '/.drbqs/', } ACL_SAMPLE =<<SAMPLE deny all allow localhost allow 127.0.0.1 SAMPLE class << self def get_path(name) File.join(@@data[:dir], name) end private :get_path def set_directory(dir) @@data[:dir] = dir end def get_host_file_directory get_path(HOST_FILE_DIRECTORY) end def check_directory_create unless File.exist?(@@data[:dir]) FileUtils.mkdir_p(@@data[:dir]) FileUtils.chmod(0700, @@data[:dir]) end host = get_host_file_directory unless File.exist?(host) FileUtils.mkdir_p(host) end end def save_sample path = get_path(ACL_SAMPLE_PATH) unless File.exist?(path) open(path, 'w') { |f| f.print ACL_SAMPLE } end end def get_acl_file path = File.join(@@data[:dir], ACL_DEFAULT_PATH) if File.exist?(path) return path end return nil end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
drbqs-0.0.10 | lib/drbqs/config.rb |
drbqs-0.0.9 | lib/drbqs/config.rb |