Skip to content

Commit

Permalink
#13 名称変更
Browse files Browse the repository at this point in the history
  • Loading branch information
aiueo-1234 committed Mar 15, 2024
1 parent 7d5a321 commit 5c3bcb6
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace KoeBook.Epub.Contracts.Services;

public interface IScrapingHelperService
public interface ISplitBraceService
{
List<string> SplitBrace(string text);
List<string> SplitBrace(List<string> texts);
Expand Down
18 changes: 9 additions & 9 deletions Epub/KoeBook.Epub/Services/ScrapingAozoraService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

namespace KoeBook.Epub.Services
{
public partial class ScrapingAozoraService(IScrapingHelperService scrapingHelperService) : IScrapingService
public partial class ScrapingAozoraService(ISplitBraceService splitBraceService) : IScrapingService
{
private readonly IScrapingHelperService _scrapingHelperService = scrapingHelperService;
private readonly ISplitBraceService _splitBraceService = splitBraceService;

public bool IsMatchSite(Uri uri)
{
Expand Down Expand Up @@ -172,7 +172,7 @@ public async ValueTask<EpubDocument> ScrapingAsync(string url, string coverFileP
paragraph.Text += TextProcess(midashi);
document.Chapters[chapterNum].Sections[sectionNum].Elements.Add(new Paragraph());

foreach (var splitText in _scrapingHelperService.SplitBrace(TextProcess(midashi)))
foreach (var splitText in _splitBraceService.SplitBrace(TextProcess(midashi)))
{
if (document.Chapters[chapterNum].Sections[sectionNum].Elements[^1] is Paragraph paragraph1)
{
Expand All @@ -191,7 +191,7 @@ public async ValueTask<EpubDocument> ScrapingAsync(string url, string coverFileP
document.EnsureParagraph(chapterNum, sectionNum);
if ((document.Chapters[chapterNum].Sections[sectionNum].Elements[^1] is Paragraph paragraph))
{
var split = _scrapingHelperService.SplitBrace(TextProcess(element));
var split = _splitBraceService.SplitBrace(TextProcess(element));
for (int i = 0; i < split.Count - 1; i++)
{
if (document.Chapters[chapterNum].Sections[sectionNum].Elements[^1] is Paragraph paragraph1)
Expand Down Expand Up @@ -229,7 +229,7 @@ public async ValueTask<EpubDocument> ScrapingAsync(string url, string coverFileP
document.EnsureParagraph(chapterNum, sectionNum);
if ((document.Chapters[chapterNum].Sections[sectionNum].Elements[^1] is Paragraph paragraph))
{
foreach (var splitText in _scrapingHelperService.SplitBrace(TextProcess(element)))
foreach (var splitText in _splitBraceService.SplitBrace(TextProcess(element)))
{
if (document.Chapters[chapterNum].Sections[sectionNum].Elements[^1] is Paragraph paragraph1)
{
Expand Down Expand Up @@ -340,7 +340,7 @@ public async ValueTask<EpubDocument> ScrapingAsync(string url, string coverFileP
document.EnsureParagraph(chapterNum, sectionNum);
if ((document.Chapters[chapterNum].Sections[sectionNum].Elements[^1] is Paragraph paragraph))
{
foreach (var splitText in _scrapingHelperService.SplitBrace(TextProcess(element)))
foreach (var splitText in _splitBraceService.SplitBrace(TextProcess(element)))
{
if (document.Chapters[chapterNum].Sections[sectionNum].Elements[^1] is Paragraph paragraph1)
{
Expand Down Expand Up @@ -375,7 +375,7 @@ public async ValueTask<EpubDocument> ScrapingAsync(string url, string coverFileP
document.EnsureParagraph(chapterNum, sectionNum);
if ((document.Chapters[chapterNum].Sections[sectionNum].Elements[^1] is Paragraph paragraph))
{
var split = _scrapingHelperService.SplitBrace(TextProcess(element));
var split = _splitBraceService.SplitBrace(TextProcess(element));
for (int i = 0; i < split.Count - 1; i++)
{
if (document.Chapters[chapterNum].Sections[sectionNum].Elements[^1] is Paragraph paragraph1)
Expand Down Expand Up @@ -417,7 +417,7 @@ public async ValueTask<EpubDocument> ScrapingAsync(string url, string coverFileP
{
paragraph.Text += TextProcess(element);

var split = _scrapingHelperService.SplitBrace(TextProcess(element));
var split = _splitBraceService.SplitBrace(TextProcess(element));
for (int i = 0; i < split.Count - 1; i++)
{
if (document.Chapters[chapterNum].Sections[sectionNum].Elements[^1] is Paragraph paragraph1)
Expand Down Expand Up @@ -463,7 +463,7 @@ public async ValueTask<EpubDocument> ScrapingAsync(string url, string coverFileP
document.EnsureParagraph(chapterNum, sectionNum);
if ((document.Chapters[chapterNum].Sections[sectionNum].Elements[^1] is Paragraph paragraph))
{
var split = _scrapingHelperService.SplitBrace(TextReplace(nextNode.Text()));
var split = _splitBraceService.SplitBrace(TextReplace(nextNode.Text()));
for (int i = 0; i < split.Count - 1; i++)
{
if (document.Chapters[chapterNum].Sections[sectionNum].Elements[^1] is Paragraph paragraph1)
Expand Down
14 changes: 7 additions & 7 deletions Epub/KoeBook.Epub/Services/ScrapingNaroService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

namespace KoeBook.Epub.Services
{
public partial class ScrapingNaroService(IHttpClientFactory httpClientFactory, IScrapingHelperService scrapingHelperService) : IScrapingService
public partial class ScrapingNaroService(IHttpClientFactory httpClientFactory, ISplitBraceService splitBraceService) : IScrapingService
{
private readonly IHttpClientFactory _httpCliantFactory = httpClientFactory;
private readonly IScrapingHelperService _scrapingHelperService = scrapingHelperService;
private readonly ISplitBraceService _splitBraceService = splitBraceService;

public bool IsMatchSite(Uri uri)
{
Expand Down Expand Up @@ -180,7 +180,7 @@ private async ValueTask<SectionWithChapterTitle> ReadPageAsync(string url, bool
{
if (!string.IsNullOrWhiteSpace(item.InnerHtml))
{
_scrapingHelperService.AddText(item.InnerHtml);
_splitBraceService.AddText(item.InnerHtml);
}
}
else if (item.ChildElementCount == 1)
Expand Down Expand Up @@ -214,12 +214,12 @@ private async ValueTask<SectionWithChapterTitle> ReadPageAsync(string url, bool
{
if (!string.IsNullOrWhiteSpace(item.InnerHtml))
{
_scrapingHelperService.AddText(item.InnerHtml);
_splitBraceService.AddText(item.InnerHtml);
}
}
else if (item.Children[0] is IHtmlBreakRowElement)
{
foreach (var split in _scrapingHelperService.SplitBrace(_scrapingHelperService.GetText()))
foreach (var split in _splitBraceService.SplitBrace(_splitBraceService.GetText()))
{
section.Elements.Add(new Paragraph() { Text = split });
}
Expand All @@ -244,10 +244,10 @@ private async ValueTask<SectionWithChapterTitle> ReadPageAsync(string url, bool

if (!string.IsNullOrWhiteSpace(item.InnerHtml))
{
_scrapingHelperService.AddText(item.InnerHtml);
_splitBraceService.AddText(item.InnerHtml);
}
}
foreach (var split in _scrapingHelperService.SplitBrace(_scrapingHelperService.GetText()))
foreach (var split in _splitBraceService.SplitBrace(_splitBraceService.GetText()))
{
section.Elements.Add(new Paragraph() { Text = split });
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace KoeBook.Epub.Services;

public class ScrapingHelperService : IScrapingHelperService
public class SplitBraceService : ISplitBraceService
{
private List<StringBuilder> stringBuilders = new();

Expand Down
2 changes: 1 addition & 1 deletion KoeBook.Test/Epub/ScrapingHelperTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public static object[][] TestCases()
[MemberData(nameof(TestCases))]
public void SplitBraceTest(string text, List<string> expected)
{
var helper = new ScrapingHelperService();
var helper = new SplitBraceService();
Assert.Equal(expected, helper.SplitBrace(text));
}
}

0 comments on commit 5c3bcb6

Please sign in to comment.