Skip to content

Commit

Permalink
Merge pull request #4 from detroit-labs/storyboard-manager
Browse files Browse the repository at this point in the history
enhance storyboard manager source generator
  • Loading branch information
nwdl committed Feb 20, 2015
2 parents 4307495 + 65f22e9 commit d6bac94
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 10 deletions.
2 changes: 1 addition & 1 deletion DLRUIKit.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "DLRUIKit"
s.version = "1.2.0"
s.version = "1.2.1"
s.summary = "A collection of UIKit categories."
s.homepage = "https://github.com/detroit-labs/dlr-uikit-ios"
s.license = 'MIT'
Expand Down
65 changes: 56 additions & 9 deletions bin/DLRStoryboardManager.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,76 @@
#

display_usage() {
echo -e "usage: `basename $0` storyboard"
echo -e "usage: `basename $0` storyboard [target]"
echo -e "usage: `basename $0` directory [target]"
echo -e "example: `basename $0` Project/Main.storyboard"
echo -e "example: `basename $0` Project Project/"
}

if [[ ( $# == "--help") || ( $# == "-h" ) ]]; then
display_usage
exit 1
fi

if [ $# -ne 1 ]; then
if [[ ( $# -lt 1 ) || ( $# -gt 2 ) ]]; then
display_usage
exit 2
fi

storyboard=$1
if [[ $# -eq 2 ]]; then
if [ ! -d "${2}" ]; then
echo -e "`basename $0`: $2: No such file or directory"
exit 3
fi
fi

process_storyboard() {

storyboard=$1

filename=`basename "${storyboard}"`
name="${filename%.*}"

xslt="`dirname $0`/resources/DLRStoryboardManager.xsl"

if [[ $# -ge 2 ]]; then
output="$2/DLRStoryboardManager+${name}.m"
else
output="`dirname $storyboard`/DLRStoryboardManager+${name}.m"
fi

[ -f "${output}" ] && rm "${output}"

xsltproc -o "${output}" --stringparam storyboard "${name}" "${xslt}" "${storyboard}"

}

process_directory() {

filename=`basename ${storyboard}`
name="${filename%.*}"
if [[ $# -ge 2 ]]; then

xslt="`dirname $0`/resources/DLRStoryboardManager.xsl"
target_directory=$2
find $1 -iname '*.storyboard' -exec "$0" {} "${target_directory}" \;

output="`dirname $storyboard`/DLRStoryboardManager+${name}.m"
else

[ -f "${output}" ] && rm "${output}"
find $1 -iname '*.storyboard' -exec "$0" {} \;

xsltproc -o "${output}" --stringparam storyboard "${name}" "${xslt}" "${storyboard}"
fi

}

if [ -d "${1}" ]; then

process_directory "$@"

elif [ -f "${1}" ]; then

process_storyboard "$@"

else

echo -e "`basename $0`: cannot open \`$1' (No such file or directory)"
exit 10

fi
2 changes: 2 additions & 0 deletions bin/resources/DLRStoryboardManager.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
<xsl:value-of select="$storyboard" />
<xsl:text>.m&#xa;</xsl:text>

<xsl:text>//&#xa;</xsl:text>
<xsl:text>// This file is automatically generated; do not modify.&#xa;</xsl:text>
<xsl:text>//&#xa;&#xa;</xsl:text>

<xsl:text>#import "DLRStoryboardManager.h"&#xa;&#xa;</xsl:text>
Expand Down

0 comments on commit d6bac94

Please sign in to comment.