diff --git a/Commits.java b/Commits.java index b25f074..13b8eee 100644 --- a/Commits.java +++ b/Commits.java @@ -1,4 +1,7 @@ import java.util.ArrayList; +import java.io.BufferedWriter; +import java.io.FileWriter; +import java.io.IOException; /** * This class is responsible for keepign track of the commit data for a given repo. * Used in the GithubScraper class primarily. @@ -97,6 +100,26 @@ public int numCommits() { return commits.size(); } + public void saveToFile(String repo) { + String[] r = repo.split("/"); + repo = r[r.length-1]; + String data = getGeneral(); + BufferedWriter writer = null; + try { + writer = new BufferedWriter(new FileWriter(repo + "-Commits.txt")); + writer.write(data); + + System.out.println("Saved commits to Commits.txt"); + } catch ( IOException e) { + } finally { + try { + if ( writer != null) + writer.close( ); + } catch ( IOException e) { + } + } + } + // == private methods == private boolean isInList(ArrayList list, String keyword) { diff --git a/GDET-Four-Musketeers-Commits.txt b/GDET-Four-Musketeers-Commits.txt new file mode 100644 index 0000000..cbccea2 --- /dev/null +++ b/GDET-Four-Musketeers-Commits.txt @@ -0,0 +1,36 @@ +Commits (20): +-------------- +User: "patrickbeekman" +Number of Commits: 5 +Messages: +>"added more tests to check for correct functionality in the GithubScraper class." +>"Merge branch 'master' into test-getting-objects" +>"rewrote tests with the testing class with the new stuff." +>"added comments as well as changed the function to return instead of print." +>"able to curl a request to the github api." +------------------------------- +User: "carnsds7" +Number of Commits: 6 +Messages: +>"Made it possible to get general data from gitobjects" +>"Added commit functionality to get the general data" +>"Started extension and abstraction of classes" +>"Able to see commit data now" +>"Included the org.json.jar file and attempted to parse the json from curl request" +>"Merge pull request #13 from CompassSoftware/GithubScraper\n\nGitHub scraper" +------------------------------- +User: "mcgalliarder" +Number of Commits: 7 +Messages: +>"Merge pull request #26 from CompassSoftware/menu_dev\n\nMenu dev" +>"Updated and added tests to GithubScraperTest" +>"Merge branch 'master' of https +>"Merge pull request #23 from CompassSoftware/general_data\n\nAdded getters for specific inner class objects" +>"Added some tests to the testing class and made changes to existing methods." +>"Merge pull request #22 from CompassSoftware/general_data\n\nMade it possible to get general data from gitobjects" +>"Merge pull request #16 from CompassSoftware/json_parse\n\nJson parse" +------------------------------- +User: "fenwickjb" +Number of Commits: 0 +Messages: +------------------------------- diff --git a/GDET-Four-Musketeers-Issues.txt b/GDET-Four-Musketeers-Issues.txt new file mode 100644 index 0000000..da078c6 --- /dev/null +++ b/GDET-Four-Musketeers-Issues.txt @@ -0,0 +1,62 @@ +Issues (12): +-------------- + +> Title: "Save to file" +Date: "2018-12-04 +URL: "https//api.github.com/repos/CompassSoftware/GDET-Four-Musketeers/issues/25" +--------------------------- + +> Title: "Save Issues to file" +Date: "2018-12-04 +URL: "https//api.github.com/repos/CompassSoftware/GDET-Four-Musketeers/issues/24" +--------------------------- + +> Title: "Build and manipulate JSON objects" +Date: "2018-11-19 +URL: "https//api.github.com/repos/CompassSoftware/GDET-Four-Musketeers/issues/14" +--------------------------- + +> Title: "Install the java Github API" +Date: "2018-11-09 +URL: "https//api.github.com/repos/CompassSoftware/GDET-Four-Musketeers/issues/12" +--------------------------- + +> Title: "Get the file contents" +Date: "2018-11-12 +URL: "https//api.github.com/repos/CompassSoftware/GDET-Four-Musketeers/issues/10" +--------------------------- + +> Title: "Parse comments from pull requests" +Date: "2018-11-09 +URL: "https//api.github.com/repos/CompassSoftware/GDET-Four-Musketeers/issues/9" +--------------------------- + +> Title: "Parse comments from commits" +Date: "2018-11-09 +URL: "https//api.github.com/repos/CompassSoftware/GDET-Four-Musketeers/issues/8" +--------------------------- + +> Title: "Get the pull request data from master and other branches" +Date: "2018-11-09 +URL: "https//api.github.com/repos/CompassSoftware/GDET-Four-Musketeers/issues/7" +--------------------------- + +> Title: "Get the issues data from master and other branches" +Date: "2018-11-13 +URL: "https//api.github.com/repos/CompassSoftware/GDET-Four-Musketeers/issues/6" +--------------------------- + +> Title: "Get the commit data from Master and other branches" +Date: "2018-11-12 +URL: "https//api.github.com/repos/CompassSoftware/GDET-Four-Musketeers/issues/4" +--------------------------- + +> Title: "issue" +Date: "2018-11-09 +URL: "https//api.github.com/repos/CompassSoftware/GDET-Four-Musketeers/issues/3" +--------------------------- + +> Title: "Create project “Kanban” board." +Date: "2018-11-09 +URL: "https//api.github.com/repos/CompassSoftware/GDET-Four-Musketeers/issues/2" +--------------------------- diff --git a/GitObject.java b/GitObject.java index 8be5ec5..55e9c2e 100644 --- a/GitObject.java +++ b/GitObject.java @@ -37,4 +37,6 @@ public void setData(String[] data) { public abstract String getGeneral(); public abstract String getData(String keyWord); + + public abstract void saveToFile(String repo); } diff --git a/GithubDriver.java b/GithubDriver.java index 8afad95..cfbac9d 100644 --- a/GithubDriver.java +++ b/GithubDriver.java @@ -3,17 +3,17 @@ public class GithubDriver { - // == main menu options == - private static final int ISSUES = 1; - private static final int COMMITS = 2; - private static final int QUIT = 3; + public static final int ISSUES = 1; + public static final int COMMITS = 2; + public static final int QUIT = 3; // == secondary menu options == private static final int GENERAL = 1; private static final int COMMENTS = 2; private static final int SPECIFIC = 3; private static final int LIST = 4; - private static final int RETURN = 5; + private static final int SAVE = 5; + private static final int RETURN = 6; private static final String ISSUES_STR = "Issues"; private static final String COMMITS_STR = "Commits"; @@ -44,7 +44,8 @@ private static void startRoutine(Scanner s, GithubScraper scraper, int opt) { + "\n2) Comments" + "\n3) Info on specific commit." + "\n4) List the " + c - + "\n5) Return to main menu\n"); + + "\n5) Save " + c + " to file." + + "\n6) Return to main menu\n"); while (true) { int choice = s.nextInt(); s.nextLine(); @@ -57,6 +58,7 @@ else if (opt == COMMITS) break; case COMMENTS: //TODO + System.out.println("Coming soon to a terminal near you!"); break; case SPECIFIC: //TODO @@ -83,6 +85,12 @@ else if (opt == COMMITS) { else if (opt == COMMITS) System.out.println(scraper.getCommits()); break; + case SAVE: + if (opt == ISSUES) + scraper.saveIssues(); + else if (opt == COMMITS) + scraper.saveCommits(); + break; case RETURN: return; default: @@ -93,7 +101,8 @@ else if (opt == COMMITS) + "\n2) Comments" + "\n3) Info on specific commit." + "\n4) List the " + c - + "\n5) Return to main menu\n"); + + "\n5) Save " + c + " to file." + + "\n6) Return to main menu\n"); } } diff --git a/GithubScraper.java b/GithubScraper.java index 8d29903..aa43cfc 100644 --- a/GithubScraper.java +++ b/GithubScraper.java @@ -43,6 +43,14 @@ public Commits getCommits() { return commits; } + public void saveIssues() { + issues.saveToFile(baseURL); + } + + public void saveCommits() { + commits.saveToFile(baseURL); + } + /* * Sets the base url of the project */ diff --git a/Issues.java b/Issues.java index 0e7abb0..3a13eee 100644 --- a/Issues.java +++ b/Issues.java @@ -1,4 +1,7 @@ import java.util.ArrayList; +import java.io.BufferedWriter; +import java.io.FileWriter; +import java.io.IOException; /** * * Class responsible for parsing the issues string array. @@ -80,6 +83,26 @@ public String toString() { return ret; } + public void saveToFile(String repo) { + String[] r = repo.split("/"); + repo = r[r.length-1]; + String data = getGeneral(); + BufferedWriter writer = null; + try { + writer = new BufferedWriter(new FileWriter(repo + "-Issues.txt")); + writer.write(data); + + System.out.println("Saved issues to Issues.txt"); + } catch ( IOException e) { + } finally { + try { + if ( writer != null) + writer.close( ); + } catch ( IOException e) { + } + } + } + // == private methods == private boolean isInList(ArrayList list, String keyword) {