Skip to content
This repository was archived by the owner on Jul 2, 2018. It is now read-only.

Commit f44c868

Browse files
authored
2.0.0 (#64)
* Updates to Swift 3.0 (#63) * [swift/3.0]: Gets framework building in Swift 3.0 * [swift/3.0]: Swift 3.0 tests passing * [swift/3.0]: Gets the podspec validating * [release/2.0.0]: Updates the version to 2.0.0
1 parent 3f1563a commit f44c868

30 files changed

+656
-840
lines changed

.jazzy.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
author: Daniel Thorpe
22
author_url: http://danthorpe.me
33
module: Money
4-
module_version: 1.8.0
4+
module_version: 2.0.0
55
github_url: https://github.com/danthorpe/Money
66
readme: README.md
77
podspec: Money.podspec
88

9-
swift_version: 2.3
10-
xcodebuild-arguments: -scheme,Money-iOS
9+
swift_version: 3.0
10+
xcodebuild-arguments: -scheme,Money
1111

1212
custom_categories:
1313
- name: Decimals

.swift-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.3
1+
3.0

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# 2.0.0
2+
1. [[MNY-63](https://github.com/danthorpe/Money/pull/63)]: Updates to Swift 3.0.
3+
14
# 1.8.0
25
1. [[MNY-61](https://github.com/danthorpe/Money/pull/61)]: Updates to Swift 2.3.
36

Cartfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
github "danthorpe/ValueCoding" "1.5.0"
1+
github "danthorpe/ValueCoding" "2.0.0"

Cartfile.resolved

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
github "danthorpe/ValueCoding" "1.5.0"
1+
github "danthorpe/ValueCoding" "2.0.0"

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2015 Daniel Thorpe
3+
Copyright (c) 2015, 2016 Daniel Thorpe
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

Money.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "Money"
3-
s.version = "1.8.0"
3+
s.version = "2.0.0"
44
s.summary = "Swift types for working with Money."
55
s.description = <<-DESC
66
@@ -30,7 +30,7 @@ Pod::Spec.new do |s|
3030
s.watchos.exclude_files = [ 'Sources/ApplePay.swift' ]
3131
s.tvos.exclude_files = [ 'Sources/ApplePay.swift' ]
3232

33-
s.dependency 'ValueCoding', '1.5.0'
33+
s.dependency 'ValueCoding', '~> 2'
3434

3535
end
3636

Money.xcodeproj/project.pbxproj

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
65599E9B1DB3D2D500EC123C /* Money.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65599E911DB3D2D500EC123C /* Money.swift */; };
4242
65599E9C1DB3D2D500EC123C /* NSDecimalExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65599E921DB3D2D500EC123C /* NSDecimalExtensions.swift */; };
4343
65599E9D1DB3D2D500EC123C /* NSDecimalNumberExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65599E931DB3D2D500EC123C /* NSDecimalNumberExtensions.swift */; };
44-
65599E9E1DB3D2D500EC123C /* Support.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65599E941DB3D2D500EC123C /* Support.swift */; };
4544
65ECB2B11DB3DC9900F96F46 /* Money.h in Headers */ = {isa = PBXBuildFile; fileRef = 65599E6A1DB3CFD300EC123C /* Money.h */; settings = {ATTRIBUTES = (Public, ); }; };
4645
/* End PBXBuildFile section */
4746

@@ -91,7 +90,8 @@
9190
65599E911DB3D2D500EC123C /* Money.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Money.swift; sourceTree = "<group>"; };
9291
65599E921DB3D2D500EC123C /* NSDecimalExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSDecimalExtensions.swift; sourceTree = "<group>"; };
9392
65599E931DB3D2D500EC123C /* NSDecimalNumberExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSDecimalNumberExtensions.swift; sourceTree = "<group>"; };
94-
65599E941DB3D2D500EC123C /* Support.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Support.swift; sourceTree = "<group>"; };
93+
65ECB2BF1DB4134C00F96F46 /* Autogenerate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Autogenerate.h; sourceTree = "<group>"; };
94+
65ECB2C01DB4134C00F96F46 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
9595
/* End PBXFileReference section */
9696

9797
/* Begin PBXFrameworksBuildPhase section */
@@ -145,6 +145,7 @@
145145
65599E8A1DB3D2D500EC123C /* Sources */,
146146
655155141DB3D59900368D35 /* Tests */,
147147
655155131DB3D56400368D35 /* ... */,
148+
65ECB2BE1DB4134C00F96F46 /* Autogenerate */,
148149
);
149150
sourceTree = "<group>";
150151
};
@@ -183,11 +184,19 @@
183184
65599E911DB3D2D500EC123C /* Money.swift */,
184185
65599E921DB3D2D500EC123C /* NSDecimalExtensions.swift */,
185186
65599E931DB3D2D500EC123C /* NSDecimalNumberExtensions.swift */,
186-
65599E941DB3D2D500EC123C /* Support.swift */,
187187
);
188188
path = Sources;
189189
sourceTree = "<group>";
190190
};
191+
65ECB2BE1DB4134C00F96F46 /* Autogenerate */ = {
192+
isa = PBXGroup;
193+
children = (
194+
65ECB2BF1DB4134C00F96F46 /* Autogenerate.h */,
195+
65ECB2C01DB4134C00F96F46 /* Info.plist */,
196+
);
197+
path = Autogenerate;
198+
sourceTree = "<group>";
199+
};
191200
/* End PBXGroup section */
192201

