Remove clashing error prefix; Use better name for RatufaCoat ROMs.
[SquirrelJME.git] / buildSrc / src / main / java / cc / squirreljme / plugin / util / NoteCalendarFinder.java
blob8af23e5c62e8fcc39a4906d203c5256208fd1db4
1 // -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
3 // SquirrelJME
4 // Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
5 // ---------------------------------------------------------------------------
6 // SquirrelJME is under the GNU General Public License v3+, or later.
7 // See license.mkd for licensing and copyright information.
8 // ---------------------------------------------------------------------------
10 package cc.squirreljme.plugin.util;
12 import java.time.LocalDate;
13 import java.util.regex.Pattern;
15 /**
16 * Finds note files.
18 * @since 2020/06/27
20 public final class NoteCalendarFinder
22 /**
23 * Not used.
25 * @since 2020/06/27
27 private NoteCalendarFinder()
31 /**
32 * Returns the file map.
34 * @param __exe The executable.
35 * @return The file map.
36 * @since 2020/06/27
38 public static NoteUsers findNotes(FossilExe __exe)
40 // There will be a number of users
41 NoteUsers users = new NoteUsers();
43 // Determine which notes exist
44 for (String fileName : __exe.unversionList())
46 // Not a notes files
47 if (!fileName.startsWith("developer-notes/"))
48 continue;
50 // Split off
51 fileName = fileName.substring("developer-notes/".length());
53 // Split to determine when
54 String[] splice = fileName.split(Pattern.quote("/"));
55 if (splice.length != 4)
56 continue;
58 // Determine the date and time
59 String userName = splice[0];
60 LocalDate date = LocalDate.of(
61 Integer.parseInt(splice[1], 10),
62 Integer.parseInt(splice[2], 10),
63 Integer.parseInt(
64 NoteCalendarFinder.__unMkd(splice[3]), 10));
66 // Add to storage
67 users.add(userName, date, fileName);
70 return users;
74 /**
75 * Removes the markdown extension from the file.
77 * @param __s The string to remove from.
78 * @return The string with the extension removed.
79 * @throws NullPointerException On null arguments.
80 * @since 2020/06/27
82 private static String __unMkd(String __s)
83 throws NullPointerException
85 if (__s == null)
86 throw new NullPointerException("NARG");
88 // Must end in this
89 if (!__s.endsWith(".mkd"))
90 throw new IllegalArgumentException("Missing .mkd: " + __s);
92 // Remove it
93 return __s.substring(0, __s.length() - 4);