Parent

Visage::Config::File

Public Class Methods

find(filename, opts={}) click to toggle source
# File lib/visage-app/config/file.rb, line 15
def self.find(filename, opts={})
  range = opts[:ignore_bundled] ? (0..-2) : (0..-1)
  potential_filenames = @@config_directories[range].map {|d| d.join(filename)}
  potential_filenames.find { |f| ::File.exists?(f) }
end
load(filename, opts={}) click to toggle source
# File lib/visage-app/config/file.rb, line 21
def self.load(filename, opts={})
  if not path = self.find(filename, opts)
    if opts[:create]
      path = @@config_directories.first.join(filename)
      begin
        FileUtils.touch(path)
      rescue Errno::EACCES => e
        raise Errno::EACCES, "Couldn't write #{path}. Do you have CONFIG_PATH set?"
      end
    end
  end

  YAML::load_file(path)
end
new(filename, opts={}) click to toggle source
# File lib/visage-app/config/file.rb, line 43
def initialize(filename, opts={})
  if not ::File.exists?(filename)
    path = @@config_directories.first.join(filename)
    FileUtils.touch(path)
  end
  @file = ::File.open(filename, 'r+')
end
open(filename, &block) click to toggle source
# File lib/visage-app/config/file.rb, line 36
def self.open(filename, &block)
  path = self.find(filename)
  ::File.open(path, 'r+') do |f|
    block.call(f)
  end
end

Public Instance Methods

to_s() click to toggle source
# File lib/visage-app/config/file.rb, line 51
def to_s
  @file.path
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.