193202
/* Begin PBXHeadersBuildPhase section */
@@ -314,6 +323,7 @@
314323
runOnlyForDeploymentPostprocessing = 0;
315324
shellPath = /bin/sh;
316325
shellScript = "\"$SCRIPT_INPUT_FILE_0\" \"$SCRIPT_OUTPUT_FILE_0\" \"$SCRIPT_OUTPUT_FILE_1\"";
326+
showEnvVarsInLog = 0;
317327
};
318328
65ECB2B21DB3DD9F00F96F46 /* Copy Carthage Frameworks */ = {
319329
isa = PBXShellScriptBuildPhase;
@@ -339,7 +349,6 @@
339349
buildActionMask = 2147483647;
340350
files = (
341351
65599E971DB3D2D500EC123C /* Currency.swift in Sources */,
342-
65599E9E1DB3D2D500EC123C /* Support.swift in Sources */,
343352
65599E9D1DB3D2D500EC123C /* NSDecimalNumberExtensions.swift in Sources */,
344353
65599E961DB3D2D500EC123C /* Bitcoin.swift in Sources */,
345354
65599E9B1DB3D2D500EC123C /* Money.swift in Sources */,

Money.xcodeproj/xcshareddata/xcschemes/Money.xcscheme

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
buildConfiguration = "Debug"
2727
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2828
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29-
shouldUseLaunchSchemeArgsEnv = "YES">
29+
shouldUseLaunchSchemeArgsEnv = "YES"
30+
codeCoverageEnabled = "YES">
3031
<Testables>
3132
<TestableReference
3233
skipped = "NO">

Sources/ApplePay.swift

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ import ValueCoding
4242
- see: PKPaymentSummaryItemType
4343
*/
4444
public enum PaymentSummaryItemType: Int {
45-
case Final = 1, Pending
45+
case final = 1, pending
4646
}
4747

4848
/**
@@ -55,7 +55,7 @@ public enum PaymentSummaryItemType: Int {
5555
The money type must use `NSDecimalNumber` storage type, and correctly
5656
conform to `ValueCoding`.
5757
*/
58-
public struct PaymentSummaryItem<Cost: MoneyType where Cost.DecimalStorageType == NSDecimalNumber, Cost.Coder: NSCoding, Cost.Coder.ValueType == Cost>: Hashable, ValueCoding {
58+
public struct PaymentSummaryItem<Cost: MoneyType>: Hashable, ValueCoding where Cost.DecimalStorageType == NSDecimalNumber, Cost.Coder: NSCoding, Cost.Coder.Value == Cost {
5959

6060
/// The ValueCoding Coder type
6161
public typealias Coder = PaymentSummaryItemCoder<Cost>
@@ -100,13 +100,13 @@ public struct PaymentSummaryItem<Cost: MoneyType where Cost.DecimalStorageType =
100100
- parameter type: the value for the `type` property.
101101
- returns: a summary item with a given label, cost and type.
102102
*/
103-
public init(label: String, cost: Cost, type: PaymentSummaryItemType = .Final) {
103+
public init(label: String, cost: Cost, type: PaymentSummaryItemType = .final) {
104104
self.label = label
105105
self.type = type
106106
switch type {
107-
case .Final:
107+
case .final:
108108
self.cost = cost
109-
case .Pending:
109+
case .pending:
110110
self.cost = 0
111111
}
112112
}
@@ -119,7 +119,7 @@ extension PaymentSummaryItem {
119119
- parameter newLabel: the value for the `label` property in an item copy
120120
- returns: a summary item with a new label value, and previously set cost and type.
121121
*/
122-
public func setLabel(newLabel: String) -> PaymentSummaryItem {
122+
public func set(label newLabel: String) -> PaymentSummaryItem {
123123
return PaymentSummaryItem(label: newLabel, cost: cost, type: type)
124124
}
125125

@@ -128,7 +128,7 @@ extension PaymentSummaryItem {
128128
- parameter newCost: the value for the `cost` property in an item copy
129129
- returns: a summary item with a new cost value, and previously set label and type.
130130
*/
131-
public func setCost(newCost: Cost) -> PaymentSummaryItem {
131+
public func set(cost newCost: Cost) -> PaymentSummaryItem {
132132
return PaymentSummaryItem(label: label, cost: newCost, type: type)
133133
}
134134

@@ -137,15 +137,15 @@ extension PaymentSummaryItem {
137137
- parameter newType: the value for the `type` property in an item copy
138138
- returns: a summary item with a new type value, and previously set label and cost.
139139
*/
140-
public func setType(newType: PaymentSummaryItemType) -> PaymentSummaryItem {
140+
public func set(type newType: PaymentSummaryItemType) -> PaymentSummaryItem {
141141
return PaymentSummaryItem(label: label, cost: cost, type: newType)
142142
}
143143
}
144144

145145
/**
146146
Coding adaptor for `PaymentSummaryItem`.
147147
*/
148-
public final class PaymentSummaryItemCoder<Cost: MoneyType where Cost.DecimalStorageType == NSDecimalNumber, Cost.Coder: NSCoding, Cost.Coder.ValueType == Cost>: NSObject, NSCoding, CodingType {
148+
public final class PaymentSummaryItemCoder<Cost: MoneyType>: NSObject, NSCoding, CodingProtocol where Cost.DecimalStorageType == NSDecimalNumber, Cost.Coder: NSCoding, Cost.Coder.Value == Cost {
149149

150150
public let value: PaymentSummaryItem<Cost>
151151

@@ -154,16 +154,16 @@ public final class PaymentSummaryItemCoder<Cost: MoneyType where Cost.DecimalSto
154154
}
155155

156156
public init?(coder aDecoder: NSCoder) {
157-
let cost = Cost.decode(aDecoder.decodeObjectForKey("cost"))
158-
let label = aDecoder.decodeObjectForKey("label") as? String
159-
let type = PaymentSummaryItemType(rawValue: aDecoder.decodeIntegerForKey("type"))
157+
let cost = Cost.decode(aDecoder.decodeObject(forKey: "cost") as AnyObject?)
158+
let label = aDecoder.decodeObject(forKey: "label") as? String
159+
let type = PaymentSummaryItemType(rawValue: aDecoder.decodeInteger(forKey: "type"))
160160
value = PaymentSummaryItem(label: label!, cost: cost!, type: type!)
161161
}
162162

163-
public func encodeWithCoder(aCoder: NSCoder) {
164-
aCoder.encodeObject(value.label, forKey: "label")
165-
aCoder.encodeObject(value.cost.encoded, forKey: "cost")
166-
aCoder.encodeInteger(value.type.rawValue, forKey: "type")
163+
public func encode(with aCoder: NSCoder) {
164+
aCoder.encode(value.label, forKey: "label")
165+
aCoder.encode(value.cost.encoded, forKey: "cost")
166+
aCoder.encode(value.type.rawValue, forKey: "type")
167167
}
168168
}
169169

@@ -174,17 +174,17 @@ internal extension PKPaymentSummaryItemType {
174174

175175
init(paymentSummaryItemType: PaymentSummaryItemType) {
176176
switch paymentSummaryItemType {
177-
case .Final:
178-
self = .Final
179-
case .Pending:
180-
self = .Pending
177+
case .final:
178+
self = .final
179+
case .pending:
180+
self = .pending
181181
}
182182
}
183183
}
184184

185185
internal extension PKPaymentSummaryItem {
186186

187-
convenience init<Cost: MoneyType where Cost.DecimalStorageType == NSDecimalNumber>(paymentSummaryItem: PaymentSummaryItem<Cost>) {
187+
convenience init<Cost: MoneyType>(paymentSummaryItem: PaymentSummaryItem<Cost>) where Cost.DecimalStorageType == NSDecimalNumber {
188188
self.init()
189189
amount = paymentSummaryItem.amount
190190
label = paymentSummaryItem.label
@@ -209,19 +209,19 @@ public extension PKPaymentRequest {
209209
- parameter sellerName: a `String` which is used in the total cost summary item.
210210
- returns: a `PKPaymentRequest` which has its payment summary items and currency code set.
211211
*/
212-
convenience init<Cost: MoneyType where Cost.DecimalStorageType == NSDecimalNumber, Cost.Coder: NSCoding, Cost.Coder.ValueType == Cost>(items: [PaymentSummaryItem<Cost>], sellerName: String) {
212+
convenience init<Cost: MoneyType>(items: [PaymentSummaryItem<Cost>], sellerName: String) where Cost.DecimalStorageType == NSDecimalNumber, Cost.Coder: NSCoding, Cost.Coder.Value == Cost {
213213
self.init()
214214
currencyCode = Cost.Currency.code
215215
var items = items
216-
let total = items.map { $0.cost }.reduce(0, combine: +)
216+
let total = items.map { $0.cost }.reduce(0, +)
217217
items.append(PaymentSummaryItem(label: sellerName, cost: total))
218218
paymentSummaryItems = items.map { PKPaymentSummaryItem(paymentSummaryItem: $0) }
219219
}
220220
}
221221

222222
// MARK: - Equality
223223

224-
public func ==<Cost: MoneyType where Cost.DecimalStorageType == NSDecimalNumber>(lhs: PaymentSummaryItem<Cost>, rhs: PaymentSummaryItem<Cost>) -> Bool {
224+
public func ==<Cost: MoneyType>(lhs: PaymentSummaryItem<Cost>, rhs: PaymentSummaryItem<Cost>) -> Bool where Cost.DecimalStorageType == NSDecimalNumber {
225225
return lhs.cost == rhs.cost && lhs.label == rhs.label && lhs.type == rhs.type
226226
}
227227

0 commit comments

Comments
 (0)