-
-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from mono0926/28_exclude-libraries-using-regix
28 exclude libraries using regix
- Loading branch information
Showing
7 changed files
with
98 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import LoggerAPI | ||
|
||
public protocol HasName { | ||
var name: String { get } | ||
} | ||
|
||
extension Array where Element: HasName { | ||
func filterExcluded(config: Config?) -> [Element] { | ||
return filter { | ||
let name = $0.name | ||
guard let config = config else { return true } | ||
let result = !config.excluded(name: name) | ||
if !result { | ||
Log.warning("\(type(of: Element.self))'s \(name) was excluded according to config yaml.") | ||
} | ||
return result | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import Foundation | ||
import XCTest | ||
@testable import LicensePlistCore | ||
|
||
class ConfigTests: XCTestCase { | ||
|
||
func testExcluded() { | ||
let target = Config(githubs: [], excludes: ["lib1"]) | ||
XCTAssertTrue(target.excluded(name: "lib1")) | ||
XCTAssertFalse(target.excluded(name: "lib2")) | ||
} | ||
|
||
func testExcluded_isRegex() { | ||
XCTAssertEqual(Config.extractRegex("/^Core.*$/"), "^Core.*$") | ||
XCTAssertNil(Config.extractRegex("/^Core.*$/a")) | ||
} | ||
|
||
func testExcluded_regex() { | ||
let target = Config(githubs: [], excludes: ["/^lib.*$/"]) | ||
XCTAssertTrue(target.excluded(name: "lib1")) | ||
XCTAssertTrue(target.excluded(name: "lib2")) | ||
XCTAssertFalse(target.excluded(name: "hello")) | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import Foundation | ||
import XCTest | ||
@testable import LicensePlistCore | ||
|
||
class HasNameTests: XCTestCase { | ||
|
||
func testfilterExcluded() { | ||
let config = Config(githubs: [], excludes: ["lib2"]) | ||
let shouldBeIncluded = GitHub.init(name: "lib1", owner: "o1") | ||
let result = [shouldBeIncluded, GitHub.init(name: "lib2", owner: "o2")] | ||
.filterExcluded(config: config) | ||
XCTAssertEqual(result, [shouldBeIncluded]) | ||
} | ||
} |