Skip to content

Commit

Permalink
Prefix category name and methods
Browse files Browse the repository at this point in the history
  • Loading branch information
SergeyKuryanov committed Oct 20, 2016
1 parent 3724624 commit 06301d1
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 22 deletions.
5 changes: 2 additions & 3 deletions Demo/librato-iOS Demo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
71FE433FB985CA1AB0DF6BDA /* Pods-librato-iOS Demo.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-librato-iOS Demo.debug.xcconfig"; path = "Pods/Target Support Files/Pods-librato-iOS Demo/Pods-librato-iOS Demo.debug.xcconfig"; sourceTree = "<group>"; };
B3CFB32942D9D0C3245EEB4E /* Pods-librato-iOS Demo.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-librato-iOS Demo.release.xcconfig"; path = "Pods/Target Support Files/Pods-librato-iOS Demo/Pods-librato-iOS Demo.release.xcconfig"; sourceTree = "<group>"; };
C5A2D3C7197B48C6A9ACC07D /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; };
D9263DD61DB946660035CC6E /* NSString+SanitizedForMetricTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+SanitizedForMetricTests.m"; sourceTree = "<group>"; };
D9263DD61DB946660035CC6E /* NSString+AULSanitizedForMetricTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+AULSanitizedForMetricTests.m"; sourceTree = "<group>"; };
F8E7DC6EE1A84E81B6B7B7A2 /* libPods-librato-iOS Demo.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-librato-iOS Demo.a"; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */

