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

Commit

Permalink
2.0.0 (#64)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
danthorpe authored Oct 19, 2016
1 parent 3f1563a commit f44c868
Show file tree
Hide file tree
Showing 30 changed files with 656 additions and 840 deletions.
6 changes: 3 additions & 3 deletions .jazzy.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
author: Daniel Thorpe
author_url: http://danthorpe.me
module: Money
module_version: 1.8.0
module_version: 2.0.0
github_url: https://github.com/danthorpe/Money
readme: README.md
podspec: Money.podspec

swift_version: 2.3
xcodebuild-arguments: -scheme,Money-iOS
swift_version: 3.0
xcodebuild-arguments: -scheme,Money

custom_categories:
- name: Decimals
Expand Down
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.3
3.0
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 2.0.0
1. [[MNY-63](https://github.com/danthorpe/Money/pull/63)]: Updates to Swift 3.0.

# 1.8.0
1. [[MNY-61](https://github.com/danthorpe/Money/pull/61)]: Updates to Swift 2.3.

Expand Down
2 changes: 1 addition & 1 deletion Cartfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "danthorpe/ValueCoding" "1.5.0"
github "danthorpe/ValueCoding" "2.0.0"
2 changes: 1 addition & 1 deletion Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "danthorpe/ValueCoding" "1.5.0"
github "danthorpe/ValueCoding" "2.0.0"
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2015 Daniel Thorpe
Copyright (c) 2015, 2016 Daniel Thorpe

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 2 additions & 2 deletions Money.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "Money"
s.version = "1.8.0"
s.version = "2.0.0"
s.summary = "Swift types for working with Money."
s.description = <<-DESC
Expand Down Expand Up @@ -30,7 +30,7 @@ Pod::Spec.new do |s|
s.watchos.exclude_files = [ 'Sources/ApplePay.swift' ]
s.tvos.exclude_files = [ 'Sources/ApplePay.swift' ]

s.dependency 'ValueCoding', '1.5.0'
s.dependency 'ValueCoding', '~> 2'

end

17 changes: 13 additions & 4 deletions Money.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
65599E9B1DB3D2D500EC123C /* Money.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65599E911DB3D2D500EC123C /* Money.swift */; };
65599E9C1DB3D2D500EC123C /* NSDecimalExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65599E921DB3D2D500EC123C /* NSDecimalExtensions.swift */; };
65599E9D1DB3D2D500EC123C /* NSDecimalNumberExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65599E931DB3D2D500EC123C /* NSDecimalNumberExtensions.swift */; };
65599E9E1DB3D2D500EC123C /* Support.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65599E941DB3D2D500EC123C /* Support.swift */; };
65ECB2B11DB3DC9900F96F46 /* Money.h in Headers */ = {isa = PBXBuildFile; fileRef = 65599E6A1DB3CFD300EC123C /* Money.h */; settings = {ATTRIBUTES = (Public, ); }; };
/* End PBXBuildFile section */

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

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -145,6 +145,7 @@
65599E8A1DB3D2D500EC123C /* Sources */,
655155141DB3D59900368D35 /* Tests */,
655155131DB3D56400368D35 /* ... */,
65ECB2BE1DB4134C00F96F46 /* Autogenerate */,
);
sourceTree = "<group>";
};
Expand Down Expand Up @@ -183,11 +184,19 @@
65599E911DB3D2D500EC123C /* Money.swift */,
65599E921DB3D2D500EC123C /* NSDecimalExtensions.swift */,
65599E931DB3D2D500EC123C /* NSDecimalNumberExtensions.swift */,
65599E941DB3D2D500EC123C /* Support.swift */,
);
path = Sources;
sourceTree = "<group>";
};
65ECB2BE1DB4134C00F96F46 /* Autogenerate */ = {
isa = PBXGroup;
children = (
65ECB2BF1DB4134C00F96F46 /* Autogenerate.h */,
65ECB2C01DB4134C00F96F46 /* Info.plist */,
);
path = Autogenerate;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXHeadersBuildPhase section */
Expand Down Expand Up @@ -314,6 +323,7 @@
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"$SCRIPT_INPUT_FILE_0\" \"$SCRIPT_OUTPUT_FILE_0\" \"$SCRIPT_OUTPUT_FILE_1\"";
showEnvVarsInLog = 0;
};
65ECB2B21DB3DD9F00F96F46 /* Copy Carthage Frameworks */ = {
isa = PBXShellScriptBuildPhase;
Expand All @@ -339,7 +349,6 @@
buildActionMask = 2147483647;
files = (
65599E971DB3D2D500EC123C /* Currency.swift in Sources */,
65599E9E1DB3D2D500EC123C /* Support.swift in Sources */,
65599E9D1DB3D2D500EC123C /* NSDecimalNumberExtensions.swift in Sources */,
65599E961DB3D2D500EC123C /* Bitcoin.swift in Sources */,
65599E9B1DB3D2D500EC123C /* Money.swift in Sources */,
Expand Down
3 changes: 2 additions & 1 deletion Money.xcodeproj/xcshareddata/xcschemes/Money.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
<Testables>
<TestableReference
skipped = "NO">
Expand Down
48 changes: 24 additions & 24 deletions Sources/ApplePay.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import ValueCoding
- see: PKPaymentSummaryItemType
*/
public enum PaymentSummaryItemType: Int {
case Final = 1, Pending
case final = 1, pending
}

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

/// The ValueCoding Coder type
public typealias Coder = PaymentSummaryItemCoder<Cost>
Expand Down Expand Up @@ -100,13 +100,13 @@ public struct PaymentSummaryItem<Cost: MoneyType where Cost.DecimalStorageType =
- parameter type: the value for the `type` property.
- returns: a summary item with a given label, cost and type.
*/
public init(label: String, cost: Cost, type: PaymentSummaryItemType = .Final) {
public init(label: String, cost: Cost, type: PaymentSummaryItemType = .final) {
self.label = label
self.type = type
switch type {
case .Final:
case .final:
self.cost = cost
case .Pending:
case .pending:
self.cost = 0
}
}
Expand All @@ -119,7 +119,7 @@ extension PaymentSummaryItem {
- parameter newLabel: the value for the `label` property in an item copy
- returns: a summary item with a new label value, and previously set cost and type.
*/
public func setLabel(newLabel: String) -> PaymentSummaryItem {
public func set(label newLabel: String) -> PaymentSummaryItem {
return PaymentSummaryItem(label: newLabel, cost: cost, type: type)
}

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

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

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

public let value: PaymentSummaryItem<Cost>

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

public init?(coder aDecoder: NSCoder) {
let cost = Cost.decode(aDecoder.decodeObjectForKey("cost"))
let label = aDecoder.decodeObjectForKey("label") as? String
let type = PaymentSummaryItemType(rawValue: aDecoder.decodeIntegerForKey("type"))
let cost = Cost.decode(aDecoder.decodeObject(forKey: "cost") as AnyObject?)
let label = aDecoder.decodeObject(forKey: "label") as? String
let type = PaymentSummaryItemType(rawValue: aDecoder.decodeInteger(forKey: "type"))
value = PaymentSummaryItem(label: label!, cost: cost!, type: type!)
}

public func encodeWithCoder(aCoder: NSCoder) {
aCoder.encodeObject(value.label, forKey: "label")
aCoder.encodeObject(value.cost.encoded, forKey: "cost")
aCoder.encodeInteger(value.type.rawValue, forKey: "type")
public func encode(with aCoder: NSCoder) {
aCoder.encode(value.label, forKey: "label")
aCoder.encode(value.cost.encoded, forKey: "cost")
aCoder.encode(value.type.rawValue, forKey: "type")
}
}

Expand All @@ -174,17 +174,17 @@ internal extension PKPaymentSummaryItemType {

init(paymentSummaryItemType: PaymentSummaryItemType) {
switch paymentSummaryItemType {
case .Final:
self = .Final
case .Pending:
self = .Pending
case .final:
self = .final
case .pending:
self = .pending
}
}
}

internal extension PKPaymentSummaryItem {

convenience init<Cost: MoneyType where Cost.DecimalStorageType == NSDecimalNumber>(paymentSummaryItem: PaymentSummaryItem<Cost>) {
convenience init<Cost: MoneyType>(paymentSummaryItem: PaymentSummaryItem<Cost>) where Cost.DecimalStorageType == NSDecimalNumber {
self.init()
amount = paymentSummaryItem.amount
label = paymentSummaryItem.label
Expand All @@ -209,19 +209,19 @@ public extension PKPaymentRequest {
- parameter sellerName: a `String` which is used in the total cost summary item.
- returns: a `PKPaymentRequest` which has its payment summary items and currency code set.
*/
convenience init<Cost: MoneyType where Cost.DecimalStorageType == NSDecimalNumber, Cost.Coder: NSCoding, Cost.Coder.ValueType == Cost>(items: [PaymentSummaryItem<Cost>], sellerName: String) {
convenience init<Cost: MoneyType>(items: [PaymentSummaryItem<Cost>], sellerName: String) where Cost.DecimalStorageType == NSDecimalNumber, Cost.Coder: NSCoding, Cost.Coder.Value == Cost {
self.init()
currencyCode = Cost.Currency.code
var items = items
let total = items.map { $0.cost }.reduce(0, combine: +)
let total = items.map { $0.cost }.reduce(0, +)
items.append(PaymentSummaryItem(label: sellerName, cost: total))
paymentSummaryItems = items.map { PKPaymentSummaryItem(paymentSummaryItem: $0) }
}
}

// MARK: - Equality

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

Expand Down
10 changes: 5 additions & 5 deletions Sources/Autogenerated.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4693,10 +4693,10 @@ in more than one country, an associated value
of the country should be provided. For example

```swift
let locale: Locale = .French(.France)
let locale: MNYLocale = .French(.France)
```
*/
public enum Locale {
public enum MNYLocale {

/**
### Afrikaans
Expand Down Expand Up @@ -5428,7 +5428,7 @@ public enum Locale {
/**
Locale conforms to LanguageType.
*/
extension Locale: LanguageType {
extension MNYLocale: LanguageType {

/// - returns: the lanauge identifier as a String.
public var languageIdentifier: String {
Expand Down Expand Up @@ -5826,7 +5826,7 @@ extension Locale: LanguageType {
/**
Locale conforms to CountryType.
*/
extension Locale: CountryType {
extension MNYLocale: CountryType {

/// - returns: the country identifier as a String.
public var countryIdentifier: String {
Expand Down Expand Up @@ -5935,6 +5935,6 @@ extension Locale: CountryType {
}
}

extension Locale: LocaleType {
extension MNYLocale: LocaleType {
// Uses default implementation
}
Loading

0 comments on commit f44c868

Please sign in to comment.