Skip to content

Instantly share code, notes, and snippets.

@sent-hil sent-hil/gist:4641437
Last active Dec 11, 2015

Embed
What would you like to do?
zsh function to show specs to code ratio in a rails folder, anything over 0.75 is good.
prompt_rspec_stats() {
if [[ ((-d app || -d lib) && -d spec) ]]; then
if [[ (-d app) ]]; then
local app=`wc -l app/**/*.rb | grep -oE "[0-9]+" | tail -n 1`
else
local app=`wc -l lib/**/*.rb | grep -oE "[0-9]+" | tail -n 1`
fi
local spec=$((`wc -l spec/**/*.rb | grep -oE "[0-9]+" | tail -n 1`))+0.01
local ratio=`printf "%.2f\n" $((spec/app))`
[[ ratio -ge 0.75 ]] && prompt_segment cyan black "$ratio"
[[ ratio -ge 0.5 && ratio -lt 0.75 ]] && prompt_segment yellow black "$ratio"
[[ ratio -lt 0.5 ]] && prompt_segment red black "$ratio"
fi
}
@dritter

This comment has been minimized.

Copy link

commented Apr 2, 2015

Nice piece of code! Just ported it to powerlevel9k-Theme:
Powerlevel9k/powerlevel9k#19

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.