Skip to content

Commit ba44ad8

Browse files
committed
Initial Commit
0 parents  commit ba44ad8

File tree

7 files changed

+505
-0
lines changed

7 files changed

+505
-0
lines changed

InflectorKit.podspec

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Pod::Spec.new do |s|
2+
s.name = 'InflectorKit'
3+
s.version = '0.0.1'
4+
s.license = 'MIT'
5+
s.summary = 'Efficiently Singularize and Pluralize Strings.'
6+
s.homepage = 'https://github.com/mattt/InflectorKit'
7+
s.authors = { 'Mattt Thompson' => '[email protected]' }
8+
s.source = { :git => 'https://github.com/mattt/InflectorKit.git', :tag => '0.0.1' }
9+
s.source_files = 'InflectorKit'
10+
s.requires_arc = true
11+
end
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// NSString+InflectorKit.h
2+
//
3+
// Copyright (c) 2013 Mattt Thompson (http://mattt.me)
4+
//
5+
// Permission is hereby granted, free of charge, to any person obtaining a copy
6+
// of this software and associated documentation files (the "Software"), to deal
7+
// in the Software without restriction, including without limitation the rights
8+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
// copies of the Software, and to permit persons to whom the Software is
10+
// furnished to do so, subject to the following conditions:
11+
//
12+
// The above copyright notice and this permission notice shall be included in
13+
// all copies or substantial portions of the Software.
14+
//
15+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
// THE SOFTWARE.
22+
23+
#import <Foundation/Foundation.h>
24+
25+
/**
26+
27+
*/
28+
@interface NSString (InflectorKit)
29+
30+
/**
31+
32+
*/
33+
- (NSString *)singularizedString;
34+
35+
/**
36+
37+
*/
38+
- (NSString *)pluralizedString;
39+
40+
@end
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// NSString+InflectorKit.m
2+
//
3+
// Copyright (c) 2013 Mattt Thompson (http://mattt.me)
4+
//
5+
// Permission is hereby granted, free of charge, to any person obtaining a copy
6+
// of this software and associated documentation files (the "Software"), to deal
7+
// in the Software without restriction, including without limitation the rights
8+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
// copies of the Software, and to permit persons to whom the Software is
10+
// furnished to do so, subject to the following conditions:
11+
//
12+
// The above copyright notice and this permission notice shall be included in
13+
// all copies or substantial portions of the Software.
14+
//
15+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
// THE SOFTWARE.
22+
23+
#import "NSString+InflectorKit.h"
24+
#import "TTTStringInflector.h"
25+
26+
@implementation NSString (InflectorKit)
27+
28+
- (NSString *)singularizedString {
29+
return [[TTTStringInflector defaultInflector] singularize:self];
30+
}
31+
32+
- (NSString *)pluralizedString {
33+
return [[TTTStringInflector defaultInflector] pluralize:self];
34+
}
35+
36+
@end

InflectorKit/TTTStringInflector.h

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
// TTTStringInflector.h
2+
//
3+
// Copyright (c) 2013 Mattt Thompson (http://mattt.me)
4+
//
5+
// Permission is hereby granted, free of charge, to any person obtaining a copy
6+
// of this software and associated documentation files (the "Software"), to deal
7+
// in the Software without restriction, including without limitation the rights
8+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
// copies of the Software, and to permit persons to whom the Software is
10+
// furnished to do so, subject to the following conditions:
11+
//
12+
// The above copyright notice and this permission notice shall be included in
13+
// all copies or substantial portions of the Software.
14+
//
15+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
// THE SOFTWARE.
22+
23+
#import <Foundation/Foundation.h>
24+
25+
/**
26+
27+
*/
28+
@interface TTTStringInflector : NSObject
29+
30+
/**
31+
32+
*/
33+
+ (instancetype)defaultInflector;
34+
35+
///=========================
36+
/// @name Inflecting Strings
37+
///=========================
38+
39+
/**
40+
41+
*/
42+
- (NSString *)singularize:(NSString *)string;
43+
44+
/**
45+
46+
*/
47+
- (NSString *)pluralize:(NSString *)string;
48+
49+
///===================
50+
/// @name Adding Rules
51+
///===================
52+
53+
/**
54+
55+
*/
56+
- (void)addSingularRule:(NSString *)rule
57+
withReplacement:(NSString *)replacement;
58+
59+
/**
60+
61+
*/
62+
- (void)addPluralRule:(NSString *)rule
63+
withReplacement:(NSString *)replacement;
64+
65+
/**
66+
67+
*/
68+
- (void)addIrregularWithSingular:(NSString *)singular
69+
plural:(NSString *)plural;
70+
71+
/**
72+
73+
*/
74+
- (void)addUncountable:(NSString *)word;
75+
76+
@end

0 commit comments

Comments
 (0)