This file contains hidden or 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
| test |
This file contains hidden or 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
| func writeMockOutput(_ invocation: XCSourceEditorCommandInvocation, | |
| firstSelection: XCSourceTextRange, | |
| selectedClassName: String, | |
| protocolName: String) throws { | |
| let outputResult = FileManager.default.currentDirectoryPath + "/output.swift" | |
| var data = try String(contentsOfFile: outputResult, encoding: .utf8) | |
| data = data.replacingOccurrences(of: "class Mock\(protocolName)", with: "class \(selectedClassName)") | |
| invocation.buffer.lines.insert(data, at: firstSelection.start.line) | |
| } |
This file contains hidden or 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
| func executeMockolo(selectedProtocolPath: String, | |
| protocolName: String) { | |
| var commandLineArgs = ["-srcs", "\(selectedProtocolPath)"] | |
| commandLineArgs.append("--annotation") | |
| commandLineArgs.append("\(protocolName)") | |
| commandLineArgs.append("--exclude-imports") | |
| commandLineArgs.append("true") | |
| commandLineArgs.append("-d") | |
| commandLineArgs.append("./output.swift") | |
This file contains hidden or 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
| func getSelectedProtocolFilePath(protocolsDict: [String: String], | |
| protocolName: String, | |
| selectedProtocolPath: String, | |
| inheritedProtocol: String) throws { | |
| if let relativePath = protocolsDict[protocolName] { | |
| let contents = try String(contentsOfFile: relativePath, encoding: .utf8) | |
| selectedProtocolPath = relativePath | |
| let rows = contents.split(separator: "\n") | |
| for row in rows { |
This file contains hidden or 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
| func findSourceFiles() -> [URL] { | |
| let enumerator = FileManager.default.enumerator(at: projectRoot, | |
| includingPropertiesForKeys: [.nameKey], | |
| errorHandler: nil) | |
| var files = [URL]() | |
| while let file = enumerator?.nextObject() as? URL { | |
| if file.pathExtension == "swift" { | |
| files.append(file) | |
| } | |
| } |
This file contains hidden or 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
| func parseProtocol(_ rows: NSMutableArray) -> String { | |
| var protocolName = "" | |
| for item in rows { | |
| if let row = item as? String, | |
| row.contains("class") { | |
| if let protocolMacth = row.range(of: "(?<=: )[^{]+", options: .regularExpression), | |
| let protocolNameMatch = row[protocolMacth].split(separator: ",").first { | |
| protocolName = protocolNameMatch.replacingOccurrences(of: ":", with: "") | |
| .replacingOccurrences(of: " ", with: "") | |
| } |
This file contains hidden or 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
| final class XcodeProjectPathFinder { | |
| func findOpenProjectPath() -> URL? { | |
| if let workspace = findOpenWorkspacePath(), workspace.hasPrefix("/") { | |
| return URL(fileURLWithPath: workspace).deletingLastPathComponent() | |
| } | |
| return nil | |
| } | |
| func findOpenWorkspacePath() -> String? { | |
| precondition(Thread.isMainThread, "NSAppleScript must be run on the main thread.") |
This file contains hidden or 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
| final class SourceEditorCommand: NSObject, XCSourceEditorCommand { | |
| let stubGenerator = StubGenerator() | |
| func perform(with invocation: XCSourceEditorCommandInvocation, | |
| completionHandler: @escaping (Error?) -> Void ) -> Void { | |
| stubGenerator.genarateStub(with: invocation, completionHandler: completionHandler) | |
| completionHandler(nil) | |
| } | |
| } |
This file contains hidden or 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
| func selectDirectory() { | |
| let panel = NSOpenPanel() | |
| panel.message = "Choose your project directory" | |
| panel.prompt = "Grant permission" | |
| panel.allowsOtherFileTypes = false | |
| panel.canChooseFiles = false | |
| panel.canChooseDirectories = true | |
| panel.directoryURL = projectPath | |
| if panel.runModal() == NSApplication.ModalResponse.OK { | |
| bookmark(panel.url) |
This file contains hidden or 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
| public extension UIImageView { | |
| static func swizzleSetImageWithUrl() { | |
| guard let setImageWithMethod = class_getInstanceMethod(UIImageView.self, #selector(setImageWith(path:placeholder:completion:))), | |
| let swizzledMethod = class_getInstanceMethod(UIImageView.self, #selector(setStaticImage)) else { return } | |
| method_exchangeImplementations(setImageWithMethod, swizzledMethod) | |
| } | |
| @objc private func setStaticImage() { | |
| sd_setImage(with: URL(string: ""), placeholderImage: UIImage(named: "mock_snapshot_image"), completed: nil) | |
| } |
NewerOlder