Class: RSCM::RevisionFile
- Inherits:
-
Object
- Object
- RSCM::RevisionFile
- 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
-
#developer ⇒ Object
The developer who modified this file.
-
#message ⇒ Object
The commit message for this file.
-
#native_revision_identifier ⇒ Object
The native SCM’s revision for this file.
-
#path ⇒ Object
Relative path from the root of the RSCM::Base instance.
-
#previous_native_revision_identifier ⇒ Object
The native SCM’s previous revision for this file.
-
#status ⇒ Object
MODIFIED, DELETED, ADDED or MOVED.
-
#time ⇒ Object
This is a UTC ruby time.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#accept(visitor) ⇒ Object
Accepts a visitor that must respond to visit_file(revision_file).
-
#diff(scm, options = {}, &block) ⇒ Object
Yields the diff as an IO for this file.
-
#initialize(path = nil, status = nil, developer = nil, message = nil, native_revision_identifier = nil, time = nil) ⇒ RevisionFile
constructor
A new instance of RevisionFile.
-
#open(scm, options = {}, &block) ⇒ Object
Returns/yields an IO containing the contents of this file, using the
scm
this file lives in. -
#to_s ⇒ Object
A simple string representation.
-
#to_yaml_properties ⇒ Object
:nodoc:.
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, =nil, native_revision_identifier=nil, time=nil) @path, @developer, @message, @native_revision_identifier, @time, @status = path, developer, , native_revision_identifier, time, status end |
Instance Attribute Details
#developer ⇒ Object
The developer who modified this file
26 27 28 |
# File 'lib/rscm/revision_file.rb', line 26 def developer @developer end |
#message ⇒ Object
The commit message for this file
29 30 31 |
# File 'lib/rscm/revision_file.rb', line 29 def @message end |
#native_revision_identifier ⇒ Object
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 |
#path ⇒ Object
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_identifier ⇒ Object
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 |
#status ⇒ Object
MODIFIED, DELETED, ADDED or MOVED
12 13 14 |
# File 'lib/rscm/revision_file.rb', line 12 def status @status end |
#time ⇒ Object
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
74 75 76 77 78 79 80 81 82 |
# File 'lib/rscm/revision_file.rb', line 74 def ==(other) return false if !other.is_a?(self.class) self.status == other.status && self.path == other.path && self.developer == other.developer && self. == other. && 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)
65 66 67 |
# File 'lib/rscm/revision_file.rb', line 65 def accept(visitor) visitor.visit_file(self) end |
#diff(scm, options = {}, &block) ⇒ Object
Yields the diff as an IO for this file
54 55 56 57 58 59 60 61 62 |
# File 'lib/rscm/revision_file.rb', line 54 def diff(scm, ={}, &block) from_to = case status when /#{RevisionFile::MODIFIED}/; [previous_native_revision_identifier, native_revision_identifier] when /#{RevisionFile::DELETED}/; [previous_native_revision_identifier, nil] when /#{RevisionFile::ADDED}/; [nil, native_revision_identifier] end scm.diff(path, from_to[0], from_to[1], , &block) end |
#open(scm, options = {}, &block) ⇒ Object
Returns/yields an IO containing the contents of this file, using the scm
this file lives in.
49 50 51 |
# File 'lib/rscm/revision_file.rb', line 49 def open(scm, ={}, &block) #:yield: io scm.open(path, native_revision_identifier, , &block) end |
#to_s ⇒ Object
A simple string representation. Useful for debugging.
70 71 72 |
# File 'lib/rscm/revision_file.rb', line 70 def to_s "#{path} | #{native_revision_identifier}" end |
#to_yaml_properties ⇒ Object
:nodoc:
38 39 40 41 42 43 44 45 |
# File 'lib/rscm/revision_file.rb', line 38 def to_yaml_properties #:nodoc: # We remove properties that are duplicated in the parent revision. props = instance_variables props.delete("@developer") props.delete("@message") props.delete("@time") props.sort! end |