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

A Revisions object is a collection of Revision objects with some additional behaviour.

Most importantly, it provides logic to group individual RevisionFile objects into Revision objects internally. This means that implementors of RSCM adapters that don’t support atomic changesets can still emulate them, simply by adding RevisionFile objects to a Revisions object. Example:

  revisions = Revisions.new
  revisions.add revision_file_1
  revisions.add revision_file_2
  revisions.add revision_file_3

The added RevisionFile objects will end up in Revision objects grouped by their comment, developer and timestamp. A set of RevisionFile object with identical developer and message will end up in the same Revision provided their time attributes are a minute apart or less.

Each Revisions object also has an attribute cmd which should contain the command used to retrieve the revision data and populate it. This is useful for debugging an RSCM adapter that might behaving incorrectly. Keep in mind that it is the responsibility of each RSCM adapter implementation to set this attribute, and that it should omit setting it if the store_revisions_command is true

Methods

==   []   add   each   empty?   length   new   sort!   to_s  

Included Modules

Enumerable

Attributes

cmd  [RW] 

Public Class methods

[Source]

    # File lib/rscm/revisions.rb, line 34
34:     def initialize(revisions=[])
35:       @revisions = revisions
36:     end

Public Instance methods

[Source]

    # File lib/rscm/revisions.rb, line 59
59:     def ==(other)
60:       self.to_s == other.to_s
61:     end

[Source]

    # File lib/rscm/revisions.rb, line 67
67:     def [](n)
68:       @revisions[n]
69:     end

[Source]

    # File lib/rscm/revisions.rb, line 38
38:     def add(file_or_revision)
39:       if(file_or_revision.is_a?(Revision))
40:         @revisions << file_or_revision
41:       else
42:         revision = find { |a_revision| a_revision.accept?(file_or_revision) }
43:         if(revision.nil?)
44:           revision = Revision.new
45:           @revisions << revision
46:         end
47:         revision.add file_or_revision
48:       end
49:     end

[Source]

    # File lib/rscm/revisions.rb, line 63
63:     def each(&block)
64:       @revisions.each(&block)
65:     end

[Source]

    # File lib/rscm/revisions.rb, line 75
75:     def empty?
76:       @revisions.empty?
77:     end

[Source]

    # File lib/rscm/revisions.rb, line 71
71:     def length
72:       @revisions.length
73:     end

[Source]

    # File lib/rscm/revisions.rb, line 51
51:     def sort!
52:       @revisions.sort!{|r1,r2| r1.time<=>r2.time}
53:     end

[Source]

    # File lib/rscm/revisions.rb, line 55
55:     def to_s
56:       @revisions.collect{|revision| revision.to_s}.join("\n-----------")
57:     end

[Validate]