Skip to content

Commit

Permalink
Merge pull request ankurp#12 from ankurp/swift-3
Browse files Browse the repository at this point in the history
Updating to use new Swift 3 syntax
  • Loading branch information
ankurp authored Sep 28, 2016
2 parents 669d9a2 + ecf4bce commit 031c881
Show file tree
Hide file tree
Showing 16 changed files with 226 additions and 240 deletions.
3 changes: 0 additions & 3 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
disabled_rules:
- type_body_length
- file_length
- type_name
- line_length
- force_cast
- force_try
Expand Down
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: objective-c
osx_image: xcode7
osx_image: xcode8

script:
- xctool -scheme Cent -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6' ONLY_ACTIVE_ARCH=NO clean build test
- xcodebuild clean build test -scheme Cent -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6'
4 changes: 2 additions & 2 deletions Cent.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "Cent"
s.version = "5.0.3"
s.version = "6.0.0"
s.summary = "Extension for common object types for Swift Language"
s.homepage = "https://github.com/ankurp/Cent"
s.license = { :type => "MIT", :file => "LICENSE" }
Expand All @@ -10,5 +10,5 @@ Pod::Spec.new do |s|
s.requires_arc = true
s.ios.deployment_target = "8.0"
s.osx.deployment_target = "10.10"
s.dependency "Dollar", "~> 5.2.0"
s.dependency "Dollar", "~> 6.0.0"
end
61 changes: 34 additions & 27 deletions Cent.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
42095FA71D9AEF5B0047580B /* CentTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 42095FA11D9AEF460047580B /* CentTests.swift */; };
92180C5F1C71064D003BA0E3 /* Array.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92180C571C71064D003BA0E3 /* Array.swift */; };
92180C601C71064D003BA0E3 /* Cent.h in Headers */ = {isa = PBXBuildFile; fileRef = 92180C581C71064D003BA0E3 /* Cent.h */; settings = {ATTRIBUTES = (Public, ); }; };
92180C611C71064D003BA0E3 /* Date.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92180C591C71064D003BA0E3 /* Date.swift */; };
Expand All @@ -17,7 +18,6 @@
92180C661C71064D003BA0E3 /* String.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92180C5E1C71064D003BA0E3 /* String.swift */; };
925CB1EB1A3FE717004F1319 /* Cent.framework in Copy Files */ = {isa = PBXBuildFile; fileRef = 924F92DC195F8338003DBB60 /* Cent.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
9299310319F747AA00150D45 /* Cent.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 924F92DC195F8338003DBB60 /* Cent.framework */; };
9299310519F747B700150D45 /* CentTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 924F92EE195F8338003DBB60 /* CentTests.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -66,6 +66,8 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
42095FA11D9AEF460047580B /* CentTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = CentTests.swift; path = Tests/CentTests/CentTests.swift; sourceTree = SOURCE_ROOT; };
42095FA41D9AEF530047580B /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = Tests/Info.plist; sourceTree = SOURCE_ROOT; };
92180C571C71064D003BA0E3 /* Array.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Array.swift; path = Sources/Array.swift; sourceTree = SOURCE_ROOT; };
92180C581C71064D003BA0E3 /* Cent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Cent.h; path = Sources/Cent.h; sourceTree = SOURCE_ROOT; };
92180C591C71064D003BA0E3 /* Date.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Date.swift; path = Sources/Date.swift; sourceTree = SOURCE_ROOT; };
Expand All @@ -77,8 +79,6 @@
92180C671C71065C003BA0E3 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = Sources/Info.plist; sourceTree = SOURCE_ROOT; };
92180C6E1C711845003BA0E3 /* Dollar.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = Dollar.xcodeproj; path = Dollar/Dollar.xcodeproj; sourceTree = "<group>"; };
924F92DC195F8338003DBB60 /* Cent.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Cent.framework; sourceTree = BUILT_PRODUCTS_DIR; };
924F92ED195F8338003DBB60 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
924F92EE195F8338003DBB60 /* CentTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CentTests.swift; sourceTree = "<group>"; };
92E6688119F0B89600BB4FB8 /* CentTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CentTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */

