Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

133 lines (117 sloc) 3.208 kB
#!/bin/sh
__sm.cache.map.add()
{
if ! __sm.string.contains "$1" "${_actions_cache[*]}"
then
_actions_cache+=( "$1" )
fi
}
# Step 1 collect direct filesystem mapping
__sm.cache.map.filesystem.initialize()
{
trace_filter action_detection || set -o xtrace
local _action_path _file_name
if [[ -d "${_actions_root}" ]]
then
for _action_path in "${_actions_root}"/*
do
[[ -f "${_action_path}" && -x "${_action_path}" ]] || continue
_action_path="${_action_path#${_actions_root}\/}"
_file_name="${_action_path##*/}"
# Ignore hidden files
case "${_file_name}" in
(.*) continue ;;
esac
__sm.cache.map.add "${_action_path}=${_action_path}"
done
fi
}
# Step 2 read map
__sm.cache.map.actions.initialize()
{
trace_filter action_detection || set -o xtrace
local _mapping
if [[ -f "${_map}" ]]
then
for _mapping in $( grep -v "^#" < "${_map}" || true )
do
__sm.cache.map.add "${_mapping}"
done
fi
}
__sm.module.detect.actions()
{
__sm.module.detect "$@" &&
[[ -f "${module_path}/actions" ]] &&
[[ -s "${module_path}/actions" ]]
}
# Step 3 collect dependent modules mapping
__sm.cache.map.modules.initialize()
{
trace_filter action_detection || set -o xtrace
local _modules _module_path _module_name _action_pair
if [[ ! -d "${_modules_root}" ]]
then
__sm.log.debug search "missing includes dir '${_modules_root}'?"
return 0
fi
_modules=( "${_modules_root}"/**/includes )
for _module_path in "${_modules[@]}"
do
[[ "${_module_path##*/}" == "includes" ]] || continue
_module_name="${_module_path#${_modules_root}\/}"
_module_name="${_module_name%includes}"
_module_name="${_module_name%\/}"
while read _module_dep
do
if __sm.extension.in.paths __sm.module.detect.actions "${_module_dep}"
then
__sm.log.search "actiondep" "${extension}${_module_name:+/}${_module_name}" "${module_path#${sm_path}\/}/actions"
while read _action_pair
do
if [[ "${_action_pair}" == [[:alpha:]]* ]]
then
__sm.cache.map.add "${_module_name:+${_module_name}/}${_action_pair/=*}=${_module_name:+${_module_name}/}${_action_pair/*=}"
fi
done < "${module_path}/actions"
fi
done < ${_module_path}
done
}
__sm.cache.map.find.matching()
{
local _method _name _item
_method="$1"
shift || __sm.log.fail "No method and action name was given for search"
_name="$1"
shift || __sm.log.fail "No action name was given for search"
for _item in "${_actions_cache[@]}"
do
case "${_method}" in
(only_one)
case "${_item}" in
(${_name}=*)
_found_actions+=("${_item}")
;;
esac
;;
(allow_many)
case "${_item}" in
(*${_name}*=*)
_found_actions+=("${_item}")
;;
esac
;;
(starting)
case "${_item}" in
(${_name}*=*)
_found_actions+=("${_item}")
;;
esac
;;
(*)
__sm.log.fail "Unknown search method, use 'only_one', 'allow_many', 'starting'."
;;
esac
done
}
Jump to Line
Something went wrong with that request. Please try again.