Skip to content

Commit

Permalink
Merge pull request #52 from amco/51_update_mantle_pod
Browse files Browse the repository at this point in the history
Update Mantle pod
  • Loading branch information
SergeyKuryanov authored Jul 10, 2018
2 parents 1e93c0c + 7486004 commit 5d0961f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 23 deletions.
16 changes: 8 additions & 8 deletions Demo/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ PODS:
- AFNetworking/NSURLSession
- librato-iOS (1.2.2):
- AFNetworking (~> 2.0)
- Mantle (~> 1.3)
- Mantle (1.5.8):
- Mantle/extobjc (= 1.5.8)
- Mantle/extobjc (1.5.8)
- Mantle (~> 2.1)
- Mantle (2.1.0):
- Mantle/extobjc (= 2.1.0)
- Mantle/extobjc (2.1.0)

DEPENDENCIES:
- librato-iOS (from `../librato-iOS.podspec`)

SPEC REPOS:
https://github.com/CocoaPods/Specs.git:
https://github.com/cocoapods/specs.git:
- AFNetworking
- Mantle

Expand All @@ -41,9 +41,9 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
AFNetworking: cb8d14a848e831097108418f5d49217339d4eb60
librato-iOS: ac4f9b431c771cccc0719e8bdade35648fac507d
Mantle: f03b2b606c3f0cabd80214ad8a2fed6b464a7359
librato-iOS: e66bc97e62ef9aa7ca8b94ed318595c8b86cc81d
Mantle: 2fa750afa478cd625a94230fbf1c13462f29395b

PODFILE CHECKSUM: 5817b13129eeec85d2fa75a097e506a23de0ee12

COCOAPODS: 1.5.0
COCOAPODS: 1.5.3
2 changes: 1 addition & 1 deletion librato-iOS.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ Pod::Spec.new do |s|
s.requires_arc = true

s.dependency 'AFNetworking', '~> 2.0'
s.dependency 'Mantle', '~> 1.3'
s.dependency 'Mantle', '~> 2.1'
end
4 changes: 1 addition & 3 deletions librato-iOS/Metrics/LibratoGaugeMetric.m
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,7 @@ + (NSDictionary *)JSONKeyPathsByPropertyKey
@"sum": sumKey,
@"min": minKey,
@"max": maxKey,
@"squares": squaresKey,
@"type": NSNull.null,
LibratoMetricValueKey: NSNull.null
@"squares": squaresKey
};
}

Expand Down
21 changes: 10 additions & 11 deletions librato-iOS/Metrics/LibratoMetric.m
Original file line number Diff line number Diff line change
Expand Up @@ -61,49 +61,48 @@ + (NSDictionary *)JSONKeyPathsByPropertyKey
@"name": LibratoMetricNameKey,
@"value": LibratoMetricValueKey,
@"measureTime": LibratoMetricMeasureTimeKey,
@"source": LibratoMetricSourceKey,
@"type": NSNull.null
@"source": LibratoMetricSourceKey
};
}


+ (NSValueTransformer *)measureTimeJSONTransformer
{
return [MTLValueTransformer reversibleTransformerWithForwardBlock:^id(NSNumber *epoch) {
return [MTLValueTransformer transformerUsingForwardBlock:^id(NSNumber *epoch, BOOL *success, NSError **error) {
return [NSDate dateWithTimeIntervalSince1970:epoch.integerValue];
} reverseBlock:^id(NSDate *date) {
} reverseBlock:^id(NSDate *date, BOOL *success, NSError **error) {
return @(floor(date.timeIntervalSince1970));
}];
}


+ (NSValueTransformer *)nameJSONTransformer
{
return [MTLValueTransformer reversibleTransformerWithForwardBlock:^id(NSString *name) {
return [MTLValueTransformer transformerUsingForwardBlock:^id(NSString *name, BOOL *success, NSError **error) {
NSAssert(name.length > 0, @"Measurements must be named");
return name.alm_sanitizedForMetric;
} reverseBlock:^id(NSString *name) {
} reverseBlock:^id(NSString *name, BOOL *success, NSError **error) {
return name.alm_sanitizedForMetric;
}];
}


+ (NSValueTransformer *)sourceJSONTransformer
{
return [MTLValueTransformer reversibleTransformerWithForwardBlock:^id(NSString *source) {
return [MTLValueTransformer transformerUsingForwardBlock:^id(NSString *source, BOOL *success, NSError **error) {
return source.alm_sanitizedForMetric;
} reverseBlock:^id(NSString *source) {
} reverseBlock:^id(NSString *source, BOOL *success, NSError **error) {
return (source.length ? source.alm_sanitizedForMetric : nil);
}];
}


+ (NSValueTransformer *)valueJSONTransformer
{
return [MTLValueTransformer reversibleTransformerWithForwardBlock:^id(NSNumber *value) {
return [MTLValueTransformer transformerUsingForwardBlock:^id(NSNumber *value, BOOL *success, NSError **error) {
NSAssert([self.class isValidValue:value], @"Boolean is not a valid metric value");
return value;
} reverseBlock:^id(NSNumber *value) {
} reverseBlock:^id(NSNumber *value, BOOL *success, NSError **error) {
return value;
}];
}
Expand All @@ -113,7 +112,7 @@ + (NSValueTransformer *)valueJSONTransformer
- (NSDictionary *)JSONDictionary
{
NSArray *nonNullableKeys = @[@"source"];
__block NSMutableDictionary *jsonDict = [MTLJSONAdapter JSONDictionaryFromModel:self].mutableCopy;
__block NSMutableDictionary *jsonDict = [MTLJSONAdapter JSONDictionaryFromModel:self error:nil].mutableCopy;
[nonNullableKeys enumerateObjectsUsingBlock:^(NSString *key, NSUInteger idx, BOOL *stop) {
if ([jsonDict.allKeys containsObject:key] && (jsonDict[key] == NSNull.null || jsonDict[key] == nil))
{
Expand Down

0 comments on commit 5d0961f

Please sign in to comment.