Skip to content

Commit 9dd98f2

Browse files
committed
proj: 0.2.0 and readme
1 parent 2040106 commit 9dd98f2

3 files changed

Lines changed: 17 additions & 17 deletions

File tree

‎ExCodable.podspec‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ Pod::Spec.new do |s|
22

33
# ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
44
s.name = "ExCodable"
5-
s.version = "0.1.0"
6-
s.summary = "Extensions for Swift Codable"
7-
# s.description = "Extensions for Swift."
5+
s.version = "0.2.0"
6+
s.summary = "Key-Mapping Extensions for Swift Codable"
7+
# s.description = "Key-Mapping Extensions for Swift Codable."
88
s.homepage = "https://github.com/iwill/ExCodable"
99

1010
# ――― Spec License ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
@@ -40,6 +40,6 @@ Pod::Spec.new do |s|
4040

4141
# ――― Project Settings ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
4242
# s.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" }
43-
# s.dependency "JSONKit", "~> 1.4"
43+
# s.dependency "Alamofire", "~> 5.4.1"
4444

4545
end

‎README-zh.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
- ExCodable —— 1 个文件、500 行代码,基于 `KeyPath` 实现 Key-Mapping,差不多实现了 YYModel 支持的所有特性。
1414

1515
**插播声明**:
16-
- **ExCodable 部分地借鉴了 [Codextended](https://github.com/JohnSundell/Codextended) 的设计,因为它“真的很棒”**,开始有考虑直接基于它做扩展的,但是后来发现受到限制较多,于是重新写了关键部分的实现,有些调整、也有些舍弃。
17-
- 在 JSON 转 Model 的场景,我们关心的只是解析结果有或没有,解析失败时抛出的错误并没有什么实际用途(除了 Debug,比如一个 Key 不存在和它存在但是类型错了对于结果有什么分别),所以为了避免到处写 `try?`,ExCodable 吞掉了所有的错误,返回值基本上都是 `Optional` 类型。
16+
- **ExCodable 部分地借鉴了 [Codextended](https://github.com/JohnSundell/Codextended) 的设计”**,因为它“真的很棒。开始有考虑直接基于它做扩展的,但是后来发现受到限制较多,于是重新写了关键部分的实现,有些调整、也有些舍弃。
17+
- 在 JSON 转 Model 的场景,我们关心的只是解析结果有或没有,解析失败时抛出的错误并没有什么实际用途(除了 Debug,比如一个 Key 不存在和它存在但是类型错了对于结果有什么分别)。所以为了避免到处写 `try?`,ExCodable 吞掉了所有的错误,返回值基本上都是 `Optional` 类型。
1818
- 没有像 Codextended 一样直接地支持 Date 格式转换,但是 ExCodable 支持全局的自定义类型转换、以及每个属性的自定义 Encode/Decode-Handler,可以很好地满足这个需求。
1919
- 目前,我只跑过 TestCase,暂时没有在实际项目中用到过 ExCodable,问题很可能是有的,如果遇到了,辛苦提交 Issue 或 Pull Request,我会尽快解决和完善。
2020

@@ -34,7 +34,7 @@ Encode/Decode:
3434
- 支持类型自动转换以及自定义转换。
3535

3636
简约且灵活的 API:
37-
- 支持多种 Encoder/Decoder,默认使用 JSON;
37+
- 支持多种 Encoder/Decoder,默认使用 JSON,支持 JSON Data、String、Object;
3838
- 使用类型推断;
3939
- 使用 `Optional` 类型取代抛出没什么 用的错误。
4040

‎README.md‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ Encode/Decode:
2929
- Supports builtin and custom `type-conversion`.
3030

3131
Simple and flexible Encodable/Decodable API:
32-
- **Part of the API draws on the design of an awesome framework - [Codextended](https://github.com/JohnSundell/Codextended).**
33-
- Uses JSON Encoder/Decoder by default.
32+
- **Part of the API borrows from an awesome framework - [Codextended](https://github.com/JohnSundell/Codextended).**
33+
- Uses JSON Encoder/Decoder by default, and supports PList.
3434
- Uses `type-inference`.
3535
- Returns `Optional` values instead of throwing errors.
3636

@@ -56,10 +56,10 @@ extension TestStruct: ExCodable {
5656
]
5757

5858
init(from decoder: Decoder) throws {
59-
Self.keyMapping.decode(&self, using: decoder)
59+
decode(with: Self.keyMapping, using: decoder)
6060
}
6161
func encode(to encoder: Encoder) throws {
62-
Self.keyMapping.encode(self, using: encoder)
62+
encode(with: Self.keyMapping, using: encoder)
6363
}
6464

6565
}
@@ -85,10 +85,10 @@ class TestClass: ExCodable, Equatable {
8585
]
8686

8787
required init(from decoder: Decoder) throws {
88-
Self.keyMapping.decode(self, using: decoder)
88+
decodeReference(with: Self.keyMapping, using: decoder)
8989
}
9090
func encode(to encoder: Encoder) throws {
91-
Self.keyMapping.encode(self, using: encoder)
91+
encode(with: Self.keyMapping, using: encoder)
9292
}
9393

9494
static func == (lhs: TestClass, rhs: TestClass) -> Bool {
@@ -115,11 +115,11 @@ class TestSubclass: TestClass {
115115

116116
required init(from decoder: Decoder) throws {
117117
try super.init(from: decoder)
118-
Self.keyMappingForTestSubclass.decode(self, using: decoder)
118+
decodeReference(with: Self.keyMappingForTestSubclass, using: decoder)
119119
}
120120
override func encode(to encoder: Encoder) throws {
121121
try super.encode(to: encoder)
122-
Self.keyMappingForTestSubclass.encode(self, using: encoder)
122+
encode(with: Self.keyMappingForTestSubclass, using: encoder)
123123
}
124124

125125
static func == (lhs: TestSubclass, rhs: TestSubclass) -> Bool {
@@ -250,13 +250,13 @@ else {
250250
[Swift Package Manager](https://github.com/apple/swift-package-manager):
251251

252252
```swift
253-
.package(url: "https://github.com/iwill/ExCodable", from: "0.1")
253+
.package(url: "https://github.com/iwill/ExCodable", from: "0.2")
254254
```
255255

256256
[CocoaPods](http://cocoapods.org):
257257

258258
```ruby
259-
pod 'ExCodable', '~> 0.1'
259+
pod 'ExCodable', '~> 0.2'
260260
```
261261

262262
## Credits

0 commit comments

Comments
 (0)