Skip to content

Commit 590feac

Browse files
authored
Bump version to 0.11.0 (#176)
* Bump version to 0.11.0 * Link to relevant issues and PRs in CHANGELOG.md
1 parent 9eb98ba commit 590feac

File tree

5 files changed

+112
-14
lines changed

5 files changed

+112
-14
lines changed

CHANGELOG.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,45 @@
1+
# 0.11.0 (13 April 2020)
2+
3+
This is a bugfix and feature release, which fixes [an issue with CDATA
4+
decoding](https://github.com/MaxDesiatov/XMLCoder/issues/168)
5+
and adds [`TopLevelEncoder` conformance to
6+
`XMLEncoder`](https://github.com/MaxDesiatov/XMLCoder/pull/175). New
7+
[`rootAttributes` argument](https://github.com/MaxDesiatov/XMLCoder/pull/160)
8+
has been added to the `encode` function on `XMLEncoder` that allows
9+
adding attributes on root elements without adding them to your model types.
10+
Thanks to [@portellaa](https://github.com/portellaa),
11+
[@Kirow](https://github.com/Kirow) and others for their contributions and
12+
bug reports!
13+
14+
**Closed issues:**
15+
16+
- CDATA Decoding not working
17+
([#168](https://github.com/MaxDesiatov/XMLCoder/issues/168))
18+
- Decode special XML Structure
19+
([#156](https://github.com/MaxDesiatov/XMLCoder/issues/156))
20+
- Root level attributes don't get encoded back to attribute when converting back to XML file from Plist
21+
([#127](https://github.com/MaxDesiatov/XMLCoder/issues/127))
22+
- Bad access error when running on device
23+
([#100](https://github.com/MaxDesiatov/XMLCoder/issues/100))
24+
25+
**Merged pull requests:**
26+
27+
- Add TopLevelEncoder implementation
28+
([#175](https://github.com/MaxDesiatov/XMLCoder/pull/175))
29+
[@MaxDesiatov](https://github.com/MaxDesiatov)
30+
- Add support for root attributes propagation
31+
([#160](https://github.com/MaxDesiatov/XMLCoder/pull/160))
32+
[@portellaa](https://github.com/portellaa)
33+
- Fix RJITest RSS encoding and decoding
34+
([#171](https://github.com/MaxDesiatov/XMLCoder/pull/171))
35+
[@MaxDesiatov](https://github.com/MaxDesiatov)
36+
- Cleanup tests, support OpenCombine
37+
([#169](https://github.com/MaxDesiatov/XMLCoder/pull/169))
38+
[@MaxDesiatov](https://github.com/MaxDesiatov)
39+
- Fix CDATA issue
40+
([#170](https://github.com/MaxDesiatov/XMLCoder/pull/170))
41+
[@MaxDesiatov](https://github.com/MaxDesiatov)
42+
143
# 0.10.0 (4 April 2020)
244

345
This is a bugfix release, which improves encoding and decoding of enums with associated values

README.md

Lines changed: 63 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,61 @@ func fetchBook(from url: URL) -> AnyPublisher<Book, Error> {
290290
This was implemented in PR [\#132](https://github.com/MaxDesiatov/XMLCoder/pull/132)
291291
by [@sharplet](https://github.com/sharplet).
292292

293+
Additionally, starting with [XMLCoder
294+
0.11](https://github.com/MaxDesiatov/XMLCoder/releases/tag/0.11.0) `XMLEncoder`
295+
conforms to the `TopLevelEncoder` protocol:
296+
297+
```swift
298+
import Combine
299+
import XMLCoder
300+
301+
func encode(book: Book) -> AnyPublisher<Data, Error> {
302+
return Just(book)
303+
.encode(encoder: XMLEncoder())
304+
.eraseToAnyPublisher()
305+
}
306+
```
307+
308+
The resulting XML in the example above will start with `<book`, to customize
309+
capitalization of the root element (e.g. `<Book`) you'll need to set an
310+
appropriate `keyEncoding` strategy on the encoder. To change the element name
311+
altogether you'll have to change the name of the type, which is an unfortunate
312+
limitation of the `TopLevelEncoder` API.
313+
314+
### Root element attributes
315+
316+
Sometimes you need to set attributes on the root element, which aren't
317+
directly related to your model type. Starting with [XMLCoder
318+
0.11](https://github.com/MaxDesiatov/XMLCoder/releases/tag/0.11.0) the `encode`
319+
function on `XMLEncoder` accepts a new `rootAttributes` argument to help with
320+
this:
321+
322+
```swift
323+
struct Policy: Encodable {
324+
var name: String
325+
}
326+
327+
let encoder = XMLEncoder()
328+
let data = try encoder.encode(Policy(name: "test"), rootAttributes: [
329+
"xmlns": "http://www.nrf-arts.org/IXRetail/namespace",
330+
"xmlns:xsd": "http://www.w3.org/2001/XMLSchema",
331+
"xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance",
332+
])
333+
```
334+
335+
The resulting XML will look like this:
336+
337+
```xml
338+
<policy xmlns="http://www.nrf-arts.org/IXRetail/namespace"
339+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
340+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
341+
<name>test</name>
342+
</policy>
343+
```
344+
345+
This was implemented in PR [\#160](https://github.com/MaxDesiatov/XMLCoder/pull/160)
346+
by [@portellaa](https://github.com/portellaa).
347+
293348
## Installation
294349

295350
### Requirements
@@ -316,7 +371,7 @@ easy as adding it to the `dependencies` value of your `Package.swift`.
316371

317372
```swift
318373
dependencies: [
319-
.package(url: "https://github.com/MaxDesiatov/XMLCoder.git", from: "0.10.0")
374+
.package(url: "https://github.com/MaxDesiatov/XMLCoder.git", from: "0.11.0")
320375
]
321376
```
322377

@@ -347,7 +402,7 @@ target 'YourApp' do
347402
use_frameworks!
348403

349404
# Pods for YourApp
350-
pod 'XMLCoder', '~> 0.10.0'
405+
pod 'XMLCoder', '~> 0.11.0'
351406
end
352407
```
353408

@@ -376,7 +431,7 @@ $ brew install carthage
376431
Inside of your `Cartfile`, add GitHub path to `XMLCoder`:
377432

378433
```ogdl
379-
github "MaxDesiatov/XMLCoder" ~> 0.10.0
434+
github "MaxDesiatov/XMLCoder" ~> 0.11.0
380435
```
381436

382437
Then, run the following command to build the framework:
@@ -403,10 +458,10 @@ appreciated and helps in maintaining the project.
403458

404459
### Coding Style
405460

406-
This project uses [SwiftFormat](https://github.com/nicklockwood/SwiftFormat)
461+
This project uses [SwiftFormat](https://github.com/nicklockwood/SwiftFormat)
407462
and [SwiftLint](https://github.com/realm/SwiftLint) to
408-
enforce formatting and coding style. We encourage you to run SwiftFormat within
409-
a local clone of the repository in whatever way works best for you either
463+
enforce formatting and coding style. We encourage you to run SwiftFormat within
464+
a local clone of the repository in whatever way works best for you either
410465
manually or automatically via an [Xcode
411466
extension](https://github.com/nicklockwood/SwiftFormat#xcode-source-editor-extension),
412467
[build phase](https://github.com/nicklockwood/SwiftFormat#xcode-build-phase) or
@@ -424,8 +479,8 @@ pre-commit install # installs pre-commit hook to run checks before you commit
424479
Refer to [the pre-commit documentation page](https://pre-commit.com/) for more details
425480
and installation instructions for other platforms.
426481

427-
SwiftFormat and SwiftLint also run on CI for every PR and thus a CI build can
428-
fail with incosistent formatting or style. We require CI builds to pass for all
482+
SwiftFormat and SwiftLint also run on CI for every PR and thus a CI build can
483+
fail with incosistent formatting or style. We require CI builds to pass for all
429484
PRs before merging.
430485

431486
### Test Coverage

Sources/XMLCoder/Encoder/XMLEncoder.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,8 @@ open class XMLEncoder {
317317
/// Encodes the given top-level value and returns its XML representation.
318318
///
319319
/// - parameter value: The value to encode.
320-
/// - parameter withRootKey: the key used to wrap the encoded values.
320+
/// - parameter withRootKey: the key used to wrap the encoded values. The
321+
/// default value is inferred from the name of the root type.
321322
/// - parameter rootAttributes: the list of attributes to be added to the root node
322323
/// - returns: A new `Data` value containing the encoded XML data.
323324
/// - throws: `EncodingError.invalidValue` if a non-conforming

XMLCoder.podspec

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
Pod::Spec.new do |s|
22
s.name = "XMLCoder"
3-
s.version = "0.10.0"
3+
s.version = "0.11.0"
44
s.summary = "XMLEncoder & XMLDecoder using the Codable protocol in Swift"
55
s.description = "XMLCoder allows Swift Codable-conforming objects to be translated to and from XML"
66
s.homepage = "https://github.com/MaxDesiatov/XMLCoder"
77
s.license = { :type => "MIT", :file => "LICENSE" }
8-
s.authors = {
9-
"Shawn Moore" => "[email protected]",
8+
s.authors = {
9+
"Shawn Moore" => "[email protected]",
1010
"Max Desiatov" => "[email protected]"
1111
}
1212
s.watchos.deployment_target = "2.0"

XMLCoder.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -962,7 +962,7 @@
962962
CLANG_ENABLE_OBJC_ARC = YES;
963963
COMBINE_HIDPI_IMAGES = YES;
964964
COPY_PHASE_STRIP = NO;
965-
CURRENT_PROJECT_VERSION = 0.10.0;
965+
CURRENT_PROJECT_VERSION = 0.11.0;
966966
DEBUG_INFORMATION_FORMAT = dwarf;
967967
DYLIB_INSTALL_NAME_BASE = "@rpath";
968968
ENABLE_NS_ASSERTIONS = YES;
@@ -990,7 +990,7 @@
990990
CLANG_ENABLE_OBJC_ARC = YES;
991991
COMBINE_HIDPI_IMAGES = YES;
992992
COPY_PHASE_STRIP = YES;
993-
CURRENT_PROJECT_VERSION = 0.10.0;
993+
CURRENT_PROJECT_VERSION = 0.11.0;
994994
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
995995
DYLIB_INSTALL_NAME_BASE = "@rpath";
996996
GCC_OPTIMIZATION_LEVEL = s;

0 commit comments

Comments
 (0)