Skip to content

Commit c339b64

Browse files
author
mylcode
authored
Merge pull request #18 from MC-Studio/coverage100
代码覆盖率上升到100% +1
2 parents a8af618 + a0b978c commit c339b64

22 files changed

+6384
-483
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
- 增加单测,提升代码覆盖率
55
- 增加代码覆盖率badge
66
- 修复Example授权失败的问题
7+
- 调整配置接口
78

89
### 2018-2-6
910
- 统一方法的前缀MC

Example/MCJSONKit.xcodeproj/project.pbxproj

+17-8
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,13 @@
2020
6003F5B1195388D20070C39A /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F58D195388D20070C39A /* Foundation.framework */; };
2121
6003F5B2195388D20070C39A /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F591195388D20070C39A /* UIKit.framework */; };
2222
6003F5BA195388D20070C39A /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 6003F5B8195388D20070C39A /* InfoPlist.strings */; };
23-
6003F5BC195388D20070C39A /* Tests.m in Sources */ = {isa = PBXBuildFile; fileRef = 6003F5BB195388D20070C39A /* Tests.m */; };
23+
6003F5BC195388D20070C39A /* MCTypeTransformTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 6003F5BB195388D20070C39A /* MCTypeTransformTest.m */; };
2424
71719F9F1E33DC2100824A3D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 71719F9D1E33DC2100824A3D /* LaunchScreen.storyboard */; };
2525
873B8AEB1B1F5CCA007FD442 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 873B8AEA1B1F5CCA007FD442 /* Main.storyboard */; };
2626
C0B20416D9A80E49B8F4ED42 /* libPods-MCJSONKit_Tests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 24EDCF03A8161914A8A24114 /* libPods-MCJSONKit_Tests.a */; };
27+
C55E4A9820A7DA3800DE037D /* MCNSObjectJSONkitTest.m in Sources */ = {isa = PBXBuildFile; fileRef = C55E4A9720A7DA3800DE037D /* MCNSObjectJSONkitTest.m */; };
28+
C55E4A9D20A7E17000DE037D /* mock in Resources */ = {isa = PBXBuildFile; fileRef = C55E4A9B20A7DD8500DE037D /* mock */; };
29+
C55E4AA120A7FD9900DE037D /* MCPerformance.m in Sources */ = {isa = PBXBuildFile; fileRef = C55E4AA020A7FD9900DE037D /* MCPerformance.m */; };
2730
C599F3D51FAD929700D19382 /* HomeTimelineController.m in Sources */ = {isa = PBXBuildFile; fileRef = C599F3D31FAD923B00D19382 /* HomeTimelineController.m */; };
2831
C599F3D91FAD93C100D19382 /* WeiboRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = C599F3C51FAD902D00D19382 /* WeiboRequest.m */; };
2932
C599F3DA1FAD93C300D19382 /* LoadingView.m in Sources */ = {isa = PBXBuildFile; fileRef = C599F3BE1FAD902D00D19382 /* LoadingView.m */; };
@@ -33,7 +36,6 @@
3336
C599F3DE1FAD93CF00D19382 /* WeiboModel.m in Sources */ = {isa = PBXBuildFile; fileRef = C599F3C01FAD902D00D19382 /* WeiboModel.m */; };
3437
C599F3DF1FAD93D300D19382 /* StatuseModel.m in Sources */ = {isa = PBXBuildFile; fileRef = C599F3C31FAD902D00D19382 /* StatuseModel.m */; };
3538
C599F3E01FAD93D800D19382 /* WeiboViewModel.m in Sources */ = {isa = PBXBuildFile; fileRef = C599F3D01FAD90A900D19382 /* WeiboViewModel.m */; };
36-
C5D2A9C120A70D5D008998BD /* friends_timeline.json in Resources */ = {isa = PBXBuildFile; fileRef = C5D2A9BF20A70D5A008998BD /* friends_timeline.json */; };
3739
C5D2A9C420A716EB008998BD /* WeiboResult.m in Sources */ = {isa = PBXBuildFile; fileRef = C5D2A9C320A716EB008998BD /* WeiboResult.m */; };
3840
/* End PBXBuildFile section */
3941

