├── .github ├── CONTRIBUTING.md └── PULL_REQUEST_TEMPLATE.md ├── .gitignore ├── .jazzy.yaml ├── .swift-version ├── .travis.yml ├── Cartfile ├── LICENSE ├── Package.swift ├── README.md ├── Sources └── Configuration │ ├── ConfigurationManager.swift │ ├── ConfigurationNode.swift │ ├── Deserializer.swift │ └── Deserializers │ ├── JSONDeserializer.swift │ └── PLISTDeserializer.swift ├── Tests ├── ConfigurationTests │ ├── ConfigurationManagerTest.swift │ ├── ConfigurationNodeTest.swift │ ├── LinuxSafeguardTest.swift │ ├── test.json │ └── test.plist └── LinuxMain.swift ├── docker-compose.yml └── docs ├── Classes.html ├── Classes ├── ConfigurationManager.html ├── ConfigurationManager │ ├── BasePath.html │ └── Source.html ├── JSONDeserializer.html └── PLISTDeserializer.html ├── Protocols.html ├── Protocols └── Deserializer.html ├── badge.svg ├── css ├── highlight.css └── jazzy.css ├── docsets ├── Configuration.docset │ └── Contents │ │ ├── Info.plist │ │ └── Resources │ │ ├── Documents │ │ ├── Classes.html │ │ ├── Classes │ │ │ ├── ConfigurationManager.html │ │ │ ├── ConfigurationManager │ │ │ │ ├── BasePath.html │ │ │ │ └── Source.html │ │ │ ├── JSONDeserializer.html │ │ │ └── PLISTDeserializer.html │ │ ├── Protocols.html │ │ ├── Protocols │ │ │ └── Deserializer.html │ │ ├── css │ │ │ ├── highlight.css │ │ │ └── jazzy.css │ │ ├── img │ │ │ ├── carat.png │ │ │ ├── dash.png │ │ │ ├── gh.png │ │ │ └── spinner.gif │ │ ├── index.html │ │ ├── js │ │ │ ├── jazzy.js │ │ │ ├── jazzy.search.js │ │ │ ├── jquery.min.js │ │ │ ├── lunr.min.js │ │ │ └── typeahead.jquery.js │ │ └── search.json │ │ └── docSet.dsidx └── Configuration.tgz ├── img ├── carat.png ├── dash.png ├── gh.png └── spinner.gif ├── index.html ├── js ├── jazzy.js ├── jazzy.search.js ├── jquery.min.js ├── lunr.min.js └── typeahead.jquery.js ├── search.json └── undocumented.json /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to IBM-Swift 2 | 3 | We welcome contributions, and request you follow these guidelines. 4 | 5 | - [Raising issues](#raising-issues) 6 | - [Contributor License Agreement](#contributor-license-agreement) 7 | - [Coding Standards](#coding-standards) 8 | 9 | 10 | ## Raising issues 11 | 12 | Please raise any bug reports on the issue tracker. Be sure to 13 | search the list to see if your issue has already been raised. 14 | 15 | A good bug report is one that make it easy for us to understand what you were 16 | trying to do and what went wrong. Provide as much context as possible so we can try to recreate the issue. 17 | 18 | ### Contributor License Agreement 19 | 20 | In order for us to accept pull-requests, the contributor must first complete 21 | a Contributor License Agreement (CLA). Please see our [CLA repo](http://github.com/IBM-Swift/CLA) for more information. 22 | 23 | This clarifies the intellectual property license granted with any contribution. It is for your protection as a 24 | Contributor as well as the protection of IBM and its customers; it does not 25 | change your rights to use your own Contributions for any other purpose. 26 | 27 | ### Coding standards 28 | 29 | Please ensure you follow [the Kitura coding standards](https://github.com/IBM-Swift/Kitura/blob/master/Documentation/CodeConventions.md) 30 | 31 | Please note: 32 | 33 | - all files must have the Apache license in the header. 34 | - all PRs must have passing builds for all operating systems. 35 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Description 4 | 5 | 6 | ## Motivation and Context 7 | 8 | 9 | 10 | ## How Has This Been Tested? 11 | 12 | 13 | 14 | 15 | ## Checklist: 16 | 17 | 18 | - [ ] I have submitted a [CLA form](https://github.com/IBM-Swift/CLA) 19 | - [ ] If applicable, I have updated the documentation accordingly. 20 | - [ ] If applicable, I have added tests to cover my changes. 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | *.xcodeproj 5 | 6 | ## Build generated 7 | build/ 8 | DerivedData/ 9 | .DS_Store 10 | 11 | ## Various settings 12 | *.pbxuser 13 | !default.pbxuser 14 | *.mode1v3 15 | !default.mode1v3 16 | *.mode2v3 17 | !default.mode2v3 18 | *.perspectivev3 19 | !default.perspectivev3 20 | xcuserdata/ 21 | 22 | ## Other 23 | *.moved-aside 24 | *.xcuserstate 25 | 26 | ## Obj-C/Swift specific 27 | *.hmap 28 | *.ipa 29 | *.dSYM.zip 30 | *.dSYM 31 | 32 | ## Playgrounds 33 | timeline.xctimeline 34 | playground.xcworkspace 35 | 36 | # Swift Package Manager 37 | # 38 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 39 | # Packages/ 40 | .build/ 41 | .build-ubuntu/ 42 | Packages/ 43 | Package.resolved 44 | 45 | # CocoaPods 46 | # 47 | # We recommend against adding the Pods directory to your .gitignore. However 48 | # you should judge for yourself, the pros and cons are mentioned at: 49 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 50 | # 51 | # Pods/ 52 | 53 | # Carthage 54 | # 55 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 56 | # Carthage/Checkouts 57 | 58 | Carthage/Build 59 | 60 | # fastlane 61 | # 62 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 63 | # screenshots whenever they are needed. 64 | # For more information about the recommended setup visit: 65 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md 66 | 67 | fastlane/report.xml 68 | fastlane/Preview.html 69 | fastlane/screenshots 70 | fastlane/test_output 71 | -------------------------------------------------------------------------------- /.jazzy.yaml: -------------------------------------------------------------------------------- 1 | module: Configuration 2 | author: IBM and the Kitura project authors 3 | github_url: https://github.com/Kitura/Configuration/ 4 | 5 | theme: fullwidth 6 | clean: true 7 | exclude: [Packages] 8 | 9 | readme: README.md 10 | 11 | skip_undocumented: false 12 | hide_documentation_coverage: false 13 | 14 | xcodebuild_arguments: [-project, Configuration.xcodeproj, -target, Configuration, LIBRARY_SEARCH_PATHS=.build/debug] 15 | -------------------------------------------------------------------------------- /.swift-version: -------------------------------------------------------------------------------- 1 | 5.1 2 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # Travis CI build file. 2 | 3 | # whitelist (branches that should be built) 4 | branches: 5 | only: 6 | - master 7 | - /^issue.*$/ 8 | 9 | # the matrix of builds should cover each combination of Swift version 10 | # and platform that is supported. The version of Swift used is specified 11 | # by .swift-version, unless SWIFT_SNAPSHOT is specified. 12 | matrix: 13 | include: 14 | - os: linux 15 | dist: xenial 16 | sudo: required 17 | services: docker 18 | env: DOCKER_IMAGE=docker.kitura.net/kitura/swift-ci-ubuntu18.04:5.2.5 19 | - os: linux 20 | dist: xenial 21 | sudo: required 22 | services: docker 23 | env: DOCKER_IMAGE=docker.kitura.net/kitura/swift-ci-ubuntu20.04:5.5.2 24 | - os: osx 25 | osx_image: xcode12.2 26 | sudo: required 27 | - os: osx 28 | osx_image: xcode13.3 29 | sudo: required 30 | env: JAZZY_ELIGIBLE=true 31 | 32 | before_install: 33 | - git clone https://github.com/Kitura/Package-Builder.git 34 | 35 | script: 36 | - ./Package-Builder/build-package.sh -projectDir $TRAVIS_BUILD_DIR 37 | -------------------------------------------------------------------------------- /Cartfile: -------------------------------------------------------------------------------- 1 | github "IBM-Swift/LoggerAPI" ~> 1.0 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.2 2 | // The swift-tools-version declares the minimum version of Swift required to build this package. 3 | 4 | /* 5 | * Copyright IBM Corporation and the Kitura project authors 2017-2020 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | import PackageDescription 21 | 22 | let package = Package( 23 | name: "Configuration", 24 | products: [ 25 | // Products define the executables and libraries produced by a package, and make them visible to other packages. 26 | .library( 27 | name: "Configuration", 28 | targets: ["Configuration"] 29 | ) 30 | ], 31 | dependencies: [ 32 | // Dependencies declare other packages that this package depends on. 33 | .package(url: "https://github.com/Kitura/FileKit.git", .upToNextMajor(from: "1.0.0")) 34 | ], 35 | targets: [ 36 | // Targets are the basic building blocks of a package. A target can define a module or a test suite. 37 | // Targets can depend on other targets in this package, and on products in packages which this package depends on. 38 | .target( 39 | name: "Configuration", 40 | dependencies: ["FileKit"] 41 | ), 42 | .testTarget( 43 | name: "ConfigurationTests", 44 | dependencies: ["Configuration"] 45 | ) 46 | ] 47 | ) 48 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 | Kitura 4 | 5 |

6 | 7 | 8 |

9 | 10 | APIDoc 11 | 12 | 13 | Build Status - Master 14 | 15 | macOS 16 | Linux 17 | Apache 2 18 | 19 | Slack Status 20 | 21 |

22 | 23 | # Configuration 24 | 25 | `Configuration` is a Swift package for managing application configurations. Using `Configuration`, an application can easily load and merge configuration data from multiple sources and access them from one central configuration store. 26 | 27 | `Configuration` supports configuration keys as paths. That is, a key is a qualified path selector written in the `[parent][child]` syntax. This allows applications to retrieve configuration objects at any level of specificity. 28 | 29 | ## Version 30 | The latest release of `Configuration` (v3.x.x) runs on Swift 5.2 and newer, on both macOS and Ubuntu Linux. 31 | 32 | 33 | ## Usage 34 | 35 | ### Add dependencies 36 | 37 | Add `Configuration` to the dependencies within your application's `Package.swift` file. Substitute `"x.x.x"` with the latest `Configuration` [release](https://github.com/Kitura/Configuration/releases). 38 | 39 | ```swift 40 | .package(url: "https://github.com/Kitura/Configuration.git", from: "x.x.x") 41 | ``` 42 | Add `Configuration` to your target's dependencies: 43 | 44 | ```Swift 45 | .target(name: "example", dependencies: ["Configuration"]), 46 | ``` 47 | 48 | ### Initialize Configuration 49 | 50 | The core of the `Configuration` package is the `ConfigurationManager` class. To manage your application's configurations, first create an instance of the `ConfigurationManager` class. 51 | 52 | ```swift 53 | import Configuration 54 | 55 | let manager = ConfigurationManager() 56 | ``` 57 | 58 | Using the `ConfigurationManager` instance, you can then load and retrieve configurations: 59 | 60 | ```swift 61 | manager.load(file: "config.json").load(.environmentVariables) 62 | let value = manager["path:to:configuration:value"] 63 | ``` 64 | 65 | ## Loading Configuration Data 66 | 67 | `Configuration` has many methods to load configuration data. 68 | 69 | **NOTE:** In all cases, configuration key paths are case sensitive. 70 | 71 | ### From a Raw `Any` Object 72 | 73 | ```swift 74 | manager.load([ 75 | "hello": "world", 76 | "foo": [ 77 | "bar": "baz" 78 | ] 79 | ]) 80 | ``` 81 | 82 | ### From Command-line Arguments 83 | 84 | ```swift 85 | manager.load(.commandLineArguments) 86 | ``` 87 | 88 | To inject configurations via the command-line at runtime, set configuration values when launching the executable, like so: 89 | 90 | ``` 91 | ./myApp --path.to.configuration=value 92 | ``` 93 | 94 | You can set your preferred argument prefix (default: `--`) and path separator (default: `.`) strings when instantiating `ConfigurationManager`. 95 | 96 | ### From Environment Variables 97 | 98 | ```swift 99 | manager.load(.environmentVariables) 100 | ``` 101 | 102 | Then, to use it in your application, set environment variables like so: 103 | 104 | ``` 105 | PATH__TO__CONFIGURATION=value 106 | ``` 107 | 108 | You can set your preferred path separator (default: `__`) string when instantiating `ConfigurationManager`. 109 | 110 | ### From a `Data` Object 111 | 112 | ```swift 113 | let data = Data(...) 114 | manager.load(data: data) 115 | ``` 116 | 117 | ### From a File 118 | 119 | ```swift 120 | manager.load(file: "/path/to/file") 121 | ``` 122 | 123 | By default, the `file` argument is a path relative from the location of the executable (i.e., `.build/debug/myApp`); if `file` is an absolute path, then it will be treated as such. You can change the relative-from path using the optional `relativeFrom` parameter, like so: 124 | 125 | ```swift 126 | // Resolve path against PWD 127 | manager.load(file: "../path/to/file", relativeFrom: .pwd) 128 | 129 | // or 130 | 131 | // Resolve path against a custom path 132 | manager.load(file: "../path/to/file", relativeFrom: .customPath("/path/to/somewhere/on/file/system")) 133 | ``` 134 | 135 | **NOTE:** The following `relativeFrom` options, `.executable` (default) and `.pwd`, will reference different file system locations if the application is run from inside Xcode than if it is run from the command-line. You can set a compiler flag, i.e. `-DXCODE`, in your `xcodeproj` and use the flag to change your configuration file loading logic. 136 | 137 | **NOTE:** Because `BasePath.project` depends on the existence of a `Package.swift` file somewhere in a parent folder of the executable, changing its location using `swift build --build-path` is not supported. 138 | 139 | ### From a `URL` 140 | 141 | ```swift 142 | let url = URL(...) 143 | manager.load(url: url) 144 | ``` 145 | 146 | **NOTE:** The `URL` MUST include a scheme, i.e., `file://`, `http://`, etc. 147 | 148 | ### From Multiple Sources 149 | 150 | You can chain these methods to load configuration data from multiple sources all at once. If the same configuration key exists in the multiple sources, the one most recently loaded will override the ones loaded earlier. In this simple example, 151 | 152 | ```swift 153 | manager.load(["foo": "bar"]).load(["foo": "baz"]) 154 | ``` 155 | 156 | the value for `foo` is now `baz` because `["foo": "baz"]` was more recently loaded than `["foo": "bar"]`. The same behavior applies to all other `load` functions. 157 | 158 | **NOTE:** Currently, `Configuration` only supports JSON and PLIST formats for resources loaded from `Data`, file, or `URL`. You can write a [custom deserializer](https://kitura.github.io/Configuration/Protocols/Deserializer.html) to parse additional formats. 159 | 160 | ## Accessing Configuration Data 161 | 162 | To get individual configuration values after they have been loaded, use: 163 | 164 | ```swift 165 | manager["path:to:configuration"] 166 | ``` 167 | 168 | The configuration store is represented as a tree, where the path elements in keys are delimited by colons (`:`). For instance, the key `VCAP_SERVICES:cloudantNoSQLDB:0:credentials:host` would traverse into `VCAP_SERVICES`, `cloudantNoSQLDB`, array index 0, `credentials`, and then `host` to grab the value. Here is a JSON example of the structure: 169 | 170 | ```json 171 | { 172 | "VCAP_SERVICES": { 173 | "cloudantNoSQLDB": [ 174 | { 175 | "credentials": { 176 | "host": 177 | } 178 | } 179 | ] 180 | } 181 | } 182 | ``` 183 | 184 | The value returned is typed as `Any?`. Therefore, it's important to cast the value to the type you want to use. For instance: 185 | 186 | ```swift 187 | let stringValue = manager["VCAP_SERVICES:cloudantNoSQLDB:0:credentials:host"] as? String 188 | ``` 189 | 190 | You can also retrieve configuration objects via partial paths; for example, if you use `manager["VCAP_SERVICES:cloudantNoSQLDB:0:credentials"]`, the result is a dictionary of the key-values in `credentials`. 191 | 192 | To get all configuration values in the configuration store, use: 193 | 194 | ```swift 195 | manager.getConfigs() 196 | ``` 197 | 198 | The return value is a raw representation of all configuration values currently in the configuration store. 199 | 200 | ## Acknowledgements 201 | `Configuration` was inspired by [`nconf`](https://github.com/indexzero/nconf), a popular NodeJS hierarchical configuration manager. 202 | 203 | ## API Documentation 204 | For more information visit our [API reference](https://kitura.github.io/Configuration/index.html). 205 | 206 | ## License 207 | This library is licensed under Apache 2.0. Full license text is available in [LICENSE](https://github.com/Kitura/Configuration/blob/master/LICENSE). 208 | -------------------------------------------------------------------------------- /Sources/Configuration/ConfigurationNode.swift: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright IBM Corporation 2017 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | enum ConfigurationNode { 18 | static let separator = ":" 19 | 20 | case any(Any) 21 | case array([ConfigurationNode]) 22 | case dictionary([String: ConfigurationNode]) 23 | 24 | init(_ rawValue: Any) { 25 | self = .dictionary([:]) 26 | self.rawValue = rawValue 27 | } 28 | 29 | var rawValue: Any { 30 | get { 31 | switch self { 32 | case .any(let nodeAny): 33 | return nodeAny 34 | case .array(let nodeArray): 35 | return nodeArray.map { $0.rawValue } 36 | case .dictionary(let nodeDictionary): 37 | var dictionary: [String: Any] = [:] 38 | nodeDictionary.forEach { dictionary[$0] = $1.rawValue } 39 | return dictionary 40 | } 41 | } 42 | set { 43 | if let valueArray = newValue as? [Any] { 44 | self = .array(valueArray.map { ConfigurationNode($0) }) 45 | } 46 | else if let valueDictionary = newValue as? [String: Any] { 47 | self = .dictionary([:]) 48 | valueDictionary.forEach { self[$0] = ConfigurationNode($1) } 49 | } 50 | else { 51 | self = .any(newValue) 52 | } 53 | } 54 | } 55 | 56 | mutating func merge(overwrittenBy other: ConfigurationNode) { 57 | // do deep overwrite if both are dictionary types 58 | // otherwise, overwrite self with other 59 | switch (self, other) { 60 | case (.dictionary(var this), .dictionary(let that)): 61 | that.forEach { (thatKey, thatNode) in 62 | if var thisNode = this[thatKey] { 63 | // key exists in both 64 | // do merge overwrite recursively 65 | thisNode.merge(overwrittenBy: thatNode) 66 | this[thatKey] = thisNode 67 | } 68 | else { 69 | // key does not exist in self 70 | // insert it into self 71 | this[thatKey] = thatNode 72 | } 73 | } 74 | 75 | self = .dictionary(this) 76 | default: 77 | self = other 78 | } 79 | } 80 | 81 | subscript(path: String) -> ConfigurationNode? { 82 | get { 83 | var node: ConfigurationNode? 84 | let (firstKey, restOfKeys) = path.splitKeys 85 | 86 | switch self { 87 | case .array(let nodeArray): 88 | if let index = Int(firstKey), 89 | nodeArray.startIndex.. Any 31 | } 32 | -------------------------------------------------------------------------------- /Sources/Configuration/Deserializers/JSONDeserializer.swift: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright IBM Corporation 2017 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import Foundation 18 | 19 | /// Default JSON deserializer implementation. 20 | /// 21 | /// Deserializes JSON formatted data using Foundation's JSONSerialization class. 22 | public class JSONDeserializer: Deserializer { 23 | /// A shared `JSONDeserializer` instance. 24 | public static let shared = JSONDeserializer() 25 | 26 | /// A unique name that identifies this deserializer. 27 | public let name = "json" 28 | 29 | /// Function that deserializes raw JSON data into a Foundation object. 30 | /// 31 | /// - Parameter data: The raw JSON data to be deserialized. 32 | public func deserialize(data: Data) throws -> Any { 33 | return try JSONSerialization.jsonObject(with: data) 34 | } 35 | 36 | // No need to create multiple instances of JSONDeserializer 37 | private init() {} 38 | } 39 | -------------------------------------------------------------------------------- /Sources/Configuration/Deserializers/PLISTDeserializer.swift: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright IBM Corporation 2017 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import Foundation 18 | 19 | /// Default PLIST deserializer implementation. 20 | /// 21 | /// Deserializes PLIST formatted data using Foundation's PropertListSerialization class. 22 | public class PLISTDeserializer: Deserializer { 23 | /// A shared `PLISTDeserializer` instance. 24 | public static let shared = PLISTDeserializer() 25 | 26 | /// A unique name that identifies this deserializer. 27 | public let name = "plist" 28 | 29 | /// Function that deserializes raw PLIST data into a Foundation object. 30 | /// 31 | /// - Parameter data: The raw PLIST data to be deserialized. 32 | public func deserialize(data: Data) throws -> Any { 33 | return try PropertyListSerialization.propertyList(from: data, format: nil) 34 | } 35 | 36 | // No need to create multiple instances of PLISTDeserializer 37 | private init() {} 38 | } 39 | -------------------------------------------------------------------------------- /Tests/ConfigurationTests/ConfigurationManagerTest.swift: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright IBM Corporation 2017 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import XCTest 18 | import Foundation 19 | import FileKit 20 | @testable import Configuration 21 | 22 | class ConfigurationManagerTest: XCTestCase { 23 | static var allTests : [(String, (ConfigurationManagerTest) -> () throws -> Void)] { 24 | return [ 25 | ("testLoadSimple", testLoadSimple), 26 | ("testLoadArgv", testLoadArgv), 27 | ("testLoadEnvVar", testLoadEnvVar), 28 | ("testLoadData", testLoadData), 29 | ("testLoadFile", testLoadFile), 30 | ("testLoadRelative", testLoadRelative) 31 | ] 32 | } 33 | 34 | static let testJSONURL = URL(fileURLWithPath: #file).appendingPathComponent("../test.json").standardized 35 | 36 | static let symlinkInPWD = { () -> URL in 37 | var pwd = FileKit.workingDirectoryURL.appendingPathComponent("test.json") 38 | return FileKit.executableURL.path.hasSuffix("/xctest") ? pwd : URL(fileURLWithPath: "test.json") 39 | }() 40 | 41 | static let symlinkInExecutableFolder = URL(fileURLWithPath: FileKit.executableFolder).appendingPathComponent("test.json").standardized 42 | 43 | let jsonString = "{\n \"env\": \"\",\n \"OAuth\": {\n \"name\": \"facebook\",\n \"configuration\": {\n \"clientID\": \"\",\n \"clientSecret\": \"\",\n \"profileFields\": [\"displayName\", \"emails\", \"id\", \"name\"],\n \"profileURL\": \"https://graph.facebook.com/v2.6/me\",\n \"scope\": [\"email\"],\n \"state\": true\n }\n },\n \"port\": \"\"\n}" 44 | 45 | // Create symlink to test configuration file in PWD and executable folder 46 | override class func setUp() { 47 | do { 48 | try FileManager.default.createSymbolicLink(at: symlinkInPWD, withDestinationURL: testJSONURL) 49 | } 50 | catch { 51 | // Nothing we can do but leave a failure message 52 | print("Failed to create pwd symbolic link") 53 | print(error.localizedDescription) 54 | } 55 | 56 | do { 57 | try FileManager.default.createSymbolicLink(at: symlinkInExecutableFolder, withDestinationURL: testJSONURL) 58 | } 59 | catch { 60 | // Nothing we can do but leave a failure message 61 | print("Failed to create executable symbolic link") 62 | print(error.localizedDescription) 63 | } 64 | } 65 | 66 | // Delete test configuration file symlink created in setUp() 67 | override class func tearDown() { 68 | do { 69 | try FileManager.default.removeItem(at: symlinkInPWD) 70 | } 71 | catch { 72 | // Nothing we can do but leave a failure message 73 | XCTFail(error.localizedDescription) 74 | } 75 | 76 | do { 77 | try FileManager.default.removeItem(at: symlinkInExecutableFolder) 78 | } 79 | catch { 80 | // Nothing we can do but leave a failure message 81 | XCTFail(error.localizedDescription) 82 | } 83 | } 84 | 85 | func testLoadArgv() { 86 | // Set up CommandLine.arguments 87 | CommandLine.arguments.append("--argv=\(jsonString)") 88 | 89 | let manager = ConfigurationManager().load(.commandLineArguments) 90 | 91 | XCTAssertEqual(manager["argv:OAuth:configuration:state"] as? Bool, true) 92 | 93 | // Clean up CommandLine.arguments 94 | CommandLine.arguments.removeLast() 95 | } 96 | 97 | func testLoadEnvVar() { 98 | // Does not work in Linux yet due to https://bugs.swift.org/browse/SR-5076 99 | 100 | #if os(macOS) 101 | // Set env var 102 | XCTAssertEqual(setenv("ENV", jsonString, 1), 0) 103 | 104 | let manager = ConfigurationManager().load(.environmentVariables) 105 | 106 | XCTAssertEqual(manager["ENV:OAuth:configuration:state"] as? Bool, true) 107 | 108 | // Unset env var 109 | XCTAssertEqual(unsetenv("ENV"), 0) 110 | #endif 111 | } 112 | 113 | func testLoadSimple() { 114 | var manager: ConfigurationManager 115 | 116 | // String 117 | manager = ConfigurationManager().load("Hello world") 118 | XCTAssertEqual(manager.getConfigs() as? String, "Hello world") 119 | 120 | // Array 121 | manager = ConfigurationManager().load([0, "1", "hello world"]) 122 | XCTAssertEqual(manager["2"] as? String, "hello world") 123 | 124 | // Dictionary 125 | manager = ConfigurationManager().load(["Hello": "World"]) 126 | XCTAssertEqual(manager["Hello"] as? String, "World") 127 | } 128 | 129 | func testLoadData() { 130 | var manager: ConfigurationManager 131 | 132 | // JSON 133 | let jsonString = "{\"hello\": \"world\"}" 134 | 135 | guard let jsonData = jsonString.data(using: .utf8) else { 136 | XCTFail("Cannot convert \(jsonString) to Data") 137 | return 138 | } 139 | 140 | manager = ConfigurationManager().load(data: jsonData) 141 | XCTAssertEqual(manager["hello"] as? String, "world") 142 | 143 | // PLIST 144 | let plistString = "\n\n\n\n\thello\n\tworld\n\n\n" 145 | 146 | guard let plistData = plistString.data(using: .utf8) else { 147 | XCTFail("Cannot convert \(plistString) to Data") 148 | return 149 | } 150 | 151 | manager = ConfigurationManager().load(data: plistData) 152 | XCTAssertEqual(manager["hello"] as? String, "world") 153 | } 154 | 155 | func testLoadFile() { 156 | var manager: ConfigurationManager 157 | 158 | // JSON 159 | manager = ConfigurationManager().load(file: "../test.json", relativeFrom: .customPath(#file)) 160 | XCTAssertEqual(manager["OAuth:configuration:state"] as? Bool, true) 161 | 162 | // PLIST 163 | manager = ConfigurationManager().load(file: "../test.plist", relativeFrom: .customPath(#file)) 164 | 165 | XCTAssertEqual(manager["OAuth:configuration:state"] as? Bool, true) 166 | } 167 | 168 | func testLoadRelative() { 169 | var manager: ConfigurationManager 170 | 171 | // Custom 172 | manager = ConfigurationManager().load(file: "../test.json", relativeFrom: .customPath(#file)) 173 | XCTAssertEqual(manager["OAuth:configuration:state"] as? Bool, true) 174 | 175 | // PWD 176 | manager = ConfigurationManager().load(file: "test.json", relativeFrom: .pwd) 177 | XCTAssertEqual(manager["OAuth:configuration:state"] as? Bool, true) 178 | 179 | // Project Folder 180 | manager = ConfigurationManager().load(file: "test.json", relativeFrom: .project) 181 | XCTAssertEqual(manager["OAuth:configuration:state"] as? Bool, true) 182 | 183 | // Executable 184 | manager = ConfigurationManager().load(file: "test.json", relativeFrom: .executable) 185 | XCTAssertEqual(manager["OAuth:configuration:state"] as? Bool, true) 186 | } 187 | } 188 | -------------------------------------------------------------------------------- /Tests/ConfigurationTests/ConfigurationNodeTest.swift: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright IBM Corporation 2017 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import XCTest 18 | @testable import Configuration 19 | 20 | class ConfigurationNodeTest: XCTestCase { 21 | static var allTests : [(String, (ConfigurationNodeTest) -> () throws -> Void)] { 22 | return [ 23 | ("testRawValue", testRawValue), 24 | ("testSubscript", testSubscript), 25 | ("testMergeOverwrite", testMergeOverwrite), 26 | ("testSplitKeys", testSplitKeys) 27 | ] 28 | } 29 | 30 | func testRawValue() { 31 | var root = ConfigurationNode.dictionary([:]) 32 | 33 | root.rawValue = "Hello world" 34 | XCTAssertEqual(root.rawValue as? String, "Hello world") 35 | 36 | root.rawValue = [0, "1", "hello world"] 37 | XCTAssertEqual((root.rawValue as? [Any])?[2] as? String, "hello world") 38 | 39 | root.rawValue = ["hello": "world"] 40 | XCTAssertEqual((root.rawValue as? [String: Any])?["hello"] as? String, "world") 41 | 42 | root.rawValue = [ 43 | "env": "", 44 | "OAuth": [ 45 | "name": "facebook", 46 | "configuration": [ 47 | "state": true, 48 | "profileFields": ["displayName", "emails", "id", "name"], 49 | "clientID": "", 50 | "clientSecret": "", 51 | "profileURL": "https://graph.facebook.com/v2.6/me", 52 | "scope": ["email"] 53 | ] 54 | ], 55 | "port": "" 56 | ] 57 | XCTAssertEqual(root["OAuth:configuration:state"]?.rawValue as? Bool, true) 58 | } 59 | 60 | func testSubscript() { 61 | var root = ConfigurationNode.any(false) 62 | root["sub1:sub2"] = ConfigurationNode(["hello", "world"]) 63 | XCTAssertEqual(root["sub1:sub2:1"]?.rawValue as? String, "world") 64 | 65 | root = ConfigurationNode.array([]) 66 | root["0:sub2"] = ConfigurationNode(["sub3": ["Hello", "world"]]) 67 | XCTAssertEqual(root["0:sub2:sub3:1"]?.rawValue as? String, "world") 68 | 69 | // edge cases 70 | root = ConfigurationNode.dictionary([:]) 71 | root["hello"] = nil 72 | XCTAssertNil(root["hello"]) 73 | 74 | root = ConfigurationNode.any("Hello world") 75 | XCTAssertNil(root["Hello:world"]) 76 | } 77 | 78 | func testMergeOverwrite() { 79 | var root = ConfigurationNode.dictionary([:]) 80 | var other = ConfigurationNode.dictionary([:]) 81 | 82 | other.rawValue = "Hello world" 83 | root.merge(overwrittenBy: other) 84 | XCTAssertEqual(root.rawValue as? String, "Hello world") 85 | 86 | root.rawValue = ["sub1": "sub1"] 87 | other.rawValue = [ 88 | "sub1": "Hello world", 89 | "sub2": "sub2" 90 | ] 91 | root.merge(overwrittenBy: other) 92 | XCTAssertEqual(root["sub1"]?.rawValue as? String, "Hello world") 93 | XCTAssertEqual(root["sub2"]?.rawValue as? String, "sub2") 94 | } 95 | 96 | func testSplitKeys() { 97 | let simpleKeys = "hello".splitKeys 98 | XCTAssertEqual(simpleKeys.0, "hello") 99 | XCTAssertNil(simpleKeys.1) 100 | 101 | let complexKeys = "hello:world".splitKeys 102 | XCTAssertEqual(complexKeys.0, "hello") 103 | XCTAssertEqual(complexKeys.1, "world") 104 | 105 | let emptyRestOfKeys = "hello:".splitKeys 106 | XCTAssertEqual(emptyRestOfKeys.0, "hello") 107 | XCTAssertEqual(emptyRestOfKeys.1, "") 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /Tests/ConfigurationTests/LinuxSafeguardTest.swift: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright IBM Corporation 2017 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // An extra test case to ensure that all other test cases include all of their 18 | // tests in their respective `allTests` variable. This is to ensure that the 19 | // same number of unit tests are executed on Linux as there are on OSX. 20 | // 21 | // Code adapted from https://oleb.net/blog/2017/03/keeping-xctest-in-sync/ 22 | 23 | // Test disabled on Swift 4 for now due to 24 | // https://bugs.swift.org/browse/SR-5684 25 | 26 | #if os(OSX) && !swift(>=3.2) 27 | import XCTest 28 | 29 | class LinuxSafeguardTest: XCTestCase { 30 | func testLinuxTestSuiteIncludesAllTests() { 31 | var linuxCount: Int 32 | var darwinCount: Int 33 | 34 | // ConfigurationManagerTest 35 | linuxCount = ConfigurationManagerTest.allTests.count 36 | darwinCount = Int(ConfigurationManagerTest.defaultTestSuite().testCaseCount) 37 | XCTAssertEqual(linuxCount, darwinCount, "\(darwinCount - linuxCount) tests are missing from ConfigurationManagerTest.allTests") 38 | 39 | // ConfigurationNodeTest 40 | linuxCount = ConfigurationNodeTest.allTests.count 41 | darwinCount = Int(ConfigurationNodeTest.defaultTestSuite().testCaseCount) 42 | XCTAssertEqual(linuxCount, darwinCount, "\(darwinCount - linuxCount) tests are missing from ConfigurationNodeTest.allTests") 43 | } 44 | } 45 | #endif 46 | -------------------------------------------------------------------------------- /Tests/ConfigurationTests/test.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": "", 3 | "OAuth": { 4 | "name": "facebook", 5 | "configuration": { 6 | "clientID": "", 7 | "clientSecret": "", 8 | "profileFields": ["displayName", "emails", "id", "name"], 9 | "profileURL": "https://graph.facebook.com/v2.6/me", 10 | "scope": ["email"], 11 | "state": true 12 | } 13 | }, 14 | "port": "" 15 | } 16 | -------------------------------------------------------------------------------- /Tests/ConfigurationTests/test.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | env 6 | <default> 7 | OAuth 8 | 9 | name 10 | facebook 11 | configuration 12 | 13 | clientID 14 | <default> 15 | clientSecret 16 | <default> 17 | profileFields 18 | 19 | displayName 20 | emails 21 | id 22 | name 23 | 24 | profileURL 25 | https://graph.facebook.com/v2.6/me 26 | scope 27 | 28 | email 29 | 30 | state 31 | 32 | 33 | 34 | port 35 | <default> 36 | 37 | 38 | -------------------------------------------------------------------------------- /Tests/LinuxMain.swift: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright IBM Corporation 2017 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | **/ 16 | 17 | import Glibc 18 | import XCTest 19 | @testable import ConfigurationTests 20 | 21 | // Implementation taken from http://stackoverflow.com/a/24029847 22 | extension MutableCollection { 23 | mutating func shuffle() { 24 | let c = count 25 | guard c > 1 else { return } 26 | 27 | srand(UInt32(time(nil))) 28 | for (firstUnshuffled , unshuffledCount) in zip(indices, stride(from: c, to: 1, by: -1)) { 29 | let d: IndexDistance = numericCast(random() % numericCast(unshuffledCount)) 30 | guard d != 0 else { continue } 31 | let i = index(firstUnshuffled, offsetBy: d) 32 | swapAt(firstUnshuffled, i) 33 | } 34 | } 35 | } 36 | 37 | extension Sequence { 38 | func shuffled() -> [Iterator.Element] { 39 | var result = Array(self) 40 | result.shuffle() 41 | return result 42 | } 43 | } 44 | 45 | XCTMain([ 46 | testCase(ConfigurationNodeTest.allTests.shuffled()), 47 | testCase(ConfigurationManagerTest.allTests.shuffled()) 48 | ].shuffled()) 49 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | app: 2 | image: ibmcom/swift-ubuntu:4.0.3 3 | ports: 4 | - "8080:8080" 5 | volumes: 6 | - .:/Configuration 7 | command: bash -c "cd /Configuration && swift package --build-path .build-ubuntu clean && swift build --build-path .build-ubuntu && swift test" 8 | -------------------------------------------------------------------------------- /docs/Classes.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Classes Reference 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 |

22 | 23 | Configuration Docs 24 | 25 | (100% documented) 26 |

27 | 28 |

29 |

30 | 31 |
32 |

33 | 34 |

35 | 36 | 37 | View on GitHub 38 | 39 |

40 | 41 |
42 | 43 | 48 | 49 |
50 | 82 |
83 | 84 |
85 |
86 |

Classes

87 |

The following classes are available globally.

88 | 89 |
90 |
91 | 92 |
93 |
94 |
95 |
    96 |
  • 97 |
    98 | 99 | 100 | 101 | ConfigurationManager 102 | 103 |
    104 |
    105 |
    106 |
    107 |
    108 |
    109 |

    A one-stop shop to aggregate configuration properties from different sources, including 110 | command-line arguments, environment variables, files, URLs and raw objects into a 111 | single configuration store. Once the store has been populated configuration data 112 | can be accessed and retrieved for an individual value, or multiple values, resources 113 | can also be removed.

    114 |

    Usage Example

    115 |
    import Configuration
    116 | 
    117 | let manager = ConfigurationManager()
    118 | manager.load(file: "config.json").load(.environmentVariables)
    119 | 
    120 | 121 |

    To get configuration values after they have been loaded, use:

    122 |
    manager["path:to:configuration:value"]
    123 | 
    124 | 125 |

    The configuration store is represented as a tree, where the path elements in keys are delimited 126 | by colons (:). The value returned is typed as Any?, therefore it’s important to cast the value 127 | to the type you want to use.

    128 | 129 |

    When aggregating configuration data from multiple sources, if the same configuration key 130 | exists in multiple sources the one most recently loaded will override those loaded earlier. 131 | In the example below the value for foo is now baz because ["foo": "baz"] was more recently 132 | loaded than ["foo": "bar"]. The same behaviour applies to all other load functions.

    133 |
    manager.load(["foo": "bar"]).load(["foo": "baz"])
    134 | 
    135 | 136 | See more 137 |
    138 |
    139 |

    Declaration

    140 |
    141 |

    Swift

    142 |
    public class ConfigurationManager
    143 | 144 |
    145 |
    146 |
    147 |
    148 |
  • 149 |
150 |
151 |
152 |
    153 |
  • 154 |
    155 | 156 | 157 | 158 | JSONDeserializer 159 | 160 |
    161 |
    162 |
    163 |
    164 |
    165 |
    166 |

    Default JSON deserializer implementation.

    167 | 168 |

    Deserializes JSON formatted data using Foundation’s JSONSerialization class.

    169 | 170 | See more 171 |
    172 |
    173 |

    Declaration

    174 |
    175 |

    Swift

    176 |
    public class JSONDeserializer: Deserializer
    177 | 178 |
    179 |
    180 |
    181 |
    182 |
  • 183 |
184 |
185 |
186 |
    187 |
  • 188 |
    189 | 190 | 191 | 192 | PLISTDeserializer 193 | 194 |
    195 |
    196 |
    197 |
    198 |
    199 |
    200 |

    Default PLIST deserializer implementation.

    201 | 202 |

    Deserializes PLIST formatted data using Foundation’s PropertListSerialization class.

    203 | 204 | See more 205 |
    206 |
    207 |

    Declaration

    208 |
    209 |

    Swift

    210 |
    public class PLISTDeserializer: Deserializer
    211 | 212 |
    213 |
    214 |
    215 |
    216 |
  • 217 |
218 |
219 |
220 |
221 | 222 |
223 |
224 | 228 | 229 | 230 | 231 | -------------------------------------------------------------------------------- /docs/Classes/ConfigurationManager/Source.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Source Enumeration Reference 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 |

23 | 24 | Configuration Docs 25 | 26 | (100% documented) 27 |

28 | 29 |

30 |

31 | 32 |
33 |

34 | 35 |

36 | 37 | 38 | View on GitHub 39 | 40 |

41 | 42 |
43 | 44 | 49 | 50 |
51 | 83 |
84 | 85 |
86 |
87 |

Source

88 |
89 |
90 |
public enum Source
91 | 92 |
93 |
94 |

Enum to specify the configuration source. The supported options are to load configuration 95 | data from either command-line arguments or environment variables.

96 | 97 |
98 |
99 | 100 |
101 |
102 |
103 |
    104 |
  • 105 |
    106 | 107 | 108 | 109 | commandLineArguments 110 | 111 |
    112 |
    113 |
    114 |
    115 |
    116 |
    117 |

    Flag to load configurations from command-line arguments.

    118 | 119 |
    120 |
    121 |

    Declaration

    122 |
    123 |

    Swift

    124 |
    case commandLineArguments
    125 | 126 |
    127 |
    128 |
    129 |
    130 |
  • 131 |
132 |
133 |
134 |
    135 |
  • 136 |
    137 | 138 | 139 | 140 | environmentVariables 141 | 142 |
    143 |
    144 |
    145 |
    146 |
    147 |
    148 |

    Flag to load configurations from environment variables.

    149 | 150 |
    151 |
    152 |

    Declaration

    153 |
    154 |

    Swift

    155 |
    case environmentVariables
    156 | 157 |
    158 |
    159 |
    160 |
    161 |
  • 162 |
163 |
164 |
165 |
166 | 167 |
168 |
169 | 173 | 174 | 175 | 176 | -------------------------------------------------------------------------------- /docs/Classes/JSONDeserializer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | JSONDeserializer Class Reference 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 |

23 | 24 | Configuration Docs 25 | 26 | (100% documented) 27 |

28 | 29 |

30 |

31 | 32 |
33 |

34 | 35 |

36 | 37 | 38 | View on GitHub 39 | 40 |

41 | 42 |
43 | 44 | 49 | 50 |
51 | 83 |
84 | 85 |
86 |
87 |

JSONDeserializer

88 |
89 |
90 |
public class JSONDeserializer: Deserializer
91 | 92 |
93 |
94 |

Default JSON deserializer implementation.

95 | 96 |

Deserializes JSON formatted data using Foundation’s JSONSerialization class.

97 | 98 |
99 |
100 | 101 |
102 |
103 |
104 |
    105 |
  • 106 |
    107 | 108 | 109 | 110 | shared 111 | 112 |
    113 |
    114 |
    115 |
    116 |
    117 |
    118 |

    A shared JSONDeserializer instance.

    119 | 120 |
    121 |
    122 |

    Declaration

    123 |
    124 |

    Swift

    125 |
    public static let shared = JSONDeserializer()
    126 | 127 |
    128 |
    129 |
    130 |
    131 |
  • 132 |
  • 133 |
    134 | 135 | 136 | 137 | name 138 | 139 |
    140 |
    141 |
    142 |
    143 |
    144 |
    145 |

    A unique name that identifies this deserializer.

    146 | 147 |
    148 |
    149 |

    Declaration

    150 |
    151 |

    Swift

    152 |
    public let name = "json"
    153 | 154 |
    155 |
    156 |
    157 |
    158 |
  • 159 |
  • 160 |
    161 | 162 | 163 | 164 | deserialize(data:) 165 | 166 |
    167 |
    168 |
    169 |
    170 |
    171 |
    172 |

    Function that deserializes raw JSON data into a Foundation object.

    173 | 174 |
    175 |
    176 |

    Declaration

    177 |
    178 |

    Swift

    179 |
    public func deserialize(data: Data) throws -> Any
    180 | 181 |
    182 |
    183 |
    184 |

    Parameters

    185 | 186 | 187 | 188 | 193 | 198 | 199 | 200 |
    189 | 190 | data 191 | 192 | 194 |
    195 |

    The raw JSON data to be deserialized.

    196 |
    197 |
    201 |
    202 |
    203 |
    204 |
  • 205 |
206 |
207 |
208 |
209 | 210 |
211 |
212 | 216 | 217 | 218 | 219 | -------------------------------------------------------------------------------- /docs/Classes/PLISTDeserializer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | PLISTDeserializer Class Reference 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 |

23 | 24 | Configuration Docs 25 | 26 | (100% documented) 27 |

28 | 29 |

30 |

31 | 32 |
33 |

34 | 35 |

36 | 37 | 38 | View on GitHub 39 | 40 |

41 | 42 |
43 | 44 | 49 | 50 |
51 | 83 |
84 | 85 |
86 |
87 |

PLISTDeserializer

88 |
89 |
90 |
public class PLISTDeserializer: Deserializer
91 | 92 |
93 |
94 |

Default PLIST deserializer implementation.

95 | 96 |

Deserializes PLIST formatted data using Foundation’s PropertListSerialization class.

97 | 98 |
99 |
100 | 101 |
102 |
103 |
104 |
    105 |
  • 106 |
    107 | 108 | 109 | 110 | shared 111 | 112 |
    113 |
    114 |
    115 |
    116 |
    117 |
    118 |

    A shared PLISTDeserializer instance.

    119 | 120 |
    121 |
    122 |

    Declaration

    123 |
    124 |

    Swift

    125 |
    public static let shared = PLISTDeserializer()
    126 | 127 |
    128 |
    129 |
    130 |
    131 |
  • 132 |
  • 133 |
    134 | 135 | 136 | 137 | name 138 | 139 |
    140 |
    141 |
    142 |
    143 |
    144 |
    145 |

    A unique name that identifies this deserializer.

    146 | 147 |
    148 |
    149 |

    Declaration

    150 |
    151 |

    Swift

    152 |
    public let name = "plist"
    153 | 154 |
    155 |
    156 |
    157 |
    158 |
  • 159 |
  • 160 |
    161 | 162 | 163 | 164 | deserialize(data:) 165 | 166 |
    167 |
    168 |
    169 |
    170 |
    171 |
    172 |

    Function that deserializes raw PLIST data into a Foundation object.

    173 | 174 |
    175 |
    176 |

    Declaration

    177 |
    178 |

    Swift

    179 |
    public func deserialize(data: Data) throws -> Any
    180 | 181 |
    182 |
    183 |
    184 |

    Parameters

    185 | 186 | 187 | 188 | 193 | 198 | 199 | 200 |
    189 | 190 | data 191 | 192 | 194 |
    195 |

    The raw PLIST data to be deserialized.

    196 |
    197 |
    201 |
    202 |
    203 |
    204 |
  • 205 |
206 |
207 |
208 |
209 | 210 |
211 |
212 | 216 | 217 | 218 | 219 | -------------------------------------------------------------------------------- /docs/Protocols.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Protocols Reference 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 |

22 | 23 | Configuration Docs 24 | 25 | (100% documented) 26 |

27 | 28 |

29 |

30 | 31 |
32 |

33 | 34 |

35 | 36 | 37 | View on GitHub 38 | 39 |

40 | 41 |
42 | 43 | 48 | 49 |
50 | 82 |
83 | 84 |
85 |
86 |

Protocols

87 |

The following protocols are available globally.

88 | 89 |
90 |
91 | 92 |
93 |
94 |
95 |
    96 |
  • 97 |
    98 | 99 | 100 | 101 | Deserializer 102 | 103 |
    104 |
    105 |
    106 |
    107 |
    108 |
    109 |

    Deserializer protocol.

    110 | 111 |

    Additional deserializers (i.e. for unsupported file formats) may be used 112 | by implementing this protocol.

    113 | 114 | See more 115 |
    116 |
    117 |

    Declaration

    118 |
    119 |

    Swift

    120 |
    public protocol Deserializer
    121 | 122 |
    123 |
    124 |
    125 |
    126 |
  • 127 |
128 |
129 |
130 |
131 | 132 |
133 |
134 | 138 | 139 | 140 | 141 | -------------------------------------------------------------------------------- /docs/Protocols/Deserializer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Deserializer Protocol Reference 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 |

23 | 24 | Configuration Docs 25 | 26 | (100% documented) 27 |

28 | 29 |

30 |

31 | 32 |
33 |

34 | 35 |

36 | 37 | 38 | View on GitHub 39 | 40 |

41 | 42 |
43 | 44 | 49 | 50 |
51 | 83 |
84 | 85 |
86 |
87 |

Deserializer

88 |
89 |
90 |
public protocol Deserializer
91 | 92 |
93 |
94 |

Deserializer protocol.

95 | 96 |

Additional deserializers (i.e. for unsupported file formats) may be used 97 | by implementing this protocol.

98 | 99 |
100 |
101 | 102 |
103 |
104 |
105 |
    106 |
  • 107 |
    108 | 109 | 110 | 111 | name 112 | 113 |
    114 |
    115 |
    116 |
    117 |
    118 |
    119 |

    A unique name that identifies this deserializer.

    120 | 121 |
    122 |
    123 |

    Declaration

    124 |
    125 |

    Swift

    126 |
    var name: String
    127 | 128 |
    129 |
    130 |
    131 |
    132 |
  • 133 |
  • 134 |
    135 | 136 | 137 | 138 | deserialize(data:) 139 | 140 |
    141 |
    142 |
    143 |
    144 |
    145 |
    146 |

    Function that deserializes raw data into a Foundation object.

    147 | 148 |
    149 |
    150 |

    Declaration

    151 |
    152 |

    Swift

    153 |
    func deserialize(data: Data) throws -> Any
    154 | 155 |
    156 |
    157 |
    158 |

    Parameters

    159 | 160 | 161 | 162 | 167 | 172 | 173 | 174 |
    163 | 164 | data 165 | 166 | 168 |
    169 |

    The raw data to be deserialized.

    170 |
    171 |
    175 |
    176 |
    177 |
    178 |
  • 179 |
180 |
181 |
182 |
183 | 184 |
185 |
186 | 190 | 191 | 192 | 193 | -------------------------------------------------------------------------------- /docs/badge.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | documentation 17 | 18 | 19 | documentation 20 | 21 | 22 | 100% 23 | 24 | 25 | 100% 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /docs/css/highlight.css: -------------------------------------------------------------------------------- 1 | /* Credit to https://gist.github.com/wataru420/2048287 */ 2 | .highlight { 3 | /* Comment */ 4 | /* Error */ 5 | /* Keyword */ 6 | /* Operator */ 7 | /* Comment.Multiline */ 8 | /* Comment.Preproc */ 9 | /* Comment.Single */ 10 | /* Comment.Special */ 11 | /* Generic.Deleted */ 12 | /* Generic.Deleted.Specific */ 13 | /* Generic.Emph */ 14 | /* Generic.Error */ 15 | /* Generic.Heading */ 16 | /* Generic.Inserted */ 17 | /* Generic.Inserted.Specific */ 18 | /* Generic.Output */ 19 | /* Generic.Prompt */ 20 | /* Generic.Strong */ 21 | /* Generic.Subheading */ 22 | /* Generic.Traceback */ 23 | /* Keyword.Constant */ 24 | /* Keyword.Declaration */ 25 | /* Keyword.Pseudo */ 26 | /* Keyword.Reserved */ 27 | /* Keyword.Type */ 28 | /* Literal.Number */ 29 | /* Literal.String */ 30 | /* Name.Attribute */ 31 | /* Name.Builtin */ 32 | /* Name.Class */ 33 | /* Name.Constant */ 34 | /* Name.Entity */ 35 | /* Name.Exception */ 36 | /* Name.Function */ 37 | /* Name.Namespace */ 38 | /* Name.Tag */ 39 | /* Name.Variable */ 40 | /* Operator.Word */ 41 | /* Text.Whitespace */ 42 | /* Literal.Number.Float */ 43 | /* Literal.Number.Hex */ 44 | /* Literal.Number.Integer */ 45 | /* Literal.Number.Oct */ 46 | /* Literal.String.Backtick */ 47 | /* Literal.String.Char */ 48 | /* Literal.String.Doc */ 49 | /* Literal.String.Double */ 50 | /* Literal.String.Escape */ 51 | /* Literal.String.Heredoc */ 52 | /* Literal.String.Interpol */ 53 | /* Literal.String.Other */ 54 | /* Literal.String.Regex */ 55 | /* Literal.String.Single */ 56 | /* Literal.String.Symbol */ 57 | /* Name.Builtin.Pseudo */ 58 | /* Name.Variable.Class */ 59 | /* Name.Variable.Global */ 60 | /* Name.Variable.Instance */ 61 | /* Literal.Number.Integer.Long */ } 62 | .highlight .c { 63 | color: #999988; 64 | font-style: italic; } 65 | .highlight .err { 66 | color: #a61717; 67 | background-color: #e3d2d2; } 68 | .highlight .k { 69 | color: #000000; 70 | font-weight: bold; } 71 | .highlight .o { 72 | color: #000000; 73 | font-weight: bold; } 74 | .highlight .cm { 75 | color: #999988; 76 | font-style: italic; } 77 | .highlight .cp { 78 | color: #999999; 79 | font-weight: bold; } 80 | .highlight .c1 { 81 | color: #999988; 82 | font-style: italic; } 83 | .highlight .cs { 84 | color: #999999; 85 | font-weight: bold; 86 | font-style: italic; } 87 | .highlight .gd { 88 | color: #000000; 89 | background-color: #ffdddd; } 90 | .highlight .gd .x { 91 | color: #000000; 92 | background-color: #ffaaaa; } 93 | .highlight .ge { 94 | color: #000000; 95 | font-style: italic; } 96 | .highlight .gr { 97 | color: #aa0000; } 98 | .highlight .gh { 99 | color: #999999; } 100 | .highlight .gi { 101 | color: #000000; 102 | background-color: #ddffdd; } 103 | .highlight .gi .x { 104 | color: #000000; 105 | background-color: #aaffaa; } 106 | .highlight .go { 107 | color: #888888; } 108 | .highlight .gp { 109 | color: #555555; } 110 | .highlight .gs { 111 | font-weight: bold; } 112 | .highlight .gu { 113 | color: #aaaaaa; } 114 | .highlight .gt { 115 | color: #aa0000; } 116 | .highlight .kc { 117 | color: #000000; 118 | font-weight: bold; } 119 | .highlight .kd { 120 | color: #000000; 121 | font-weight: bold; } 122 | .highlight .kp { 123 | color: #000000; 124 | font-weight: bold; } 125 | .highlight .kr { 126 | color: #000000; 127 | font-weight: bold; } 128 | .highlight .kt { 129 | color: #445588; } 130 | .highlight .m { 131 | color: #009999; } 132 | .highlight .s { 133 | color: #d14; } 134 | .highlight .na { 135 | color: #008080; } 136 | .highlight .nb { 137 | color: #0086B3; } 138 | .highlight .nc { 139 | color: #445588; 140 | font-weight: bold; } 141 | .highlight .no { 142 | color: #008080; } 143 | .highlight .ni { 144 | color: #800080; } 145 | .highlight .ne { 146 | color: #990000; 147 | font-weight: bold; } 148 | .highlight .nf { 149 | color: #990000; } 150 | .highlight .nn { 151 | color: #555555; } 152 | .highlight .nt { 153 | color: #000080; } 154 | .highlight .nv { 155 | color: #008080; } 156 | .highlight .ow { 157 | color: #000000; 158 | font-weight: bold; } 159 | .highlight .w { 160 | color: #bbbbbb; } 161 | .highlight .mf { 162 | color: #009999; } 163 | .highlight .mh { 164 | color: #009999; } 165 | .highlight .mi { 166 | color: #009999; } 167 | .highlight .mo { 168 | color: #009999; } 169 | .highlight .sb { 170 | color: #d14; } 171 | .highlight .sc { 172 | color: #d14; } 173 | .highlight .sd { 174 | color: #d14; } 175 | .highlight .s2 { 176 | color: #d14; } 177 | .highlight .se { 178 | color: #d14; } 179 | .highlight .sh { 180 | color: #d14; } 181 | .highlight .si { 182 | color: #d14; } 183 | .highlight .sx { 184 | color: #d14; } 185 | .highlight .sr { 186 | color: #009926; } 187 | .highlight .s1 { 188 | color: #d14; } 189 | .highlight .ss { 190 | color: #990073; } 191 | .highlight .bp { 192 | color: #999999; } 193 | .highlight .vc { 194 | color: #008080; } 195 | .highlight .vg { 196 | color: #008080; } 197 | .highlight .vi { 198 | color: #008080; } 199 | .highlight .il { 200 | color: #009999; } 201 | -------------------------------------------------------------------------------- /docs/css/jazzy.css: -------------------------------------------------------------------------------- 1 | *, *:before, *:after { 2 | box-sizing: inherit; } 3 | 4 | body { 5 | margin: 0; 6 | background: #fff; 7 | color: #333; 8 | font: 16px/1.7 "Helvetica Neue", Helvetica, Arial, sans-serif; 9 | letter-spacing: .2px; 10 | -webkit-font-smoothing: antialiased; 11 | box-sizing: border-box; } 12 | 13 | h1 { 14 | font-size: 2rem; 15 | font-weight: 700; 16 | margin: 1.275em 0 0.6em; } 17 | 18 | h2 { 19 | font-size: 1.75rem; 20 | font-weight: 700; 21 | margin: 1.275em 0 0.3em; } 22 | 23 | h3 { 24 | font-size: 1.5rem; 25 | font-weight: 700; 26 | margin: 1em 0 0.3em; } 27 | 28 | h4 { 29 | font-size: 1.25rem; 30 | font-weight: 700; 31 | margin: 1.275em 0 0.85em; } 32 | 33 | h5 { 34 | font-size: 1rem; 35 | font-weight: 700; 36 | margin: 1.275em 0 0.85em; } 37 | 38 | h6 { 39 | font-size: 1rem; 40 | font-weight: 700; 41 | margin: 1.275em 0 0.85em; 42 | color: #777; } 43 | 44 | p { 45 | margin: 0 0 1em; } 46 | 47 | ul, ol { 48 | padding: 0 0 0 2em; 49 | margin: 0 0 0.85em; } 50 | 51 | blockquote { 52 | margin: 0 0 0.85em; 53 | padding: 0 15px; 54 | color: #858585; 55 | border-left: 4px solid #e5e5e5; } 56 | 57 | img { 58 | max-width: 100%; } 59 | 60 | a { 61 | color: #4183c4; 62 | text-decoration: none; } 63 | a:hover, a:focus { 64 | outline: 0; 65 | text-decoration: underline; } 66 | 67 | table { 68 | background: #fff; 69 | width: 100%; 70 | border-collapse: collapse; 71 | border-spacing: 0; 72 | overflow: auto; 73 | margin: 0 0 0.85em; } 74 | 75 | tr:nth-child(2n) { 76 | background-color: #fbfbfb; } 77 | 78 | th, td { 79 | padding: 6px 13px; 80 | border: 1px solid #ddd; } 81 | 82 | pre { 83 | margin: 0 0 1.275em; 84 | padding: .85em 1em; 85 | overflow: auto; 86 | background: #f7f7f7; 87 | font-size: .85em; 88 | font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; } 89 | 90 | code { 91 | font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; } 92 | 93 | p > code, li > code { 94 | background: #f7f7f7; 95 | padding: .2em; } 96 | p > code:before, p > code:after, li > code:before, li > code:after { 97 | letter-spacing: -.2em; 98 | content: "\00a0"; } 99 | 100 | pre code { 101 | padding: 0; 102 | white-space: pre; } 103 | 104 | .content-wrapper { 105 | display: flex; 106 | flex-direction: column; } 107 | @media (min-width: 768px) { 108 | .content-wrapper { 109 | flex-direction: row; } } 110 | 111 | .header { 112 | display: flex; 113 | padding: 8px; 114 | font-size: 0.875em; 115 | background: #444; 116 | color: #999; } 117 | 118 | .header-col { 119 | margin: 0; 120 | padding: 0 8px; } 121 | 122 | .header-col--primary { 123 | flex: 1; } 124 | 125 | .header-link { 126 | color: #fff; } 127 | 128 | .header-icon { 129 | padding-right: 6px; 130 | vertical-align: -4px; 131 | height: 16px; } 132 | 133 | .breadcrumbs { 134 | font-size: 0.875em; 135 | padding: 8px 16px; 136 | margin: 0; 137 | background: #fbfbfb; 138 | border-bottom: 1px solid #ddd; } 139 | 140 | .carat { 141 | height: 10px; 142 | margin: 0 5px; } 143 | 144 | .navigation { 145 | order: 2; } 146 | @media (min-width: 768px) { 147 | .navigation { 148 | order: 1; 149 | width: 25%; 150 | max-width: 300px; 151 | padding-bottom: 64px; 152 | overflow: hidden; 153 | word-wrap: normal; 154 | background: #fbfbfb; 155 | border-right: 1px solid #ddd; } } 156 | 157 | .nav-groups { 158 | list-style-type: none; 159 | padding-left: 0; } 160 | 161 | .nav-group-name { 162 | border-bottom: 1px solid #ddd; 163 | padding: 8px 0 8px 16px; } 164 | 165 | .nav-group-name-link { 166 | color: #333; } 167 | 168 | .nav-group-tasks { 169 | margin: 8px 0; 170 | padding: 0 0 0 8px; } 171 | 172 | .nav-group-task { 173 | font-size: 1em; 174 | list-style-type: none; 175 | white-space: nowrap; } 176 | 177 | .nav-group-task-link { 178 | color: #808080; } 179 | 180 | .main-content { 181 | order: 1; } 182 | @media (min-width: 768px) { 183 | .main-content { 184 | order: 2; 185 | flex: 1; 186 | padding-bottom: 60px; } } 187 | 188 | .section { 189 | padding: 0 32px; 190 | border-bottom: 1px solid #ddd; } 191 | 192 | .section-content { 193 | max-width: 834px; 194 | margin: 0 auto; 195 | padding: 16px 0; } 196 | 197 | .section-name { 198 | color: #666; 199 | display: block; } 200 | 201 | .declaration .highlight { 202 | overflow-x: initial; 203 | padding: 8px 0; 204 | margin: 0; 205 | background-color: transparent; 206 | border: none; } 207 | 208 | .task-group-section { 209 | border-top: 1px solid #ddd; } 210 | 211 | .task-group { 212 | padding-top: 0px; } 213 | 214 | .task-name-container a[name]:before { 215 | content: ""; 216 | display: block; } 217 | 218 | .item-container { 219 | padding: 0; } 220 | 221 | .item { 222 | padding-top: 8px; 223 | width: 100%; 224 | list-style-type: none; } 225 | .item a[name]:before { 226 | content: ""; 227 | display: block; } 228 | .item .token { 229 | padding-left: 3px; 230 | margin-left: 0px; 231 | font-size: 1rem; } 232 | .item .declaration-note { 233 | font-size: .85em; 234 | color: #808080; 235 | font-style: italic; } 236 | 237 | .pointer-container { 238 | border-bottom: 1px solid #ddd; 239 | left: -23px; 240 | padding-bottom: 13px; 241 | position: relative; 242 | width: 110%; } 243 | 244 | .pointer { 245 | left: 21px; 246 | top: 7px; 247 | display: block; 248 | position: absolute; 249 | width: 12px; 250 | height: 12px; 251 | border-left: 1px solid #ddd; 252 | border-top: 1px solid #ddd; 253 | background: #fff; 254 | transform: rotate(45deg); } 255 | 256 | .height-container { 257 | display: none; 258 | position: relative; 259 | width: 100%; 260 | overflow: hidden; } 261 | .height-container .section { 262 | background: #fff; 263 | border: 1px solid #ddd; 264 | border-top-width: 0; 265 | padding-top: 10px; 266 | padding-bottom: 5px; 267 | padding: 8px 16px; } 268 | 269 | .aside, .language { 270 | padding: 6px 12px; 271 | margin: 12px 0; 272 | border-left: 5px solid #dddddd; 273 | overflow-y: hidden; } 274 | .aside .aside-title, .language .aside-title { 275 | font-size: 9px; 276 | letter-spacing: 2px; 277 | text-transform: uppercase; 278 | padding-bottom: 0; 279 | margin: 0; 280 | color: #aaa; 281 | -webkit-user-select: none; } 282 | .aside p:last-child, .language p:last-child { 283 | margin-bottom: 0; } 284 | 285 | .language { 286 | border-left: 5px solid #cde9f4; } 287 | .language .aside-title { 288 | color: #4183c4; } 289 | 290 | .aside-warning { 291 | border-left: 5px solid #ff6666; } 292 | .aside-warning .aside-title { 293 | color: #ff0000; } 294 | 295 | .graybox { 296 | border-collapse: collapse; 297 | width: 100%; } 298 | .graybox p { 299 | margin: 0; 300 | word-break: break-word; 301 | min-width: 50px; } 302 | .graybox td { 303 | border: 1px solid #ddd; 304 | padding: 5px 25px 5px 10px; 305 | vertical-align: middle; } 306 | .graybox tr td:first-of-type { 307 | text-align: right; 308 | padding: 7px; 309 | vertical-align: top; 310 | word-break: normal; 311 | width: 40px; } 312 | 313 | .slightly-smaller { 314 | font-size: 0.9em; } 315 | 316 | .footer { 317 | padding: 8px 16px; 318 | background: #444; 319 | color: #ddd; 320 | font-size: 0.8em; } 321 | .footer p { 322 | margin: 8px 0; } 323 | .footer a { 324 | color: #fff; } 325 | 326 | html.dash .header, html.dash .breadcrumbs, html.dash .navigation { 327 | display: none; } 328 | html.dash .height-container { 329 | display: block; } 330 | 331 | form[role=search] input { 332 | font: 16px/1.7 "Helvetica Neue", Helvetica, Arial, sans-serif; 333 | font-size: 14px; 334 | line-height: 24px; 335 | padding: 0 10px; 336 | margin: 0; 337 | border: none; 338 | border-radius: 1em; } 339 | .loading form[role=search] input { 340 | background: white url(../img/spinner.gif) center right 4px no-repeat; } 341 | form[role=search] .tt-menu { 342 | margin: 0; 343 | min-width: 300px; 344 | background: #fbfbfb; 345 | color: #333; 346 | border: 1px solid #ddd; } 347 | form[role=search] .tt-highlight { 348 | font-weight: bold; } 349 | form[role=search] .tt-suggestion { 350 | font: 16px/1.7 "Helvetica Neue", Helvetica, Arial, sans-serif; 351 | padding: 0 8px; } 352 | form[role=search] .tt-suggestion span { 353 | display: table-cell; 354 | white-space: nowrap; } 355 | form[role=search] .tt-suggestion .doc-parent-name { 356 | width: 100%; 357 | text-align: right; 358 | font-weight: normal; 359 | font-size: 0.9em; 360 | padding-left: 16px; } 361 | form[role=search] .tt-suggestion:hover, 362 | form[role=search] .tt-suggestion.tt-cursor { 363 | cursor: pointer; 364 | background-color: #4183c4; 365 | color: #fff; } 366 | form[role=search] .tt-suggestion:hover .doc-parent-name, 367 | form[role=search] .tt-suggestion.tt-cursor .doc-parent-name { 368 | color: #fff; } 369 | -------------------------------------------------------------------------------- /docs/docsets/Configuration.docset/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleIdentifier 6 | com.jazzy.configuration 7 | CFBundleName 8 | Configuration 9 | DocSetPlatformFamily 10 | configuration 11 | isDashDocset 12 | 13 | dashIndexFilePath 14 | index.html 15 | isJavaScriptEnabled 16 | 17 | DashDocSetFamily 18 | dashtoc 19 | 20 | 21 | -------------------------------------------------------------------------------- /docs/docsets/Configuration.docset/Contents/Resources/Documents/Classes.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Classes Reference 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 |

22 | 23 | Configuration Docs 24 | 25 | (100% documented) 26 |

27 | 28 |

29 |

30 | 31 |
32 |

33 | 34 |

35 | 36 | 37 | View on GitHub 38 | 39 |

40 | 41 |
42 | 43 | 48 | 49 |
50 | 82 |
83 | 84 |
85 |
86 |

Classes

87 |

The following classes are available globally.

88 | 89 |
90 |
91 | 92 |
93 |
94 |
95 |
    96 |
  • 97 |
    98 | 99 | 100 | 101 | ConfigurationManager 102 | 103 |
    104 |
    105 |
    106 |
    107 |
    108 |
    109 |

    A one-stop shop to aggregate configuration properties from different sources, including 110 | command-line arguments, environment variables, files, URLs and raw objects into a 111 | single configuration store. Once the store has been populated configuration data 112 | can be accessed and retrieved for an individual value, or multiple values, resources 113 | can also be removed.

    114 |

    Usage Example

    115 |
    import Configuration
    116 | 
    117 | let manager = ConfigurationManager()
    118 | manager.load(file: "config.json").load(.environmentVariables)
    119 | 
    120 | 121 |

    To get configuration values after they have been loaded, use:

    122 |
    manager["path:to:configuration:value"]
    123 | 
    124 | 125 |

    The configuration store is represented as a tree, where the path elements in keys are delimited 126 | by colons (:). The value returned is typed as Any?, therefore it’s important to cast the value 127 | to the type you want to use.

    128 | 129 |

    When aggregating configuration data from multiple sources, if the same configuration key 130 | exists in multiple sources the one most recently loaded will override those loaded earlier. 131 | In the example below the value for foo is now baz because ["foo": "baz"] was more recently 132 | loaded than ["foo": "bar"]. The same behaviour applies to all other load functions.

    133 |
    manager.load(["foo": "bar"]).load(["foo": "baz"])
    134 | 
    135 | 136 | See more 137 |
    138 |
    139 |

    Declaration

    140 |
    141 |

    Swift

    142 |
    public class ConfigurationManager
    143 | 144 |
    145 |
    146 |
    147 |
    148 |
  • 149 |
150 |
151 |
152 |
    153 |
  • 154 |
    155 | 156 | 157 | 158 | JSONDeserializer 159 | 160 |
    161 |
    162 |
    163 |
    164 |
    165 |
    166 |

    Default JSON deserializer implementation.

    167 | 168 |

    Deserializes JSON formatted data using Foundation’s JSONSerialization class.

    169 | 170 | See more 171 |
    172 |
    173 |

    Declaration

    174 |
    175 |

    Swift

    176 |
    public class JSONDeserializer: Deserializer
    177 | 178 |
    179 |
    180 |
    181 |
    182 |
  • 183 |
184 |
185 |
186 |
    187 |
  • 188 |
    189 | 190 | 191 | 192 | PLISTDeserializer 193 | 194 |
    195 |
    196 |
    197 |
    198 |
    199 |
    200 |

    Default PLIST deserializer implementation.

    201 | 202 |

    Deserializes PLIST formatted data using Foundation’s PropertListSerialization class.

    203 | 204 | See more 205 |
    206 |
    207 |

    Declaration

    208 |
    209 |

    Swift

    210 |
    public class PLISTDeserializer: Deserializer
    211 | 212 |
    213 |
    214 |
    215 |
    216 |
  • 217 |
218 |
219 |
220 |
221 | 222 |
223 |
224 | 228 | 229 | 230 | 231 | -------------------------------------------------------------------------------- /docs/docsets/Configuration.docset/Contents/Resources/Documents/Classes/ConfigurationManager/Source.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Source Enumeration Reference 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 |

23 | 24 | Configuration Docs 25 | 26 | (100% documented) 27 |

28 | 29 |

30 |

31 | 32 |
33 |

34 | 35 |

36 | 37 | 38 | View on GitHub 39 | 40 |

41 | 42 |
43 | 44 | 49 | 50 |
51 | 83 |
84 | 85 |
86 |
87 |

Source

88 |
89 |
90 |
public enum Source
91 | 92 |
93 |
94 |

Enum to specify the configuration source. The supported options are to load configuration 95 | data from either command-line arguments or environment variables.

96 | 97 |
98 |
99 | 100 |
101 |
102 |
103 |
    104 |
  • 105 |
    106 | 107 | 108 | 109 | commandLineArguments 110 | 111 |
    112 |
    113 |
    114 |
    115 |
    116 |
    117 |

    Flag to load configurations from command-line arguments.

    118 | 119 |
    120 |
    121 |

    Declaration

    122 |
    123 |

    Swift

    124 |
    case commandLineArguments
    125 | 126 |
    127 |
    128 |
    129 |
    130 |
  • 131 |
132 |
133 |
134 |
    135 |
  • 136 |
    137 | 138 | 139 | 140 | environmentVariables 141 | 142 |
    143 |
    144 |
    145 |
    146 |
    147 |
    148 |

    Flag to load configurations from environment variables.

    149 | 150 |
    151 |
    152 |

    Declaration

    153 |
    154 |

    Swift

    155 |
    case environmentVariables
    156 | 157 |
    158 |
    159 |
    160 |
    161 |
  • 162 |
163 |
164 |
165 |
166 | 167 |
168 |
169 | 173 | 174 | 175 | 176 | -------------------------------------------------------------------------------- /docs/docsets/Configuration.docset/Contents/Resources/Documents/Classes/JSONDeserializer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | JSONDeserializer Class Reference 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 |

23 | 24 | Configuration Docs 25 | 26 | (100% documented) 27 |

28 | 29 |

30 |

31 | 32 |
33 |

34 | 35 |

36 | 37 | 38 | View on GitHub 39 | 40 |

41 | 42 |
43 | 44 | 49 | 50 |
51 | 83 |
84 | 85 |
86 |
87 |

JSONDeserializer

88 |
89 |
90 |
public class JSONDeserializer: Deserializer
91 | 92 |
93 |
94 |

Default JSON deserializer implementation.

95 | 96 |

Deserializes JSON formatted data using Foundation’s JSONSerialization class.

97 | 98 |
99 |
100 | 101 |
102 |
103 |
104 |
    105 |
  • 106 |
    107 | 108 | 109 | 110 | shared 111 | 112 |
    113 |
    114 |
    115 |
    116 |
    117 |
    118 |

    A shared JSONDeserializer instance.

    119 | 120 |
    121 |
    122 |

    Declaration

    123 |
    124 |

    Swift

    125 |
    public static let shared = JSONDeserializer()
    126 | 127 |
    128 |
    129 |
    130 |
    131 |
  • 132 |
  • 133 |
    134 | 135 | 136 | 137 | name 138 | 139 |
    140 |
    141 |
    142 |
    143 |
    144 |
    145 |

    A unique name that identifies this deserializer.

    146 | 147 |
    148 |
    149 |

    Declaration

    150 |
    151 |

    Swift

    152 |
    public let name = "json"
    153 | 154 |
    155 |
    156 |
    157 |
    158 |
  • 159 |
  • 160 |
    161 | 162 | 163 | 164 | deserialize(data:) 165 | 166 |
    167 |
    168 |
    169 |
    170 |
    171 |
    172 |

    Function that deserializes raw JSON data into a Foundation object.

    173 | 174 |
    175 |
    176 |

    Declaration

    177 |
    178 |

    Swift

    179 |
    public func deserialize(data: Data) throws -> Any
    180 | 181 |
    182 |
    183 |
    184 |

    Parameters

    185 | 186 | 187 | 188 | 193 | 198 | 199 | 200 |
    189 | 190 | data 191 | 192 | 194 |
    195 |

    The raw JSON data to be deserialized.

    196 |
    197 |
    201 |
    202 |
    203 |
    204 |
  • 205 |
206 |
207 |
208 |
209 | 210 |
211 |
212 | 216 | 217 | 218 | 219 | -------------------------------------------------------------------------------- /docs/docsets/Configuration.docset/Contents/Resources/Documents/Classes/PLISTDeserializer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | PLISTDeserializer Class Reference 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 |

23 | 24 | Configuration Docs 25 | 26 | (100% documented) 27 |

28 | 29 |

30 |

31 | 32 |
33 |

34 | 35 |

36 | 37 | 38 | View on GitHub 39 | 40 |

41 | 42 |
43 | 44 | 49 | 50 |
51 | 83 |
84 | 85 |
86 |
87 |

PLISTDeserializer

88 |
89 |
90 |
public class PLISTDeserializer: Deserializer
91 | 92 |
93 |
94 |

Default PLIST deserializer implementation.

95 | 96 |

Deserializes PLIST formatted data using Foundation’s PropertListSerialization class.

97 | 98 |
99 |
100 | 101 |
102 |
103 |
104 |
    105 |
  • 106 |
    107 | 108 | 109 | 110 | shared 111 | 112 |
    113 |
    114 |
    115 |
    116 |
    117 |
    118 |

    A shared PLISTDeserializer instance.

    119 | 120 |
    121 |
    122 |

    Declaration

    123 |
    124 |

    Swift

    125 |
    public static let shared = PLISTDeserializer()
    126 | 127 |
    128 |
    129 |
    130 |
    131 |
  • 132 |
  • 133 |
    134 | 135 | 136 | 137 | name 138 | 139 |
    140 |
    141 |
    142 |
    143 |
    144 |
    145 |

    A unique name that identifies this deserializer.

    146 | 147 |
    148 |
    149 |

    Declaration

    150 |
    151 |

    Swift

    152 |
    public let name = "plist"
    153 | 154 |
    155 |
    156 |
    157 |
    158 |
  • 159 |
  • 160 |
    161 | 162 | 163 | 164 | deserialize(data:) 165 | 166 |
    167 |
    168 |
    169 |
    170 |
    171 |
    172 |

    Function that deserializes raw PLIST data into a Foundation object.

    173 | 174 |
    175 |
    176 |

    Declaration

    177 |
    178 |

    Swift

    179 |
    public func deserialize(data: Data) throws -> Any
    180 | 181 |
    182 |
    183 |
    184 |

    Parameters

    185 | 186 | 187 | 188 | 193 | 198 | 199 | 200 |
    189 | 190 | data 191 | 192 | 194 |
    195 |

    The raw PLIST data to be deserialized.

    196 |
    197 |
    201 |
    202 |
    203 |
    204 |
  • 205 |
206 |
207 |
208 |
209 | 210 |
211 |
212 | 216 | 217 | 218 | 219 | -------------------------------------------------------------------------------- /docs/docsets/Configuration.docset/Contents/Resources/Documents/Protocols.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Protocols Reference 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 |

22 | 23 | Configuration Docs 24 | 25 | (100% documented) 26 |

27 | 28 |

29 |

30 | 31 |
32 |

33 | 34 |

35 | 36 | 37 | View on GitHub 38 | 39 |

40 | 41 |
42 | 43 | 48 | 49 |
50 | 82 |
83 | 84 |
85 |
86 |

Protocols

87 |

The following protocols are available globally.

88 | 89 |
90 |
91 | 92 |
93 |
94 |
95 |
    96 |
  • 97 |
    98 | 99 | 100 | 101 | Deserializer 102 | 103 |
    104 |
    105 |
    106 |
    107 |
    108 |
    109 |

    Deserializer protocol.

    110 | 111 |

    Additional deserializers (i.e. for unsupported file formats) may be used 112 | by implementing this protocol.

    113 | 114 | See more 115 |
    116 |
    117 |

    Declaration

    118 |
    119 |

    Swift

    120 |
    public protocol Deserializer
    121 | 122 |
    123 |
    124 |
    125 |
    126 |
  • 127 |
128 |
129 |
130 |
131 | 132 |
133 |
134 | 138 | 139 | 140 | 141 | -------------------------------------------------------------------------------- /docs/docsets/Configuration.docset/Contents/Resources/Documents/Protocols/Deserializer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Deserializer Protocol Reference 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 |

23 | 24 | Configuration Docs 25 | 26 | (100% documented) 27 |

28 | 29 |

30 |

31 | 32 |
33 |

34 | 35 |

36 | 37 | 38 | View on GitHub 39 | 40 |

41 | 42 |
43 | 44 | 49 | 50 |
51 | 83 |
84 | 85 |
86 |
87 |

Deserializer

88 |
89 |
90 |
public protocol Deserializer
91 | 92 |
93 |
94 |

Deserializer protocol.

95 | 96 |

Additional deserializers (i.e. for unsupported file formats) may be used 97 | by implementing this protocol.

98 | 99 |
100 |
101 | 102 |
103 |
104 |
105 |
    106 |
  • 107 |
    108 | 109 | 110 | 111 | name 112 | 113 |
    114 |
    115 |
    116 |
    117 |
    118 |
    119 |

    A unique name that identifies this deserializer.

    120 | 121 |
    122 |
    123 |

    Declaration

    124 |
    125 |

    Swift

    126 |
    var name: String
    127 | 128 |
    129 |
    130 |
    131 |
    132 |
  • 133 |
  • 134 |
    135 | 136 | 137 | 138 | deserialize(data:) 139 | 140 |
    141 |
    142 |
    143 |
    144 |
    145 |
    146 |

    Function that deserializes raw data into a Foundation object.

    147 | 148 |
    149 |
    150 |

    Declaration

    151 |
    152 |

    Swift

    153 |
    func deserialize(data: Data) throws -> Any
    154 | 155 |
    156 |
    157 |
    158 |

    Parameters

    159 | 160 | 161 | 162 | 167 | 172 | 173 | 174 |
    163 | 164 | data 165 | 166 | 168 |
    169 |

    The raw data to be deserialized.

    170 |
    171 |
    175 |
    176 |
    177 |
    178 |
  • 179 |
180 |
181 |
182 |
183 | 184 |
185 |
186 | 190 | 191 | 192 | 193 | -------------------------------------------------------------------------------- /docs/docsets/Configuration.docset/Contents/Resources/Documents/css/highlight.css: -------------------------------------------------------------------------------- 1 | /* Credit to https://gist.github.com/wataru420/2048287 */ 2 | .highlight { 3 | /* Comment */ 4 | /* Error */ 5 | /* Keyword */ 6 | /* Operator */ 7 | /* Comment.Multiline */ 8 | /* Comment.Preproc */ 9 | /* Comment.Single */ 10 | /* Comment.Special */ 11 | /* Generic.Deleted */ 12 | /* Generic.Deleted.Specific */ 13 | /* Generic.Emph */ 14 | /* Generic.Error */ 15 | /* Generic.Heading */ 16 | /* Generic.Inserted */ 17 | /* Generic.Inserted.Specific */ 18 | /* Generic.Output */ 19 | /* Generic.Prompt */ 20 | /* Generic.Strong */ 21 | /* Generic.Subheading */ 22 | /* Generic.Traceback */ 23 | /* Keyword.Constant */ 24 | /* Keyword.Declaration */ 25 | /* Keyword.Pseudo */ 26 | /* Keyword.Reserved */ 27 | /* Keyword.Type */ 28 | /* Literal.Number */ 29 | /* Literal.String */ 30 | /* Name.Attribute */ 31 | /* Name.Builtin */ 32 | /* Name.Class */ 33 | /* Name.Constant */ 34 | /* Name.Entity */ 35 | /* Name.Exception */ 36 | /* Name.Function */ 37 | /* Name.Namespace */ 38 | /* Name.Tag */ 39 | /* Name.Variable */ 40 | /* Operator.Word */ 41 | /* Text.Whitespace */ 42 | /* Literal.Number.Float */ 43 | /* Literal.Number.Hex */ 44 | /* Literal.Number.Integer */ 45 | /* Literal.Number.Oct */ 46 | /* Literal.String.Backtick */ 47 | /* Literal.String.Char */ 48 | /* Literal.String.Doc */ 49 | /* Literal.String.Double */ 50 | /* Literal.String.Escape */ 51 | /* Literal.String.Heredoc */ 52 | /* Literal.String.Interpol */ 53 | /* Literal.String.Other */ 54 | /* Literal.String.Regex */ 55 | /* Literal.String.Single */ 56 | /* Literal.String.Symbol */ 57 | /* Name.Builtin.Pseudo */ 58 | /* Name.Variable.Class */ 59 | /* Name.Variable.Global */ 60 | /* Name.Variable.Instance */ 61 | /* Literal.Number.Integer.Long */ } 62 | .highlight .c { 63 | color: #999988; 64 | font-style: italic; } 65 | .highlight .err { 66 | color: #a61717; 67 | background-color: #e3d2d2; } 68 | .highlight .k { 69 | color: #000000; 70 | font-weight: bold; } 71 | .highlight .o { 72 | color: #000000; 73 | font-weight: bold; } 74 | .highlight .cm { 75 | color: #999988; 76 | font-style: italic; } 77 | .highlight .cp { 78 | color: #999999; 79 | font-weight: bold; } 80 | .highlight .c1 { 81 | color: #999988; 82 | font-style: italic; } 83 | .highlight .cs { 84 | color: #999999; 85 | font-weight: bold; 86 | font-style: italic; } 87 | .highlight .gd { 88 | color: #000000; 89 | background-color: #ffdddd; } 90 | .highlight .gd .x { 91 | color: #000000; 92 | background-color: #ffaaaa; } 93 | .highlight .ge { 94 | color: #000000; 95 | font-style: italic; } 96 | .highlight .gr { 97 | color: #aa0000; } 98 | .highlight .gh { 99 | color: #999999; } 100 | .highlight .gi { 101 | color: #000000; 102 | background-color: #ddffdd; } 103 | .highlight .gi .x { 104 | color: #000000; 105 | background-color: #aaffaa; } 106 | .highlight .go { 107 | color: #888888; } 108 | .highlight .gp { 109 | color: #555555; } 110 | .highlight .gs { 111 | font-weight: bold; } 112 | .highlight .gu { 113 | color: #aaaaaa; } 114 | .highlight .gt { 115 | color: #aa0000; } 116 | .highlight .kc { 117 | color: #000000; 118 | font-weight: bold; } 119 | .highlight .kd { 120 | color: #000000; 121 | font-weight: bold; } 122 | .highlight .kp { 123 | color: #000000; 124 | font-weight: bold; } 125 | .highlight .kr { 126 | color: #000000; 127 | font-weight: bold; } 128 | .highlight .kt { 129 | color: #445588; } 130 | .highlight .m { 131 | color: #009999; } 132 | .highlight .s { 133 | color: #d14; } 134 | .highlight .na { 135 | color: #008080; } 136 | .highlight .nb { 137 | color: #0086B3; } 138 | .highlight .nc { 139 | color: #445588; 140 | font-weight: bold; } 141 | .highlight .no { 142 | color: #008080; } 143 | .highlight .ni { 144 | color: #800080; } 145 | .highlight .ne { 146 | color: #990000; 147 | font-weight: bold; } 148 | .highlight .nf { 149 | color: #990000; } 150 | .highlight .nn { 151 | color: #555555; } 152 | .highlight .nt { 153 | color: #000080; } 154 | .highlight .nv { 155 | color: #008080; } 156 | .highlight .ow { 157 | color: #000000; 158 | font-weight: bold; } 159 | .highlight .w { 160 | color: #bbbbbb; } 161 | .highlight .mf { 162 | color: #009999; } 163 | .highlight .mh { 164 | color: #009999; } 165 | .highlight .mi { 166 | color: #009999; } 167 | .highlight .mo { 168 | color: #009999; } 169 | .highlight .sb { 170 | color: #d14; } 171 | .highlight .sc { 172 | color: #d14; } 173 | .highlight .sd { 174 | color: #d14; } 175 | .highlight .s2 { 176 | color: #d14; } 177 | .highlight .se { 178 | color: #d14; } 179 | .highlight .sh { 180 | color: #d14; } 181 | .highlight .si { 182 | color: #d14; } 183 | .highlight .sx { 184 | color: #d14; } 185 | .highlight .sr { 186 | color: #009926; } 187 | .highlight .s1 { 188 | color: #d14; } 189 | .highlight .ss { 190 | color: #990073; } 191 | .highlight .bp { 192 | color: #999999; } 193 | .highlight .vc { 194 | color: #008080; } 195 | .highlight .vg { 196 | color: #008080; } 197 | .highlight .vi { 198 | color: #008080; } 199 | .highlight .il { 200 | color: #009999; } 201 | -------------------------------------------------------------------------------- /docs/docsets/Configuration.docset/Contents/Resources/Documents/css/jazzy.css: -------------------------------------------------------------------------------- 1 | *, *:before, *:after { 2 | box-sizing: inherit; } 3 | 4 | body { 5 | margin: 0; 6 | background: #fff; 7 | color: #333; 8 | font: 16px/1.7 "Helvetica Neue", Helvetica, Arial, sans-serif; 9 | letter-spacing: .2px; 10 | -webkit-font-smoothing: antialiased; 11 | box-sizing: border-box; } 12 | 13 | h1 { 14 | font-size: 2rem; 15 | font-weight: 700; 16 | margin: 1.275em 0 0.6em; } 17 | 18 | h2 { 19 | font-size: 1.75rem; 20 | font-weight: 700; 21 | margin: 1.275em 0 0.3em; } 22 | 23 | h3 { 24 | font-size: 1.5rem; 25 | font-weight: 700; 26 | margin: 1em 0 0.3em; } 27 | 28 | h4 { 29 | font-size: 1.25rem; 30 | font-weight: 700; 31 | margin: 1.275em 0 0.85em; } 32 | 33 | h5 { 34 | font-size: 1rem; 35 | font-weight: 700; 36 | margin: 1.275em 0 0.85em; } 37 | 38 | h6 { 39 | font-size: 1rem; 40 | font-weight: 700; 41 | margin: 1.275em 0 0.85em; 42 | color: #777; } 43 | 44 | p { 45 | margin: 0 0 1em; } 46 | 47 | ul, ol { 48 | padding: 0 0 0 2em; 49 | margin: 0 0 0.85em; } 50 | 51 | blockquote { 52 | margin: 0 0 0.85em; 53 | padding: 0 15px; 54 | color: #858585; 55 | border-left: 4px solid #e5e5e5; } 56 | 57 | img { 58 | max-width: 100%; } 59 | 60 | a { 61 | color: #4183c4; 62 | text-decoration: none; } 63 | a:hover, a:focus { 64 | outline: 0; 65 | text-decoration: underline; } 66 | 67 | table { 68 | background: #fff; 69 | width: 100%; 70 | border-collapse: collapse; 71 | border-spacing: 0; 72 | overflow: auto; 73 | margin: 0 0 0.85em; } 74 | 75 | tr:nth-child(2n) { 76 | background-color: #fbfbfb; } 77 | 78 | th, td { 79 | padding: 6px 13px; 80 | border: 1px solid #ddd; } 81 | 82 | pre { 83 | margin: 0 0 1.275em; 84 | padding: .85em 1em; 85 | overflow: auto; 86 | background: #f7f7f7; 87 | font-size: .85em; 88 | font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; } 89 | 90 | code { 91 | font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; } 92 | 93 | p > code, li > code { 94 | background: #f7f7f7; 95 | padding: .2em; } 96 | p > code:before, p > code:after, li > code:before, li > code:after { 97 | letter-spacing: -.2em; 98 | content: "\00a0"; } 99 | 100 | pre code { 101 | padding: 0; 102 | white-space: pre; } 103 | 104 | .content-wrapper { 105 | display: flex; 106 | flex-direction: column; } 107 | @media (min-width: 768px) { 108 | .content-wrapper { 109 | flex-direction: row; } } 110 | 111 | .header { 112 | display: flex; 113 | padding: 8px; 114 | font-size: 0.875em; 115 | background: #444; 116 | color: #999; } 117 | 118 | .header-col { 119 | margin: 0; 120 | padding: 0 8px; } 121 | 122 | .header-col--primary { 123 | flex: 1; } 124 | 125 | .header-link { 126 | color: #fff; } 127 | 128 | .header-icon { 129 | padding-right: 6px; 130 | vertical-align: -4px; 131 | height: 16px; } 132 | 133 | .breadcrumbs { 134 | font-size: 0.875em; 135 | padding: 8px 16px; 136 | margin: 0; 137 | background: #fbfbfb; 138 | border-bottom: 1px solid #ddd; } 139 | 140 | .carat { 141 | height: 10px; 142 | margin: 0 5px; } 143 | 144 | .navigation { 145 | order: 2; } 146 | @media (min-width: 768px) { 147 | .navigation { 148 | order: 1; 149 | width: 25%; 150 | max-width: 300px; 151 | padding-bottom: 64px; 152 | overflow: hidden; 153 | word-wrap: normal; 154 | background: #fbfbfb; 155 | border-right: 1px solid #ddd; } } 156 | 157 | .nav-groups { 158 | list-style-type: none; 159 | padding-left: 0; } 160 | 161 | .nav-group-name { 162 | border-bottom: 1px solid #ddd; 163 | padding: 8px 0 8px 16px; } 164 | 165 | .nav-group-name-link { 166 | color: #333; } 167 | 168 | .nav-group-tasks { 169 | margin: 8px 0; 170 | padding: 0 0 0 8px; } 171 | 172 | .nav-group-task { 173 | font-size: 1em; 174 | list-style-type: none; 175 | white-space: nowrap; } 176 | 177 | .nav-group-task-link { 178 | color: #808080; } 179 | 180 | .main-content { 181 | order: 1; } 182 | @media (min-width: 768px) { 183 | .main-content { 184 | order: 2; 185 | flex: 1; 186 | padding-bottom: 60px; } } 187 | 188 | .section { 189 | padding: 0 32px; 190 | border-bottom: 1px solid #ddd; } 191 | 192 | .section-content { 193 | max-width: 834px; 194 | margin: 0 auto; 195 | padding: 16px 0; } 196 | 197 | .section-name { 198 | color: #666; 199 | display: block; } 200 | 201 | .declaration .highlight { 202 | overflow-x: initial; 203 | padding: 8px 0; 204 | margin: 0; 205 | background-color: transparent; 206 | border: none; } 207 | 208 | .task-group-section { 209 | border-top: 1px solid #ddd; } 210 | 211 | .task-group { 212 | padding-top: 0px; } 213 | 214 | .task-name-container a[name]:before { 215 | content: ""; 216 | display: block; } 217 | 218 | .item-container { 219 | padding: 0; } 220 | 221 | .item { 222 | padding-top: 8px; 223 | width: 100%; 224 | list-style-type: none; } 225 | .item a[name]:before { 226 | content: ""; 227 | display: block; } 228 | .item .token { 229 | padding-left: 3px; 230 | margin-left: 0px; 231 | font-size: 1rem; } 232 | .item .declaration-note { 233 | font-size: .85em; 234 | color: #808080; 235 | font-style: italic; } 236 | 237 | .pointer-container { 238 | border-bottom: 1px solid #ddd; 239 | left: -23px; 240 | padding-bottom: 13px; 241 | position: relative; 242 | width: 110%; } 243 | 244 | .pointer { 245 | left: 21px; 246 | top: 7px; 247 | display: block; 248 | position: absolute; 249 | width: 12px; 250 | height: 12px; 251 | border-left: 1px solid #ddd; 252 | border-top: 1px solid #ddd; 253 | background: #fff; 254 | transform: rotate(45deg); } 255 | 256 | .height-container { 257 | display: none; 258 | position: relative; 259 | width: 100%; 260 | overflow: hidden; } 261 | .height-container .section { 262 | background: #fff; 263 | border: 1px solid #ddd; 264 | border-top-width: 0; 265 | padding-top: 10px; 266 | padding-bottom: 5px; 267 | padding: 8px 16px; } 268 | 269 | .aside, .language { 270 | padding: 6px 12px; 271 | margin: 12px 0; 272 | border-left: 5px solid #dddddd; 273 | overflow-y: hidden; } 274 | .aside .aside-title, .language .aside-title { 275 | font-size: 9px; 276 | letter-spacing: 2px; 277 | text-transform: uppercase; 278 | padding-bottom: 0; 279 | margin: 0; 280 | color: #aaa; 281 | -webkit-user-select: none; } 282 | .aside p:last-child, .language p:last-child { 283 | margin-bottom: 0; } 284 | 285 | .language { 286 | border-left: 5px solid #cde9f4; } 287 | .language .aside-title { 288 | color: #4183c4; } 289 | 290 | .aside-warning { 291 | border-left: 5px solid #ff6666; } 292 | .aside-warning .aside-title { 293 | color: #ff0000; } 294 | 295 | .graybox { 296 | border-collapse: collapse; 297 | width: 100%; } 298 | .graybox p { 299 | margin: 0; 300 | word-break: break-word; 301 | min-width: 50px; } 302 | .graybox td { 303 | border: 1px solid #ddd; 304 | padding: 5px 25px 5px 10px; 305 | vertical-align: middle; } 306 | .graybox tr td:first-of-type { 307 | text-align: right; 308 | padding: 7px; 309 | vertical-align: top; 310 | word-break: normal; 311 | width: 40px; } 312 | 313 | .slightly-smaller { 314 | font-size: 0.9em; } 315 | 316 | .footer { 317 | padding: 8px 16px; 318 | background: #444; 319 | color: #ddd; 320 | font-size: 0.8em; } 321 | .footer p { 322 | margin: 8px 0; } 323 | .footer a { 324 | color: #fff; } 325 | 326 | html.dash .header, html.dash .breadcrumbs, html.dash .navigation { 327 | display: none; } 328 | html.dash .height-container { 329 | display: block; } 330 | 331 | form[role=search] input { 332 | font: 16px/1.7 "Helvetica Neue", Helvetica, Arial, sans-serif; 333 | font-size: 14px; 334 | line-height: 24px; 335 | padding: 0 10px; 336 | margin: 0; 337 | border: none; 338 | border-radius: 1em; } 339 | .loading form[role=search] input { 340 | background: white url(../img/spinner.gif) center right 4px no-repeat; } 341 | form[role=search] .tt-menu { 342 | margin: 0; 343 | min-width: 300px; 344 | background: #fbfbfb; 345 | color: #333; 346 | border: 1px solid #ddd; } 347 | form[role=search] .tt-highlight { 348 | font-weight: bold; } 349 | form[role=search] .tt-suggestion { 350 | font: 16px/1.7 "Helvetica Neue", Helvetica, Arial, sans-serif; 351 | padding: 0 8px; } 352 | form[role=search] .tt-suggestion span { 353 | display: table-cell; 354 | white-space: nowrap; } 355 | form[role=search] .tt-suggestion .doc-parent-name { 356 | width: 100%; 357 | text-align: right; 358 | font-weight: normal; 359 | font-size: 0.9em; 360 | padding-left: 16px; } 361 | form[role=search] .tt-suggestion:hover, 362 | form[role=search] .tt-suggestion.tt-cursor { 363 | cursor: pointer; 364 | background-color: #4183c4; 365 | color: #fff; } 366 | form[role=search] .tt-suggestion:hover .doc-parent-name, 367 | form[role=search] .tt-suggestion.tt-cursor .doc-parent-name { 368 | color: #fff; } 369 | -------------------------------------------------------------------------------- /docs/docsets/Configuration.docset/Contents/Resources/Documents/img/carat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kitura/Configuration/75fb96405263e72a2ed4546dceebe0993b92eb79/docs/docsets/Configuration.docset/Contents/Resources/Documents/img/carat.png -------------------------------------------------------------------------------- /docs/docsets/Configuration.docset/Contents/Resources/Documents/img/dash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kitura/Configuration/75fb96405263e72a2ed4546dceebe0993b92eb79/docs/docsets/Configuration.docset/Contents/Resources/Documents/img/dash.png -------------------------------------------------------------------------------- /docs/docsets/Configuration.docset/Contents/Resources/Documents/img/gh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kitura/Configuration/75fb96405263e72a2ed4546dceebe0993b92eb79/docs/docsets/Configuration.docset/Contents/Resources/Documents/img/gh.png -------------------------------------------------------------------------------- /docs/docsets/Configuration.docset/Contents/Resources/Documents/img/spinner.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kitura/Configuration/75fb96405263e72a2ed4546dceebe0993b92eb79/docs/docsets/Configuration.docset/Contents/Resources/Documents/img/spinner.gif -------------------------------------------------------------------------------- /docs/docsets/Configuration.docset/Contents/Resources/Documents/js/jazzy.js: -------------------------------------------------------------------------------- 1 | window.jazzy = {'docset': false} 2 | if (typeof window.dash != 'undefined') { 3 | document.documentElement.className += ' dash' 4 | window.jazzy.docset = true 5 | } 6 | if (navigator.userAgent.match(/xcode/i)) { 7 | document.documentElement.className += ' xcode' 8 | window.jazzy.docset = true 9 | } 10 | 11 | // On doc load, toggle the URL hash discussion if present 12 | $(document).ready(function() { 13 | if (!window.jazzy.docset) { 14 | var linkToHash = $('a[href="' + window.location.hash +'"]'); 15 | linkToHash.trigger("click"); 16 | } 17 | }); 18 | 19 | // On token click, toggle its discussion and animate token.marginLeft 20 | $(".token").click(function(event) { 21 | if (window.jazzy.docset) { 22 | return; 23 | } 24 | var link = $(this); 25 | var animationDuration = 300; 26 | $content = link.parent().parent().next(); 27 | $content.slideToggle(animationDuration); 28 | 29 | // Keeps the document from jumping to the hash. 30 | var href = $(this).attr('href'); 31 | if (history.pushState) { 32 | history.pushState({}, '', href); 33 | } else { 34 | location.hash = href; 35 | } 36 | event.preventDefault(); 37 | }); 38 | 39 | // Dumb down quotes within code blocks that delimit strings instead of quotations 40 | // https://github.com/realm/jazzy/issues/714 41 | $("code q").replaceWith(function () { 42 | return ["\"", $(this).contents(), "\""]; 43 | }); 44 | -------------------------------------------------------------------------------- /docs/docsets/Configuration.docset/Contents/Resources/Documents/js/jazzy.search.js: -------------------------------------------------------------------------------- 1 | $(function(){ 2 | var searchIndex = lunr(function() { 3 | this.ref('url'); 4 | this.field('name'); 5 | }); 6 | 7 | var $typeahead = $('[data-typeahead]'); 8 | var $form = $typeahead.parents('form'); 9 | var searchURL = $form.attr('action'); 10 | 11 | function displayTemplate(result) { 12 | return result.name; 13 | } 14 | 15 | function suggestionTemplate(result) { 16 | var t = '
'; 17 | t += '' + result.name + ''; 18 | if (result.parent_name) { 19 | t += '' + result.parent_name + ''; 20 | } 21 | t += '
'; 22 | return t; 23 | } 24 | 25 | $typeahead.one('focus', function() { 26 | $form.addClass('loading'); 27 | 28 | $.getJSON(searchURL).then(function(searchData) { 29 | $.each(searchData, function (url, doc) { 30 | searchIndex.add({url: url, name: doc.name}); 31 | }); 32 | 33 | $typeahead.typeahead( 34 | { 35 | highlight: true, 36 | minLength: 3 37 | }, 38 | { 39 | limit: 10, 40 | display: displayTemplate, 41 | templates: { suggestion: suggestionTemplate }, 42 | source: function(query, sync) { 43 | var results = searchIndex.search(query).map(function(result) { 44 | var doc = searchData[result.ref]; 45 | doc.url = result.ref; 46 | return doc; 47 | }); 48 | sync(results); 49 | } 50 | } 51 | ); 52 | $form.removeClass('loading'); 53 | $typeahead.trigger('focus'); 54 | }); 55 | }); 56 | 57 | var baseURL = searchURL.slice(0, -"search.json".length); 58 | 59 | $typeahead.on('typeahead:select', function(e, result) { 60 | window.location = baseURL + result.url; 61 | }); 62 | }); 63 | -------------------------------------------------------------------------------- /docs/docsets/Configuration.docset/Contents/Resources/Documents/search.json: -------------------------------------------------------------------------------- 1 | {"Protocols/Deserializer.html#/s:13Configuration12DeserializerP4nameSSv":{"name":"name","abstract":"

A unique name that identifies this deserializer.

","parent_name":"Deserializer"},"Protocols/Deserializer.html#/s:13Configuration12DeserializerP11deserializeyp10Foundation4DataV4data_tKF":{"name":"deserialize(data:)","abstract":"

Function that deserializes raw data into a Foundation object.

","parent_name":"Deserializer"},"Protocols/Deserializer.html":{"name":"Deserializer","abstract":"

Deserializer protocol.

"},"Classes/PLISTDeserializer.html#/s:13Configuration17PLISTDeserializerC6sharedACvZ":{"name":"shared","abstract":"

A shared PLISTDeserializer instance.

","parent_name":"PLISTDeserializer"},"Classes/PLISTDeserializer.html#/s:13Configuration17PLISTDeserializerC4nameSSv":{"name":"name","abstract":"

A unique name that identifies this deserializer.

","parent_name":"PLISTDeserializer"},"Classes/PLISTDeserializer.html#/s:13Configuration17PLISTDeserializerC11deserializeyp10Foundation4DataV4data_tKF":{"name":"deserialize(data:)","abstract":"

Function that deserializes raw PLIST data into a Foundation object.

","parent_name":"PLISTDeserializer"},"Classes/JSONDeserializer.html#/s:13Configuration16JSONDeserializerC6sharedACvZ":{"name":"shared","abstract":"

A shared JSONDeserializer instance.

","parent_name":"JSONDeserializer"},"Classes/JSONDeserializer.html#/s:13Configuration16JSONDeserializerC4nameSSv":{"name":"name","abstract":"

A unique name that identifies this deserializer.

","parent_name":"JSONDeserializer"},"Classes/JSONDeserializer.html#/s:13Configuration16JSONDeserializerC11deserializeyp10Foundation4DataV4data_tKF":{"name":"deserialize(data:)","abstract":"

Function that deserializes raw JSON data into a Foundation object.

","parent_name":"JSONDeserializer"},"Classes/ConfigurationManager/BasePath.html#/s:13Configuration0A7ManagerC8BasePathO10executableA2EmF":{"name":"executable","abstract":"

Relative to the directory containing the executable itself.

","parent_name":"BasePath"},"Classes/ConfigurationManager/BasePath.html#/s:13Configuration0A7ManagerC8BasePathO7projectA2EmF":{"name":"project","abstract":"

Relative to the project directory. (This is the directory containing the Package.swift of the project, determined by traversing up the directory structure starting at the directory containing the executable).

","parent_name":"BasePath"},"Classes/ConfigurationManager/BasePath.html#/s:13Configuration0A7ManagerC8BasePathO3pwdA2EmF":{"name":"pwd","abstract":"

Relative to the present working directory (PWD).

","parent_name":"BasePath"},"Classes/ConfigurationManager/BasePath.html#/s:13Configuration0A7ManagerC8BasePathO06customD0AESScAEmF":{"name":"customPath","abstract":"

Relative to a custom location passed in by String.

","parent_name":"BasePath"},"Classes/ConfigurationManager/BasePath.html#/s:13Configuration0A7ManagerC8BasePathO4pathSSv":{"name":"path","abstract":"

Get the absolute path, as denoted by self.

","parent_name":"BasePath"},"Classes/ConfigurationManager/Source.html#/s:13Configuration0A7ManagerC6SourceO20commandLineArgumentsA2EmF":{"name":"commandLineArguments","abstract":"

Flag to load configurations from command-line arguments.

","parent_name":"Source"},"Classes/ConfigurationManager/Source.html#/s:13Configuration0A7ManagerC6SourceO20environmentVariablesA2EmF":{"name":"environmentVariables","abstract":"

Flag to load configurations from environment variables.

","parent_name":"Source"},"Classes/ConfigurationManager.html#/s:13Configuration0A7ManagerC28commandLineArgumentKeyPrefixSSv":{"name":"commandLineArgumentKeyPrefix","abstract":"

Prefix used to denote a command line argument as a configuration path-value pair. Defaults to --

","parent_name":"ConfigurationManager"},"Classes/ConfigurationManager.html#/s:13Configuration0A7ManagerC32commandLineArgumentPathSeparatorSSv":{"name":"commandLineArgumentPathSeparator","abstract":"

Path separator to specify the components of a path that is passed in as a command line argument. Defaults to .

","parent_name":"ConfigurationManager"},"Classes/ConfigurationManager.html#/s:13Configuration0A7ManagerC32environmentVariablePathSeparatorSSv":{"name":"environmentVariablePathSeparator","abstract":"

Path separator to specify the components of a path that is passed in as an environment variable. Defaults to __

","parent_name":"ConfigurationManager"},"Classes/ConfigurationManager.html#/s:13Configuration0A7ManagerC19parseStringToObjectSbv":{"name":"parseStringToObject","abstract":"

Used to indicate if string values in command-line arguments and environment variables should be parsed to","parent_name":"ConfigurationManager"},"Classes/ConfigurationManager/Source.html":{"name":"Source","abstract":"

Enum to specify the configuration source. The supported options are to load configuration","parent_name":"ConfigurationManager"},"Classes/ConfigurationManager/BasePath.html":{"name":"BasePath","abstract":"

Base paths for resolving relative paths.

","parent_name":"ConfigurationManager"},"Classes/ConfigurationManager.html#/s:13Configuration0A7ManagerCACSS28commandLineArgumentKeyPrefix_SS0cdE13PathSeparatorSS019environmentVariablehI0Sb19parseStringToObjecttcfc":{"name":"init(commandLineArgumentKeyPrefix:commandLineArgumentPathSeparator:environmentVariablePathSeparator:parseStringToObject:)","abstract":"

Create a customized instance of ConfigurationManager. Used to customize the default prefix,","parent_name":"ConfigurationManager"},"Classes/ConfigurationManager.html#/s:13Configuration0A7ManagerC4loadACypF":{"name":"load(_:)","abstract":"

Load configurations from a raw object.

","parent_name":"ConfigurationManager"},"Classes/ConfigurationManager.html#/s:13Configuration0A7ManagerC4loadA2C6SourceOF":{"name":"load(_:)","abstract":"

Load configurations from command-line arguments or environment variables.","parent_name":"ConfigurationManager"},"Classes/ConfigurationManager.html#/s:13Configuration0A7ManagerC4loadAC10Foundation4DataV4data_SSSg16deserializerNametF":{"name":"load(data:deserializerName:)","abstract":"

Load configurations from a Data object.

","parent_name":"ConfigurationManager"},"Classes/ConfigurationManager.html#/s:13Configuration0A7ManagerC4loadACSS4file_AC8BasePathO12relativeFromSSSg16deserializerNametF":{"name":"load(file:relativeFrom:deserializerName:)","abstract":"

Load configurations from a file.

","parent_name":"ConfigurationManager"},"Classes/ConfigurationManager.html#/s:13Configuration0A7ManagerC4loadAC10Foundation3URLV3url_SSSg16deserializerNametF":{"name":"load(url:deserializerName:)","abstract":"

Load configurations from a URL location.

","parent_name":"ConfigurationManager"},"Classes/ConfigurationManager.html#/s:13Configuration0A7ManagerC3useAcA12Deserializer_pF":{"name":"use(_:)","abstract":"

Add a deserializer to the list of deserializers that can be used to parse raw data.

","parent_name":"ConfigurationManager"},"Classes/ConfigurationManager.html#/s:13Configuration0A7ManagerC10getConfigsypyF":{"name":"getConfigs()","abstract":"

Get all configurations that have been merged into the ConfigurationManager as a raw object.

","parent_name":"ConfigurationManager"},"Classes/ConfigurationManager.html#/s:13Configuration0A7ManagerC9subscriptypSgSSci":{"name":"subscript(_:)","abstract":"

Access configurations by path.

","parent_name":"ConfigurationManager"},"Classes/ConfigurationManager.html":{"name":"ConfigurationManager","abstract":"

A one-stop shop to aggregate configuration properties from different sources, including"},"Classes/JSONDeserializer.html":{"name":"JSONDeserializer","abstract":"

Default JSON deserializer implementation.

"},"Classes/PLISTDeserializer.html":{"name":"PLISTDeserializer","abstract":"

Default PLIST deserializer implementation.

"},"Classes.html":{"name":"Classes","abstract":"

The following classes are available globally.

"},"Protocols.html":{"name":"Protocols","abstract":"

The following protocols are available globally.

"}} -------------------------------------------------------------------------------- /docs/docsets/Configuration.docset/Contents/Resources/docSet.dsidx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kitura/Configuration/75fb96405263e72a2ed4546dceebe0993b92eb79/docs/docsets/Configuration.docset/Contents/Resources/docSet.dsidx -------------------------------------------------------------------------------- /docs/docsets/Configuration.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kitura/Configuration/75fb96405263e72a2ed4546dceebe0993b92eb79/docs/docsets/Configuration.tgz -------------------------------------------------------------------------------- /docs/img/carat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kitura/Configuration/75fb96405263e72a2ed4546dceebe0993b92eb79/docs/img/carat.png -------------------------------------------------------------------------------- /docs/img/dash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kitura/Configuration/75fb96405263e72a2ed4546dceebe0993b92eb79/docs/img/dash.png -------------------------------------------------------------------------------- /docs/img/gh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kitura/Configuration/75fb96405263e72a2ed4546dceebe0993b92eb79/docs/img/gh.png -------------------------------------------------------------------------------- /docs/img/spinner.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kitura/Configuration/75fb96405263e72a2ed4546dceebe0993b92eb79/docs/img/spinner.gif -------------------------------------------------------------------------------- /docs/js/jazzy.js: -------------------------------------------------------------------------------- 1 | window.jazzy = {'docset': false} 2 | if (typeof window.dash != 'undefined') { 3 | document.documentElement.className += ' dash' 4 | window.jazzy.docset = true 5 | } 6 | if (navigator.userAgent.match(/xcode/i)) { 7 | document.documentElement.className += ' xcode' 8 | window.jazzy.docset = true 9 | } 10 | 11 | // On doc load, toggle the URL hash discussion if present 12 | $(document).ready(function() { 13 | if (!window.jazzy.docset) { 14 | var linkToHash = $('a[href="' + window.location.hash +'"]'); 15 | linkToHash.trigger("click"); 16 | } 17 | }); 18 | 19 | // On token click, toggle its discussion and animate token.marginLeft 20 | $(".token").click(function(event) { 21 | if (window.jazzy.docset) { 22 | return; 23 | } 24 | var link = $(this); 25 | var animationDuration = 300; 26 | $content = link.parent().parent().next(); 27 | $content.slideToggle(animationDuration); 28 | 29 | // Keeps the document from jumping to the hash. 30 | var href = $(this).attr('href'); 31 | if (history.pushState) { 32 | history.pushState({}, '', href); 33 | } else { 34 | location.hash = href; 35 | } 36 | event.preventDefault(); 37 | }); 38 | 39 | // Dumb down quotes within code blocks that delimit strings instead of quotations 40 | // https://github.com/realm/jazzy/issues/714 41 | $("code q").replaceWith(function () { 42 | return ["\"", $(this).contents(), "\""]; 43 | }); 44 | -------------------------------------------------------------------------------- /docs/js/jazzy.search.js: -------------------------------------------------------------------------------- 1 | $(function(){ 2 | var searchIndex = lunr(function() { 3 | this.ref('url'); 4 | this.field('name'); 5 | }); 6 | 7 | var $typeahead = $('[data-typeahead]'); 8 | var $form = $typeahead.parents('form'); 9 | var searchURL = $form.attr('action'); 10 | 11 | function displayTemplate(result) { 12 | return result.name; 13 | } 14 | 15 | function suggestionTemplate(result) { 16 | var t = '
'; 17 | t += '' + result.name + ''; 18 | if (result.parent_name) { 19 | t += '' + result.parent_name + ''; 20 | } 21 | t += '
'; 22 | return t; 23 | } 24 | 25 | $typeahead.one('focus', function() { 26 | $form.addClass('loading'); 27 | 28 | $.getJSON(searchURL).then(function(searchData) { 29 | $.each(searchData, function (url, doc) { 30 | searchIndex.add({url: url, name: doc.name}); 31 | }); 32 | 33 | $typeahead.typeahead( 34 | { 35 | highlight: true, 36 | minLength: 3 37 | }, 38 | { 39 | limit: 10, 40 | display: displayTemplate, 41 | templates: { suggestion: suggestionTemplate }, 42 | source: function(query, sync) { 43 | var results = searchIndex.search(query).map(function(result) { 44 | var doc = searchData[result.ref]; 45 | doc.url = result.ref; 46 | return doc; 47 | }); 48 | sync(results); 49 | } 50 | } 51 | ); 52 | $form.removeClass('loading'); 53 | $typeahead.trigger('focus'); 54 | }); 55 | }); 56 | 57 | var baseURL = searchURL.slice(0, -"search.json".length); 58 | 59 | $typeahead.on('typeahead:select', function(e, result) { 60 | window.location = baseURL + result.url; 61 | }); 62 | }); 63 | -------------------------------------------------------------------------------- /docs/search.json: -------------------------------------------------------------------------------- 1 | {"Protocols/Deserializer.html#/s:13Configuration12DeserializerP4nameSSv":{"name":"name","abstract":"

A unique name that identifies this deserializer.

","parent_name":"Deserializer"},"Protocols/Deserializer.html#/s:13Configuration12DeserializerP11deserializeyp10Foundation4DataV4data_tKF":{"name":"deserialize(data:)","abstract":"

Function that deserializes raw data into a Foundation object.

","parent_name":"Deserializer"},"Protocols/Deserializer.html":{"name":"Deserializer","abstract":"

Deserializer protocol.

"},"Classes/PLISTDeserializer.html#/s:13Configuration17PLISTDeserializerC6sharedACvZ":{"name":"shared","abstract":"

A shared PLISTDeserializer instance.

","parent_name":"PLISTDeserializer"},"Classes/PLISTDeserializer.html#/s:13Configuration17PLISTDeserializerC4nameSSv":{"name":"name","abstract":"

A unique name that identifies this deserializer.

","parent_name":"PLISTDeserializer"},"Classes/PLISTDeserializer.html#/s:13Configuration17PLISTDeserializerC11deserializeyp10Foundation4DataV4data_tKF":{"name":"deserialize(data:)","abstract":"

Function that deserializes raw PLIST data into a Foundation object.

","parent_name":"PLISTDeserializer"},"Classes/JSONDeserializer.html#/s:13Configuration16JSONDeserializerC6sharedACvZ":{"name":"shared","abstract":"

A shared JSONDeserializer instance.

","parent_name":"JSONDeserializer"},"Classes/JSONDeserializer.html#/s:13Configuration16JSONDeserializerC4nameSSv":{"name":"name","abstract":"

A unique name that identifies this deserializer.

","parent_name":"JSONDeserializer"},"Classes/JSONDeserializer.html#/s:13Configuration16JSONDeserializerC11deserializeyp10Foundation4DataV4data_tKF":{"name":"deserialize(data:)","abstract":"

Function that deserializes raw JSON data into a Foundation object.

","parent_name":"JSONDeserializer"},"Classes/ConfigurationManager/BasePath.html#/s:13Configuration0A7ManagerC8BasePathO10executableA2EmF":{"name":"executable","abstract":"

Relative to the directory containing the executable itself.

","parent_name":"BasePath"},"Classes/ConfigurationManager/BasePath.html#/s:13Configuration0A7ManagerC8BasePathO7projectA2EmF":{"name":"project","abstract":"

Relative to the project directory. (This is the directory containing the Package.swift of the project, determined by traversing up the directory structure starting at the directory containing the executable).

","parent_name":"BasePath"},"Classes/ConfigurationManager/BasePath.html#/s:13Configuration0A7ManagerC8BasePathO3pwdA2EmF":{"name":"pwd","abstract":"

Relative to the present working directory (PWD).

","parent_name":"BasePath"},"Classes/ConfigurationManager/BasePath.html#/s:13Configuration0A7ManagerC8BasePathO06customD0AESScAEmF":{"name":"customPath","abstract":"

Relative to a custom location passed in by String.

","parent_name":"BasePath"},"Classes/ConfigurationManager/BasePath.html#/s:13Configuration0A7ManagerC8BasePathO4pathSSv":{"name":"path","abstract":"

Get the absolute path, as denoted by self.

","parent_name":"BasePath"},"Classes/ConfigurationManager/Source.html#/s:13Configuration0A7ManagerC6SourceO20commandLineArgumentsA2EmF":{"name":"commandLineArguments","abstract":"

Flag to load configurations from command-line arguments.

","parent_name":"Source"},"Classes/ConfigurationManager/Source.html#/s:13Configuration0A7ManagerC6SourceO20environmentVariablesA2EmF":{"name":"environmentVariables","abstract":"

Flag to load configurations from environment variables.

","parent_name":"Source"},"Classes/ConfigurationManager.html#/s:13Configuration0A7ManagerC28commandLineArgumentKeyPrefixSSv":{"name":"commandLineArgumentKeyPrefix","abstract":"

Prefix used to denote a command line argument as a configuration path-value pair. Defaults to --

","parent_name":"ConfigurationManager"},"Classes/ConfigurationManager.html#/s:13Configuration0A7ManagerC32commandLineArgumentPathSeparatorSSv":{"name":"commandLineArgumentPathSeparator","abstract":"

Path separator to specify the components of a path that is passed in as a command line argument. Defaults to .

","parent_name":"ConfigurationManager"},"Classes/ConfigurationManager.html#/s:13Configuration0A7ManagerC32environmentVariablePathSeparatorSSv":{"name":"environmentVariablePathSeparator","abstract":"

Path separator to specify the components of a path that is passed in as an environment variable. Defaults to __

","parent_name":"ConfigurationManager"},"Classes/ConfigurationManager.html#/s:13Configuration0A7ManagerC19parseStringToObjectSbv":{"name":"parseStringToObject","abstract":"

Used to indicate if string values in command-line arguments and environment variables should be parsed to","parent_name":"ConfigurationManager"},"Classes/ConfigurationManager/Source.html":{"name":"Source","abstract":"

Enum to specify the configuration source. The supported options are to load configuration","parent_name":"ConfigurationManager"},"Classes/ConfigurationManager/BasePath.html":{"name":"BasePath","abstract":"

Base paths for resolving relative paths.

","parent_name":"ConfigurationManager"},"Classes/ConfigurationManager.html#/s:13Configuration0A7ManagerCACSS28commandLineArgumentKeyPrefix_SS0cdE13PathSeparatorSS019environmentVariablehI0Sb19parseStringToObjecttcfc":{"name":"init(commandLineArgumentKeyPrefix:commandLineArgumentPathSeparator:environmentVariablePathSeparator:parseStringToObject:)","abstract":"

Create a customized instance of ConfigurationManager. Used to customize the default prefix,","parent_name":"ConfigurationManager"},"Classes/ConfigurationManager.html#/s:13Configuration0A7ManagerC4loadACypF":{"name":"load(_:)","abstract":"

Load configurations from a raw object.

","parent_name":"ConfigurationManager"},"Classes/ConfigurationManager.html#/s:13Configuration0A7ManagerC4loadA2C6SourceOF":{"name":"load(_:)","abstract":"

Load configurations from command-line arguments or environment variables.","parent_name":"ConfigurationManager"},"Classes/ConfigurationManager.html#/s:13Configuration0A7ManagerC4loadAC10Foundation4DataV4data_SSSg16deserializerNametF":{"name":"load(data:deserializerName:)","abstract":"

Load configurations from a Data object.

","parent_name":"ConfigurationManager"},"Classes/ConfigurationManager.html#/s:13Configuration0A7ManagerC4loadACSS4file_AC8BasePathO12relativeFromSSSg16deserializerNametF":{"name":"load(file:relativeFrom:deserializerName:)","abstract":"

Load configurations from a file.

","parent_name":"ConfigurationManager"},"Classes/ConfigurationManager.html#/s:13Configuration0A7ManagerC4loadAC10Foundation3URLV3url_SSSg16deserializerNametF":{"name":"load(url:deserializerName:)","abstract":"

Load configurations from a URL location.

","parent_name":"ConfigurationManager"},"Classes/ConfigurationManager.html#/s:13Configuration0A7ManagerC3useAcA12Deserializer_pF":{"name":"use(_:)","abstract":"

Add a deserializer to the list of deserializers that can be used to parse raw data.

","parent_name":"ConfigurationManager"},"Classes/ConfigurationManager.html#/s:13Configuration0A7ManagerC10getConfigsypyF":{"name":"getConfigs()","abstract":"

Get all configurations that have been merged into the ConfigurationManager as a raw object.

","parent_name":"ConfigurationManager"},"Classes/ConfigurationManager.html#/s:13Configuration0A7ManagerC9subscriptypSgSSci":{"name":"subscript(_:)","abstract":"

Access configurations by path.

","parent_name":"ConfigurationManager"},"Classes/ConfigurationManager.html":{"name":"ConfigurationManager","abstract":"

A one-stop shop to aggregate configuration properties from different sources, including"},"Classes/JSONDeserializer.html":{"name":"JSONDeserializer","abstract":"

Default JSON deserializer implementation.

"},"Classes/PLISTDeserializer.html":{"name":"PLISTDeserializer","abstract":"

Default PLIST deserializer implementation.

"},"Classes.html":{"name":"Classes","abstract":"

The following classes are available globally.

"},"Protocols.html":{"name":"Protocols","abstract":"

The following protocols are available globally.

"}} -------------------------------------------------------------------------------- /docs/undocumented.json: -------------------------------------------------------------------------------- 1 | { 2 | "warnings": [ 3 | 4 | ], 5 | "source_directory": "/Users/travis/build/IBM-Swift/Configuration" 6 | } --------------------------------------------------------------------------------