-
Notifications
You must be signed in to change notification settings - Fork 0
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
20 changed files
with
88,386 additions
and
95 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
16 changes: 16 additions & 0 deletions
16
src/main/java/com/github/lernejo/korekto/grader/load_file/PathUtils.java
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,16 @@ | ||
package com.github.lernejo.korekto.grader.load_file; | ||
|
||
import java.net.URISyntaxException; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
|
||
public class PathUtils { | ||
|
||
public static Path resourceToPath(String resourceName) { | ||
try { | ||
return Paths.get(WeatherComputationData.class.getClassLoader().getResource(resourceName).toURI()); | ||
} catch (URISyntaxException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/com/github/lernejo/korekto/grader/load_file/StringUtils.java
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,26 @@ | ||
package com.github.lernejo.korekto.grader.load_file; | ||
|
||
import java.util.regex.Matcher; | ||
|
||
public class StringUtils { | ||
|
||
public static String safeEscapeElide(String s) { | ||
if (s == null) { | ||
return ""; | ||
} else { | ||
String s1 = s.trim().replaceAll("\n", Matcher.quoteReplacement("\\n")); | ||
if (s1.length() > 80) { | ||
return s1.substring(0, 77) + "..."; | ||
} | ||
return s1; | ||
} | ||
} | ||
|
||
public static String safeLowerTrim(String s) { | ||
if (s == null) { | ||
return ""; | ||
} else { | ||
return s.trim().toLowerCase(); | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/com/github/lernejo/korekto/grader/load_file/WeatherComputationData.java
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,25 @@ | ||
package com.github.lernejo.korekto.grader.load_file; | ||
|
||
import com.github.lernejo.korekto.grader.load_file.vault.Vault; | ||
|
||
import java.util.List; | ||
|
||
import static com.github.lernejo.korekto.grader.load_file.PathUtils.resourceToPath; | ||
|
||
public record WeatherComputationData(String start, String end, String metric, String selector, String agg, | ||
String result) { | ||
|
||
public String asDescription() { | ||
String period = Vault.isClear() ? start + '/' + end : "(period undisclosed)"; | ||
return period + '/' + metric + '/' + selector + '/' + agg; | ||
} | ||
|
||
public static final class Loader { | ||
Check warning on line 17 in src/main/java/com/github/lernejo/korekto/grader/load_file/WeatherComputationData.java Codecov / codecov/patchsrc/main/java/com/github/lernejo/korekto/grader/load_file/WeatherComputationData.java#L17
|
||
public static final Vault<List<WeatherComputationData>> vault = new Vault<>() { | ||
}; | ||
|
||
public static List<WeatherComputationData> load() { | ||
return vault.load(resourceToPath("vault/results.encrypted"), resourceToPath("vault/results.clear")); | ||
} | ||
} | ||
} |
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.