class QED::Settings

Settings ecapsulates setup configuration for running QED.

Constants

DEFAULT_FILES

If files are not specified than these directories will be searched.

OMIT_PATHS

Directory names to omit from automatic selection.

Attributes

format[RW]

Output format.

loadpath[RW]

Paths to be added to $LOAD_PATH.

mode[RW]

Parse mode.

omit[RW]

File patterns to omit.

requires[RW]

Libraries to be required.

rooted[RW]

Operate from project root?

rootless[RW]

Operate from system temporary directory?

trace[RW]

Trace execution?

Public Class Methods

new(options={}, &block) click to toggle source

Initialize new Settings instance.

# File lib/qed/settings.rb, line 23
def initialize(options={}, &block)
  initialize_defaults

  @profile = (options.delete(:profile) || default_profile).to_s

  load_profile(&block)

  options.each do |key, val|
    send("#{key}=", val) if val
  end
end

Public Instance Methods

clear_directory() click to toggle source

Remove and recreate temporary working directory.

# File lib/qed/settings.rb, line 158
def clear_directory
  FileUtils.rm_r(tmpdir) if File.exist?(tmpdir)
  FileUtils.mkdir_p(tmpdir)
end
default_profile() click to toggle source

Profile name can come from ‘profile` or `p` environment variables.

# File lib/qed/settings.rb, line 51
def default_profile
  ENV['profile'] || ENV['p'] || 'default'
end
files() click to toggle source

Demonstration files (or globs).

# File lib/qed/settings.rb, line 56
def files
  @files ||= (
    [DEFAULT_FILES.find{ |d| File.directory?(d) }].compact
  )
end
files=(files) click to toggle source
# File lib/qed/settings.rb, line 63
def files=(files)
  @files = (
    if files.nil? or files.empty?
      nil
    else
      Array(files).flatten.compact
    end
  )
end
initialize_defaults() click to toggle source

Initialize default settings.

# File lib/qed/settings.rb, line 38
def initialize_defaults
  @files    = nil #DEFAULT_FILES
  @format   = :dot
  @trace    = false
  @mode     = nil  # ?
  @loadpath = ['lib']
  @omit     = OMIT_PATHS
  @rootless = false
  @requires = []
  #@profile  = :default
end
load_profile(&block) click to toggle source

Load QED configuration profile. The load procedure is stored as a Proc object in a hash b/c different configuration systems can be used.

# File lib/qed/settings.rb, line 102
def load_profile(&block)
  config = QED.profiles[@profile]
  config.call(self) if config
end
profiles() click to toggle source

Profiles are collected from the RC library, unless RC is deactivated via the override file.

# File lib/qed/settings.rb, line 111
def profiles
  QED.profiles.keys
end
root() click to toggle source

Project’s root directory.

# File lib/qed/settings.rb, line 125
def root
  Utils.root
end
Also aliased as: root_directory
root_directory()

Alias for ‘#root`.

Alias for: root
rootless?() click to toggle source

Operate relative to project root directory, or use system’s location.

# File lib/qed/settings.rb, line 118
def rootless?
  @rootless
end
temporary_directory() click to toggle source

Temporary directory. If ‘#rootless?` return true then this will be a system’s temporary directory (e.g. ‘/tmp/qed/foo/20111117242323/`). Otherwise, it will local to the project’s root int ‘tmp/qed/`.

# File lib/qed/settings.rb, line 139
def temporary_directory
  @temporary_directory ||= (
    if rootless?
      Utils.system_tmpdir
    else
      File.join(root_directory, 'tmp', 'qed')
    end
    #FileUtils.mkdir_p(dir) unless File.directory?(dir)
  )
end
Also aliased as: tmpdir
tmpdir()

Shorthand for ‘#temporary_directory`.

Alias for: temporary_directory