Skip to content

Commit 782364d

Browse files
authored
Rename ScenarioKind and ScenarioName (#70)
* Rename ScenarioKind to ScenarioCategory, ScenarioName to ScenarioTitle * Format
1 parent 138b644 commit 782364d

33 files changed

+168
-168
lines changed

Playbook.xcodeproj/project.pbxproj

Lines changed: 20 additions & 20 deletions
Large diffs are not rendered by default.

Sources/Playbook/Playbook.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,21 @@ open class Playbook {
2525
Array(storage)
2626
}
2727

28-
private var storage = OrderedStorage<ScenarioKind, ScenarioStore>()
28+
private var storage = OrderedStorage<ScenarioCategory, ScenarioStore>()
2929

3030
/// Initialize a new `Playbook`.
3131
public init() {}
3232

33-
/// Returns a store identified by specified kind.
33+
/// Returns a store identified by specified category.
3434
///
3535
/// If there is no store yet, add and return it.
3636
///
3737
/// - Parameters:
38-
/// - kind: A unique identifier that stores a set of scenarios.
38+
/// - category: A unique identifier that stores a set of scenarios.
3939
///
40-
/// - Returns: A store identified by specified kind.
41-
public func scenarios(of kind: ScenarioKind) -> ScenarioStore {
42-
storage.element(for: kind, default: ScenarioStore(kind: kind))
40+
/// - Returns: A store identified by specified category.
41+
public func scenarios(of category: ScenarioCategory) -> ScenarioStore {
42+
storage.element(for: category, default: ScenarioStore(category: category))
4343
}
4444

4545
/// Adds a set scenarios defined in specified provider.
@@ -57,13 +57,13 @@ open class Playbook {
5757
/// Adds a set of scenarios passed by function builder.
5858
///
5959
/// - Parameters:
60-
/// - kind: A unique identifier that stores a set of scenarios.
60+
/// - category: A unique identifier that stores a set of scenarios.
6161
/// - scenarios: A function builder that create a set of scenarios.
6262
///
6363
/// - Returns: A instance of `self`.
6464
@discardableResult
65-
public func addScenarios<S: ScenariosBuildable>(of kind: ScenarioKind, @ScenariosBuilder _ scenarios: () -> S) -> Self {
66-
let store = self.scenarios(of: kind)
65+
public func addScenarios<S: ScenariosBuildable>(of category: ScenarioCategory, @ScenariosBuilder _ scenarios: () -> S) -> Self {
66+
let store = self.scenarios(of: category)
6767

6868
for scenario in scenarios().buildScenarios() {
6969
store.add(scenario)

Sources/Playbook/Scenario.swift

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import UIKit
22

33
/// Represents part of the component state.
44
public struct Scenario {
5-
/// A unique name of scenario that describes component and its state.
6-
public var name: ScenarioName
5+
/// A unique title of scenario that describes component and its state.
6+
public var title: ScenarioTitle
77

88
/// Represents how the component should be laid out.
99
public var layout: ScenarioLayout
@@ -20,19 +20,19 @@ public struct Scenario {
2020
/// Creates a new scenario.
2121
///
2222
/// - Parameters:
23-
/// - name: A unique name of this scenario.
23+
/// - title: A unique title of this scenario.
2424
/// - layout: Represents how the component should be laid out.
2525
/// - file: A file path where defined this scenario.
2626
/// - line: A line number where defined this scenario in file.
2727
/// - content: A closure that make a new content with passed context.
2828
public init(
29-
_ name: ScenarioName,
29+
_ title: ScenarioTitle,
3030
layout: ScenarioLayout,
3131
file: StaticString = #file,
3232
line: UInt = #line,
3333
content: @escaping (ScenarioContext) -> UIViewController
3434
) {
35-
self.name = name
35+
self.title = title
3636
self.layout = layout
3737
self.file = file
3838
self.line = line
@@ -42,20 +42,20 @@ public struct Scenario {
4242
/// Creates a new scenario.
4343
///
4444
/// - Parameters:
45-
/// - name: A unique name of this scenario.
45+
/// - title: A unique title of this scenario.
4646
/// - layout: Represents how the component should be laid out.
4747
/// - file: A file path where defined this scenario.
4848
/// - line: A line number where defined this scenario in file.
4949
/// - content: A closure that make a new content with passed context.
5050
public init(
51-
_ name: ScenarioName,
51+
_ title: ScenarioTitle,
5252
layout: ScenarioLayout,
5353
file: StaticString = #file,
5454
line: UInt = #line,
5555
content: @escaping (ScenarioContext) -> UIView
5656
) {
5757
self.init(
58-
name,
58+
title,
5959
layout: layout,
6060
file: file,
6161
line: line,
@@ -68,20 +68,20 @@ public struct Scenario {
6868
/// Creates a new scenario.
6969
///
7070
/// - Parameters:
71-
/// - name: A unique name of this scenario.
71+
/// - title: A unique title of this scenario.
7272
/// - layout: Represents how the component should be laid out.
7373
/// - file: A file path where defined this scenario.
7474
/// - line: A line number where defined this scenario in file.
7575
/// - content: A closure that make a new content.
7676
public init(
77-
_ name: ScenarioName,
77+
_ title: ScenarioTitle,
7878
layout: ScenarioLayout,
7979
file: StaticString = #file,
8080
line: UInt = #line,
8181
content: @escaping () -> UIViewController
8282
) {
8383
self.init(
84-
name,
84+
title,
8585
layout: layout,
8686
file: file,
8787
line: line,
@@ -92,20 +92,20 @@ public struct Scenario {
9292
/// Creates a new scenario.
9393
///
9494
/// - Parameters:
95-
/// - name: A unique name of this scenario.
95+
/// - title: A unique title of this scenario.
9696
/// - layout: Represents how the component should be laid out.
9797
/// - file: A file path where defined this scenario.
9898
/// - line: A line number where defined this scenario in file.
9999
/// - content: A closure that make a new content.
100100
public init(
101-
_ name: ScenarioName,
101+
_ title: ScenarioTitle,
102102
layout: ScenarioLayout,
103103
file: StaticString = #file,
104104
line: UInt = #line,
105105
content: @escaping () -> UIView
106106
) {
107107
self.init(
108-
name,
108+
title,
109109
layout: layout,
110110
file: file,
111111
line: line,

Sources/Playbook/ScenarioKind.swift renamed to Sources/Playbook/ScenarioCategory.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
/// Represents a unique identifier of the set of scenarios.
2-
public struct ScenarioKind: Hashable, RawRepresentable, ExpressibleByStringLiteral, CustomStringConvertible, ExpressibleByStringInterpolation {
2+
public struct ScenarioCategory: Hashable, RawRepresentable, ExpressibleByStringLiteral, CustomStringConvertible, ExpressibleByStringInterpolation {
33
/// The raw string value.
44
public var rawValue: String
55

66
/// A textual representation of this instance.
77
public var description: String { rawValue }
88

9-
/// Creates a new kind with given raw string value.
9+
/// Creates a new category with given raw string value.
1010
///
1111
/// - Parameters:
1212
/// - rawValue: The raw string value.
1313
public init(rawValue: String) {
1414
self.rawValue = rawValue
1515
}
1616

17-
/// Creates a new kind with given raw string value.
17+
/// Creates a new category with given raw string value.
1818
///
1919
/// - Parameters:
2020
/// - value: The raw string value.

Sources/Playbook/ScenarioStore.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
/// The class for managing a set of scenarios identified by the arbitrary kind.
1+
/// The class for managing a set of scenarios identified by the arbitrary category.
22
public final class ScenarioStore {
33
/// A unique identifier of the secenarios managed by this instance.
4-
public let kind: ScenarioKind
4+
public let category: ScenarioCategory
55

6-
private var storage = OrderedStorage<ScenarioName, Scenario>()
6+
private var storage = OrderedStorage<ScenarioTitle, Scenario>()
77

88
/// The set of scenarios managed by this store.
99
public var scenarios: [Scenario] {
1010
Array(storage)
1111
}
1212

13-
/// Initialize a new store with given kind.
13+
/// Initialize a new store with given category.
1414
///
1515
/// - Parameters:
16-
/// - kind: A unique identifier of the secenarios managed by this instance.
17-
public init(kind: ScenarioKind) {
18-
self.kind = kind
16+
/// - category: A unique identifier of the secenarios managed by this instance.
17+
public init(category: ScenarioCategory) {
18+
self.category = category
1919
}
2020

2121
/// Adds a scenario to this store instance.
@@ -26,7 +26,7 @@ public final class ScenarioStore {
2626
/// - Returns: A instance of `self`.
2727
@discardableResult
2828
public func add(_ scenario: Scenario) -> Self {
29-
storage.append(scenario, for: scenario.name)
29+
storage.append(scenario, for: scenario.title)
3030
return self
3131
}
3232
}

Sources/Playbook/ScenarioName.swift renamed to Sources/Playbook/ScenarioTitle.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
/// Represents a unique name of the scenario.
2-
public struct ScenarioName: Hashable, RawRepresentable, ExpressibleByStringLiteral, CustomStringConvertible, ExpressibleByStringInterpolation {
1+
/// Represents a unique title of the scenario.
2+
public struct ScenarioTitle: Hashable, RawRepresentable, ExpressibleByStringLiteral, CustomStringConvertible, ExpressibleByStringInterpolation {
33
/// The raw string value.
44
public var rawValue: String
55

66
/// A textual representation of this instance.
77
public var description: String { rawValue }
88

9-
/// Creates a new name with given raw string value.
9+
/// Creates a new title with given raw string value.
1010
///
1111
/// - Parameters:
1212
/// - rawValue: The raw string value.
1313
public init(rawValue: String) {
1414
self.rawValue = rawValue
1515
}
1616

17-
/// Creates a new name with given raw string value.
17+
/// Creates a new title with given raw string value.
1818
///
1919
/// - Parameters:
2020
/// - rawValue: The raw string value.

Sources/Playbook/ScenarioViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ private extension ScenarioViewController {
7777
return contentViewController = nil
7878
}
7979

80-
if let previous = previous, scenario.name == previous.name {
80+
if let previous = previous, scenario.title == previous.title {
8181
return
8282
}
8383

Sources/Playbook/SnapshotSupport/SnapshotSupport.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,11 @@ private extension SnapshotSupport {
123123

124124
window.prepareForSnapshot {
125125
if contentView.bounds.size.width <= 0 {
126-
fatalError("The view was laid out with zero width in scenario - \(scenario.name)", file: scenario.file, line: scenario.line)
126+
fatalError("The view was laid out with zero width in scenario - \(scenario.title)", file: scenario.file, line: scenario.line)
127127
}
128128

129129
if contentView.bounds.size.height <= 0 {
130-
fatalError("The view was laid out with zero height in scenario - \(scenario.name)", file: scenario.file, line: scenario.line)
130+
fatalError("The view was laid out with zero height in scenario - \(scenario.title)", file: scenario.file, line: scenario.line)
131131
}
132132

133133
let format = UIGraphicsImageRendererFormat(for: device.traitCollection)

Sources/Playbook/SwiftUISupport/ScenarioSwiftUI.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@ public extension Scenario {
55
/// Creates a new scenario with SwiftUI view.
66
///
77
/// - Parameters:
8-
/// - name: A unique name of this scenario.
8+
/// - title: A unique title of this scenario.
99
/// - layout: Represents how the component should be laid out.
1010
/// - file: A file path where defined this scenario.
1111
/// - line: A line number where defined this scenario in file.
1212
/// - content: A closure that make a new content with passed context.
1313
init<Content: View>(
14-
_ name: ScenarioName,
14+
_ title: ScenarioTitle,
1515
layout: ScenarioLayout,
1616
file: StaticString = #file,
1717
line: UInt = #line,
1818
@ViewBuilder content: @escaping (ScenarioContext) -> Content
1919
) {
20-
self.init(name, layout: layout, file: file, line: line) { context in
20+
self.init(title, layout: layout, file: file, line: line) { context in
2121
let content = content(context).transaction { transaction in
2222
if context.isSnapshot {
2323
transaction.disablesAnimations = true
@@ -32,20 +32,20 @@ public extension Scenario {
3232
/// Creates a new scenario with SwiftUI view.
3333
///
3434
/// - Parameters:
35-
/// - name: A unique name of this scenario.
35+
/// - title: A unique title of this scenario.
3636
/// - layout: Represents how the component should be laid out.
3737
/// - file: A file path where defined this scenario.
3838
/// - line: A line number where defined this scenario in file.
3939
/// - content: A closure that make a new content.
4040
init<Content: View>(
41-
_ name: ScenarioName,
41+
_ title: ScenarioTitle,
4242
layout: ScenarioLayout,
4343
file: StaticString = #file,
4444
line: UInt = #line,
4545
@ViewBuilder content: @escaping () -> Content
4646
) {
4747
self.init(
48-
name,
48+
title,
4949
layout: layout,
5050
file: file,
5151
line: line,

Sources/PlaybookSnapshot/Snapshot.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,14 @@ public struct Snapshot: TestTool {
8282
let directoryURL =
8383
directoryURL
8484
.appendingPathComponent(device.name, isDirectory: true)
85-
.appendingPathComponent(normalize(store.kind.rawValue), isDirectory: true)
85+
.appendingPathComponent(normalize(store.category.rawValue), isDirectory: true)
8686

8787
try fileManager.createDirectory(at: directoryURL, withIntermediateDirectories: true)
8888

8989
func attemptToWrite(data: Data, scenario: Scenario) {
9090
let fileURL =
9191
directoryURL
92-
.appendingPathComponent(normalize(scenario.name.rawValue))
92+
.appendingPathComponent(normalize(scenario.title.rawValue))
9393
.appendingPathExtension(format.fileExtension)
9494

9595
do {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
internal struct SearchResult {
22
let count: Int
33
let total: Int
4-
let kinds: [SearchedKindData]
4+
let categories: [SearchedCategoryData]
55
}
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Playbook
22

3-
internal struct SearchedKindData {
4-
let kind: ScenarioKind
3+
internal struct SearchedCategoryData {
4+
let category: ScenarioCategory
55
let highlightRange: Range<String.Index>?
66
let scenarios: [SearchedData]
77
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Playbook
22

33
internal struct SearchedData {
4-
let kind: ScenarioKind
4+
let category: ScenarioCategory
55
let scenario: Scenario
66
let highlightRange: Range<String.Index>?
77
}

Sources/PlaybookUI/Internal/Entities/SelectData.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ import Playbook
22

33
internal struct SelectData: Identifiable {
44
struct ID: Hashable {
5-
let kind: ScenarioKind
6-
let name: ScenarioName
5+
let category: ScenarioCategory
6+
let title: ScenarioTitle
77
}
88

99
var id: ID {
10-
ID(kind: kind, name: scenario.name)
10+
ID(category: category, title: scenario.title)
1111
}
1212

13-
let kind: ScenarioKind
13+
let category: ScenarioCategory
1414
let scenario: Scenario
1515
}

0 commit comments

Comments
 (0)