Skip to content

Commit

Permalink
Changed comments format to Markdown.
Browse files Browse the repository at this point in the history
  • Loading branch information
leonid20000 committed Jan 6, 2024
1 parent 4c0ea28 commit bac1ce4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
22 changes: 11 additions & 11 deletions src/main/java/org/odinware/odinrunes/TextHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public void appendStringToFile(String content) {
*/
public void appendOdinFirstInfo(String model, String date) {
String odinFirstInfo = String.format(
"// =====[ Odin Runes ]======[ {\"model\" : \"%s\", \"date\": \"%s\"} ]======[ + ]\n",
"<!-- =====[ Odin Runes ]======[ {\"model\" : \"%s\", \"date\": \"%s\"} ]======[ + ] -->\n",
model, date
);
appendStringToFile(odinFirstInfo);
Expand All @@ -97,31 +97,31 @@ public void appendOdinFirstInfo(String model, String date) {
* Appends the user info to the file.
*/
public void appendUserInfo() {
String userInfo = "// =====[ User ]=====[ : ]\n";
String userInfo = "<!-- =====[ User ]=====[ : ] -->\n";
appendStringToFile(userInfo);
}

/**
* Appends the over info with an error to the file.
*/
public void appendOverInfoWithError() {
String overInfo = "// =====[ OVER ]=====[ ! ]\n";
String overInfo = "<!-- =====[ OVER ]=====[ ! ] -->\n";
appendStringToFile(overInfo);
}

/**
* Appends the assistant info to the file.
*/
public void appendAssistantInfo() {
String assistantInfo = "// =====[ Assistant ]=====[ : ]\n";
String assistantInfo = "<!-- =====[ Assistant ]=====[ : ] -->\n";
appendStringToFile(assistantInfo);
}

/**
* Appends the over info to the file.
*/
public void appendOverInfo() {
String overInfo = "// =====[ OVER ]=====[ # ]\n";
String overInfo = "<!-- =====[ OVER ]=====[ # ] -->\n";
appendStringToFile(overInfo);
}

Expand Down Expand Up @@ -158,11 +158,11 @@ public JSONArray getMessages() {
String line;

while ((line = reader.readLine()) != null) {
if (line.contains("// =====[ User ]=====[ : ]")) {
if (line.contains("<!-- =====[ User ]=====[ : ] -->")) {
isUserSection = true;
isAssistantSection = false;
messageBuilder.setLength(0); // Clear the message builder.
} else if (line.contains("// =====[ Odin Runes ]======[") && line.contains("]======[ + ]")) {
} else if (line.contains("<!-- =====[ Odin Runes ]======[") && line.contains("]======[ + ] -->")) {
isUserSection = false;
isAssistantSection = false;
messageBuilder.setLength(0); // Clear the message builder.
Expand All @@ -179,11 +179,11 @@ public JSONArray getMessages() {
jsonTemp = null; // JSON is invalid.
}
}
} else if (line.contains("// =====[ Assistant ]=====[ : ]")) {
} else if (line.contains("<!-- =====[ Assistant ]=====[ : ] -->")) {
isUserSection = false;
isAssistantSection = true;
messageBuilder.setLength(0); // Clear the message builder.
} else if (line.contains("// =====[ OVER ]=====[ # ]")) {
} else if (line.contains("<!-- =====[ OVER ]=====[ # ] -->")) {
if (isUserSection || isAssistantSection) {
String content = messageBuilder.toString().trim();
if (!content.isEmpty()) {
Expand All @@ -200,7 +200,7 @@ public JSONArray getMessages() {
isUserSection = false;
isAssistantSection = false;
jsonTemp = null; // Reset the JSON temp variable.
} else if (line.contains("// =====[ OVER ]=====[ ! ]")) {
} else if (line.contains("<!-- =====[ OVER ]=====[ ! ] -->")) {
if (isUserSection || isAssistantSection) {
messageBuilder.setLength(0); // Clear the message builder.
}
Expand Down Expand Up @@ -237,7 +237,7 @@ public JSONArray getMessages() {
public static boolean isFirstLineValid(File file) {
try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
String firstLine = reader.readLine();
return firstLine != null && firstLine.contains("// =====[ Odin");
return firstLine != null && firstLine.contains("<!-- =====[ Odin");
} catch (IOException e) {
logger.log(Level.SEVERE, "An error occurred: ", e);
return false; // Handle the exception as needed
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/org/odinware/odinrunes/TextHelperTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void testCheckAndPopulateFileIfEmpty() throws IOException {
reader.close();

// Use a regular expression to match the date format dd/MM/yy
assertEquals(true, line.matches("// =====\\[ Odin Runes \\]======\\[ \\{\"model\" : \"as-specified\", \"date\": \"\\d{2}/\\d{2}/\\d{2}\"\\} \\]======\\[ \\+ \\]"));
assertEquals(true, line.matches("<!-- =====\\[ Odin Runes \\]======\\[ \\{\"model\" : \"as-specified\", \"date\": \"\\d{2}/\\d{2}/\\d{2}\"\\} \\]======\\[ \\+ \\] -->"));
}


Expand Down Expand Up @@ -88,7 +88,7 @@ public void testAppendOdinFirstInfo() throws IOException {
String line = reader.readLine();
reader.close();

Assertions.assertEquals("// =====[ Odin Runes ]======[ {\"model\" : \"" + model + "\", \"date\": \"" + date + "\"} ]======[ + ]", line);
Assertions.assertEquals("<!-- =====[ Odin Runes ]======[ {\"model\" : \"" + model + "\", \"date\": \"" + date + "\"} ]======[ + ] -->", line);
}

}

0 comments on commit bac1ce4

Please sign in to comment.