Skip to content

Commit

Permalink
Merge pull request #788 from moufort/newDev
Browse files Browse the repository at this point in the history
add a root variable for give the root folder of the blog
  • Loading branch information
Ducasse authored Jul 4, 2024
2 parents de6ef8f + 62d0a75 commit 5ad9dfb
Show file tree
Hide file tree
Showing 10 changed files with 243 additions and 40 deletions.
16 changes: 15 additions & 1 deletion src/Microdown-Blog-Tests/MicAbstractBlogCreatorTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ MicAbstractBlogCreatorTest >> setUp [

"Put here a common initialization logic for tests"

abstractBlog := MicAbstractBlogCreator new
abstractBlog := MicAbstractBlogCreator new.
abstractBlog root: MicFileTestResources new genericEmptyRootPath
]

{ #category : 'tests' }
Expand Down Expand Up @@ -61,6 +62,19 @@ MicAbstractBlogCreatorTest >> testMakeALinkToWithNilArguments [
assert: link plainText equals: '[Undefined](Undefined)'
]

{ #category : 'tests' }
MicAbstractBlogCreatorTest >> testMakeALinkToWithRootPath [

| link ressources |
ressources := MicFileTestResources new.
abstractBlog root: ressources genericNonEmptyRootPath.
link := abstractBlog makeALink: 'Pharo is cool' to: 'Test' asFileReference.

self
assert: (link isKindOf: MicLinkBlock);
assert: link plainText equals: '[Pharo is cool](', ressources genericNonEmptyRootPath ,'Test)'
]

{ #category : 'tests' }
MicAbstractBlogCreatorTest >> testVerifyDateMetadata [

Expand Down
43 changes: 21 additions & 22 deletions src/Microdown-Blog-Tests/MicBlogCreatorTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Class {
#instVars : [
'fileSystem',
'blog',
'resources'
'resources',
'singleSummarizer'
],
#category : 'Microdown-Blog-Tests',
#package : 'Microdown-Blog-Tests'
Expand Down Expand Up @@ -44,22 +45,30 @@ MicBlogCreatorTest >> listOfFile [
{ #category : 'running' }
MicBlogCreatorTest >> setUp [

| monthList |
| monthList monthListCreator|

super setUp.

"Put here a common initialization logic for tests"
resources := MicFileTestResources new.

monthList := {
(Month year: 2018 month: 1).
(Month year: 2019 month: 1) }.

"Put here a common initialization logic for tests"
resources := MicFileTestResources new.
monthListCreator := MicMonthListCreator new.
monthListCreator root: resources genericEmptyRootPath.

singleSummarizer := MicSingleSummarizer new.
singleSummarizer targetDirectory: '/';
root: resources genericEmptyRootPath.

self generateArchitecture.
blog := MicBlogCreator new.
blog
targetDirectory: fileSystem / 'html';
sourceDirectory: fileSystem / 'source';
dateList: (MicMonthListCreator new generateMicListBlockOfLinkDateWith: monthList).
root: resources genericEmptyRootPath;
dateList: (monthListCreator generateMicListBlockOfLinkDateWith: monthList).
]

{ #category : 'tests' }
Expand Down Expand Up @@ -144,13 +153,10 @@ MicBlogCreatorTest >> testCreateHtmlFileToReplace [
{ #category : 'tests' }
MicBlogCreatorTest >> testCreateHtmlGroupFileAt [

| root summarizer singleSummarizer allFileParse |
| root summarizer allFileParse |
summarizer := MicListSummarizer new.
summarizer targetDirectory: 'html'.

singleSummarizer := MicSingleSummarizer new.
singleSummarizer targetDirectory: blog targetDirectory.

allFileParse := self listOfFile collect: [ :each |
singleSummarizer summarizeFile: each ].

Expand All @@ -172,6 +178,7 @@ MicBlogCreatorTest >> testCreateHtmlSummarize [

| root summarizer |
summarizer := MicListSummarizer new.
summarizer root: resources genericEmptyRootPath.
summarizer targetDirectory: blog targetDirectory.
root := summarizer summarizeFile: self listOfFile.
blog createHtmlSummarize: root.
Expand All @@ -195,17 +202,11 @@ MicBlogCreatorTest >> testInitializeMonthList [
| listSingleSummarizer singleSum1 singleSum2 singleSum3 |
listSingleSummarizer := Array new: 3.

singleSum1 := MicSingleSummarizer new targetDirectory:
blog targetDirectory.
singleSum1 := singleSum1 summarizeFile:
singleSum1 := singleSummarizer summarizeFile:
fileSystem / 'source' / 'anExample1.md'.
singleSum2 := MicSingleSummarizer new targetDirectory:
blog targetDirectory.
singleSum2 := singleSum2 summarizeFile:
singleSum2 := singleSummarizer summarizeFile:
fileSystem / 'source' / 'anExample2.md'.
singleSum3 := MicSingleSummarizer new targetDirectory:
blog targetDirectory.
singleSum3 := singleSum3 summarizeFile:
singleSum3 := singleSummarizer summarizeFile:
fileSystem / 'source' / 'test' / 'anExample3.md'.

listSingleSummarizer at: 1 put: singleSum1.
Expand Down Expand Up @@ -243,10 +244,8 @@ MicBlogCreatorTest >> testRootAssembly [
{ #category : 'tests' }
MicBlogCreatorTest >> testSortSingleSummarizedDocuments [

| listOfSummarizedDocuments summarized1 summarized2 summarized3 singleSummarizer |
| listOfSummarizedDocuments summarized1 summarized2 summarized3 |
listOfSummarizedDocuments := Array new: 3.
singleSummarizer := MicSingleSummarizer new.
singleSummarizer targetDirectory: '/'.

summarized1 := singleSummarizer summarize:
((Microdown parse:
Expand Down
59 changes: 56 additions & 3 deletions src/Microdown-Blog-Tests/MicFileTestResources.class.st
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
Class {
#name : 'MicFileTestResources',
#superclass : 'Object',
#instVars : [
'micSummarizer'
],
#category : 'Microdown-Blog-Tests',
#package : 'Microdown-Blog-Tests'
}
Expand All @@ -22,6 +19,20 @@ MicFileTestResources >> dumperInput1 [
^ root
]

{ #category : 'as yet unclassified' }
MicFileTestResources >> dumperInput1WithRootPath [

| root |
root := Microdown parse:
'# [A Cool Story](' , '' , self genericNonEmptyRootPath, '/anExample1.html' , '' , ')'.
root children add: (Microdown parse: '2019/01/09') children first.
root children add: (Microdown parse:
'Pharo is cool but this is a superlong paragraph Simple powerful language: No constructors, no...')
children first.

^ root
]

{ #category : 'as yet unclassified' }
MicFileTestResources >> dumperInput2 [

Expand All @@ -37,6 +48,21 @@ MicFileTestResources >> dumperInput2 [
^ root
]

{ #category : 'as yet unclassified' }
MicFileTestResources >> dumperInput2WithRootPath [

| root |
root := Microdown parse:
'# [Pharo is cool](' , '' , self genericNonEmptyRootPath, '/anExample2.html' , '' , ')'.
root children add:
(Microdown parse: '2019/01/22') children first.
root children add: (Microdown parse:
'If you are either a beginner or an expert in object-oriented programming, this MOOC will...')
children first.

^ root
]

{ #category : 'as yet unclassified' }
MicFileTestResources >> dumperInput3 [

Expand All @@ -52,6 +78,21 @@ MicFileTestResources >> dumperInput3 [
^ root
]

{ #category : 'as yet unclassified' }
MicFileTestResources >> dumperInput3WithRootPath [

| root |
root := Microdown parse:
'# [Mooc Pharo](' , '' , self genericNonEmptyRootPath, '/anExample3.html' , '' , ')'.
root children add:
(Microdown parse: '2018/01/29') children first.
root children add: (Microdown parse:
'Welcome to the Pharo Mooc (a set of videos, exercises, challenges, and miniprojects).')
children first.

^ root
]

{ #category : 'as yet unclassified' }
MicFileTestResources >> fileSystem [

Expand Down Expand Up @@ -265,6 +306,18 @@ When you participate to the mooc you get access to the quizz and the credit vali
^ file
]

{ #category : 'as yet unclassified' }
MicFileTestResources >> genericEmptyRootPath [

^ ''
]

{ #category : 'as yet unclassified' }
MicFileTestResources >> genericNonEmptyRootPath [

^ 'https://test/'
]

{ #category : 'as yet unclassified' }
MicFileTestResources >> workingDirectory [

Expand Down
24 changes: 22 additions & 2 deletions src/Microdown-Blog-Tests/MicListSummarizerTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,11 @@ MicListSummarizerTest >> setUp [
super setUp.
resources := MicFileTestResources new.
micSummarizer := MicListSummarizer new.
micSummarizer targetDirectory: '/html/' asFileReference.
micSummarizer targetDirectory: '/html/' asFileReference;
root: MicFileTestResources new genericEmptyRootPath.
singleSummarizer := MicSingleSummarizer new.
singleSummarizer targetDirectory: '/html/' asFileReference.
singleSummarizer targetDirectory: '/html/' asFileReference;
root: MicFileTestResources new genericEmptyRootPath.
]

{ #category : 'tests' }
Expand Down Expand Up @@ -115,6 +117,24 @@ MicListSummarizerTest >> testContentsOfAssembledListsIsCorrect [
self assert: root contents equals: dumper contents
]

{ #category : 'tests' }
MicListSummarizerTest >> testContentsWithRootPath [

| root dumper dumper1 dumper2 dumper3 |
singleSummarizer root: resources genericNonEmptyRootPath.
root := MicRealDumper new visit:
(micSummarizer assembleSummarizedDocuments:
self createListOfMicRootBlock).

dumper1 := MicRealDumper new visit: resources dumperInput1WithRootPath.
dumper2 := MicRealDumper new visit: resources dumperInput2WithRootPath.
dumper3 := MicRealDumper new visit: resources dumperInput3WithRootPath.

dumper := dumper1 contents , dumper2 contents , dumper3 contents.

self assert: root contents equals: dumper contents
]

{ #category : 'tests' }
MicListSummarizerTest >> testGroupByDate [

Expand Down
49 changes: 46 additions & 3 deletions src/Microdown-Blog-Tests/MicMonthListCreatorTest.class.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Class {
#name : 'MicMonthListCreatorTest',
#superclass : 'TestCase',
#instVars : [
'monthListCreator',
'ressources'
],
#category : 'Microdown-Blog-Tests',
#package : 'Microdown-Blog-Tests'
}
Expand All @@ -11,12 +15,24 @@ MicMonthListCreatorTest >> numberOfMonthSince2014 [
^ Date today year - 2014 * 12 + Date today month index
]

{ #category : 'running' }
MicMonthListCreatorTest >> setUp [
super setUp.

"Put here a common initialization logic for tests"

ressources := MicFileTestResources new.

monthListCreator := MicMonthListCreator new.
monthListCreator root: MicFileTestResources new genericEmptyRootPath
]

{ #category : 'tests' }
MicMonthListCreatorTest >> testGenerateDateListSince2014 [

| dateList |

dateList := MicMonthListCreator new generateDateListSince2014.
dateList := monthListCreator generateDateListSince2014.

self assert: dateList size equals: (Date today year - 2014)*12 + Date today month index .
self assert: dateList first equals: (Date newDay: 1 month: 1 year: 2014) month .
Expand All @@ -30,7 +46,7 @@ MicMonthListCreatorTest >> testGenerateMicListBlockOfLinkDate [
fileSystem := FileSystem memory.
fileSystem createDirectory: '/html'.

root := MicMonthListCreator new generateMicListBlockOfLinkDate.
root := monthListCreator generateMicListBlockOfLinkDate.

self assert: (root isKindOf: MicRootBlock).
self
Expand All @@ -56,7 +72,7 @@ MicMonthListCreatorTest >> testGenerateMicListBlockOfLinkDateWith [
fileSystem := FileSystem memory.
fileSystem createDirectory: '/html'.

root := MicMonthListCreator new generateMicListBlockOfLinkDate.
root := monthListCreator generateMicListBlockOfLinkDate.

self
assert: (root isKindOf: MicRootBlock);
Expand All @@ -73,3 +89,30 @@ MicMonthListCreatorTest >> testGenerateMicListBlockOfLinkDateWith [
equals: '[' , Date today month asString , '](/_monthBlog/'
, Date today month name , '_' , Date today year asString , '.html)'
]

{ #category : 'tests' }
MicMonthListCreatorTest >> testGenerateMicListBlockOfLinkDateWithRootPath [

| dateList fileSystem root |
fileSystem := FileSystem memory.
fileSystem createDirectory: '/html'.

monthListCreator root: ressources genericNonEmptyRootPath.

root := monthListCreator generateMicListBlockOfLinkDate.

self
assert: (root isKindOf: MicRootBlock);
assert: root children size equals: 2;
assert: (root children first isKindOf: MicHeaderBlock);
assert: (root children second isKindOf: MicUnorderedListBlock).

dateList := root children second.
self
assert: dateList children size equals: self numberOfMonthSince2014;
assert: dateList children first children first plainText
equals: '[January 2014](', ressources genericNonEmptyRootPath ,'/_monthBlog/January_2014.html)';
assert: dateList children last children first plainText
equals: '[' , Date today month asString , '](', ressources genericNonEmptyRootPath ,'/_monthBlog/'
, Date today month name , '_' , Date today year asString , '.html)'
]
Loading

0 comments on commit 5ad9dfb

Please sign in to comment.