Skip to content
This repository has been archived by the owner on Jan 25, 2019. It is now read-only.

Commit

Permalink
Merge pull request #46 from robb/string-support
Browse files Browse the repository at this point in the history
[WIP] String support
  • Loading branch information
robb committed Dec 23, 2013
2 parents fc8b22f + 2449906 commit fe8f189
Show file tree
Hide file tree
Showing 10 changed files with 729 additions and 9 deletions.
24 changes: 24 additions & 0 deletions .gitignore
@@ -0,0 +1,24 @@
# OS X
.DS_Store

# Xcode
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
profile
*.moved-aside
DerivedData
*.hmap
*.xccheckout

# CocoaPods
Pods

4 changes: 4 additions & 0 deletions Podfile
@@ -0,0 +1,4 @@
target :UnderscoreTests, :exclusive => true do
pod 'Specta', '0.1.11'
pod 'Expecta', '0.2.2'
end
13 changes: 13 additions & 0 deletions Podfile.lock
@@ -0,0 +1,13 @@
PODS:
- Expecta (0.2.2)
- Specta (0.1.11)

DEPENDENCIES:
- Expecta (= 0.2.2)
- Specta (= 0.1.11)

SPEC CHECKSUMS:
Expecta: 99adbb2e366a02796477523bfd426143350d9caf
Specta: 82746c6fd70b104c5d37cfbadb7bf15a2cbc4da0

