Permalink
Browse files

Added NSMutableString+Ruby, breaking change: swapCase > swapcase

  • Loading branch information...
1 parent dd6a67f commit 9bec0706702349d6c0263ac5e726cc3b5142108c @zdavison committed Oct 10, 2013
View
@@ -1,12 +1,12 @@
Pod::Spec.new do |s|
s.name = "NSString+Ruby"
- s.version = "1.0b"
+ s.version = "1.1"
s.summary = "NSString category providing common Ruby String methods."
s.homepage = "https://github.com/zdavison/NSString-Ruby"
s.license = 'MIT'
s.author = { "zdavison" => "zac.developer@gmail.com" }
- s.source = { :git => "https://github.com/zdavison/NSString-Ruby.git", :tag => "v1.0b" }
- s.source_files = 'NSString+Ruby/NSString+Ruby.{h,m}'
- s.public_header_files = 'NSString+Ruby/NSString+Ruby.h'
+ s.source = { :git => "https://github.com/zdavison/NSString-Ruby.git", :tag => "1.1" }
+ s.source_files = 'NSString+Ruby/*.{h,m}'
+ s.public_header_files = 'NSString+Ruby/*.h'
s.requires_arc = true
end
@@ -14,6 +14,7 @@
873D11001804A51800BCAC49 /* NSStringRubyTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 873D10FF1804A51800BCAC49 /* NSStringRubyTests.m */; };
87600EA31804A63B0095E6CC /* NSString+Ruby.m in Sources */ = {isa = PBXBuildFile; fileRef = B1DB17EC16DE6AB8005DF97A /* NSString+Ruby.m */; };
87600EA41804A63B0095E6CC /* NSMutableString+Ruby.m in Sources */ = {isa = PBXBuildFile; fileRef = B1D4F38B177C4DAF001CFD4E /* NSMutableString+Ruby.m */; };
+ 879051241806E8840016DA9E /* NSMutableStringRubyTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 879051231806E8840016DA9E /* NSMutableStringRubyTests.m */; };
B1D4F38C177C4DAF001CFD4E /* NSMutableString+Ruby.m in Sources */ = {isa = PBXBuildFile; fileRef = B1D4F38B177C4DAF001CFD4E /* NSMutableString+Ruby.m */; };
B1DB17C416DE6A6F005DF97A /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B1DB17C316DE6A6F005DF97A /* Foundation.framework */; };
B1DB17ED16DE6AB8005DF97A /* NSString+Ruby.m in Sources */ = {isa = PBXBuildFile; fileRef = B1DB17EC16DE6AB8005DF97A /* NSString+Ruby.m */; };
@@ -40,6 +41,7 @@
873D10FD1804A51800BCAC49 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
873D10FF1804A51800BCAC49 /* NSStringRubyTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NSStringRubyTests.m; sourceTree = "<group>"; };
873D11011804A51800BCAC49 /* NSStringRubyTests-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSStringRubyTests-Prefix.pch"; sourceTree = "<group>"; };
+ 879051231806E8840016DA9E /* NSMutableStringRubyTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NSMutableStringRubyTests.m; sourceTree = "<group>"; };
B1D4F38A177C4DAF001CFD4E /* NSMutableString+Ruby.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSMutableString+Ruby.h"; sourceTree = "<group>"; };
B1D4F38B177C4DAF001CFD4E /* NSMutableString+Ruby.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSMutableString+Ruby.m"; sourceTree = "<group>"; };
B1DB17C016DE6A6F005DF97A /* libNSStringRuby.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libNSStringRuby.a; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -79,6 +81,7 @@
isa = PBXGroup;
children = (
873D10FF1804A51800BCAC49 /* NSStringRubyTests.m */,
+ 879051231806E8840016DA9E /* NSMutableStringRubyTests.m */,
873D10FA1804A51800BCAC49 /* Supporting Files */,
);
path = NSStringRubyTests;
@@ -261,6 +264,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
+ 879051241806E8840016DA9E /* NSMutableStringRubyTests.m in Sources */,
87600EA31804A63B0095E6CC /* NSString+Ruby.m in Sources */,
87600EA41804A63B0095E6CC /* NSMutableString+Ruby.m in Sources */,
873D11001804A51800BCAC49 /* NSStringRubyTests.m in Sources */,
@@ -12,20 +12,23 @@
@interface NSMutableString (Ruby)
//Ruby Methods
--(NSString*)chompM;
--(NSString*)deleteM:(NSString*)first, ...;
--(NSString*)lowercaseStringM;
--(NSString*)substituteAllM:(NSDictionary *)subDictionary;
--(NSString*)substituteAllM:(NSString *)pattern with:(NSString *)sub;
--(NSString*)leftStripM;
--(NSString*)reverseM;
--(NSString*)rightStripM;
--(NSString*)squeezeM;
--(NSString*)squeezeM:(NSString *)pattern;
--(NSString*)stripM;
--(NSString*)substituteFirstM:(NSString *)pattern with:(NSString *)sub;
--(NSString*)substituteLastM:(NSString *)pattern with:(NSString *)sub;
--(NSString*)swapCaseM;
--(NSString*)upperCaseStringM;
+-(NSString*)capitalizeInPlace;
+-(NSString*)chompInPlace;
+-(NSString*)chompInPlace:(NSString*)string;
+-(NSString*)chopInPlace;
+-(NSString*)deleteInPlace:(NSString*)first, ...;
+-(NSString*)lowercaseInPlace;
+-(NSString*)substituteAllInPlace:(NSDictionary *)subDictionary;
+-(NSString*)substituteAllInPlace:(NSString *)pattern with:(NSString *)sub;
+-(NSString*)leftStripInPlace;
+-(NSString*)reverseInPlace;
+-(NSString*)rightStripInPlace;
+-(NSString*)squeezeInPlace;
+-(NSString*)squeezeInPlace:(NSString *)pattern;
+-(NSString*)stripInPlace;
+-(NSString*)substituteFirstInPlace:(NSString *)pattern with:(NSString *)sub;
+-(NSString*)substituteLastInPlace:(NSString *)pattern with:(NSString *)sub;
+-(NSString*)swapcaseInPlace;
+-(NSString*)uppercaseInPlace;
@end
@@ -8,24 +8,24 @@
/* Ruby -> Obj-C Equivalents
- #capitalize! capitalizedStringM
- #chomp! chompM
- chompM:
- #chop chopM
- #delete deleteM:
- #downcase lowercaseStringM
- #gsub substituteAllM:
- substituteAllM:pattern
- #lstrip leftStripM
- #reverse reverseM
- #rstrip rightStripM
- #squeeze squeezeM
- squeezeM:
- #strip stripM
- #sub substituteFirstM:
- substituteLastM:
- #swapcase swapCaseM
- #upcase uppercaseStringM
+ #capitalize! capitalizedStringInPlace
+ #chomp! chompInPlace
+ chompInPlace:
+ #chop! chopInPlace
+ #delete! deleteInPlace:
+ #downcase! lowercaseStringInPlace
+ #gsub! substituteAllInPlace:
+ substituteAllInPlace:pattern
+ #lstrip! leftStripInPlace
+ #reverse! reverseInPlace
+ #rstrip! rightStripInPlace
+ #squeeze! squeezeInPlace
+ squeezeInPlace:
+ #strip! stripInPlace
+ #sub! substituteFirstInPlace:
+ substituteLastInPlace:
+ #swapcase! swapcaseInPlace
+ #upcase! uppercaseStringInPlace
*/
@@ -40,7 +40,7 @@ -(NSString*)_delete:(NSString*)first remaining:(va_list)args;
@implementation NSMutableString (Ruby)
--(NSString*)capitalizedStringM{
+-(NSString*)capitalizeInPlace{
NSString *oldString = [NSString stringWithString:self];
[self setString:[self capitalizedString]];
if([oldString isEqualToString:self]){
@@ -50,7 +50,7 @@ -(NSString*)capitalizedStringM{
}
}
--(NSString*)chompM{
+-(NSString*)chompInPlace{
NSString *oldString = [NSString stringWithString:self];
[self setString:[self chomp]];
if([oldString isEqualToString:self]){
@@ -60,7 +60,7 @@ -(NSString*)chompM{
}
}
--(NSString*)chompM:(NSString*)string{
+-(NSString*)chompInPlace:(NSString*)string{
NSString *oldString = [NSString stringWithString:self];
[self setString:[self chomp:string]];
if([oldString isEqualToString:self]){
@@ -70,12 +70,12 @@ -(NSString*)chompM:(NSString*)string{
}
}
--(NSString*)chopM{
+-(NSString*)chopInPlace{
[self setString:[self chop]];
return self;
}
--(NSString*)deleteM:(NSString*)first, ...{
+-(NSString*)deleteInPlace:(NSString*)first, ...{
NSString *oldString = [NSString stringWithString:self];
va_list args;
va_start(args, first);
@@ -88,7 +88,7 @@ -(NSString*)deleteM:(NSString*)first, ...{
}
}
--(NSString*)lowercaseStringM{
+-(NSString*)lowercaseInPlace{
NSString *oldString = [NSString stringWithString:self];
[self setString:[self lowercaseString]];
if([oldString isEqualToString:self]){
@@ -98,7 +98,7 @@ -(NSString*)lowercaseStringM{
}
}
--(NSString*)substituteAllM:(NSDictionary *)subDictionary{
+-(NSString*)substituteAllInPlace:(NSDictionary *)subDictionary{
NSString *oldString = [NSString stringWithString:self];
[self setString:[self substituteAll:subDictionary]];
if([oldString isEqualToString:self]){
@@ -108,7 +108,7 @@ -(NSString*)substituteAllM:(NSDictionary *)subDictionary{
}
}
--(NSString*)substituteAllM:(NSString *)pattern with:(NSString *)sub{
+-(NSString*)substituteAllInPlace:(NSString *)pattern with:(NSString *)sub{
NSString *oldString = [NSString stringWithString:self];
[self setString:[self substituteAll:pattern with:sub]];
if([oldString isEqualToString:self]){
@@ -118,7 +118,7 @@ -(NSString*)substituteAllM:(NSString *)pattern with:(NSString *)sub{
}
}
--(NSString*)leftStripM{
+-(NSString*)leftStripInPlace{
NSString *oldString = [NSString stringWithString:self];
[self setString:[self leftStrip]];
if([oldString isEqualToString:self]){
@@ -128,7 +128,7 @@ -(NSString*)leftStripM{
}
}
--(NSString*)reverseM{
+-(NSString*)reverseInPlace{
NSString *oldString = [NSString stringWithString:self];
[self setString:[self reverse]];
if([oldString isEqualToString:self]){
@@ -138,7 +138,7 @@ -(NSString*)reverseM{
}
}
--(NSString*)rightStripM{
+-(NSString*)rightStripInPlace{
NSString *oldString = [NSString stringWithString:self];
[self setString:[self rightStrip]];
if([oldString isEqualToString:self]){
@@ -148,7 +148,7 @@ -(NSString*)rightStripM{
}
}
--(NSString*)squeezeM{
+-(NSString*)squeezeInPlace{
NSString *oldString = [NSString stringWithString:self];
[self setString:[self squeeze]];
if([oldString isEqualToString:self]){
@@ -158,7 +158,7 @@ -(NSString*)squeezeM{
}
}
--(NSString*)squeezeM:(NSString *)pattern{
+-(NSString*)squeezeInPlace:(NSString *)pattern{
NSString *oldString = [NSString stringWithString:self];
[self setString:[self squeeze:pattern]];
if([oldString isEqualToString:self]){
@@ -168,7 +168,7 @@ -(NSString*)squeezeM:(NSString *)pattern{
}
}
--(NSString*)stripM{
+-(NSString*)stripInPlace{
NSString *oldString = [NSString stringWithString:self];
[self setString:[self strip]];
if([oldString isEqualToString:self]){
@@ -178,7 +178,7 @@ -(NSString*)stripM{
}
}
--(NSString*)substituteFirstM:(NSString *)pattern with:(NSString *)sub{
+-(NSString*)substituteFirstInPlace:(NSString *)pattern with:(NSString *)sub{
NSString *oldString = [NSString stringWithString:self];
[self setString:[self substituteFirst:pattern with:sub]];
if([oldString isEqualToString:self]){
@@ -188,7 +188,7 @@ -(NSString*)substituteFirstM:(NSString *)pattern with:(NSString *)sub{
}
}
--(NSString*)substituteLastM:(NSString *)pattern with:(NSString *)sub{
+-(NSString*)substituteLastInPlace:(NSString *)pattern with:(NSString *)sub{
NSString *oldString = [NSString stringWithString:self];
[self setString:[self substituteLast:pattern with:sub]];
if([oldString isEqualToString:self]){
@@ -198,17 +198,17 @@ -(NSString*)substituteLastM:(NSString *)pattern with:(NSString *)sub{
}
}
--(NSString*)swapCaseM{
+-(NSString*)swapcaseInPlace{
NSString *oldString = [NSString stringWithString:self];
- [self setString:[self swapCase]];
+ [self setString:[self swapcase]];
if([oldString isEqualToString:self]){
return nil;
}else{
return self;
}
}
--(NSString*)upperCaseStringM{
+-(NSString*)uppercaseInPlace{
NSString *oldString = [NSString stringWithString:self];
[self setString:[self uppercaseString]];
if([oldString isEqualToString:self]){
@@ -83,7 +83,7 @@
-(NSString*)substituteAll:(NSString*)pattern with:(NSString*)sub;
-(NSInteger )sum;
-(NSInteger )sum:(NSInteger )bit;
--(NSString*)swapCase;
+-(NSString*)swapcase;
//Subscript Protocol
-(id)objectAtIndexedSubscript:(NSUInteger)index;
@@ -102,7 +102,7 @@
#succ
#sum sum
sum:
- #swapcase swapCase
+ #swapcase swapcase
#to_c
#to_f floatValue
#to_i intValue
@@ -743,7 +743,7 @@ - (NSInteger )sum:(NSInteger )bit{
return (total % (NSInteger )pow(2, bit-1));
}
-- (NSString*)swapCase{
+- (NSString*)swapcase{
unichar *s = calloc(self.length, sizeof(unichar));
[self getCharacters:s];
for(NSInteger i=0;i<self.length;i++){
Oops, something went wrong.

0 comments on commit 9bec070

Please sign in to comment.