forked from ochococo/Design-Patterns-In-Swift
-
Notifications
You must be signed in to change notification settings - Fork 2
/
generate-playground.sh
executable file
·59 lines (40 loc) · 1.74 KB
/
generate-playground.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
cleanThisMessForReadme () {
FILENAME=$1
{ rm $FILENAME && awk '{gsub("\\*/", "\n```swift\n", $0); print}' > $FILENAME; } < $FILENAME
{ rm $FILENAME && awk '{gsub("\\*//\\*:", "", $0); print}' > $FILENAME; } < $FILENAME
{ rm $FILENAME && awk '{gsub("/\\*:", "```\n", $0); print}' > $FILENAME; } < $FILENAME
{ rm $FILENAME && awk '{gsub("//\\*:", "", $0); print}' > $FILENAME; } < $FILENAME
{ rm $FILENAME && awk '{gsub("//:", "", $0); print}' > $FILENAME; } < $FILENAME
{ rm $FILENAME && awk 'NR>1{print buf}{buf = $0}' > $FILENAME; } < $FILENAME
}
makePlayground () {
for i in $( ls source/$1 );
do
if [[ $i == *"title"* ]]; then
continue
fi
cat source/$1/_title.swift source/$1/$i > $i
baseName=`echo $i | cut -d "." -f 1`
cp $i ./$1.playground/Pages/$baseName.xcplaygroundpage/Contents.swift
rm $i
done
}
cat source/behavioral/* > ./Behavioral.swift
cat source/creational/* > ./Creational.swift
cat source/structural/* > ./Structural.swift
cp ./Behavioral.swift ./Design-Patterns.playground/Pages/Behavioral.xcplaygroundpage/Contents.swift
cp ./Creational.swift ./Design-Patterns.playground/Pages/Creational.xcplaygroundpage/Contents.swift
cp ./Structural.swift ./Design-Patterns.playground/Pages/Structural.xcplaygroundpage/Contents.swift
cat source/header.swift source/*/* source/footer.swift > ./contents.swift
cleanThisMessForReadme ./contents.swift
cp ./contents.swift ./README.md
#zip -r -X Design-Patterns.playground.zip ./Design-Patterns.playground
rm ./Behavioral.swift
rm ./Creational.swift
rm ./Structural.swift
rm ./contents.swift
makePlayground Behavioral
makePlayground Creational
makePlayground Structural
zip -r -X Design-Patterns.zip ./Behavioral.playground ./Creational.playground ./Structural.playground