COCOAPODS: 0.28.0
90 changes: 81 additions & 9 deletions Underscore.xcodeproj/project.pbxproj
Expand Up @@ -12,14 +12,11 @@
54567D99154DDED4000F38AC /* Underscore.h in Headers */ = {isa = PBXBuildFile; fileRef = 54A3DCCD154DD4BF00387DE3 /* Underscore.h */; settings = {ATTRIBUTES = (Public, ); }; };
547C44DB15B30ADD004698B8 /* Underscore+Functional.h in Headers */ = {isa = PBXBuildFile; fileRef = 547C44D915B30ADC004698B8 /* Underscore+Functional.h */; };
547C44DC15B30ADD004698B8 /* Underscore+Functional.m in Sources */ = {isa = PBXBuildFile; fileRef = 547C44DA15B30ADD004698B8 /* Underscore+Functional.m */; };
547C44DD15B30B8D004698B8 /* Underscore+Functional.m in Sources */ = {isa = PBXBuildFile; fileRef = 547C44DA15B30ADD004698B8 /* Underscore+Functional.m */; };
54903D13155FF779006854CB /* USArrayWrapper.h in Headers */ = {isa = PBXBuildFile; fileRef = 54903D11155FF779006854CB /* USArrayWrapper.h */; };
54903D14155FF779006854CB /* USArrayWrapper.m in Sources */ = {isa = PBXBuildFile; fileRef = 54903D12155FF779006854CB /* USArrayWrapper.m */; };
54903D1B15600A45006854CB /* USArrayTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 54903D1A15600A45006854CB /* USArrayTest.m */; };
54903D2115602003006854CB /* USArrayWrapper.m in Sources */ = {isa = PBXBuildFile; fileRef = 54903D12155FF779006854CB /* USArrayWrapper.m */; };
54996B2315614B220016BE94 /* USDictionaryWrapper.h in Headers */ = {isa = PBXBuildFile; fileRef = 54996B2115614B220016BE94 /* USDictionaryWrapper.h */; };
54996B2415614B220016BE94 /* USDictionaryWrapper.m in Sources */ = {isa = PBXBuildFile; fileRef = 54996B2215614B220016BE94 /* USDictionaryWrapper.m */; };
54996B2515614B220016BE94 /* USDictionaryWrapper.m in Sources */ = {isa = PBXBuildFile; fileRef = 54996B2215614B220016BE94 /* USDictionaryWrapper.m */; };
54996B2D15614F900016BE94 /* USConstants.h in Headers */ = {isa = PBXBuildFile; fileRef = 54996B2C15614F900016BE94 /* USConstants.h */; };
54996B371561576D0016BE94 /* USDictionaryTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 54996B361561576D0016BE94 /* USDictionaryTest.m */; };
54A3DCC9154DD4BF00387DE3 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 54A3DCC8154DD4BF00387DE3 /* Foundation.framework */; };
Expand All @@ -28,6 +25,12 @@
54A3DCDA154DD4BF00387DE3 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 54A3DCC8154DD4BF00387DE3 /* Foundation.framework */; };
54A3DCDD154DD4BF00387DE3 /* libUnderscore.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 54A3DCC5154DD4BF00387DE3 /* libUnderscore.a */; };
54A3DCE3154DD4BF00387DE3 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 54A3DCE1154DD4BF00387DE3 /* InfoPlist.strings */; };
6775CC96B4B74AF283884A0A /* libPods-UnderscoreTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 44D4915E525F41A183CA3B1D /* libPods-UnderscoreTests.a */; };
BCFADFF31837E77000A81EB5 /* Underscore+Strings.h in Headers */ = {isa = PBXBuildFile; fileRef = BCFADFEF1837E77000A81EB5 /* Underscore+Strings.h */; };
BCFADFF41837E77000A81EB5 /* Underscore+Strings.m in Sources */ = {isa = PBXBuildFile; fileRef = BCFADFF01837E77000A81EB5 /* Underscore+Strings.m */; };
BCFADFF61837E77000A81EB5 /* USStringWrapper.h in Headers */ = {isa = PBXBuildFile; fileRef = BCFADFF11837E77000A81EB5 /* USStringWrapper.h */; };
BCFADFF71837E77000A81EB5 /* USStringWrapper.m in Sources */ = {isa = PBXBuildFile; fileRef = BCFADFF21837E77000A81EB5 /* USStringWrapper.m */; };
BCFADFFC1837EBE600A81EB5 /* UnderscoreStringsSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = BCFADFF91837EBA200A81EB5 /* UnderscoreStringsSpec.m */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand All @@ -41,6 +44,8 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
3074062DBA9E4660841E3D0A /* Pods-UnderscoreTests.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-UnderscoreTests.xcconfig"; path = "Pods/Pods-UnderscoreTests.xcconfig"; sourceTree = "<group>"; };
44D4915E525F41A183CA3B1D /* libPods-UnderscoreTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-UnderscoreTests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
541D18A515616E2400599033 /* Underscore.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Underscore.m; sourceTree = "<group>"; };
541D18A81561726C00599033 /* HelperTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HelperTest.h; sourceTree = "<group>"; };
541D18A91561726C00599033 /* HelperTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HelperTest.m; sourceTree = "<group>"; };
Expand All @@ -64,6 +69,12 @@
54A3DCD8154DD4BF00387DE3 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; };
54A3DCE0154DD4BF00387DE3 /* UnderscoreTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "UnderscoreTests-Info.plist"; sourceTree = "<group>"; };
54A3DCE2154DD4BF00387DE3 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
54DDBDDF1837AAEB002EAEB3 /* UnderscoreTests-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UnderscoreTests-Prefix.pch"; sourceTree = "<group>"; };
BCFADFEF1837E77000A81EB5 /* Underscore+Strings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "Underscore+Strings.h"; path = "Strings/Underscore+Strings.h"; sourceTree = "<group>"; };
BCFADFF01837E77000A81EB5 /* Underscore+Strings.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "Underscore+Strings.m"; path = "Strings/Underscore+Strings.m"; sourceTree = "<group>"; };
BCFADFF11837E77000A81EB5 /* USStringWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = USStringWrapper.h; path = Strings/USStringWrapper.h; sourceTree = "<group>"; };
BCFADFF21837E77000A81EB5 /* USStringWrapper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = USStringWrapper.m; path = Strings/USStringWrapper.m; sourceTree = "<group>"; };
BCFADFF91837EBA200A81EB5 /* UnderscoreStringsSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = UnderscoreStringsSpec.m; path = Strings/UnderscoreStringsSpec.m; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand All @@ -83,6 +94,7 @@
54A3DCD9154DD4BF00387DE3 /* UIKit.framework in Frameworks */,
54A3DCDA154DD4BF00387DE3 /* Foundation.framework in Frameworks */,
54A3DCDD154DD4BF00387DE3 /* libUnderscore.a in Frameworks */,
6775CC96B4B74AF283884A0A /* libPods-UnderscoreTests.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -96,6 +108,7 @@
54A3DCDE154DD4BF00387DE3 /* UnderscoreTests */,
54A3DCC7154DD4BF00387DE3 /* Frameworks */,
54A3DCC6154DD4BF00387DE3 /* Products */,
3074062DBA9E4660841E3D0A /* Pods-UnderscoreTests.xcconfig */,
);
sourceTree = "<group>";
};
Expand All @@ -114,13 +127,15 @@
54A3DCC8154DD4BF00387DE3 /* Foundation.framework */,
54A3DCD6154DD4BF00387DE3 /* SenTestingKit.framework */,
54A3DCD8154DD4BF00387DE3 /* UIKit.framework */,
44D4915E525F41A183CA3B1D /* libPods-UnderscoreTests.a */,
);
name = Frameworks;
sourceTree = "<group>";
};
54A3DCCA154DD4BF00387DE3 /* Underscore */ = {
isa = PBXGroup;
children = (
BCFADFE91837D5F700A81EB5 /* Strings */,
54A3DCCD154DD4BF00387DE3 /* Underscore.h */,
541D18A515616E2400599033 /* Underscore.m */,
547C44D915B30ADC004698B8 /* Underscore+Functional.h */,
Expand All @@ -146,13 +161,14 @@
54A3DCDE154DD4BF00387DE3 /* UnderscoreTests */ = {
isa = PBXGroup;
children = (
54A3DCDF154DD4BF00387DE3 /* Supporting Files */,
BCFADFFB1837EBC100A81EB5 /* Strings */,
54903D1915600A45006854CB /* USArrayTest.h */,
54903D1A15600A45006854CB /* USArrayTest.m */,
54996B351561576D0016BE94 /* USDictionaryTest.h */,
54996B361561576D0016BE94 /* USDictionaryTest.m */,
541D18A81561726C00599033 /* HelperTest.h */,
541D18A91561726C00599033 /* HelperTest.m */,
54A3DCDF154DD4BF00387DE3 /* Supporting Files */,
);
path = UnderscoreTests;
sourceTree = "<group>";
Expand All @@ -162,10 +178,30 @@
children = (
54A3DCE0154DD4BF00387DE3 /* UnderscoreTests-Info.plist */,
54A3DCE1154DD4BF00387DE3 /* InfoPlist.strings */,
54DDBDDF1837AAEB002EAEB3 /* UnderscoreTests-Prefix.pch */,
);
name = "Supporting Files";
sourceTree = "<group>";
};
BCFADFE91837D5F700A81EB5 /* Strings */ = {
isa = PBXGroup;
children = (
BCFADFEF1837E77000A81EB5 /* Underscore+Strings.h */,
BCFADFF01837E77000A81EB5 /* Underscore+Strings.m */,
BCFADFF11837E77000A81EB5 /* USStringWrapper.h */,
BCFADFF21837E77000A81EB5 /* USStringWrapper.m */,
);
name = Strings;
sourceTree = "<group>";
};
BCFADFFB1837EBC100A81EB5 /* Strings */ = {
isa = PBXGroup;
children = (
BCFADFF91837EBA200A81EB5 /* UnderscoreStringsSpec.m */,
);
name = Strings;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXHeadersBuildPhase section */
Expand All @@ -174,9 +210,11 @@
buildActionMask = 2147483647;
files = (
54567D99154DDED4000F38AC /* Underscore.h in Headers */,
BCFADFF31837E77000A81EB5 /* Underscore+Strings.h in Headers */,
54903D13155FF779006854CB /* USArrayWrapper.h in Headers */,
54996B2315614B220016BE94 /* USDictionaryWrapper.h in Headers */,
54996B2D15614F900016BE94 /* USConstants.h in Headers */,
BCFADFF61837E77000A81EB5 /* USStringWrapper.h in Headers */,
547C44DB15B30ADD004698B8 /* Underscore+Functional.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -205,10 +243,12 @@
isa = PBXNativeTarget;
buildConfigurationList = 54A3DCEC154DD4BF00387DE3 /* Build configuration list for PBXNativeTarget "UnderscoreTests" */;
buildPhases = (
05E919BE37484386820D8966 /* Check Pods Manifest.lock */,
54A3DCD0154DD4BF00387DE3 /* Sources */,
54A3DCD1154DD4BF00387DE3 /* Frameworks */,
54A3DCD2154DD4BF00387DE3 /* Resources */,
54A3DCD3154DD4BF00387DE3 /* ShellScript */,
1F2BDAFB2B734AC0A0FF4000 /* Copy Pods Resources */,
);
buildRules = (
);
Expand Down Expand Up @@ -259,6 +299,36 @@
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
05E919BE37484386820D8966 /* Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Check Pods Manifest.lock";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
1F2BDAFB2B734AC0A0FF4000 /* Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Copy Pods Resources";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Pods-UnderscoreTests-resources.sh\"\n";
showEnvVarsInLog = 0;
};
54A3DCD3154DD4BF00387DE3 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand All @@ -282,6 +352,8 @@
54903D14155FF779006854CB /* USArrayWrapper.m in Sources */,
54996B2415614B220016BE94 /* USDictionaryWrapper.m in Sources */,
541D18A615616E2400599033 /* Underscore.m in Sources */,
BCFADFF71837E77000A81EB5 /* USStringWrapper.m in Sources */,
BCFADFF41837E77000A81EB5 /* Underscore+Strings.m in Sources */,
547C44DC15B30ADD004698B8 /* Underscore+Functional.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -291,11 +363,9 @@
buildActionMask = 2147483647;
files = (
54903D1B15600A45006854CB /* USArrayTest.m in Sources */,
54903D2115602003006854CB /* USArrayWrapper.m in Sources */,
54996B2515614B220016BE94 /* USDictionaryWrapper.m in Sources */,
BCFADFFC1837EBE600A81EB5 /* UnderscoreStringsSpec.m in Sources */,
54996B371561576D0016BE94 /* USDictionaryTest.m in Sources */,
541D18AA1561726C00599033 /* HelperTest.m in Sources */,
547C44DD15B30B8D004698B8 /* Underscore+Functional.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -399,13 +469,14 @@
};
54A3DCED154DD4BF00387DE3 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 3074062DBA9E4660841E3D0A /* Pods-UnderscoreTests.xcconfig */;
buildSettings = {
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(DEVELOPER_LIBRARY_DIR)/Frameworks",
);
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "Underscore/Underscore-Prefix.pch";
GCC_PREFIX_HEADER = "UnderscoreTests/UnderscoreTests-Prefix.pch";
INFOPLIST_FILE = "UnderscoreTests/UnderscoreTests-Info.plist";
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = octest;
Expand All @@ -414,13 +485,14 @@
};
54A3DCEE154DD4BF00387DE3 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 3074062DBA9E4660841E3D0A /* Pods-UnderscoreTests.xcconfig */;
buildSettings = {
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(DEVELOPER_LIBRARY_DIR)/Frameworks",
);
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "Underscore/Underscore-Prefix.pch";
GCC_PREFIX_HEADER = "UnderscoreTests/UnderscoreTests-Prefix.pch";
INFOPLIST_FILE = "UnderscoreTests/UnderscoreTests-Info.plist";
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = octest;
Expand Down
78 changes: 78 additions & 0 deletions Underscore/Strings/USStringWrapper.h
@@ -0,0 +1,78 @@
//
// USStringWrapper.h
// Underscore
//
// Created by Vasco d'Orey on 16/11/13.
// Copyright (c) 2013 Robert Böhnke. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//

#import <Foundation/Foundation.h>
#import "Underscore+Functional.h"
#import "USArrayWrapper.h"

@interface USStringWrapper : NSObject

+(instancetype) wrap:(NSString *)string;

-(id) init __deprecated_msg("You should use Underscore.string() instead.");

@property (readonly) NSString *unwrap;

/**
* Removes any leading and trailing whitespace character.
*/
@property (readonly) USStringWrapper *trim;

/**
* Capitalizes the first character in every word, all other characters are lowercase'd
*/
@property (readonly) USStringWrapper *capitalize;

/**
* Lowercases all characters.
*/
@property (readonly) USStringWrapper *lowercase;

/**
* Uppercases all characters.
*/
@property (readonly) USStringWrapper *uppercase;

/**
* Removes occurences of the given string.
*/
@property (readonly) USStringWrapper *(^strip)(NSString *strip);

/**
* Splits the string at the given separator. Returns a nil array if the separator is nil.
*/
@property (readonly) USArrayWrapper *(^split)(NSString *separator);

@end

@interface USArrayWrapper (USStrings)

/**
* Joins the elements in the array.
*/
@property (readonly) USStringWrapper *(^join)(NSString *joiner);

@end

0 comments on commit fe8f189

Please sign in to comment.