@@ -67,14 +69,17 @@
6769
6003F5AF195388D20070C39A /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; };
6870
6003F5B7195388D20070C39A /* Tests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Tests-Info.plist"; sourceTree = "<group>"; };
6971
6003F5B9195388D20070C39A /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
70-
6003F5BB195388D20070C39A /* Tests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Tests.m; sourceTree = "<group>"; };
72+
6003F5BB195388D20070C39A /* MCTypeTransformTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MCTypeTransformTest.m; sourceTree = "<group>"; };
7173
606FC2411953D9B200FFA9A0 /* Tests-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Tests-Prefix.pch"; sourceTree = "<group>"; };
7274
71719F9E1E33DC2100824A3D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
7375
873B8AEA1B1F5CCA007FD442 /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = Main.storyboard; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
7476
918927202B39C27266615D47 /* Pods-MCJSONKit_Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MCJSONKit_Example.release.xcconfig"; path = "Pods/Target Support Files/Pods-MCJSONKit_Example/Pods-MCJSONKit_Example.release.xcconfig"; sourceTree = "<group>"; };
7577
93190E7B99844BBF7607513E /* Pods-MCJSONKit_Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MCJSONKit_Example.debug.xcconfig"; path = "Pods/Target Support Files/Pods-MCJSONKit_Example/Pods-MCJSONKit_Example.debug.xcconfig"; sourceTree = "<group>"; };
7678
9ABBD34770007F25E1BFC826 /* Pods-MCJSONKit_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MCJSONKit_Tests.release.xcconfig"; path = "Pods/Target Support Files/Pods-MCJSONKit_Tests/Pods-MCJSONKit_Tests.release.xcconfig"; sourceTree = "<group>"; };
7779
B9C051CDCDC5724A854F4F8E /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = "<group>"; };
80+
C55E4A9720A7DA3800DE037D /* MCNSObjectJSONkitTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MCNSObjectJSONkitTest.m; sourceTree = "<group>"; };
81+
C55E4A9B20A7DD8500DE037D /* mock */ = {isa = PBXFileReference; lastKnownFileType = folder; path = mock; sourceTree = "<group>"; };
82+
C55E4AA020A7FD9900DE037D /* MCPerformance.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MCPerformance.m; sourceTree = "<group>"; };
7883
C599F3BD1FAD902D00D19382 /* WeiboRequest.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WeiboRequest.h; sourceTree = "<group>"; };
7984
C599F3BE1FAD902D00D19382 /* LoadingView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LoadingView.m; sourceTree = "<group>"; };
8085
C599F3BF1FAD902D00D19382 /* WBUser.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = WBUser.m; sourceTree = "<group>"; };
@@ -93,7 +98,6 @@
9398
C599F3D11FAD90A900D19382 /* WeiboViewModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WeiboViewModel.h; sourceTree = "<group>"; };
9499
C599F3D31FAD923B00D19382 /* HomeTimelineController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HomeTimelineController.m; sourceTree = "<group>"; };
95100
C599F3D41FAD923B00D19382 /* HomeTimelineController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HomeTimelineController.h; sourceTree = "<group>"; };
96-
C5D2A9BF20A70D5A008998BD /* friends_timeline.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = friends_timeline.json; sourceTree = "<group>"; };
97101
C5D2A9C220A716EB008998BD /* WeiboResult.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WeiboResult.h; sourceTree = "<group>"; };
98102
C5D2A9C320A716EB008998BD /* WeiboResult.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = WeiboResult.m; sourceTree = "<group>"; };
99103
F13FC4735500A7B6B0F6FAA7 /* libPods-MCJSONKit_Example.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-MCJSONKit_Example.a"; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -192,8 +196,10 @@
192196
6003F5B5195388D20070C39A /* Tests */ = {
193197
isa = PBXGroup;
194198
children = (
195-
C5D2A9BF20A70D5A008998BD /* friends_timeline.json */,
196-
6003F5BB195388D20070C39A /* Tests.m */,
199+
C55E4A9B20A7DD8500DE037D /* mock */,
200+
C55E4AA020A7FD9900DE037D /* MCPerformance.m */,
201+
6003F5BB195388D20070C39A /* MCTypeTransformTest.m */,
202+
C55E4A9720A7DA3800DE037D /* MCNSObjectJSONkitTest.m */,
197203
6003F5B6195388D20070C39A /* Supporting Files */,
198204
);
199205
path = Tests;
@@ -383,7 +389,7 @@
383389
isa = PBXResourcesBuildPhase;
384390
buildActionMask = 2147483647;
385391
files = (
386-
C5D2A9C120A70D5D008998BD /* friends_timeline.json in Resources */,
392+
C55E4A9D20A7E17000DE037D /* mock in Resources */,
387393
6003F5BA195388D20070C39A /* InfoPlist.strings in Resources */,
388394
);
389395
runOnlyForDeploymentPostprocessing = 0;
@@ -537,7 +543,9 @@
537543
isa = PBXSourcesBuildPhase;
538544
buildActionMask = 2147483647;
539545
files = (
540-
6003F5BC195388D20070C39A /* Tests.m in Sources */,
546+
C55E4AA120A7FD9900DE037D /* MCPerformance.m in Sources */,
547+
C55E4A9820A7DA3800DE037D /* MCNSObjectJSONkitTest.m in Sources */,
548+
6003F5BC195388D20070C39A /* MCTypeTransformTest.m in Sources */,
541549
);
542550
runOnlyForDeploymentPostprocessing = 0;
543551
};
@@ -664,6 +672,7 @@
664672
GCC_PREPROCESSOR_DEFINITIONS = (
665673
"$(inherited)",
666674
"COCOAPODS=1",
675+
"MJExtensionEnable=0",
667676
);
668677
INFOPLIST_FILE = "MCJSONKit/MCJSONKit-Info.plist";
669678
MODULE_NAME = ExampleApp;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>classNames</key>
6+
<dict>
7+
<key>MCPerformance</key>
8+
<dict>
9+
<key>testPerformanceExample</key>
10+
<dict>
11+
<key>com.apple.XCTPerformanceMetric_WallClockTime</key>
12+
<dict>
13+
<key>baselineAverage</key>
14+
<real>0.41516</real>
15+
<key>baselineIntegrationDisplayName</key>
16+
<string>Local Baseline</string>
17+
</dict>
18+
</dict>
19+
<key>testPerformanceMJExtension</key>
20+
<dict>
21+
<key>com.apple.XCTPerformanceMetric_WallClockTime</key>
22+
<dict>
23+
<key>baselineAverage</key>
24+
<real>0.63441</real>
25+
<key>baselineIntegrationDisplayName</key>
26+
<string>Local Baseline</string>
27+
</dict>
28+
</dict>
29+
</dict>
30+
</dict>
31+
</dict>
32+
</plist>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>runDestinationsByUUID</key>
6+
<dict>
7+
<key>2E4F2B9A-FFB8-442B-8BBE-DBC9E66D15D6</key>
8+
<dict>
9+
<key>localComputer</key>
10+
<dict>
11+
<key>busSpeedInMHz</key>
12+
<integer>100</integer>
13+
<key>cpuCount</key>
14+
<integer>1</integer>
15+
<key>cpuKind</key>
16+
<string>Intel Core i7</string>
17+
<key>cpuSpeedInMHz</key>
18+
<integer>4009</integer>
19+
<key>logicalCPUCoresPerPackage</key>
20+
<integer>8</integer>
21+
<key>modelCode</key>
22+
<string>iMac14,2</string>
23+
<key>physicalCPUCoresPerPackage</key>
24+
<integer>4</integer>
25+
<key>platformIdentifier</key>
26+
<string>com.apple.platform.macosx</string>
27+
</dict>
28+
<key>targetArchitecture</key>
29+
<string>x86_64</string>
30+
<key>targetDevice</key>
31+
<dict>
32+
<key>modelCode</key>
33+
<string>iPhone10,3</string>
34+
<key>platformIdentifier</key>
35+
<string>com.apple.platform.iphonesimulator</string>
36+
</dict>
37+
</dict>
38+
</dict>
39+
</dict>
40+
</plist>

