Skip to content

Commit 672417e

Browse files
committed
Merge branch 'release/1.0.1'
2 parents c7ef09f + 27b525d commit 672417e

9 files changed

Lines changed: 31 additions & 28 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,9 @@ All notable changes to this project will be documented in this file.
44
`dependency-injector-object-mapper-swift` adheres to [Semantic Versioning](http://semver.org/).
55

66
---
7+
8+
## [1.0.1](https://github.com/Digipolitan/dependency-injector-object-mapper-swift/releases/tag/v1.0.1)
9+
10+
update providers + update tests
11+
12+
---

DependencyInjectorObjectMapper.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "DependencyInjectorObjectMapper"
3-
s.version = "1.0.0"
3+
s.version = "1.0.1"
44
s.summary = "Add Mappable support with dependency injection"
55
s.homepage = "https://github.com/Digipolitan/dependency-injector-object-mapper-swift"
66
s.authors = "Digipolitan"

DependencyInjectorObjectMapper.xcodeproj/project.pbxproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
A38EF2CA1DECF97000637484 /* DependencyInjectorObjectMapperTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A38EF2C71DECF97000637484 /* DependencyInjectorObjectMapperTests.swift */; };
2222
A38EF2CB1DECF97000637484 /* DependencyInjectorObjectMapperTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A38EF2C71DECF97000637484 /* DependencyInjectorObjectMapperTests.swift */; };
2323
A38EF2CC1DECF97000637484 /* DependencyInjectorObjectMapperTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A38EF2C71DECF97000637484 /* DependencyInjectorObjectMapperTests.swift */; };
24+
A3924B971F55A32400CBA3CD /* Map+DependencyInjector.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3B8AA571F4ECE830086EFC2 /* Map+DependencyInjector.swift */; };
25+
A3924B981F55A32400CBA3CD /* Map+DependencyInjector.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3B8AA571F4ECE830086EFC2 /* Map+DependencyInjector.swift */; };
26+
A3924B991F55A32500CBA3CD /* Map+DependencyInjector.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3B8AA571F4ECE830086EFC2 /* Map+DependencyInjector.swift */; };
2427
A3B8AA371F4DCBB90086EFC2 /* Binder+ObjectMapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3B8AA341F4DCBB90086EFC2 /* Binder+ObjectMapper.swift */; };
2528
A3B8AA381F4DCBB90086EFC2 /* Binder+ObjectMapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3B8AA341F4DCBB90086EFC2 /* Binder+ObjectMapper.swift */; };
2629
A3B8AA391F4DCBB90086EFC2 /* Binder+ObjectMapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3B8AA341F4DCBB90086EFC2 /* Binder+ObjectMapper.swift */; };
@@ -971,6 +974,7 @@
971974
buildActionMask = 2147483647;
972975
files = (
973976
A3B8AA381F4DCBB90086EFC2 /* Binder+ObjectMapper.swift in Sources */,
977+
A3924B971F55A32400CBA3CD /* Map+DependencyInjector.swift in Sources */,
974978
A3B8AA3C1F4DCBB90086EFC2 /* InjectorTransformer.swift in Sources */,
975979
A3B8AA401F4DCBB90086EFC2 /* Provider+ObjectMapper.swift in Sources */,
976980
);
@@ -981,6 +985,7 @@
981985
buildActionMask = 2147483647;
982986
files = (
983987
A3B8AA391F4DCBB90086EFC2 /* Binder+ObjectMapper.swift in Sources */,
988+
A3924B981F55A32400CBA3CD /* Map+DependencyInjector.swift in Sources */,
984989
A3B8AA3D1F4DCBB90086EFC2 /* InjectorTransformer.swift in Sources */,
985990
A3B8AA411F4DCBB90086EFC2 /* Provider+ObjectMapper.swift in Sources */,
986991
);
@@ -1004,6 +1009,7 @@
10041009
buildActionMask = 2147483647;
10051010
files = (
10061011
A3B8AA3A1F4DCBB90086EFC2 /* Binder+ObjectMapper.swift in Sources */,
1012+
A3924B991F55A32500CBA3CD /* Map+DependencyInjector.swift in Sources */,
10071013
A3B8AA3E1F4DCBB90086EFC2 /* InjectorTransformer.swift in Sources */,
10081014
A3B8AA421F4DCBB90086EFC2 /* Provider+ObjectMapper.swift in Sources */,
10091015
);

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ DependencyInjector+ObjectMapper
22
=================================
33

