Permalink
Browse files

Rewrite loc-metrics.sh to generate SVG

  • Loading branch information...
lmorchard committed Sep 21, 2015
1 parent cdbbff7 commit 0014232c9858e082414e094be021170fda19aab0
Showing with 237 additions and 22 deletions.
  1. +123 −22 loc-metrics.sh
  2. +57 −0 shared-models.svg
  3. +57 −0 shared-views.svg
View
@@ -1,34 +1,135 @@
#!/bin/zsh
echo Total LoC
cat lib/**/*.js | wc -l
TOTAL_LOC=$(cat lib/**/*.js | wc -l);
echo All models LoC
cat lib/models/**/*.js | wc -l
MODELS_LOC=$(cat lib/models/**/*.js | wc -l);
MODELS_COMMON_LOC=$(cat lib/models/*js | wc -l);
MODELS_WEB_LOC=$(cat lib/models/web/*js | wc -l);
MODELS_NATIVE_LOC=$(cat lib/models/native/*js | wc -l);
echo Common shared models LoC
cat lib/models/*js | wc -l
VIEWS_LOC=$(cat lib/views/**/*.js | wc -l);
VIEWS_COMMON_LOC=$(cat lib/views/common-mixins.js | wc -l);
VIEWS_WEB_LOC=$(cat lib/views/web/*js | wc -l);
VIEWS_NATIVE_COMMON_LOC=$(cat lib/views/native-mixins.js | wc -l);
VIEWS_IOS_LOC=$(cat lib/views/ios/*js | wc -l);
VIEWS_ANDROID_LOC=$(cat lib/views/android/*js | wc -l);
echo Web specific models LoC
cat lib/models/web/*js | wc -l
cat << EOF0 > shared-models.svg
<svg version="1.1"
baseProfile="full"
width="500" height="500"
xmlns="http://www.w3.org/2000/svg">
echo Native specific models LoC
cat lib/models/native/*js | wc -l
<defs>
<style type="text/css"><![CDATA[
g.base-circles {
fill-opacity: 0.5;
}
text.title, g.base-labels text {
font-family: monospace;
font-size: 16pt;
font-weight: bold;
fill: black;
text-anchor: middle;
}
text.title {
text-decoration: underline;
font-size: 24pt;
}
g.areas text {
font-family: monospace;
font-size: 16pt;
fill: black;
text-anchor: middle;
}
]]></style>
</defs>
echo All views LoC
cat lib/views/**/*.js | wc -l
<rect width="100%" height="100%" fill="transparent" />
echo Common shared views LoC
cat lib/views/common-mixins.js | wc -l
<g class="base-circles">
<circle cx="33%" cy="33%" r="33%" fill="#f88" />
<circle cx="66%" cy="33%" r="33%" fill="#8f8" />
<circle cx="50%" cy="66%" r="33%" fill="#88f" />
</g>
echo Web specific views LoC
cat lib/views/web/*js | wc -l
<g class="base-labels">
<text x="20%" y="18%">iOS</text>
<text x="80%" y="18%">Android</text>
<text x="50%" y="88%">Web</text>
</g>
echo Native shared views LoC
cat lib/views/native-mixins.js | wc -l
<g class="areas">
<text x="20%" y="28%" class="a"></text>
<text x="50%" y="25%" class="ab">${MODELS_NATIVE_LOC}</text>
<text x="80%" y="28%" class="b"></text>
<text x="30%" y="55%" class="ac"></text>
<text x="50%" y="50%" class="abc">${MODELS_COMMON_LOC}</text>
<text x="70%" y="55%" class="bc"></text>
<text x="50%" y="75%" class="c">${MODELS_WEB_LOC}</text>
</g>
echo iOS specific views LoC
cat lib/views/ios/*js | wc -l
<text x="50%" y="5%" class="title">Models</text>
echo Android specific views LoC
cat lib/views/android/*js | wc -l
</svg>
EOF0
cat << EOF1 > shared-views.svg
<svg version="1.1"
baseProfile="full"
width="500" height="500"
xmlns="http://www.w3.org/2000/svg">
<defs>
<style type="text/css"><![CDATA[
g.base-circles {
fill-opacity: 0.5;
}
text.title, g.base-labels text {
font-family: monospace;
font-size: 16pt;
font-weight: bold;
fill: black;
text-anchor: middle;
}
text.title {
text-decoration: underline;
font-size: 24pt;
}
g.areas text {
font-family: monospace;
font-size: 16pt;
fill: black;
text-anchor: middle;
}
]]></style>
</defs>
<rect width="100%" height="100%" fill="transparent" />
<g class="base-circles">
<circle cx="33%" cy="33%" r="33%" fill="#f88" />
<circle cx="66%" cy="33%" r="33%" fill="#8f8" />
<circle cx="50%" cy="66%" r="33%" fill="#88f" />
</g>
<g class="base-labels">
<text x="20%" y="18%">iOS</text>
<text x="80%" y="18%">Android</text>
<text x="50%" y="88%">Web</text>
</g>
<g class="areas">
<text x="20%" y="28%" class="a">${VIEWS_IOS_LOC}</text>
<text x="50%" y="25%" class="ab">${VIEWS_NATIVE_COMMON_LOC}</text>
<text x="80%" y="28%" class="b">${VIEWS_ANDROID_LOC}</text>
<text x="30%" y="55%" class="ac"></text>
<text x="50%" y="50%" class="abc">${VIEWS_COMMON_LOC}</text>
<text x="70%" y="55%" class="bc"></text>
<text x="50%" y="75%" class="c">${VIEWS_WEB_LOC}</text>
</g>
<text x="50%" y="5%" class="title">Views</text>
</svg>
EOF1
View
@@ -0,0 +1,57 @@
<svg version="1.1"
baseProfile="full"
width="500" height="500"
xmlns="http://www.w3.org/2000/svg">
<defs>
<style type="text/css"><![CDATA[
g.base-circles {
fill-opacity: 0.5;
}
text.title, g.base-labels text {
font-family: monospace;
font-size: 16pt;
font-weight: bold;
fill: black;
text-anchor: middle;
}
text.title {
text-decoration: underline;
font-size: 24pt;
}
g.areas text {
font-family: monospace;
font-size: 16pt;
fill: black;
text-anchor: middle;
}
]]></style>
</defs>
<rect width="100%" height="100%" fill="transparent" />
<g class="base-circles">
<circle cx="33%" cy="33%" r="33%" fill="#f88" />
<circle cx="66%" cy="33%" r="33%" fill="#8f8" />
<circle cx="50%" cy="66%" r="33%" fill="#88f" />
</g>
<g class="base-labels">
<text x="20%" y="18%">iOS</text>
<text x="80%" y="18%">Android</text>
<text x="50%" y="88%">Web</text>
</g>
<g class="areas">
<text x="20%" y="28%" class="a"></text>
<text x="50%" y="25%" class="ab"> 25</text>
<text x="80%" y="28%" class="b"></text>
<text x="30%" y="55%" class="ac"></text>
<text x="50%" y="50%" class="abc"> 159</text>
<text x="70%" y="55%" class="bc"></text>
<text x="50%" y="75%" class="c"> 31</text>
</g>
<text x="50%" y="5%" class="title">Models</text>
</svg>
View
@@ -0,0 +1,57 @@
<svg version="1.1"
baseProfile="full"
width="500" height="500"
xmlns="http://www.w3.org/2000/svg">
<defs>
<style type="text/css"><![CDATA[
g.base-circles {
fill-opacity: 0.5;
}
text.title, g.base-labels text {
font-family: monospace;
font-size: 16pt;
font-weight: bold;
fill: black;
text-anchor: middle;
}
text.title {
text-decoration: underline;
font-size: 24pt;
}
g.areas text {
font-family: monospace;
font-size: 16pt;
fill: black;
text-anchor: middle;
}
]]></style>
</defs>
<rect width="100%" height="100%" fill="transparent" />
<g class="base-circles">
<circle cx="33%" cy="33%" r="33%" fill="#f88" />
<circle cx="66%" cy="33%" r="33%" fill="#8f8" />
<circle cx="50%" cy="66%" r="33%" fill="#88f" />
</g>
<g class="base-labels">
<text x="20%" y="18%">iOS</text>
<text x="80%" y="18%">Android</text>
<text x="50%" y="88%">Web</text>
</g>
<g class="areas">
<text x="20%" y="28%" class="a"> 159</text>
<text x="50%" y="25%" class="ab"> 90</text>
<text x="80%" y="28%" class="b"> 207</text>
<text x="30%" y="55%" class="ac"></text>
<text x="50%" y="50%" class="abc"> 75</text>
<text x="70%" y="55%" class="bc"></text>
<text x="50%" y="75%" class="c"> 233</text>
</g>
<text x="50%" y="5%" class="title">Views</text>
</svg>

0 comments on commit 0014232

Please sign in to comment.