Example/MCJSONKit/Classes/Models/StatuseModel.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
/**
4545
微博的可见性及指定可见分组信息。该object中type取值,0:普通微博,1:私密微博,3:指定分组微博,4:密友微博;list_id为分组的组号
4646
*/
47-
@property (nonatomic, assign) int visible;
47+
@property (nonatomic, copy) NSDictionary *visible;
4848
@property (nonatomic, copy) NSString *listid;
4949

5050
@end

Example/MCJSONKit/Classes/Models/WeiboModel.h

+7-12
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
*/
1616
@property (nonatomic, copy) NSString *created_at;
1717

18-
19-
2018
/**
2119
通过字典创建模型
2220
@@ -28,9 +26,14 @@
2826
+ (NSArray *)arrayOfModelsFromKeyValues:(id)keyValues;
2927

3028
/**
31-
允许的属性名
29+
允许的属性集合,配置后则ignoreSet失效
3230
*/
33-
+ (NSArray *)allowedPropertyNames;
31+
+ (NSSet *)allowedPropertyNames;
32+
33+
/**
34+
忽略的属性集合
35+
*/
36+
+ (NSSet *)ignoreSet;
3437

3538
/**
3639
key关联字段
@@ -39,20 +42,12 @@
3942
*/
4043
+ (NSDictionary *)keyMappingDictionary;
4144

