Skip to content

Commit

Permalink
Merge branch 'deploy/3.0.0' into productive
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeehut committed Apr 30, 2019
2 parents f736ec0 + 82f7c8d commit 4225d76
Show file tree
Hide file tree
Showing 22 changed files with 246 additions and 102 deletions.
7 changes: 0 additions & 7 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ opt_in_rules:
- multiline_parameters
- multiline_parameters_brackets
- nimble_operator
- no_extension_access_modifier
- number_separator
- object_literal
- operator_usage_whitespace
Expand Down Expand Up @@ -280,12 +279,6 @@ custom_rules:
name: "Remove Where for Negative Filtering"
message: "Use `remove(where:)` instead of `filter(where not ...)` for performance."
severity: warning
self_conditional_binding:
included: ".*.swift"
regex: '\s+`?\w+`?(?<! strongSelf)\s*=\s*self\s'
name: "Self Conditional Binding"
message: "Constants with conditional binding on `self` should be named `strongSelf`."
severity: warning
single_line_enum_cases:
included: ".*.swift"
regex: 'enum [^\{]+\{\s*(?:\s*\/\/[^\n]*)*\s*case\s+[^,(\n]+,'
Expand Down
20 changes: 17 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
### Addedge
- None.
### Changed
- None.
- None.
### Deprecated
- None.
### Removed
Expand All @@ -17,15 +17,29 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
### Security
- None.

## [3.0.0] - 2019-04-30
### Addedge
- New `Withable` protocol to init/copy objects and set properties in a convenient way on a single line.
### Changed
- Upgraded to Swift 5 & Xcode 10.2.
### Deprecated
- None.
### Removed
- Remove `ExpressibleByStringLiteral` conformance of `Regex` type to only allow initialization via `init(_:options:) throws` interface.
### Fixed
- None.
### Security
- None.


## [2.8.0]
## [2.8.0] - 2019-02-11
### Added
- New `NSRange(_:in:)` initializer for converting from `Range<String.Index>`
- New `sum` computed property on `Sequence` types like `Array`
- New `average` computed property on `Collection` types with `Int` or `Double` elements like `[Int]`
- New `fullRange` and `fullNSRange` computed properties on `String`
### Changed
- Made some APIs available in wider contexts (like `sample` in `RandomAccessCollection` instead of `Array`)
- Made some APIs available in wider contexts (like `sample` in `RandomAccessCollection` instead of `Array`)
### Deprecated
- None.
### Removed
Expand Down
21 changes: 0 additions & 21 deletions Frameworks/HandySwift/Extensions/ArrayExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -114,27 +114,6 @@ extension RandomAccessCollection where Index == Int {
}
}

extension Sequence where Element: Numeric {
/// Returns the sum of all elements.
public func sum() -> Element {
return reduce(0, +)
}
}

extension Collection where Element == Int {
/// Returns the average of all elements as a Double value.
public func average() -> Double {
return reduce(0) { $0 + Double($1) } / Double(count)
}
}

extension Collection where Element == Double {
/// Returns the average of all elements as a Double value.
public func average() -> Double {
return reduce(0, +) / Double(count)
}
}

extension Array where Element: Comparable {
/// Sorts the collection in place by the order specified in the closure.
///
Expand Down
21 changes: 21 additions & 0 deletions Frameworks/HandySwift/Extensions/CollectionExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,24 @@ extension Collection {
return indices.contains(index) ? self[index] : nil
}
}

extension Sequence where Element: Numeric {
/// Returns the sum of all elements.
public func sum() -> Element {
return reduce(0, +)
}
}

extension Collection where Element == Int {
/// Returns the average of all elements as a Double value.
public func average() -> Double {
return reduce(0) { $0 + Double($1) } / Double(count)
}
}