Expand Down Expand Up @@ -156,7 +156,7 @@
924F92EB195F8338003DBB60 /* CentTests */ = {
isa = PBXGroup;
children = (
924F92EE195F8338003DBB60 /* CentTests.swift */,
42095FA11D9AEF460047580B /* CentTests.swift */,
924F92EC195F8338003DBB60 /* Supporting Files */,
);
path = CentTests;
Expand All @@ -165,7 +165,7 @@
924F92EC195F8338003DBB60 /* Supporting Files */ = {
isa = PBXGroup;
children = (
924F92ED195F8338003DBB60 /* Info.plist */,
42095FA41D9AEF530047580B /* Info.plist */,
);
name = "Supporting Files";
sourceTree = "<group>";
Expand Down Expand Up @@ -230,15 +230,17 @@
attributes = {
LastSwiftMigration = 0700;
LastSwiftUpdateCheck = 0700;
LastUpgradeCheck = 0700;
LastUpgradeCheck = 0800;
ORGANIZATIONNAME = "Encore Dev Labs LLC";
TargetAttributes = {
924F92DB195F8338003DBB60 = {
CreatedOnToolsVersion = 6.0;
DevelopmentTeam = 38KBGXJ48U;
LastSwiftMigration = 0800;
};
92E6688019F0B89600BB4FB8 = {
CreatedOnToolsVersion = 6.0.1;
LastSwiftMigration = 0800;
};
};
};
Expand Down Expand Up @@ -319,7 +321,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
9299310519F747B700150D45 /* CentTests.swift in Sources */,
42095FA71D9AEF5B0047580B /* CentTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -352,16 +354,20 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
Expand Down Expand Up @@ -400,16 +406,20 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "";
COPY_PHASE_STRIP = YES;
CURRENT_PROJECT_VERSION = 1;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
Expand All @@ -421,6 +431,7 @@
METAL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos macosx";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
VALID_ARCHS = "arm64 armv7 armv7s i386 x86_64";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand All @@ -432,16 +443,14 @@
buildSettings = {
APPLICATION_EXTENSION_API_ONLY = YES;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_IDENTITY = "";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
COMBINE_HIDPI_IMAGES = YES;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
);
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
FRAMEWORK_VERSION = A;
INFOPLIST_FILE = "$(SRCROOT)/Sources/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
Expand All @@ -450,6 +459,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
};
name = Debug;
};
Expand All @@ -458,61 +468,58 @@
buildSettings = {
APPLICATION_EXTENSION_API_ONLY = YES;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_IDENTITY = "";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
COMBINE_HIDPI_IMAGES = YES;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
);
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
FRAMEWORK_VERSION = A;
INFOPLIST_FILE = "$(SRCROOT)/Sources/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.encoredevlabs.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
};
name = Release;
};
92E6688819F0B89700BB4FB8 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_IDENTITY = "";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
);
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
INFOPLIST_FILE = CentTests/Info.plist;
INFOPLIST_FILE = Tests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MTL_ENABLE_DEBUG_INFO = YES;
PRODUCT_BUNDLE_IDENTIFIER = "com.encoredevlabs.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
name = Debug;
};
92E6688919F0B89700BB4FB8 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_IDENTITY = "";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
);
INFOPLIST_FILE = CentTests/Info.plist;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
INFOPLIST_FILE = Tests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MTL_ENABLE_DEBUG_INFO = NO;
PRODUCT_BUNDLE_IDENTIFIER = "com.encoredevlabs.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
VALIDATE_PRODUCT = YES;
};
name = Release;
Expand Down
2 changes: 1 addition & 1 deletion Cent.xcodeproj/xcshareddata/xcschemes/Cent.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0700"
LastUpgradeVersion = "0800"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import PackageDescription
let package = Package(
name: "Cent",
dependencies: [
.Package(url: "https://github.com/ankurp/Dollar", majorVersion: 5, minor: 2)
.Package(url: "https://github.com/ankurp/Dollar", majorVersion: 6, minor: 0)
])
22 changes: 11 additions & 11 deletions Sources/Array.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public extension Array {
/// - parameter callback: The callback function to invoke that take an element
/// - returns: array itself
func eachWithIndex(callback: (Int, Element) -> ()) -> [Element] {
for (index, elem) in self.enumerate() {
for (index, elem) in self.enumerated() {
callback(index, elem)
}
return self
Expand All @@ -51,7 +51,7 @@ public extension Array {
/// - parameter callback: The callback function to invoke
/// - returns: The array itself
func each(callback: (Element) -> ()) -> [Element] {
self.eachWithIndex { (index, elem) -> () in
_ = self.eachWithIndex { (index, elem) -> () in
callback(elem)
}
return self
Expand All @@ -62,7 +62,7 @@ public extension Array {
/// - parameter when: The condition to check each element against
/// - parameter callback: The callback function to invoke
/// - returns: The array itself
func each(when when: (Element) -> Bool, callback: (Element) -> ()) -> [Element] {
func each(when: (Element) -> Bool, callback: (Element) -> ()) -> [Element] {
return $.each(self, when: when, callback: callback)
}

Expand All @@ -80,7 +80,7 @@ public extension Array {
/// - parameter index: Can be positive or negative to find from end of the array
/// - parameter orElse: Default value to use if index is out of bounds
/// - returns: Element fetched from the array or the default value passed in orElse
func fetch(index: Int, orElse: Element? = .None) -> Element! {
func fetch(index: Int, orElse: Element? = .none) -> Element! {
return $.fetch(self, index, orElse: orElse)
}

Expand Down Expand Up @@ -121,7 +121,7 @@ public extension Array {
/// - parameter index: The index in the array
/// - returns: Element at that index
func get(index: Int) -> Element! {
return self.fetch(index)
return self.fetch(index: index)
}

/// Gets all but the last element or last n elements of an array.
Expand Down Expand Up @@ -175,9 +175,9 @@ public extension Array {
/// - returns: Element at that index
mutating func remove<T: Equatable>(value: T) -> T? {
if let index = $.indexOf(map { $0 as! T }, value: value) {
return (removeAtIndex(index) as? T)
return (remove(at: index) as? T)
} else {
return .None
return .none
}
}

Expand All @@ -196,9 +196,9 @@ public extension Array {
/// - parameter combine: the combiner with the result, index, and current element
/// - throws: Rethrows the error generated from combine
/// - returns: combined result
func reduceWithIndex<T>(initial: T, @noescape combine: (T, Int, Array.Generator.Element) throws -> T) rethrows -> T {
func reduceWithIndex<T>(initial: T, combine: (T, Int, Array.Generator.Element) throws -> T) rethrows -> T {
var result = initial
for (index, element) in self.enumerate() {
for (index, element) in self.enumerated() {
result = try combine(result, index, element)
}
return result
Expand Down Expand Up @@ -231,7 +231,7 @@ extension Array where Element: Hashable {
/// - parameter left: array to insert elements into
/// - parameter right: array to source elements from
/// - returns: array with the element appended in the end
public func<<<T>(inout left: [T], right: [T]) -> [T] {
public func<<<T>(left: inout [T], right: [T]) -> [T] {
left += right
return left
}
Expand All @@ -241,7 +241,7 @@ public func<<<T>(inout left: [T], right: [T]) -> [T] {
/// - parameter array: array to insert element into
/// - parameter elem: element to insert
/// - returns: array with the element appended in the end
public func<<<T>(inout array: [T], elem: T) -> [T] {
public func<<<T>( array: inout [T], elem: T) -> [T] {
array.append(elem)
return array
}
Expand Down
Loading

0 comments on commit 031c881

Please sign in to comment.