class VCLog::Adapters::Abstract

Abstract base class for all version control system adapters.

Attributes

config[R]
heuristics[R]

Heuristics object.

root[R]

Root location.

Public Class Methods

new(repo) click to toggle source
# File lib/vclog/adapters/abstract.rb, line 31
def initialize(repo)
  @repo       = repo
  @root       = repo.root  
  @heuristics = repo.heuristics

  initialize_framework
end

Public Instance Methods

change_by_date(date) click to toggle source

Return the latest commit as of a given date.

# File lib/vclog/adapters/abstract.rb, line 88
def change_by_date(date)
  list = changes.select{ |c| c.date <= date }
  list.sort_by{ |c| c.date }.last
end
change_points() click to toggle source
# File lib/vclog/adapters/abstract.rb, line 65
def change_points
  @change_points ||= (
    changes.inject([]){ |list, change| list.concat(change.points); list }
  )
end
changes() click to toggle source
# File lib/vclog/adapters/abstract.rb, line 60
def changes
  @changes ||= extract_changes
end
email() click to toggle source

Fallback for email address is ‘ENV`.

# File lib/vclog/adapters/abstract.rb, line 99
def email
  ENV['EMAIL']
end
extract_changes() click to toggle source
# File lib/vclog/adapters/abstract.rb, line 50
def extract_changes
  raise "Not Implemented"
end
extract_tags() click to toggle source
# File lib/vclog/adapters/abstract.rb, line 45
def extract_tags
  raise "Not Implemented"
end
initialize_framework() click to toggle source

This is used if the adapter is using an external library to interface with the repository.

# File lib/vclog/adapters/abstract.rb, line 41
def initialize_framework
end
repository() click to toggle source
# File lib/vclog/adapters/abstract.rb, line 104
def repository
  nil
end
tag?(name) click to toggle source
# File lib/vclog/adapters/abstract.rb, line 72
def tag?(name)
  tags.find{ |t| t.name == name }
end
tags() click to toggle source
# File lib/vclog/adapters/abstract.rb, line 55
def tags
  @tags ||= extract_tags
end
user() click to toggle source

Fallback for user is ‘ENV`.

# File lib/vclog/adapters/abstract.rb, line 94
def user
  ENV['USER']
end
uuid() click to toggle source
# File lib/vclog/adapters/abstract.rb, line 109
def uuid
  nil
end
version() click to toggle source

Returns the current verion string.

# File lib/vclog/adapters/abstract.rb, line 77
def version
  if tags.last
    v = tags[-1].name # TODO: ensure the latest version
    v = tags[-2].name if v == 'HEAD'
  else
    v = '0.0.0'
  end
  return v
end

Private Instance Methods

tempfile(name, content) click to toggle source
# File lib/vclog/adapters/abstract.rb, line 121
def tempfile(name, content)
  mfile = Tempfile.new(name)
  File.open(mfile.path, 'w'){ |f| f << content }
  mfile.path
end
version_tag?(tag_name) click to toggle source
# File lib/vclog/adapters/abstract.rb, line 116
def version_tag?(tag_name)
  /(v|\d)/i =~ tag_name
end