Class: RSCM::Revision
- Inherits:
-
Object
- Object
- RSCM::Revision
- Includes:
- Enumerable
- Defined in:
- lib/rscm/revision.rb
Overview
Represents a collection of File that were committed at the same time. Non-transactional SCMs (such as CVS and StarTeam) emulate Revision by grouping File s that were committed by the same developer, with the same commit message, and within a “reasonably” small timespan.
Instance Attribute Summary collapse
-
#developer ⇒ Object
Returns the value of attribute developer.
-
#files ⇒ Object
readonly
Returns the value of attribute files.
-
#identifier ⇒ Object
Returns the value of attribute identifier.
-
#message ⇒ Object
Returns the value of attribute message.
-
#time ⇒ Object
Returns the value of attribute time.
Instance Method Summary collapse
- #<<(file) ⇒ Object
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object
- #[](index) ⇒ Object
- #accept(visitor) ⇒ Object
-
#can_contain?(file) ⇒ Boolean
Whether this instance can contain a File.
-
#each(&block) ⇒ Object
Iterates over all the RevisionFile objects.
-
#initialize(files = []) ⇒ Revision
constructor
A new instance of Revision.
- #length ⇒ Object (also: #size)
- #pop ⇒ Object
-
#to_s ⇒ Object
String representation that can be used for debugging.
Constructor Details
#initialize(files = []) ⇒ Revision
Returns a new instance of Revision.
123 124 125 |
# File 'lib/rscm/revision.rb', line 123 def initialize(files=[]) @files = files end |
Instance Attribute Details
#developer ⇒ Object
Returns the value of attribute developer.
119 120 121 |
# File 'lib/rscm/revision.rb', line 119 def developer @developer end |
#files ⇒ Object (readonly)
Returns the value of attribute files.
117 118 119 |
# File 'lib/rscm/revision.rb', line 117 def files @files end |
#identifier ⇒ Object
Returns the value of attribute identifier.
118 119 120 |
# File 'lib/rscm/revision.rb', line 118 def identifier @identifier end |
#message ⇒ Object
Returns the value of attribute message.
120 121 122 |
# File 'lib/rscm/revision.rb', line 120 def @message end |
#time ⇒ Object
Returns the value of attribute time.
121 122 123 |
# File 'lib/rscm/revision.rb', line 121 def time @time end |
Instance Method Details
#<<(file) ⇒ Object
132 133 134 135 136 137 138 139 140 |
# File 'lib/rscm/revision.rb', line 132 def << (file) @files << file if(self.time.nil? || self.time < file.time unless file.time.nil?) self.time = file.time self.identifier = self.time if(self.identifier.nil? || self.identifier.is_a?(Time)) end self.developer = file.developer if file.developer self. = file. if file. end |
#<=>(other) ⇒ Object
170 171 172 |
# File 'lib/rscm/revision.rb', line 170 def <=>(other) @time <=> other.time end |
#==(other) ⇒ Object
166 167 168 |
# File 'lib/rscm/revision.rb', line 166 def ==(other) other.is_a?(self.class) && @files == other.files end |
#[](index) ⇒ Object
142 143 144 |
# File 'lib/rscm/revision.rb', line 142 def [] (index) @files[index] end |
#accept(visitor) ⇒ Object
127 128 129 130 |
# File 'lib/rscm/revision.rb', line 127 def accept(visitor) visitor.visit_revision(self) @files.each{|file| file.accept(visitor)} end |
#can_contain?(file) ⇒ Boolean
Whether this instance can contain a File. Used by non-transactional SCMs.
176 177 178 179 180 |
# File 'lib/rscm/revision.rb', line 176 def can_contain?(file) #:nodoc: self.developer == file.developer && self. == file. && (self.time - file.time).abs < 60 end |
#each(&block) ⇒ Object
Iterates over all the RevisionFile objects
147 148 149 |
# File 'lib/rscm/revision.rb', line 147 def each(&block) @files.each(&block) end |
#length ⇒ Object Also known as: size
155 156 157 |
# File 'lib/rscm/revision.rb', line 155 def length @files.length end |
#pop ⇒ Object
151 152 153 |
# File 'lib/rscm/revision.rb', line 151 def pop @files.pop end |
#to_s ⇒ Object
String representation that can be used for debugging.
183 184 185 186 187 188 189 |
# File 'lib/rscm/revision.rb', line 183 def to_s result = "#{identifier} | #{developer} | #{time} | #{}\n" self.each do |file| result << " " << file.to_s << "\n" end result end |