Skip to content

Commit 0f8facb

Browse files
committed
cleanup, prior checkin was missing jar
1 parent a51ac18 commit 0f8facb

5 files changed

Lines changed: 31 additions & 10 deletions

File tree

‎.gitignore‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
*.class
22
bin/*
33
*/bin/*
4+
koans/data
5+
koans/data*

‎koans-lib/src/com/sandwich/koan/cmdline/CommandLineArgument.java‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,15 @@
55
public class CommandLineArgument implements Runnable, Comparable<CommandLineArgument> {
66
private ArgumentType argType;
77
private String value;
8+
boolean isPlantedByApp = false;
89
public CommandLineArgument(ArgumentType argType, String value) {
10+
this(argType, value, false);
11+
}
12+
13+
public CommandLineArgument(ArgumentType argType, String value, boolean isPlantedByApp) {
914
this.argType = argType;
1015
this.value = value;
16+
this.isPlantedByApp = isPlantedByApp;
1117
}
1218

1319
public String getValue() {
@@ -18,6 +24,14 @@ public ArgumentType getArgumentType() {
1824
return argType;
1925
}
2026

27+
public void setPlantedByApp(boolean isPlantedByApp){
28+
this.isPlantedByApp = isPlantedByApp;
29+
}
30+
31+
public boolean isPlantedByApp() {
32+
return isPlantedByApp;
33+
}
34+
2135
public void run(){
2236
argType.run(value);
2337
}
@@ -65,4 +79,5 @@ public boolean equals(Object obj) {
6579
return false;
6680
return true;
6781
}
82+
6883
}

‎koans-lib/src/com/sandwich/koan/runner/KoanSuiteRunner.java‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,7 @@ public void run() throws ClassNotFoundException, IOException,
3434
IllegalArgumentException, InvocationTargetException {
3535
Map<ArgumentType, CommandLineArgument> commandLineArguments =
3636
new HashMap<ArgumentType, CommandLineArgument>(this.commandLineArguments); //clone entries
37-
if(isFirstTimeAppHasBeenRun()){
38-
commandLineArguments.put(ArgumentType.BACKUP, new CommandLineArgument(ArgumentType.BACKUP, null));
39-
}
40-
ifNecessaryPlantDefaultArgumentToRunKoans(commandLineArguments);
37+
applyAssumedStartupBehaviors(commandLineArguments);
4138
List<CommandLineArgument> sortedArguments = new ArrayList<CommandLineArgument>(commandLineArguments.values());
4239
Collections.sort(sortedArguments);
4340
for(CommandLineArgument argument : sortedArguments){
@@ -51,8 +48,15 @@ private boolean isFirstTimeAppHasBeenRun() {
5148
return !dataDirectory.exists();
5249
}
5350

54-
void ifNecessaryPlantDefaultArgumentToRunKoans(Map<ArgumentType, CommandLineArgument> commandLineArguments) {
55-
if(commandLineArguments.isEmpty() ||
51+
void applyAssumedStartupBehaviors(Map<ArgumentType, CommandLineArgument> commandLineArguments) {
52+
if(isFirstTimeAppHasBeenRun()){
53+
ArgumentType.BACKUP.run(null);
54+
// really hackish - but this will clear console for first run, not necessary after
55+
for(int i = 0; i < 80; i++){
56+
System.out.println();
57+
}
58+
}
59+
if(commandLineArguments.isEmpty() ||
5660
(!commandLineArguments.containsKey(ArgumentType.RUN_KOANS)
5761
&& commandLineArguments.containsKey(ArgumentType.CLASS_ARG))){
5862
if(KoanConstants.DEBUG){
@@ -63,7 +67,7 @@ void ifNecessaryPlantDefaultArgumentToRunKoans(Map<ArgumentType, CommandLineArgu
6367
}
6468
}
6569
commandLineArguments.put(ArgumentType.RUN_KOANS, new CommandLineArgument(
66-
ArgumentType.RUN_KOANS, null));
70+
ArgumentType.RUN_KOANS, null, true));
6771
}
6872
}
6973

‎koans-tests/test/com/sandwich/koan/runner/KoanSuiteRunnerTest.java‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ public class KoanSuiteRunnerTest {
2121
@Test
2222
public void testNecessityOfAddingRunKoansCommandLineArgument_addsIfNoArgsPresent(){ //default target
2323
Map<ArgumentType, CommandLineArgument> args = new HashMap<ArgumentType, CommandLineArgument>();
24-
new KoanSuiteRunner().ifNecessaryPlantDefaultArgumentToRunKoans(args);
24+
new KoanSuiteRunner().applyAssumedStartupBehaviors(args);
2525
assertArgsContains(true, args, ArgumentType.RUN_KOANS);
2626
}
2727

2828
@Test
2929
public void testNecessityOfAddingRunKoansCommandLineArgument_ifClassArgIsPresent(){ //default target
3030
Map<ArgumentType, CommandLineArgument> args = new HashMap<ArgumentType, CommandLineArgument>();
3131
args.put(ArgumentType.CLASS_ARG, new CommandLineArgument(ArgumentType.CLASS_ARG, Object.class.getName()));
32-
new KoanSuiteRunner().ifNecessaryPlantDefaultArgumentToRunKoans(args);
32+
new KoanSuiteRunner().applyAssumedStartupBehaviors(args);
3333
assertArgsContains(true, args, ArgumentType.RUN_KOANS, ArgumentType.CLASS_ARG);
3434
}
3535

@@ -41,7 +41,7 @@ public void testNecessityOfAddingRunKoansCommandLineArgument_doesntIfClassArgIsn
4141
for(ArgumentType type : types){
4242
Map<ArgumentType, CommandLineArgument> args = new HashMap<ArgumentType, CommandLineArgument>();
4343
args.put(type, new CommandLineArgument(type, null));
44-
new KoanSuiteRunner().ifNecessaryPlantDefaultArgumentToRunKoans(args);
44+
new KoanSuiteRunner().applyAssumedStartupBehaviors(args);
4545
assertArgsContains(false, args, ArgumentType.RUN_KOANS);
4646
assertArgsContains(true, args, type);
4747
}

‎koans/lib/koans.jar‎

3.02 KB
Binary file not shown.

0 commit comments

Comments
 (0)