Class: RSCM::HistoricFile

Inherits:
Object
  • Object
show all
Defined in:
lib/rscm/historic_file.rb

Overview

Represents the full history of a single file

Instance Method Summary collapse

Constructor Details

#initialize(relative_path, scm) ⇒ HistoricFile

Returns a new instance of HistoricFile.



4
5
6
# File 'lib/rscm/historic_file.rb', line 4

def initialize(relative_path, scm)
  @relative_path, @scm = relative_path, scm
end

Instance Method Details

#revision_filesObject

Returns an Array of RevisionFile - from Time.epoch until Time.infinity (now)



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/rscm/historic_file.rb', line 9

def revision_files
  @scm.revisions(Time.epoch, Time.infinity, @relative_path).collect do |revision|
    if revision.files.length != 1
      files_s = revision.files.collect{|f| f.to_s}.join("\n")
      raise "The file-specific revision didn't have exactly one file, but #{revision.files.length}:\n#{files_s}"
    end
    if(revision.files[0].path != @relative_path)
      raise "The file-specific revision didn't have expected path #{@relative_path}, but #{revision.files[0].path}"
    end
    revision.files[0]
  end
end