diff --git a/math-rules-cache.zip b/math-rules-cache.zip index 1428591c..83c7c1cc 100644 Binary files a/math-rules-cache.zip and b/math-rules-cache.zip differ diff --git a/src/main/java/org/warp/picalculator/math/rules/RulesManager.java b/src/main/java/org/warp/picalculator/math/rules/RulesManager.java index 85d14802..713a1b3b 100644 --- a/src/main/java/org/warp/picalculator/math/rules/RulesManager.java +++ b/src/main/java/org/warp/picalculator/math/rules/RulesManager.java @@ -12,7 +12,10 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.StandardOpenOption; +import java.util.ArrayList; import java.util.List; +import java.util.stream.Stream; + import org.warp.picalculator.Error; import org.warp.picalculator.Utils; import org.warp.picalculator.math.Function; @@ -40,13 +43,29 @@ public class RulesManager { } try { boolean compiledSomething = false; - final Path rulesPath = Utils.getResource("/rules.csv"); - if (!Files.exists(rulesPath)) { - throw new FileNotFoundException("rules.csv not found!"); + final Path defaultRulesPath = Utils.getResource("/default-rules.lst"); + if (!Files.exists(defaultRulesPath)) { + throw new FileNotFoundException("default-rules.lst not found!"); } - List ruleLines = Files.readAllLines(rulesPath); - ruleLines.remove(0); //Remove the headers - + List ruleLines = new ArrayList(); + Path rulesPath = Paths.get("rules/"); + if (rulesPath.toFile().exists()) { + System.err.println("RULES EXISTS!!!!!!"); + try (Stream paths = Files.walk(rulesPath)) { + paths + .filter(Files::isRegularFile) + .forEach((Path p) -> { + if (p.toString().endsWith(".java")) { + String path = rulesPath.relativize(p).toString(); + path = path.substring(0, path.length() - ".java".length()); + ruleLines.add(path); + System.err.println(path); + } + }); + } + } + ruleLines.addAll(Files.readAllLines(defaultRulesPath)); + boolean useCache = false; Path tDir = Paths.get(System.getProperty("java.io.tmpdir"), "WarpPi-Calculator").resolve("rules-rt"); // try { diff --git a/src/main/resources/rules.csv b/src/main/resources/default-rules.lst similarity index 93% rename from src/main/resources/rules.csv rename to src/main/resources/default-rules.lst index b171febb..38c710a2 100644 --- a/src/main/resources/rules.csv +++ b/src/main/resources/default-rules.lst @@ -1,4 +1,3 @@ -Rule file functions/DivisionRule functions/EmptyNumberRule functions/ExpressionRule