Skip to content

Commit

Permalink
Bump version to 0.12.0, update CHANGELOG.md (#210)
Browse files Browse the repository at this point in the history
* Bump version to 0.12.0, update `CHANGELOG.md`

* Fix formatting and shuffled tuple fields warning

* Remove broken Danger workflow

* Add an Ubuntu Swift 5.3.2 job to Azure Pipelines
  • Loading branch information
MaxDesiatov authored Jan 26, 2021
1 parent 8a07649 commit b8fa7fe
Show file tree
Hide file tree
Showing 21 changed files with 174 additions and 164 deletions.
22 changes: 0 additions & 22 deletions .github/workflows/danger.yml

This file was deleted.

41 changes: 13 additions & 28 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,6 @@ on:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
xcode-11_0:
# The type of runner that the job will run on
runs-on: macOS-10.15

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

- name: Build with Xcode 11.0
run: ./test_xcodebuild.sh Xcode_11
env:
IOS_DEVICE: "platform=iOS Simulator,OS=13.0,name=iPhone 8"
TVOS_DEVICE: "platform=tvOS Simulator,OS=13.0,name=Apple TV 4K"

xcode-11_1:
runs-on: macOS-10.15

steps:
- uses: actions/checkout@v2

- name: Build with Xcode 11.1
run: ./test_xcodebuild.sh Xcode_11.1
env:
IOS_DEVICE: "platform=iOS Simulator,OS=13.1,name=iPhone 8"
TVOS_DEVICE: "platform=tvOS Simulator,OS=13.0,name=Apple TV 4K"

xcode-11_2:
runs-on: macOS-10.15

Expand Down Expand Up @@ -72,7 +45,7 @@ jobs:
- name: Build with Xcode 11.4
run: ./test_xcodebuild.sh Xcode_11.4
env:
IOS_DEVICE: "platform=iOS Simulator,OS=13.4,name=iPhone 8"
IOS_DEVICE: "platform=iOS Simulator,OS=13.4.1,name=iPhone 8"
TVOS_DEVICE: "platform=tvOS Simulator,OS=13.4,name=Apple TV 4K"

xcode-11_5:
Expand All @@ -86,6 +59,18 @@ jobs:
env:
IOS_DEVICE: "platform=iOS Simulator,OS=13.5,name=iPhone 8"
TVOS_DEVICE: "platform=tvOS Simulator,OS=13.4,name=Apple TV 4K"

xcode-12_3:
runs-on: macOS-10.15

steps:
- uses: actions/checkout@v2

- name: Build with Xcode 12.3
run: ./test_xcodebuild.sh Xcode_12.3
env:
IOS_DEVICE: "platform=iOS Simulator,OS=14.3,name=iPhone 8"
TVOS_DEVICE: "platform=tvOS Simulator,OS=14.3,name=Apple TV 4K"
CODECOV_JOB: "true"
CODECOV_TOKEN: ${{ secrets.codecovToken }}

Expand Down
30 changes: 30 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
# 0.12.0 (26 January 2021)

This release adds a few new features. Namely:

- New `charactersEscapedInAttributes` and `charactersEscapedInElements` properties on `XMLEncoder`
that allow customizing how certain characters are escaped.
- You can now override the implementation of `TopLevelEncoder` Combine protocol conformance when
subclassing `XMLEncoder`.
- New `prettyPrintIndentation` property on `XMLEncoder`, which can take `XMLEncoder.PrettyPrintIndentation` values such as `.tabs(1)` or `.spaces(2)`.

Thanks to [Kenta Kubo](https://github.com/kkk669) for the contribution!

**Closed issues:**

- How to decode `<itunes:episode>` tags ([#201](https://github.com/MaxDesiatov/XMLCoder/issues/201))
- Fail to build in Xcode 12 beta ([#196](https://github.com/MaxDesiatov/XMLCoder/issues/196))
- Changing the root node name ? ([#191](https://github.com/MaxDesiatov/XMLCoder/issues/191))
- " in XML element may not always be escaping ([#187](https://github.com/MaxDesiatov/XMLCoder/issues/187))
- `&#10;` in XML attributes ([#185](https://github.com/MaxDesiatov/XMLCoder/issues/185))
- " and `&quot;` are not decoded equally ([#184](https://github.com/MaxDesiatov/XMLCoder/issues/184))
- Use 2 spaces instead of 4 when .prettyPrinted ([#183](https://github.com/MaxDesiatov/XMLCoder/issues/183))
- (Help using) How to decode this XML? ([#180](https://github.com/MaxDesiatov/XMLCoder/issues/180))

**Merged pull requests:**

- Test `DynamicNodeEncoding` for root elements ([#195](https://github.com/MaxDesiatov/XMLCoder/pull/195)) via [@MaxDesiatov](https://github.com/MaxDesiatov)
- Make character escaping customizable in `XMLEncoder` ([#188](https://github.com/MaxDesiatov/XMLCoder/pull/188)) via [@MaxDesiatov](https://github.com/MaxDesiatov)
- Add `prettyPrintIndentation` property on `XMLEncoder` ([#186](https://github.com/MaxDesiatov/XMLCoder/pull/186)) via [@MaxDesiatov](https://github.com/MaxDesiatov)
- Make `TopLevelEncoder` implementation overridable ([#182](https://github.com/MaxDesiatov/XMLCoder/pull/182)) via [@kkk669](https://github.com/kkk669)

# 0.11.1 (3 May 2020)

This release fixes an issue, where non-string values used CDATA encoding.
Expand Down
14 changes: 0 additions & 14 deletions Dangerfile.swift

This file was deleted.

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ easy as adding it to the `dependencies` value of your `Package.swift`.

```swift
dependencies: [
.package(url: "https://github.com/MaxDesiatov/XMLCoder.git", from: "0.11.1")
.package(url: "https://github.com/MaxDesiatov/XMLCoder.git", from: "0.12.0")
]
```

Expand Down Expand Up @@ -409,7 +409,7 @@ target 'YourApp' do
use_frameworks!

# Pods for YourApp
pod 'XMLCoder', '~> 0.11.1'
pod 'XMLCoder', '~> 0.12.0'
end
```

Expand Down Expand Up @@ -438,7 +438,7 @@ $ brew install carthage
Inside of your `Cartfile`, add GitHub path to `XMLCoder`:

```ogdl
github "MaxDesiatov/XMLCoder" ~> 0.11.1
github "MaxDesiatov/XMLCoder" ~> 0.12.0
```

Then, run the following command to build the framework:
Expand Down
3 changes: 2 additions & 1 deletion Sources/XMLCoder/Auxiliaries/Box/KeyedBox.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ struct KeyedBox {
extension KeyedBox {
init<E, A>(elements: E, attributes: A)
where E: Sequence, E.Element == (Key, Element),
A: Sequence, A.Element == (Key, Attribute) {
A: Sequence, A.Element == (Key, Attribute)
{
let elements = Elements(elements)
let attributes = Attributes(attributes)
self.init(elements: elements, attributes: attributes)
Expand Down
6 changes: 4 additions & 2 deletions Sources/XMLCoder/Auxiliaries/XMLStackParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ extension XMLStackParser: XMLParserDelegate {
didStartElement elementName: String,
namespaceURI: String?,
qualifiedName: String?,
attributes attributeDict: [String: String] = [:]) {
attributes attributeDict: [String: String] = [:])
{
#if os(Linux) && !compiler(>=5.1)
// For some reason, element names on linux are coming out with the namespace after the name
// https://bugs.swift.org/browse/SR-11191
Expand All @@ -144,7 +145,8 @@ extension XMLStackParser: XMLParserDelegate {
func parser(_: XMLParser,
didEndElement _: String,
namespaceURI _: String?,
qualifiedName _: String?) {
qualifiedName _: String?)
{
guard let element = stack.popLast() else {
return
}
Expand Down
6 changes: 4 additions & 2 deletions Sources/XMLCoder/Decoder/XMLDecoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ open class XMLDecoder {
}

guard let container = try? decoder.singleValueContainer(),
let text = try? container.decode(String.self) else {
let text = try? container.decode(String.self)
else {
throw DecodingError.dataCorrupted(DecodingError.Context(
codingPath: decoder.codingPath,
debugDescription: "Could not decode date text"
Expand Down Expand Up @@ -100,7 +101,8 @@ open class XMLDecoder {
}

guard let container = try? decoder.singleValueContainer(),
let text = try? container.decode(String.self) else {
let text = try? container.decode(String.self)
else {
throw DecodingError.dataCorrupted(DecodingError.Context(
codingPath: decoder.codingPath,
debugDescription: "Could not decode date text"
Expand Down
10 changes: 6 additions & 4 deletions Sources/XMLCoder/Decoder/XMLDecoderImplementation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class XMLDecoderImplementation: Decoder {
// MARK: Properties

/// The decoder's storage.
var storage: XMLDecodingStorage = XMLDecodingStorage()
var storage = XMLDecodingStorage()

/// Options set on the top-level decoder.
let options: XMLDecoder.Options
Expand Down Expand Up @@ -442,7 +442,8 @@ extension XMLDecoderImplementation {
decoded = decimal as? T
} else if
type == String.self || type == NSString.self,
let value = (try unbox(box) as String) as? T {
let value = (try unbox(box) as String) as? T
{
decoded = value
} else {
storage.push(container: box)
Expand All @@ -454,8 +455,9 @@ extension XMLDecoderImplementation {
decoded = try type.init(from: self)
} catch {
guard case DecodingError.valueNotFound = error,
let type = type as? AnyOptional.Type,
let result = type.init() as? T else {
let type = type as? AnyOptional.Type,
let result = type.init() as? T
else {
throw error
}

Expand Down
25 changes: 16 additions & 9 deletions Sources/XMLCoder/Decoder/XMLKeyedDecodingContainer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,10 @@ struct XMLKeyedDecodingContainer<K: CodingKey>: KeyedDecodingContainerProtocol {
}

if let type = type as? AnySequence.Type,
!attributeFound,
!elementFound,
let result = type.init() as? T {
!attributeFound,
!elementFound,
let result = type.init() as? T
{
return result
}

Expand Down Expand Up @@ -207,19 +208,22 @@ extension XMLKeyedDecodingContainer {

private func decodeSignedInteger<T>(_ type: T.Type,
forKey key: Key) throws -> T
where T: BinaryInteger & SignedInteger & Decodable {
where T: BinaryInteger & SignedInteger & Decodable
{
return try decodeConcrete(type, forKey: key)
}

private func decodeUnsignedInteger<T>(_ type: T.Type,
forKey key: Key) throws -> T
where T: BinaryInteger & UnsignedInteger & Decodable {
where T: BinaryInteger & UnsignedInteger & Decodable
{
return try decodeConcrete(type, forKey: key)
}

private func decodeFloatingPoint<T>(_ type: T.Type,
forKey key: Key) throws -> T
where T: BinaryFloatingPoint & Decodable {
where T: BinaryFloatingPoint & Decodable
{
return try decodeConcrete(type, forKey: key)
}

Expand Down Expand Up @@ -265,7 +269,8 @@ extension XMLKeyedDecodingContainer {
// You can't decode sequences from attributes, but other strategies
// need special handling for empty sequences.
if strategy(key) != .attribute && elements.isEmpty,
let empty = (type as? AnySequence.Type)?.init() as? T {
let empty = (type as? AnySequence.Type)?.init() as? T
{
return empty
}

Expand Down Expand Up @@ -309,7 +314,8 @@ extension XMLKeyedDecodingContainer {

let value: T?
if !(type is AnySequence.Type), let unkeyedBox = box as? UnkeyedBox,
let first = unkeyedBox.first {
let first = unkeyedBox.first
{
// Handle case where we have held onto a `SingleKeyedBox`
if let singleKeyed = first as? SingleKeyedBox {
if singleKeyed.element.isNull {
Expand All @@ -325,7 +331,8 @@ extension XMLKeyedDecodingContainer {
}

if value == nil, let type = type as? AnyOptional.Type,
let result = type.init() as? T {
let result = type.init() as? T
{
return result
}

Expand Down
3 changes: 2 additions & 1 deletion Sources/XMLCoder/Decoder/XMLUnkeyedDecodingContainer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ struct XMLUnkeyedDecodingContainer: UnkeyedDecodingContainer {
defer { currentIndex += 1 }

if value == nil, let type = type as? AnyOptional.Type,
let result = type.init() as? T {
let result = type.init() as? T
{
return result
}

Expand Down
4 changes: 2 additions & 2 deletions Sources/XMLCoder/Encoder/DynamicNodeEncoding.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ extension Array: DynamicNodeEncoding where Element: DynamicNodeEncoding {
}
}

extension DynamicNodeEncoding where Self: Collection, Self.Iterator.Element: DynamicNodeEncoding {
public static func nodeEncoding(for key: CodingKey) -> XMLEncoder.NodeEncoding {
public extension DynamicNodeEncoding where Self: Collection, Self.Iterator.Element: DynamicNodeEncoding {
static func nodeEncoding(for key: CodingKey) -> XMLEncoder.NodeEncoding {
return Element.nodeEncoding(for: key)
}
}
7 changes: 4 additions & 3 deletions Sources/XMLCoder/Encoder/XMLEncoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,8 @@ open class XMLEncoder {
open func encode<T: Encodable>(_ value: T,
withRootKey rootKey: String? = nil,
rootAttributes: [String: String]? = nil,
header: XMLHeader? = nil) throws -> Data {
header: XMLHeader? = nil) throws -> Data
{
let encoder = XMLEncoderImplementation(options: options, nodeEncodings: [])
encoder.nodeEncodings.append(options.nodeEncodingStrategy.nodeEncodings(forType: T.self, with: encoder))

Expand Down Expand Up @@ -403,8 +404,8 @@ open class XMLEncoder {
return element.toXMLString(
with: header,
escapedCharacters: (
attributes: charactersEscapedInAttributes,
elements: charactersEscapedInElements
elements: charactersEscapedInElements,
attributes: charactersEscapedInAttributes
),
formatting: outputFormatting,
indentation: prettyPrintIndentation
Expand Down
12 changes: 8 additions & 4 deletions Sources/XMLCoder/Encoder/XMLEncoderImplementation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -256,16 +256,20 @@ extension XMLEncoderImplementation {

func box<T: Encodable>(_ value: T) throws -> Box {
if T.self == Date.self || T.self == NSDate.self,
let value = value as? Date {
let value = value as? Date
{
return try box(value)
} else if T.self == Data.self || T.self == NSData.self,
let value = value as? Data {
let value = value as? Data
{
return try box(value)
} else if T.self == URL.self || T.self == NSURL.self,
let value = value as? URL {
let value = value as? URL
{
return box(value)
} else if T.self == Decimal.self || T.self == NSDecimalNumber.self,
let value = value as? Decimal {
let value = value as? Decimal
{
return box(value)
}

Expand Down
Loading

0 comments on commit b8fa7fe

Please sign in to comment.