Created
February 7, 2017 06:40
-
-
Save hiasinho/77e2065a585295fa7e5a8877a7fac33f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
RED='\033[0;31m' | |
YELLOW='\033[1;33m' | |
NC='\033[0m' # No Color | |
FILE_TYPES="\.(erb|html|haml|rb|js|jsx|cjsx)" | |
CLASSES_PREFIX="class(Name)?=[\"\'](.*\s)?" | |
SELECTORS=( | |
"Containers :container" | |
"Rows :row" | |
"Columns :column(s)?" | |
"Sizes :(small|medium|large)-\d{1,2}" | |
"Pushes & Pulls:(small|medium|large)-(pull|push)-\d{1,2}" | |
"Hiding :hide-for-(small|medium|large)" | |
) | |
echo "" | |
echo "Files infected by Zurb Foundation classes:" | |
echo "==========================================" | |
printf "\n==> Pattern Prefix: ${RED}/%s/${NC}\n" "$CLASSES_PREFIX" | |
printf "==> File Types: ${RED}/%s/${NC}\n\n" "$FILE_TYPES" | |
printf "Files\tOccurances\tName\t\t\t\tPattern\n" | |
echo "------------------------------------------------------------------------------------" | |
for selector in "${SELECTORS[@]}" ; do | |
KEY=${selector%%:*} | |
PATTERN=${selector#*:} | |
COMBINED_PATTERN=${CLASSES_PREFIX}${PATTERN} | |
AMOUNT=`ag -G $FILE_TYPES -i -l --stats "$COMBINED_PATTERN" | ag -o '^[0-9]+(?=\sfiles\scontained)'` | |
OCCUR=`ag -G $FILE_TYPES -i -l --stats "$COMBINED_PATTERN" | ag -o '^[0-9]+(?=\smatches)'` | |
printf "${YELLOW}%s\t%s${NC}\t\t%s\t\t\t${RED}%s${NC}\n" "$AMOUNT" "$OCCUR" "$KEY" "$PATTERN" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment