Skip to content

Commit

Permalink
Whitespace unify (2 spaces) & .editorconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
niieani committed Jan 23, 2016
1 parent bb0ac1b commit 61ab903
Show file tree
Hide file tree
Showing 18 changed files with 1,003 additions and 973 deletions.
14 changes: 14 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# EditorConfig is awesome: http://EditorConfig.org

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true

# 2 space indentation
[**.*]
indent_style = space
indent_size = 2
18 changes: 18 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Auto detect text files and perform LF normalization
* text eol=lf
*.ico binary

# Custom for Visual Studio
*.cs diff=csharp

# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
7 changes: 7 additions & 0 deletions .idea/bashsupport_project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 26 additions & 26 deletions lib/oo-framework.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,34 @@
### BOOTSTRAP FUNCTIONS ###
###########################

System::Bootstrap(){
local file
local path
for file in "$__oo__libPath"/system/*.sh
do
path="$(File::GetAbsolutePath "$file")"
__oo__importedFiles+=( "$path" )
System::Bootstrap() {
local file
local path
for file in "$__oo__libPath"/system/*.sh
do
path="$(File::GetAbsolutePath "$file")"
__oo__importedFiles+=( "$path" )

## note: aliases are visible inside functions only if
## they were initialized AFTER they were created
## this is the reason why we have to load lib/system/* in a specific order (numbers)
if ! source "$path"
then
cat <<< "FATAL ERROR: Unable to bootstrap (loading $libPath)" 1>&2
exit 1
fi
done
## note: aliases are visible inside functions only if
## they were initialized AFTER they were created
## this is the reason why we have to load lib/system/* in a specific order (numbers)
if ! source "$path"
then
cat <<< "FATAL ERROR: Unable to bootstrap (loading $libPath)" 1>&2
exit 1
fi
done
}

File::GetAbsolutePath() {
# http://stackoverflow.com/questions/3915040/bash-fish-command-to-print-absolute-path-to-a-file
# $1 : relative filename
if [[ "$file" == "/"* ]]
then
echo "$file"
else
echo "$(cd "$(dirname "$1")" && pwd)/$(basename "$1")"
fi
# http://stackoverflow.com/questions/3915040/bash-fish-command-to-print-absolute-path-to-a-file
# $1 : relative filename
if [[ "$file" == "/"* ]]
then
echo "$file"
else
echo "$(cd "$(dirname "$1")" && pwd)/$(basename "$1")"
fi
}

########################
Expand All @@ -49,9 +49,9 @@ declare -g __oo__path="${__oo__libPath}/.."
declare -ag __oo__importedFiles
if [[ -n "$__INTERNAL_LOGGING__" ]]
then
alias DEBUG=":; "
alias DEBUG=":; "
else
alias DEBUG=":; #"
alias DEBUG=":; #"
fi

System::Bootstrap
Expand Down
138 changes: 69 additions & 69 deletions lib/system/00_log.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,97 +4,97 @@ declare -Ag __oo__logDisabledFilter
declare -Ag __oo__loggers

Log::NameScope() {
local scopeName="$1"
local script="${BASH_SOURCE[1]}"
__oo__logScopes["$script"]="$scopeName"
local scopeName="$1"
local script="${BASH_SOURCE[1]}"
__oo__logScopes["$script"]="$scopeName"
}

Log::AddOutput() {
local scopeName="$1"
local outputType="${2:-STDERR}"
__oo__logScopeOutputs["$scopeName"]+="$outputType;"
local scopeName="$1"
local outputType="${2:-STDERR}"
__oo__logScopeOutputs["$scopeName"]+="$outputType;"
}

Log::ResetOutputsAndFilters() {
local scopeName="$1"
unset __oo__logScopeOutputs["$scopeName"]
unset __oo__logDisabledFilter["$scopeName"]
local scopeName="$1"
unset __oo__logScopeOutputs["$scopeName"]
unset __oo__logDisabledFilter["$scopeName"]
}

Log::ResetAllOutputsAndFilters() {
unset __oo__logScopeOutputs
unset __oo__logDisabledFilter
declare -Ag __oo__logScopeOutputs
declare -Ag __oo__logDisabledFilter
unset __oo__logScopeOutputs
unset __oo__logDisabledFilter
declare -Ag __oo__logScopeOutputs
declare -Ag __oo__logDisabledFilter
}

Log::DisableFilter() {
__oo__logDisabledFilter["$1"]=true
__oo__logDisabledFilter["$1"]=true
}

Log() {
local callingFunction="${FUNCNAME[1]}"
local callingScript="${BASH_SOURCE[1]}"
local scope
if [[ ! -z "${__oo__logScopes["$callingScript"]}" ]]
local callingFunction="${FUNCNAME[1]}"
local callingScript="${BASH_SOURCE[1]}"
local scope
if [[ ! -z "${__oo__logScopes["$callingScript"]}" ]]
then
scope="${__oo__logScopes["$callingScript"]}"
else # just the filename without extension
scope="${callingScript##*/}"
scope="${scope%.*}"
fi
local loggerList
local loggers
local logger
local logged

if [[ ! -z "$subject" ]]
then
if [[ ! -z "${__oo__logScopeOutputs["$scope/$callingFunction/$subject"]}" ]]
then
scope="${__oo__logScopes["$callingScript"]}"
else # just the filename without extension
scope="${callingScript##*/}"
scope="${scope%.*}"
fi
local loggerList
local loggers
local logger
local logged

if [[ ! -z "$subject" ]]
loggerList="${__oo__logScopeOutputs["$scope/$callingFunction/$subject"]}"
elif [[ ! -z "${__oo__logScopeOutputs["$scope/$subject"]}" ]]
then
loggerList="${__oo__logScopeOutputs["$scope/$subject"]}"
elif [[ ! -z "${__oo__logScopeOutputs["$subject"]}" ]]
then
if [[ ! -z "${__oo__logScopeOutputs["$scope/$callingFunction/$subject"]}" ]]
then
loggerList="${__oo__logScopeOutputs["$scope/$callingFunction/$subject"]}"
elif [[ ! -z "${__oo__logScopeOutputs["$scope/$subject"]}" ]]
then
loggerList="${__oo__logScopeOutputs["$scope/$subject"]}"
elif [[ ! -z "${__oo__logScopeOutputs["$subject"]}" ]]
then
loggerList="${__oo__logScopeOutputs["$subject"]}"
fi

loggers=( ${loggerList//;/ } )
for logger in "${loggers[@]}"
do
subject="${subject:-LOG}" Log::Using "$logger" "$@"
logged=true
done
loggerList="${__oo__logScopeOutputs["$subject"]}"
fi

if [[ ! -z "${__oo__logScopeOutputs["$scope/$callingFunction"]}" ]]

loggers=( ${loggerList//;/ } )
for logger in "${loggers[@]}"
do
subject="${subject:-LOG}" Log::Using "$logger" "$@"
logged=true
done
fi

if [[ ! -z "${__oo__logScopeOutputs["$scope/$callingFunction"]}" ]]
then
if [[ -z $logged ]] || [[ ${__oo__logDisabledFilter["$scope/$callingFunction"]} == true || ${__oo__logDisabledFilter["$scope"]} == true ]]
then
if [[ -z $logged ]] || [[ ${__oo__logDisabledFilter["$scope/$callingFunction"]} == true || ${__oo__logDisabledFilter["$scope"]} == true ]]
then
loggerList="${__oo__logScopeOutputs["$scope/$callingFunction"]}"
loggers=( ${loggerList//;/ } )
for logger in "${loggers[@]}"
do
subject="${subject:-LOG}" Log::Using "$logger" "$@"
logged=true
done
fi
loggerList="${__oo__logScopeOutputs["$scope/$callingFunction"]}"
loggers=( ${loggerList//;/ } )
for logger in "${loggers[@]}"
do
subject="${subject:-LOG}" Log::Using "$logger" "$@"
logged=true
done
fi

if [[ ! -z "${__oo__logScopeOutputs["$scope"]}" ]]
fi

if [[ ! -z "${__oo__logScopeOutputs["$scope"]}" ]]
then
if [[ -z $logged ]] || [[ ${__oo__logDisabledFilter["$scope"]} == true ]]
then
if [[ -z $logged ]] || [[ ${__oo__logDisabledFilter["$scope"]} == true ]]
then
loggerList="${__oo__logScopeOutputs["$scope"]}"
loggers=( ${loggerList//;/ } )
for logger in "${loggers[@]}"
do
subject="${subject:-LOG}" Log::Using "$logger" "$@"
done
fi
loggerList="${__oo__logScopeOutputs["$scope"]}"
loggers=( ${loggerList//;/ } )
for logger in "${loggers[@]}"
do
subject="${subject:-LOG}" Log::Using "$logger" "$@"
done
fi
fi
}

Log::RegisterLogger() {
Expand Down
Loading

0 comments on commit 61ab903

Please sign in to comment.