Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .swift-format
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
},
"maximumBlankLines": 1,
"indentConditionalCompilationBlocks": false,
"rules": {
"AllPublicDeclarationsHaveDocumentation": false
}
"lineBreakBeforeEachArgument": true,
"lineBreakBeforeEachGenericRequirement": true,
"respectsExistingLineBreaks": false
}
20 changes: 10 additions & 10 deletions DevelopmentDependencies/Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions DevelopmentDependencies/Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.2
// swift-tools-version:5.4
import PackageDescription

let package = Package(
Expand All @@ -8,7 +8,7 @@ let package = Package(
],
dependencies: [
.package(url: "https://github.com/JosephDuffy/xcutils.git", .branch("master")),
.package(url: "https://github.com/apple/swift-format.git", .branch("swift-5.2-branch")),
.package(url: "https://github.com/apple/swift-format.git", .exact("0.50400.0")),
],
targets: [
.target(name: "DevelopmentDependencies"),
Expand Down
10 changes: 2 additions & 8 deletions Sources/GatheredKit/Action/Action.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,12 @@ public struct Action {

private let performClosure: () -> Void

public init(
title: String,
isAvailable: Bool,
perform: @escaping () -> Void
) {
public init(title: String, isAvailable: Bool, perform: @escaping () -> Void) {
self.title = title
self.isAvailable = isAvailable
self.performClosure = perform
}

public func perform() {
performClosure()
}
public func perform() { performClosure() }

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ extension CustomisableUpdateIntervalControllable {
Starts performing period updated. The value of the static variable `defaultUpdateInterval` will
used for the update interval.
*/
public func startUpdating() {
startUpdating(every: type(of: self).defaultUpdateInterval)
}
public func startUpdating() { startUpdating(every: type(of: self).defaultUpdateInterval) }

}
4 changes: 1 addition & 3 deletions Sources/GatheredKit/Extensions/String+localized.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ extension String {

var localized: String {
let appLocalizedString = NSLocalizedString(self, comment: "")
guard appLocalizedString == self else {
return appLocalizedString
}
guard appLocalizedString == self else { return appLocalizedString }

let frameworkBundle = Bundle(for: FrameworkClass.self)
return NSLocalizedString(self, bundle: frameworkBundle, comment: "")
Expand Down
17 changes: 7 additions & 10 deletions Sources/GatheredKit/Extensions/castToOptional.swift
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
/// Casts the provided value to `Any?`
///
///
/// This method is required because casting an `Any` to `Any?` wraps the original `Any`
/// in an `Optional`, producing an `Any??`.
///
///
/// To get around this issue if the value passed is actually optional it is matched against
/// the `Optional` case `some`, and the wrapped value is returned, wrapped in an `Optional`, allowing
/// the compiler to correctly treat it as an `Any?`.
///
///
/// If the passed value is not an `Optional` it is wrapped in an `Optional` for concistency.
///
///
/// - parameter value: The value to be cast to `Any?`
/// - returns: The provided value cast to `Any?`
internal func castToOptional(_ value: Any) -> Any? {
// swiftlint:disable syntactic_sugar
switch value {
case Optional<Any>.some(let value):
return Optional(value)
case Optional<Any>.none:
return nil
default:
return Optional(value)
case Optional<Any>.some(let value): return Optional(value)
case Optional<Any>.none: return nil
default: return Optional(value)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ extension AnyProperty {
date: Date = Date()
) -> AccelerationProperty {
return .init(
displayName: displayName, value: value, unit: unit, formatter: formatter, date: date)
displayName: displayName,
value: value,
unit: unit,
formatter: formatter,
date: date
)
}

public static func acceleration(
Expand All @@ -24,7 +29,12 @@ extension AnyProperty {
date: Date = Date()
) -> OptionalAccelerationProperty {
return .init(
displayName: displayName, value: value, unit: unit, formatter: formatter, date: date)
displayName: displayName,
value: value,
unit: unit,
formatter: formatter,
date: date
)
}

public static func metersPerSecondSquared(
Expand All @@ -34,8 +44,12 @@ extension AnyProperty {
date: Date = Date()
) -> AccelerationProperty {
return .init(
displayName: displayName, value: value, unit: .metersPerSecondSquared,
formatter: formatter, date: date)
displayName: displayName,
value: value,
unit: .metersPerSecondSquared,
formatter: formatter,
date: date
)
}

public static func metersPerSecondSquared(
Expand All @@ -45,8 +59,12 @@ extension AnyProperty {
date: Date = Date()
) -> OptionalAccelerationProperty {
return .init(
displayName: displayName, value: value, unit: .metersPerSecondSquared,
formatter: formatter, date: date)
displayName: displayName,
value: value,
unit: .metersPerSecondSquared,
formatter: formatter,
date: date
)
}

public static func gravity(
Expand All @@ -56,7 +74,11 @@ extension AnyProperty {
date: Date = Date()
) -> AccelerationProperty {
return .init(
displayName: displayName, value: value, unit: .gravity, formatter: formatter, date: date
displayName: displayName,
value: value,
unit: .gravity,
formatter: formatter,
date: date
)
}

Expand All @@ -67,7 +89,11 @@ extension AnyProperty {
date: Date = Date()
) -> OptionalAccelerationProperty {
return .init(
displayName: displayName, value: value, unit: .gravity, formatter: formatter, date: date
displayName: displayName,
value: value,
unit: .gravity,
formatter: formatter,
date: date
)
}

Expand Down
38 changes: 32 additions & 6 deletions Sources/GatheredKit/Properties/Measurements/AngleProperty.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ extension AnyProperty {
date: Date = Date()
) -> AngleProperty {
return AngleProperty(
displayName: displayName, value: value, unit: unit, formatter: formatter, date: date)
displayName: displayName,
value: value,
unit: unit,
formatter: formatter,
date: date
)
}

public static func angle(
Expand All @@ -24,7 +29,12 @@ extension AnyProperty {
date: Date = Date()
) -> OptionalAngleProperty {
return OptionalAngleProperty(
displayName: displayName, value: value, unit: unit, formatter: formatter, date: date)
displayName: displayName,
value: value,
unit: unit,
formatter: formatter,
date: date
)
}

public static func degrees(
Expand All @@ -34,7 +44,11 @@ extension AnyProperty {
date: Date = Date()
) -> AngleProperty {
return AngleProperty(
displayName: displayName, value: value, unit: .degrees, formatter: formatter, date: date
displayName: displayName,
value: value,
unit: .degrees,
formatter: formatter,
date: date
)
}

Expand All @@ -45,7 +59,11 @@ extension AnyProperty {
date: Date = Date()
) -> OptionalAngleProperty {
return OptionalAngleProperty(
displayName: displayName, value: value, unit: .degrees, formatter: formatter, date: date
displayName: displayName,
value: value,
unit: .degrees,
formatter: formatter,
date: date
)
}

Expand All @@ -56,7 +74,11 @@ extension AnyProperty {
date: Date = Date()
) -> AngleProperty {
return .init(
displayName: displayName, value: value, unit: .radians, formatter: formatter, date: date
displayName: displayName,
value: value,
unit: .radians,
formatter: formatter,
date: date
)
}

Expand All @@ -67,7 +89,11 @@ extension AnyProperty {
date: Date = Date()
) -> OptionalAngleProperty {
return .init(
displayName: displayName, value: value, unit: .radians, formatter: formatter, date: date
displayName: displayName,
value: value,
unit: .radians,
formatter: formatter,
date: date
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ extension AnyProperty {
date: Date = Date()
) -> FrequencyProperty {
return .init(
displayName: displayName, value: value, unit: unit, formatter: formatter, date: date)
displayName: displayName,
value: value,
unit: unit,
formatter: formatter,
date: date
)
}

public static func frequency(
Expand All @@ -24,7 +29,12 @@ extension AnyProperty {
date: Date = Date()
) -> OptionalFrequencyProperty {
return .init(
displayName: displayName, value: value, unit: unit, formatter: formatter, date: date)
displayName: displayName,
value: value,
unit: unit,
formatter: formatter,
date: date
)
}

public static func radiansPerSecond(
Expand All @@ -34,8 +44,12 @@ extension AnyProperty {
date: Date = Date()
) -> FrequencyProperty {
return .init(
displayName: displayName, value: value, unit: .radiansPerSecond, formatter: formatter,
date: date)
displayName: displayName,
value: value,
unit: .radiansPerSecond,
formatter: formatter,
date: date
)
}

public static func radiansPerSecond(
Expand All @@ -45,8 +59,12 @@ extension AnyProperty {
date: Date = Date()
) -> OptionalFrequencyProperty {
return .init(
displayName: displayName, value: value, unit: .radiansPerSecond, formatter: formatter,
date: date)
displayName: displayName,
value: value,
unit: .radiansPerSecond,
formatter: formatter,
date: date
)
}

}
Loading