소스 검색

update docs and bump the version to 0.9.8

ibireme 9 년 전
부모
커밋
403a17eff3
6개의 변경된 파일67개의 추가작업 그리고 31개의 파일을 삭제
  1. 1 1
      Framework/Info.plist
  2. 2 2
      README.md
  3. 1 1
      YYModel.podspec
  4. 48 26
      YYModel/YYClassInfo.h
  5. 10 0
      YYModelTests/YYTestAutoTypeConvert.m
  6. 5 1
      YYModelTests/YYTestModelMapper.m

+ 1 - 1
Framework/Info.plist

@@ -15,7 +15,7 @@
 	<key>CFBundlePackageType</key>
 	<string>FMWK</string>
 	<key>CFBundleShortVersionString</key>
-	<string>0.9.7</string>
+	<string>0.9.8</string>
 	<key>CFBundleSignature</key>
 	<string>????</string>
 	<key>CFBundleVersion</key>

+ 2 - 2
README.md

@@ -31,7 +31,7 @@ Features
 - **Type Safe**: All data types will be verified to ensure type-safe during the conversion process.
 - **Non-intrusive**: There is no need to make the model class inherit from other base class.
 - **Lightwight**: This library contains only 5 files.
-
+- **Docs and unit testing**: Coverage 100%.
 
 Usage
 ==============
@@ -328,7 +328,7 @@ YYModel is provided under the MIT license. See LICENSE file for details.
 - **类型安全**: 转换过程中,所有的数据类型都会被检测一遍,以保证类型安全,避免崩溃问题。
 - **无侵入性**: 模型无需继承自其他基类。
 - **轻量**: 该框架只有 5 个文件 (包括.h文件)。
-
+- **文档和单元测试**: 覆盖率 100%。
 
 使用方法
 ==============

+ 1 - 1
YYModel.podspec

@@ -1,7 +1,7 @@
 Pod::Spec.new do |s|
   s.name         = 'YYModel'
   s.summary      = 'High performance model framework for iOS.'
-  s.version      = '0.9.7'
+  s.version      = '0.9.8'
   s.license      = { :type => 'MIT', :file => 'LICENSE' }
   s.authors      = { 'ibireme' => 'ibireme@gmail.com' }
   s.social_media_url = 'http://blog.ibireme.com'

+ 48 - 26
YYModel/YYClassInfo.h

@@ -78,55 +78,77 @@ YYEncodingType YYEncodingGetType(const char *typeEncoding);
  Instance variable information.
  */
 @interface YYClassIvarInfo : NSObject
-@property (nonatomic, assign, readonly) Ivar ivar;
-@property (nonatomic, strong, readonly) NSString *name; ///< Ivar's name
-@property (nonatomic, assign, readonly) ptrdiff_t offset; ///< Ivar's offset
+@property (nonatomic, assign, readonly) Ivar ivar;              ///< ivar opaque struct
+@property (nonatomic, strong, readonly) NSString *name;         ///< Ivar's name
+@property (nonatomic, assign, readonly) ptrdiff_t offset;       ///< Ivar's offset
 @property (nonatomic, strong, readonly) NSString *typeEncoding; ///< Ivar's type encoding
-@property (nonatomic, assign, readonly) YYEncodingType type; ///< Ivar's type
+@property (nonatomic, assign, readonly) YYEncodingType type;    ///< Ivar's type
+
+/**
+ Creates and returns an ivar info object.
+ 
+ @param ivar ivar opaque struct
+ @return A new object, or nil if an error occurs.
+ */
 - (instancetype)initWithIvar:(Ivar)ivar;
 @end
 
+
 /**
  Method information.
  */
 @interface YYClassMethodInfo : NSObject
-@property (nonatomic, assign, readonly) Method method;
-@property (nonatomic, strong, readonly) NSString *name; ///< method name
-@property (nonatomic, assign, readonly) SEL sel; ///< method's selector
-@property (nonatomic, assign, readonly) IMP imp; ///< method's implementation
-@property (nonatomic, strong, readonly) NSString *typeEncoding; ///< method's parameter and return types
-@property (nonatomic, strong, readonly) NSString *returnTypeEncoding; ///< return value's type
+@property (nonatomic, assign, readonly) Method method;                  ///< method opaque struct
+@property (nonatomic, strong, readonly) NSString *name;                 ///< method name
+@property (nonatomic, assign, readonly) SEL sel;                        ///< method's selector
+@property (nonatomic, assign, readonly) IMP imp;                        ///< method's implementation
+@property (nonatomic, strong, readonly) NSString *typeEncoding;         ///< method's parameter and return types
+@property (nonatomic, strong, readonly) NSString *returnTypeEncoding;   ///< return value's type
 @property (nonatomic, strong, readonly) NSArray *argumentTypeEncodings; ///< array of arguments' type
+
+/**
+ Creates and returns a method info object.
+ 
+ @param method method opaque struct
+ @return A new object, or nil if an error occurs.
+ */
 - (instancetype)initWithMethod:(Method)method;
 @end
 
