From 803c1145097d2cd211332ade2b0bc4fc2b2491e9 Mon Sep 17 00:00:00 2001 From: Nate Walczak Date: Thu, 19 Feb 2015 17:52:56 -0500 Subject: [PATCH 1/5] enhance storyboard manager source generator You can now pass in a directory or just a single storyboard. You can also pass a second argument to redirect where the source files are created. --- bin/DLRStoryboardManager.sh | 65 ++++++++++++++++++++++++++++++++----- 1 file changed, 56 insertions(+), 9 deletions(-) diff --git a/bin/DLRStoryboardManager.sh b/bin/DLRStoryboardManager.sh index a422bef..96a4056 100755 --- a/bin/DLRStoryboardManager.sh +++ b/bin/DLRStoryboardManager.sh @@ -8,8 +8,10 @@ # 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 @@ -17,20 +19,65 @@ if [[ ( $# == "--help") || ( $# == "-h" ) ]]; then 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 . -iname '*.storyboard' -exec "$0" {} "${target_directory}" \; -output="`dirname $storyboard`/DLRStoryboardManager+${name}.m" + else -[ -f "${output}" ] && rm "${output}" + find . -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 From 9273fdc2740f75443f81be962826daba9963c24a Mon Sep 17 00:00:00 2001 From: Jon Shier Date: Thu, 19 Feb 2015 18:25:42 -0500 Subject: [PATCH 2/5] Properly quote the storyboard path so spaces are handled. --- bin/DLRStoryboardManager.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/DLRStoryboardManager.sh b/bin/DLRStoryboardManager.sh index 96a4056..e2a7bb4 100755 --- a/bin/DLRStoryboardManager.sh +++ b/bin/DLRStoryboardManager.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -x # # DLRStoryboardManager.sh # DLRUIKit @@ -35,7 +35,7 @@ process_storyboard() { storyboard=$1 - filename=`basename ${storyboard}` + filename=`basename "${storyboard}"` name="${filename%.*}" xslt="`dirname $0`/resources/DLRStoryboardManager.xsl" @@ -57,11 +57,11 @@ process_directory() { if [[ $# -ge 2 ]]; then target_directory=$2 - find . -iname '*.storyboard' -exec "$0" {} "${target_directory}" \; + find $1 -iname '*.storyboard' -exec "$0" {} "${target_directory}" \; else - find . -iname '*.storyboard' -exec "$0" {} \; + find $1 -iname '*.storyboard' -exec "$0" {} \; fi From 7fecdcdca47c1700aca105dca7df646a418dc3f9 Mon Sep 17 00:00:00 2001 From: Jon Shier Date: Thu, 19 Feb 2015 18:25:59 -0500 Subject: [PATCH 3/5] Update stylesheet to warn users that the file is generated. --- bin/resources/DLRStoryboardManager.xsl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bin/resources/DLRStoryboardManager.xsl b/bin/resources/DLRStoryboardManager.xsl index a486a46..6820938 100644 --- a/bin/resources/DLRStoryboardManager.xsl +++ b/bin/resources/DLRStoryboardManager.xsl @@ -21,6 +21,8 @@ .m + // + // This file is automatically generated; do not modify. // #import "DLRStoryboardManager.h" From caf25ea2efe116752f4781430135a1412cc4941b Mon Sep 17 00:00:00 2001 From: Nate Walczak Date: Thu, 19 Feb 2015 18:30:18 -0500 Subject: [PATCH 4/5] removed storyboard manager script debug switch --- bin/DLRStoryboardManager.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/DLRStoryboardManager.sh b/bin/DLRStoryboardManager.sh index e2a7bb4..dca970b 100755 --- a/bin/DLRStoryboardManager.sh +++ b/bin/DLRStoryboardManager.sh @@ -1,4 +1,4 @@ -#!/bin/bash -x +#!/bin/bash # # DLRStoryboardManager.sh # DLRUIKit From 65f22e953bf4275c5a9b7465bf26f4e0d1fa5fc3 Mon Sep 17 00:00:00 2001 From: Nate Walczak Date: Thu, 19 Feb 2015 20:05:22 -0500 Subject: [PATCH 5/5] increment pod version number --- DLRUIKit.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DLRUIKit.podspec b/DLRUIKit.podspec index a9aa8a6..6d3b83e 100644 --- a/DLRUIKit.podspec +++ b/DLRUIKit.podspec @@ -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'