Skip to content

Commit 88edd59

Browse files
committed
Migrate to Swift 3
1 parent 629e0c8 commit 88edd59

19 files changed

+264
-250
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.build
2+
Packages

.travis.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
language: objective-c
2-
osx_image: xcode7
3-
install: brew install --HEAD kylef/formulae/conche
2+
osx_image: xcode8
43
script:
5-
- conche test
4+
- swift test

CardKit.podspec.json

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,5 @@
1212
"watchos": "2.0",
1313
"tvos": "9.0"
1414
},
15-
"source_files": "CardKit/*.swift",
16-
"test_specification": {
17-
"dependencies": {
18-
"Spectre": [ "~> 0.2.0" ]
19-
},
20-
"source_files": "CardKitSpecs/*.swift"
21-
}
15+
"source_files": "Sources/*.swift"
2216
}

CardKit/Value.swift

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

CardKitSpecs/CardSpec.swift

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

CardKitSpecs/DeckSpec.swift

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

CardKitSpecs/SuitSpec.swift

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

CardKitSpecs/ValueSpec.swift

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

Package.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import PackageDescription
2+
3+
4+
let package = Package(
5+
name: "CardKit",
6+
dependencies: [
7+
.Package(url: "https://github.com/kylef/Spectre.git", majorVersion: 0, minor: 7),
8+
]
9+
)

README.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,6 @@ New shuffled array of cards
2828
let shuffledDeck = deck.shuffled()
2929
```
3030

31-
## Installation
32-
33-
[CocoaPods](http://cocoapods.org/) or [Conche](https://github.com/kylef/Conche)
34-
are the recommended and supported installation methods.
35-
36-
```ruby
37-
pod 'CardKit'
38-
```
39-
4031
## License
4132

4233
CardKit is licensed under the BSD license. See [LICENSE](LICENSE) for more
File renamed without changes.

CardKit/Deck.swift renamed to Sources/Deck.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Darwin
22

3-
extension CollectionType {
3+
extension Collection {
44
/// Returns a shuffled array
55
public func shuffled() -> [Generator.Element] {
66
var array = Array(self)
@@ -9,11 +9,11 @@ extension CollectionType {
99
}
1010
}
1111

12-
extension MutableCollectionType where Index == Int {
12+
extension MutableCollection where Index == Int {
1313
/// Shuffle elements in-place
1414
mutating public func shuffle() {
15-
for index in 0 ..< (count - 1) {
16-
let newIndex = Int(arc4random_uniform(UInt32(count - index))) + index
15+
for index in startIndex ..< (endIndex - 1) {
16+
let newIndex = Int(arc4random_uniform(UInt32(endIndex - index))) + index
1717

1818
if newIndex != index {
1919
swap(&self[index], &self[newIndex])

CardKit/Suit.swift renamed to Sources/Suit.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
public enum Suit {
2-
case Spade
3-
case Heart
4-
case Diamond
5-
case Club
2+
case spade
3+
case heart
4+
case diamond
5+
case club
66

77
/// Returns all possible suits
88
static var all: [Suit] {
9-
return [.Spade, .Heart, .Diamond, .Club]
9+
return [.spade, .heart, .diamond, .club]
1010
}
1111
}
1212

1313
extension Suit : CustomStringConvertible {
1414
public var description: String {
1515
switch self {
16-
case Spade:
16+
case .spade:
1717
return "Spade"
18-
case Heart:
18+
case .heart:
1919
return "Heart"
20-
case Diamond:
20+
case .diamond:
2121
return "Diamond"
22-
case Club:
22+
case .club:
2323
return "Club"
2424
}
2525
}

Sources/Value.swift

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
public enum Value {
2+
case ace
3+
case two
4+
case three
5+
case four
6+
case five
7+
case six
8+
case seven
9+
case eight
10+
case nine
11+
case ten
12+
case jack
13+
case queen
14+
case king
15+
16+
/// Returns all possible values
17+
static var all: [Value] {
18+
return [
19+
.ace, .two, .three, .four, .five, .six, .seven, .eight, .nine, .ten,
20+
.jack, .queen, .king
21+
]
22+
}
23+
}
24+
25+
extension Value : CustomStringConvertible {
26+
public var description: String {
27+
switch self {
28+
case .ace:
29+
return "A"
30+
case .two:
31+
return "2"
32+
case .three:
33+
return "3"
34+
case .four:
35+
return "4"
36+
case .five:
37+
return "5"
38+
case .six:
39+
return "6"
40+
case .seven:
41+
return "7"
42+
case .eight:
43+
return "8"
44+
case .nine:
45+
return "9"
46+
case .ten:
47+
return "10"
48+
case .jack:
49+
return "J"
50+
case .queen:
51+
return "Q"
52+
case .king:
53+
return "K"
54+
}
55+
}
56+
}

0 commit comments

Comments
 (0)