class Repository::MemoryRevision

Class responsible for storing files in and retrieving files from memory

Attributes

changed_files[RW]

getter/setters for instance variables

comment[RW]

getter/setters for instance variables

files[RW]

getter/setters for instance variables

files_content[RW]

getter/setters for instance variables

timestamp[RW]

getter/setters for instance variables

user_id[RW]

getter/setters for instance variables

Public Class Methods

new(revision_number) click to toggle source

Constructor

# File lib/repo/memory_repository.rb, line 484
def initialize(revision_number)
  super(revision_number)
  @files = []           # files in this revision (<filename> <RevisionDirectory/RevisionFile>)
  @files_content = {}   # hash: keys => RevisionFile object, value => content
  @user_id = "dummy_user_id"     # user_id, who created this revision
  @comment = "commit_message" # commit-message for this revision
end

Public Instance Methods

__add_directory(dir) click to toggle source

Not (!) part of the AbstractRepository API: A simple helper method to be used to add directories to this revision

# File lib/repo/memory_repository.rb, line 551
def __add_directory(dir)
  __add_file(dir)
end
__add_file(file, content="") click to toggle source

Not (!) part of the AbstractRepository API: A simple helper method to be used to add files to this revision

# File lib/repo/memory_repository.rb, line 530
def __add_file(file, content="")
  @files.push(file)
  if file.instance_of?(RevisionFile)
    @files_content[file.to_s] = content
  end
end
__increment_revision_number() click to toggle source

Not (!) part of the AbstractRepository API: A simple helper method to be used to increment the revision number

# File lib/repo/memory_repository.rb, line 557
def __increment_revision_number()
  @revision_number += 1
end
__replace_file_content(file, new_content) click to toggle source

Not (!) part of the AbstractRepository API: A simple helper method to be used to replace the content of a file

# File lib/repo/memory_repository.rb, line 540
def __replace_file_content(file, new_content)
  if file.instance_of?(RevisionFile)
    @files_content[file.to_s] = new_content
  else
    raise "Expected file to be of type RevisionFile"
  end
end
changed_files_at_path(path) click to toggle source
# File lib/repo/memory_repository.rb, line 523
def changed_files_at_path(path)
  return files_at_path_helper(path, true)
end
directories_at_path(path="/") click to toggle source
# File lib/repo/memory_repository.rb, line 518
def directories_at_path(path="/")
  return Hash.new if @files.empty?
  return files_at_path_helper(path, false, RevisionDirectory)
end
files_at_path(path="/") click to toggle source

Return all of the files in this repository at the root directory

# File lib/repo/memory_repository.rb, line 507
def files_at_path(path="/")
  return Hash.new if @files.empty?
  return files_at_path_helper(path)
end
path_exists?(path) click to toggle source

Returns true if and only if path exists in files and path is a directory

# File lib/repo/memory_repository.rb, line 493
def path_exists?(path)
  if path == "/"
    return true # the root in a repository always exists
  end
  @files.each do |object|
    object_fqpn = File.join(object.path, object.name) # fqpn is: fully qualified pathname :-)
    if object_fqpn == path
      return true
    end
  end
  return false
end
revision_at_path(path) click to toggle source

Return true if there was files submitted at the desired path for the revision

# File lib/repo/memory_repository.rb, line 513
def revision_at_path(path)
  return false if @files.empty?
  return revision_at_path_helper(path)
end