Class: Piston::Revision
- Inherits:
-
Object
- Object
- Piston::Revision
- Includes:
- Enumerable
- Defined in:
- lib/piston/revision.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#dir ⇒ Object
readonly
Returns the value of attribute dir.
-
#recalled_values ⇒ Object
readonly
Returns the value of attribute recalled_values.
-
#repository ⇒ Object
readonly
Returns the value of attribute repository.
-
#revision ⇒ Object
readonly
Returns the value of attribute revision.
Class Method Summary collapse
Instance Method Summary collapse
-
#checkout_to(dir) ⇒ Object
Retrieve a copy of this repository into
dir
. -
#copy_from(abspath, relpath) ⇒ Object
Copies
abspath
(an absolute path) torelpath
(relative to ourselves). -
#copy_to(relpath, abspath) ⇒ Object
Copies
relpath
(relative to ourselves) toabspath
(an absolute path). -
#each ⇒ Object
Yields each file of this revision in turn to our caller.
- #exclude_for_diff ⇒ Object
-
#initialize(repository, revision, recalled_values = {}) ⇒ Revision
constructor
A new instance of Revision.
- #inspect ⇒ Object
- #logger ⇒ Object
- #name ⇒ Object
-
#remember_values ⇒ Object
What values does this revision want to remember for the future ?.
- #remotely_modified ⇒ Object
- #to_s ⇒ Object
-
#update_to(to, lock) ⇒ Object
Update a copy of this repository to revision
to
. - #url ⇒ Object
Constructor Details
#initialize(repository, revision, recalled_values = {}) ⇒ Revision
Returns a new instance of Revision.
13 14 15 |
# File 'lib/piston/revision.rb', line 13 def initialize(repository, revision, recalled_values={}) @repository, @revision, @recalled_values = repository, revision, recalled_values end |
Instance Attribute Details
#dir ⇒ Object (readonly)
Returns the value of attribute dir.
11 12 13 |
# File 'lib/piston/revision.rb', line 11 def dir @dir end |
#recalled_values ⇒ Object (readonly)
Returns the value of attribute recalled_values.
11 12 13 |
# File 'lib/piston/revision.rb', line 11 def recalled_values @recalled_values end |
#repository ⇒ Object (readonly)
Returns the value of attribute repository.
11 12 13 |
# File 'lib/piston/revision.rb', line 11 def repository @repository end |
#revision ⇒ Object (readonly)
Returns the value of attribute revision.
11 12 13 |
# File 'lib/piston/revision.rb', line 11 def revision @revision end |
Class Method Details
.logger ⇒ Object
6 7 8 |
# File 'lib/piston/revision.rb', line 6 def logger @@logger ||= Log4r::Logger["handler"] end |
Instance Method Details
#checkout_to(dir) ⇒ Object
Retrieve a copy of this repository into dir
.
38 39 40 41 |
# File 'lib/piston/revision.rb', line 38 def checkout_to(dir) logger.debug {"Checking out #{@repository}@#{@revision} into #{dir}"} @dir = dir.kind_of?(Pathname) ? dir : Pathname.new(dir) end |
#copy_from(abspath, relpath) ⇒ Object
Copies abspath
(an absolute path) to relpath
(relative to ourselves).
67 68 69 70 71 72 73 |
# File 'lib/piston/revision.rb', line 67 def copy_from(abspath, relpath) raise ArgumentError, "Revision #{revision} of #{repository.url} was never checked out -- can't iterate over files" unless @dir target = @dir + relpath Pathname.new(target).dirname.mkpath FileUtils.copy_entry(abspath, target) unless abspath.symlink? end |
#copy_to(relpath, abspath) ⇒ Object
Copies relpath
(relative to ourselves) to abspath
(an absolute path).
59 60 61 62 63 64 |
# File 'lib/piston/revision.rb', line 59 def copy_to(relpath, abspath) raise ArgumentError, "Revision #{revision} of #{repository.url} was never checked out -- can't iterate over files" unless @dir Pathname.new(abspath).dirname.mkpath FileUtils.copy_entry(@dir + relpath, abspath) unless abspath.symlink? end |
#each ⇒ Object
Yields each file of this revision in turn to our caller.
55 56 |
# File 'lib/piston/revision.rb', line 55 def each end |
#exclude_for_diff ⇒ Object
79 80 81 |
# File 'lib/piston/revision.rb', line 79 def exclude_for_diff raise SubclassResponsibilityError, "Piston::Revision#exclude_for_diff should be implemented by a subclass." end |
#inspect ⇒ Object
33 34 35 |
# File 'lib/piston/revision.rb', line 33 def inspect "Piston::Revision(#{@repository.url}@#{@revision})" end |
#logger ⇒ Object
25 26 27 |
# File 'lib/piston/revision.rb', line 25 def logger self.class.logger end |
#name ⇒ Object
21 22 23 |
# File 'lib/piston/revision.rb', line 21 def name @revision end |
#remember_values ⇒ Object
What values does this revision want to remember for the future ?
49 50 51 52 |
# File 'lib/piston/revision.rb', line 49 def remember_values logger.debug {"Generating remember values"} {} end |
#remotely_modified ⇒ Object
75 76 77 |
# File 'lib/piston/revision.rb', line 75 def remotely_modified raise SubclassResponsibilityError, "Piston::Revision#remotely_modified should be implemented by a subclass." end |
#to_s ⇒ Object
29 30 31 |
# File 'lib/piston/revision.rb', line 29 def to_s "revision #{@revision}" end |
#update_to(to, lock) ⇒ Object
Update a copy of this repository to revision to
.
44 45 46 |
# File 'lib/piston/revision.rb', line 44 def update_to(to, lock) raise SubclassResponsibilityError, "Piston::Revision#update_to should be implemented by a subclass." end |
#url ⇒ Object
17 18 19 |
# File 'lib/piston/revision.rb', line 17 def url repository.url end |