Skip to content
This repository has been archived by the owner on Feb 8, 2021. It is now read-only.

Commit

Permalink
Merge pull request #283 from hkellaway/release/1.2.4
Browse files Browse the repository at this point in the history
Release/1.2.4
  • Loading branch information
Harlan Kellaway authored Mar 30, 2017
2 parents 0c83d73 + 2736909 commit e45facb
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
All notable changes to this project will be documented in this file.
`Gloss` adheres to [Semantic Versioning](http://semver.org/).

- `1.2.x` Releases - [1.2.0](#120) | [1.2.1](#121) | [1.2.2](#122) | [1.2.3](#123)
- `1.2.x` Releases - [1.2.0](#120) | [1.2.1](#121) | [1.2.2](#122) | [1.2.3](#123) | [1.2.4](#124)
- `1.1.x` Releases - [1.1.0](#110) | [1.1.1](#111)
- `1.0.x` Releases - [1.0.0](#100)
- `0.8.x` Releases - [0.8.0](#080)
Expand All @@ -16,6 +16,13 @@ All notable changes to this project will be documented in this file.

---

## [1.2.4](https://github.com/hkellaway/Gloss/releases/tag/1.2.4)
Released on 2017-03-30. All issues associated with this milestone can be found using this [filter](https://github.com/hkellaway/Gloss/issues?utf8=%E2%9C%93&q=milestone%3A1.2.4)

#### Added
- Ability to inject logger used by Decoder [Issue #282](https://github.com/hkellaway/Gloss/pull/282)
---

## [1.2.3](https://github.com/hkellaway/Gloss/releases/tag/1.2.3)
Released on 2017-03-29. All issues associated with this milestone can be found using this [filter](https://github.com/hkellaway/Gloss/issues?utf8=%E2%9C%93&q=milestone%3A1.2.3)

Expand Down
2 changes: 1 addition & 1 deletion Gloss.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "Gloss"
s.version = "1.2.3"
s.version = "1.2.4"
s.summary = "A shiny JSON parsing library in Swift"
s.description = "A shiny JSON parsing library in Swift. Features include mapping JSON to objects, mapping objects to JSON, handling of nested objects and custom transformations."
s.homepage = "https://github.com/hkellaway/Gloss"
Expand Down
5 changes: 4 additions & 1 deletion Sources/Decoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,17 @@ Decodes JSON to objects.
*/
public struct Decoder {

/// Default logger
public static var logger: Logger = GlossLogger()

/**
Decodes JSON to a generic value.

- parameter key: Key used in JSON for decoded value.

- returns: Value decoded from JSON.
*/
public static func decode<T>(key: String, keyPathDelimiter: String = GlossKeyPathDelimiter, logger: Logger = GlossLogger()) -> (JSON) -> T? {
public static func decode<T>(key: String, keyPathDelimiter: String = GlossKeyPathDelimiter, logger: Logger = logger) -> (JSON) -> T? {
return {
json in

Expand Down
10 changes: 10 additions & 0 deletions Tests/GlossTests/DecoderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,16 @@ class DecoderTests: XCTestCase {
XCTAssertTrue(fakeLogger.wasMessageLogged, "Message should be logged when an unknown type is attempted to be decoded.")
}

func testDecodingModelWithUnknownTypeLogsErrorMessageInInjectedDefaultLogger() {
let fakeLogger = FakeLogger()
Decoder.logger = fakeLogger

let value: UnknownType? = Decoder.decode(key: "value")(testUnknownTypeJSON!)

XCTAssertNil(value)
XCTAssertTrue(fakeLogger.wasMessageLogged, "Message should be logged when an unknown type is attempted to be decoded.")
}

func testInitializingFailableObjectsWithBadDataCanFail() {
let result = TestFailableModel(json: testFailableModelJSONInvalid!)

Expand Down

0 comments on commit e45facb

Please sign in to comment.