This repository has been archived by the owner on Mar 19, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
166 additions
and
171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/main/scala/com/atomist/rug/kind/core/ChangeCounting.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.atomist.rug.kind.core | ||
|
||
/** | ||
* Extended by classes with | ||
* versioned backing objects | ||
*/ | ||
trait ChangeCounting { | ||
|
||
/** | ||
* | ||
* @return the number of revisions of this object. 0 means it has not | ||
* been changed | ||
*/ | ||
def changeCount: Int | ||
|
||
def dirty: Boolean = changeCount > 0 | ||
|
||
} |
32 changes: 32 additions & 0 deletions
32
src/main/scala/com/atomist/rug/kind/core/ChangeLogging.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.atomist.rug.kind.core | ||
|
||
import com.atomist.rug.spi.ExportFunction | ||
|
||
case class ChangeLogEntry[S]( | ||
comment: String, | ||
resultState: S | ||
) | ||
|
||
/** | ||
* Extended by classes modeling mutable objects that undergo deliberate change | ||
*/ | ||
trait ChangeLogging[S] { | ||
|
||
private var _changeLogEntries: Seq[ChangeLogEntry[S]] = Seq() | ||
|
||
protected def currentBackingObject: S | ||
|
||
/** | ||
* Describe a change we've made to this resource. | ||
* Does not necessarily map 1:1 to versions as in changeCount | ||
* @param comment message describing what we've done | ||
*/ | ||
@ExportFunction(readOnly = false, description = "Describe a change we made to this object") | ||
def describeChange(comment: String): Unit = { | ||
val le = new ChangeLogEntry[S](comment, currentBackingObject) | ||
_changeLogEntries = _changeLogEntries :+ le | ||
} | ||
|
||
def changeLogEntries: Seq[ChangeLogEntry[S]] = _changeLogEntries | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.