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.
131 132 133 |
# File 'lib/rscm/revision.rb', line 131 def initialize(files=[]) @files = files end |
Instance Attribute Details
#developer ⇒ Object
Returns the value of attribute developer.
127 128 129 |
# File 'lib/rscm/revision.rb', line 127 def developer @developer end |
#files ⇒ Object (readonly)
Returns the value of attribute files.
125 126 127 |
# File 'lib/rscm/revision.rb', line 125 def files @files end |
#identifier ⇒ Object
Returns the value of attribute identifier.
126 127 128 |
# File 'lib/rscm/revision.rb', line 126 def identifier @identifier end |
#message ⇒ Object
Returns the value of attribute message.
128 129 130 |
# File 'lib/rscm/revision.rb', line 128 def @message end |
#time ⇒ Object
Returns the value of attribute time.
129 130 131 |
# File 'lib/rscm/revision.rb', line 129 def time @time end |
Instance Method Details
#<<(file) ⇒ Object
140 141 142 143 144 145 146 147 148 |
# File 'lib/rscm/revision.rb', line 140 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
183 184 185 |
# File 'lib/rscm/revision.rb', line 183 def <=>(other) @time <=> other.time end |
#==(other) ⇒ Object
174 175 176 177 178 179 180 181 |
# File 'lib/rscm/revision.rb', line 174 def ==(other) other.is_a?(self.class) && @developer == other.developer && @identifier == other.identifier && @message == other. && @time == other.time && @files == other.files end |
#[](index) ⇒ Object
150 151 152 |
# File 'lib/rscm/revision.rb', line 150 def [] (index) @files[index] end |
#accept(visitor) ⇒ Object
135 136 137 138 |
# File 'lib/rscm/revision.rb', line 135 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.
189 190 191 192 193 |
# File 'lib/rscm/revision.rb', line 189 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
155 156 157 |
# File 'lib/rscm/revision.rb', line 155 def each(&block) @files.each(&block) end |
#length ⇒ Object Also known as: size
163 164 165 |
# File 'lib/rscm/revision.rb', line 163 def length @files.length end |
#pop ⇒ Object
159 160 161 |
# File 'lib/rscm/revision.rb', line 159 def pop @files.pop end |
#to_s ⇒ Object
String representation that can be used for debugging.
196 197 198 199 200 201 202 |
# File 'lib/rscm/revision.rb', line 196 def to_s result = "#{identifier} | #{developer} | #{time} | #{}\n" self.each do |file| result << " " << file.to_s << "\n" end result end |