class VCLog::Config

Encapsulates configuration settings for running vclog.

Constants

DEFAULT_GLOB

Default vclog config file glob looks for these possible matches in order:

  • .vclog

  • .config/vclog

  • config/vclog

  • .dot/vclog

  • dot/vclog

File may have optional ‘.rb` extension.

MAP_FILE

If not in a default location a ‘.map` entry can be used to tell vclog where the config file it located.

@example

---
vclog: task/vclog.rb

Attributes

root[R]

Project’s root directory.

Public Class Methods

new(options={}) click to toggle source
# File lib/vclog/config.rb, line 35
def initialize(options={})
  @root    = options[:root]  || lookup_root
  @level   = options[:level] || 0
  @force   = options[:force] || false
  @version = options[:version]
end

Public Instance Methods

file() click to toggle source

The vclog config file.

# File lib/vclog/config.rb, line 97
def file
  if glob = file_map['vclog']
    Dir.glob(glob).first
  else
    Dir.glob(DEFAULT_GLOB).first
  end
end
file_map() click to toggle source

Load the map file.

# File lib/vclog/config.rb, line 117
def file_map
  @file_map ||= (
    map_file ? YAML.load_file(map_file) : {}
  )
end
force?() click to toggle source

Force mode active?

# File lib/vclog/config.rb, line 57
def force?
  @force
end
heuristics() click to toggle source

Load heuristics.

# File lib/vclog/config.rb, line 71
def heuristics
  @heuristics ||= (
    if file
      Heuristics.load(file)
    else
      Heuristics.new
    end
  )
end
level() click to toggle source

Default change level.

# File lib/vclog/config.rb, line 50
def level
  heuristics.level
end
lookup_root() click to toggle source

Find project root. This searches up from the current working directory for a .map configuration file or source control manager directory.

.ruby/
.map
.git/
.hg/
.svn/
_darcs/

If all else fails the current directory is returned.

# File lib/vclog/config.rb, line 137
def lookup_root
  root = nil
  Dir.ascend(Dir.pwd) do |path|
    check = Dir[ROOT_GLOB].first
    if check
      root = path 
      break
    end
  end
  root || Dir.pwd
end
map_file() click to toggle source

Project’s map file, if present.

# File lib/vclog/config.rb, line 108
def map_file
  file = File.join(root, MAP_FILE)
  return file if File.exist?(file)
  return nil
end
vcs_type() click to toggle source

Which version control system?

# File lib/vclog/config.rb, line 84
def vcs_type
  @vcs_type ||= (
    dir = nil
    Dir.chdir(root) do
      dir = Dir.glob("{.git,.hg,.svn,_darcs}").first
    end
    dir[1..-1] if dir
  )
end
version() click to toggle source

Indicates the version of HEAD.

# File lib/vclog/config.rb, line 64
def version
  @version
end