Files
resgen.swift/Sources/ResgenSwift/Strings/Model/Section.swift
Thibaut Schmitt 264c221604
Some checks failed
gitea-openium/resgen.swift/pipeline/head There was a failure building this commit
Refactor in one unique command with subcommand + add a new command to generate ressources from a configuration file
2022-08-30 17:02:11 +02:00

40 lines
972 B
Swift

//
// Section.swift
//
//
// Created by Thibaut Schmitt on 04/01/2022.
//
import Foundation
class Section {
let name: String // OnBoarding
var definitions = [Definition]()
init(name: String) {
self.name = name
}
static func match(_ line: String) -> Section? {
guard line.range(of: "\\[\\[(.*?)]]$", options: .regularExpression, range: nil, locale: nil) != nil else {
return nil
}
let sectionName = line
.replacingOccurrences(of: ["[", "]"], with: "")
.removeLeadingTrailingWhitespace()
return Section(name: sectionName)
}
func hasOneOrMoreMatchingTags(tags: [String]) -> Bool {
let allTags = definitions.flatMap { $0.tags }
let allTagsSet = Set(allTags)
let intersection = Set(tags).intersection(allTagsSet)
if intersection.isEmpty {
return false
}
return true
}
}