-
Notifications
You must be signed in to change notification settings - Fork 154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[#2161] One-Stop Config File for Code Portfolio #2172
Changes from 4 commits
2db2ac0
202d247
f64f6ed
356299a
ffd4912
2cbb662
9190fb0
b611f29
6573637
6c5e401
4259db3
43f1c14
d5fd31a
6e58493
7924629
cbf622d
fa95f75
4299ff2
1145f8e
7c94fea
6ee3249
48c873b
50f6ec6
941f420
6dd383b
d628e85
68ea84e
28d9c84
83329cf
f70ead4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
repoUrl: github.com/user/repo | ||
reportTitle: RepoSense Report | ||
authorDisplayName: Sample Author | ||
authorGithubId: Sample Author Github ID | ||
branches: | ||
- name: Branch 1 | ||
blurb: Blurb 1 | ||
- name: Branch 2 | ||
blurb: Blurb 2 | ||
startDate: 2020-01-01 | ||
endDate: 9999-12-31 |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
repoUrl: github.com/user/repo | ||
reportTitle: RepoSense Report | ||
authorDisplayName: Sample Author | ||
authorGithubId: Sample Author Github ID | ||
branches: | ||
- name: Branch 1 | ||
blurb: Blurb 1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Blurb should allow a few paragraph of markdown text. So, yml might not be the right format for this config file. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
- name: Branch 2 | ||
blurb: Blurb 2 | ||
startDate: 2020-01-01 | ||
endDate: 9999-12-31 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See #2161 (comment) for an example that seems intuitive from the user POV There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @damithc Just wanted to clarify, do you mean that we should include the configs within the markdown files itself, and have the backend parse the markdown files and then generate the reports, or that the overall order/style/keys in the YAML file should match what was used in the example provided? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @asdfghjkxd I wasn't specifically using markdown either. It is just a custom format that makes sense from the user's point of view. I'm fine if something close can be achieved by YAML or some other commonly-used format, provided it makes sense from the user (i.e., the user shouldn't have to do a lot of extra work just to conform to the file format) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @damithc I see, sure thing, we will try to design a user-friendly and convenient config file format and update this PR and parent issue with any new findings/improvements! |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,85 @@ | ||
package reposense.model; | ||
|
||
import java.time.LocalDate; | ||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
/** | ||
* Represents configuration information from JSON config file for generated report. | ||
* Class that contains information on a report's configurations. | ||
* This class is used mainly for quickly setting up one's personal code portfolio. | ||
*/ | ||
public class ReportConfiguration { | ||
private static final String DEFAULT_TITLE = "RepoSense Report"; | ||
private String title; | ||
public static final String DEFAULT_REPO_URL = "github.com/user/repo"; | ||
public static final String DEFAULT_TITLE = "RepoSense Report"; | ||
public static final String DEFAULT_AUTHOR_DISPLAY_NAME = "Sample Author"; | ||
public static final String DEFAULT_AUTHOR_GITHUB_ID = "Sample Author Github ID"; | ||
public static final List<Map<String, String>> DEFAULT_BRANCHES_WITH_BLURBS = new ArrayList<>(); | ||
public static final LocalDate DEFAULT_START_DATE = LocalDate.of(2020, 1, 1); | ||
public static final LocalDate DEFAULT_END_DATE = LocalDate.of(9999, 12, 31); | ||
|
||
private static final HashMap<String, String> DEFAULT_BRANCH_ONE = new HashMap<>(); | ||
private static final HashMap<String, String> DEFAULT_BRANCH_TWO = new HashMap<>(); | ||
|
||
@JsonProperty("repoUrl") | ||
private String repoUrl; | ||
|
||
@JsonProperty("reportTitle") | ||
private String reportTitle; | ||
|
||
@JsonProperty("authorDisplayName") | ||
private String authorDisplayName; | ||
|
||
@JsonProperty("authorGithubId") | ||
private String authorGithubId; | ||
|
||
@JsonProperty("startDate") | ||
private LocalDate startDate; | ||
|
||
@JsonProperty("endDate") | ||
private LocalDate endDate; | ||
|
||
@JsonProperty("branches") | ||
private List<Map<String, String>> branchesWithBlurbs; | ||
|
||
// SIB to set the default values in the maps | ||
static { | ||
DEFAULT_BRANCH_ONE.put("name", "Branch 1"); | ||
DEFAULT_BRANCH_ONE.put("blurb", "Blurb 1"); | ||
DEFAULT_BRANCH_TWO.put("name", "Branch 2"); | ||
DEFAULT_BRANCH_TWO.put("blurb", "Blurb 2"); | ||
DEFAULT_BRANCHES_WITH_BLURBS.add(DEFAULT_BRANCH_ONE); | ||
DEFAULT_BRANCHES_WITH_BLURBS.add(DEFAULT_BRANCH_TWO); | ||
} | ||
|
||
public String getReportTitle() { | ||
return reportTitle == null ? DEFAULT_TITLE : reportTitle; | ||
} | ||
|
||
public String getAuthorDisplayName() { | ||
return authorDisplayName == null ? DEFAULT_AUTHOR_DISPLAY_NAME : authorDisplayName; | ||
} | ||
|
||
public String getAuthorGithubId() { | ||
return authorGithubId == null ? DEFAULT_AUTHOR_GITHUB_ID : authorGithubId; | ||
} | ||
|
||
public LocalDate getStartDate() { | ||
return startDate == null ? DEFAULT_START_DATE : startDate; | ||
} | ||
|
||
public LocalDate getEndDate() { | ||
return endDate == null ? DEFAULT_END_DATE : endDate; | ||
} | ||
|
||
public String getRepoUrl() { | ||
return repoUrl == null ? DEFAULT_REPO_URL : repoUrl; | ||
} | ||
|
||
public String getTitle() { | ||
return (title == null) ? DEFAULT_TITLE : title; | ||
public List<Map<String, String>> getBranchesWithBlurbs() { | ||
return branchesWithBlurbs == null ? DEFAULT_BRANCHES_WITH_BLURBS : branchesWithBlurbs; | ||
} | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package reposense.parser; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.lang.reflect.Type; | ||
import java.nio.file.Path; | ||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
|
||
import com.fasterxml.jackson.databind.JsonMappingException; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; | ||
import com.google.gson.Gson; | ||
|
||
import reposense.model.ReportConfiguration; | ||
import reposense.system.LogsManager; | ||
|
||
/** | ||
* YAML Parser for report-config.yaml files. | ||
*/ | ||
public class ReportConfigYamlParser extends JsonParser<ReportConfiguration> { | ||
public static final String REPORT_CONFIG_FILENAME = "report-config.yaml"; | ||
private static final Logger logger = LogsManager.getLogger(ReportConfigYamlParser.class); | ||
|
||
@Override | ||
public Type getType() { | ||
return ReportConfiguration.class; | ||
} | ||
|
||
@Override | ||
public ReportConfiguration parse(Path path) throws IOException { | ||
return this.fromJson(null, path, null); | ||
} | ||
|
||
@Override | ||
protected ReportConfiguration fromJson(Path path) throws IOException { | ||
return this.fromJson(null, path, null); | ||
} | ||
|
||
@Override | ||
protected ReportConfiguration fromJson(Gson gson, Path path, Type type) throws IOException , JsonMappingException { | ||
// adapted from https://www.baeldung.com/jackson-yaml | ||
ReportConfiguration reportConfigation; | ||
|
||
try { | ||
logger.log(Level.INFO, "Parsing report-config.yaml file..."); | ||
ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); | ||
mapper.findAndRegisterModules(); | ||
reportConfigation = mapper.readValue(new File(path.toString()), ReportConfiguration.class); | ||
logger.log(Level.INFO, "report-config.yaml file parsed successfully!"); | ||
} catch (IOException ioe) { | ||
// if the parse fails for any reason, the default config file is used instead | ||
logger.log(Level.WARNING, "Error parsing report-config.yaml: " + ioe.getMessage(), ioe); | ||
reportConfigation = new ReportConfiguration(); | ||
} | ||
|
||
return reportConfigation; | ||
} | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
repoUrl: github.com/user/repo | ||
reportTitle: RepoSense Report Test Title | ||
authorDisplayName: Sample Author | ||
authorGithubId: Sample Author Github ID | ||
branches: | ||
- name: Branch 1 | ||
blurb: Blurb 1 | ||
- name: Branch 2 | ||
blurb: Blurb 2 | ||
startDate: 2020-01-01 | ||
endDate: 9999-12-31 |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@damithc Sure thing, will remove these from the YAML file and other associated classes in a future commit.