Class: Subtrigger::Revision
- Inherits:
-
Object
- Object
- Subtrigger::Revision
- Defined in:
- lib/subtrigger/revision.rb
Overview
A simple wrapper around the output of Subversion’s svnlook command.
This class will let you make simple queries against the properties of a Subversion revision. It parses its output into keys and values so you can perform operations on them.
Attributes
It knows about the following attributes:
-
Revision number
-
Author
-
Timestamp
-
Log message
-
changed directories
This works by passing in the number of the revision to use, the raw output of svnlook info and the raw output of svnlook dirs-changed.
Special attributes
Revision knows about changed projects. This is extracted from the list of changed directories. A project is a directory that is directly above a directory named trunk, branches or tags. So when a directory /internal/accounting/trunk is changed, the project /internal/accounting is reported.
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
the parsed Hash of attributes for this revision.
-
#dirs_changed ⇒ Object
readonly
A list of all directories that were changed in this revision.
-
#raw ⇒ Object
readonly
The raw output of the svnlook command.
Instance Method Summary collapse
-
#initialize(revision_number, info, dirs_changed) ⇒ Revision
constructor
A new instance of Revision.
-
#projects ⇒ Array<String>
Creates a list of directory paths in the repository that have changes and contain a
trunk,branchesortagsdirectory.
Constructor Details
#initialize(revision_number, info, dirs_changed) ⇒ Revision
Returns a new instance of Revision.
56 57 58 59 60 61 |
# File 'lib/subtrigger/revision.rb', line 56 def initialize(revision_number, info, dirs_changed) @attributes = { :number => revision_number.to_i } @raw = info @dirs_changed = dirs_changed.split parse end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
the parsed Hash of attributes for this revision
54 55 56 |
# File 'lib/subtrigger/revision.rb', line 54 def attributes @attributes end |
#dirs_changed ⇒ Object (readonly)
A list of all directories that were changed in this revision
51 52 53 |
# File 'lib/subtrigger/revision.rb', line 51 def dirs_changed @dirs_changed end |
#raw ⇒ Object (readonly)
The raw output of the svnlook command.
48 49 50 |
# File 'lib/subtrigger/revision.rb', line 48 def raw @raw end |
Instance Method Details
#projects ⇒ Array<String>
Creates a list of directory paths in the repository that have changes and contain a trunk, branches or tags directory.
For example, a changed path in like /topdir/project_name/trunk would result in /topdir/project_name.
77 78 79 80 81 82 |
# File 'lib/subtrigger/revision.rb', line 77 def projects pattern = /\/(trunk|branches|tags)/ dirs_changed.grep(pattern).map do |dir| dir.split(pattern, 2).first end.uniq end |