├── .github ├── FUNDING.yml └── workflows │ ├── ci.yml │ └── documentation.yml ├── .gitignore ├── CurrencyConverter.playground ├── Contents.swift ├── Sources │ └── Money+Playgrounds.swift └── contents.xcplayground ├── CurrencyConverter.xcodeproj ├── CurrencyConverterTests_Info.plist ├── CurrencyConverter_Info.plist ├── Money_Info.plist ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ ├── IDEWorkspaceChecks.plist │ │ └── WorkspaceSettings.xcsettings └── xcshareddata │ └── xcschemes │ ├── CurrencyConverter.xcscheme │ └── xcschememanagement.plist ├── CurrencyConverter.xcworkspace ├── contents.xcworkspacedata └── xcshareddata │ └── IDEWorkspaceChecks.plist ├── LICENSE.md ├── Package.resolved ├── Package.swift ├── README.md ├── Sources └── CurrencyConverter │ ├── BidirectionalCurrencyConverter.swift │ ├── CurrencyPair.swift │ └── UnidirectionalCurrencyConverter.swift └── Tests └── CurrencyConverterTests └── CurrenyPairTests.swift /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: [mattt] 2 | custom: https://flight.school/books/numbers 3 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | branches: [master] 6 | pull_request: 7 | branches: [master] 8 | 9 | jobs: 10 | macos: 11 | runs-on: macos-latest 12 | 13 | steps: 14 | - name: Checkout 15 | uses: actions/checkout@v1 16 | - name: Build and Test 17 | run: swift test 18 | 19 | linux: 20 | runs-on: ubuntu-latest 21 | 22 | strategy: 23 | matrix: 24 | swift: ["5.1", "5.2", "latest"] 25 | 26 | container: 27 | image: swift:${{ matrix.swift }} 28 | 29 | steps: 30 | - name: Checkout 31 | uses: actions/checkout@v1 32 | - name: Build and Test 33 | run: swift test --enable-test-discovery 34 | -------------------------------------------------------------------------------- /.github/workflows/documentation.yml: -------------------------------------------------------------------------------- 1 | name: Documentation 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | paths: 8 | - .github/workflows/documentation.yml 9 | - Sources/**.swift 10 | 11 | jobs: 12 | build: 13 | runs-on: ubuntu-latest 14 | 15 | steps: 16 | - name: Checkout 17 | uses: actions/checkout@v1 18 | - name: Generate Documentation 19 | uses: SwiftDocOrg/swift-doc@master 20 | with: 21 | inputs: "Sources/SwiftDoc" 22 | output: "Documentation" 23 | - name: Upload Documentation to Wiki 24 | uses: SwiftDocOrg/github-wiki-publish-action@v1 25 | with: 26 | path: "Documentation" 27 | env: 28 | GH_PERSONAL_ACCESS_TOKEN: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} 29 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | /.build 3 | /Packages 4 | /*.xcodeproj 5 | -------------------------------------------------------------------------------- /CurrencyConverter.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | import Money 2 | import CurrencyConverter 3 | 4 | let EURtoUSD = CurrencyPair(rate: 1.17) // as of June 1st, 2018 5 | 6 | let euros: Money = 123.45 7 | let dollars = EURtoUSD.convert(euros).rounded 8 | -------------------------------------------------------------------------------- /CurrencyConverter.playground/Sources/Money+Playgrounds.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | import Money 3 | 4 | extension Money: CustomPlaygroundDisplayConvertible { 5 | public var playgroundDescription: Any { 6 | let formatter = NumberFormatter() 7 | formatter.numberStyle = .currency 8 | formatter.currencyCode = Currency.code 9 | 10 | return formatter.string(for: self.amount)! 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /CurrencyConverter.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /CurrencyConverter.xcodeproj/CurrencyConverterTests_Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CFBundleDevelopmentRegion 5 | en 6 | CFBundleExecutable 7 | $(EXECUTABLE_NAME) 8 | CFBundleIdentifier 9 | $(PRODUCT_BUNDLE_IDENTIFIER) 10 | CFBundleInfoDictionaryVersion 11 | 6.0 12 | CFBundleName 13 | $(PRODUCT_NAME) 14 | CFBundlePackageType 15 | BNDL 16 | CFBundleShortVersionString 17 | 1.0 18 | CFBundleSignature 19 | ???? 20 | CFBundleVersion 21 | $(CURRENT_PROJECT_VERSION) 22 | NSPrincipalClass 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /CurrencyConverter.xcodeproj/CurrencyConverter_Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CFBundleDevelopmentRegion 5 | en 6 | CFBundleExecutable 7 | $(EXECUTABLE_NAME) 8 | CFBundleIdentifier 9 | $(PRODUCT_BUNDLE_IDENTIFIER) 10 | CFBundleInfoDictionaryVersion 11 | 6.0 12 | CFBundleName 13 | $(PRODUCT_NAME) 14 | CFBundlePackageType 15 | FMWK 16 | CFBundleShortVersionString 17 | 1.0 18 | CFBundleSignature 19 | ???? 20 | CFBundleVersion 21 | $(CURRENT_PROJECT_VERSION) 22 | NSPrincipalClass 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /CurrencyConverter.xcodeproj/Money_Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CFBundleDevelopmentRegion 5 | en 6 | CFBundleExecutable 7 | $(EXECUTABLE_NAME) 8 | CFBundleIdentifier 9 | $(PRODUCT_BUNDLE_IDENTIFIER) 10 | CFBundleInfoDictionaryVersion 11 | 6.0 12 | CFBundleName 13 | $(PRODUCT_NAME) 14 | CFBundlePackageType 15 | FMWK 16 | CFBundleShortVersionString 17 | 1.0 18 | CFBundleSignature 19 | ???? 20 | CFBundleVersion 21 | $(CURRENT_PROJECT_VERSION) 22 | NSPrincipalClass 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /CurrencyConverter.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXAggregateTarget section */ 10 | "CurrencyConverter::CurrencyConverterPackageTests::ProductTarget" /* CurrencyConverterPackageTests */ = { 11 | isa = PBXAggregateTarget; 12 | buildConfigurationList = OBJ_45 /* Build configuration list for PBXAggregateTarget "CurrencyConverterPackageTests" */; 13 | buildPhases = ( 14 | ); 15 | dependencies = ( 16 | OBJ_48 /* PBXTargetDependency */, 17 | ); 18 | name = CurrencyConverterPackageTests; 19 | productName = CurrencyConverterPackageTests; 20 | }; 21 | /* End PBXAggregateTarget section */ 22 | 23 | /* Begin PBXBuildFile section */ 24 | OBJ_31 /* BidirectionalCurrencyConverter.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_9 /* BidirectionalCurrencyConverter.swift */; }; 25 | OBJ_32 /* CurrencyPair.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_10 /* CurrencyPair.swift */; }; 26 | OBJ_33 /* UnidirectionalCurrencyConverter.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_11 /* UnidirectionalCurrencyConverter.swift */; }; 27 | OBJ_35 /* Money.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = "Money::Money::Product" /* Money.framework */; }; 28 | OBJ_43 /* Package.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_6 /* Package.swift */; }; 29 | OBJ_54 /* CurrenyPairTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_14 /* CurrenyPairTests.swift */; }; 30 | OBJ_55 /* XCTestManifests.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_15 /* XCTestManifests.swift */; }; 31 | OBJ_57 /* CurrencyConverter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = "CurrencyConverter::CurrencyConverter::Product" /* CurrencyConverter.framework */; }; 32 | OBJ_58 /* Money.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = "Money::Money::Product" /* Money.framework */; }; 33 | OBJ_65 /* Currency.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_19 /* Currency.swift */; }; 34 | OBJ_66 /* Money.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_20 /* Money.swift */; }; 35 | OBJ_73 /* Package.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_21 /* Package.swift */; }; 36 | /* End PBXBuildFile section */ 37 | 38 | /* Begin PBXContainerItemProxy section */ 39 | F86A62AF20E6CE3A00E69276 /* PBXContainerItemProxy */ = { 40 | isa = PBXContainerItemProxy; 41 | containerPortal = OBJ_1 /* Project object */; 42 | proxyType = 1; 43 | remoteGlobalIDString = "Money::Money"; 44 | remoteInfo = Money; 45 | }; 46 | F86A62B020E6CE3A00E69276 /* PBXContainerItemProxy */ = { 47 | isa = PBXContainerItemProxy; 48 | containerPortal = OBJ_1 /* Project object */; 49 | proxyType = 1; 50 | remoteGlobalIDString = "CurrencyConverter::CurrencyConverter"; 51 | remoteInfo = CurrencyConverter; 52 | }; 53 | F86A62B120E6CE3A00E69276 /* PBXContainerItemProxy */ = { 54 | isa = PBXContainerItemProxy; 55 | containerPortal = OBJ_1 /* Project object */; 56 | proxyType = 1; 57 | remoteGlobalIDString = "Money::Money"; 58 | remoteInfo = Money; 59 | }; 60 | F86A62B220E6CE3A00E69276 /* PBXContainerItemProxy */ = { 61 | isa = PBXContainerItemProxy; 62 | containerPortal = OBJ_1 /* Project object */; 63 | proxyType = 1; 64 | remoteGlobalIDString = "CurrencyConverter::CurrencyConverterTests"; 65 | remoteInfo = CurrencyConverterTests; 66 | }; 67 | /* End PBXContainerItemProxy section */ 68 | 69 | /* Begin PBXFileReference section */ 70 | "CurrencyConverter::CurrencyConverter::Product" /* CurrencyConverter.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = CurrencyConverter.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 71 | "CurrencyConverter::CurrencyConverterTests::Product" /* CurrencyConverterTests.xctest */ = {isa = PBXFileReference; lastKnownFileType = file; path = CurrencyConverterTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 72 | "Money::Money::Product" /* Money.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Money.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 73 | OBJ_10 /* CurrencyPair.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurrencyPair.swift; sourceTree = ""; }; 74 | OBJ_11 /* UnidirectionalCurrencyConverter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UnidirectionalCurrencyConverter.swift; sourceTree = ""; }; 75 | OBJ_14 /* CurrenyPairTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurrenyPairTests.swift; sourceTree = ""; }; 76 | OBJ_15 /* XCTestManifests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = XCTestManifests.swift; sourceTree = ""; }; 77 | OBJ_19 /* Currency.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Currency.swift; sourceTree = ""; }; 78 | OBJ_20 /* Money.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Money.swift; sourceTree = ""; }; 79 | OBJ_21 /* Package.swift */ = {isa = PBXFileReference; explicitFileType = sourcecode.swift; name = Package.swift; path = "/Users/mattt/Code/FlightSchool/CurrencyConverter/.build/checkouts/Money.git--6764331332525957513/Package.swift"; sourceTree = ""; }; 80 | OBJ_6 /* Package.swift */ = {isa = PBXFileReference; explicitFileType = sourcecode.swift; path = Package.swift; sourceTree = ""; }; 81 | OBJ_9 /* BidirectionalCurrencyConverter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BidirectionalCurrencyConverter.swift; sourceTree = ""; }; 82 | /* End PBXFileReference section */ 83 | 84 | /* Begin PBXFrameworksBuildPhase section */ 85 | OBJ_34 /* Frameworks */ = { 86 | isa = PBXFrameworksBuildPhase; 87 | buildActionMask = 0; 88 | files = ( 89 | OBJ_35 /* Money.framework in Frameworks */, 90 | ); 91 | runOnlyForDeploymentPostprocessing = 0; 92 | }; 93 | OBJ_56 /* Frameworks */ = { 94 | isa = PBXFrameworksBuildPhase; 95 | buildActionMask = 0; 96 | files = ( 97 | OBJ_57 /* CurrencyConverter.framework in Frameworks */, 98 | OBJ_58 /* Money.framework in Frameworks */, 99 | ); 100 | runOnlyForDeploymentPostprocessing = 0; 101 | }; 102 | OBJ_67 /* Frameworks */ = { 103 | isa = PBXFrameworksBuildPhase; 104 | buildActionMask = 0; 105 | files = ( 106 | ); 107 | runOnlyForDeploymentPostprocessing = 0; 108 | }; 109 | /* End PBXFrameworksBuildPhase section */ 110 | 111 | /* Begin PBXGroup section */ 112 | OBJ_12 /* Tests */ = { 113 | isa = PBXGroup; 114 | children = ( 115 | OBJ_13 /* CurrencyConverterTests */, 116 | ); 117 | name = Tests; 118 | sourceTree = SOURCE_ROOT; 119 | }; 120 | OBJ_13 /* CurrencyConverterTests */ = { 121 | isa = PBXGroup; 122 | children = ( 123 | OBJ_14 /* CurrenyPairTests.swift */, 124 | OBJ_15 /* XCTestManifests.swift */, 125 | ); 126 | name = CurrencyConverterTests; 127 | path = Tests/CurrencyConverterTests; 128 | sourceTree = SOURCE_ROOT; 129 | }; 130 | OBJ_16 /* Dependencies */ = { 131 | isa = PBXGroup; 132 | children = ( 133 | OBJ_17 /* Money 1.0.0 */, 134 | ); 135 | name = Dependencies; 136 | sourceTree = ""; 137 | }; 138 | OBJ_17 /* Money 1.0.0 */ = { 139 | isa = PBXGroup; 140 | children = ( 141 | OBJ_18 /* Money */, 142 | OBJ_21 /* Package.swift */, 143 | ); 144 | name = "Money 1.0.0"; 145 | sourceTree = SOURCE_ROOT; 146 | }; 147 | OBJ_18 /* Money */ = { 148 | isa = PBXGroup; 149 | children = ( 150 | OBJ_19 /* Currency.swift */, 151 | OBJ_20 /* Money.swift */, 152 | ); 153 | name = Money; 154 | path = ".build/checkouts/Money.git--6764331332525957513/Sources/Money"; 155 | sourceTree = SOURCE_ROOT; 156 | }; 157 | OBJ_22 /* Products */ = { 158 | isa = PBXGroup; 159 | children = ( 160 | "CurrencyConverter::CurrencyConverterTests::Product" /* CurrencyConverterTests.xctest */, 161 | "CurrencyConverter::CurrencyConverter::Product" /* CurrencyConverter.framework */, 162 | "Money::Money::Product" /* Money.framework */, 163 | ); 164 | name = Products; 165 | sourceTree = BUILT_PRODUCTS_DIR; 166 | }; 167 | OBJ_5 = { 168 | isa = PBXGroup; 169 | children = ( 170 | OBJ_6 /* Package.swift */, 171 | OBJ_7 /* Sources */, 172 | OBJ_12 /* Tests */, 173 | OBJ_16 /* Dependencies */, 174 | OBJ_22 /* Products */, 175 | ); 176 | sourceTree = ""; 177 | }; 178 | OBJ_7 /* Sources */ = { 179 | isa = PBXGroup; 180 | children = ( 181 | OBJ_8 /* CurrencyConverter */, 182 | ); 183 | name = Sources; 184 | sourceTree = SOURCE_ROOT; 185 | }; 186 | OBJ_8 /* CurrencyConverter */ = { 187 | isa = PBXGroup; 188 | children = ( 189 | OBJ_11 /* UnidirectionalCurrencyConverter.swift */, 190 | OBJ_9 /* BidirectionalCurrencyConverter.swift */, 191 | OBJ_10 /* CurrencyPair.swift */, 192 | ); 193 | name = CurrencyConverter; 194 | path = Sources/CurrencyConverter; 195 | sourceTree = SOURCE_ROOT; 196 | }; 197 | /* End PBXGroup section */ 198 | 199 | /* Begin PBXNativeTarget section */ 200 | "CurrencyConverter::CurrencyConverter" /* CurrencyConverter */ = { 201 | isa = PBXNativeTarget; 202 | buildConfigurationList = OBJ_27 /* Build configuration list for PBXNativeTarget "CurrencyConverter" */; 203 | buildPhases = ( 204 | OBJ_30 /* Sources */, 205 | OBJ_34 /* Frameworks */, 206 | ); 207 | buildRules = ( 208 | ); 209 | dependencies = ( 210 | OBJ_36 /* PBXTargetDependency */, 211 | ); 212 | name = CurrencyConverter; 213 | productName = CurrencyConverter; 214 | productReference = "CurrencyConverter::CurrencyConverter::Product" /* CurrencyConverter.framework */; 215 | productType = "com.apple.product-type.framework"; 216 | }; 217 | "CurrencyConverter::CurrencyConverterTests" /* CurrencyConverterTests */ = { 218 | isa = PBXNativeTarget; 219 | buildConfigurationList = OBJ_50 /* Build configuration list for PBXNativeTarget "CurrencyConverterTests" */; 220 | buildPhases = ( 221 | OBJ_53 /* Sources */, 222 | OBJ_56 /* Frameworks */, 223 | ); 224 | buildRules = ( 225 | ); 226 | dependencies = ( 227 | OBJ_59 /* PBXTargetDependency */, 228 | OBJ_60 /* PBXTargetDependency */, 229 | ); 230 | name = CurrencyConverterTests; 231 | productName = CurrencyConverterTests; 232 | productReference = "CurrencyConverter::CurrencyConverterTests::Product" /* CurrencyConverterTests.xctest */; 233 | productType = "com.apple.product-type.bundle.unit-test"; 234 | }; 235 | "CurrencyConverter::SwiftPMPackageDescription" /* CurrencyConverterPackageDescription */ = { 236 | isa = PBXNativeTarget; 237 | buildConfigurationList = OBJ_39 /* Build configuration list for PBXNativeTarget "CurrencyConverterPackageDescription" */; 238 | buildPhases = ( 239 | OBJ_42 /* Sources */, 240 | ); 241 | buildRules = ( 242 | ); 243 | dependencies = ( 244 | ); 245 | name = CurrencyConverterPackageDescription; 246 | productName = CurrencyConverterPackageDescription; 247 | productType = "com.apple.product-type.framework"; 248 | }; 249 | "Money::Money" /* Money */ = { 250 | isa = PBXNativeTarget; 251 | buildConfigurationList = OBJ_61 /* Build configuration list for PBXNativeTarget "Money" */; 252 | buildPhases = ( 253 | OBJ_64 /* Sources */, 254 | OBJ_67 /* Frameworks */, 255 | ); 256 | buildRules = ( 257 | ); 258 | dependencies = ( 259 | ); 260 | name = Money; 261 | productName = Money; 262 | productReference = "Money::Money::Product" /* Money.framework */; 263 | productType = "com.apple.product-type.framework"; 264 | }; 265 | "Money::SwiftPMPackageDescription" /* MoneyPackageDescription */ = { 266 | isa = PBXNativeTarget; 267 | buildConfigurationList = OBJ_69 /* Build configuration list for PBXNativeTarget "MoneyPackageDescription" */; 268 | buildPhases = ( 269 | OBJ_72 /* Sources */, 270 | ); 271 | buildRules = ( 272 | ); 273 | dependencies = ( 274 | ); 275 | name = MoneyPackageDescription; 276 | productName = MoneyPackageDescription; 277 | productType = "com.apple.product-type.framework"; 278 | }; 279 | /* End PBXNativeTarget section */ 280 | 281 | /* Begin PBXProject section */ 282 | OBJ_1 /* Project object */ = { 283 | isa = PBXProject; 284 | attributes = { 285 | LastUpgradeCheck = 9999; 286 | }; 287 | buildConfigurationList = OBJ_2 /* Build configuration list for PBXProject "CurrencyConverter" */; 288 | compatibilityVersion = "Xcode 3.2"; 289 | developmentRegion = English; 290 | hasScannedForEncodings = 0; 291 | knownRegions = ( 292 | en, 293 | ); 294 | mainGroup = OBJ_5; 295 | productRefGroup = OBJ_22 /* Products */; 296 | projectDirPath = ""; 297 | projectRoot = ""; 298 | targets = ( 299 | "CurrencyConverter::CurrencyConverter" /* CurrencyConverter */, 300 | "CurrencyConverter::SwiftPMPackageDescription" /* CurrencyConverterPackageDescription */, 301 | "CurrencyConverter::CurrencyConverterPackageTests::ProductTarget" /* CurrencyConverterPackageTests */, 302 | "CurrencyConverter::CurrencyConverterTests" /* CurrencyConverterTests */, 303 | "Money::Money" /* Money */, 304 | "Money::SwiftPMPackageDescription" /* MoneyPackageDescription */, 305 | ); 306 | }; 307 | /* End PBXProject section */ 308 | 309 | /* Begin PBXSourcesBuildPhase section */ 310 | OBJ_30 /* Sources */ = { 311 | isa = PBXSourcesBuildPhase; 312 | buildActionMask = 0; 313 | files = ( 314 | OBJ_31 /* BidirectionalCurrencyConverter.swift in Sources */, 315 | OBJ_32 /* CurrencyPair.swift in Sources */, 316 | OBJ_33 /* UnidirectionalCurrencyConverter.swift in Sources */, 317 | ); 318 | runOnlyForDeploymentPostprocessing = 0; 319 | }; 320 | OBJ_42 /* Sources */ = { 321 | isa = PBXSourcesBuildPhase; 322 | buildActionMask = 0; 323 | files = ( 324 | OBJ_43 /* Package.swift in Sources */, 325 | ); 326 | runOnlyForDeploymentPostprocessing = 0; 327 | }; 328 | OBJ_53 /* Sources */ = { 329 | isa = PBXSourcesBuildPhase; 330 | buildActionMask = 0; 331 | files = ( 332 | OBJ_54 /* CurrenyPairTests.swift in Sources */, 333 | OBJ_55 /* XCTestManifests.swift in Sources */, 334 | ); 335 | runOnlyForDeploymentPostprocessing = 0; 336 | }; 337 | OBJ_64 /* Sources */ = { 338 | isa = PBXSourcesBuildPhase; 339 | buildActionMask = 0; 340 | files = ( 341 | OBJ_65 /* Currency.swift in Sources */, 342 | OBJ_66 /* Money.swift in Sources */, 343 | ); 344 | runOnlyForDeploymentPostprocessing = 0; 345 | }; 346 | OBJ_72 /* Sources */ = { 347 | isa = PBXSourcesBuildPhase; 348 | buildActionMask = 0; 349 | files = ( 350 | OBJ_73 /* Package.swift in Sources */, 351 | ); 352 | runOnlyForDeploymentPostprocessing = 0; 353 | }; 354 | /* End PBXSourcesBuildPhase section */ 355 | 356 | /* Begin PBXTargetDependency section */ 357 | OBJ_36 /* PBXTargetDependency */ = { 358 | isa = PBXTargetDependency; 359 | target = "Money::Money" /* Money */; 360 | targetProxy = F86A62AF20E6CE3A00E69276 /* PBXContainerItemProxy */; 361 | }; 362 | OBJ_48 /* PBXTargetDependency */ = { 363 | isa = PBXTargetDependency; 364 | target = "CurrencyConverter::CurrencyConverterTests" /* CurrencyConverterTests */; 365 | targetProxy = F86A62B220E6CE3A00E69276 /* PBXContainerItemProxy */; 366 | }; 367 | OBJ_59 /* PBXTargetDependency */ = { 368 | isa = PBXTargetDependency; 369 | target = "CurrencyConverter::CurrencyConverter" /* CurrencyConverter */; 370 | targetProxy = F86A62B020E6CE3A00E69276 /* PBXContainerItemProxy */; 371 | }; 372 | OBJ_60 /* PBXTargetDependency */ = { 373 | isa = PBXTargetDependency; 374 | target = "Money::Money" /* Money */; 375 | targetProxy = F86A62B120E6CE3A00E69276 /* PBXContainerItemProxy */; 376 | }; 377 | /* End PBXTargetDependency section */ 378 | 379 | /* Begin XCBuildConfiguration section */ 380 | OBJ_28 /* Debug */ = { 381 | isa = XCBuildConfiguration; 382 | buildSettings = { 383 | ENABLE_TESTABILITY = YES; 384 | FRAMEWORK_SEARCH_PATHS = ( 385 | "$(inherited)", 386 | "$(PLATFORM_DIR)/Developer/Library/Frameworks", 387 | ); 388 | HEADER_SEARCH_PATHS = "$(inherited)"; 389 | INFOPLIST_FILE = CurrencyConverter.xcodeproj/CurrencyConverter_Info.plist; 390 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 391 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) $(TOOLCHAIN_DIR)/usr/lib/swift/macosx"; 392 | OTHER_CFLAGS = "$(inherited)"; 393 | OTHER_LDFLAGS = "$(inherited)"; 394 | OTHER_SWIFT_FLAGS = "$(inherited)"; 395 | PRODUCT_BUNDLE_IDENTIFIER = CurrencyConverter; 396 | PRODUCT_MODULE_NAME = "$(TARGET_NAME:c99extidentifier)"; 397 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; 398 | SKIP_INSTALL = YES; 399 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited)"; 400 | SWIFT_VERSION = 4.2.0; 401 | TARGET_NAME = CurrencyConverter; 402 | TVOS_DEPLOYMENT_TARGET = 9.0; 403 | }; 404 | name = Debug; 405 | }; 406 | OBJ_29 /* Release */ = { 407 | isa = XCBuildConfiguration; 408 | buildSettings = { 409 | ENABLE_TESTABILITY = YES; 410 | FRAMEWORK_SEARCH_PATHS = ( 411 | "$(inherited)", 412 | "$(PLATFORM_DIR)/Developer/Library/Frameworks", 413 | ); 414 | HEADER_SEARCH_PATHS = "$(inherited)"; 415 | INFOPLIST_FILE = CurrencyConverter.xcodeproj/CurrencyConverter_Info.plist; 416 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 417 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) $(TOOLCHAIN_DIR)/usr/lib/swift/macosx"; 418 | OTHER_CFLAGS = "$(inherited)"; 419 | OTHER_LDFLAGS = "$(inherited)"; 420 | OTHER_SWIFT_FLAGS = "$(inherited)"; 421 | PRODUCT_BUNDLE_IDENTIFIER = CurrencyConverter; 422 | PRODUCT_MODULE_NAME = "$(TARGET_NAME:c99extidentifier)"; 423 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; 424 | SKIP_INSTALL = YES; 425 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited)"; 426 | SWIFT_VERSION = 4.2.0; 427 | TARGET_NAME = CurrencyConverter; 428 | TVOS_DEPLOYMENT_TARGET = 9.0; 429 | }; 430 | name = Release; 431 | }; 432 | OBJ_3 /* Debug */ = { 433 | isa = XCBuildConfiguration; 434 | buildSettings = { 435 | CLANG_ENABLE_OBJC_ARC = YES; 436 | COMBINE_HIDPI_IMAGES = YES; 437 | COPY_PHASE_STRIP = NO; 438 | DEBUG_INFORMATION_FORMAT = dwarf; 439 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 440 | ENABLE_NS_ASSERTIONS = YES; 441 | GCC_OPTIMIZATION_LEVEL = 0; 442 | GCC_PREPROCESSOR_DEFINITIONS = ( 443 | "DEBUG=1", 444 | "$(inherited)", 445 | ); 446 | MACOSX_DEPLOYMENT_TARGET = 10.10; 447 | ONLY_ACTIVE_ARCH = YES; 448 | OTHER_SWIFT_FLAGS = "-DXcode"; 449 | PRODUCT_NAME = "$(TARGET_NAME)"; 450 | SDKROOT = macosx; 451 | SUPPORTED_PLATFORMS = "macosx iphoneos iphonesimulator appletvos appletvsimulator watchos watchsimulator"; 452 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 453 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 454 | USE_HEADERMAP = NO; 455 | }; 456 | name = Debug; 457 | }; 458 | OBJ_4 /* Release */ = { 459 | isa = XCBuildConfiguration; 460 | buildSettings = { 461 | CLANG_ENABLE_OBJC_ARC = YES; 462 | COMBINE_HIDPI_IMAGES = YES; 463 | COPY_PHASE_STRIP = YES; 464 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 465 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 466 | GCC_OPTIMIZATION_LEVEL = s; 467 | MACOSX_DEPLOYMENT_TARGET = 10.10; 468 | OTHER_SWIFT_FLAGS = "-DXcode"; 469 | PRODUCT_NAME = "$(TARGET_NAME)"; 470 | SDKROOT = macosx; 471 | SUPPORTED_PLATFORMS = "macosx iphoneos iphonesimulator appletvos appletvsimulator watchos watchsimulator"; 472 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = SWIFT_PACKAGE; 473 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 474 | USE_HEADERMAP = NO; 475 | }; 476 | name = Release; 477 | }; 478 | OBJ_40 /* Debug */ = { 479 | isa = XCBuildConfiguration; 480 | buildSettings = { 481 | LD = /usr/bin/true; 482 | OTHER_SWIFT_FLAGS = "-swift-version 4.2 -I $(TOOLCHAIN_DIR)/usr/lib/swift/pm/4_2 -target x86_64-apple-macosx10.10 -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk"; 483 | SWIFT_VERSION = 4_2.0; 484 | }; 485 | name = Debug; 486 | }; 487 | OBJ_41 /* Release */ = { 488 | isa = XCBuildConfiguration; 489 | buildSettings = { 490 | LD = /usr/bin/true; 491 | OTHER_SWIFT_FLAGS = "-swift-version 4.2 -I $(TOOLCHAIN_DIR)/usr/lib/swift/pm/4_2 -target x86_64-apple-macosx10.10 -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk"; 492 | SWIFT_VERSION = 4_2.0; 493 | }; 494 | name = Release; 495 | }; 496 | OBJ_46 /* Debug */ = { 497 | isa = XCBuildConfiguration; 498 | buildSettings = { 499 | }; 500 | name = Debug; 501 | }; 502 | OBJ_47 /* Release */ = { 503 | isa = XCBuildConfiguration; 504 | buildSettings = { 505 | }; 506 | name = Release; 507 | }; 508 | OBJ_51 /* Debug */ = { 509 | isa = XCBuildConfiguration; 510 | buildSettings = { 511 | EMBEDDED_CONTENT_CONTAINS_SWIFT = YES; 512 | FRAMEWORK_SEARCH_PATHS = ( 513 | "$(inherited)", 514 | "$(PLATFORM_DIR)/Developer/Library/Frameworks", 515 | ); 516 | HEADER_SEARCH_PATHS = "$(inherited)"; 517 | INFOPLIST_FILE = CurrencyConverter.xcodeproj/CurrencyConverterTests_Info.plist; 518 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @loader_path/../Frameworks @loader_path/Frameworks"; 519 | OTHER_CFLAGS = "$(inherited)"; 520 | OTHER_LDFLAGS = "$(inherited)"; 521 | OTHER_SWIFT_FLAGS = "$(inherited)"; 522 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited)"; 523 | SWIFT_VERSION = 4.2.0; 524 | TARGET_NAME = CurrencyConverterTests; 525 | }; 526 | name = Debug; 527 | }; 528 | OBJ_52 /* Release */ = { 529 | isa = XCBuildConfiguration; 530 | buildSettings = { 531 | EMBEDDED_CONTENT_CONTAINS_SWIFT = YES; 532 | FRAMEWORK_SEARCH_PATHS = ( 533 | "$(inherited)", 534 | "$(PLATFORM_DIR)/Developer/Library/Frameworks", 535 | ); 536 | HEADER_SEARCH_PATHS = "$(inherited)"; 537 | INFOPLIST_FILE = CurrencyConverter.xcodeproj/CurrencyConverterTests_Info.plist; 538 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @loader_path/../Frameworks @loader_path/Frameworks"; 539 | OTHER_CFLAGS = "$(inherited)"; 540 | OTHER_LDFLAGS = "$(inherited)"; 541 | OTHER_SWIFT_FLAGS = "$(inherited)"; 542 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited)"; 543 | SWIFT_VERSION = 4.2.0; 544 | TARGET_NAME = CurrencyConverterTests; 545 | }; 546 | name = Release; 547 | }; 548 | OBJ_62 /* Debug */ = { 549 | isa = XCBuildConfiguration; 550 | buildSettings = { 551 | ENABLE_TESTABILITY = YES; 552 | FRAMEWORK_SEARCH_PATHS = ( 553 | "$(inherited)", 554 | "$(PLATFORM_DIR)/Developer/Library/Frameworks", 555 | ); 556 | HEADER_SEARCH_PATHS = "$(inherited)"; 557 | INFOPLIST_FILE = CurrencyConverter.xcodeproj/Money_Info.plist; 558 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) $(TOOLCHAIN_DIR)/usr/lib/swift/macosx"; 559 | OTHER_CFLAGS = "$(inherited)"; 560 | OTHER_LDFLAGS = "$(inherited)"; 561 | OTHER_SWIFT_FLAGS = "$(inherited)"; 562 | PRODUCT_BUNDLE_IDENTIFIER = Money; 563 | PRODUCT_MODULE_NAME = "$(TARGET_NAME:c99extidentifier)"; 564 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; 565 | SKIP_INSTALL = YES; 566 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited)"; 567 | SWIFT_VERSION = 4.0; 568 | TARGET_NAME = Money; 569 | }; 570 | name = Debug; 571 | }; 572 | OBJ_63 /* Release */ = { 573 | isa = XCBuildConfiguration; 574 | buildSettings = { 575 | ENABLE_TESTABILITY = YES; 576 | FRAMEWORK_SEARCH_PATHS = ( 577 | "$(inherited)", 578 | "$(PLATFORM_DIR)/Developer/Library/Frameworks", 579 | ); 580 | HEADER_SEARCH_PATHS = "$(inherited)"; 581 | INFOPLIST_FILE = CurrencyConverter.xcodeproj/Money_Info.plist; 582 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) $(TOOLCHAIN_DIR)/usr/lib/swift/macosx"; 583 | OTHER_CFLAGS = "$(inherited)"; 584 | OTHER_LDFLAGS = "$(inherited)"; 585 | OTHER_SWIFT_FLAGS = "$(inherited)"; 586 | PRODUCT_BUNDLE_IDENTIFIER = Money; 587 | PRODUCT_MODULE_NAME = "$(TARGET_NAME:c99extidentifier)"; 588 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; 589 | SKIP_INSTALL = YES; 590 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited)"; 591 | SWIFT_VERSION = 4.0; 592 | TARGET_NAME = Money; 593 | }; 594 | name = Release; 595 | }; 596 | OBJ_70 /* Debug */ = { 597 | isa = XCBuildConfiguration; 598 | buildSettings = { 599 | LD = /usr/bin/true; 600 | OTHER_SWIFT_FLAGS = "-swift-version 4 -I $(TOOLCHAIN_DIR)/usr/lib/swift/pm/4 -target x86_64-apple-macosx10.10 -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk"; 601 | SWIFT_VERSION = 4.0; 602 | }; 603 | name = Debug; 604 | }; 605 | OBJ_71 /* Release */ = { 606 | isa = XCBuildConfiguration; 607 | buildSettings = { 608 | LD = /usr/bin/true; 609 | OTHER_SWIFT_FLAGS = "-swift-version 4 -I $(TOOLCHAIN_DIR)/usr/lib/swift/pm/4 -target x86_64-apple-macosx10.10 -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk"; 610 | SWIFT_VERSION = 4.0; 611 | }; 612 | name = Release; 613 | }; 614 | /* End XCBuildConfiguration section */ 615 | 616 | /* Begin XCConfigurationList section */ 617 | OBJ_2 /* Build configuration list for PBXProject "CurrencyConverter" */ = { 618 | isa = XCConfigurationList; 619 | buildConfigurations = ( 620 | OBJ_3 /* Debug */, 621 | OBJ_4 /* Release */, 622 | ); 623 | defaultConfigurationIsVisible = 0; 624 | defaultConfigurationName = Release; 625 | }; 626 | OBJ_27 /* Build configuration list for PBXNativeTarget "CurrencyConverter" */ = { 627 | isa = XCConfigurationList; 628 | buildConfigurations = ( 629 | OBJ_28 /* Debug */, 630 | OBJ_29 /* Release */, 631 | ); 632 | defaultConfigurationIsVisible = 0; 633 | defaultConfigurationName = Release; 634 | }; 635 | OBJ_39 /* Build configuration list for PBXNativeTarget "CurrencyConverterPackageDescription" */ = { 636 | isa = XCConfigurationList; 637 | buildConfigurations = ( 638 | OBJ_40 /* Debug */, 639 | OBJ_41 /* Release */, 640 | ); 641 | defaultConfigurationIsVisible = 0; 642 | defaultConfigurationName = Release; 643 | }; 644 | OBJ_45 /* Build configuration list for PBXAggregateTarget "CurrencyConverterPackageTests" */ = { 645 | isa = XCConfigurationList; 646 | buildConfigurations = ( 647 | OBJ_46 /* Debug */, 648 | OBJ_47 /* Release */, 649 | ); 650 | defaultConfigurationIsVisible = 0; 651 | defaultConfigurationName = Release; 652 | }; 653 | OBJ_50 /* Build configuration list for PBXNativeTarget "CurrencyConverterTests" */ = { 654 | isa = XCConfigurationList; 655 | buildConfigurations = ( 656 | OBJ_51 /* Debug */, 657 | OBJ_52 /* Release */, 658 | ); 659 | defaultConfigurationIsVisible = 0; 660 | defaultConfigurationName = Release; 661 | }; 662 | OBJ_61 /* Build configuration list for PBXNativeTarget "Money" */ = { 663 | isa = XCConfigurationList; 664 | buildConfigurations = ( 665 | OBJ_62 /* Debug */, 666 | OBJ_63 /* Release */, 667 | ); 668 | defaultConfigurationIsVisible = 0; 669 | defaultConfigurationName = Release; 670 | }; 671 | OBJ_69 /* Build configuration list for PBXNativeTarget "MoneyPackageDescription" */ = { 672 | isa = XCConfigurationList; 673 | buildConfigurations = ( 674 | OBJ_70 /* Debug */, 675 | OBJ_71 /* Release */, 676 | ); 677 | defaultConfigurationIsVisible = 0; 678 | defaultConfigurationName = Release; 679 | }; 680 | /* End XCConfigurationList section */ 681 | }; 682 | rootObject = OBJ_1 /* Project object */; 683 | } 684 | -------------------------------------------------------------------------------- /CurrencyConverter.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /CurrencyConverter.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /CurrencyConverter.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /CurrencyConverter.xcodeproj/xcshareddata/xcschemes/CurrencyConverter.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 47 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 69 | 70 | 76 | 77 | 78 | 79 | 80 | 81 | 87 | 88 | 90 | 91 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /CurrencyConverter.xcodeproj/xcshareddata/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | SchemeUserState 5 | 6 | CurrencyConverter-Package.xcscheme 7 | 8 | 9 | SuppressBuildableAutocreation 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /CurrencyConverter.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /CurrencyConverter.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright 2018 Read Evaluate Press, LLC 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a 4 | copy of this software and associated documentation files (the "Software"), 5 | to deal in the Software without restriction, including without limitation 6 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | and/or sell copies of the Software, and to permit persons to whom the 8 | Software is furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | DEALINGS IN THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /Package.resolved: -------------------------------------------------------------------------------- 1 | { 2 | "object": { 3 | "pins": [ 4 | { 5 | "package": "Money", 6 | "repositoryURL": "https://github.com/Flight-School/Money.git", 7 | "state": { 8 | "branch": null, 9 | "revision": "ed42a0a42039541ff09245d8f280d68e5adfe531", 10 | "version": "1.0.1" 11 | } 12 | } 13 | ] 14 | }, 15 | "version": 1 16 | } 17 | -------------------------------------------------------------------------------- /Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:4.1 2 | // The swift-tools-version declares the minimum version of Swift required to build this package. 3 | 4 | import PackageDescription 5 | 6 | let package = Package( 7 | name: "CurrencyConverter", 8 | products: [ 9 | // Products define the executables and libraries produced by a package, and make them visible to other packages. 10 | .library( 11 | name: "CurrencyConverter", 12 | targets: ["CurrencyConverter"]), 13 | ], 14 | dependencies: [ 15 | // Dependencies declare other packages that this package depends on. 16 | .package(url: "https://github.com/Flight-School/Money.git", from: "1.0.0"), 17 | ], 18 | targets: [ 19 | // Targets are the basic building blocks of a package. A target can define a module or a test suite. 20 | // Targets can depend on other targets in this package, and on products in packages which this package depends on. 21 | .target( 22 | name: "CurrencyConverter", 23 | dependencies: ["Money"]), 24 | .testTarget( 25 | name: "CurrencyConverterTests", 26 | dependencies: ["CurrencyConverter"]), 27 | ] 28 | ) 29 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CurrencyConverter 2 | 3 | [![Build Status][build status badge]][build status] 4 | 5 | Utilities for doing currency conversion with the 6 | [Money](https://github.com/flight-school/money) library. 7 | 8 | This functionality is discussed in Chapter 3 of 9 | [Flight School Guide to Swift Numbers](https://flight.school/books/numbers). 10 | 11 | ## Requirements 12 | 13 | - Swift 4.0+ 14 | 15 | ## Installation 16 | 17 | ### Swift Package Manager 18 | 19 | Add the CurrencyConverter package to your target dependencies in `Package.swift`: 20 | 21 | ```swift 22 | import PackageDescription 23 | 24 | let package = Package( 25 | name: "YourProject", 26 | dependencies: [ 27 | .package( 28 | url: "https://github.com/Flight-School/CurrencyConverter", 29 | from: "1.0.0" 30 | ), 31 | ] 32 | ) 33 | ``` 34 | 35 | Then run the `swift build` command to build your project. 36 | 37 | ### Carthage 38 | 39 | To use `CurrencyConverter` in your Xcode project using Carthage, 40 | specify it in `Cartfile`: 41 | 42 | ``` 43 | github "Flight-School/CurrencyConverter" ~> 1.0.0 44 | ``` 45 | 46 | Then run the `carthage update` command to build the framework, 47 | and drag the built CurrencyConverter.framework into your Xcode project. 48 | 49 | ## Usage 50 | 51 | A [currency pair](https://en.wikipedia.org/wiki/Currency_pair) 52 | describes the relative value of one currency in terms of another. 53 | You can create a `CurrencyPair` object with a specified exchange rate 54 | to convert from a monetary amount in one currency to the other: 55 | 56 | ```swift 57 | let EURtoUSD = CurrencyPair(rate: 1.17) // as of June 1st, 2018 58 | 59 | let euros: Money = 123.45 60 | let dollars = EURtoUSD.convert(euros).rounded // "$144.44" 61 | ``` 62 | 63 | > **Note**: This library doesn't include functionality 64 | > for querying the current exchange rates of currencies. 65 | > You can get this information from various third party web applications. 66 | 67 | To only allow conversion in one direction, 68 | create a type that conforms to the `UnidirectionalCurrencyConverter` protocol. 69 | If you want to offer different rates depending on the direction of conversion 70 | (that is, a rate going from variable to fixed 71 | that isn't the inverse of going the other way) 72 | create a type that conforms to the `BidirectionalCurrencyConverter` protocol. 73 | 74 | ## License 75 | 76 | MIT 77 | 78 | ## Contact 79 | 80 | Mattt ([@mattt](https://twitter.com/mattt)) 81 | 82 | [build status]: https://github.com/Flight-School/CurrencyConverter/actions?query=workflow%3ACI 83 | [build status badge]: https://github.com/Flight-School/CurrencyConverter/workflows/CI/badge.svg 84 | -------------------------------------------------------------------------------- /Sources/CurrencyConverter/BidirectionalCurrencyConverter.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | import Money 3 | 4 | public protocol BidirectionalCurrencyConverter: UnidirectionalCurrencyConverter {} 5 | 6 | extension BidirectionalCurrencyConverter { 7 | public func convert(_ value: Money) -> Money { 8 | return Money(value.amount / rate) 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Sources/CurrencyConverter/CurrencyPair.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | import Money 3 | 4 | public struct CurrencyPair: BidirectionalCurrencyConverter where Fixed: CurrencyType, Variable: CurrencyType { 5 | public var rate: Decimal 6 | 7 | public init(rate: Decimal) { 8 | precondition(rate > 0) 9 | self.rate = rate 10 | } 11 | } 12 | 13 | extension CurrencyPair: CustomStringConvertible { 14 | public var description: String { 15 | return "\(Fixed.code)/\(Variable.code) \(rate)" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Sources/CurrencyConverter/UnidirectionalCurrencyConverter.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | import Money 3 | 4 | public protocol UnidirectionalCurrencyConverter { 5 | associatedtype Fixed: CurrencyType 6 | associatedtype Variable: CurrencyType 7 | 8 | var rate: Decimal { get set } 9 | } 10 | 11 | extension UnidirectionalCurrencyConverter { 12 | public func convert(_ value: Money) -> Money { 13 | return Money(value.amount * rate) 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Tests/CurrencyConverterTests/CurrenyPairTests.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | @testable import CurrencyConverter 3 | import Money 4 | 5 | final class CurrencyPairTests: XCTestCase { 6 | let EURtoUSD = CurrencyPair(rate: 1.17) // as of June 1st, 2018 7 | 8 | func testConvertTo() { 9 | let euros: Money = 123.45 10 | let dollars = EURtoUSD.convert(euros).rounded 11 | 12 | XCTAssertEqual(dollars.amount, Decimal(string: "144.44")) 13 | } 14 | 15 | func testConvertFrom() { 16 | let dollars: Money = 123.45 17 | let euros = EURtoUSD.convert(dollars).rounded 18 | 19 | XCTAssertEqual(euros.amount, Decimal(string: "105.51")) 20 | } 21 | } 22 | --------------------------------------------------------------------------------