Skip to content

Commit

Permalink
imp - doc - Names and word generators are no longer online
Browse files Browse the repository at this point in the history
---

A very important change has been made to Textify that allows you to use the name generator and the word generator without requiring an active Internet connection.

Starting from this commit, we require cloning this repo and its submodules in order for Textify to build successfully. Our own forks (spoiler: non-fork forks, just like what we did to ReadLine.Reboot) are maintained to ensure that you only get the content that you need.

This commit also increments the version to 1.1.0 just for this change.

---

Type: imp
Breaking: False
Doc Required: True
Part: 1/1
  • Loading branch information
AptiviCEO committed Dec 5, 2023
1 parent 53cf241 commit 86f959c
Show file tree
Hide file tree
Showing 22 changed files with 529 additions and 90 deletions.
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "assets/NamesList"]
path = assets/NamesList
url = https://github.com/Aptivi/NamesList.git
[submodule "assets/WordsList"]
path = assets/WordsList
url = https://github.com/Aptivi/WordsList.git
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,17 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.

using System;
using Textify.Online.NameGen;

namespace Textify.Demos.Online.Fixtures.Cases
namespace Textify.Demos.Offline.Fixtures.Cases
{
internal class NameGen : IFixture
internal class NameGenerator : IFixture
{
public string FixtureID => "NameGen";
public string FixtureID => "NameGenerator";
public void RunFixture()
{
string[] names = NameGenerator.GenerateNames(10);
string[] firstNames = NameGenerator.GenerateFirstNames(10);
string[] surnames = NameGenerator.GenerateLastNames(10);
string[] names = NameGen.NameGenerator.GenerateNames(10);
string[] firstNames = NameGen.NameGenerator.GenerateFirstNames(10);
string[] surnames = NameGen.NameGenerator.GenerateLastNames(10);

Console.WriteLine($"10 names: {string.Join(", ", names)}");
Console.WriteLine($"10 first names: {string.Join(", ", firstNames)}");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.

using System;
using Textify.Online.Words;
using Textify.Words;

namespace Textify.Demos.Online.Fixtures.Cases
namespace Textify.Demos.Offline.Fixtures.Cases
{
internal class WordGet : IFixture
{
Expand Down
6 changes: 6 additions & 0 deletions Textify.Demos.Offline/Fixtures/FixtureManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ internal static class FixtureManager
// Versioning
new VersionInfo(),
new VersionInfoRev(),

// NameGen
new NameGenerator(),

// Words
new WordGet(),
];

internal static IFixture GetFixtureFromName(string name)
Expand Down
8 changes: 8 additions & 0 deletions Textify.Demos.Offline/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@
"Textify - Offline - VersionInfoRev": {
"commandName": "Project",
"commandLineArgs": "VersionInfoRev"
},
"Textify - Offline - WordGet": {
"commandName": "Project",
"commandLineArgs": "WordGet"
},
"Textify - Offline - NameGenerator": {
"commandName": "Project",
"commandLineArgs": "NameGenerator"
}
}
}
6 changes: 0 additions & 6 deletions Textify.Demos.Online/Fixtures/FixtureManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@ internal static class FixtureManager

// MailAddress
new Addresstigation(),

// NameGen
new NameGen(),

// Words
new WordGet(),
];

internal static IFixture GetFixtureFromName(string name)
Expand Down
10 changes: 1 addition & 9 deletions Textify.Demos.Online/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,6 @@
"Textify - Online - Addresstigation": {
"commandName": "Project",
"commandLineArgs": "Addresstigation"
},
"Textify - Online - NameGen": {
"commandName": "Project",
"commandLineArgs": "NameGen"
},
"Textify - Online - WordGet": {
"commandName": "Project",
"commandLineArgs": "WordGet"
}
}
}
}
4 changes: 2 additions & 2 deletions Textify.Online/Textify.Online.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<IncludeSymbols>True</IncludeSymbols>
<Version>1.0.1</Version>
<Version>1.1.0</Version>
<Authors>Aptivi</Authors>
<Company>Aptivi Corp.</Company>
<Description>Text tools (online)</Description>
Expand All @@ -16,7 +16,7 @@
<PackageTags>dictionary;api;free;csharp;visualbasic;word;meaning;definition;text;tools;library</PackageTags>
<PackageLicenseExpression>GPL-3.0-or-later</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
<PackageVersion>1.0.1</PackageVersion>
<PackageVersion>1.1.0</PackageVersion>
<PackageIcon>OfficialAppIcon-Textify-512.png</PackageIcon>
<PackageReadmeFile>README.md</PackageReadmeFile>
<LangVersion>latest</LangVersion>
Expand Down
1 change: 0 additions & 1 deletion Textify.Tests/Sequences/VtSequenceToolsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.

