diff --git a/HandySwift.podspec b/HandySwift.podspec index 64a5b85..67ec964 100644 --- a/HandySwift.podspec +++ b/HandySwift.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "HandySwift" - s.version = "2.0.1" + s.version = "2.1.0" s.summary = "Handy Swift features that didn't make it into the Swift standard library" s.description = <<-DESC diff --git a/HandySwift.xcodeproj/project.pbxproj b/HandySwift.xcodeproj/project.pbxproj index e91a517..98a26c7 100644 --- a/HandySwift.xcodeproj/project.pbxproj +++ b/HandySwift.xcodeproj/project.pbxproj @@ -51,6 +51,9 @@ 826F69B01C389DB800B2CC6B /* FrequencyTableTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 826F69AF1C389DB800B2CC6B /* FrequencyTableTests.swift */; }; 826F69B11C389DB800B2CC6B /* FrequencyTableTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 826F69AF1C389DB800B2CC6B /* FrequencyTableTests.swift */; }; 826F69B21C389DB800B2CC6B /* FrequencyTableTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 826F69AF1C389DB800B2CC6B /* FrequencyTableTests.swift */; }; + 827599641E520FB800787F99 /* DispatchTimeIntervalExtensionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 827599631E520FB800787F99 /* DispatchTimeIntervalExtensionTests.swift */; }; + 827599651E520FB800787F99 /* DispatchTimeIntervalExtensionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 827599631E520FB800787F99 /* DispatchTimeIntervalExtensionTests.swift */; }; + 827599661E520FB800787F99 /* DispatchTimeIntervalExtensionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 827599631E520FB800787F99 /* DispatchTimeIntervalExtensionTests.swift */; }; 8280D7DC1C4A6EC9001172EF /* DictionaryExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8280D7DB1C4A6EC9001172EF /* DictionaryExtension.swift */; }; 8280D7DD1C4A6EC9001172EF /* DictionaryExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8280D7DB1C4A6EC9001172EF /* DictionaryExtension.swift */; }; 8280D7DE1C4A6EC9001172EF /* DictionaryExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8280D7DB1C4A6EC9001172EF /* DictionaryExtension.swift */; }; @@ -116,6 +119,7 @@ 825EFDF21C33351300558497 /* HandySwift tvOS Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "HandySwift tvOS Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; 826F69AB1C3895A300B2CC6B /* FrequencyTable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FrequencyTable.swift; sourceTree = ""; }; 826F69AF1C389DB800B2CC6B /* FrequencyTableTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FrequencyTableTests.swift; sourceTree = ""; }; + 827599631E520FB800787F99 /* DispatchTimeIntervalExtensionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DispatchTimeIntervalExtensionTests.swift; sourceTree = ""; }; 8280D7DB1C4A6EC9001172EF /* DictionaryExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DictionaryExtension.swift; sourceTree = ""; }; 8280D7DF1C4A6FF3001172EF /* DictionaryExtensionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DictionaryExtensionTests.swift; sourceTree = ""; }; 82812A9A1D06877B00CD5B6C /* Globals.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Globals.swift; sourceTree = ""; }; @@ -228,6 +232,7 @@ 82CAE2971C2EE95200F934A7 /* ArrayExtensionTests.swift */, 825EFDC21C332AD200558497 /* CharacterViewExtensionTests.swift */, 8280D7DF1C4A6FF3001172EF /* DictionaryExtensionTests.swift */, + 827599631E520FB800787F99 /* DispatchTimeIntervalExtensionTests.swift */, ); path = Extensions; sourceTree = ""; @@ -614,6 +619,7 @@ buildActionMask = 2147483647; files = ( 826F69B01C389DB800B2CC6B /* FrequencyTableTests.swift in Sources */, + 827599641E520FB800787F99 /* DispatchTimeIntervalExtensionTests.swift in Sources */, 825EFDC31C332AD200558497 /* CharacterViewExtensionTests.swift in Sources */, 8258E4591C2E1ACE0031CBFF /* SortedArrayTests.swift in Sources */, 825EFDC11C332ABB00558497 /* IntegerTypeExtensionTests.swift in Sources */, @@ -647,6 +653,7 @@ buildActionMask = 2147483647; files = ( 826F69B11C389DB800B2CC6B /* FrequencyTableTests.swift in Sources */, + 827599651E520FB800787F99 /* DispatchTimeIntervalExtensionTests.swift in Sources */, 825EFE131C3335A400558497 /* CharacterViewExtensionTests.swift in Sources */, 825EFE111C3335A400558497 /* StringExtensionTests.swift in Sources */, 825EFE0E1C3335A400558497 /* SortedArrayTests.swift in Sources */, @@ -680,6 +687,7 @@ buildActionMask = 2147483647; files = ( 826F69B21C389DB800B2CC6B /* FrequencyTableTests.swift in Sources */, + 827599661E520FB800787F99 /* DispatchTimeIntervalExtensionTests.swift in Sources */, 825EFE191C3335A500558497 /* CharacterViewExtensionTests.swift in Sources */, 825EFE171C3335A500558497 /* StringExtensionTests.swift in Sources */, 825EFE141C3335A500558497 /* SortedArrayTests.swift in Sources */, diff --git a/LICENSE.md b/LICENSE.md index 419dacc..4ec62c0 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,6 +1,6 @@ # The MIT License (MIT) -**Copyright (c) 2015-2016 Flinesoft** +**Copyright (c) 2015-2017 Flinesoft** Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index dbf7332..76b3141 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,8 @@ alt="codebeat badge"> - Version: 2.0.1 + Version: 2.1.0 Swift: 3.0 @@ -56,7 +56,7 @@ You can of course also just include this framework manually into your project by Place the following line to your Cartfile: ``` Swift -github "Flinesoft/HandySwift" +github "Flinesoft/HandySwift" ~> 2.1 ``` Now run `carthage update`. Then drag & drop the HandySwift.framework in the Carthage/build folder to your project. Now you can `import HandySwift` in each class you want to use its features. Refer to the [Carthage README](https://github.com/Carthage/Carthage#adding-frameworks-to-an-application) for detailed / updated instructions. @@ -71,7 +71,7 @@ platform :ios, '8.0' use_frameworks! target 'MyAppTarget' do - pod 'HandySwift', '~> 1.0' + pod 'HandySwift', '~> 2.1' end ``` @@ -94,6 +94,7 @@ Open the Playground from within the `.xcworkspace` in order for it to work. - [StringExtension](#stringextension) - [ArrayExtension](#arrayextension) - [DictionaryExtension](#dictionaryextension) + - [DispatchTimeIntervalExtension](#dispatchtimeintervalextension) - New types - [SortedArray](#sortedarray) - [FrequencyTable](#frequencytable) @@ -197,7 +198,6 @@ Returns an array with `size` random elements or nil if array empty. ([] as [Int]).sample(size: 3) // => nil ``` - #### .combinations(with:) Combines each element with each element of a given other array. @@ -207,6 +207,7 @@ Combines each element with each element of a given other array. // => [(1, "A"), (1, "B"), (2, "A"), (2, "B"), (3, "A"), (3, "B")] ``` + ### DictionaryExtension #### init?(keys:values:) @@ -242,6 +243,16 @@ immutableDict.merged(with: ["B": "New B value", "C": "C value"]) // => ["A": "A value", "B": "New B value", "C": "C value"] ``` +### DispatchTimeIntervalExtension +#### .timeInterval + +Returns a `TimeInterval` object from a `DispatchTimeInterval`. + +``` Swift +DispatchTimeInterval.milliseconds(500).timeInterval // => 0.5 +``` + + ### SortedArray The main purpose of this wrapper is to provide speed improvements for specific actions on sorted arrays. diff --git a/Sources/Extensions/DispatchTimeIntervalExtension.swift b/Sources/Extensions/DispatchTimeIntervalExtension.swift index 0107c90..d8bea75 100644 --- a/Sources/Extensions/DispatchTimeIntervalExtension.swift +++ b/Sources/Extensions/DispatchTimeIntervalExtension.swift @@ -12,7 +12,7 @@ public typealias Timespan = DispatchTimeInterval extension Timespan { /// - Returns: The time in seconds using the`TimeInterval` type. - var timeInterval: TimeInterval { + public var timeInterval: TimeInterval { switch self { case .seconds(let seconds): return Double(seconds) diff --git a/Sources/Supporting Files/Info.plist b/Sources/Supporting Files/Info.plist index 783e22e..dca568e 100644 --- a/Sources/Supporting Files/Info.plist +++ b/Sources/Supporting Files/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 2.0.1 + 2.1.0 CFBundleSignature ???? CFBundleVersion diff --git a/Tests/Extensions/DispatchTimeIntervalExtensionTests.swift b/Tests/Extensions/DispatchTimeIntervalExtensionTests.swift new file mode 100644 index 0000000..cf897c2 --- /dev/null +++ b/Tests/Extensions/DispatchTimeIntervalExtensionTests.swift @@ -0,0 +1,20 @@ +// +// DispatchTimeIntervalExtensionTests.swift +// HandySwift +// +// Created by Cihat Gündüz on 13.02.17. +// Copyright © 2017 Flinesoft. All rights reserved. +// + +import XCTest + +@testable import HandySwift + +class DispatchTimeIntervalTests: XCTestCase { + func testTimeInterval() { + let dispatchTimeInterval = DispatchTimeInterval.milliseconds(500) + let timeInterval = dispatchTimeInterval.timeInterval + + XCTAssertEqualWithAccuracy(timeInterval, 0.5, accuracy: 0.001) + } +} diff --git a/UsageExamples.playground/Contents.swift b/UsageExamples.playground/Contents.swift index 7b3fddd..2f0b77f 100644 --- a/UsageExamples.playground/Contents.swift +++ b/UsageExamples.playground/Contents.swift @@ -123,6 +123,12 @@ mergedDict //: Combines each element with each element of a given other array. [1, 2, 3].combinations(with: ["A", "B"]) +//: ## DispatchTimeIntervalExtension +//: ### .timeInterval +//: Returns a `TimeInterval` object from a `DispatchTimeInterval`. + +DispatchTimeInterval.milliseconds(500).timeInterval + //: # Added Structures //: New structures added to extend the Swift standard library. //: ## SortedArray