Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed HTML footer year and last update strings. Closes #49.

This was broken when switching from $ to % in commit 45159f0. Forgot to check it then.
  • Loading branch information...
commit f18465ee4c7e53b9dfbc96f2f0eb2d3d266d62ff 1 parent 1ab0711
@tomaz authored
View
16 Application/GBApplicationSettingsProvider.h
@@ -379,11 +379,17 @@
This method provides application-wide string placeholders replacement functionality. It replaces all known placeholders with actual values from the receiver. Placeholders are identified by a dollar mark, followed by placeholder name. The following placeholders are supported (note that case is important!):
- - `$PROJECT`: Replaced by `projectName` value.
- - `$COMPANY`: Replaced by `projectCompany` value.
- - `$VERSION`: Replaced by `projectVersion` value.
- - `$YEAR`: Replaced by current year as four digit string.
- - `$UPDATEDATE`: Replaced by current date in the form of year, month and day with format `YYYY-MM-DD`. For example `2010-11-30`.
+ - `%PROJECT`: Replaced by `projectName` value.
+ - `%PROJECTID`: Replaced by `projectIdentifier` value.
+ - `%COMPANY`: Replaced by `projectCompany` value.
+ - `%COMPANYID`: Replaced by `companyIdentifier` value.
+ - `%VERSION`: Replaced by `projectVersion` value.
+ - `%VERSIONID`: Replaced by `versionIdentifier` value.
+ - `%DOCSETBUNDLEFILENAME`: Replaced by `docsetBundleFilename` value.
+ - `%DOCSETATOMFILENAME`: Replaced by `docsetAtomFilename` value.
+ - `%DOCSETPACKAGEFILENAME`: Replaced by `docsetPackageFilename` value.
+ - `%YEAR`: Replaced by current year as four digit string.
+ - `%UPDATEDATE`: Replaced by current date in the form of year, month and day with format `YYYY-MM-DD`. For example `2010-11-30`.
@param string The string to replace placeholder occurences in.
@return Returns new string with all placeholder occurences replaced.
View
4 Generating/GBHTMLTemplateVariablesProvider.m
@@ -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:@"%YEAR"] forKey:@"copyrightDate"];
+ [dict setObject:[self.settings stringByReplacingOccurencesOfPlaceholdersInString:@"%UPDATEDATE"] forKey:@"lastUpdatedDate"];
}
#pragma mark Properties
View
30 Testing/GBTemplateVariablesProvider-CommonTesting.m
@@ -11,13 +11,16 @@
#import "GBTokenizer.h"
@interface GBTemplateVariablesProviderCommonTesting : GHTestCase
+- (NSDateFormatter *)yearFormatterFromSettings:(GBApplicationSettingsProvider *)settings;
+- (NSDateFormatter *)yearToDayFormatterFromSettings:(GBApplicationSettingsProvider *)settings;
@end
@implementation GBTemplateVariablesProviderCommonTesting
- (void)testVariablesForClass_shouldPrepareDefaultVariables {
// setup
- GBHTMLTemplateVariablesProvider *provider = [GBHTMLTemplateVariablesProvider providerWithSettingsProvider:[GBTestObjectsRegistry realSettingsProvider]];
+ id settings = [GBTestObjectsRegistry realSettingsProvider];
+ GBHTMLTemplateVariablesProvider *provider = [GBHTMLTemplateVariablesProvider providerWithSettingsProvider:settings];
GBClassData *class = [GBClassData classDataWithName:@"Class"];
// execute
NSDictionary *vars = [provider variablesForClass:class withStore:[GBTestObjectsRegistry store]];
@@ -28,4 +31,29 @@ - (void)testVariablesForClass_shouldPrepareDefaultVariables {
assertThat([vars objectForKey:@"object"], is(class));
}
+- (void)testVariableForClass_shouldPrepareFooterVariables {
+ // setup
+ id settings = [GBTestObjectsRegistry realSettingsProvider];
+ GBHTMLTemplateVariablesProvider *provider = [GBHTMLTemplateVariablesProvider providerWithSettingsProvider:settings];
+ GBClassData *class = [GBClassData classDataWithName:@"Class"];
+ // execute
+ NSDictionary *vars = [provider variablesForClass:class withStore:[GBTestObjectsRegistry store]];
+ // verify - just basic tests...
+ NSDate *date = [NSDate date];
+ NSString *year = [[self yearFormatterFromSettings:settings] stringFromDate:date];
+ NSString *day = [[self yearToDayFormatterFromSettings:settings] stringFromDate:date];
+ assertThat([vars valueForKeyPath:@"page.copyrightDate"], is(year));
+ assertThat([vars valueForKeyPath:@"page.lastUpdatedDate"], is(day));
+}
+
+#pragma mark Creation methods
+
+- (NSDateFormatter *)yearFormatterFromSettings:(GBApplicationSettingsProvider *)settings {
+ return [settings valueForKey:@"yearDateFormatter"];
+}
+
+- (NSDateFormatter *)yearToDayFormatterFromSettings:(GBApplicationSettingsProvider *)settings {
+ return [settings valueForKey:@"yearToDayDateFormatter"];
+}
+
@end
Please sign in to comment.
Something went wrong with that request. Please try again.