Skip to content

Commit 265c110

Browse files
Davidde94rolivieri
authored andcommitted
Updated to Swift 4.0 (Kitura#61)
* Updated to Swift 4 * Deleted Package.pins * Finalised conversion to Swift 4 only * Migration to Swift 4.0.2
1 parent d6626c0 commit 265c110

14 files changed

+45
-73
lines changed

.gitignore

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
*.DS_Store
2-
*.pkg
3-
.build
4-
/SwiftRedis.xcodeproj
2+
.build/*
3+
.build-ubuntu/*
4+
*.xcodeproj/*
55
Package.resolved
66
Packages
7-
build
7+
build/*

.gitmodules

Whitespace-only changes.

.swift-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.1.1
1+
4.0.2

.travis.yml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,9 @@ matrix:
1414
- os: linux
1515
dist: trusty
1616
sudo: required
17-
- os: linux
18-
dist: trusty
19-
sudo: required
20-
env: SWIFT_SNAPSHOT=$SWIFT_4_DEV_SNAPSHOT
21-
- os: osx
22-
osx_image: xcode8.3
23-
sudo: required
2417
- os: osx
25-
osx_image: xcode9
18+
osx_image: xcode9.1
2619
sudo: required
27-
env: SWIFT_SNAPSHOT=$SWIFT_4_DEV_SNAPSHOT
2820

2921
before_install:
3022
- git clone https://github.com/IBM-Swift/Kitura-CI.git

Package.pins

Lines changed: 0 additions & 5 deletions
This file was deleted.

Package.swift

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// swift-tools-version:4.0
2+
// The swift-tools-version declares the minimum version of Swift required to build this package.
3+
14
/**
25
* Copyright IBM Corporation 2016, 2017
36
*
@@ -18,7 +21,25 @@ import PackageDescription
1821

1922
let package = Package(
2023
name: "SwiftRedis",
24+
products: [
25+
// Products define the executables and libraries produced by a package, and make them visible to other packages.
26+
.library(
27+
name: "SwiftRedis",
28+
targets: ["SwiftRedis"]),
29+
],
2130
dependencies: [
22-
.Package(url: "https://github.com/IBM-Swift/BlueSocket.git", majorVersion: 0, minor: 12)
23-
]
31+
// Dependencies declare other packages that this package depends on.
32+
// .package(url: /* package url */, from: "1.0.0"),
33+
.package(url: "https://github.com/IBM-Swift/BlueSocket.git", from: "0.12.0")
34+
],
35+
targets: [
36+
// Targets are the basic building blocks of a package. A target defines a module or a test suite.
37+
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
38+
.target(
39+
name: "SwiftRedis",
40+
dependencies: ["Socket"]),
41+
.testTarget(
42+
name: "SwiftRedisTests",
43+
dependencies: ["SwiftRedis"]),
44+
]
2445
)

[email protected]

Lines changed: 0 additions & 45 deletions
This file was deleted.

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ KituraRedis is a Swift library for interacting with a Redis database using.
88

