Small enhancements to libpit to facilitate pit-swing.
Added delete() and createNewProject(String) to Project class. Added nicer toString() method to Category enum.
This commit is contained in:
@ -8,9 +8,11 @@ public enum Category {
|
||||
|
||||
public static Category toCategory(String s) {
|
||||
for(c in Category.values())
|
||||
if (c.toString().startsWith(s.toUpperCase())) return c
|
||||
if (c.name().startsWith(s.toUpperCase())) return c
|
||||
throw new IllegalArgumentException("No category matches ${s}.")
|
||||
}
|
||||
|
||||
public String getSymbol() { toString()[0].toLowerCase() }
|
||||
|
||||
public String toString() { return "${name()[0]}${name()[1..-1].toLowerCase()}" }
|
||||
}
|
||||
|
@ -36,6 +36,11 @@ public class FileIssue extends Issue {
|
||||
|
||||
public String getFilename() { return makeFilename(id, category, priority) }
|
||||
|
||||
public void setText(String text) {
|
||||
super.setText(text)
|
||||
source.write(text)
|
||||
}
|
||||
|
||||
public static boolean isValidFilename(String name) {
|
||||
return name ==~ /(\d+)([bcft])(\d).*/
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ class FileProject extends Project {
|
||||
protected File source
|
||||
|
||||
public FileProject(File dir) {
|
||||
super(dir.name)
|
||||
super(dir.canonicalFile.name)
|
||||
|
||||
if (!dir.isDirectory())
|
||||
throw new IllegalArgumentException(
|
||||
@ -65,6 +65,15 @@ class FileProject extends Project {
|
||||
return issue
|
||||
}
|
||||
|
||||
public FileProject createNewProject(String name) {
|
||||
def newDir = new File(source, name)
|
||||
newDir.mkdirs()
|
||||
|
||||
return new FileProject(newDir)
|
||||
}
|
||||
|
||||
public boolean delete() { return source.delete() }
|
||||
|
||||
@Override
|
||||
public String toString() { return name }
|
||||
|
||||
|
@ -30,4 +30,8 @@ public abstract class Project {
|
||||
String toString() { return name }
|
||||
|
||||
public abstract Issue createNewIssue(Map options)
|
||||
|
||||
public abstract Project createNewProject(String name)
|
||||
|
||||
public abstract boolean delete()
|
||||
}
|
||||
|
Reference in New Issue
Block a user