+
 /**
  Property information.
  */
 @interface YYClassPropertyInfo : NSObject
-@property (nonatomic, assign, readonly) objc_property_t property;
-@property (nonatomic, strong, readonly) NSString *name; ///< property's name
-@property (nonatomic, assign, readonly) YYEncodingType type; ///< property's type
-@property (nonatomic, strong, readonly) NSString *typeEncoding; ///< property's encoding value
-@property (nonatomic, strong, readonly) NSString *ivarName; ///< property's ivar name
-@property (nonatomic, assign, readonly) Class cls; ///< may be nil
-@property (nonatomic, strong, readonly) NSString *getter; ///< getter (nonnull)
-@property (nonatomic, strong, readonly) NSString *setter; ///< setter (nonnull)
+@property (nonatomic, assign, readonly) objc_property_t property; ///< property's opaque struct
+@property (nonatomic, strong, readonly) NSString *name;           ///< property's name
+@property (nonatomic, assign, readonly) YYEncodingType type;      ///< property's type
+@property (nonatomic, strong, readonly) NSString *typeEncoding;   ///< property's encoding value
+@property (nonatomic, strong, readonly) NSString *ivarName;       ///< property's ivar name
+@property (nonatomic, assign, readonly) Class cls;                ///< may be nil
+@property (nonatomic, strong, readonly) NSString *getter;         ///< getter (nonnull)
+@property (nonatomic, strong, readonly) NSString *setter;         ///< setter (nonnull)
+
+/**
+ Creates and returns a property info object.
+ 
+ @param property property opaque struct
+ @return A new object, or nil if an error occurs.
+ */
 - (instancetype)initWithProperty:(objc_property_t)property;
 @end
 
+
 /**
  Class information for a class.
  */
 @interface YYClassInfo : NSObject
-
-@property (nonatomic, assign, readonly) Class cls;
-@property (nonatomic, assign, readonly) Class superCls;
-@property (nonatomic, assign, readonly) Class metaCls;
-@property (nonatomic, assign, readonly) BOOL isMeta;
-@property (nonatomic, strong, readonly) NSString *name;
-@property (nonatomic, strong, readonly) YYClassInfo *superClassInfo;
-
+@property (nonatomic, assign, readonly) Class cls;      ///< class object
+@property (nonatomic, assign, readonly) Class superCls; ///< super class object
+@property (nonatomic, assign, readonly) Class metaCls;  ///< class's meta class object
+@property (nonatomic, assign, readonly) BOOL isMeta;    ///< whether this class is meta class
+@property (nonatomic, strong, readonly) NSString *name; ///< class name
+@property (nonatomic, strong, readonly) YYClassInfo *superClassInfo; ///< super class's class info
 @property (nonatomic, strong, readonly) NSDictionary *ivarInfos;     ///< key:NSString(ivar),     value:YYClassIvarInfo
 @property (nonatomic, strong, readonly) NSDictionary *methodInfos;   ///< key:NSString(selector), value:YYClassMethodInfo
 @property (nonatomic, strong, readonly) NSDictionary *propertyInfos; ///< key:NSString(property), value:YYClassPropertyInfo

+ 10 - 0
YYModelTests/YYTestAutoTypeConvert.m

@@ -370,6 +370,16 @@
     XCTAssertTrue(model.object == nil);
 }
 
+- (void)testBlock {
+    int (^block)(void) = ^{return 12;};
+    NSDictionary *dic = @{@"v":block};
+    YYTestAutoTypeModel *model = [YYTestAutoTypeModel yy_modelWithDictionary:dic];
+    XCTAssertNotNil(model.blockValue);
+    
+    block = (id)model.blockValue;
+    XCTAssertTrue(block() == 12);
+}
+
 - (void)testArrayAndDic {
     NSString *json;
     

+ 5 - 1
YYModelTests/YYTestModelMapper.m

@@ -39,7 +39,7 @@
               @"desc2" : @"ext.d", // mapped to same key path
               @"desc3" : @"ext.d.e",
               @"desc4" : @".ext",
-              @"modelID" : @[@"ID", @"Id", @"id"]};
+              @"modelID" : @[@"ID", @"Id", @"id", @"ext.id"]};
 }
 @end
 
@@ -151,6 +151,10 @@
     model = [YYTestPropertyMapperModelCustom yy_modelWithJSON:json];
     XCTAssertTrue([model.modelID isEqualToString:@"abcd"]);
     
+    json = @"{\"ext\":{\"id\":\"abcd\"}}";
+    model = [YYTestPropertyMapperModelCustom yy_modelWithJSON:json];
+    XCTAssertTrue([model.modelID isEqualToString:@"abcd"]);
+    
     json = @"{\"id\":\"abcd\",\"ID\":\"ABCD\",\"Id\":\"Abcd\"}";
     model = [YYTestPropertyMapperModelCustom yy_modelWithJSON:json];
     XCTAssertTrue([model.modelID isEqualToString:@"ABCD"]);