@@ -7,23 +7,22 @@ import Yams
77
88public struct BetaGroupProcessor : ResourceProcessor {
99
10+ var path : ResourcePath
11+
1012 public init ( path: ResourcePath ) {
1113 self . path = path
1214 }
1315
14- func write( _: [ BetaGroup ] ) throws -> [ File ] {
15- fatalError ( )
16- }
17-
18- var path : ResourcePath
19-
20- @discardableResult
21- func write( _ betaGroup: BetaGroup ) throws -> File {
22- try writeFile ( betaGroup)
23- }
16+ public func read( ) throws -> [ BetaGroup ] {
17+ try getFolder ( ) . files. compactMap { ( file: File ) -> BetaGroup ? in
18+ if file. extension == " yml " {
19+ return Readers
20+ . FileReader< BetaGroup> ( format: . yaml)
21+ . read ( filePath: file. path)
22+ }
2423
25- func read ( ) throws -> [ BetaGroup ] {
26- fatalError ( )
24+ return nil
25+ }
2726 }
2827
2928 public func write( groupsWithTesters: [ ( betaGroup: BetaGroup , testers: [ BetaTester ] ) ] ) throws {
@@ -32,14 +31,24 @@ public struct BetaGroupProcessor: ResourceProcessor {
3231 let betagroups = try groupsWithTesters
3332 . map { try write ( betaTesters: $0. testers, into: $0. betaGroup) }
3433
35- try betagroups. forEach { try write ( $0) }
34+ try write ( betagroups)
35+ }
36+
37+ @discardableResult
38+ func write( _ betaGroups: [ BetaGroup ] ) throws -> [ File ] {
39+ try betaGroups. map { try write ( $0) }
40+ }
41+
42+ @discardableResult
43+ func write( _ betaGroup: BetaGroup ) throws -> File {
44+ try writeFile ( betaGroup)
3645 }
3746
3847 private func write( betaTesters: [ BetaTester ] , into betaGroup: BetaGroup ) throws -> BetaGroup {
39- let testerProcessor = BetaTesterProcessor ( folder: try getFolder ( ) )
4048
4149 var group = betaGroup
42- group. testers = try testerProcessor. write ( group: group, testers: betaTesters)
50+ group. testers = try BetaTesterProcessor ( folder: try getFolder ( ) )
51+ . write ( group: group, testers: betaTesters)
4352
4453 return group
4554 }
0 commit comments