From aacddc9211cbf82868b98616903e99adcd9a6197 Mon Sep 17 00:00:00 2001 From: Moshe Berman <mosheberman@users.noreply.github.com> Date: Thu, 29 Mar 2018 19:11:25 -0400 Subject: [PATCH 1/3] Generate hebrew kabbalistic strings. --- .../Core/Calendar/Sefira/KCSefiraFormatter.m | 76 ++++++------------- 1 file changed, 25 insertions(+), 51 deletions(-) diff --git a/KosherCocoa/Library/Core/Calendar/Sefira/KCSefiraFormatter.m b/KosherCocoa/Library/Core/Calendar/Sefira/KCSefiraFormatter.m index ebf8978..83c9217 100644 --- a/KosherCocoa/Library/Core/Calendar/Sefira/KCSefiraFormatter.m +++ b/KosherCocoa/Library/Core/Calendar/Sefira/KCSefiraFormatter.m @@ -30,6 +30,7 @@ @interface KCSefiraFormatter () @property (nonatomic, strong) NSArray <NSString *> *englishKabbalisticStrings; @property (nonatomic, strong) NSArray <NSString *> *hebrewKabbalisticStrings; @property (nonatomic, strong) NSArray <NSString *> *transliteratedHebrewKabbalisticStrings; +@property (nonatomic, strong) NSArray <NSString *> *sefirahNamesByWeek; @end @@ -259,57 +260,30 @@ - (nonnull id)init _sefardTransliteratedStrings = @[]; _sephardicTransliteratedStrings = @[]; - _hebrewKabbalisticStrings = @[ - @"חֶסֶד שֶבְּחֶסֶד", - @"גְבוּרָה שֶבְּחֶסֶד", - @"תִּפֶארֶת שֶבְּחֶסֶד", - @"נֶצַח שֶבְּחֶסֶד", - @"הוֹד שֶבְּחֶסֶד", - @"יְסֹוד שֶבְּחֶסֶד", - @"מַלְכוּת שֶבְּחֶסֶד", - @"חֶסֶד שֶבְּגְבוּרָה", - @"גְבוּרָה שֶבְּגְבוּרָה", - @"תִּפֶארֶת שֶבְּגְבוּרָה", - @"נֶצַח שֶבְּגְבוּרָה", - @"הוֹד שֶבְּגְבוּרָה", - @"יְסֹוד שֶבְּגְבוּרָה", - @"מַלְכוּת שֶבְּגְבוּרָה", - @"חֶסֶד שֶבְּתִּפֶארֶת", - @"גְבוּרָה שֶבְּתִּפֶארֶת", - @"תִּפֶארֶת שֶבְּתִּפֶארֶת", - @"נֶצַח שֶבְּתִּפֶארֶת", - @"הוֹד שֶבְּתִּפֶארֶת", - @"יְסֹוד שֶבְּתִּפֶארֶת", - @"מַלְכוּת שֶבְּתִּפֶארֶת", - @"חֶסֶד שֶבְּנֶצַח", - @"גְבוּרָה שֶבְּנֶצַח", - @"תִּפֶארֶת שֶבְּנֶצַח", - @"נֶצַח שֶבְּנֶצַח", - @"הוֹד שֶבְּנֶצַח", - @"יְסֹוד שֶבְּנֶצַח", - @"מַלְכוּת שֶבְּנֶצַח" - , @"חֶסֶד שֶבְּהוֹד", - @"גְבוּרָה שֶבְּהוֹד", - @"תִּפֶארֶת שֶבְּהוֹד", - @"נֶצַח שֶבְּהוֹד", - @"הוֹד שֶבְּהוֹד", - @"יְסֹוד שֶבְּהוֹד", - @"מַלְכוּת שֶבְּהוֹד", - @"חֶסֶד שֶבְּיְסֹוד", - @"גְבוּרָה שֶבְּיְסֹוד", - @"תִּפֶארֶת שֶבְּיְסֹוד", - @"נֶצַח שֶבְּיְסֹוד", - @"הוֹד שֶבְּיְסֹוד", - @"יְסֹוד שֶבְּיְסֹוד", - @"מַלְכוּת שֶבְּיְסֹוד", - @"חֶסֶד שֶבְּמַלְכוּת", - @"גְבוּרָה שֶבְּמַלְכוּת", - @"תִּפֶארֶת שֶבְּמַלְכוּת", - @"נֶצַח שֶבְּמַלְכוּת", - @"הוֹד שֶבְּמַלְכוּת", - @"יְסֹוד שֶבְּמַלְכוּת", - @"מַלְכוּת שֶבְּמַלְכוּת" - ]; + _sefirahNamesByWeek = @[ + @"חֶסֶד", + @"גְבוּרָה", + @"תִּפֶארֶת", + @"נֶצַח", + @"הוֹד", + @"יְסֹוד", + @"מַלְכוּת" + ]; + NSMutableArray <NSString *>* hebrewKabbalisticStrings = [@[] mutableCopy]; + + for (NSInteger i = 0; i<_sefirahNamesByWeek.count; i++) { + for (NSInteger j = 0; j<_sefirahNamesByWeek.count; j++) { + NSString *part1 = _sefirahNamesByWeek[j]; + NSString *part2 = @"שֶבְּ"; + NSString *part3 = _sefirahNamesByWeek[i]; + + NSString *trait = [NSString stringWithFormat:@"%@ %@%@", part1, part2, part3]; + [hebrewKabbalisticStrings addObject:trait]; + } + } + + _hebrewKabbalisticStrings = hebrewKabbalisticStrings; + _englishKabbalisticStrings = @[]; _transliteratedHebrewKabbalisticStrings = @[]; } From 8bb458586b12d237a7eb4561b396740669f1fcac Mon Sep 17 00:00:00 2001 From: Moshe Berman <mosheberman@users.noreply.github.com> Date: Sun, 1 Apr 2018 22:49:28 -0400 Subject: [PATCH 2/3] Added sefiraTraitForDay: and sefiraTraitFoWeek: Deprecates sefiraTraitForInteger:. --- .../Core/Calendar/Sefira/KCSefiraFormatter.h | 35 +++++++++--- .../Core/Calendar/Sefira/KCSefiraFormatter.m | 53 +++++++++++++++---- 2 files changed, 71 insertions(+), 17 deletions(-) diff --git a/KosherCocoa/Library/Core/Calendar/Sefira/KCSefiraFormatter.h b/KosherCocoa/Library/Core/Calendar/Sefira/KCSefiraFormatter.h index 1332f39..8e1dc79 100644 --- a/KosherCocoa/Library/Core/Calendar/Sefira/KCSefiraFormatter.h +++ b/KosherCocoa/Library/Core/Calendar/Sefira/KCSefiraFormatter.h @@ -117,17 +117,40 @@ NS_SWIFT_NAME(SefiraFormatter) - (nullable NSString *)countStringFromInteger:(NSInteger)integer withPrayers:(KCSefiraPrayerAddition)prayers; +#pragma mark - Getting the Kabbalistic Trait of the Week + +/** + Converts an integer (between 1 and 7, inclusive) + into a kabbalistic trait traditionally assigned + to a given week of the omer. + + @param week The week to get the trait for. + @return A string containing the attribure of that week. + */ +- (nullable NSString *)kabbalisticTraitForWeek:(NSInteger)week; + + #pragma mark - Getting the Kabbalistic Trait of the Day /** - * Converts an integer (between 1 and 49, inclusive) - * into a kabbalistic trait traditionally assigned - * to a given day of the omer. - * - * @return A string containing the attribure of that day. + Converts an integer (between 1 and 49, inclusive) + into a kabbalistic trait traditionally assigned + to a given day of the omer. + + @param day The day to get the trait for. + @return A string containing the attribure of that day. */ +- (nullable NSString *)kabbalisticTraitForDay:(NSInteger)day; -- (nullable NSString *)kabbalisticTraitFromInteger:(NSInteger)integer; +/** + Converts an integer (between 1 and 49, inclusive) + into a kabbalistic trait traditionally assigned + to a given day of the omer. + + @param integer The day to get the trait for. + @return A string containing the attribure of that day. + */ +- (nullable NSString *)kabbalisticTraitFromInteger:(NSInteger)integer DEPRECATED_MSG_ATTRIBUTE("Use kabbalisticTraitForDay: and kabbalisticTraitForWeek: instead."); /** * Get the blessing text for counting the omer. diff --git a/KosherCocoa/Library/Core/Calendar/Sefira/KCSefiraFormatter.m b/KosherCocoa/Library/Core/Calendar/Sefira/KCSefiraFormatter.m index 83c9217..b7aff59 100644 --- a/KosherCocoa/Library/Core/Calendar/Sefira/KCSefiraFormatter.m +++ b/KosherCocoa/Library/Core/Calendar/Sefira/KCSefiraFormatter.m @@ -434,7 +434,7 @@ - (nullable NSString *)countStringFromInteger:(NSInteger)integer withPrayers:(en if (showRibono) { - NSString *trait = [self kabbalisticTraitFromInteger:integer]; + NSString *trait = [self kabbalisticTraitForDay:integer]; ribono = [NSString stringWithFormat:@"רִבּוֹנוֹ שֶׁל עוֹלָם, אַתָּה צִוִּיתָֽנוּ עַל יְדֵי מֹשֶׁה עַבְדֶּֽךָ לִסְפּוֹר סְפִירַת הָעֹֽמֶר, כְּדֵי לְטַהֲרֵֽנוּ מִקְּלִפּוֹתֵֽינוּ וּמִטֻּמְאוֹתֵֽינוּ, כְּמוֹ שֶׁכָּתַֽבְתָּ בְּתוֹרָתֶֽךָ: וּסְפַרְתֶּם לָכֶם מִמָּחֳרַת הַשַּׁבָּת מִיּוֹם הֲבִיאֲכֶם אֶת עֹֽמֶר הַתְּנוּפָה, שֶֽׁבַע שַׁבָּתוֹת תְּמִימֹת תִּהְיֶֽינָה, עַד מִמָּחֳרַת הַשַּׁבָּת הַשְּׁבִיעִת תִּסְפְּרוּ חֲמִשִּׁים יוֹם, כְּדֵי שֶׁיִּטָּהֲרוּ נַפְשׁוֹת עַמְּךָ יִשְׂרָאֵל מִזֻּהֲמָתָם. וּבְכֵן יְהִי רָצוֹן מִלְּפָנֶֽיךָ יְיָ אֱלֹהֵֽינוּ וֵאלֹהֵי אֲבוֹתֵֽינוּ, שֶׁבִּזְכוּת סְפִירַת הָעֹֽמֶר שֶׁסָּפַֽרְתִּי הַיּוֹם, יְתֻקַּן מַה שֶּׁפָּגַֽמְתִּי בִּסְפִירָה %@ וְאֶטָּהֵר וְאֶתְקַדֵּשׁ בִּקְדֻשָּׁה שֶׁל מַֽעְלָה, וְעַל יְדֵי זֶה יֻשְׁפַּע שֶֽׁפַע רַב בְּכָל הָעוֹלָמוֹת, וּלְתַקֵּן אֶת נַפְשׁוֹתֵֽינוּ וְרוּחוֹתֵֽינוּ וְנִשְׁמוֹתֵֽינוּ מִכָּל סִיג וּפְגַם, וּלְטַהֲרֵֽנוּ וּלְקַדְּשֵֽׁנוּ בִּקְדֻשָּׁתְךָ הָעֶלְיוֹנָה, אָמֵן סֶֽלָה.", trait]; @@ -455,30 +455,61 @@ - (nullable NSString *)countStringFromInteger:(NSInteger)integer withPrayers:(en return output; } -#pragma mark - Getting the Kabbalistic Trait of the Day +#pragma mark - Getting the Kabbalistic Trait of the Week /** - * Converts an integer (between 1 and 49, inclusive) - * into a kabbalistic trait traditionally assigned - * to a given day of the omer. - * - * @return A string containing the attribure of that day. + Converts an integer (between 1 and 7, inclusive) + into a kabbalistic trait traditionally assigned + to a given week of the omer. + + @param week The week to get the trait for. + @return A string containing the attribure of that week. */ +- (nullable NSString *)kabbalisticTraitForWeek:(NSInteger)week; +{ + if (week > 7 || week < 1) { + return nil; + } + return self.sefirahNamesByWeek[week - 1]; +} -- (nullable NSString *)kabbalisticTraitFromInteger:(NSInteger)integer +#pragma mark - Getting the Kabbalistic Trait of the Day + +/** + Converts an integer (between 1 and 49, inclusive) + into a kabbalistic trait traditionally assigned + to a given day of the omer. + + @param day The day to get the trait for. + @return A string containing the attribure of that day. + */ +- (nullable NSString *)kabbalisticTraitForDay:(NSInteger)day; { NSString *trait = nil; - integer = integer - 1; + day = day - 1; - if (integer < self.hebrewKabbalisticStrings.count) + if (day < self.hebrewKabbalisticStrings.count) { - trait = self.hebrewKabbalisticStrings[integer]; + trait = self.hebrewKabbalisticStrings[day]; } return trait; } +/** + * Converts an integer (between 1 and 49, inclusive) + * into a kabbalistic trait traditionally assigned + * to a given day of the omer. + * + * @return A string containing the attribure of that day. + */ + +- (nullable NSString *)kabbalisticTraitFromInteger:(NSInteger)integer +{ + return [self kabbalisticTraitForDay:integer]; +} + #pragma mark - Helpers /** From 801d7056bc82fd59c04eff43e4cf90a71a8bfaad Mon Sep 17 00:00:00 2001 From: Moshe Berman <mosheberman@users.noreply.github.com> Date: Sun, 1 Apr 2018 23:07:37 -0400 Subject: [PATCH 3/3] Upgrade to Swift 4. --- KosherCocoa.xcodeproj/project.pbxproj | 7 +++++-- KosherCocoaTests/KosherCocoaTests.swift | 20 ++++++++++---------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/KosherCocoa.xcodeproj/project.pbxproj b/KosherCocoa.xcodeproj/project.pbxproj index ff3810a..0030216 100644 --- a/KosherCocoa.xcodeproj/project.pbxproj +++ b/KosherCocoa.xcodeproj/project.pbxproj @@ -1020,6 +1020,7 @@ 46DB49631D9839F100F3A576 = { CreatedOnToolsVersion = 8.0; DevelopmentTeam = HK64RUWW3P; + LastSwiftMigration = 0920; ProvisioningStyle = Automatic; }; }; @@ -1708,7 +1709,8 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = On; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -1734,7 +1736,8 @@ MTL_ENABLE_DEBUG_INFO = NO; PRODUCT_BUNDLE_IDENTIFIER = com.mosheberman.KosherCocoaTests; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = On; + SWIFT_VERSION = 4.0; }; name = Release; }; diff --git a/KosherCocoaTests/KosherCocoaTests.swift b/KosherCocoaTests/KosherCocoaTests.swift index d43a00e..91934b7 100644 --- a/KosherCocoaTests/KosherCocoaTests.swift +++ b/KosherCocoaTests/KosherCocoaTests.swift @@ -26,7 +26,7 @@ class KosherCocoaTests: XCTestCase { /** Iterate and check all fields for zero length strings */ func testForMetadataWithMissingEntries() { - let metadata = KCZman.metadata() + let metadata = Zman.metadata() for (selectorString, calculationMetadata) in metadata { @@ -42,7 +42,7 @@ class KosherCocoaTests: XCTestCase { /** Iterate and check for strings containing the word "method" or a pair of parenthesis'()' */ func testForMethodNames() { - let metadata = KCZman.metadata() + let metadata = Zman.metadata() let flaggableContent = ["()", "method", "Method"] @@ -66,7 +66,7 @@ class KosherCocoaTests: XCTestCase { func testForPlaceholders() { - let metadata = KCZman.metadata() + let metadata = Zman.metadata() let flaggableContent = ["<# #>", "<#explanation#>"] @@ -93,7 +93,7 @@ class KosherCocoaTests: XCTestCase { /** Iterate groups and check for strings that appear more than once */ func testForDuplicateMethodNamesInGroupings() { - let originalMappings = KCZman.relatedZmanimMapping() + let originalMappings = Zman.relatedZmanimMapping() var count : [String: Int] = [:] @@ -123,7 +123,7 @@ class KosherCocoaTests: XCTestCase { /** Iterate metadata keys and check for selector names that appear more than once. */ func testForDuplicateDescriptionNamesInMetadata() { - let metadata = KCZman.metadata() + let metadata = Zman.metadata() var count : [String: Int] = [:] @@ -158,7 +158,7 @@ class KosherCocoaTests: XCTestCase { /** Detect double spaces in descriptions */ func testDuplicateSpaceCharactersInDescriptions() { - let metadata = KCZman.metadata() + let metadata = Zman.metadata() let characters = "abcdefghijklmnopqrstuvwxyz.,)+*1234567890" @@ -188,8 +188,8 @@ class KosherCocoaTests: XCTestCase { /** Iterate groups of methods and check for missing metadata entries. */ func testForMissingMetadataEntry() { - let flattenedMethodGroups = KCZman.relatedZmanimMapping().flatMap { $0 } - let metadataKeys = KCZman.metadata().keys + let flattenedMethodGroups = Zman.relatedZmanimMapping().flatMap { $0 } + let metadataKeys = Zman.metadata().keys for selectorName in flattenedMethodGroups { @@ -201,8 +201,8 @@ class KosherCocoaTests: XCTestCase { /** Iterate metadata and check for groups that aren't represented in the selectors grouping. */ func testForExtraMetadata() { - let flattenedMethodGroups = KCZman.relatedZmanimMapping().flatMap { $0 } - let metadataKeys = KCZman.metadata().keys + let flattenedMethodGroups = Zman.relatedZmanimMapping().flatMap { $0 } + let metadataKeys = Zman.metadata().keys for metadataGroup in metadataKeys {