summaryrefslogtreecommitdiff
path: root/powerlevel9k.zsh-theme
diff options
context:
space:
mode:
authorromkatv <roman.perepelitsa@gmail.com>2019-05-21 15:55:55 +0300
committerromkatv <roman.perepelitsa@gmail.com>2019-05-21 15:55:55 +0300
commitee8a1b940fbed7500d71d0313a8c0288509adf7c (patch)
treed7bc9547a5255c1e5b97c08076909a2039814717 /powerlevel9k.zsh-theme
parentedc4e1375aba17b4193d4d6445d2841258008cb7 (diff)
speed up symfony2_tests and rspec_stats
Diffstat (limited to 'powerlevel9k.zsh-theme')
-rwxr-xr-xpowerlevel9k.zsh-theme24
1 files changed, 11 insertions, 13 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme
index 9c531c42..2ce66144 100755
--- a/powerlevel9k.zsh-theme
+++ b/powerlevel9k.zsh-theme
@@ -1401,11 +1401,10 @@ prompt_rust_version() {
# RSpec test ratio
prompt_rspec_stats() {
if [[ -d app && -d spec ]]; then
- local code_amount tests_amount
- code_amount=$(ls -1 app/**/*.rb | wc -l)
- tests_amount=$(ls -1 spec/**/*.rb | wc -l)
-
- build_test_stats "$1" "$0" "$2" "$code_amount" "$tests_amount" "RSpec" 'TEST_ICON'
+ local -a code=(app/**/*.rb(N))
+ (( $#code )) || return
+ local tests=(spec/**/*.rb(N))
+ build_test_stats "$1" "$0" "$2" "$#code" "$#tests" "RSpec" 'TEST_ICON'
fi
}
@@ -1531,11 +1530,10 @@ prompt_swap() {
# Symfony2-PHPUnit test ratio
prompt_symfony2_tests() {
if [[ -d src && -d app && -f app/AppKernel.php ]]; then
- local code_amount tests_amount
- code_amount=$(ls -1 src/**/*.php | grep -vc Tests)
- tests_amount=$(ls -1 src/**/*.php | grep -c Tests)
-
- build_test_stats "$1" "$0" "$2" "$code_amount" "$tests_amount" "SF2" 'TEST_ICON'
+ local -a all=(src/**/*.php(N))
+ local -a code=(${(@)all##*Tests*})
+ (( $#code )) || return
+ build_test_stats "$1" "$0" "$2" "$#code" "$(($#all - $#code))" "SF2" 'TEST_ICON'
fi
}
@@ -1553,11 +1551,11 @@ prompt_symfony2_version() {
# Show a ratio of tests vs code
build_test_stats() {
local code_amount="$4"
- local tests_amount="$5"+0.00001
+ local tests_amount="$5"
local headline="$6"
- # Set float precision to 2 digits:
- local -F 2 ratio=$(( (tests_amount/code_amount) * 100 ))
+ (( code_amount > 0 )) || return
+ local -F 2 ratio=$(( 100. * tests_amount / code_amount ))
(( ratio >= 75 )) && "$1_prompt_segment" "${2}_GOOD" "$3" "cyan" "$DEFAULT_COLOR" "$6" 0 '' "$headline: $ratio%%"
(( ratio >= 50 && ratio < 75 )) && "$1_prompt_segment" "$2_AVG" "$3" "yellow" "$DEFAULT_COLOR" "$6" 0 '' "$headline: $ratio%%"