Sha256: d3bfea9d4af384b182f189421488db65461cbec71fc9ee75cbdb295537b22f9f

Contents?: true

Size: 931 Bytes

Versions: 1

Compression:

Stored size: 931 Bytes

Contents

require 'fileutils'
require 'singleton'

module DRbQS

  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 check_directory_create
        unless File.exist?(@@data[:dir])
          FileUtils.mkdir_p(@@data[:dir])
          FileUtils.chmod(0700, @@data[:dir])
        end
      end

      def save_sample
        path = get_path('acl.txt.sample')
        unless File.exist?(path)
          open(path, 'w') { |f| f.print ACL_SAMPLE }
        end
      end

      def get_acl_file
        path = File.join(@@data[:dir], 'acl.txt')
        if File.exist?(path)
          return path
        end
        return nil
      end
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
drbqs-0.0.8 lib/drbqs/config.rb