-
Notifications
You must be signed in to change notification settings - Fork 232
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
358 additions
and
387 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,20 @@ | ||
import Dependencies | ||
import DependenciesMacros | ||
import ComposableArchitecture | ||
import Foundation | ||
import Tagged | ||
|
||
@DependencyClient | ||
public struct Build { | ||
public var gitSha: () -> String = { "deadbeef" } | ||
public var number: () -> Number = { 0 } | ||
public struct Build: Equatable, Sendable { | ||
public var gitSha = Bundle.main.infoDictionary?["GitSHA"] as? String ?? "" | ||
public var number = Number( | ||
rawValue: (Bundle.main.infoDictionary?["CFBundleVersion"] as? String) | ||
.flatMap(Int.init) | ||
?? 0) | ||
public init() {} | ||
|
||
public typealias Number = Tagged<((), number: ()), Int> | ||
} | ||
|
||
extension DependencyValues { | ||
public var build: Build { | ||
get { self[Build.self] } | ||
set { self[Build.self] = newValue } | ||
extension PersistenceReaderKey where Self == InMemoryKey<Build> { | ||
public static var build: Self { | ||
inMemory("build") | ||
} | ||
} | ||
|
||
extension Build: TestDependencyKey { | ||
public static let previewValue = Self.noop | ||
public static let testValue = Self() | ||
} | ||
|
||
extension Build: DependencyKey { | ||
public static let liveValue = Self( | ||
gitSha: { Bundle.main.infoDictionary?["GitSHA"] as? String ?? "" }, | ||
number: { | ||
.init( | ||
rawValue: (Bundle.main.infoDictionary?["CFBundleVersion"] as? String) | ||
.flatMap(Int.init) | ||
?? 0 | ||
) | ||
} | ||
) | ||
} | ||
|
||
extension Build { | ||
public static let noop = Self( | ||
gitSha: { "deadbeef" }, | ||
number: { 0 } | ||
) | ||
} |
Oops, something went wrong.