Permalink
Browse files

Refactored template placeholder strings by moving them to global cons…

…tants.
  • Loading branch information...
1 parent 7d47416 commit 1f23b3e6ecca2c93e6d51771a0bafe059877b444 @tomaz committed Jan 17, 2011
@@ -663,17 +663,17 @@ - (void)printHelp {
ddprintf(@"[b] boolean parameter, uses no value, use --no- prefix to negate.\n");
ddprintf(@"\n");
ddprintf(@"[*] indicates parameters accepting placeholder strings:\n");
- ddprintf(@"- %%PROJECT replaced with --project-name\n");
- ddprintf(@"- %%PROJECTID replaced with normalized --project-name\n");
- ddprintf(@"- %%VERSION replaced with --project-version\n");
- ddprintf(@"- %%VERSIONID replaced with normalized --project-version\n");
- ddprintf(@"- %%COMPANY replaced with --project-company\n");
- ddprintf(@"- %%COMPANYID replaced with --company-id\n");
- ddprintf(@"- %%YEAR replaced with current year (format yyyy)\n");
- ddprintf(@"- %%UPDATEDATE replaced with current date (format yyyy-MM-dd)\n");
- ddprintf(@"- %%DOCSETBUNDLEFILENAME replaced with --docset-bundle-filename\n");
- ddprintf(@"- %%DOCSETATOMFILENAME replaced with --docset-atom-filename\n");
- ddprintf(@"- %%DOCSETPACKAGEFILENAME replaced with --docset-package-filename\n");
+ ddprintf(@"- %@ replaced with --project-name\n", kGBTemplatePlaceholderProject);
+ ddprintf(@"- %@ replaced with normalized --project-name\n", kGBTemplatePlaceholderProjectID);
+ ddprintf(@"- %@ replaced with --project-version\n", kGBTemplatePlaceholderVersion);
+ ddprintf(@"- %@ replaced with normalized --project-version\n", kGBTemplatePlaceholderVersionID);
+ ddprintf(@"- %@ replaced with --project-company\n", kGBTemplatePlaceholderCompany);
+ ddprintf(@"- %@ replaced with --company-id\n", kGBTemplatePlaceholderCompanyID);
+ ddprintf(@"- %@ replaced with current year (format yyyy)\n", kGBTemplatePlaceholderYear);
+ ddprintf(@"- %@ replaced with current date (format yyyy-MM-dd)\n", kGBTemplatePlaceholderUpdateDate);
+ ddprintf(@"- %@ replaced with --docset-bundle-filename\n", kGBTemplatePlaceholderDocSetBundleFilename);
+ ddprintf(@"- %@ replaced with --docset-atom-filename\n", kGBTemplatePlaceholderDocSetAtomFilename);
+ ddprintf(@"- %@ replaced with --docset-package-filename\n", kGBTemplatePlaceholderDocSetPackageFilename);
ddprintf(@"\n");
ddprintf(@"==================================================================\n");
ddprintf(@"Find more help and tips online:\n");
@@ -408,3 +408,17 @@
@property (retain) GBApplicationStringsProvider *stringTemplates;
@end
+
+#pragma -
+
+extern NSString *kGBTemplatePlaceholderCompanyID;
+extern NSString *kGBTemplatePlaceholderProjectID;
+extern NSString *kGBTemplatePlaceholderVersionID;
+extern NSString *kGBTemplatePlaceholderProject;
+extern NSString *kGBTemplatePlaceholderCompany;
+extern NSString *kGBTemplatePlaceholderVersion;
+extern NSString *kGBTemplatePlaceholderDocSetBundleFilename;
+extern NSString *kGBTemplatePlaceholderDocSetAtomFilename;
+extern NSString *kGBTemplatePlaceholderDocSetPackageFilename;
+extern NSString *kGBTemplatePlaceholderYear;
+extern NSString *kGBTemplatePlaceholderUpdateDate;
@@ -11,6 +11,20 @@
#import "GBDataObjects.h"
#import "GBApplicationSettingsProvider.h"
+NSString *kGBTemplatePlaceholderCompanyID = @"%COMPANYID";
+NSString *kGBTemplatePlaceholderProjectID = @"%PROJECTID";
+NSString *kGBTemplatePlaceholderVersionID = @"%VERSIONID";
+NSString *kGBTemplatePlaceholderProject = @"%PROJECT";
+NSString *kGBTemplatePlaceholderCompany = @"%COMPANY";
+NSString *kGBTemplatePlaceholderVersion = @"%VERSION";
+NSString *kGBTemplatePlaceholderDocSetBundleFilename = @"%DOCSETBUNDLEFILENAME";
+NSString *kGBTemplatePlaceholderDocSetAtomFilename = @"%DOCSETATOMFILENAME";
+NSString *kGBTemplatePlaceholderDocSetPackageFilename = @"%DOCSETPACKAGEFILENAME";
+NSString *kGBTemplatePlaceholderYear = @"%YEAR";
+NSString *kGBTemplatePlaceholderUpdateDate = @"%UPDATEDATE";
+
+#pragma mark -
+
@interface GBApplicationSettingsProvider ()
+ (NSSet *)nonCopyableProperties;
@@ -73,8 +87,8 @@ - (id)init {
self.warnOnInvalidCrossReference = YES;
self.warnOnMissingMethodArgument = YES;
- self.docsetBundleIdentifier = @"%COMPANYID.%PROJECTID";
- self.docsetBundleName = @"%PROJECT Documentation";
+ self.docsetBundleIdentifier = [NSString stringWithFormat:@"%@.%@", kGBTemplatePlaceholderCompanyID, kGBTemplatePlaceholderProjectID];
+ self.docsetBundleName = [NSString stringWithFormat:@"%@ Documentation", kGBTemplatePlaceholderProject];
self.docsetCertificateIssuer = @"";
self.docsetCertificateSigner = @"";
self.docsetDescription = @"";
@@ -84,13 +98,13 @@ - (id)init {
self.docsetPackageURL = @"";
self.docsetMinimumXcodeVersion = @"3.0";
self.docsetPlatformFamily = @"";
- self.docsetPublisherIdentifier = @"%COMPANYID.documentation";
- self.docsetPublisherName = @"%COMPANY";
- self.docsetCopyrightMessage = @"Copyright © %YEAR %COMPANY. All rights reserved.";
+ self.docsetPublisherIdentifier = [NSString stringWithFormat:@"%@.documentation", kGBTemplatePlaceholderCompanyID];
+ self.docsetPublisherName = [NSString stringWithFormat:@"%@", kGBTemplatePlaceholderCompany];
+ self.docsetCopyrightMessage = [NSString stringWithFormat:@"Copyright © %@ %@. All rights reserved.", kGBTemplatePlaceholderYear, kGBTemplatePlaceholderCompany];
- self.docsetBundleFilename = @"%COMPANYID.%PROJECTID.docset";
- self.docsetAtomFilename = @"%COMPANYID.%PROJECTID.atom";
- self.docsetPackageFilename = @"%COMPANYID.%PROJECTID-%VERSIONID.xar";
+ self.docsetBundleFilename = [NSString stringWithFormat:@"%@.%@.docset", kGBTemplatePlaceholderCompanyID, kGBTemplatePlaceholderProjectID];
+ self.docsetAtomFilename = [NSString stringWithFormat:@"%@.%@.atom", kGBTemplatePlaceholderCompanyID, kGBTemplatePlaceholderProjectID];
+ self.docsetPackageFilename = [NSString stringWithFormat:@"%@.%@-%@.xar", kGBTemplatePlaceholderCompanyID, kGBTemplatePlaceholderProjectID, kGBTemplatePlaceholderVersionID];
self.commentComponents = [GBCommentComponentsProvider provider];
self.stringTemplates = [GBApplicationStringsProvider provider];
@@ -266,17 +280,17 @@ - (BOOL)isTopLevelStoreObject:(id)object {
}
- (NSString *)stringByReplacingOccurencesOfPlaceholdersInString:(NSString *)string {
- string = [string stringByReplacingOccurrencesOfString:@"%COMPANYID" withString:self.companyIdentifier];
- string = [string stringByReplacingOccurrencesOfString:@"%PROJECTID" withString:self.projectIdentifier];
- string = [string stringByReplacingOccurrencesOfString:@"%VERSIONID" withString:self.versionIdentifier];
- string = [string stringByReplacingOccurrencesOfString:@"%PROJECT" withString:self.projectName];
- string = [string stringByReplacingOccurrencesOfString:@"%COMPANY" withString:self.projectCompany];
- string = [string stringByReplacingOccurrencesOfString:@"%VERSION" withString:self.projectVersion];
- string = [string stringByReplacingOccurrencesOfString:@"%DOCSETBUNDLEFILENAME" withString:self.docsetBundleFilename];
- string = [string stringByReplacingOccurrencesOfString:@"%DOCSETATOMFILENAME" withString:self.docsetAtomFilename];
- string = [string stringByReplacingOccurrencesOfString:@"%DOCSETPACKAGEFILENAME" withString:self.docsetPackageFilename];
- string = [string stringByReplacingOccurrencesOfString:@"%YEAR" withString:[self yearStringFromDate:[NSDate date]]];
- string = [string stringByReplacingOccurrencesOfString:@"%UPDATEDATE" withString:[self yearToDayStringFromDate:[NSDate date]]];
+ string = [string stringByReplacingOccurrencesOfString:kGBTemplatePlaceholderCompanyID withString:self.companyIdentifier];
+ string = [string stringByReplacingOccurrencesOfString:kGBTemplatePlaceholderProjectID withString:self.projectIdentifier];
+ string = [string stringByReplacingOccurrencesOfString:kGBTemplatePlaceholderVersionID withString:self.versionIdentifier];
+ string = [string stringByReplacingOccurrencesOfString:kGBTemplatePlaceholderProject withString:self.projectName];
+ string = [string stringByReplacingOccurrencesOfString:kGBTemplatePlaceholderCompany withString:self.projectCompany];
+ string = [string stringByReplacingOccurrencesOfString:kGBTemplatePlaceholderVersion withString:self.projectVersion];
+ string = [string stringByReplacingOccurrencesOfString:kGBTemplatePlaceholderDocSetBundleFilename withString:self.docsetBundleFilename];
+ string = [string stringByReplacingOccurrencesOfString:kGBTemplatePlaceholderDocSetAtomFilename withString:self.docsetAtomFilename];
+ string = [string stringByReplacingOccurrencesOfString:kGBTemplatePlaceholderDocSetPackageFilename withString:self.docsetPackageFilename];
+ string = [string stringByReplacingOccurrencesOfString:kGBTemplatePlaceholderYear withString:[self yearStringFromDate:[NSDate date]]];
+ string = [string stringByReplacingOccurrencesOfString:kGBTemplatePlaceholderUpdateDate withString:[self yearToDayStringFromDate:[NSDate date]]];
return string;
}
@@ -186,8 +186,8 @@ - (NSDictionary *)arrayDescriptorForArray:(NSArray *)array {
- (void)addFooterVarsToDictionary:(NSMutableDictionary *)dict {
[dict setObject:self.settings.projectCompany forKey:@"copyrightHolder"];
- [dict setObject:[self.settings stringByReplacingOccurencesOfPlaceholdersInString:@"%YEAR"] forKey:@"copyrightDate"];
- [dict setObject:[self.settings stringByReplacingOccurencesOfPlaceholdersInString:@"%UPDATEDATE"] forKey:@"lastUpdatedDate"];
+ [dict setObject:[self.settings stringByReplacingOccurencesOfPlaceholdersInString:kGBTemplatePlaceholderYear] forKey:@"copyrightDate"];
+ [dict setObject:[self.settings stringByReplacingOccurencesOfPlaceholdersInString:kGBTemplatePlaceholderUpdateDate] forKey:@"lastUpdatedDate"];
}
#pragma mark Properties

0 comments on commit 1f23b3e

Please sign in to comment.