Skip to content

Commit

Permalink
Merge pull request #1 from riiid/feature/AddComposableArchitecture
Browse files Browse the repository at this point in the history
Move to ComposableLogsSheetKit
  • Loading branch information
yermukhanbet authored Oct 6, 2022
2 parents 007fff4 + e924527 commit dc1611f
Show file tree
Hide file tree
Showing 11 changed files with 365 additions and 194 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1400"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "ComposableLogsSheetKit"
BuildableName = "ComposableLogsSheetKit"
BlueprintName = "ComposableLogsSheetKit"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "NO"
buildForArchiving = "NO"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "ComposableLogsSheetKitTests"
BuildableName = "ComposableLogsSheetKitTests"
BlueprintName = "ComposableLogsSheetKitTests"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "ComposableLogsSheetKitTests"
BuildableName = "ComposableLogsSheetKitTests"
BlueprintName = "ComposableLogsSheetKitTests"
ReferencedContainer = "container:">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "ComposableLogsSheetKit"
BuildableName = "ComposableLogsSheetKit"
BlueprintName = "ComposableLogsSheetKit"
ReferencedContainer = "container:">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1400"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "NO"
buildForArchiving = "NO"
buildForAnalyzing = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "ComposableLogsSheetKitTests"
BuildableName = "ComposableLogsSheetKitTests"
BlueprintName = "ComposableLogsSheetKitTests"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "ComposableLogsSheetKitTests"
BuildableName = "ComposableLogsSheetKitTests"
BlueprintName = "ComposableLogsSheetKitTests"
ReferencedContainer = "container:">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "ComposableLogsSheetKitTests"
BuildableName = "ComposableLogsSheetKitTests"
BlueprintName = "ComposableLogsSheetKitTests"
ReferencedContainer = "container:">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
72 changes: 72 additions & 0 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
{
"pins" : [
{
"identity" : "combine-schedulers",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/combine-schedulers",
"state" : {
"revision" : "aa3e575929f2bcc5bad012bd2575eae716cbcdf7",
"version" : "0.8.0"
}
},
{
"identity" : "logssheetkit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/riiid/LogsSheetKit",
"state" : {
"revision" : "5bb7cc405d718e86f9362e6a335230e2e295801b",
"version" : "0.9.0"
}
},
{
"identity" : "spindicator",
"kind" : "remoteSourceControl",
Expand All @@ -8,6 +26,60 @@
"revision" : "43600857729d9efff046dc6673e6f94e095882c7",
"version" : "1.6.4"
}
},
{
"identity" : "swift-case-paths",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-case-paths",
"state" : {
"revision" : "7346701ea29da0a85d4403cf3d7a589a58ae3dee",
"version" : "0.9.2"
}
},
{
"identity" : "swift-collections",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-collections",
"state" : {
"revision" : "f504716c27d2e5d4144fa4794b12129301d17729",
"version" : "1.0.3"
}
},
{
"identity" : "swift-composable-architecture",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-composable-architecture",
"state" : {
"revision" : "9ea8c763061287052a68d5e6723fed45e898b7d9",
"version" : "0.40.2"
}
},
{
"identity" : "swift-custom-dump",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-custom-dump",
"state" : {
"revision" : "819d9d370cd721c9d87671e29d947279292e4541",
"version" : "0.6.0"
}
},
{
"identity" : "swift-identified-collections",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-identified-collections",
"state" : {
"revision" : "bfb0d43e75a15b6dfac770bf33479e8393884a36",
"version" : "0.4.1"
}
},
{
"identity" : "xctest-dynamic-overlay",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/xctest-dynamic-overlay",
"state" : {
"revision" : "30314f1ece684dd60679d598a9b89107557b67d9",
"version" : "0.4.1"
}
}
],
"version" : 2
Expand Down
21 changes: 13 additions & 8 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,31 @@
import PackageDescription

let package = Package(
name: "LogsSheetKit",
name: "ComposableLogsSheetKit",
platforms: [
.iOS(.v14)
],
products: [
.library(
name: "LogsSheetKit",
targets: ["LogsSheetKit"]),
name: "ComposableLogsSheetKit",
targets: ["ComposableLogsSheetKit"]),
],
dependencies: [
.package(url: "https://github.com/ivanvorobei/SPIndicator", .upToNextMajor(from: "1.6.0"))
.package(url: "https://github.com/pointfreeco/swift-composable-architecture", .upToNextMajor(from: "0.40.0")),
.package(url: "https://github.com/riiid/LogsSheetKit", .upToNextMajor(from: "0.9.0"))
],
targets: [
.target(
name: "LogsSheetKit",
name: "ComposableLogsSheetKit",
dependencies: [
"SPIndicator"
"LogsSheetKit",
.product(name: "ComposableArchitecture", package: "swift-composable-architecture")
]),
.testTarget(
name: "LogsSheetKitTests",
dependencies: ["LogsSheetKit"]),
name: "ComposableLogsSheetKitTests",
dependencies: [
"ComposableLogsSheetKit",
"LogsSheetKit"
]),
]
)
40 changes: 40 additions & 0 deletions Sources/ComposableLogsSheetKit/Extensions/TCA/Reducer+Log.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//
// Reducer+Log.swift
//
//
// Created by Yessen Yermukhanbet on 2022/10/05.
// Copyright © 2022 Riiid Inc. All rights reserved.
//

import Foundation
import ComposableArchitecture

extension Reducer where State: LoggableState {
/// Saves each action run through the reducer as the log message if debug build configuration is on
/// - Parameters:
/// - isDebug: is debug configuration on
public func log(isDebug: Bool) -> Self {
.init { state, action, environment in
if isDebug {
state.logs.append(.init(message: "\(action)"))
}
return self.run(&state, action, environment)
}
}

/// Saves the custom log message if debug build configuration is on
/// - Parameters:
/// - isDebug: is debug configuration on
/// - message: custom log message
public func log(
isDebug: Bool,
with message: @escaping ((Action) -> String)
) -> Self {
.init { state, action, environment in
if isDebug {
state.logs.append(.init(message: message(action)))
}
return self.run(&state, action, environment)
}
}
}
30 changes: 30 additions & 0 deletions Sources/ComposableLogsSheetKit/LoggableState.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// File.swift
//
//
// Created by Yessen Yermukhanbet on 2022/10/05.
// Copyright © 2022 Riiid Inc. All rights reserved.
//

import Foundation
import LogsSheetKit

public protocol LoggableState: Equatable {
var logs: [ActionLog] { get set }
}

extension LoggableState {
var logs: [ActionLog] {
get {
return GlobalLogs.shared.logs
}
set {
GlobalLogs.shared.logs = newValue
}
}
}

struct GlobalLogs {
static var shared: GlobalLogs = GlobalLogs()
var logs: [ActionLog] = []
}
19 changes: 0 additions & 19 deletions Sources/LogsSheetKit/ActionLog.swift

This file was deleted.

Loading

0 comments on commit dc1611f

Please sign in to comment.