Class: RSCM::HistoricFile
- Inherits:
-
Object
- Object
- RSCM::HistoricFile
- Defined in:
- lib/rscm/historic_file.rb
Overview
Represents the full history of a single file or directory.
Instance Attribute Summary collapse
-
#relative_path ⇒ Object
readonly
Returns the value of attribute relative_path.
Instance Method Summary collapse
- #directory? ⇒ Boolean
-
#initialize(relative_path, directory, scm) ⇒ HistoricFile
constructor
A new instance of HistoricFile.
-
#revision_files(options = {}) ⇒ Object
Returns an Array of RevisionFile - from Time.epoch until Time.infinity (now).
Constructor Details
#initialize(relative_path, directory, scm) ⇒ HistoricFile
Returns a new instance of HistoricFile.
6 7 8 9 |
# File 'lib/rscm/historic_file.rb', line 6 def initialize(relative_path, directory, scm) raise "Not a String: '#{relative_path}' (#{relative_path.class.name})" unless relative_path.is_a? String @relative_path, @directory, @scm = relative_path, directory, scm end |
Instance Attribute Details
#relative_path ⇒ Object (readonly)
Returns the value of attribute relative_path.
4 5 6 |
# File 'lib/rscm/historic_file.rb', line 4 def relative_path @relative_path end |
Instance Method Details
#directory? ⇒ Boolean
11 12 13 |
# File 'lib/rscm/historic_file.rb', line 11 def directory? @directory end |
#revision_files(options = {}) ⇒ Object
Returns an Array of RevisionFile - from Time.epoch until Time.infinity (now)
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rscm/historic_file.rb', line 16 def revision_files(={}) @scm.revisions(Time.epoch, .dup.merge({:to_identifier => Time.infinity, :relative_path => @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.eql?(@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 |