Skip to content

Commit

Permalink
Merge pull request #87 from net-a-porter-mobile/feature/remove-swift-…
Browse files Browse the repository at this point in the history
…4-warnings

Tiny fixes to remove Swift 4 warnings
  • Loading branch information
deanWombourne authored Nov 8, 2017
2 parents d0883c9 + d99fde1 commit 955d4e4
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 12 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

### Unreleased

### 0.13.2
+ Fix swift 4 warnings about String.characters

## 0.13.1
+ Swift 4

Expand Down
1 change: 0 additions & 1 deletion Example/Tests/StringGherkinExtensionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,4 @@ class StringGherkinExtensionTests: XCTestCase {
let simpleString = ""
XCTAssertEqual("", simpleString.camelCaseify)
}

}
10 changes: 5 additions & 5 deletions Pod/Core/StringGherkinExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public extension String {
*/
var camelCaseify: String {
get {
guard case let characters = (self.characters.split { $0 == " " || $0 == "-" }), characters.count > 1 else {
guard case let characters = (self.split { $0 == " " || $0 == "-" }), characters.count > 1 else {
return self.uppercaseFirstLetterString
}
return characters.map { String($0).lowercased().uppercaseFirstLetterString }.joined(separator: "")
Expand All @@ -33,8 +33,8 @@ public extension String {
*/
var uppercaseFirstLetterString: String {
get {
guard case let characters = self.characters, let firstCharacter = characters.first else { return self }
return String(firstCharacter).uppercased() + String(characters.dropFirst())
guard let firstCharacter = self.first else { return self }
return String(firstCharacter).uppercased() + String(self.dropFirst())
}
}

Expand All @@ -45,8 +45,8 @@ public extension String {
*/
var humanReadableString: String {
get {
guard case let characters = self.characters, characters.count > 1, let firstCharacter = characters.first else { return self }
return String(firstCharacter) + characters.dropFirst().reduce("") { (word, character) in
guard self.count > 1, let firstCharacter = self.first else { return self }
return String(firstCharacter) + self.dropFirst().reduce("") { (word, character) in
let letter = String(character)
if letter == letter.uppercased() {
return word + " " + letter
Expand Down
7 changes: 3 additions & 4 deletions Pod/Core/XCTestCase+Gherkin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,14 @@ class GherkinState {
fileprivate var missingStepsImplementations = [String]()

func gherkinStepsAndMatchesMatchingExpression(_ expression: String) -> [(step: Step, match: NSTextCheckingResult)] {
let range = NSMakeRange(0, expression.characters.count)
let matches = self.steps.map { (step: Step) -> (step: Step, match: NSTextCheckingResult)? in
let range = NSMakeRange(0, expression.count)
return self.steps.flatMap { (step: Step) -> (step: Step, match: NSTextCheckingResult)? in
if let match = step.regex.firstMatch(in: expression, options: [], range: range) {
return (step:step, match:match)
} else {
return nil
}
}.flatMap { $0 }
return matches
}
}

func gherkinStepsMatchingExpression(_ expression: String) -> [Step] {
Expand Down
2 changes: 1 addition & 1 deletion Pod/Native/NativeFeature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ extension NativeFeature {
var lines = contentsFixedWindowsNewLineCharacters.components(separatedBy: "\n").map { $0.trimmingCharacters(in: whitespace) }

// Filter comments (#) and tags (@), also filter white lines
lines = lines.filter { $0.characters.first != "#" && $0.characters.first != "@" && $0.characters.count > 0}
lines = lines.filter { $0.first != "#" && $0.first != "@" && $0.count > 0}

guard lines.count > 0 else { return nil }

Expand Down
2 changes: 1 addition & 1 deletion XCTest-Gherkin.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = "XCTest-Gherkin"
s.version = "0.13.1"
s.version = "0.13.2"
s.summary = "Gherkin style tests"
s.description = <<-DESC
Adds Gherkin syntax to XCTestCase
Expand Down

0 comments on commit 955d4e4

Please sign in to comment.