44
[![Build Status](https://travis-ci.org/Digipolitan/dependency-injector-object-mapper-swift.svg?branch=master)](https://travis-ci.org/Digipolitan/dependency-injector-object-mapper-swift)
5-
[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/DependencyInjector_ObjectMapper.svg)](https://img.shields.io/cocoapods/v/DependencyInjector_ObjectMapper.svg)
5+
[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/DependencyInjectorObjectMapper.svg)](https://img.shields.io/cocoapods/v/DependencyInjectorObjectMapper.svg)
66
[![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
7-
[![Platform](https://img.shields.io/cocoapods/p/DependencyInjector_ObjectMapper.svg?style=flat)](http://cocoadocs.org/docsets/DependencyInjector_ObjectMapper)
7+
[![Platform](https://img.shields.io/cocoapods/p/DependencyInjectorObjectMapper.svg?style=flat)](http://cocoadocs.org/docsets/DependencyInjectorObjectMapper)
88
[![Twitter](https://img.shields.io/badge/twitter-@Digipolitan-blue.svg?style=flat)](http://twitter.com/Digipolitan)
99

1010
Dependency injector Swift compatible with ObjectMapper
@@ -65,7 +65,7 @@ class UserModel: User, Mappable {
6565

6666
public func mapping(map: Map) {
6767
self.id >>> map["id"]
68-
self.created <- map["createdAt"]
68+
self.created <- (map["createdAt"], DateTransform())
6969
self.address >>> map.inject("address", type: Address.self)
7070
}
7171
}

Sources/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>FMWK</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>1.0.0</string>
18+
<string>1.0.1</string>
1919
<key>CFBundleVersion</key>
2020
<string>1</string>
2121
<key>NSPrincipalClass</key>

Sources/Provider+ObjectMapper.swift

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,4 @@ public extension Provider {
1919
return nil
2020
}
2121
}
22-
23-
public convenience init(type: Mappable.Type) {
24-
self.init { (_, arguments) -> T? in
25-
if let res = type.init(map: Map(mappingType: .fromJSON, JSON: arguments ?? [:])) as? T {
26-
return res
27-
}
28-
return nil
29-
}
30-
}
31-
32-
public convenience init(type: ImmutableMappable.Type) {
33-
self.init { (_, arguments) throws -> T? in
34-
if let res = try type.init(map: Map(mappingType: .fromJSON, JSON: arguments ?? [:])) as? T {
35-
return res
36-
}
37-
return nil
38-
}
39-
}
4022
}

Tests/DependencyInjectorObjectMapperTests/DependencyInjectorObjectMapperTests.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@ class DependencyInjectorObjectMapperTests: XCTestCase {
2929
XCTAssertNotNil(user?.addresses)
3030
}
3131

32+
func testInitWithTransformer() {
33+
let injector = Injector.default
34+
let date = Date()
35+
let user = try? injector.inject(User.self, arguments: [
36+
"id": "1",
37+
"createdAt": date.timeIntervalSince1970
38+
])
39+
XCTAssertEqual(user?.created?.timeIntervalSince1970, date.timeIntervalSince1970)
40+
}
41+
3242
func testReverseTransformInjectNestedObject() {
3343
let injector = Injector.default
3444
let dict: [String: Any] = [

Tests/DependencyInjectorObjectMapperTests/UserModel.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,16 @@ class UserModel: User, Mappable {
2222

2323
public required init?(map: Map) {
2424
guard
25-
let id: String = try? map.value("id"),
26-
let addresses: [Address] = try? map.injectedValue("addresses", type: Address.self) else {
25+
let id: String = try? map.value("id") else {
2726
return nil
2827
}
2928
self.id = id
30-
self.addresses = addresses
29+
self.addresses = (try? map.injectedValue("addresses", type: Address.self)) ?? []
3130
}
3231

3332
public func mapping(map: Map) {
3433
self.id >>> map["id"]
35-
self.created <- map["createdAt"]
34+
self.created <- (map["createdAt"], DateTransform())
3635
self.addresses >>> map.inject("addresses", type: Address.self)
3736
}
3837
}

Tests/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>BNDL</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>1.0.0</string>
18+
<string>1.0.1</string>
1919
<key>CFBundleVersion</key>
2020
<string>1</string>
2121
</dict>

0 commit comments

Comments
 (0)