#!/bin/sh

# This copies and patches the namespace so we can use it as a static library with GHKit on the iPhone.

SRC_DIR="$HOME/Projects/gh-kit/Classes"
DEST_DIR="`pwd`/GHKit"

FILES="GHNSInvocation+Utils GHNSObject+Invocation GHNSInvocationProxy"
CLASSES="GHNSInvocationProxy"

for FILE in $FILES; do
  cp -v $SRC_DIR/$FILE.m $DEST_DIR/
  cp -v $SRC_DIR/$FILE.h $DEST_DIR/
done

for CLASS in $CLASSES; do
  REGEX="s@${CLASS}@${CLASS}_GHUNIT@g"
  echo "Patching class: $REGEX"
  perl -pi -e $REGEX $DEST_DIR/*
done

echo "Patching to unique namespace"
perl -pi -e 's@_GHKIT@_GHUNIT@g' $DEST_DIR/*
perl -pi -e 's@gh_@ghu_@g' $DEST_DIR/*
