Skip to content

Commit

Permalink
Small cleanups and code formatting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
frossm committed Aug 7, 2023
1 parent 3683351 commit bdcfecc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion snap/snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: quoter
version: '5.0.19'
version: '5.0.20'
summary: Command line utility to pull stock and index quotes
description: |
Quoter fetches online stock quotes and index data for easy display on
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/fross/quoter/QuoteConsoleOutput.java
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ public void displayOutput(FileExporter exporter) {
timeStamp = timeStamp.replaceAll("AM", "am");

// Display the time stamp
Output.printColor(Ansi.Color.CYAN, "Data as of " + timeStamp + ". Quotes are delayed.");
Output.printColorln(Ansi.Color.CYAN, "Data as of " + timeStamp + ". Quotes are delayed.");

// Display trending data if -t was provided and there is at least one valid symbol
if (cli.clTrend == true) {
Expand Down
16 changes: 10 additions & 6 deletions src/main/java/org/fross/quoter/Symbol.java
Original file line number Diff line number Diff line change
Expand Up @@ -295,23 +295,27 @@ private void getSymbolData(String symb) {

}

/**
* setOptionalField(): Handles error conditions for those fields that do not have a valid value from the website
*
* @param htmlPage
* @param key
* @param marketStatus
*/
private void setOptionalField(final Document htmlPage, final String key, final MarketStatus marketStatus) {
try {
final String result = queryPageItem(htmlPage,
marketStatus == MarketStatus.Closed ?
xPathLookup.lookupSymbolClosed(key) :
xPathLookup.lookupSymbolOpen(key)
);
marketStatus == MarketStatus.Closed ? xPathLookup.lookupSymbolClosed(key) : xPathLookup.lookupSymbolOpen(key));
symbolData.put(key, result.replaceAll("[,%]", "").trim());

} catch (Exception e) {
Output.debugPrintln("Failed to fetch key: " + key + " from page. Setting value as '---'");
symbolData.put(key, "---");
}
}

private enum MarketStatus {
Open,
Closed
Open, Closed
}

}

0 comments on commit bdcfecc

Please sign in to comment.