99
It is dependent on the [BlueSocket](https://github.com/IBM-Swift/BlueSocket.git) module.
1010

11+
## Swift version
12+
The latest version of Kitura-redis requires **Swift 4.0.2**. You can download this version of the Swift binaries by following this [link](https://swift.org/download/). Compatibility with other Swift versions is not guaranteed.
13+
1114
## Build:
1215

1316
- `swift build`

Sources/.swift-version

Lines changed: 0 additions & 1 deletion
This file was deleted.

Sources/SwiftRedis/RedisInfo.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ public struct RedisInfo {
4040
for val in strArray {
4141
let pos = val.range(of: ":")
4242
if let pos = pos {
43-
parsedInfo[val.substring(to: pos.lowerBound)] = val.substring(from: pos.upperBound)
43+
let key = String(val[..<pos.lowerBound])
44+
let value = val[pos.upperBound...]
45+
parsedInfo[key] = String(value)
4446
}
4547
}
4648

Tests/SwiftRedisTests/TestHashCommands.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public class TestHashCommands: XCTestCase {
132132
redis.hstrlen(self.key, field: self.field1) {(length: Int?, error: NSError?) in
133133
XCTAssertNil(error, "\(error != nil ? error!.localizedDescription : "")")
134134
XCTAssertNotNil(length, "Length of field shouldn't be nil")
135-
XCTAssertEqual(length!, expVal1.characters.count, "Length of field should be \(expVal1.characters.count), was \(length!)")
135+
XCTAssertEqual(length!, expVal1.count, "Length of field should be \(expVal1.count), was \(length!)")
136136
}
137137
}
138138
}

Tests/SwiftRedisTests/TestStringAndBitCommands.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ public class TestStringAndBitCommands: XCTestCase {
4747
redis.append(self.key1, value: self.expVal2) {(length: Int?, error: NSError?) in
4848
XCTAssertNil(error, "\(error != nil ? error!.localizedDescription : "")")
4949
XCTAssertNotNil(length, "Length result shouldn't be nil")
50-
XCTAssertEqual(length!, self.expVal1.characters.count+self.expVal2.characters.count, "Length of updated \(self.key1) is incorrect")
50+
XCTAssertEqual(length!, self.expVal1.count+self.expVal2.count, "Length of updated \(self.key1) is incorrect")
5151

5252
redis.strlen(self.key1) {(length: Int?, error: NSError?) in
5353
XCTAssertNil(error, "\(error != nil ? error!.localizedDescription : "")")
5454
XCTAssertNotNil(length, "Length result shouldn't be nil")
55-
XCTAssertEqual(length!, self.expVal1.characters.count+self.expVal2.characters.count, "Length of updated \(self.key1) is incorrect")
55+
XCTAssertEqual(length!, self.expVal1.count+self.expVal2.count, "Length of updated \(self.key1) is incorrect")
5656

5757
redis.getrange(self.key1, start: 7, end: 11) {(value: RedisString?, error: NSError?) in
5858
XCTAssertNil(error, "\(error != nil ? error!.localizedDescription : "")")
@@ -62,7 +62,7 @@ public class TestStringAndBitCommands: XCTestCase {
6262
redis.setrange(self.key1, offset: 7, value: self.expVal3) {(length: Int?, error: NSError?) in
6363
XCTAssertNil(error, "\(error != nil ? error!.localizedDescription : "")")
6464
XCTAssertNotNil(length, "Length result shouldn't be nil")
65-
XCTAssertEqual(length!, self.expVal1.characters.count+self.expVal2.characters.count, "Length of updated \(self.key1) is incorrect")
65+
XCTAssertEqual(length!, self.expVal1.count+self.expVal2.count, "Length of updated \(self.key1) is incorrect")
6666

6767
redis.get(self.key1) {(value: RedisString?, error: NSError?) in
6868
XCTAssertNil(error, "\(error != nil ? error!.localizedDescription : "")")

Tests/SwiftRedisTests/TestTransactionsPart2.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public class TestTransactionsPart2: XCTestCase {
148148
multi.exec() {(response: RedisResponse) in
149149
if let nestedResponses = self.baseAsserts(response: response, count: 6) {
150150
XCTAssertEqual(nestedResponses[0], RedisResponse.Status("OK"), "set didn't return an 'OK'")
151-
let updatedLength = Int64(self.expVal1.characters.count+self.expVal2.characters.count)
151+
let updatedLength = Int64(self.expVal1.count+self.expVal2.count)
152152
XCTAssertEqual(nestedResponses[1], RedisResponse.IntegerValue(updatedLength), "Length of updated \(self.key1) is incorrect")
153153
XCTAssertEqual(nestedResponses[2], RedisResponse.IntegerValue(updatedLength), "Length of updated \(self.key1) is incorrect")
154154
XCTAssertEqual(nestedResponses[3], RedisResponse.StringValue(RedisString(", 1 2")), "Get of getrange wasn't ', 1 2' was \(nestedResponses[3])")

docker-compose.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
app:
2+
image: ibmcom/swift-ubuntu:4.0.2
3+
volumes:
4+
- .:/KituraRedis
5+
command: bash -c "cd /KituraRedis && swift package --build-path .build-ubuntu clean && swift build --build-path .build-ubuntu && swift test --build-path .build-ubuntu"

0 commit comments

Comments
 (0)