Expand Down Expand Up @@ -148,7 +148,7 @@
isa = PBXGroup;
children = (
66922642180358B000237E77 /* librato_iOS_DemoTests.m */,
D9263DD61DB946660035CC6E /* NSString+SanitizedForMetricTests.m */,
D9263DD61DB946660035CC6E /* NSString+AULSanitizedForMetricTests.m */,
6692263D180358B000237E77 /* Supporting Files */,
);
path = "librato-iOS DemoTests";
Expand Down Expand Up @@ -331,7 +331,6 @@
buildActionMask = 2147483647;
files = (
66922643180358B000237E77 /* librato_iOS_DemoTests.m in Sources */,
D9263DD71DB946660035CC6E /* NSString+SanitizedForMetricTests.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

#import <XCTest/XCTest.h>
#import "NSString+SanitizedForMetric.h"
#import "NSString+AULSanitizedForMetric.h"

@interface NSString_SanitizedForMetricTests : XCTestCase
@property (nonatomic, strong) NSString *testString;
Expand Down
12 changes: 6 additions & 6 deletions librato-iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
6692259917FE44B800237E77 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6692258117FE44B800237E77 /* UIKit.framework */; };
669225A117FE44B800237E77 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 6692259F17FE44B800237E77 /* InfoPlist.strings */; };
669225A317FE44B800237E77 /* librato_iOSTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 669225A217FE44B800237E77 /* librato_iOSTests.m */; };
669225B117FE457800237E77 /* NSString+SanitizedForMetric.m in Sources */ = {isa = PBXBuildFile; fileRef = 669225B017FE457800237E77 /* NSString+SanitizedForMetric.m */; };
669225B117FE457800237E77 /* NSString+AYLSanitizedForMetric.m in Sources */ = {isa = PBXBuildFile; fileRef = 669225B017FE457800237E77 /* NSString+AYLSanitizedForMetric.m */; };
669225C017FE458100237E77 /* LibratoClient.m in Sources */ = {isa = PBXBuildFile; fileRef = 669225B317FE458100237E77 /* LibratoClient.m */; };
669225C117FE458100237E77 /* LibratoConnection.m in Sources */ = {isa = PBXBuildFile; fileRef = 669225B517FE458100237E77 /* LibratoConnection.m */; };
669225C217FE458100237E77 /* LibratoDirectPersister.m in Sources */ = {isa = PBXBuildFile; fileRef = 669225B717FE458100237E77 /* LibratoDirectPersister.m */; };
Expand Down Expand Up @@ -57,8 +57,8 @@
6692259E17FE44B800237E77 /* librato-iOSTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "librato-iOSTests-Info.plist"; sourceTree = "<group>"; };
669225A017FE44B800237E77 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
669225A217FE44B800237E77 /* librato_iOSTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = librato_iOSTests.m; sourceTree = "<group>"; };
669225AF17FE457800237E77 /* NSString+SanitizedForMetric.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+SanitizedForMetric.h"; sourceTree = "<group>"; };
669225B017FE457800237E77 /* NSString+SanitizedForMetric.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+SanitizedForMetric.m"; sourceTree = "<group>"; };
669225AF17FE457800237E77 /* NSString+AYLSanitizedForMetric.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+AYLSanitizedForMetric.h"; sourceTree = "<group>"; };
669225B017FE457800237E77 /* NSString+AYLSanitizedForMetric.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+AYLSanitizedForMetric.m"; sourceTree = "<group>"; };
669225B217FE458100237E77 /* LibratoClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LibratoClient.h; sourceTree = "<group>"; };
669225B317FE458100237E77 /* LibratoClient.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LibratoClient.m; sourceTree = "<group>"; };
669225B417FE458100237E77 /* LibratoConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LibratoConnection.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -184,8 +184,8 @@
669225AC17FE454800237E77 /* Categories */ = {
isa = PBXGroup;
children = (
669225AF17FE457800237E77 /* NSString+SanitizedForMetric.h */,
669225B017FE457800237E77 /* NSString+SanitizedForMetric.m */,
669225AF17FE457800237E77 /* NSString+AYLSanitizedForMetric.h */,
669225B017FE457800237E77 /* NSString+AYLSanitizedForMetric.m */,
);
path = Categories;
sourceTree = "<group>";
Expand Down Expand Up @@ -335,7 +335,7 @@
669225C417FE458100237E77 /* LibratoProcessor.m in Sources */,
669225C517FE458100237E77 /* LibratoQueue.m in Sources */,
6692260A17FF3C2A00237E77 /* Librato.m in Sources */,
669225B117FE457800237E77 /* NSString+SanitizedForMetric.m in Sources */,
669225B117FE457800237E77 /* NSString+AYLSanitizedForMetric.m in Sources */,
669225C617FE458100237E77 /* LibratoVersion.m in Sources */,
669225CC17FE458800237E77 /* LibratoMetric.m in Sources */,
669225C017FE458100237E77 /* LibratoClient.m in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// NSString+SanitizedForMetric.h
// NSString+AYLSanitizedForMetric.h
// Librato-iOS
//
// Created by Adam Yanalunas on 10/3/13.
Expand All @@ -8,8 +8,8 @@

#import <Foundation/Foundation.h>

@interface NSString (SanitizedForMetric)
@interface NSString (AYLSanitizedForMetric)

- (NSString *)sanitizedForMetric;
- (NSString *)ayl_sanitizedForMetric;

@end
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
//
// NSString+SanitizedForMetric.m
// NSString+AYLSanitizedForMetric.m
// Librato-iOS
//
// Created by Adam Yanalunas on 10/3/13.
// Copyright (c) 2013 Amco International Education Services, LLC. All rights reserved.
//

#import "NSString+SanitizedForMetric.h"
#import "NSString+AYLSanitizedForMetric.h"

@implementation NSString (SanitizedForMetric)
@implementation NSString (AYLSanitizedForMetric)

- (NSString *)sanitizedForMetric
- (NSString *)ayl_sanitizedForMetric
{
NSCharacterSet *allowedSet = [NSCharacterSet characterSetWithCharactersInString:@"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:-_"];
NSString *cleaned = [[self componentsSeparatedByCharactersInSet:allowedSet.invertedSet] componentsJoinedByString:@"-"];
Expand Down
10 changes: 5 additions & 5 deletions librato-iOS/Metrics/LibratoMetric.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

#import "LibratoMetric.h"
#import "NSString+SanitizedForMetric.h"
#import "NSString+AYLSanitizedForMetric.h"
#import "MTLValueTransformer.h"

NSString *const LibratoMetricMeasureTimeKey = @"measure_time";
Expand Down Expand Up @@ -81,19 +81,19 @@ + (NSValueTransformer *)nameJSONTransformer
{
return [MTLValueTransformer reversibleTransformerWithForwardBlock:^id(NSString *name) {
NSAssert(name.length > 0, @"Measurements must be named");
return name.sanitizedForMetric;
return name.ayl_sanitizedForMetric;
} reverseBlock:^id(NSString *name) {
return name.sanitizedForMetric;
return name.ayl_sanitizedForMetric;
}];
}


+ (NSValueTransformer *)sourceJSONTransformer
{
return [MTLValueTransformer reversibleTransformerWithForwardBlock:^id(NSString *source) {
return source.sanitizedForMetric;
return source.ayl_sanitizedForMetric;
} reverseBlock:^id(NSString *source) {
return (source.length ? source.sanitizedForMetric : nil);
return (source.length ? source.ayl_sanitizedForMetric : nil);
}];
}

Expand Down

0 comments on commit 06301d1

Please sign in to comment.