extension Collection where Element == Double {
/// Returns the average of all elements as a Double value.
public func average() -> Double {
return reduce(0, +) / Double(count)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ extension DispatchTimeInterval {

case .never:
return TimeInterval.infinity

@unknown default:
fatalError("Unknown DispatchTimeInterval unit.")
}
}
}
9 changes: 4 additions & 5 deletions Frameworks/HandySwift/Extensions/StringExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,14 @@ extension String {

extension String {
/// The type of allowed characters.
///
/// - Numeric: Allow all numbers from 0 to 9.
/// - Alphabetic: Allow all alphabetic characters ignoring case.
/// - AlphaNumeric: Allow both numbers and alphabetic characters ignoring case.
/// - AllCharactersIn: Allow all characters appearing within the specified String.
public enum AllowedCharacters {
/// Allow all numbers from 0 to 9.
case numeric
/// Allow all alphabetic characters ignoring case.
case alphabetic
/// Allow both numbers and alphabetic characters ignoring case.
case alphaNumeric
/// Allow all characters appearing within the specified String.
case allCharactersIn(String)
}
}
25 changes: 25 additions & 0 deletions Frameworks/HandySwift/Protocols/Withable.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// Created by Cihat Gündüz on 30.04.19.
// Copyright © 2019 Flinesoft. All rights reserved.
//

/// Simple protocol to make constructing and modifying objects with multiple properties more pleasant (functional, chainable, point-free).
public protocol Withable {
/// Default initializer without parameters to support Withable protocol.
init()
}

extension Withable {
/// Construct a new instance, setting an arbitrary subset of properties.
public init(with config: (inout Self) -> Void) {
self.init()
config(&self)
}

/// Create a copy, overriding an arbitrary subset of properties.
public func with(_ config: (inout Self) -> Void) -> Self {
var copy = self
config(&copy)
return copy
}
}
23 changes: 3 additions & 20 deletions Frameworks/HandySwift/Structs/Regex.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,23 +101,6 @@ public struct Regex {
}
}

// MARK: - ExpressibleByStringLiteral
extension Regex: ExpressibleByStringLiteral {
@available(*, deprecated, message: "Use `init(_:options:) throws` instead.")
/// Creates a new `Regex` based on a string literal.
/// If the internal initialization fails, the code will crash without any option to handle the error.
/// For safe `Regex` initialization, use the `init(_: String, options: Options) throws` overload instead.
///
/// - parameter stringLiteral: The pattern string.
public init(stringLiteral value: String) {
do {
try self.init(value)
} catch {
preconditionFailure("Not a valid regex: \(value)")
}
}
}

// MARK: - CustomStringConvertible
extension Regex: CustomStringConvertible {
/// Returns a string describing the regex using its pattern string.
Expand All @@ -139,9 +122,9 @@ extension Regex: Equatable {

// MARK: - Hashable
extension Regex: Hashable {
/// Returns a unique hash value for the `Regex` instance.
public var hashValue: Int {
return regularExpression.hashValue
/// Manages hashing of the `Regex` instance.
public func hash(into hasher: inout Hasher) {
hasher.combine(regularExpression)
}
}

Expand Down
2 changes: 1 addition & 1 deletion Frameworks/HandySwift/Structs/SortedArray.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public struct SortedArray<Element: Comparable> {
/// - Parameters:
/// - newElement: The new element to be inserted into the array.
public mutating func insert(newElement: Element) {
let insertIndex = internalArray.index { $0 >= newElement } ?? internalArray.endIndex
let insertIndex = internalArray.firstIndex { $0 >= newElement } ?? internalArray.endIndex
internalArray.insert(newElement, at: insertIndex)
}

Expand Down
2 changes: 1 addition & 1 deletion Frameworks/SupportingFiles/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>2.8.0
<string>3.0.0
</string>
<key>CFBundleSignature</key>
<string>????</string>
Expand Down
3 changes: 1 addition & 2 deletions HandySwift.podspec
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
Pod::Spec.new do |s|

s.name = "HandySwift"
s.version = "2.8.0
"
s.version = "3.0.0"
s.summary = "Handy Swift features that didn't make it into the Swift standard library"

s.description = <<-DESC
Expand Down
Loading

0 comments on commit 4225d76

Please sign in to comment.