Skip to content

Commit

Permalink
Merge branch 'master' into 51_update_afnetworking_pod
Browse files Browse the repository at this point in the history
  • Loading branch information
SergeyKuryanov committed Jul 10, 2018
2 parents 486b240 + 5d0961f commit 885b32b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 21 deletions.
12 changes: 6 additions & 6 deletions Demo/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ PODS:
- AFNetworking/NSURLSession
- librato-iOS (1.2.2):
- AFNetworking (~> 3.2)
- 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`)
Expand All @@ -35,8 +35,8 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
AFNetworking: b6f891fdfaed196b46c7a83cf209e09697b94057
librato-iOS: 2f81a2d383d2f0a7452d8f11284f33608530bdf9
Mantle: f03b2b606c3f0cabd80214ad8a2fed6b464a7359
librato-iOS: 1e81d75af883abe3f588f2ba3b29efd6379c4dfe
Mantle: 2fa750afa478cd625a94230fbf1c13462f29395b

PODFILE CHECKSUM: 5817b13129eeec85d2fa75a097e506a23de0ee12

Expand Down
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', '~> 3.2'
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 885b32b

Please sign in to comment.