using Shouldly;
using System;
using System.Text.RegularExpressions;
using Textify.Sequences.Tools;

Expand Down
8 changes: 4 additions & 4 deletions Textify.Tests/Versioning/SemVerParseTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public bool TestSemVerEquality(string version, string otherVersion)
[Test]
[TestCase("0.9.0", "1.0.0", ExpectedResult = true)]
[TestCase("0.9.0-alpha1", "1.0.0", ExpectedResult = true)]
[TestCase("1.0.1", "1.0.0", ExpectedResult = false)]
[TestCase("1.1.0", "1.0.0", ExpectedResult = false)]
[TestCase("1.1.0-alpha1", "1.0.0", ExpectedResult = false)]
[TestCase("1.0.0", "1.0.0", ExpectedResult = false)]
[TestCase("1.0.0-alpha1", "1.0.0", ExpectedResult = true)]
Expand All @@ -92,7 +92,7 @@ public bool TestSemVerIsOlderThan(string version, string otherVersion)
[Test]
[TestCase("0.9.0", "1.0.0", ExpectedResult = true)]
[TestCase("0.9.0-alpha1", "1.0.0", ExpectedResult = true)]
[TestCase("1.0.1", "1.0.0", ExpectedResult = false)]
[TestCase("1.1.0", "1.0.0", ExpectedResult = false)]
[TestCase("1.1.0-alpha1", "1.0.0", ExpectedResult = false)]
[TestCase("1.0.0", "1.0.0", ExpectedResult = true)]
[TestCase("1.0.0-alpha1", "1.0.0", ExpectedResult = true)]
Expand All @@ -114,7 +114,7 @@ public bool TestSemVerIsOlderOrEqualTo(string version, string otherVersion)
[Test]
[TestCase("0.9.0", "1.0.0", ExpectedResult = false)]
[TestCase("0.9.0-alpha1", "1.0.0", ExpectedResult = false)]
[TestCase("1.0.1", "1.0.0", ExpectedResult = true)]
[TestCase("1.1.0", "1.0.0", ExpectedResult = true)]
[TestCase("1.1.0-alpha1", "1.0.0", ExpectedResult = true)]
[TestCase("1.0.0-alpha1", "1.0.0", ExpectedResult = false)]
[TestCase("1.0.0", "1.0.0-alpha1", ExpectedResult = true)]
Expand All @@ -135,7 +135,7 @@ public bool TestSemVerIsNewerThan(string version, string otherVersion)
[Test]
[TestCase("0.9.0", "1.0.0", ExpectedResult = false)]
[TestCase("0.9.0-alpha1", "1.0.0", ExpectedResult = false)]
[TestCase("1.0.1", "1.0.0", ExpectedResult = true)]
[TestCase("1.1.0", "1.0.0", ExpectedResult = true)]
[TestCase("1.1.0-alpha1", "1.0.0", ExpectedResult = true)]
[TestCase("1.0.0", "1.0.0", ExpectedResult = true)]
[TestCase("1.0.0-alpha1", "1.0.0", ExpectedResult = false)]
Expand Down
8 changes: 4 additions & 4 deletions Textify.Tests/Versioning/SemVerWithRevParseTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public bool TestSemVerEquality(string version, string otherVersion)
[Test]
[TestCase("0.9.0.5", "1.0.0.5", ExpectedResult = true)]
[TestCase("0.9.0.5-alpha1", "1.0.0.5", ExpectedResult = true)]
[TestCase("1.0.1.0", "1.0.0.5", ExpectedResult = false)]
[TestCase("1.1.0.0", "1.0.0.5", ExpectedResult = false)]
[TestCase("1.1.0.5-alpha1", "1.0.0.5", ExpectedResult = false)]
[TestCase("1.0.0.5", "1.0.0.5", ExpectedResult = false)]
[TestCase("1.0.0.5-alpha1", "1.0.0.5", ExpectedResult = true)]
Expand All @@ -93,7 +93,7 @@ public bool TestSemVerIsOlderThan(string version, string otherVersion)
[Test]
[TestCase("0.9.0.5", "1.0.0.5", ExpectedResult = true)]
[TestCase("0.9.0.5-alpha1", "1.0.0.5", ExpectedResult = true)]
[TestCase("1.0.1.0", "1.0.0.5", ExpectedResult = false)]
[TestCase("1.1.0.0", "1.0.0.5", ExpectedResult = false)]
[TestCase("1.1.0.5-alpha1", "1.0.0.5", ExpectedResult = false)]
[TestCase("1.0.0.5", "1.0.0.5", ExpectedResult = true)]
[TestCase("1.0.0.5-alpha1", "1.0.0.5", ExpectedResult = true)]
Expand All @@ -115,7 +115,7 @@ public bool TestSemVerIsOlderOrEqualTo(string version, string otherVersion)
[Test]
[TestCase("0.9.0.5", "1.0.0.5", ExpectedResult = false)]
[TestCase("0.9.0.5-alpha1", "1.0.0.5", ExpectedResult = false)]
[TestCase("1.0.1.0", "1.0.0.5", ExpectedResult = true)]
[TestCase("1.1.0.0", "1.0.0.5", ExpectedResult = true)]
[TestCase("1.1.0.5-alpha1", "1.0.0.5", ExpectedResult = true)]
[TestCase("1.0.0.5-alpha1", "1.0.0.5", ExpectedResult = false)]
[TestCase("1.0.0.5", "1.0.0.5-alpha1", ExpectedResult = true)]
Expand All @@ -136,7 +136,7 @@ public bool TestSemVerIsNewerThan(string version, string otherVersion)
[Test]
[TestCase("0.9.0.5", "1.0.0.5", ExpectedResult = false)]
[TestCase("0.9.0.5-alpha1", "1.0.0.5", ExpectedResult = false)]
[TestCase("1.0.1.0", "1.0.0.5", ExpectedResult = true)]
[TestCase("1.1.0.0", "1.0.0.5", ExpectedResult = true)]
[TestCase("1.1.0.5-alpha1", "1.0.0.5", ExpectedResult = true)]
[TestCase("1.0.0.5", "1.0.0.5", ExpectedResult = true)]
[TestCase("1.0.0.5-alpha1", "1.0.0.5", ExpectedResult = false)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//

namespace Textify.Online.NameGen
namespace Textify.NameGen
{
/// <summary>
/// Name gender type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using Textify.General;
using Textify.NameGen.Resources;

namespace Textify.Online.NameGen
namespace Textify.NameGen
{
/// <summary>
/// Name generator class
Expand All @@ -34,12 +35,6 @@ public static class NameGenerator
internal static string[] Names = [];
internal static string[] Surnames = [];
private static NameGenderType lastGenderType = NameGenderType.Unified;
private static readonly HttpClient NameClient = new();
private static readonly string nameAddressPart = "https://cdn.jsdelivr.net/gh/Aptivi/NamesList@latest/Processed/";
private static readonly string unifiedNameListFileName = "FirstNames.txt";
private static readonly string femaleNameListFileName = "FirstNames_Female.txt";
private static readonly string maleNameListFileName = "FirstNames_Male.txt";
private static readonly string surnameListFileName = "Surnames.txt";

/// <summary>
/// Populates the names and the surnames for the purpose of initialization
Expand All @@ -56,17 +51,20 @@ public static async Task PopulateNamesAsync(NameGenderType genderType = NameGend
{
try
{
string surnameAddress = $"{nameAddressPart}{surnameListFileName}";
string namesFileName =
genderType == NameGenderType.Female ? femaleNameListFileName :
genderType == NameGenderType.Male ? maleNameListFileName :
unifiedNameListFileName;
string nameAddress = $"{nameAddressPart}{namesFileName}";

if (Names.Length == 0 || genderType != lastGenderType)
Names = await PopulateInternalAsync(nameAddress);
{
var namesBytes =
genderType == NameGenderType.Female ? NamesData.FirstNames_Female :
genderType == NameGenderType.Male ? NamesData.FirstNames_Male :
NamesData.FirstNames;
var namesByteStream = new MemoryStream(namesBytes);
Names = (await new StreamReader(namesByteStream).ReadToEndAsync()).SplitNewLines();
}
if (Surnames.Length == 0)
Surnames = await PopulateInternalAsync(surnameAddress);
{
var lastsByteStream = new MemoryStream(NamesData.Surnames);
Surnames = (await new StreamReader(lastsByteStream).ReadToEndAsync()).SplitNewLines();
}
lastGenderType = genderType;
}
catch (Exception ex)
Expand Down Expand Up @@ -491,22 +489,5 @@ internal static string[] GenerateNameArray(int Count, string NamePrefix, string
}
return [.. namesList];
}

internal static async Task<string[]> PopulateInternalAsync(string nameLink)
{
HttpResponseMessage Response = await NameClient.GetAsync(nameLink);
Response.EnsureSuccessStatusCode();
Stream SurnamesStream = await Response.Content.ReadAsStreamAsync();
string SurnamesString = new StreamReader(SurnamesStream).ReadToEnd();
return SurnamesString.SplitNewLines();
}

/// <summary>
/// Makes a string array with new line as delimiter
/// </summary>
/// <param name="Str">Target string</param>
/// <returns></returns>
internal static string[] SplitNewLines(this string Str) =>
Str.Replace(Convert.ToChar(13), default).Split(Convert.ToChar(10));
}
}
103 changes: 103 additions & 0 deletions Textify/NameGen/Resources/NamesData.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 86f959c

Please sign in to comment.