Skip to content

Commit

Permalink
Updated to Swift 4.0 (#61)
Browse files Browse the repository at this point in the history
* Updated to Swift 4

* Deleted Package.pins

* Finalised conversion to Swift 4 only

* Migration to Swift 4.0.2
  • Loading branch information
Davidde94 authored and rolivieri committed Nov 21, 2017
1 parent d6626c0 commit 265c110
Show file tree
Hide file tree
Showing 14 changed files with 45 additions and 73 deletions.
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
*.DS_Store
*.pkg
.build
/SwiftRedis.xcodeproj
.build/*
.build-ubuntu/*
*.xcodeproj/*
Package.resolved
Packages
build
build/*
Empty file removed .gitmodules
Empty file.
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.1.1
4.0.2
10 changes: 1 addition & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,9 @@ matrix:
- os: linux
dist: trusty
sudo: required
- os: linux
dist: trusty
sudo: required
env: SWIFT_SNAPSHOT=$SWIFT_4_DEV_SNAPSHOT
- os: osx
osx_image: xcode8.3
sudo: required
- os: osx
osx_image: xcode9
osx_image: xcode9.1
sudo: required
env: SWIFT_SNAPSHOT=$SWIFT_4_DEV_SNAPSHOT

before_install:
- git clone https://github.com/IBM-Swift/Kitura-CI.git
Expand Down
5 changes: 0 additions & 5 deletions Package.pins

This file was deleted.

25 changes: 23 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// swift-tools-version:4.0
// The swift-tools-version declares the minimum version of Swift required to build this package.

/**
* Copyright IBM Corporation 2016, 2017
*
Expand All @@ -18,7 +21,25 @@ import PackageDescription

let package = Package(
name: "SwiftRedis",
products: [
// Products define the executables and libraries produced by a package, and make them visible to other packages.
.library(
name: "SwiftRedis",
targets: ["SwiftRedis"]),
],
dependencies: [
.Package(url: "https://github.com/IBM-Swift/BlueSocket.git", majorVersion: 0, minor: 12)
]
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
.package(url: "https://github.com/IBM-Swift/BlueSocket.git", from: "0.12.0")
],
targets: [
// Targets are the basic building blocks of a package. A target defines a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
.target(
name: "SwiftRedis",
dependencies: ["Socket"]),
.testTarget(
name: "SwiftRedisTests",
dependencies: ["SwiftRedis"]),
]
)
45 changes: 0 additions & 45 deletions Package@swift-4.swift

This file was deleted.

3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ KituraRedis is a Swift library for interacting with a Redis database using.

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

## Swift version
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.

## Build:

- `swift build`
Expand Down
1 change: 0 additions & 1 deletion Sources/.swift-version

This file was deleted.

4 changes: 3 additions & 1 deletion Sources/SwiftRedis/RedisInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ public struct RedisInfo {
for val in strArray {
let pos = val.range(of: ":")
if let pos = pos {
parsedInfo[val.substring(to: pos.lowerBound)] = val.substring(from: pos.upperBound)
let key = String(val[..<pos.lowerBound])
let value = val[pos.upperBound...]
parsedInfo[key] = String(value)
}
}

Expand Down
2 changes: 1 addition & 1 deletion Tests/SwiftRedisTests/TestHashCommands.swift
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public class TestHashCommands: XCTestCase {
redis.hstrlen(self.key, field: self.field1) {(length: Int?, error: NSError?) in
XCTAssertNil(error, "\(error != nil ? error!.localizedDescription : "")")
XCTAssertNotNil(length, "Length of field shouldn't be nil")
XCTAssertEqual(length!, expVal1.characters.count, "Length of field should be \(expVal1.characters.count), was \(length!)")
XCTAssertEqual(length!, expVal1.count, "Length of field should be \(expVal1.count), was \(length!)")
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions Tests/SwiftRedisTests/TestStringAndBitCommands.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ public class TestStringAndBitCommands: XCTestCase {
redis.append(self.key1, value: self.expVal2) {(length: Int?, error: NSError?) in
XCTAssertNil(error, "\(error != nil ? error!.localizedDescription : "")")
XCTAssertNotNil(length, "Length result shouldn't be nil")
XCTAssertEqual(length!, self.expVal1.characters.count+self.expVal2.characters.count, "Length of updated \(self.key1) is incorrect")
XCTAssertEqual(length!, self.expVal1.count+self.expVal2.count, "Length of updated \(self.key1) is incorrect")

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

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

redis.get(self.key1) {(value: RedisString?, error: NSError?) in
XCTAssertNil(error, "\(error != nil ? error!.localizedDescription : "")")
Expand Down
2 changes: 1 addition & 1 deletion Tests/SwiftRedisTests/TestTransactionsPart2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public class TestTransactionsPart2: XCTestCase {
multi.exec() {(response: RedisResponse) in
if let nestedResponses = self.baseAsserts(response: response, count: 6) {
XCTAssertEqual(nestedResponses[0], RedisResponse.Status("OK"), "set didn't return an 'OK'")
let updatedLength = Int64(self.expVal1.characters.count+self.expVal2.characters.count)
let updatedLength = Int64(self.expVal1.count+self.expVal2.count)
XCTAssertEqual(nestedResponses[1], RedisResponse.IntegerValue(updatedLength), "Length of updated \(self.key1) is incorrect")
XCTAssertEqual(nestedResponses[2], RedisResponse.IntegerValue(updatedLength), "Length of updated \(self.key1) is incorrect")
XCTAssertEqual(nestedResponses[3], RedisResponse.StringValue(RedisString(", 1 2")), "Get of getrange wasn't ', 1 2' was \(nestedResponses[3])")
Expand Down
5 changes: 5 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
app:
image: ibmcom/swift-ubuntu:4.0.2
volumes:
- .:/KituraRedis
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 comments on commit 265c110

Please # to comment.