Class: RSCM::RevisionFile

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

Overview

Represents a file within a Revision, and also information about how this file was modified compared with the previous revision.

Constant Summary collapse

MODIFIED =
"MODIFIED"
DELETED =
"DELETED"
ADDED =
"ADDED"
MOVED =
"MOVED"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path = nil, status = nil, developer = nil, message = nil, native_revision_identifier = nil, time = nil) ⇒ RevisionFile

Returns a new instance of RevisionFile.



34
35
36
# File 'lib/rscm/revision_file.rb', line 34

def initialize(path=nil, status=nil, developer=nil, message=nil, native_revision_identifier=nil, time=nil)
  @path, @developer, @message, @native_revision_identifier, @time, @status = path, developer, message, native_revision_identifier, time, status
end

Instance Attribute Details

#developerObject

The developer who modified this file



26
27
28
# File 'lib/rscm/revision_file.rb', line 26

def developer
  @developer
end

#messageObject

The commit message for this file



29
30
31
# File 'lib/rscm/revision_file.rb', line 29

def message
  @message
end

#native_revision_identifierObject

The native SCM’s revision for this file. For non-transactional SCMs this is different from the parent Revision’s



23
24
25
# File 'lib/rscm/revision_file.rb', line 23

def native_revision_identifier
  @native_revision_identifier
end

#pathObject

Relative path from the root of the RSCM::Base instance



15
16
17
# File 'lib/rscm/revision_file.rb', line 15

def path
  @path
end

#previous_native_revision_identifierObject

The native SCM’s previous revision for this file. For non-transactional SCMs this is different from the parent Revision’s



19
20
21
# File 'lib/rscm/revision_file.rb', line 19

def previous_native_revision_identifier
  @previous_native_revision_identifier
end

#statusObject

MODIFIED, DELETED, ADDED or MOVED



12
13
14
# File 'lib/rscm/revision_file.rb', line 12

def status
  @status
end

#timeObject

This is a UTC ruby time



32
33
34
# File 'lib/rscm/revision_file.rb', line 32

def time
  @time
end

Instance Method Details

#==(other) ⇒ Object



59
60
61
62
63
64
65
66
# File 'lib/rscm/revision_file.rb', line 59

def ==(other)
  return false if !other.is_a?(self.class)
  self.path == other.path &&
  self.developer == other.developer &&
  self.message == other.message &&
  self.native_revision_identifier == other.native_revision_identifier &&
  self.time == other.time
end

#accept(visitor) ⇒ Object

Accepts a visitor that must respond to visit_file(revision_file)



50
51
52
# File 'lib/rscm/revision_file.rb', line 50

def accept(visitor)
  visitor.visit_file(self)
end

#diff(scm, options = {}, &block) ⇒ Object

Yields the diff as an IO for this file



45
46
47
# File 'lib/rscm/revision_file.rb', line 45

def diff(scm, options={}, &block)
  scm.diff(self, options, &block)
end

#open(scm, options = {}, &block) ⇒ Object

Returns/yields an IO containing the contents of this file, using the scm this file lives in.



40
41
42
# File 'lib/rscm/revision_file.rb', line 40

def open(scm, options={}, &block) #:yield: io
  scm.open(self, options, &block)
end

#to_sObject

A simple string representation. Useful for debugging.



55
56
57
# File 'lib/rscm/revision_file.rb', line 55

def to_s
  "#{path} | #{native_revision_identifier}"
end