Skip to content

Commit

Permalink
Converted to Swift 3.0 (#20)
Browse files Browse the repository at this point in the history
* Converted to Swift 3.0
* Added Swift version file
  • Loading branch information
jimvanzummeren committed Sep 29, 2016
1 parent 3d41f34 commit fbef836
Show file tree
Hide file tree
Showing 124 changed files with 565 additions and 513 deletions.
1 change: 1 addition & 0 deletions .swift-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.0
6 changes: 3 additions & 3 deletions Example/Tests/ListRuleIntegrationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ class ListRuleIntegrationTests: XCTestCase {
let fakeLines3 = ["- Aliquam eleifend", "- pharetra"," 1. diam", " 2. Morbi"," a. metus", " b. sollicitudin", " c. dictum", " - malesuada", "- tempor"]

// Act
sut.recognizesLines(fakeLines)
_ = sut.recognizesLines(fakeLines)
let actualLinesConsumed = sut.linesConsumed()
sut.recognizesLines(fakeLines2)
_ = sut.recognizesLines(fakeLines2)
let actualLinesConsumed2 = sut.linesConsumed()
sut.recognizesLines(fakeLines3)
_ = sut.recognizesLines(fakeLines3)
let actualLinesConsumedLong = sut.linesConsumed()

// Assert
Expand Down
4 changes: 2 additions & 2 deletions Example/Tests/MarkDownLinesTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ class MarkDownLinesTests: XCTestCase {

private class MockRule : Rule {

func recognizesLines(lines:[String]) -> Bool {
func recognizesLines(_ lines:[String]) -> Bool {
return true
}

func createMarkDownItemWithLines(lines:[String]) -> MarkDownItem {
func createMarkDownItemWithLines(_ lines:[String]) -> MarkDownItem {
return MockMarkDownItem(lines:lines, content: lines.first ?? "")
}

Expand Down
2 changes: 1 addition & 1 deletion Example/Tests/MarkyMarkContentfulIntegrationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class MarkyMarkContentfulIntegrationTests: XCTestCase {
let markDownString = "# Headers\n---\n# Header 1\n## Header 2\n### Header 3\n#### Header 4\n##### Header 5\n###### Header 6\n\n# Lists\n---\n## Ordered list\n1. Number 1\n2. Number 2\n3. Number 3\n5. Number 4\n 1. Nested 1\n 2. Nested 2\n6. Number 5\n---\n## Unordered list\n- Item 1\n- Item 2\n- Item 3\n - Nested item 1\n - ~~Nested item 2~~\n - Subnested it'em 1\n - Subnested it'em 2\n - Subsubnest'ed item 1\n - Subsubnest'ed item 2 [Velit](https://m2mobi.com)\n - Subsubnes'ted item 3 *(with single **space**)*\n---\n## Combo\n1. Ordered 1\n2. Ordered 2\n - Unordered 1\n - Unordered 2\n - Nested unorder'ed 1\n - Nested unorder'ed 2\n 1. Subnested o'rdered 1\n 2. Subnested o'rdered 2\n\n# Images\n---\n![My Apple](http://images.apple.com/apple-events/static/apple-events/october-2013/video/poster_large.jpg)\n\n# Paragraphs\nLorem ipsum *dolor* sit amet, __consectetur__ adipiscing elit. Proin ***aliquet vulputate*** diam. Duis sodales ~~sapien~~ quis ***elementum* posuere**. Duis quam lectus, posueresed [~~pellentesqueaauctor~~](https://m2mobi.com) eu [Velit](https://m2mobi.com).\n---\n## Quotes\n> MarkDown is awesome\n> Seriously..\n\n## Links\n[This is a test link](https://m2mobi.com)\nInline links are also possible, click [here](https://m2mobi.com)\n# Code\n---\n\n```\n@Override\nOn *multiple* lines\n```\n\n``` @Override ```\n\nOr maybe in line `@Override`"

// This is an example of a performance test case.
self.measureBlock {
self.measure {
let _ = self.sut.parseMarkDown(markDownString)
}
}
Expand Down
27 changes: 13 additions & 14 deletions Example/Tests/MarkyMarkTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class MarkyMarkTests: XCTestCase {

sut = MarkyMark(build: {
$0.setDefaultRule(MockNeverRecognizeRule())
$0.setDefaultInlineRule(MockNeverRecognizeInlineRule())
$0.setDefaultInlineRule(InlineTextRule())
})
}

Expand All @@ -32,7 +32,7 @@ class MarkyMarkTests: XCTestCase {
sut.setDefaultRule(expectedDefaultRule)

//Assert
XCTAssert((sut.getRuleForLines([]) as! AnyObject) === expectedDefaultRule)
XCTAssert((sut.getRuleForLines([]) as AnyObject) === expectedDefaultRule)
}

func testAddRuleEndsUpInAllRules() {
Expand Down Expand Up @@ -68,7 +68,7 @@ class MarkyMarkTests: XCTestCase {
//Act

//Assert
XCTAssert((sut.getRuleForLines(["Test"]) as! AnyObject) === rule)
XCTAssert((sut.getRuleForLines(["Test"]) as AnyObject) === rule)
}

func testParseMarkDownReturnsCorrectMarkDownItems() {
Expand Down Expand Up @@ -117,52 +117,51 @@ class MarkyMarkTests: XCTestCase {

private class MockTestRule : Rule {

func recognizesLines(lines:[String]) -> Bool {
func recognizesLines(_ lines:[String]) -> Bool {
guard let line = lines.first else { return false }
return line == "Test"
}

func createMarkDownItemWithLines(lines:[String]) -> MarkDownItem {
func createMarkDownItemWithLines(_ lines:[String]) -> MarkDownItem {
return MockMarkDownItem(lines:lines, content: lines.first ?? "")
}
}

private class MockAlwaysRecognizeRule : Rule {

func recognizesLines(lines:[String]) -> Bool {
func recognizesLines(_ lines:[String]) -> Bool {
return true
}

func createMarkDownItemWithLines(lines:[String]) -> MarkDownItem {
func createMarkDownItemWithLines(_ lines:[String]) -> MarkDownItem {
return MockMarkDownItem(lines:lines, content: lines.first ?? "")
}
}

private class MockNeverRecognizeRule : Rule {

func recognizesLines(lines:[String]) -> Bool {
func recognizesLines(_ lines:[String]) -> Bool {
return false
}

func createMarkDownItemWithLines(lines:[String]) -> MarkDownItem {
func createMarkDownItemWithLines(_ lines:[String]) -> MarkDownItem {
return MockWrongMarkDownItem(lines:lines, content: lines.first ?? "")
}
}

private class MockNeverRecognizeInlineRule : InlineRule {

func recognizesLines(lines:[String]) -> Bool {
func recognizesLines(_ lines:[String]) -> Bool {
return false
}

func createMarkDownItemWithLines(lines:[String]) -> MarkDownItem {
func createMarkDownItemWithLines(_ lines:[String]) -> MarkDownItem {
return MockWrongMarkDownItem(lines:lines, content: lines.first ?? "")
}

func getAllMatches(lines:[String]) -> [NSRange] {
func getAllMatches(_ lines:[String]) -> [NSRange] {
return []
}

}

private class MockMarkDownItem : MarkDownItem {
Expand All @@ -184,4 +183,4 @@ private class MockFlavor : Flavor {
self.inlineRules = [MockNeverRecognizeInlineRule(), MockNeverRecognizeInlineRule()]
}

}
}
15 changes: 15 additions & 0 deletions Example/Tests/NSRange+Equatable.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// NSRange+Equatable.swift
// markymark
//
// Created by Jim van Zummeren on 29/09/16.
// Copyright © 2016 CocoaPods. All rights reserved.
//

import Foundation

extension NSRange: Equatable {}

public func == (lhs: NSRange, rhs: NSRange) -> Bool {
return lhs.length == rhs.length && lhs.location == rhs.location
}
3 changes: 2 additions & 1 deletion Example/Tests/Rules/Block/BoldRuleTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,5 @@ class BoldRuleTests: XCTestCase {
XCTAssertEqual(sut.getAllMatches(["*Text*"]).count, 0)
XCTAssertEqual(sut.getAllMatches(["**Text** test **Text**"]), [expectedMatchesRange,expectedMatchesRange2])
}
}
}

2 changes: 1 addition & 1 deletion Example/Tests/Rules/Block/ImageRuleTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ class ImageRuleTests: XCTestCase {
XCTAssertEqual(sut.getAllMatches(["![Alt text](image.png) test ![Alt text](image.png)"]), [expectedMatchesRange,expectedMatchesRange2])
}

}
}
2 changes: 1 addition & 1 deletion Example/Tests/Rules/Block/InlineTextRuleTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class InlineTextRuleTests: XCTestCase {

func testGetAllMatches() {
//Arrange
let expectedMatchesRange = []
let expectedMatchesRange = [NSRange]()
//Act

//Assert
Expand Down
2 changes: 1 addition & 1 deletion Example/Tests/Rules/Block/ItalicRuleTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ class ItalicRuleTests: XCTestCase {
XCTAssertEqual(sut.getAllMatches(["**Text**"]).count, 0)
XCTAssertEqual(sut.getAllMatches(["*Text* test *Text*"]), [expectedMatchesRange,expectedMatchesRange2])
}
}
}
8 changes: 4 additions & 4 deletions Example/Tests/Rules/Block/ListRuleTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ class ListRuleTests: XCTestCase {
let fakeLines2 = ["- List item", "^-^ Another list item", "- Yes another list item"]

//Act
sut.recognizesLines(fakeLines)
_ = sut.recognizesLines(fakeLines)
let actualLinesConsumed = sut.linesConsumed()
sut.recognizesLines(fakeLines2)
_ = sut.recognizesLines(fakeLines2)
let actualLinesConsumed2 = sut.linesConsumed()

//Assert
Expand Down Expand Up @@ -85,11 +85,11 @@ class FakeListType : ListType {

var relatedListMarkDownType:ListMarkDownItem.Type { return FakeListMarkDownItem.self }

func getIndex(stringIndex:String) -> Int? {
func getIndex(_ stringIndex:String) -> Int? {
return stringIndex == "^-^" ? 1 : nil
}
}

class FakeListMarkDownItem : ListMarkDownItem {

}
}
33 changes: 30 additions & 3 deletions Example/markymark.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
0706B40A1D9D2FF80064A640 /* NSRange+Equatable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0706B4081D9D2FE10064A640 /* NSRange+Equatable.swift */; };
07EC79F51CF3A19D004239CB /* ListRuleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 07EC79F41CF3A19D004239CB /* ListRuleTests.swift */; };
1E5D871F2AD8705B0A87B17C /* Pods_markymark_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6E8357CFD26059D0E00EA777 /* Pods_markymark_Example.framework */; };
607FACD61AFB9204008FA782 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACD51AFB9204008FA782 /* AppDelegate.swift */; };
Expand Down Expand Up @@ -54,6 +55,7 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
0706B4081D9D2FE10064A640 /* NSRange+Equatable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSRange+Equatable.swift"; sourceTree = "<group>"; };
07EC79F41CF3A19D004239CB /* ListRuleTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListRuleTests.swift; sourceTree = "<group>"; };
09F6D551E99F224FBB0ACEA1 /* Pods-markymark_Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-markymark_Example.debug.xcconfig"; path = "Pods/Target Support Files/Pods-markymark_Example/Pods-markymark_Example.debug.xcconfig"; sourceTree = "<group>"; };
518BCFAF9A99531082BDFBDE /* markymark.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = markymark.podspec; path = ../markymark.podspec; sourceTree = "<group>"; };
Expand Down Expand Up @@ -177,6 +179,7 @@
629C42341CEB47F900DA57D8 /* MarkDownLinesTests.swift */,
629C42351CEB47F900DA57D8 /* MarkyMarkTests.swift */,
607FACE91AFB9204008FA782 /* Supporting Files */,
0706B4081D9D2FE10064A640 /* NSRange+Equatable.swift */,
);
path = Tests;
sourceTree = "<group>";
Expand Down Expand Up @@ -344,15 +347,19 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0720;
LastUpgradeCheck = 0720;
LastUpgradeCheck = 0800;
ORGANIZATIONNAME = CocoaPods;
TargetAttributes = {
607FACCF1AFB9204008FA782 = {
CreatedOnToolsVersion = 6.3.1;
DevelopmentTeam = 3B6J93GERH;
LastSwiftMigration = 0800;
ProvisioningStyle = Automatic;
};
607FACE41AFB9204008FA782 = {
CreatedOnToolsVersion = 6.3.1;
DevelopmentTeam = 3B6J93GERH;
LastSwiftMigration = 0800;
TestTargetID = 607FACCF1AFB9204008FA782;
};
};
Expand Down Expand Up @@ -529,6 +536,7 @@
9A8BE0BB1CEE0459004593A0 /* ImageBlockRuleTests.swift in Sources */,
9A8BE0B01CEE0416004593A0 /* StrikeRuleTests.swift in Sources */,
9AD91A7A1CF7393A00BA3FD4 /* UnOrderedListTypeTests.swift in Sources */,
0706B40A1D9D2FF80064A640 /* NSRange+Equatable.swift in Sources */,
629C42461CEB4B3000DA57D8 /* MarkDownConverterTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -576,10 +584,13 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
Expand Down Expand Up @@ -621,10 +632,13 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
Expand All @@ -642,6 +656,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 8.3;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
VALIDATE_PRODUCT = YES;
};
name = Release;
Expand All @@ -650,38 +665,46 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 09F6D551E99F224FBB0ACEA1 /* Pods-markymark_Example.debug.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_IDENTITY = "";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
DEVELOPMENT_TEAM = 3B6J93GERH;
INFOPLIST_FILE = markymark/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MODULE_NAME = ExampleApp;
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
SWIFT_VERSION = 3.0;
};
name = Debug;
};
607FACF11AFB9204008FA782 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 9704F30C7296E4A0EA9A0087 /* Pods-markymark_Example.release.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_IDENTITY = "";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
DEVELOPMENT_TEAM = 3B6J93GERH;
INFOPLIST_FILE = markymark/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MODULE_NAME = ExampleApp;
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
SWIFT_VERSION = 3.0;
};
name = Release;
};
607FACF31AFB9204008FA782 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 9ACED21B5B719CEBD45DC4FF /* Pods-markymark_Tests.debug.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
DEVELOPMENT_TEAM = 3B6J93GERH;
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
Expand All @@ -694,13 +717,16 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
name = Debug;
};
607FACF41AFB9204008FA782 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = F999758130B6D43C3A4FA9BF /* Pods-markymark_Tests.release.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
DEVELOPMENT_TEAM = 3B6J93GERH;
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
Expand All @@ -709,6 +735,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
name = Release;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0720"
LastUpgradeVersion = "0800"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Loading

0 comments on commit fbef836

Please sign in to comment.