Class RSCM::Revisions
In: lib/rscm/revision.rb
Parent: Object

A collection of Revision.

Methods

==   []   accept   add   developers   each   empty?   latest   length   new   push   reverse   sort!  

Included Modules

Enumerable

Attributes

revisions  [RW] 

Public Class methods

[Source]

    # File lib/rscm/revision.rb, line 12
12:     def initialize(revisions=[])
13:       @revisions = revisions
14:     end

Public Instance methods

[Source]

    # File lib/rscm/revision.rb, line 47
47:     def ==(other)
48:       return false if !other.is_a?(self.class)
49:       @revisions == other.revisions
50:     end

[Source]

    # File lib/rscm/revision.rb, line 29
29:     def [](file)
30:       @revisions[file]
31:     end

Accepts a visitor that will receive callbacks while iterating over this instance’s internal structure. The visitor should respond to the following methods:

  • visit_revisions(revisions)
  • visit_revision(revision)
  • visit_file(file)

[Source]

    # File lib/rscm/revision.rb, line 24
24:     def accept(visitor)
25:       visitor.visit_revisions(self)
26:       self.each{|revision| revision.accept(visitor)}
27:     end

Adds a File or a Revision. If the argument is a File and no corresponding Revision exists, a new Revision is created, added, and the File is added to that Revision - and then finally the newly created Revision is returned. Otherwise nil is returned.

[Source]

    # File lib/rscm/revision.rb, line 80
80:     def add(file_or_revision)
81:       if(file_or_revision.is_a?(Revision))
82:         @revisions << file_or_revision
83:         return file_or_revision
84:       else
85:         revision = @revisions.find { |a_revision| a_revision.can_contain?(file_or_revision) }
86:         if(revision.nil?)
87:           revision = Revision.new
88:           @revisions << revision
89:           revision << file_or_revision
90:           return revision
91:         end
92:         revision << file_or_revision
93:         return nil
94:       end
95:     end

The set of developers that contributed to all of the contained Revision s.

[Source]

    # File lib/rscm/revision.rb, line 57
57:     def developers
58:       result = []
59:       each do |revision|
60:         result << revision.developer unless result.index(revision.developer)
61:       end
62:       result
63:     end

[Source]

    # File lib/rscm/revision.rb, line 33
33:     def each(&block)
34:       @revisions.each(&block)
35:     end

[Source]

    # File lib/rscm/revision.rb, line 52
52:     def empty?
53:       @revisions.empty?
54:     end

The latest Revision (with the latest time) or nil if there are none.

[Source]

    # File lib/rscm/revision.rb, line 67
67:     def latest
68:       result = nil
69:       each do |revision|
70:         result = revision if result.nil? || result.time < revision.time
71:       end
72:       result
73:     end

[Source]

    # File lib/rscm/revision.rb, line 43
43:     def length
44:       @revisions.length
45:     end

[Source]

     # File lib/rscm/revision.rb, line 97
 97:     def push(*file_or_revisions)
 98:       file_or_revisions.each { |file_or_revision| self << (file_or_revision) }
 99:       self
100:     end

[Source]

    # File lib/rscm/revision.rb, line 37
37:     def reverse
38:       r = clone
39:       r.revisions = @revisions.dup.reverse
40:       r
41:     end

Sorts the revisions according to time

[Source]

     # File lib/rscm/revision.rb, line 103
103:     def sort!
104:       @revisions.sort!
105:       self
106:     end

[Validate]