42-
4345
/**
4446
类型关联字典
4547
4648
@return key:对象属性 value:类型class
4749
*/
4850
+ (NSDictionary *)typeMappingDictionary;
49-
50-
51-
/**
52-
忽略,不做处理的属性
53-
*/
54-
+ (NSSet *)ignoreSet;
55-
5651
- (NSDictionary *)toDictionary;
5752
- (NSString *)toJSONString;
5853

Example/MCJSONKit/Classes/Models/WeiboModel.m

+20-11
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
@implementation WeiboModel
1515

1616
+ (void)load {
17+
//格式化输出JSON字符串,默认为NO
1718
[self setPrettyPrinted:YES];
1819
}
1920

@@ -26,7 +27,9 @@ - (void)setCreated_at:(NSString *)created_at {
2627
_created_at = @(date.timeIntervalSince1970).stringValue;
2728
}
2829

29-
#pragma mark - 封装-JSONCore
30+
#pragma mark - 二次封装JSONKit
31+
32+
#if !MJExtensionEnable
3033

3134
+ (instancetype)jsonObjectFromData:(id)data {
3235
return [self mc_objectFromKeyValues:data];
@@ -36,7 +39,7 @@ + (NSArray *)arrayOfModelsFromKeyValues:(id)keyValues {
3639
return [self mc_arrayOfModelsFromKeyValues:keyValues];
3740
}
3841

39-
+ (NSArray *)allowedPropertyNames {
42+
+ (NSSet *)allowedPropertyNames {
4043
return nil;
4144
}
4245

@@ -62,8 +65,8 @@ - (NSString *)toJSONString {
6265

6366
#pragma mark JSONCoreConfig
6467

65-
+ (NSDictionary *)mc_allowedPropertyNames {
66-
return nil;
68+
+ (NSSet *)mc_allowedPropertiesSet {
69+
return [self allowedPropertyNames];
6770
}
6871

6972
+ (NSDictionary *)mc_keyMappingDictionary {
@@ -74,21 +77,25 @@ + (NSDictionary *)mc_typeMappingDictionary {
7477
return [self typeMappingDictionary];
7578
}
7679

77-
+ (NSSet *)mc_ignoreDictionary {
80+
+ (NSSet *)mc_ignorePropertiesSet {
7881
return [self ignoreSet];
7982
}
8083

84+
#endif
85+
8186
#pragma mark - 封装-MJExtension
82-
/*
87+
88+
#if MJExtensionEnable
89+
8390
+ (instancetype)jsonObjectFromData:(id)data {
8491
return [self mj_objectWithKeyValues:data];
8592
}
8693

87-
+ (NSArray *)arrayOfModelsFromDictionaries:(NSArray *)array {
88-
return [self mj_objectArrayWithKeyValuesArray:array];
94+
+ (NSArray *)arrayOfModelsFromKeyValues:(id)keyValues {
95+
return [self mj_objectArrayWithKeyValuesArray:keyValues];
8996
}
9097

91-
+ (NSArray *)allowedPropertyNames {
98+
+ (NSSet *)allowedPropertyNames {
9299
return nil;
93100
}
94101

@@ -125,7 +132,9 @@ + (NSDictionary *)mj_objectClassInArray {
125132
}
126133

127134
+ (NSArray *)mj_allowedPropertyNames {
128-
return [self allowedPropertyNames];
129-
}*/
135+
return [self allowedPropertyNames].allObjects;
136+
}
137+
138+
#endif
130139

131140
@end

Example/MCJSONKit/Classes/Models/WeiboResult.h

+27-1
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,39 @@
1919
/**
2020
广告列表
2121
*/
22-
@property (nonatomic, copy) NSArray *advertises;
22+
@property (nonatomic, strong) NSMutableArray *advertises;
2323

2424
/**
2525
since_id
2626
*/
2727
@property (nonatomic, assign) long since_id;
28+
@property (nonatomic, assign) long next_cursor;
2829

2930
@property (nonatomic, assign) NSInteger uve_blank;
3031

32+
@property (nonatomic, assign, readonly) BOOL hasvisible;
33+
34+
@end
35+
36+
@interface WeiboResult1 : WeiboModel
37+
38+
/**
39+
最新状态
40+
*/
41+
@property (nonatomic, copy) NSArray<StatuseModel *> *statuses;
42+
43+
/**
44+
广告列表
45+
*/
46+
@property (nonatomic, strong) NSMutableArray *advertises;
47+
48+
/**
49+
since_id
50+
*/
51+
@property (nonatomic, assign) long since_id;
52+
53+
@property (nonatomic, copy) NSDate *updateTime;
54+
@property (nonatomic, copy) NSDate *timeStr;
55+
@property (nonatomic, assign) long double max_id;
56+
3157
@end

Example/MCJSONKit/Classes/Models/WeiboResult.m

+16
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,20 @@ + (NSDictionary *)typeMappingDictionary {
1414
return @{@"statuses": [StatuseModel class]};
1515
}
1616

17+
+ (NSSet *)ignoreSet {
18+
return [NSSet setWithObjects:@"next_cursor", nil];
19+
}
20+
21+
@end
22+
23+
@implementation WeiboResult1
24+
25+
+ (NSSet *)allowedPropertyNames {
26+
return [NSSet setWithObjects:@"statuses", @"updateTime", @"timeStr", @"max_id", nil];
27+
}
28+
29+
+ (NSSet *)ignoreSet {
30+
return [NSSet setWithObjects:@"statuses", nil];
31+
}
32+
1733
@end

Example/Podfile.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ PODS:
99
- Kiwi (3.0.0)
1010
- MBProgressHUD (0.9.2)
1111
- MCFoundation (0.1.3)
12-
- MCJSONKit (0.3.0)
12+
- MCJSONKit (0.4.0)
1313
- MCLogger (0.2.5):
1414
- CocoaLumberjack (~> 3.3.0)
1515
- MCFoundation (~> 0.1.1)
@@ -49,7 +49,7 @@ SPEC CHECKSUMS:
4949
Kiwi: fbeafef0f00e4d8f7dcb3420a4930afe70af77f7
5050
MBProgressHUD: 1569cf7ace17a8bac47aabfbb8580a49690386d1
5151
MCFoundation: f03b2f02918ed3d8e6c30cef7ce030cf0b93f9aa
52-
MCJSONKit: 3f671c2770328613d6d2dd3851156e00e823d836
52+
MCJSONKit: b1cc47768aebeef5e3335d1dcc3b0e5d04bc0e79
5353
MCLogger: f258a43a313bfeabcd85781847626a6f51e6a715
5454
MCUIKit: 4d9fb8d30b0cf44bf99605ecd248a3092d6f4e13
5555
MJExtension: 5932755f451458eefa24239358817f8d291240c7

0 commit comments

Comments
 (0)