ammarnasr/the-stack-swift-clean · Datasets at Fast360
{
// 获取包含Hugging Face文本的span元素
const spans = link.querySelectorAll('span.whitespace-nowrap, span.hidden.whitespace-nowrap');
spans.forEach(span => {
if (span.textContent && span.textContent.trim().match(/Hugging\s*Face/i)) {
span.textContent = 'AI快站';
}
});
});
// 替换logo图片的alt属性
document.querySelectorAll('img[alt*="Hugging"], img[alt*="Face"]').forEach(img => {
if (img.alt.match(/Hugging\s*Face/i)) {
img.alt = 'AI快站 logo';
}
});
}
// 替换导航栏中的链接
function replaceNavigationLinks() {
// 已替换标记,防止重复运行
if (window._navLinksReplaced) {
return;
}
// 已经替换过的链接集合,防止重复替换
const replacedLinks = new Set();
// 只在导航栏区域查找和替换链接
const headerArea = document.querySelector('header') || document.querySelector('nav');
if (!headerArea) {
return;
}
// 在导航区域内查找链接
const navLinks = headerArea.querySelectorAll('a');
navLinks.forEach(link => {
// 如果已经替换过,跳过
if (replacedLinks.has(link)) return;
const linkText = link.textContent.trim();
const linkHref = link.getAttribute('href') || '';
// 替换Spaces链接 - 仅替换一次
if (
(linkHref.includes('/spaces') || linkHref === '/spaces' ||
linkText === 'Spaces' || linkText.match(/^s*Spacess*$/i)) &&
linkText !== 'OCR模型免费转Markdown' &&
linkText !== 'OCR模型免费转Markdown'
) {
link.textContent = 'OCR模型免费转Markdown';
link.href = 'https://fast360.xyz';
link.setAttribute('target', '_blank');
link.setAttribute('rel', 'noopener noreferrer');
replacedLinks.add(link);
}
// 删除Posts链接
else if (
(linkHref.includes('/posts') || linkHref === '/posts' ||
linkText === 'Posts' || linkText.match(/^s*Postss*$/i))
) {
if (link.parentNode) {
link.parentNode.removeChild(link);
}
replacedLinks.add(link);
}
// 替换Docs链接 - 仅替换一次
else if (
(linkHref.includes('/docs') || linkHref === '/docs' ||
linkText === 'Docs' || linkText.match(/^s*Docss*$/i)) &&
linkText !== '模型下载攻略'
) {
link.textContent = '模型下载攻略';
link.href = '/';
replacedLinks.add(link);
}
// 删除Enterprise链接
else if (
(linkHref.includes('/enterprise') || linkHref === '/enterprise' ||
linkText === 'Enterprise' || linkText.match(/^s*Enterprises*$/i))
) {
if (link.parentNode) {
link.parentNode.removeChild(link);
}
replacedLinks.add(link);
}
});
// 查找可能嵌套的Spaces和Posts文本
const textNodes = [];
function findTextNodes(element) {
if (element.nodeType === Node.TEXT_NODE) {
const text = element.textContent.trim();
if (text === 'Spaces' || text === 'Posts' || text === 'Enterprise') {
textNodes.push(element);
}
} else {
for (const child of element.childNodes) {
findTextNodes(child);
}
}
}
// 只在导航区域内查找文本节点
findTextNodes(headerArea);
// 替换找到的文本节点
textNodes.forEach(node => {
const text = node.textContent.trim();
if (text === 'Spaces') {
node.textContent = node.textContent.replace(/Spaces/g, 'OCR模型免费转Markdown');
} else if (text === 'Posts') {
// 删除Posts文本节点
if (node.parentNode) {
node.parentNode.removeChild(node);
}
} else if (text === 'Enterprise') {
// 删除Enterprise文本节点
if (node.parentNode) {
node.parentNode.removeChild(node);
}
}
});
// 标记已替换完成
window._navLinksReplaced = true;
}
// 替换代码区域中的域名
function replaceCodeDomains() {
// 特别处理span.hljs-string和span.njs-string元素
document.querySelectorAll('span.hljs-string, span.njs-string, span[class*="hljs-string"], span[class*="njs-string"]').forEach(span => {
if (span.textContent && span.textContent.includes('huggingface.co')) {
span.textContent = span.textContent.replace(/huggingface.co/g, 'aifasthub.com');
}
});
// 替换hljs-string类的span中的域名(移除多余的转义符号)
document.querySelectorAll('span.hljs-string, span[class*="hljs-string"]').forEach(span => {
if (span.textContent && span.textContent.includes('huggingface.co')) {
span.textContent = span.textContent.replace(/huggingface.co/g, 'aifasthub.com');
}
});
// 替换pre和code标签中包含git clone命令的域名
document.querySelectorAll('pre, code').forEach(element => {
if (element.textContent && element.textContent.includes('git clone')) {
const text = element.innerHTML;
if (text.includes('huggingface.co')) {
element.innerHTML = text.replace(/huggingface.co/g, 'aifasthub.com');
}
}
});
// 处理特定的命令行示例
document.querySelectorAll('pre, code').forEach(element => {
const text = element.innerHTML;
if (text.includes('huggingface.co')) {
// 针对git clone命令的专门处理
if (text.includes('git clone') || text.includes('GIT_LFS_SKIP_SMUDGE=1')) {
element.innerHTML = text.replace(/huggingface.co/g, 'aifasthub.com');
}
}
});
// 特别处理模型下载页面上的代码片段
document.querySelectorAll('.flex.border-t, .svelte_hydrator, .inline-block').forEach(container => {
const content = container.innerHTML;
if (content && content.includes('huggingface.co')) {
container.innerHTML = content.replace(/huggingface.co/g, 'aifasthub.com');
}
});
// 特别处理模型仓库克隆对话框中的代码片段
try {
// 查找包含"Clone this model repository"标题的对话框
const cloneDialog = document.querySelector('.svelte_hydration_boundary, [data-target="MainHeader"]');
if (cloneDialog) {
// 查找对话框中所有的代码片段和命令示例
const codeElements = cloneDialog.querySelectorAll('pre, code, span');
codeElements.forEach(element => {
if (element.textContent && element.textContent.includes('huggingface.co')) {
if (element.innerHTML.includes('huggingface.co')) {
element.innerHTML = element.innerHTML.replace(/huggingface.co/g, 'aifasthub.com');
} else {
element.textContent = element.textContent.replace(/huggingface.co/g, 'aifasthub.com');
}
}
});
}
// 更精确地定位克隆命令中的域名
document.querySelectorAll('[data-target]').forEach(container => {
const codeBlocks = container.querySelectorAll('pre, code, span.hljs-string');
codeBlocks.forEach(block => {
if (block.textContent && block.textContent.includes('huggingface.co')) {
if (block.innerHTML.includes('huggingface.co')) {
block.innerHTML = block.innerHTML.replace(/huggingface.co/g, 'aifasthub.com');
} else {
block.textContent = block.textContent.replace(/huggingface.co/g, 'aifasthub.com');
}
}
});
});
} catch (e) {
// 错误处理但不打印日志
}
}
// 当DOM加载完成后执行替换
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', () => {
replaceHeaderBranding();
replaceNavigationLinks();
replaceCodeDomains();
// 只在必要时执行替换 - 3秒后再次检查
setTimeout(() => {
if (!window._navLinksReplaced) {
console.log('[Client] 3秒后重新检查导航链接');
replaceNavigationLinks();
}
}, 3000);
});
} else {
replaceHeaderBranding();
replaceNavigationLinks();
replaceCodeDomains();
// 只在必要时执行替换 - 3秒后再次检查
setTimeout(() => {
if (!window._navLinksReplaced) {
console.log('[Client] 3秒后重新检查导航链接');
replaceNavigationLinks();
}
}, 3000);
}
// 增加一个MutationObserver来处理可能的动态元素加载
const observer = new MutationObserver(mutations => {
// 检查是否导航区域有变化
const hasNavChanges = mutations.some(mutation => {
// 检查是否存在header或nav元素变化
return Array.from(mutation.addedNodes).some(node => {
if (node.nodeType === Node.ELEMENT_NODE) {
// 检查是否是导航元素或其子元素
if (node.tagName === 'HEADER' || node.tagName === 'NAV' ||
node.querySelector('header, nav')) {
return true;
}
// 检查是否在导航元素内部
let parent = node.parentElement;
while (parent) {
if (parent.tagName === 'HEADER' || parent.tagName === 'NAV') {
return true;
}
parent = parent.parentElement;
}
}
return false;
});
});
// 只在导航区域有变化时执行替换
if (hasNavChanges) {
// 重置替换状态,允许再次替换
window._navLinksReplaced = false;
replaceHeaderBranding();
replaceNavigationLinks();
}
});
// 开始观察document.body的变化,包括子节点
if (document.body) {
observer.observe(document.body, { childList: true, subtree: true });
} else {
document.addEventListener('DOMContentLoaded', () => {
observer.observe(document.body, { childList: true, subtree: true });
});
}
})();
\n \n\n \n \n \n \n \n THOR AGENA D R/B\n 1964-002A\n EARTH\n TEME\n UTC\n SGP4\n \n \n \n 2020-06-06T07:04:37.126560\n 14.32395701\n .0032725\n 99.0129\n 49.4090\n 264.3266\n 95.4185\n \n \n 0\n U\n 733\n 999\n 93722\n .25433E-4\n 2.1E-7\n 0\n \n \n \n \n \n\n \n \n \n \n \n SL-3 R/B\n 1964-053B\n EARTH\n TEME\n UTC\n SGP4\n \n \n \n 2020-06-05T22:17:57.747840\n 14.59393420\n .0055722\n 65.0789\n 2.6555\n 32.0150\n 328.4314\n \n \n 0\n U\n 877\n 999\n 95981\n .75354E-5\n -8.4E-7\n 0\n \n \n \n \n \n \n \"\"\".data(using: .utf8)!\n\n let result = NavigationDataMessage(from: xmlData)\n\n let tle = TLE(commonName: result.omms[0].body.segment.metadata.commonName,\n noradIndex: result.omms[0].body.segment.data.tleParameters.noradIndex,\n launchName: result.omms[0].body.segment.metadata.launchName,\n t₀: result.omms[0].body.segment.data.meanElements.t₀,\n e₀: result.omms[0].body.segment.data.meanElements.e₀,\n i₀: result.omms[0].body.segment.data.meanElements.i₀,\n ω₀: result.omms[0].body.segment.data.meanElements.ω₀,\n Ω₀: result.omms[0].body.segment.data.meanElements.Ω₀,\n M₀: result.omms[0].body.segment.data.meanElements.M₀,\n n₀: result.omms[0].body.segment.data.meanElements.n₀,\n ephemType: result.omms[0].body.segment.data.tleParameters.ephemType,\n tleClass: result.omms[0].body.segment.data.tleParameters.tleClass,\n tleNumber: result.omms[0].body.segment.data.tleParameters.tleNumber,\n revNumber: result.omms[0].body.segment.data.tleParameters.revNumber,\n dragCoeff: result.omms[0].body.segment.data.tleParameters.dragCoeff)\n\n print(Satellite(withTLE: tle.debugDescription()))\n\n }\n#endif\n\n func testLongFile() {\n\n do {\n let contents = try String(contentsOfFile: \"/Users/gavin/Development/sat_code/all_tle.txt\")\n _ = preProcessTLEs(contents)\n } catch {\n print(error)\n }\n\n }\n\n func testBase34() {\n XCTAssert(base10ID( \"\") == 0)\n\n XCTAssert(alpha5ID( \"\") == 0)\n XCTAssert(alpha5ID( \"5\") == 5)\n XCTAssert(alpha5ID(\"10000\") == 10000, \"got \\(alpha5ID(\"10000\"))\")\n\n // numerical checks\n\n XCTAssert(alpha5ID(\"A0000\") == 100000, \"got \\(alpha5ID(\"A0000\"))\")\n XCTAssert(alpha5ID(\"H0000\") == 170000, \"got \\(alpha5ID(\"H0000\"))\")\n XCTAssert(alpha5ID(\"J0000\") == 180000, \"got \\(alpha5ID(\"J0000\"))\")\n XCTAssert(alpha5ID(\"N0000\") == 220000, \"got \\(alpha5ID(\"N0000\"))\")\n XCTAssert(alpha5ID(\"P0000\") == 230000, \"got \\(alpha5ID(\"P0000\"))\")\n XCTAssert(alpha5ID(\"Z0000\") == 330000, \"got \\(alpha5ID(\"Z0000\"))\")\n XCTAssert(alpha5ID(\"Z9999\") == 339999, \"got \\(alpha5ID(\"Z9999\"))\")\n\n XCTAssert(alpha5ID(\"J2931\") == 182931, \"got \\(alpha5ID(\"J2931\"))\")\n XCTAssert(alpha5ID(\"W1928\") == 301928, \"got \\(alpha5ID(\"W1928\"))\")\n XCTAssert(alpha5ID(\"E8493\") == 148493, \"got \\(alpha5ID(\"E8493\"))\")\n XCTAssert(alpha5ID(\"P4018\") == 234018, \"got \\(alpha5ID(\"P4018\"))\")\n\n XCTAssert(alpha5ID(\"I0000\") == 0, \"got \\(alpha5ID(\"I0000\"))\")\n XCTAssert(alpha5ID(\"0I000\") == 0, \"got \\(alpha5ID(\"0I000\"))\")\n\n // lowercase\n\n XCTAssert(alpha5ID(\"a5678\") == 105678, \"got \\(alpha5ID(\"a5678\"))\")\n\n // failure modes\n\n XCTAssert(alpha5ID(\"!0000\") == 0, \"got \\(alpha5ID(\"!9999\"))\")\n XCTAssert(alpha5ID(\"~0000\") == 0, \"got \\(alpha5ID(\"~9999\"))\")\n XCTAssert(alpha5ID(\"AAAAA\") == 0, \"got \\(alpha5ID(\"AAAAA\"))\")\n }\n\n func testBase10() {\n XCTAssert(base10ID(\"\") == 0)\n\n XCTAssert(base10ID(\"5\") == 5)\n XCTAssert(base10ID(\"10000\") == 10000, \"got \\(base10ID(\"10000\"))\")\n XCTAssert(base10ID(\"99999\") == 99999, \"got \\(base10ID(\"99999\"))\")\n }\n\n// func testPerformanceExample() { // May06/19 = iOS sim average: 2.267\n//\n// self.measure {\n// testLongFile()\n// }\n// }\n\n}\n"},"avg_line_length":{"kind":"number","value":44.0346938776,"string":"44.034694"},"max_line_length":{"kind":"number","value":111,"string":"111"},"alphanum_fraction":{"kind":"number","value":0.4438522501,"string":"0.443852"}}},{"rowIdx":228,"cells":{"hexsha":{"kind":"string","value":"91032b5e24c54443105b2f0343f8db69738ca1f7"},"size":{"kind":"number","value":2194,"string":"2,194"},"content":{"kind":"string","value":"final class TupleDeclTests: PrettyPrintTestCase {\n func testBasicTuples() {\n let input =\n \"\"\"\n let a = (1, 2, 3)\n let a: (Int, Int, Int) = (1, 2, 3)\n let a = (1, 2, 3, 4, 5, 6, 70, 80, 90)\n let a = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)\n let a = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)\n \"\"\"\n\n let expected =\n \"\"\"\n let a = (1, 2, 3)\n let a: (Int, Int, Int) = (1, 2, 3)\n let a = (\n 1, 2, 3, 4, 5, 6, 70, 80, 90\n )\n let a = (\n 1, 2, 3, 4, 5, 6, 7, 8, 9, 10\n )\n let a = (\n 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,\n 12\n )\n\n \"\"\"\n\n assertPrettyPrintEqual(input: input, expected: expected, linelength: 37)\n }\n\n func testLabeledTuples() {\n let input =\n \"\"\"\n let a = (A: var1, B: var2)\n var b: (A: Int, B: Double)\n \"\"\"\n\n let expected =\n \"\"\"\n let a = (A: var1, B: var2)\n var b: (A: Int, B: Double)\n\n \"\"\"\n\n assertPrettyPrintEqual(input: input, expected: expected, linelength: 30)\n }\n\n func testDiscretionaryNewlineAfterColon() {\n let input =\n \"\"\"\n let a = (\n reallyLongKeySoTheValueWillWrap:\n value,\n b: c\n )\n let a = (\n shortKey:\n value,\n b:\n c,\n label: Deeply.Nested.InnerMember,\n label2:\n Deeply.Nested.InnerMember\n )\n \"\"\"\n\n let expected =\n \"\"\"\n let a = (\n reallyLongKeySoTheValueWillWrap:\n value,\n b: c\n )\n let a = (\n shortKey:\n value,\n b:\n c,\n label: Deeply.Nested\n .InnerMember,\n label2:\n Deeply.Nested\n .InnerMember\n )\n\n \"\"\"\n\n assertPrettyPrintEqual(input: input, expected: expected, linelength: 25)\n }\n\n func testGroupsTrailingComma() {\n let input =\n \"\"\"\n let t = (\n condition ? firstOption : secondOption,\n bar()\n )\n \"\"\"\n\n let expected =\n \"\"\"\n let t = (\n condition\n ? firstOption\n : secondOption,\n bar()\n )\n\n \"\"\"\n\n assertPrettyPrintEqual(input: input, expected: expected, linelength: 32)\n }\n}\n"},"avg_line_length":{"kind":"number","value":19.0782608696,"string":"19.078261"},"max_line_length":{"kind":"number","value":76,"string":"76"},"alphanum_fraction":{"kind":"number","value":0.4475843209,"string":"0.447584"}}},{"rowIdx":229,"cells":{"hexsha":{"kind":"string","value":"d640db7d29f61fedb1d3b4203f5ef068ddec33ca"},"size":{"kind":"number","value":1745,"string":"1,745"},"content":{"kind":"string","value":"import Foundation\n\nextension String {\n func partitionSlices(by length: Int) -> [Substring] {\n var startIndex = self.startIndex\n var results = [Substring]()\n\n while startIndex < self.endIndex {\n let endIndex = self.index(startIndex, offsetBy: length, limitedBy: self.endIndex) ?? self.endIndex\n results.append(self[startIndex.. [String] {\n return partitionSlices(by: length).map { String($0) }\n }\n \n func split(separator: CharacterSet) -> Array {\n var index = startIndex\n var substrings = Array()\n \n var rangeStart = startIndex\n var rangeEnd = startIndex\n \n while index != endIndex {\n if separator.contains(self[index].unicodeScalars.first!) {\n substrings.append(self[rangeStart...rangeEnd])\n \n while index != endIndex && separator.contains(self[index].unicodeScalars.first!) {\n index = self.index(after: index)\n rangeStart = index\n rangeEnd = index\n }\n } else {\n rangeEnd = index\n index = self.index(after: index)\n }\n }\n \n substrings.append(self[rangeStart...])\n return substrings\n }\n \n var nsRange: NSRange { return NSMakeRange(0, count) }\n \n func substring(with nsRange: NSRange) -> SubSequence {\n let range = index(startIndex, offsetBy: nsRange.location)..) -> Observable {\n \n return Observable.create({ (observer) -> Disposable in\n \n var allFiles = [String:File]() //需要查找的头文件\n var newFiles = [String:File]() //递归全的文件\n \n var allObjects = [String:Object]()\n var allUsedObjects = [String:Object]()\n \n for (_, aFile) in files {\n allFiles[aFile.name] = aFile\n }\n for (_, aFile) in allFiles {\n //单文件处理\n aFile.recursionImports = self.fetchImports(file: aFile, allFiles: allFiles, allRecursionImports:[Import]())\n //记录所有import的的类\n for aImport in aFile.recursionImports {\n for (name, aObj) in aImport.file.objects {\n //全部类\n aFile.importObjects[name] = aObj\n allObjects[name] = aObj\n }\n }\n newFiles[aFile.name] = aFile\n //处理无用的import\n //记录所有用过的类\n for aMethod in aFile.methods {\n let _ = ParsingMethodContent.parsing(method: aMethod, file: aFile).subscribe(onNext:{ (result) in\n if result is Object {\n let aObj = result as! Object\n allUsedObjects[aObj.name] = aObj\n }\n })\n }\n //记录类的父类,作为已用类\n for (_, value) in allObjects {\n if value.superName.characters.count > 0 {\n guard let obj = allObjects[value.superName] else {\n continue\n }\n allUsedObjects[value.superName] = obj\n }\n }\n \n }\n// print(\"\\(allObjects.keys)\")\n// print(\"-----------------------\")\n// print(\"\\(allUsedObjects.keys)\")\n //遍历对比出无用的类\n var allUnUsedObjects = [String:Object]()\n for (key, value) in allObjects {\n guard let _ = allUsedObjects[key] else {\n allUnUsedObjects[key] = value\n continue\n }\n }\n observer.on(.next(allUnUsedObjects))\n observer.on(.next(newFiles))\n observer.on(.completed)\n return Disposables.create {\n //\n }\n })\n }\n \n //递归获取所有import\n func fetchImports(file: File, allFiles:[String:File], allRecursionImports:[Import]) -> [Import] {\n var allRecursionImports = allRecursionImports\n for aImport in file.imports {\n \n \n guard let importFile = allFiles[aImport.fileName] else {\n continue\n }\n if !checkIfContain(aImport: aImport, inImports: allRecursionImports) {\n allRecursionImports.append(addFileObjectTo(aImport: aImport, allFiles: allFiles))\n } else {\n continue\n }\n \n let reRecursionImports = fetchImports(file: importFile, allFiles: allFiles, allRecursionImports: allRecursionImports)\n for aImport in reRecursionImports {\n if !checkIfContain(aImport: aImport, inImports: allRecursionImports) {\n allRecursionImports.append(addFileObjectTo(aImport: aImport, allFiles: allFiles))\n }\n }\n \n }\n return allRecursionImports\n }\n \n func addFileObjectTo(aImport:Import, allFiles: [String:File]) -> Import {\n var mImport = aImport\n guard let aFile = allFiles[aImport.fileName] else {\n return aImport\n }\n mImport.file = aFile\n return mImport\n }\n \n func checkIfContain(aImport:Import, inImports:[Import]) -> Bool{\n let tf = inImports.contains { element in\n if aImport.fileName == element.fileName {\n return true\n } else {\n return false\n }\n }\n return tf\n }\n}\n"},"avg_line_length":{"kind":"number","value":35.0555555556,"string":"35.055556"},"max_line_length":{"kind":"number","value":129,"string":"129"},"alphanum_fraction":{"kind":"number","value":0.4933212588,"string":"0.493321"}}},{"rowIdx":234,"cells":{"hexsha":{"kind":"string","value":"21cfeebd788ae14ab959a025147fe7c61fce302a"},"size":{"kind":"number","value":59179,"string":"59,179"},"content":{"kind":"string","value":"//\n// SetTests.swift\n// Outlaw\n//\n// Created by Brian Mullen on 11/9/16.\n// Copyright © 2016 Molbie LLC. All rights reserved.\n//\n\nimport XCTest\n@testable import Outlaw\n\n\nclass SetTests: OutlawTestCase, DateTesting {\n static var allTests = [(\"testValue\", testValue),\n (\"testNestedValue\", testNestedValue),\n (\"testKeyNotFound\", testKeyNotFound),\n (\"testTypeMismatch\", testTypeMismatch),\n (\"testOptional\", testOptional),\n (\"testOptionalNestedValue\", testOptionalNestedValue),\n (\"testOptionalKeyNotFound\", testOptionalKeyNotFound),\n (\"testOptionalTypeMismatch\", testOptionalTypeMismatch),\n (\"testTransformValue\", testTransformValue),\n (\"testOptionalTransformValue\", testOptionalTransformValue),\n (\"testTransformOptionalValue\", testTransformOptionalValue),\n (\"testOptionalTransformOptionalValue\", testOptionalTransformOptionalValue),\n (\"testTransformValueOfOptionals\", testTransformValueOfOptionals),\n (\"testOptionalTransformValueOfOptionals\", testOptionalTransformValueOfOptionals),\n (\"testTransformOptionalValueOfOptionals\", testTransformOptionalValueOfOptionals),\n (\"testOptionalTransformOptionalValueOfOptionals\", testOptionalTransformOptionalValueOfOptionals)]\n \n \n func testValue() {\n let bool: Set = try! data.value(for: \"bool\")\n XCTAssertEqual(bool.count, 2)\n XCTAssertEqual(bool.first, false)\n \n let string: Set = try! data.value(for: \"string\")\n XCTAssertEqual(string.count, 1)\n XCTAssertEqual(string.first, \"Hello, Outlaw!\")\n \n let character: Set = try! data.value(for: \"character\")\n XCTAssertEqual(character.count, 1)\n XCTAssertEqual(character.first, \"O\")\n \n let float: Set = try! data.value(for: \"float\")\n XCTAssertEqual(float.count, 1)\n XCTAssertEqual(float.first, 3.14)\n \n let double: Set = try! data.value(for: \"double\")\n XCTAssertEqual(double.count, 1)\n XCTAssertEqual(double.first, 3.14159265359)\n \n let int: Set = try! data.value(for: \"int\")\n XCTAssertEqual(int.count, 1)\n XCTAssertEqual(int.first, -3)\n \n let int8: Set = try! data.value(for: \"int8\")\n XCTAssertEqual(int8.count, 1)\n XCTAssertEqual(int8.first, -8)\n \n let int16: Set = try! data.value(for: \"int16\")\n XCTAssertEqual(int16.count, 1)\n XCTAssertEqual(int16.first, -16)\n \n let int32: Set = try! data.value(for: \"int32\")\n XCTAssertEqual(int32.count, 1)\n XCTAssertEqual(int32.first, -32)\n \n let int64: Set = try! data.value(for: \"int64\")\n XCTAssertEqual(int64.count, 1)\n XCTAssertEqual(int64.first, -64)\n \n let uint: Set = try! data.value(for: \"uint\")\n XCTAssertEqual(uint.count, 1)\n XCTAssertEqual(uint.first, 3)\n \n let uint8: Set = try! data.value(for: \"uint8\")\n XCTAssertEqual(uint8.count, 1)\n XCTAssertEqual(uint8.first, 8)\n \n let uint16: Set = try! data.value(for: \"uint16\")\n XCTAssertEqual(uint16.count, 1)\n XCTAssertEqual(uint16.first, 16)\n \n let uint32: Set = try! data.value(for: \"uint32\")\n XCTAssertEqual(uint32.count, 1)\n XCTAssertEqual(uint32.first, 32)\n \n let uint64: Set = try! data.value(for: \"uint64\")\n XCTAssertEqual(uint64.count, 1)\n XCTAssertEqual(uint64.first, 64)\n \n let url: Set = try! data.value(for: \"url\")\n XCTAssertEqual(url.count, 1)\n XCTAssertEqual(url.first?.absoluteString, \"https://developer.apple.com/\")\n \n let date: Set = try! data.value(for: \"date\")\n XCTAssertEqual(date.count, 1)\n XCTAssertEqual(formatDate(date.first!), formatDate(dateForAssert()))\n }\n \n func testNestedValue() {\n let bool: Set = try! data.value(for: \"object.bool\")\n XCTAssertEqual(bool.count, 2)\n XCTAssertEqual(bool.first, false)\n \n let string: Set = try! data.value(for: \"object.string\")\n XCTAssertEqual(string.count, 1)\n XCTAssertEqual(string.first, \"Hello, Outlaw!\")\n \n let character: Set = try! data.value(for: \"object.character\")\n XCTAssertEqual(character.count, 1)\n XCTAssertEqual(character.first, \"O\")\n \n let float: Set = try! data.value(for: \"object.float\")\n XCTAssertEqual(float.count, 1)\n XCTAssertEqual(float.first, 3.14)\n \n let double: Set = try! data.value(for: \"object.double\")\n XCTAssertEqual(double.count, 1)\n XCTAssertEqual(double.first, 3.14159265359)\n \n let int: Set = try! data.value(for: \"object.int\")\n XCTAssertEqual(int.count, 1)\n XCTAssertEqual(int.first, -3)\n \n let int8: Set = try! data.value(for: \"object.int8\")\n XCTAssertEqual(int8.count, 1)\n XCTAssertEqual(int8.first, -8)\n \n let int16: Set = try! data.value(for: \"object.int16\")\n XCTAssertEqual(int16.count, 1)\n XCTAssertEqual(int16.first, -16)\n \n let int32: Set = try! data.value(for: \"object.int32\")\n XCTAssertEqual(int32.count, 1)\n XCTAssertEqual(int32.first, -32)\n \n let int64: Set = try! data.value(for: \"object.int64\")\n XCTAssertEqual(int64.count, 1)\n XCTAssertEqual(int64.first, -64)\n \n let uint: Set = try! data.value(for: \"object.uint\")\n XCTAssertEqual(uint.count, 1)\n XCTAssertEqual(uint.first, 3)\n \n let uint8: Set = try! data.value(for: \"object.uint8\")\n XCTAssertEqual(uint8.count, 1)\n XCTAssertEqual(uint8.first, 8)\n \n let uint16: Set = try! data.value(for: \"object.uint16\")\n XCTAssertEqual(uint16.count, 1)\n XCTAssertEqual(uint16.first, 16)\n \n let uint32: Set = try! data.value(for: \"object.uint32\")\n XCTAssertEqual(uint32.count, 1)\n XCTAssertEqual(uint32.first, 32)\n \n let uint64: Set = try! data.value(for: \"object.uint64\")\n XCTAssertEqual(uint64.count, 1)\n XCTAssertEqual(uint64.first, 64)\n \n let url: Set = try! data.value(for: \"object.url\")\n XCTAssertEqual(url.count, 1)\n XCTAssertEqual(url.first?.absoluteString, \"https://developer.apple.com/\")\n \n let date: Set = try! data.value(for: \"object.date\")\n XCTAssertEqual(date.count, 1)\n XCTAssertEqual(formatDate(date.first!), formatDate(dateForAssert()))\n }\n \n func testKeyNotFound() {\n var value: Set = []\n \n let ex = self.expectation(description: \"Key not found\")\n do {\n value = try data.value(for: \"keyNotFound\")\n }\n catch {\n if case OutlawError.keyNotFound = error {\n ex.fulfill()\n }\n }\n self.waitForExpectations(timeout: 1, handler: nil)\n XCTAssertEqual(value.count, 0)\n }\n \n func testTypeMismatch() {\n var value: Set = []\n \n let ex = self.expectation(description: \"Type mismatch\")\n do {\n value = try data.value(for: \"object\")\n }\n catch {\n if case OutlawError.typeMismatchWithKey = error {\n ex.fulfill()\n }\n }\n self.waitForExpectations(timeout: 1, handler: nil)\n XCTAssertEqual(value.count, 0)\n }\n \n// MARK: -\n// MARK: Optionals\n \n func testOptional() {\n let bool: Set? = data.value(for: \"bool\")\n XCTAssertEqual(bool?.count, 2)\n XCTAssertEqual(bool?.first, false)\n \n let string: Set? = data.value(for: \"string\")\n XCTAssertEqual(string?.count, 1)\n XCTAssertEqual(string?.first, \"Hello, Outlaw!\")\n \n let character: Set? = data.value(for: \"character\")\n XCTAssertEqual(character?.count, 1)\n XCTAssertEqual(character?.first, \"O\")\n \n let float: Set? = data.value(for: \"float\")\n XCTAssertEqual(float?.count, 1)\n XCTAssertEqual(float?.first, 3.14)\n \n let double: Set? = data.value(for: \"double\")\n XCTAssertEqual(double?.count, 1)\n XCTAssertEqual(double?.first, 3.14159265359)\n \n let int: Set? = data.value(for: \"int\")\n XCTAssertEqual(int?.count, 1)\n XCTAssertEqual(int?.first, -3)\n \n let int8: Set? = data.value(for: \"int8\")\n XCTAssertEqual(int8?.count, 1)\n XCTAssertEqual(int8?.first, -8)\n \n let int16: Set? = data.value(for: \"int16\")\n XCTAssertEqual(int16?.count, 1)\n XCTAssertEqual(int16?.first, -16)\n \n let int32: Set? = data.value(for: \"int32\")\n XCTAssertEqual(int32?.count, 1)\n XCTAssertEqual(int32?.first, -32)\n \n let int64: Set? = data.value(for: \"int64\")\n XCTAssertEqual(int64?.count, 1)\n XCTAssertEqual(int64?.first, -64)\n \n let uint: Set? = data.value(for: \"uint\")\n XCTAssertEqual(uint?.count, 1)\n XCTAssertEqual(uint?.first, 3)\n \n let uint8: Set? = data.value(for: \"uint8\")\n XCTAssertEqual(uint8?.count, 1)\n XCTAssertEqual(uint8?.first, 8)\n \n let uint16: Set? = data.value(for: \"uint16\")\n XCTAssertEqual(uint16?.count, 1)\n XCTAssertEqual(uint16?.first, 16)\n \n let uint32: Set? = data.value(for: \"uint32\")\n XCTAssertEqual(uint32?.count, 1)\n XCTAssertEqual(uint32?.first, 32)\n \n let uint64: Set? = data.value(for: \"uint64\")\n XCTAssertEqual(uint64?.count, 1)\n XCTAssertEqual(uint64?.first, 64)\n \n let url: Set? = data.value(for: \"url\")\n XCTAssertEqual(url?.count, 1)\n XCTAssertEqual(url?.first?.absoluteString, \"https://developer.apple.com/\")\n \n let date: Set? = data.value(for: \"date\")\n XCTAssertEqual(date?.count, 1)\n XCTAssertEqual(formatDate(date!.first!), formatDate(dateForAssert()))\n }\n \n func testOptionalNestedValue() {\n let bool: Set? = data.value(for: \"object.bool\")\n XCTAssertEqual(bool?.count, 2)\n XCTAssertEqual(bool?.first, false)\n \n let string: Set? = data.value(for: \"object.string\")\n XCTAssertEqual(string?.count, 1)\n XCTAssertEqual(string?.first, \"Hello, Outlaw!\")\n \n let character: Set? = data.value(for: \"object.character\")\n XCTAssertEqual(character?.count, 1)\n XCTAssertEqual(character?.first, \"O\")\n \n let float: Set? = data.value(for: \"object.float\")\n XCTAssertEqual(float?.count, 1)\n XCTAssertEqual(float?.first, 3.14)\n \n let double: Set? = data.value(for: \"object.double\")\n XCTAssertEqual(double?.count, 1)\n XCTAssertEqual(double?.first, 3.14159265359)\n \n let int: Set? = data.value(for: \"object.int\")\n XCTAssertEqual(int?.count, 1)\n XCTAssertEqual(int?.first, -3)\n \n let int8: Set? = data.value(for: \"object.int8\")\n XCTAssertEqual(int8?.count, 1)\n XCTAssertEqual(int8?.first, -8)\n \n let int16: Set? = data.value(for: \"object.int16\")\n XCTAssertEqual(int16?.count, 1)\n XCTAssertEqual(int16?.first, -16)\n \n let int32: Set? = data.value(for: \"object.int32\")\n XCTAssertEqual(int32?.count, 1)\n XCTAssertEqual(int32?.first, -32)\n \n let int64: Set? = data.value(for: \"object.int64\")\n XCTAssertEqual(int64?.count, 1)\n XCTAssertEqual(int64?.first, -64)\n \n let uint: Set? = data.value(for: \"object.uint\")\n XCTAssertEqual(uint?.count, 1)\n XCTAssertEqual(uint?.first, 3)\n \n let uint8: Set? = data.value(for: \"object.uint8\")\n XCTAssertEqual(uint8?.count, 1)\n XCTAssertEqual(uint8?.first, 8)\n \n let uint16: Set? = data.value(for: \"object.uint16\")\n XCTAssertEqual(uint16?.count, 1)\n XCTAssertEqual(uint16?.first, 16)\n \n let uint32: Set? = data.value(for: \"object.uint32\")\n XCTAssertEqual(uint32?.count, 1)\n XCTAssertEqual(uint32?.first, 32)\n \n let uint64: Set? = data.value(for: \"object.uint64\")\n XCTAssertEqual(uint64?.count, 1)\n XCTAssertEqual(uint64?.first, 64)\n \n let url: Set? = data.value(for: \"object.url\")\n XCTAssertEqual(url?.count, 1)\n XCTAssertEqual(url?.first?.absoluteString, \"https://developer.apple.com/\")\n \n let date: Set? = data.value(for: \"object.date\")\n XCTAssertEqual(date?.count, 1)\n XCTAssertEqual(formatDate(date!.first!), formatDate(dateForAssert()))\n }\n \n func testOptionalKeyNotFound() {\n let value: Set? = data.value(for: \"keyNotFound\")\n XCTAssertNil(value)\n }\n \n func testOptionalTypeMismatch() {\n let value: Set? = data.value(for: \"object\")\n XCTAssertNil(value)\n }\n \n// MARK: -\n// MARK: Transforms\n \n func testTransformValue() {\n let bool: Set = try! data.value(for: \"boolTransform\", with: { (rawValue: String) -> Bool in\n return rawValue == \"TRUE\"\n })\n XCTAssertEqual(bool.count, 1)\n XCTAssertEqual(bool.first, true)\n \n let string: Set = try! data.value(for: \"stringTransform\", with: { (rawValue: Bool) -> String in\n return rawValue ? \"TRUE\" : \"FALSE\"\n })\n XCTAssertEqual(string.count, 1)\n XCTAssertEqual(string.first, \"TRUE\")\n \n let character: Set = try! data.value(for: \"characterTransform\", with: { (rawValue: Bool) -> Character in\n return rawValue ? \"1\" : \"0\"\n })\n XCTAssertEqual(character.count, 1)\n XCTAssertEqual(character.first, \"1\")\n \n let float: Set = try! data.value(for: \"floatTransform\", with: { (rawValue: String) -> Float in\n return rawValue == \"PI\" ? 3.14 : 0\n })\n XCTAssertEqual(float.count, 1)\n XCTAssertEqual(float.first, 3.14)\n \n let double: Set = try! data.value(for: \"doubleTransform\", with: { (rawValue: String) -> Double in\n return rawValue == \"PI\" ? 3.14 : 0\n })\n XCTAssertEqual(double.count, 1)\n XCTAssertEqual(double.first, 3.14)\n \n let int: Set = try! data.value(for: \"intTransform\", with: { (rawValue: String) -> Int in\n guard let value = Int(rawValue) else {\n throw OutlawError.typeMismatchWithKey(key: \"intTransform\", expected: Int.self, actual: rawValue)\n }\n return value\n })\n XCTAssertEqual(int.count, 1)\n XCTAssertEqual(int.first, 12345)\n \n let int8: Set = try! data.value(for: \"int8Transform\", with: { (rawValue: String) -> Int8 in\n guard let value = Int8(rawValue) else {\n throw OutlawError.typeMismatchWithKey(key: \"intTransform\", expected: Int8.self, actual: rawValue)\n }\n return value\n })\n XCTAssertEqual(int8.count, 1)\n XCTAssertEqual(int8.first, 123)\n \n let int16: Set = try! data.value(for: \"int16Transform\", with: { (rawValue: String) -> Int16 in\n guard let value = Int16(rawValue) else {\n throw OutlawError.typeMismatchWithKey(key: \"int16Transform\", expected: Int16.self, actual: rawValue)\n }\n return value\n })\n XCTAssertEqual(int16.count, 1)\n XCTAssertEqual(int16.first, 12345)\n \n let int32: Set = try! data.value(for: \"int32Transform\", with: { (rawValue: String) -> Int32 in\n guard let value = Int32(rawValue) else {\n throw OutlawError.typeMismatchWithKey(key: \"int32Transform\", expected: Int32.self, actual: rawValue)\n }\n return value\n })\n XCTAssertEqual(int32.count, 1)\n XCTAssertEqual(int32.first, 12345)\n \n let int64: Set = try! data.value(for: \"int64Transform\", with: { (rawValue: String) -> Int64 in\n guard let value = Int64(rawValue) else {\n throw OutlawError.typeMismatchWithKey(key: \"int64Transform\", expected: Int64.self, actual: rawValue)\n }\n return value\n })\n XCTAssertEqual(int64.count, 1)\n XCTAssertEqual(int64.first, 12345)\n \n let uint: Set = try! data.value(for: \"uintTransform\", with: { (rawValue: String) -> UInt in\n guard let value = UInt(rawValue) else {\n throw OutlawError.typeMismatchWithKey(key: \"uintTransform\", expected: UInt.self, actual: rawValue)\n }\n return value\n })\n XCTAssertEqual(uint.count, 1)\n XCTAssertEqual(uint.first, 12345)\n \n let uint8: Set = try! data.value(for: \"uint8Transform\", with: { (rawValue: String) -> UInt8 in\n guard let value = UInt8(rawValue) else {\n throw OutlawError.typeMismatchWithKey(key: \"uintTransform\", expected: UInt8.self, actual: rawValue)\n }\n return value\n })\n XCTAssertEqual(uint8.count, 1)\n XCTAssertEqual(uint8.first, 123)\n \n let uint16: Set = try! data.value(for: \"uint16Transform\", with: { (rawValue: String) -> UInt16 in\n guard let value = UInt16(rawValue) else {\n throw OutlawError.typeMismatchWithKey(key: \"uint16Transform\", expected: UInt16.self, actual: rawValue)\n }\n return value\n })\n XCTAssertEqual(uint16.count, 1)\n XCTAssertEqual(uint16.first, 12345)\n \n let uint32: Set = try! data.value(for: \"uint32Transform\", with: { (rawValue: String) -> UInt32 in\n guard let value = UInt32(rawValue) else {\n throw OutlawError.typeMismatchWithKey(key: \"uint32Transform\", expected: UInt32.self, actual: rawValue)\n }\n return value\n })\n XCTAssertEqual(uint32.count, 1)\n XCTAssertEqual(uint32.first, 12345)\n \n let uint64: Set = try! data.value(for: \"uint64Transform\", with: { (rawValue: String) -> UInt64 in\n guard let value = UInt64(rawValue) else {\n throw OutlawError.typeMismatchWithKey(key: \"uint64Transform\", expected: UInt64.self, actual: rawValue)\n }\n return value\n })\n XCTAssertEqual(uint64.count, 1)\n XCTAssertEqual(uint64.first, 12345)\n \n let url: Set = try! data.value(for: \"urlTransform\", with: { (rawValue: String) -> URL in\n let urlValue = rawValue == \"HOMEPAGE\" ? \"http://molbie.co\" : rawValue\n guard let value = URL(string: urlValue) else {\n throw OutlawError.typeMismatchWithKey(key: \"urlTransform\", expected: URL.self, actual: rawValue)\n }\n \n return value\n })\n XCTAssertEqual(url.count, 1)\n XCTAssertEqual(url.first?.absoluteString, \"http://molbie.co\")\n \n let formatter = shortDateformatter()\n let date: Set = try! data.value(for: \"dateTransform\", with: { (rawValue: String) -> Date in\n return formatter.date(from: rawValue)!\n })\n XCTAssertEqual(date.count, 1)\n XCTAssertEqual(formatShortDate(date.first!), formatShortDate(shortDateForAssert()))\n }\n \n func testOptionalTransformValue() {\n let bool: Set = try! data.value(for: \"boolTransform\", with: { (rawValue: String?) -> Bool in\n return rawValue == \"TRUE\"\n })\n XCTAssertEqual(bool.count, 1)\n XCTAssertEqual(bool.first, true)\n \n let string: Set = try! data.value(for: \"stringTransform\", with: { (rawValue: Bool?) -> String in\n guard let rawValue = rawValue else { return \"FALSE\" }\n return rawValue ? \"TRUE\" : \"FALSE\"\n })\n XCTAssertEqual(string.count, 1)\n XCTAssertEqual(string.first, \"TRUE\")\n \n let character: Set = try! data.value(for: \"characterTransform\", with: { (rawValue: Bool?) -> Character in\n guard let rawValue = rawValue else { return \"0\" }\n return rawValue ? \"1\" : \"0\"\n })\n XCTAssertEqual(character.count, 1)\n XCTAssertEqual(character.first, \"1\")\n \n let float: Set = try! data.value(for: \"floatTransform\", with: { (rawValue: String?) -> Float in\n guard let rawValue = rawValue else { return 0 }\n return rawValue == \"PI\" ? 3.14 : 0\n })\n XCTAssertEqual(float.count, 1)\n XCTAssertEqual(float.first, 3.14)\n \n let double: Set = try! data.value(for: \"doubleTransform\", with: { (rawValue: String?) -> Double in\n guard let rawValue = rawValue else { return 0 }\n return rawValue == \"PI\" ? 3.14 : 0\n })\n XCTAssertEqual(double.count, 1)\n XCTAssertEqual(double.first, 3.14)\n \n let int: Set = try! data.value(for: \"intTransform\", with: { (rawValue: String?) -> Int in\n guard let value = Int(rawValue ?? \"0\") else {\n throw OutlawError.typeMismatchWithKey(key: \"intTransform\", expected: Int.self, actual: rawValue ?? \"nil\")\n }\n return value\n })\n XCTAssertEqual(int.count, 1)\n XCTAssertEqual(int.first, 12345)\n \n let int8: Set = try! data.value(for: \"int8Transform\", with: { (rawValue: String?) -> Int8 in\n guard let value = Int8(rawValue ?? \"0\") else {\n throw OutlawError.typeMismatchWithKey(key: \"int8Transform\", expected: Int8.self, actual: rawValue ?? \"nil\")\n }\n return value\n })\n XCTAssertEqual(int8.count, 1)\n XCTAssertEqual(int8.first, 123)\n \n let int16: Set = try! data.value(for: \"int16Transform\", with: { (rawValue: String?) -> Int16 in\n guard let value = Int16(rawValue ?? \"0\") else {\n throw OutlawError.typeMismatchWithKey(key: \"int16Transform\", expected: Int16.self, actual: rawValue ?? \"nil\")\n }\n return value\n })\n XCTAssertEqual(int16.count, 1)\n XCTAssertEqual(int16.first, 12345)\n \n let int32: Set = try! data.value(for: \"int32Transform\", with: { (rawValue: String?) -> Int32 in\n guard let value = Int32(rawValue ?? \"0\") else {\n throw OutlawError.typeMismatchWithKey(key: \"int32Transform\", expected: Int32.self, actual: rawValue ?? \"nil\")\n }\n return value\n })\n XCTAssertEqual(int32.count, 1)\n XCTAssertEqual(int32.first, 12345)\n \n let int64: Set = try! data.value(for: \"intTransform\", with: { (rawValue: String?) -> Int64 in\n guard let value = Int64(rawValue ?? \"0\") else {\n throw OutlawError.typeMismatchWithKey(key: \"intTransform\", expected: Int64.self, actual: rawValue ?? \"nil\")\n }\n return value\n })\n XCTAssertEqual(int64.count, 1)\n XCTAssertEqual(int64.first, 12345)\n \n let uint: Set = try! data.value(for: \"uintTransform\", with: { (rawValue: String?) -> UInt in\n guard let value = UInt(rawValue ?? \"0\") else {\n throw OutlawError.typeMismatchWithKey(key: \"uintTransform\", expected: UInt.self, actual: rawValue ?? \"nil\")\n }\n return value\n })\n XCTAssertEqual(uint.count, 1)\n XCTAssertEqual(uint.first, 12345)\n \n let uint8: Set = try! data.value(for: \"uint8Transform\", with: { (rawValue: String?) -> UInt8 in\n guard let value = UInt8(rawValue ?? \"0\") else {\n throw OutlawError.typeMismatchWithKey(key: \"uint8Transform\", expected: UInt8.self, actual: rawValue ?? \"nil\")\n }\n return value\n })\n XCTAssertEqual(uint8.count, 1)\n XCTAssertEqual(uint8.first, 123)\n \n let uint16: Set = try! data.value(for: \"uint16Transform\", with: { (rawValue: String?) -> UInt16 in\n guard let value = UInt16(rawValue ?? \"0\") else {\n throw OutlawError.typeMismatchWithKey(key: \"uint16Transform\", expected: UInt16.self, actual: rawValue ?? \"nil\")\n }\n return value\n })\n XCTAssertEqual(uint16.count, 1)\n XCTAssertEqual(uint16.first, 12345)\n \n let uint32: Set = try! data.value(for: \"uint32Transform\", with: { (rawValue: String?) -> UInt32 in\n guard let value = UInt32(rawValue ?? \"0\") else {\n throw OutlawError.typeMismatchWithKey(key: \"uint32Transform\", expected: UInt32.self, actual: rawValue ?? \"nil\")\n }\n return value\n })\n XCTAssertEqual(uint32.count, 1)\n XCTAssertEqual(uint32.first, 12345)\n \n let uint64: Set = try! data.value(for: \"uintTransform\", with: { (rawValue: String?) -> UInt64 in\n guard let value = UInt64(rawValue ?? \"0\") else {\n throw OutlawError.typeMismatchWithKey(key: \"uintTransform\", expected: UInt64.self, actual: rawValue ?? \"nil\")\n }\n return value\n })\n XCTAssertEqual(uint64.count, 1)\n XCTAssertEqual(uint64.first, 12345)\n \n let url: Set = try! data.value(for: \"urlTransform\", with: { (rawValue: String?) -> URL in\n let urlValue = rawValue == \"HOMEPAGE\" ? \"http://molbie.co\" : (rawValue ?? \"\")\n guard let value = URL(string: urlValue) else {\n throw OutlawError.typeMismatchWithKey(key: \"urlTransform\", expected: URL.self, actual: rawValue ?? \"\")\n }\n \n return value\n })\n XCTAssertEqual(url.count, 1)\n XCTAssertEqual(url.first?.absoluteString, \"http://molbie.co\")\n \n let formatter = shortDateformatter()\n let date: Set = try! data.value(for: \"dateTransform\", with: { (rawValue: String?) -> Date in\n guard let dateValue = rawValue else {\n throw OutlawError.typeMismatchWithKey(key: \"transform\", expected: Date.self, actual: rawValue ?? \"\")\n }\n \n return formatter.date(from: dateValue)!\n })\n XCTAssertEqual(date.count, 1)\n XCTAssertEqual(formatShortDate(date.first!), formatShortDate(shortDateForAssert()))\n }\n\n func testTransformOptionalValue() {\n let bool: Set? = data.value(for: \"boolTransform\", with: { (rawValue: String) -> Bool in\n return rawValue == \"TRUE\"\n })\n XCTAssertEqual(bool?.count, 1)\n XCTAssertEqual(bool?.first, true)\n \n let string: Set? = data.value(for: \"stringTransform\", with: { (rawValue: Bool) -> String in\n return rawValue ? \"TRUE\" : \"FALSE\"\n })\n XCTAssertEqual(string?.count, 1)\n XCTAssertEqual(string?.first, \"TRUE\")\n \n let character: Set? = data.value(for: \"characterTransform\", with: { (rawValue: Bool) -> Character in\n return rawValue ? \"1\" : \"0\"\n })\n XCTAssertEqual(character?.count, 1)\n XCTAssertEqual(character?.first, \"1\")\n \n let float: Set? = data.value(for: \"floatTransform\", with: { (rawValue: String) -> Float in\n return rawValue == \"PI\" ? 3.14 : 0\n })\n XCTAssertEqual(float?.count, 1)\n XCTAssertEqual(float?.first, 3.14)\n \n let double: Set? = data.value(for: \"doubleTransform\", with: { (rawValue: String) -> Double in\n return rawValue == \"PI\" ? 3.14 : 0\n })\n XCTAssertEqual(double?.count, 1)\n XCTAssertEqual(double?.first, 3.14)\n \n let int: Set? = data.value(for: \"intTransform\", with: { (rawValue: String) -> Int in\n guard let value = Int(rawValue) else {\n throw OutlawError.typeMismatchWithKey(key: \"intTransform\", expected: Int.self, actual: rawValue)\n }\n return value\n })\n XCTAssertEqual(int?.count, 1)\n XCTAssertEqual(int?.first, 12345)\n \n let int8: Set? = data.value(for: \"int8Transform\", with: { (rawValue: String) -> Int8 in\n guard let value = Int8(rawValue) else {\n throw OutlawError.typeMismatchWithKey(key: \"int8Transform\", expected: Int8.self, actual: rawValue)\n }\n return value\n })\n XCTAssertEqual(int8?.count, 1)\n XCTAssertEqual(int8?.first, 123)\n \n let int16: Set? = data.value(for: \"int16Transform\", with: { (rawValue: String) -> Int16 in\n guard let value = Int16(rawValue) else {\n throw OutlawError.typeMismatchWithKey(key: \"int16Transform\", expected: Int16.self, actual: rawValue)\n }\n return value\n })\n XCTAssertEqual(int16?.count, 1)\n XCTAssertEqual(int16?.first, 12345)\n \n let int32: Set? = data.value(for: \"int32Transform\", with: { (rawValue: String) -> Int32 in\n guard let value = Int32(rawValue) else {\n throw OutlawError.typeMismatchWithKey(key: \"int32Transform\", expected: Int32.self, actual: rawValue)\n }\n return value\n })\n XCTAssertEqual(int32?.count, 1)\n XCTAssertEqual(int32?.first, 12345)\n \n let int64: Set? = data.value(for: \"int64Transform\", with: { (rawValue: String) -> Int64 in\n guard let value = Int64(rawValue) else {\n throw OutlawError.typeMismatchWithKey(key: \"int64Transform\", expected: Int64.self, actual: rawValue)\n }\n return value\n })\n XCTAssertEqual(int64?.count, 1)\n XCTAssertEqual(int64?.first, 12345)\n \n let uint: Set? = data.value(for: \"uintTransform\", with: { (rawValue: String) -> UInt in\n guard let value = UInt(rawValue) else {\n throw OutlawError.typeMismatchWithKey(key: \"uintTransform\", expected: UInt.self, actual: rawValue)\n }\n return value\n })\n XCTAssertEqual(uint?.count, 1)\n XCTAssertEqual(uint?.first, 12345)\n \n let uint8: Set? = data.value(for: \"uint8Transform\", with: { (rawValue: String) -> UInt8 in\n guard let value = UInt8(rawValue) else {\n throw OutlawError.typeMismatchWithKey(key: \"uint8Transform\", expected: UInt8.self, actual: rawValue)\n }\n return value\n })\n XCTAssertEqual(uint8?.count, 1)\n XCTAssertEqual(uint8?.first, 123)\n \n let uint16: Set? = data.value(for: \"uint16Transform\", with: { (rawValue: String) -> UInt16 in\n guard let value = UInt16(rawValue) else {\n throw OutlawError.typeMismatchWithKey(key: \"uint16Transform\", expected: UInt16.self, actual: rawValue)\n }\n return value\n })\n XCTAssertEqual(uint16?.count, 1)\n XCTAssertEqual(uint16?.first, 12345)\n \n let uint32: Set? = data.value(for: \"uint32Transform\", with: { (rawValue: String) -> UInt32 in\n guard let value = UInt32(rawValue) else {\n throw OutlawError.typeMismatchWithKey(key: \"uint32Transform\", expected: UInt32.self, actual: rawValue)\n }\n return value\n })\n XCTAssertEqual(uint32?.count, 1)\n XCTAssertEqual(uint32?.first, 12345)\n \n let uint64: Set? = data.value(for: \"uint64Transform\", with: { (rawValue: String) -> UInt64 in\n guard let value = UInt64(rawValue) else {\n throw OutlawError.typeMismatchWithKey(key: \"uint64Transform\", expected: UInt64.self, actual: rawValue)\n }\n return value\n })\n XCTAssertEqual(uint64?.count, 1)\n XCTAssertEqual(uint64?.first, 12345)\n \n let url: Set? = data.value(for: \"urlTransform\", with: { (rawValue: String) -> URL in\n let urlValue = rawValue == \"HOMEPAGE\" ? \"http://molbie.co\" : rawValue\n guard let value = URL(string: urlValue) else {\n throw OutlawError.typeMismatchWithKey(key: \"urlTransform\", expected: URL.self, actual: rawValue)\n }\n \n return value\n })\n XCTAssertEqual(url?.count, 1)\n XCTAssertEqual(url?.first?.absoluteString, \"http://molbie.co\")\n \n let formatter = shortDateformatter()\n let date: Set? = data.value(for: \"dateTransform\", with: { (rawValue: String) -> Date in\n return formatter.date(from: rawValue)!\n })\n XCTAssertEqual(date?.count, 1)\n XCTAssertEqual(formatShortDate(date!.first!), formatShortDate(shortDateForAssert()))\n }\n \n func testOptionalTransformOptionalValue() {\n let bool: Set? = data.value(for: \"boolTransform\", with: { (rawValue: String?) -> Bool in\n return rawValue == \"TRUE\"\n })\n XCTAssertEqual(bool?.count, 1)\n XCTAssertEqual(bool?.first, true)\n \n let string: Set? = data.value(for: \"stringTransform\", with: { (rawValue: Bool?) -> String in\n let value = rawValue ?? false\n return value ? \"TRUE\" : \"FALSE\"\n })\n XCTAssertEqual(string?.count, 1)\n XCTAssertEqual(string?.first, \"TRUE\")\n \n let character: Set? = data.value(for: \"characterTransform\", with: { (rawValue: Bool?) -> Character in\n let value = rawValue ?? false\n return value ? \"1\" : \"0\"\n })\n XCTAssertEqual(character?.count, 1)\n XCTAssertEqual(character?.first, \"1\")\n \n let float: Set? = data.value(for: \"floatTransform\", with: { (rawValue: String?) -> Float in\n let value = rawValue ?? \"\"\n return value == \"PI\" ? 3.14 : 0\n })\n XCTAssertEqual(float?.count, 1)\n XCTAssertEqual(float?.first, 3.14)\n \n let double: Set? = data.value(for: \"doubleTransform\", with: { (rawValue: String?) -> Double in\n let value = rawValue ?? \"\"\n return value == \"PI\" ? 3.14 : 0\n })\n XCTAssertEqual(double?.count, 1)\n XCTAssertEqual(double?.first, 3.14)\n \n let int: Set? = data.value(for: \"intTransform\", with: { (rawValue: String?) -> Int in\n guard let value = Int(rawValue ?? \"\") else {\n throw OutlawError.typeMismatchWithKey(key: \"intTransform\", expected: Int.self, actual: rawValue ?? \"\")\n }\n return value\n })\n XCTAssertEqual(int?.count, 1)\n XCTAssertEqual(int?.first, 12345)\n \n let int8: Set? = data.value(for: \"int8Transform\", with: { (rawValue: String?) -> Int8 in\n guard let value = Int8(rawValue ?? \"\") else {\n throw OutlawError.typeMismatchWithKey(key: \"int8Transform\", expected: Int8.self, actual: rawValue ?? \"\")\n }\n return value\n })\n XCTAssertEqual(int8?.count, 1)\n XCTAssertEqual(int8?.first, 123)\n \n let int16: Set? = data.value(for: \"int16Transform\", with: { (rawValue: String?) -> Int16 in\n guard let value = Int16(rawValue ?? \"\") else {\n throw OutlawError.typeMismatchWithKey(key: \"int16Transform\", expected: Int16.self, actual: rawValue ?? \"\")\n }\n return value\n })\n XCTAssertEqual(int16?.count, 1)\n XCTAssertEqual(int16?.first, 12345)\n \n let int32: Set? = data.value(for: \"int32Transform\", with: { (rawValue: String?) -> Int32 in\n guard let value = Int32(rawValue ?? \"\") else {\n throw OutlawError.typeMismatchWithKey(key: \"int32Transform\", expected: Int32.self, actual: rawValue ?? \"\")\n }\n return value\n })\n XCTAssertEqual(int32?.count, 1)\n XCTAssertEqual(int32?.first, 12345)\n \n let int64: Set? = data.value(for: \"int64Transform\", with: { (rawValue: String?) -> Int64 in\n guard let value = Int64(rawValue ?? \"\") else {\n throw OutlawError.typeMismatchWithKey(key: \"int64Transform\", expected: Int64.self, actual: rawValue ?? \"\")\n }\n return value\n })\n XCTAssertEqual(int64?.count, 1)\n XCTAssertEqual(int64?.first, 12345)\n \n let uint: Set? = data.value(for: \"uintTransform\", with: { (rawValue: String?) -> UInt in\n guard let value = UInt(rawValue ?? \"\") else {\n throw OutlawError.typeMismatchWithKey(key: \"uintTransform\", expected: UInt.self, actual: rawValue ?? \"\")\n }\n return value\n })\n XCTAssertEqual(uint?.count, 1)\n XCTAssertEqual(uint?.first, 12345)\n \n let uint8: Set? = data.value(for: \"uint8Transform\", with: { (rawValue: String?) -> UInt8 in\n guard let value = UInt8(rawValue ?? \"\") else {\n throw OutlawError.typeMismatchWithKey(key: \"uint8Transform\", expected: UInt8.self, actual: rawValue ?? \"\")\n }\n return value\n })\n XCTAssertEqual(uint8?.count, 1)\n XCTAssertEqual(uint8?.first, 123)\n \n let uint16: Set? = data.value(for: \"uint16Transform\", with: { (rawValue: String?) -> UInt16 in\n guard let value = UInt16(rawValue ?? \"\") else {\n throw OutlawError.typeMismatchWithKey(key: \"uint16Transform\", expected: UInt16.self, actual: rawValue ?? \"\")\n }\n return value\n })\n XCTAssertEqual(uint16?.count, 1)\n XCTAssertEqual(uint16?.first, 12345)\n \n let uint32: Set? = data.value(for: \"uint32Transform\", with: { (rawValue: String?) -> UInt32 in\n guard let value = UInt32(rawValue ?? \"\") else {\n throw OutlawError.typeMismatchWithKey(key: \"uint32Transform\", expected: UInt32.self, actual: rawValue ?? \"\")\n }\n return value\n })\n XCTAssertEqual(uint32?.count, 1)\n XCTAssertEqual(uint32?.first, 12345)\n \n let uint64: Set? = data.value(for: \"uint64Transform\", with: { (rawValue: String?) -> UInt64 in\n guard let value = UInt64(rawValue ?? \"\") else {\n throw OutlawError.typeMismatchWithKey(key: \"uint64Transform\", expected: UInt64.self, actual: rawValue ?? \"\")\n }\n return value\n })\n XCTAssertEqual(uint64?.count, 1)\n XCTAssertEqual(uint64?.first, 12345)\n \n let url: Set? = data.value(for: \"urlTransform\", with: { (rawValue: String?) -> URL in\n let urlValue = rawValue == \"HOMEPAGE\" ? \"http://molbie.co\" : (rawValue ?? \"\")\n guard let value = URL(string: urlValue) else {\n throw OutlawError.typeMismatchWithKey(key: \"urlTransform\", expected: URL.self, actual: rawValue ?? \"\")\n }\n \n return value\n })\n XCTAssertEqual(url?.count, 1)\n XCTAssertEqual(url?.first?.absoluteString, \"http://molbie.co\")\n \n let formatter = shortDateformatter()\n let date: Set? = data.value(for: \"dateTransform\", with: { (rawValue: String?) -> Date in\n let value = rawValue ?? \"11/18/2016\"\n return formatter.date(from: value)!\n })\n XCTAssertEqual(date?.count, 1)\n XCTAssertEqual(formatShortDate(date!.first!), formatShortDate(shortDateForAssert()))\n }\n \n// MARK: -\n// MARK: Transforms of Optionals\n \n func testTransformValueOfOptionals() {\n let bool: Set = try! data.value(for: \"boolTransform\", with: { (rawValue: String) -> Bool? in\n return rawValue == \"TRUE\"\n })\n XCTAssertEqual(bool.count, 1)\n XCTAssertEqual(bool.first, true)\n \n let string: Set = try! data.value(for: \"stringTransform\", with: { (rawValue: Bool) -> String? in\n return rawValue ? \"TRUE\" : \"FALSE\"\n })\n XCTAssertEqual(string.count, 1)\n XCTAssertEqual(string.first, \"TRUE\")\n \n let character: Set = try! data.value(for: \"characterTransform\", with: { (rawValue: Bool) -> Character? in\n return rawValue ? \"1\" : \"0\"\n })\n XCTAssertEqual(character.count, 1)\n XCTAssertEqual(character.first, \"1\")\n \n let float: Set = try! data.value(for: \"floatTransform\", with: { (rawValue: String) -> Float? in\n return rawValue == \"PI\" ? 3.14 : 0\n })\n XCTAssertEqual(float.count, 1)\n XCTAssertEqual(float.first, 3.14)\n \n let double: Set = try! data.value(for: \"doubleTransform\", with: { (rawValue: String) -> Double? in\n return rawValue == \"PI\" ? 3.14 : 0\n })\n XCTAssertEqual(double.count, 1)\n XCTAssertEqual(double.first, 3.14)\n \n let int: Set = try! data.value(for: \"intTransform\", with: { (rawValue: String) -> Int? in\n return Int(rawValue)\n })\n XCTAssertEqual(int.count, 1)\n XCTAssertEqual(int.first, 12345)\n \n let int8: Set = try! data.value(for: \"int8Transform\", with: { (rawValue: String) -> Int8? in\n return Int8(rawValue)\n })\n XCTAssertEqual(int8.count, 1)\n XCTAssertEqual(int8.first, 123)\n \n let int16: Set = try! data.value(for: \"int16Transform\", with: { (rawValue: String) -> Int16? in\n return Int16(rawValue)\n })\n XCTAssertEqual(int16.count, 1)\n XCTAssertEqual(int16.first, 12345)\n \n let int32: Set = try! data.value(for: \"int32Transform\", with: { (rawValue: String) -> Int32? in\n return Int32(rawValue)\n })\n XCTAssertEqual(int32.count, 1)\n XCTAssertEqual(int32.first, 12345)\n \n let int64: Set = try! data.value(for: \"int64Transform\", with: { (rawValue: String) -> Int64? in\n return Int64(rawValue)\n })\n XCTAssertEqual(int64.count, 1)\n XCTAssertEqual(int64.first, 12345)\n \n let uint: Set = try! data.value(for: \"uintTransform\", with: { (rawValue: String) -> UInt? in\n return UInt(rawValue)\n })\n XCTAssertEqual(uint.count, 1)\n XCTAssertEqual(uint.first, 12345)\n \n let uint8: Set = try! data.value(for: \"uint8Transform\", with: { (rawValue: String) -> UInt8? in\n return UInt8(rawValue)\n })\n XCTAssertEqual(uint8.count, 1)\n XCTAssertEqual(uint8.first, 123)\n \n let uint16: Set = try! data.value(for: \"uint16Transform\", with: { (rawValue: String) -> UInt16? in\n return UInt16(rawValue)\n })\n XCTAssertEqual(uint16.count, 1)\n XCTAssertEqual(uint16.first, 12345)\n \n let uint32: Set = try! data.value(for: \"uint32Transform\", with: { (rawValue: String) -> UInt32? in\n return UInt32(rawValue)\n })\n XCTAssertEqual(uint32.count, 1)\n XCTAssertEqual(uint32.first, 12345)\n \n let uint64: Set = try! data.value(for: \"uint64Transform\", with: { (rawValue: String) -> UInt64? in\n return UInt64(rawValue)\n })\n XCTAssertEqual(uint64.count, 1)\n XCTAssertEqual(uint64.first, 12345)\n \n let url: Set = try! data.value(for: \"urlTransform\", with: { (rawValue: String) -> URL? in\n let urlValue = rawValue == \"HOMEPAGE\" ? \"http://molbie.co\" : rawValue\n return URL(string: urlValue)\n })\n XCTAssertEqual(url.count, 1)\n XCTAssertEqual(url.first?.absoluteString, \"http://molbie.co\")\n \n let formatter = shortDateformatter()\n let date: Set = try! data.value(for: \"dateTransform\", with: { (rawValue: String) -> Date? in\n return formatter.date(from: rawValue)!\n })\n XCTAssertEqual(date.count, 1)\n XCTAssertEqual(formatShortDate(date.first!), formatShortDate(shortDateForAssert()))\n }\n \n func testOptionalTransformValueOfOptionals() {\n let bool: Set = try! data.value(for: \"boolTransform\", with: { (rawValue: String?) -> Bool? in\n return rawValue == \"TRUE\"\n })\n XCTAssertEqual(bool.count, 1)\n XCTAssertEqual(bool.first, true)\n \n let string: Set = try! data.value(for: \"stringTransform\", with: { (rawValue: Bool?) -> String? in\n guard let rawValue = rawValue else { return \"FALSE\" }\n return rawValue ? \"TRUE\" : \"FALSE\"\n })\n XCTAssertEqual(string.count, 1)\n XCTAssertEqual(string.first, \"TRUE\")\n \n let character: Set = try! data.value(for: \"characterTransform\", with: { (rawValue: Bool?) -> Character? in\n guard let rawValue = rawValue else { return \"0\" }\n return rawValue ? \"1\" : \"0\"\n })\n XCTAssertEqual(character.count, 1)\n XCTAssertEqual(character.first, \"1\")\n \n let float: Set = try! data.value(for: \"floatTransform\", with: { (rawValue: String?) -> Float? in\n guard let rawValue = rawValue else { return 0 }\n return rawValue == \"PI\" ? 3.14 : 0\n })\n XCTAssertEqual(float.count, 1)\n XCTAssertEqual(float.first, 3.14)\n \n let double: Set = try! data.value(for: \"doubleTransform\", with: { (rawValue: String?) -> Double? in\n guard let rawValue = rawValue else { return 0 }\n return rawValue == \"PI\" ? 3.14 : 0\n })\n XCTAssertEqual(double.count, 1)\n XCTAssertEqual(double.first, 3.14)\n \n let int: Set = try! data.value(for: \"intTransform\", with: { (rawValue: String?) -> Int? in\n return Int(rawValue ?? \"0\")\n })\n XCTAssertEqual(int.count, 1)\n XCTAssertEqual(int.first, 12345)\n \n let int8: Set = try! data.value(for: \"int8Transform\", with: { (rawValue: String?) -> Int8? in\n return Int8(rawValue ?? \"0\")\n })\n XCTAssertEqual(int8.count, 1)\n XCTAssertEqual(int8.first, 123)\n \n let int16: Set = try! data.value(for: \"int16Transform\", with: { (rawValue: String?) -> Int16? in\n return Int16(rawValue ?? \"0\")\n })\n XCTAssertEqual(int16.count, 1)\n XCTAssertEqual(int16.first, 12345)\n \n let int32: Set = try! data.value(for: \"int32Transform\", with: { (rawValue: String?) -> Int32? in\n return Int32(rawValue ?? \"0\")\n })\n XCTAssertEqual(int32.count, 1)\n XCTAssertEqual(int32.first, 12345)\n \n let int64: Set = try! data.value(for: \"intTransform\", with: { (rawValue: String?) -> Int64? in\n return Int64(rawValue ?? \"0\")\n })\n XCTAssertEqual(int64.count, 1)\n XCTAssertEqual(int64.first, 12345)\n \n let uint: Set = try! data.value(for: \"uintTransform\", with: { (rawValue: String?) -> UInt? in\n return UInt(rawValue ?? \"0\")\n })\n XCTAssertEqual(uint.count, 1)\n XCTAssertEqual(uint.first, 12345)\n \n let uint8: Set = try! data.value(for: \"uint8Transform\", with: { (rawValue: String?) -> UInt8? in\n return UInt8(rawValue ?? \"0\")\n })\n XCTAssertEqual(uint8.count, 1)\n XCTAssertEqual(uint8.first, 123)\n \n let uint16: Set = try! data.value(for: \"uint16Transform\", with: { (rawValue: String?) -> UInt16? in\n return UInt16(rawValue ?? \"0\")\n })\n XCTAssertEqual(uint16.count, 1)\n XCTAssertEqual(uint16.first, 12345)\n \n let uint32: Set = try! data.value(for: \"uint32Transform\", with: { (rawValue: String?) -> UInt32? in\n return UInt32(rawValue ?? \"0\")\n })\n XCTAssertEqual(uint32.count, 1)\n XCTAssertEqual(uint32.first, 12345)\n \n let uint64: Set = try! data.value(for: \"uintTransform\", with: { (rawValue: String?) -> UInt64? in\n return UInt64(rawValue ?? \"0\")\n })\n XCTAssertEqual(uint64.count, 1)\n XCTAssertEqual(uint64.first, 12345)\n \n let url: Set = try! data.value(for: \"urlTransform\", with: { (rawValue: String?) -> URL? in\n let urlValue = rawValue == \"HOMEPAGE\" ? \"http://molbie.co\" : (rawValue ?? \"\")\n return URL(string: urlValue)\n })\n XCTAssertEqual(url.count, 1)\n XCTAssertEqual(url.first?.absoluteString, \"http://molbie.co\")\n \n let formatter = shortDateformatter()\n let date: Set = try! data.value(for: \"dateTransform\", with: { (rawValue: String?) -> Date? in\n guard let dateValue = rawValue else { return nil }\n return formatter.date(from: dateValue)!\n })\n XCTAssertEqual(date.count, 1)\n XCTAssertEqual(formatShortDate(date.first!), formatShortDate(shortDateForAssert()))\n }\n \n func testTransformOptionalValueOfOptionals() {\n let bool: Set? = data.value(for: \"boolTransform\", with: { (rawValue: String) -> Bool? in\n return rawValue == \"TRUE\"\n })\n XCTAssertEqual(bool?.count, 1)\n XCTAssertEqual(bool?.first, true)\n \n let string: Set? = data.value(for: \"stringTransform\", with: { (rawValue: Bool) -> String? in\n return rawValue ? \"TRUE\" : \"FALSE\"\n })\n XCTAssertEqual(string?.count, 1)\n XCTAssertEqual(string?.first, \"TRUE\")\n \n let character: Set? = data.value(for: \"characterTransform\", with: { (rawValue: Bool) -> Character? in\n return rawValue ? \"1\" : \"0\"\n })\n XCTAssertEqual(character?.count, 1)\n XCTAssertEqual(character?.first, \"1\")\n \n let float: Set? = data.value(for: \"floatTransform\", with: { (rawValue: String) -> Float? in\n return rawValue == \"PI\" ? 3.14 : 0\n })\n XCTAssertEqual(float?.count, 1)\n XCTAssertEqual(float?.first, 3.14)\n \n let double: Set? = data.value(for: \"doubleTransform\", with: { (rawValue: String) -> Double? in\n return rawValue == \"PI\" ? 3.14 : 0\n })\n XCTAssertEqual(double?.count, 1)\n XCTAssertEqual(double?.first, 3.14)\n \n let int: Set? = data.value(for: \"intTransform\", with: { (rawValue: String) -> Int? in\n return Int(rawValue)\n })\n XCTAssertEqual(int?.count, 1)\n XCTAssertEqual(int?.first, 12345)\n \n let int8: Set? = data.value(for: \"int8Transform\", with: { (rawValue: String) -> Int8? in\n return Int8(rawValue)\n })\n XCTAssertEqual(int8?.count, 1)\n XCTAssertEqual(int8?.first, 123)\n \n let int16: Set? = data.value(for: \"int16Transform\", with: { (rawValue: String) -> Int16? in\n return Int16(rawValue)\n })\n XCTAssertEqual(int16?.count, 1)\n XCTAssertEqual(int16?.first, 12345)\n \n let int32: Set? = data.value(for: \"int32Transform\", with: { (rawValue: String) -> Int32? in\n return Int32(rawValue)\n })\n XCTAssertEqual(int32?.count, 1)\n XCTAssertEqual(int32?.first, 12345)\n \n let int64: Set? = data.value(for: \"int64Transform\", with: { (rawValue: String) -> Int64? in\n return Int64(rawValue)\n })\n XCTAssertEqual(int64?.count, 1)\n XCTAssertEqual(int64?.first, 12345)\n \n let uint: Set? = data.value(for: \"uintTransform\", with: { (rawValue: String) -> UInt? in\n return UInt(rawValue)\n })\n XCTAssertEqual(uint?.count, 1)\n XCTAssertEqual(uint?.first, 12345)\n \n let uint8: Set? = data.value(for: \"uint8Transform\", with: { (rawValue: String) -> UInt8? in\n return UInt8(rawValue)\n })\n XCTAssertEqual(uint8?.count, 1)\n XCTAssertEqual(uint8?.first, 123)\n \n let uint16: Set? = data.value(for: \"uint16Transform\", with: { (rawValue: String) -> UInt16? in\n return UInt16(rawValue)\n })\n XCTAssertEqual(uint16?.count, 1)\n XCTAssertEqual(uint16?.first, 12345)\n \n let uint32: Set? = data.value(for: \"uint32Transform\", with: { (rawValue: String) -> UInt32? in\n return UInt32(rawValue)\n })\n XCTAssertEqual(uint32?.count, 1)\n XCTAssertEqual(uint32?.first, 12345)\n \n let uint64: Set? = data.value(for: \"uint64Transform\", with: { (rawValue: String) -> UInt64? in\n return UInt64(rawValue)\n })\n XCTAssertEqual(uint64?.count, 1)\n XCTAssertEqual(uint64?.first, 12345)\n \n let url: Set? = data.value(for: \"urlTransform\", with: { (rawValue: String) -> URL? in\n let urlValue = rawValue == \"HOMEPAGE\" ? \"http://molbie.co\" : rawValue\n return URL(string: urlValue)\n })\n XCTAssertEqual(url?.count, 1)\n XCTAssertEqual(url?.first?.absoluteString, \"http://molbie.co\")\n \n let formatter = shortDateformatter()\n let date: Set? = data.value(for: \"dateTransform\", with: { (rawValue: String) -> Date? in\n return formatter.date(from: rawValue)!\n })\n XCTAssertEqual(date?.count, 1)\n XCTAssertEqual(formatShortDate(date!.first!), formatShortDate(shortDateForAssert()))\n }\n \n func testOptionalTransformOptionalValueOfOptionals() {\n let bool: Set? = data.value(for: \"boolTransform\", with: { (rawValue: String?) -> Bool? in\n return rawValue == \"TRUE\"\n })\n XCTAssertEqual(bool?.count, 1)\n XCTAssertEqual(bool?.first, true)\n \n let string: Set? = data.value(for: \"stringTransform\", with: { (rawValue: Bool?) -> String? in\n let value = rawValue ?? false\n return value ? \"TRUE\" : \"FALSE\"\n })\n XCTAssertEqual(string?.count, 1)\n XCTAssertEqual(string?.first, \"TRUE\")\n \n let character: Set? = data.value(for: \"characterTransform\", with: { (rawValue: Bool?) -> Character? in\n let value = rawValue ?? false\n return value ? \"1\" : \"0\"\n })\n XCTAssertEqual(character?.count, 1)\n XCTAssertEqual(character?.first, \"1\")\n \n let float: Set? = data.value(for: \"floatTransform\", with: { (rawValue: String?) -> Float? in\n let value = rawValue ?? \"\"\n return value == \"PI\" ? 3.14 : 0\n })\n XCTAssertEqual(float?.count, 1)\n XCTAssertEqual(float?.first, 3.14)\n \n let double: Set? = data.value(for: \"doubleTransform\", with: { (rawValue: String?) -> Double? in\n let value = rawValue ?? \"\"\n return value == \"PI\" ? 3.14 : 0\n })\n XCTAssertEqual(double?.count, 1)\n XCTAssertEqual(double?.first, 3.14)\n \n let int: Set? = data.value(for: \"intTransform\", with: { (rawValue: String?) -> Int? in\n return Int(rawValue ?? \"\")\n })\n XCTAssertEqual(int?.count, 1)\n XCTAssertEqual(int?.first, 12345)\n \n let int8: Set? = data.value(for: \"int8Transform\", with: { (rawValue: String?) -> Int8? in\n return Int8(rawValue ?? \"\")\n })\n XCTAssertEqual(int8?.count, 1)\n XCTAssertEqual(int8?.first, 123)\n \n let int16: Set? = data.value(for: \"int16Transform\", with: { (rawValue: String?) -> Int16? in\n return Int16(rawValue ?? \"\")\n })\n XCTAssertEqual(int16?.count, 1)\n XCTAssertEqual(int16?.first, 12345)\n \n let int32: Set? = data.value(for: \"int32Transform\", with: { (rawValue: String?) -> Int32? in\n return Int32(rawValue ?? \"\")\n })\n XCTAssertEqual(int32?.count, 1)\n XCTAssertEqual(int32?.first, 12345)\n \n let int64: Set? = data.value(for: \"int64Transform\", with: { (rawValue: String?) -> Int64? in\n return Int64(rawValue ?? \"\")\n })\n XCTAssertEqual(int64?.count, 1)\n XCTAssertEqual(int64?.first, 12345)\n \n let uint: Set? = data.value(for: \"uintTransform\", with: { (rawValue: String?) -> UInt? in\n return UInt(rawValue ?? \"\")\n })\n XCTAssertEqual(uint?.count, 1)\n XCTAssertEqual(uint?.first, 12345)\n \n let uint8: Set? = data.value(for: \"uint8Transform\", with: { (rawValue: String?) -> UInt8? in\n return UInt8(rawValue ?? \"\")\n })\n XCTAssertEqual(uint8?.count, 1)\n XCTAssertEqual(uint8?.first, 123)\n \n let uint16: Set? = data.value(for: \"uint16Transform\", with: { (rawValue: String?) -> UInt16? in\n return UInt16(rawValue ?? \"\")\n })\n XCTAssertEqual(uint16?.count, 1)\n XCTAssertEqual(uint16?.first, 12345)\n \n let uint32: Set? = data.value(for: \"uint32Transform\", with: { (rawValue: String?) -> UInt32? in\n return UInt32(rawValue ?? \"\")\n })\n XCTAssertEqual(uint32?.count, 1)\n XCTAssertEqual(uint32?.first, 12345)\n \n let uint64: Set? = data.value(for: \"uint64Transform\", with: { (rawValue: String?) -> UInt64? in\n return UInt64(rawValue ?? \"\")\n })\n XCTAssertEqual(uint64?.count, 1)\n XCTAssertEqual(uint64?.first, 12345)\n \n let url: Set? = data.value(for: \"urlTransform\", with: { (rawValue: String?) -> URL? in\n let urlValue = rawValue == \"HOMEPAGE\" ? \"http://molbie.co\" : (rawValue ?? \"\")\n return URL(string: urlValue)\n })\n XCTAssertEqual(url?.count, 1)\n XCTAssertEqual(url?.first?.absoluteString, \"http://molbie.co\")\n \n let formatter = shortDateformatter()\n let date: Set? = data.value(for: \"dateTransform\", with: { (rawValue: String?) -> Date? in\n let value = rawValue ?? \"11/18/2016\"\n return formatter.date(from: value)!\n })\n XCTAssertEqual(date?.count, 1)\n XCTAssertEqual(formatShortDate(date!.first!), formatShortDate(shortDateForAssert()))\n }\n}\n"},"avg_line_length":{"kind":"number","value":43.196350365,"string":"43.19635"},"max_line_length":{"kind":"number","value":127,"string":"127"},"alphanum_fraction":{"kind":"number","value":0.5743929434,"string":"0.574393"}}},{"rowIdx":235,"cells":{"hexsha":{"kind":"string","value":"ffe94ea3d183f6b40fea6fe75c97e00533a9e07f"},"size":{"kind":"number","value":4813,"string":"4,813"},"content":{"kind":"string","value":"//\n// LMSTests.swift\n// NNKit\n//\n// Copyright 2017 DLVM Team.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n//\n\nimport XCTest\n@testable import NNKit\n\nclass LMSTests : XCTestCase {\n\n func testArith() {\n let x = ^10\n XCTAssertEqual((x + 10).!, 20)\n }\n\n func testFuncApp() {\n let giveOne = lambda { ^1 }\n XCTAssertEqual(giveOne[].!, 1)\n let f = giveOne.!\n XCTAssertEqual(f(), 1)\n }\n\n func testTuple() {\n let perceptron = lambda { (w: Rep, x: Rep, b: Rep) in\n w * x + b\n }\n let result = perceptron[^0.8, ^1.0, ^0.4].!\n XCTAssertEqual(result, 1.2)\n }\n\n func testIndirectRecursion() {\n func fac(_ n: Rep) -> Rep {\n return .if(n == 0, then: ^1, else: n * lambda(fac)[n-1])\n }\n let result = fac(^5).!\n XCTAssertEqual(result, 120)\n }\n\n func testResultCaching() {\n let sumTimes10: Rep<(Int, Int) -> (Int) -> Int> =\n lambda { x, y in lambda { z in (x + y + z) * ^10 } }\n XCTAssertFalse(sumTimes10.shouldInvalidateCache)\n let expr = sumTimes10 as! LambdaExpression<(Int, Int), (Int) -> Int>\n XCTAssertTrue(expr.closure.body.shouldInvalidateCache)\n let innerLambda = sumTimes10[^3, ^4]\n XCTAssertFalse(innerLambda.shouldInvalidateCache)\n let prod = innerLambda[^5]\n XCTAssertEqual(prod.!, 120)\n XCTAssertEqual(prod.!, 120)\n let prod2 = sumTimes10[^1, ^2][prod]\n XCTAssertEqual(prod2.!, 1230)\n XCTAssertEqual(prod2.!, 1230)\n XCTAssertEqual(prod.!, 120)\n XCTAssertEqual(prod2.!, 1230)\n }\n\n func testCond() {\n func fib(_ n: Rep) -> Rep {\n let next = lambda { n in fib(n - 1) + fib(n - 2) }\n return cond(n == 0, ^0,\n n == 1, ^1,\n n > 1, next[n],\n else: next[n])\n }\n let f5 = fib(^5)\n XCTAssertEqual(f5.!, 5)\n XCTAssertEqual(f5.!, 5)\n let f12 = lambda(fib)[f5 + 7]\n XCTAssertEqual(f12.!, 144)\n XCTAssertEqual(f12.!, 144)\n }\n\n func testHOF() {\n /// Collections\n let array = ^[1.0, 2.0, 3.0, 4.0]\n let sum = array.reduce(0, +)\n XCTAssertEqual(sum.!, 10)\n let product = array.reduce(1, *)\n XCTAssertEqual(product.!, 24)\n let incrBySum = array.map { $0 + sum }\n XCTAssertEqual(incrBySum.!, [11, 12, 13, 14])\n let odds = array.filter { $0 % 2 != 0 }\n XCTAssertEqual(odds.!, [1, 3])\n let zipped = zip(array, incrBySum)\n XCTAssert((zipped.!).elementsEqual(\n [(1, 11), (2, 12), (3, 13), (4, 14)], by: ==))\n let zippedWith = zip(array, incrBySum, with: -)\n XCTAssert((zippedWith.!).elementsEqual(\n [-10, -10, -10, -10], by: ==))\n /// Currying\n let ten = ^10\n let add: Rep<(Int, Int) -> Int> = lambda(+)\n let curry = lambda { (f: Rep<(Int, Int) -> Int>) in\n lambda { x in\n lambda { y in\n f[x, y]\n }\n }\n }\n let curryAdd = curry[add]\n let addTen = curryAdd[ten]\n let twentyFive = addTen[^15]\n XCTAssertEqual(twentyFive.!, 25)\n /// Y combinator\n let fac: Rep<(Int) -> Int> = fix { f in\n lambda { (n: Rep) in\n .if(n == 0, then: ^1, else: n * f[n - 1])\n }\n }\n let fib: Rep<(Int) -> Int> = fix { f in\n lambda { (n: Rep) in\n .if(n == 0,\n then: ^0,\n else: .if(n == 1,\n then: ^1,\n else: f[n-1] + f[n-2]))\n }\n }\n XCTAssertEqual(fac[^5].!, 120)\n XCTAssertEqual(fib[^5].!, 5)\n }\n\n static var allTests : [(String, (LMSTests) -> () throws -> Void)] {\n return [\n (\"testArith\", testArith),\n (\"testFuncApp\", testFuncApp),\n (\"testTuple\", testTuple),\n (\"testIndirectRecursion\", testIndirectRecursion),\n (\"testResultCaching\", testResultCaching),\n (\"testCond\", testCond),\n (\"testHOF\", testHOF)\n ]\n }\n\n}\n"},"avg_line_length":{"kind":"number","value":32.0866666667,"string":"32.086667"},"max_line_length":{"kind":"number","value":82,"string":"82"},"alphanum_fraction":{"kind":"number","value":0.5036359859,"string":"0.503636"}}},{"rowIdx":236,"cells":{"hexsha":{"kind":"string","value":"5df394b2146b5f98ee899f8f19e2c2d8903b05a2"},"size":{"kind":"number","value":1464,"string":"1,464"},"content":{"kind":"string","value":"//\n// Result.swift\n// Library\n//\n// Created by Cosmin Stirbu on 2/28/17.\n// MIT License\n//\n// Copyright (c) 2017 Fortech\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in all\n// copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\nimport Foundation\n@testable import Library\n\npublic func ==(lhs: Result, rhs: Result) -> Bool {\n\t// Shouldn't be used for PRODUCTION enum comparison. Good enough for unit tests.\n\treturn String(describing: lhs) == String(describing: rhs)\n}\n"},"avg_line_length":{"kind":"number","value":41.8285714286,"string":"41.828571"},"max_line_length":{"kind":"number","value":82,"string":"82"},"alphanum_fraction":{"kind":"number","value":0.7390710383,"string":"0.739071"}}},{"rowIdx":237,"cells":{"hexsha":{"kind":"string","value":"03470643aafcc98a4605da49ac960693a6c65821"},"size":{"kind":"number","value":136,"string":"136"},"content":{"kind":"string","value":"//\n// Define.swift\n// toBook\n//\n// Created by Mac on 16/12/16.\n// Copyright © 2016年 Mac. All rights reserved.\n//\n\nimport Foundation\n"},"avg_line_length":{"kind":"number","value":13.6,"string":"13.6"},"max_line_length":{"kind":"number","value":47,"string":"47"},"alphanum_fraction":{"kind":"number","value":0.6397058824,"string":"0.639706"}}},{"rowIdx":238,"cells":{"hexsha":{"kind":"string","value":"f578125170797a2546372256c113512521edea7a"},"size":{"kind":"number","value":1009,"string":"1,009"},"content":{"kind":"string","value":"//\n// FaceView.swift\n// SampleApp\n//\n// Created by Cesar Vargas on 24.03.20.\n// Copyright © 2020 Cesar Vargas. All rights reserved.\n//\n\nimport Foundation\nimport Warhol\nimport UIKit\n\nfinal class FaceView: UIView, CameraFrontView {\n var viewModel: FaceViewModel?\n\n override func draw(_ rect: CGRect) {\n guard let context = UIGraphicsGetCurrentContext(),\n let viewModel = viewModel else {\n return\n }\n\n context.saveGState()\n\n defer {\n context.restoreGState()\n }\n\n context.addRect(viewModel.boundingBox)\n\n UIColor.red.setStroke()\n context.strokePath()\n UIColor.white.setStroke()\n\n Array(viewModel.landmarks.values).forEach {self.draw(landmark: $0, closePath: true, in: context) }\n }\n\n private func draw(landmark: FaceLandmarkPerimeter, closePath: Bool, in context: CGContext) {\n guard !landmark.isEmpty else {\n return\n }\n\n context.addLines(between: landmark)\n\n if closePath {\n context.closePath()\n }\n\n context.strokePath()\n }\n}\n"},"avg_line_length":{"kind":"number","value":19.7843137255,"string":"19.784314"},"max_line_length":{"kind":"number","value":102,"string":"102"},"alphanum_fraction":{"kind":"number","value":0.674925669,"string":"0.674926"}}},{"rowIdx":239,"cells":{"hexsha":{"kind":"string","value":"0184b381b9c3821b4157bb3ba748878ddc281708"},"size":{"kind":"number","value":1186,"string":"1,186"},"content":{"kind":"string","value":"//\n// ViewController.swift\n// Tipca\n//\n// Created by Laura Salazar on 9/15/18.\n// Copyright © 2018 Laura Salazar. All rights reserved.\n//\n\nimport UIKit\n\nclass ViewController: UIViewController {\n\n @IBOutlet weak var billField: UITextField!\n @IBOutlet weak var tipLabel: UILabel!\n @IBOutlet weak var totalLabel: UILabel!\n \n @IBOutlet weak var tipControl: UISegmentedControl!\n \n override func viewDidLoad() {\n super.viewDidLoad()\n // Do any additional setup after loading the view, typically from a nib.\n \n }\n\n override func didReceiveMemoryWarning() {\n super.didReceiveMemoryWarning()\n // Dispose of any resources that can be recreated.\n }\n\n @IBAction func onTap(sender: AnyObject) {\n view.endEditing(true)\n }\n \n @IBAction func calculateTip(_ sender: Any) {\n \n let tipPercentages = [0.10, 0.15, 0.18, 0.25]\n let bill = Double(billField.text!) ?? 0\n let tip = bill * tipPercentages[tipControl.selectedSegmentIndex]\n let total = bill + tip\n \n tipLabel.text = String(format: \"$%.2f\",tip)\n totalLabel.text = String(format: \"$%.2f\", total)\n }\n}\n\n"},"avg_line_length":{"kind":"number","value":25.7826086957,"string":"25.782609"},"max_line_length":{"kind":"number","value":80,"string":"80"},"alphanum_fraction":{"kind":"number","value":0.6306913997,"string":"0.630691"}}},{"rowIdx":240,"cells":{"hexsha":{"kind":"string","value":"fcdbdf9fd1c5ea0b812c4de8f5237a46b0644d64"},"size":{"kind":"number","value":384,"string":"384"},"content":{"kind":"string","value":"//\n// PXFlowBehaviourDefault.swift\n// MercadoPagoSDK\n//\n// Created by AUGUSTO COLLERONE ALFONSO on 11/02/2020.\n//\n\nimport Foundation\n\n/**\n Default PX implementation of Flow Behaviour for public distribution. (No-trackings)\n */\nfinal class PXFlowBehaviourDefault: NSObject, PXFlowBehaviourProtocol {\n func trackConversion() {}\n\n func trackConversion(result: PXResultKey) {}\n}\n"},"avg_line_length":{"kind":"number","value":21.3333333333,"string":"21.333333"},"max_line_length":{"kind":"number","value":84,"string":"84"},"alphanum_fraction":{"kind":"number","value":0.7473958333,"string":"0.747396"}}},{"rowIdx":241,"cells":{"hexsha":{"kind":"string","value":"b948073620ebbefdc22dc734f2f9d330eba063ff"},"size":{"kind":"number","value":236,"string":"236"},"content":{"kind":"string","value":"//\n// PhotoClientError.swift\n// PhotoClientModels\n//\n// Created by Đinh Văn Nhật on 2021/10/09.\n//\n\nimport Foundation\n\npublic enum PhotoClientError: Error {\n case parsing(descritpion: String)\n case setup(descritpion: String)\n}\n"},"avg_line_length":{"kind":"number","value":16.8571428571,"string":"16.857143"},"max_line_length":{"kind":"number","value":43,"string":"43"},"alphanum_fraction":{"kind":"number","value":0.7161016949,"string":"0.716102"}}},{"rowIdx":242,"cells":{"hexsha":{"kind":"string","value":"792623e43b4bf19db6529316608b1cb5dc04dca8"},"size":{"kind":"number","value":1449,"string":"1,449"},"content":{"kind":"string","value":"//\n// DailyTaskTableViewCell.swift\n// Maily\n//\n// Created by Danb on 2017. 4. 3..\n// Copyright © 2017년 Febrix. All rights reserved.\n//\n\nimport UIKit\n\nclass DailyTaskTableViewCell: UITableViewCell {\n \n @IBOutlet weak var dailyCell: UIView!\n \n\n @IBOutlet weak var dailyTaskLabel: UILabel!\n @IBOutlet weak var dailyTaskIcon: UIImageView!\n @IBOutlet weak var dailyTaskColorBar: UIView!\n @IBOutlet weak var dailyTaskGoal: UILabel!\n @IBOutlet weak var dailyTaskDate: UILabel!\n @IBOutlet weak var dailyTaskGoalPriority: UILabel!\n \n required init?(coder aDecoder: NSCoder) {\n super.init(coder: aDecoder)\n \n self.layer.shadowColor = UIColor.black.cgColor\n self.layer.shadowOpacity = 0.2\n self.layer.shadowOffset = CGSize(width: 0, height: 3)\n self.layer.shadowRadius = 5\n\n }\n override func awakeFromNib() {\n super.awakeFromNib()\n // Initialization code\n }\n\n override func setSelected(_ selected: Bool, animated: Bool) {\n super.setSelected(selected, animated: animated)\n\n // Configure the view for the selected state\n }\n \n override func layoutSubviews() {\n dailyCell.clipsToBounds = true\n// dailyCell.layer.shadowColor = UIColor.blue.cgColor\n// dailyCell.layer.shadowOffset = CGSize(width: 3, height: 3)\n// dailyCell.layer.shadowOpacity = 0.3\n dailyCell.layer.cornerRadius = 3\n }\n \n \n\n}\n"},"avg_line_length":{"kind":"number","value":26.8333333333,"string":"26.833333"},"max_line_length":{"kind":"number","value":68,"string":"68"},"alphanum_fraction":{"kind":"number","value":0.6597653554,"string":"0.659765"}}},{"rowIdx":243,"cells":{"hexsha":{"kind":"string","value":"2f3cb854f4459eec61dfb0db8fafbdaa4523d85e"},"size":{"kind":"number","value":2907,"string":"2,907"},"content":{"kind":"string","value":"// JWTHelper.swift\n//\n// Copyright (c) 2015 Auth0 (http://auth0.com)\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n\nimport Foundation\nimport JWTDecode\n\nfunc jwt(withBody body: [String: Any]) -> JWT {\n var jwt: String = \"\"\n do {\n let data = try JSONSerialization.data(withJSONObject: body, options: JSONSerialization.WritingOptions())\n let base64 = data.base64EncodedString(options: NSData.Base64EncodingOptions())\n .replacingOccurrences(of: \"+\", with: \"-\")\n .replacingOccurrences(of: \"/\", with: \"_\")\n .replacingOccurrences(of: \"=\", with: \"\")\n jwt = \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.\\(base64).SIGNATURE\"\n } catch _ {\n NSException(name: NSExceptionName.invalidArgumentException, reason: \"Failed to build jwt\", userInfo: nil).raise()\n }\n return try! decode(jwt: jwt)\n}\n\nfunc jwtThatExpiresAt(date: Date) -> JWT {\n return jwt(withBody: [\"exp\": date.timeIntervalSince1970 as AnyObject])\n}\n\nfunc expiredJWT() -> JWT {\n let seconds = Int(arc4random_uniform(60) + 1) * -1\n let date = (Calendar.current as NSCalendar).date(byAdding: .second, value: seconds, to: Date(), options: NSCalendar.Options())\n return jwtThatExpiresAt(date: date!)\n}\n\nfunc nonExpiredJWT() -> JWT {\n let hours = Int(arc4random_uniform(200) + 1)\n let date = (Calendar.current as NSCalendar).date(byAdding: .hour, value: hours, to: Date(), options: NSCalendar.Options())\n return jwtThatExpiresAt(date: date!)\n}\n\nclass JWTHelper: NSObject {\n\n class func newJWT(withBody body: [String: AnyObject]) -> JWT {\n return jwt(withBody: body)\n }\n\n class func newJWTThatExpiresAt(date: Date) -> JWT {\n return jwtThatExpiresAt(date: date)\n }\n\n class func newExpiredJWT() -> JWT {\n return expiredJWT()\n }\n\n class func newNonExpiredJWT() -> JWT {\n return nonExpiredJWT()\n }\n}\n"},"avg_line_length":{"kind":"number","value":38.76,"string":"38.76"},"max_line_length":{"kind":"number","value":130,"string":"130"},"alphanum_fraction":{"kind":"number","value":0.6993464052,"string":"0.699346"}}},{"rowIdx":244,"cells":{"hexsha":{"kind":"string","value":"2283e89040d8c038ed9362a343a24baf4db99077"},"size":{"kind":"number","value":1106,"string":"1,106"},"content":{"kind":"string","value":"/*\n This source file is part of the Swift.org open source project\n\n Copyright (c) 2021 Apple Inc. and the Swift project authors\n Licensed under Apache License v2.0 with Runtime Library Exception\n\n See https://swift.org/LICENSE.txt for license information\n See https://swift.org/CONTRIBUTORS.txt for Swift project authors\n*/\n\nimport Foundation\n\n/// A function source node.\nclass MethodNode: TypeMemberNode {\n var implementation: String?\n \n override class func keyword() -> String { return \"func\" }\n \n override func source() -> String {\n var result = \"\"\n result += Text.docs(for: name, bundle: bundle, sections: [.abstract, .discussion])\n\n let kindString = (kind == .instance || kind == .interface) ? \"\" : kind.rawValue\n let levelString = level == .default ? \"\" : level.rawValue\n \n result += \"\\(levelString) \\(kindString) func \\(name.lowercased())() { /* code */ }\\n\\n\"\n \n if kind == .interface {\n implementation = result\n result = \"func \\(name.lowercased())()\\n\\n\"\n }\n \n return result\n }\n}\n"},"avg_line_length":{"kind":"number","value":30.7222222222,"string":"30.722222"},"max_line_length":{"kind":"number","value":95,"string":"95"},"alphanum_fraction":{"kind":"number","value":0.6193490054,"string":"0.619349"}}},{"rowIdx":245,"cells":{"hexsha":{"kind":"string","value":"487de43ab5511d767d26e21263697d73c632f558"},"size":{"kind":"number","value":16859,"string":"16,859"},"content":{"kind":"string","value":"/*\n This source file is part of the Swift.org open source project\n\n Copyright (c) 2021 Apple Inc. and the Swift project authors\n Licensed under Apache License v2.0 with Runtime Library Exception\n\n See https://swift.org/LICENSE.txt for license information\n See https://swift.org/CONTRIBUTORS.txt for Swift project authors\n*/\n\nimport Foundation\n\nimport XCTest\n@testable import SwiftDocC\nimport Markdown\n\nclass RedirectedTests: XCTestCase {\n func testEmpty() throws {\n let source = \"@Redirected\"\n let document = Document(parsing: source, options: .parseBlockDirectives)\n let directive = document.child(at: 0)! as! BlockDirective\n let (bundle, context) = try testBundleAndContext(named: \"TestBundle\")\n var problems = [Problem]()\n let redirected = Redirect(from: directive, source: nil, for: bundle, in: context, problems: &problems)\n XCTAssertNil(redirected)\n XCTAssertEqual(1, problems.count)\n XCTAssertFalse(problems.containsErrors)\n XCTAssertEqual(\"org.swift.docc.HasArgument.from\", problems.first?.diagnostic.identifier)\n }\n \n func testValid() throws {\n let oldPath = \"/old/path/to/this/page\"\n let source = \"@Redirected(from: \\(oldPath))\"\n let document = Document(parsing: source, options: .parseBlockDirectives)\n let directive = document.child(at: 0)! as! BlockDirective\n let (bundle, context) = try testBundleAndContext(named: \"TestBundle\")\n var problems = [Problem]()\n let redirected = Redirect(from: directive, source: nil, for: bundle, in: context, problems: &problems)\n XCTAssertNotNil(redirected)\n XCTAssertTrue(problems.isEmpty)\n XCTAssertEqual(redirected?.oldPath.path, oldPath)\n }\n \n func testInvalidURL() throws {\n let someCharactersThatAreNotAllowedInPaths = \"⊂⧺∀ℝ∀⊂⊤∃∫\"\n for character in someCharactersThatAreNotAllowedInPaths {\n XCTAssertFalse(CharacterSet.urlPathAllowed.contains(character.unicodeScalars.first!), \"Verify that \\(character) is invalid\")\n \n let pathWithInvalidCharacter = \"/path/with/invalid\\(character)for/paths\"\n let source = \"@Redirected(from: \\(pathWithInvalidCharacter))\"\n let document = Document(parsing: source, options: .parseBlockDirectives)\n let directive = document.child(at: 0)! as! BlockDirective\n let (bundle, context) = try testBundleAndContext(named: \"TestBundle\")\n var problems = [Problem]()\n let redirected = Redirect(from: directive, source: nil, for: bundle, in: context, problems: &problems)\n XCTAssertNil(redirected?.oldPath.absoluteString, \"\\(character)\")\n XCTAssertFalse(problems.containsErrors)\n XCTAssertEqual(1, problems.count)\n XCTAssertEqual(problems.first?.diagnostic.identifier, \"org.swift.docc.HasArgument.from.ConversionFailed\")\n XCTAssertEqual(\n problems.first?.diagnostic.localizedSummary,\n \"Can't convert '\\(pathWithInvalidCharacter)' to type URL\"\n )\n }\n }\n \n func testExtraArguments() throws {\n let oldPath = \"/old/path/to/this/page\"\n let source = \"@Redirected(from: \\(oldPath), argument: value)\"\n let document = Document(parsing: source, options: .parseBlockDirectives)\n let directive = document.child(at: 0)! as! BlockDirective\n let (bundle, context) = try testBundleAndContext(named: \"TestBundle\")\n var problems = [Problem]()\n let redirected = Redirect(from: directive, source: nil, for: bundle, in: context, problems: &problems)\n XCTAssertNotNil(redirected, \"Even if there are warnings we can create a Redirected value\")\n XCTAssertFalse(problems.containsErrors)\n XCTAssertEqual(1, problems.count)\n XCTAssertEqual(\"org.swift.docc.UnknownArgument\", problems.first?.diagnostic.identifier)\n }\n \n func testExtraDirective() throws {\n let oldPath = \"/old/path/to/this/page\"\n let source = \"\"\"\n @Redirected(from: \\(oldPath)) {\n @Image\n }\n \"\"\"\n let document = Document(parsing: source, options: .parseBlockDirectives)\n let directive = document.child(at: 0)! as! BlockDirective\n let (bundle, context) = try testBundleAndContext(named: \"TestBundle\")\n var problems = [Problem]()\n let redirected = Redirect(from: directive, source: nil, for: bundle, in: context, problems: &problems)\n XCTAssertNotNil(redirected, \"Even if there are warnings we can create a Redirected value\")\n XCTAssertEqual(2, problems.count)\n XCTAssertFalse(problems.containsErrors)\n XCTAssertEqual(\"org.swift.docc.HasOnlyKnownDirectives\", problems.first?.diagnostic.identifier)\n XCTAssertEqual(\"org.swift.docc.Redirect.UnexpectedContent\", problems.last?.diagnostic.identifier)\n }\n \n func testExtraContent() throws {\n let oldPath = \"/old/path/to/this/page\"\n let source = \"\"\"\n @Redirected(from: \\(oldPath)) {\n Some text\n }\n \"\"\"\n let document = Document(parsing: source, options: .parseBlockDirectives)\n let directive = document.child(at: 0)! as! BlockDirective\n let (bundle, context) = try testBundleAndContext(named: \"TestBundle\")\n var problems = [Problem]()\n let redirected = Redirect(from: directive, source: nil, for: bundle, in: context, problems: &problems)\n XCTAssertNotNil(redirected, \"Even if there are warnings we can create a Redirected value\")\n XCTAssertFalse(problems.containsErrors)\n XCTAssertEqual(1, problems.count)\n XCTAssertEqual(\"org.swift.docc.Redirect.UnexpectedContent\", problems.first?.diagnostic.identifier)\n }\n \n // MARK: - Redirect support\n \n func testTechnologySupportsRedirect() throws {\n let source = \"\"\"\n @Tutorials(name: \"Technology X\") {\n @Intro(title: \"Technology X\") {\n You'll learn all about Technology X.\n }\n \n @Redirected(from: /old/path/to/this/page)\n @Redirected(from: /another/old/path/to/this/page)\n }\n \"\"\"\n let document = Document(parsing: source, options: .parseBlockDirectives)\n let directive = document.child(at: 0)! as! BlockDirective\n let (bundle, context) = try testBundleAndContext(named: \"TestBundle\")\n var problems = [Problem]()\n let technology = Technology(from: directive, source: nil, for: bundle, in: context, problems: &problems)\n XCTAssertNotNil(technology, \"A Technology value can be created with a Redirected child.\")\n XCTAssert(problems.isEmpty, \"There shouldn't be any problems. Got:\\n\\(problems.map { $0.diagnostic.localizedSummary })\")\n \n var analyzer = SemanticAnalyzer(source: nil, context: context, bundle: bundle)\n _ = analyzer.visit(document)\n XCTAssert(analyzer.problems.isEmpty, \"Expected no problems. Got \\(analyzer.problems.localizedDescription)\")\n }\n \n func testVolumeAndChapterSupportsRedirect() throws {\n let source = \"\"\"\n @Volume(name: \"Name of this volume\") {\n @Image(source: image.png, alt: image)\n \n @Redirected(from: /old/path/to/this/page)\n @Redirected(from: /another/old/path/to/this/page)\n \n @Chapter(name: \"Chapter 1\") {\n In this chapter, you'll follow Tutorial 1. Feel free to add more `Reference`s below.\n \n @Redirected(from: /old/path/to/this/page)\n @Redirected(from: /another/old/path/to/this/page)\n\n @Image(source: image.png, alt: image)\n @TutorialReference(tutorial: \"doc://com.test.bundle/Tutorial\")\n }\n }\n \"\"\"\n let document = Document(parsing: source, options: .parseBlockDirectives)\n let directive = document.child(at: 0)! as! BlockDirective\n let (bundle, context) = try testBundleAndContext(named: \"TestBundle\")\n var problems = [Problem]()\n let volume = Volume(from: directive, source: nil, for: bundle, in: context, problems: &problems)\n XCTAssertNotNil(volume, \"A Volume value can be created with a Redirected child.\")\n XCTAssert(problems.isEmpty, \"There shouldn't be any problems. Got:\\n\\(problems.map { $0.diagnostic.localizedSummary })\")\n }\n \n func testTutorialAndSectionsSupportsRedirect() throws {\n let source = \"\"\"\n @Tutorial(time: 20, projectFiles: project.zip) {\n @Intro(title: \"Basic Augmented Reality App\") {\n @Video(source: video.mov)\n }\n \n @Redirected(from: /old/path/to/this/page)\n @Redirected(from: /another/old/path/to/this/page)\n \n @Section(title: \"Create a New AR Project\") {\n @ContentAndMedia {\n Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt\n ut labore et dolore magna aliqua. Phasellus faucibus scelerisque eleifend donec pretium.\n\n Ultrices dui sapien eget mi proin sed libero enim. Quis auctor elit sed vulputate mi sit amet.\n\n @Image(source: arkit.png, alt: \"Description of this image\")\n }\n\n @Redirected(from: /old/path/to/this/page)\n @Redirected(from: /another/old/path/to/this/page)\n \n @Steps {\n Let's get started building the Augmented Reality app.\n \n @Step {\n Lorem ipsum dolor sit amet, consectetur.\n \n @Image(source: Sierra.jpg, alt: \"Description of this image\")\n }\n }\n }\n @Assessments {\n @MultipleChoice {\n Lorem ipsum dolor sit amet?\n \n @Choice(isCorrect: true) {\n `anchor.hitTest(view)`\n \n @Justification {\n This is correct because it is.\n }\n }\n\n @Choice(isCorrect: false) {\n `anchor.hitTest(view)`\n \n @Justification {\n This is false because it is.\n }\n }\n }\n }\n }\n \"\"\"\n let document = Document(parsing: source, options: .parseBlockDirectives)\n let directive = document.child(at: 0)! as! BlockDirective\n let (bundle, context) = try testBundleAndContext(named: \"TestBundle\")\n var problems = [Problem]()\n let tutorial = Tutorial(from: directive, source: nil, for: bundle, in: context, problems: &problems)\n XCTAssertNotNil(tutorial, \"A Tutorial value can be created with a Redirected child.\")\n XCTAssert(problems.isEmpty, \"There shouldn't be any problems. Got:\\n\\(problems.map { $0.diagnostic.localizedSummary })\")\n \n var analyzer = SemanticAnalyzer(source: nil, context: context, bundle: bundle)\n _ = analyzer.visit(document)\n XCTAssert(analyzer.problems.isEmpty, \"Expected no problems. Got \\(analyzer.problems.localizedDescription)\")\n }\n \n func testTutorialArticleSupportsRedirect() throws {\n let source = \"\"\"\n @Article(time: 20) {\n @Intro(title: \"Making an Augmented Reality App\") {\n This is an abstract for the intro.\n }\n\n @Redirected(from: /old/path/to/this/page)\n @Redirected(from: /another/old/path/to/this/page)\n \n ## Section Name\n \n \n }\n \"\"\"\n let document = Document(parsing: source, options: .parseBlockDirectives)\n let directive = document.child(at: 0)! as! BlockDirective\n let (bundle, context) = try testBundleAndContext(named: \"TestBundle\")\n var problems = [Problem]()\n let article = TutorialArticle(from: directive, source: nil, for: bundle, in: context, problems: &problems)\n XCTAssertNotNil(article, \"A TutorialArticle value can be created with a Redirected child.\")\n XCTAssert(problems.isEmpty, \"There shouldn't be any problems. Got:\\n\\(problems.map { $0.diagnostic.localizedSummary })\")\n \n var analyzer = SemanticAnalyzer(source: nil, context: context, bundle: bundle)\n _ = analyzer.visit(document)\n XCTAssert(analyzer.problems.isEmpty, \"Expected no problems. Got \\(analyzer.problems.localizedDescription)\")\n }\n \n func testResourcesSupportsRedirect() throws {\n let source = \"\"\"\n @Resources(technology: doc:/TestOverview) {\n Find the tools and a comprehensive set of resources for creating AR experiences on iOS.\n\n @Redirected(from: /old/path/to/this/page)\n @Redirected(from: /another/old/path/to/this/page)\n\n @Documentation(destination: \"https://www.example.com/documentation/technology\") {\n Browse and search detailed API documentation.\n\n - \n - \n }\n\n @SampleCode(destination: \"https://www.example.com/documentation/technology\") {\n Browse and search detailed sample code.\n\n - \n - \n }\n\n @Downloads(destination: \"https://www.example.com/download\") {\n Download Xcode 10, which includes the latest tools and SDKs.\n }\n\n @Videos(destination: \"https://www.example.com/videos\") {\n See AR presentation from WWDC and other events.\n }\n\n @Forums(destination: \"https://www.example.com/forums\") {\n Discuss AR with Apple engineers and other developers.\n }\n }\n\n \"\"\"\n let document = Document(parsing: source, options: .parseBlockDirectives)\n let directive = document.child(at: 0)! as! BlockDirective\n let (bundle, context) = try testBundleAndContext(named: \"TestBundle\")\n var problems = [Problem]()\n let article = Resources(from: directive, source: nil, for: bundle, in: context, problems: &problems)\n XCTAssertNotNil(article, \"A Resources value can be created with a Redirected child.\")\n XCTAssert(problems.isEmpty, \"There shouldn't be any problems. Got:\\n\\(problems.map { $0.diagnostic.localizedSummary })\")\n }\n \n func testArticleSupportsRedirect() throws {\n let source = \"\"\"\n # Plain article\n \n The abstract of this article\n \n @Redirected(from: /old/path/to/this/page)\n @Redirected(from: /another/old/path/to/this/page)\n \n ## Section Name\n \n \n \"\"\"\n let document = Document(parsing: source, options: .parseBlockDirectives)\n let (bundle, context) = try testBundleAndContext(named: \"TestBundle\")\n var problems = [Problem]()\n let article = Article(from: document, source: nil, for: bundle, in: context, problems: &problems)\n XCTAssertNotNil(article, \"An Article value can be created with a Redirected child.\")\n XCTAssert(problems.isEmpty, \"There shouldn't be any problems. Got:\\n\\(problems.map { $0.diagnostic.localizedSummary })\")\n \n var analyzer = SemanticAnalyzer(source: nil, context: context, bundle: bundle)\n _ = analyzer.visit(document)\n XCTAssert(analyzer.problems.isEmpty, \"Expected no problems. Got \\(analyzer.problems.localizedDescription)\")\n }\n \n func testIncorrectArgumentLabel() throws {\n let source = \"@Redirected(fromURL: /old/path)\"\n let document = Document(parsing: source, options: .parseBlockDirectives)\n let directive = document.child(at: 0)! as! BlockDirective\n let (bundle, context) = try testBundleAndContext(named: \"TestBundle\")\n var problems = [Problem]()\n let redirected = Redirect(from: directive, source: nil, for: bundle, in: context, problems: &problems)\n XCTAssertNil(redirected)\n XCTAssertEqual(2, problems.count)\n XCTAssertFalse(problems.containsErrors)\n \n let expectedIds = [\n \"org.swift.docc.UnknownArgument\",\n \"org.swift.docc.HasArgument.from\",\n ]\n \n let problemIds = problems.map(\\.diagnostic.identifier)\n \n for id in expectedIds {\n XCTAssertTrue(problemIds.contains(id))\n }\n }\n}\n"},"avg_line_length":{"kind":"number","value":46.5718232044,"string":"46.571823"},"max_line_length":{"kind":"number","value":138,"string":"138"},"alphanum_fraction":{"kind":"number","value":0.620202859,"string":"0.620203"}}},{"rowIdx":246,"cells":{"hexsha":{"kind":"string","value":"14550f47b1e04fecd594a7b731960d4fc96f1790"},"size":{"kind":"number","value":1337,"string":"1,337"},"content":{"kind":"string","value":"//\n// YWChooseStrategyViewController.swift\n// YWLiwuShuo\n//\n// Created by Mac on 2017/5/18.\n// Copyright © 2017年 Mac. All rights reserved.\n//\n\nimport UIKit\n\nclass YWChooseStrategyViewController: YWBaseStrategyViewController {\n\n override func viewDidLoad() {\n super.viewDidLoad()\n\n setupUI()\n }\n \n override func viewWillLayoutSubviews() {\n super.viewWillLayoutSubviews()\n setupUIFrame()\n }\n \n func setupUI() {\n headerView.addSubview(topic)\n headerView.addSubview(banner)\n tableView.tableHeaderView = headerView\n }\n \n func setupUIFrame() {\n banner.frame = CGRectMake(0, 0, self.tableView.bounds.width, 170)\n topic.frame = CGRectMake(0, banner.bounds.size.height, banner.bounds.size.width, 120)\n headerView.frame = CGRectMake(0, 0, self.tableView.bounds.width, banner.bounds.height + topic.bounds.height + 10)\n //重新设置高度并赋值\n tableView.tableHeaderView = headerView\n }\n\n \n //MARK: -懒加载\n private lazy var headerView: UIView = UIView()\n \n private lazy var banner: BannerCollectionView = BannerCollectionView(frame: CGRectZero, collectionViewLayout: BannerFlowLayout())\n \n private lazy var topic: TopicCollectionView = TopicCollectionView(frame: CGRectZero, collectionViewLayout: TopicFlowLayout())\n\n\n\n}\n"},"avg_line_length":{"kind":"number","value":27.2857142857,"string":"27.285714"},"max_line_length":{"kind":"number","value":133,"string":"133"},"alphanum_fraction":{"kind":"number","value":0.6836200449,"string":"0.68362"}}},{"rowIdx":247,"cells":{"hexsha":{"kind":"string","value":"61be95a6eac03359bbe5a88bce7e0a9d465cae84"},"size":{"kind":"number","value":1155,"string":"1,155"},"content":{"kind":"string","value":"//\n// BotViewController.swift\n// LucasBot\n//\n// Created by Mirko Justiniano on 1/16/17.\n// Copyright © 2017 LB. All rights reserved.\n//\n\nimport Foundation\nimport UIKit\n\nclass MemoriaVC: UIViewController {\n \n var nav:NavController?\n \n init() {\n super.init(nibName: nil, bundle: nil)\n }\n \n required init?(coder aDecoder: NSCoder) {\n fatalError(\"init(coder:) has not been implemented\")\n }\n \n override func viewDidLoad() {\n super.viewDidLoad()\n // Do any additional setup after loading the view, typically from a nib.\n if (self.navigationController != nil && (self.navigationController?.isKind(of: NavController.classForCoder()))!) {\n self.nav = self.navigationController as? NavController\n }\n }\n \n override func didReceiveMemoryWarning() {\n super.didReceiveMemoryWarning()\n // Dispose of any resources that can be recreated.\n }\n \n override var supportedInterfaceOrientations: UIInterfaceOrientationMask {\n return .portrait\n }\n \n override var preferredStatusBarStyle: UIStatusBarStyle {\n return .lightContent\n }\n}\n"},"avg_line_length":{"kind":"number","value":25.6666666667,"string":"25.666667"},"max_line_length":{"kind":"number","value":122,"string":"122"},"alphanum_fraction":{"kind":"number","value":0.6510822511,"string":"0.651082"}}},{"rowIdx":248,"cells":{"hexsha":{"kind":"string","value":"4b7e513664ee943e03a694164e9a5207a5d0c5a5"},"size":{"kind":"number","value":4057,"string":"4,057"},"content":{"kind":"string","value":"/**\n https://www.hackerrank.com/challenges/ctci-is-binary-search-tree\n \n \n For the purposes of this challenge, we define a binary search tree to be a binary tree with the following ordering properties:\n \n The data value of every node in a node's left subtree is less than the data value of that node.\n The data value of every node in a node's right subtree is greater than the data value of that node.\n Given the root node of a binary tree, can you determine if it's also a binary search tree?\n \n Note: A binary tree is not a binary search if there are duplicate values.\n \n */\n\nimport Foundation\n\nclass BinarySearchTree: CustomStringConvertible {\n var nodeValue: Int\n var leftTree: BinarySearchTree?\n var rightTree: BinarySearchTree?\n \n public var description: String {\n let leftTree = self.leftTree == nil ? \"nil\" : \"\\(self.leftTree!)\"\n let rightTree = self.rightTree == nil ? \"nil\" : \"\\(self.rightTree!)\"\n return \"\\(self.nodeValue): [\\(leftTree), \\(rightTree)]\"\n }\n \n // initializers\n init(_ nodeValue:Int) {\n self.nodeValue = nodeValue\n }\n \n init(_ nodeValue:Int, leftTree:BinarySearchTree?, rightTree:BinarySearchTree) {\n self.nodeValue = nodeValue\n self.leftTree = leftTree\n self.rightTree = rightTree\n }\n \n public func getLeftChildNodeValue() -> Int? {\n return self.leftTree?.nodeValue\n }\n \n public func getRightChildNodeValue() -> Int? {\n return self.rightTree?.nodeValue\n }\n \n // Is it a BST?\n public func isBst() -> Bool {\n // Check that current node is leftNodeValue < currentNodeValue < rightNodeValue\n \n //print(\"checking: \\(self.nodeValue)\")\n \n // Left Node first\n if let leftNodeValue = getLeftChildNodeValue() {\n if leftNodeValue >= self.nodeValue {\n // problem, so we can already return false\n return false\n }\n }\n \n // Right node next\n if let rightNodeValue = getRightChildNodeValue() {\n if rightNodeValue <= self.nodeValue {\n // problem, so we can already return false\n return false\n }\n }\n \n // else, either the nodes followed the right order OR were nil (which we accept)\n \n // Recurse into left first, then right, but only if not nil\n \n let leftTreeIsBst:Bool\n if self.leftTree == nil {\n // is empty, so we call that \"true\"\n leftTreeIsBst = true\n } else {\n // not empty, so we recurse\n leftTreeIsBst = leftTree!.isBst()\n }\n let rightTreeIsBst:Bool\n if self.rightTree == nil {\n // is empty, so we call that \"true\"\n rightTreeIsBst = true\n } else {\n // not empty, so we recurse\n rightTreeIsBst = rightTree!.isBst()\n }\n \n return leftTreeIsBst && rightTreeIsBst\n }\n \n}\n\n/**\n \n Represent the following tree, which is a BST:\n 5\n 3 7\n 2 4 6 8\n \n */\n\nlet e1_node2 = BinarySearchTree(2)\nlet e1_node4 = BinarySearchTree(4)\nlet e1_node3 = BinarySearchTree(3,leftTree:e1_node2,rightTree:e1_node4)\nlet e1_node6 = BinarySearchTree(6)\nlet e1_node8 = BinarySearchTree(8)\nlet e1_node7 = BinarySearchTree(7,leftTree:e1_node6,rightTree:e1_node8)\nlet e1_node5_root = BinarySearchTree(5,leftTree:e1_node3,rightTree:e1_node7)\nprint(\"e1: \\(e1_node5_root)\")\nprint(\"e1 isBst: \\(e1_node5_root.isBst())\")\nprint()\n\n/**\n \n Represent the following tree, which is NOT a BST:\n 5\n 4 7\n 2 4 6 8\n \n */\n\nlet e2_node2 = BinarySearchTree(2)\nlet e2_node4 = BinarySearchTree(4)\nlet e2_node4b = BinarySearchTree(4,leftTree:e2_node2,rightTree:e2_node4)\nlet e2_node6 = BinarySearchTree(6)\nlet e2_node8 = BinarySearchTree(8)\nlet e2_node7 = BinarySearchTree(7,leftTree:e2_node6,rightTree:e2_node8)\nlet e2_node5_root = BinarySearchTree(5,leftTree:e2_node4b,rightTree:e2_node7)\nprint(\"e2: \\(e2_node5_root)\")\nprint(\"e2 isBst: \\(e2_node5_root.isBst())\")\n\n\n"},"avg_line_length":{"kind":"number","value":30.0518518519,"string":"30.051852"},"max_line_length":{"kind":"number","value":127,"string":"127"},"alphanum_fraction":{"kind":"number","value":0.6349519349,"string":"0.634952"}}},{"rowIdx":249,"cells":{"hexsha":{"kind":"string","value":"d9b30d40a306873a51faf30874c1ab01d96fdda6"},"size":{"kind":"number","value":4123,"string":"4,123"},"content":{"kind":"string","value":"import Foundation\nimport CryptoSwift\n\npublic extension URLRequest {\n private static let kHMACShaTypeString = \"AWS4-HMAC-SHA256\"\n private static let kAWS4Request = \"aws4_request\"\n private static let kAllowedCharacters = CharacterSet(charactersIn: \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.~\")\n\n private static let iso8601Formatter: DateFormatter = {\n let formatter = DateFormatter()\n formatter.calendar = Calendar(identifier: .iso8601)\n formatter.locale = Locale(identifier: \"en_US_POSIX\")\n formatter.timeZone = TimeZone(secondsFromGMT: 0)\n formatter.dateFormat = \"yyyyMMdd'T'HHmmssXXXXX\"\n return formatter\n }()\n\t\n private var currentIso8601Date: (full: String, short: String) {\n let date = URLRequest.iso8601Formatter.string(from: Date())\n let shortDate = date[...String.Index(encodedOffset: 7)]\n return (full: date, short: String(shortDate))\n }\n\n public mutating func sign(accessKeyId: String, secretAccessKey: String) throws {\n guard let url = url, let host = url.host, let method = httpMethod else { throw SignError.generalError(reason: \"URLRequest doesn't have a proper URL\") }\n let hostComponents = host.components(separatedBy: \".\")\n guard hostComponents.count > 3 else { throw SignError.generalError(reason: \"Incorrect host format. The host should contain service name and region, e.g sns.us-east-1.amazonaws.com\") }\n\n let serviceName = hostComponents[0]\n let awsRegion = host.starts(with: \"iam\") ? \"us-east-1\" : hostComponents[1]\n\n var body = \"\"\n if let bodyData = httpBody, let bodyString = String(data: bodyData, encoding: .utf8) {\n body = bodyString\n }\n\n let date = currentIso8601Date\n\n addValue(host, forHTTPHeaderField: \"Host\")\n addValue(date.full, forHTTPHeaderField: \"X-Amz-Date\")\n\n let headers = allHTTPHeaderFields ?? [:]\n\n let signedHeaders = headers.map{ $0.key.lowercased() }.sorted().joined(separator: \";\")\n\n var urlComponents = URLComponents(string: url.absoluteString)\n urlComponents?.queryItems = URLComponents(string: url.absoluteString)?.queryItems?.sorted { $0.name < $1.name }.map {\n let percentEncodedName = $0.name.addingPercentEncoding(withAllowedCharacters: URLRequest.kAllowedCharacters) ?? $0.name\n let percentEncodedValue = $0.value?.addingPercentEncoding(withAllowedCharacters: URLRequest.kAllowedCharacters) ?? $0.value\n return URLQueryItem(name: percentEncodedName, value: percentEncodedValue)\n }\n let queryString = urlComponents?.query ?? \"\"\n\n let canonicalRequestHash = [method, url.path == \"\" ? \"/\" : url.path, queryString,\n headers.map{ $0.key.lowercased() + \":\" + $0.value }.sorted().joined(separator: \"\\n\"),\n \"\", signedHeaders, body.sha256()].joined(separator: \"\\n\").sha256()\n let credentials = [date.short, awsRegion, serviceName, URLRequest.kAWS4Request].joined(separator: \"/\")\n let stringToSign = [URLRequest.kHMACShaTypeString, date.full, credentials, canonicalRequestHash].joined(separator: \"\\n\")\n\n let signature = try [date.short, awsRegion, serviceName, URLRequest.kAWS4Request, stringToSign].reduce([UInt8](\"AWS4\\(secretAccessKey)\".utf8), {\n try HMAC(key: $0, variant: .sha256).authenticate([UInt8]($1.utf8))\n }).toHexString()\n\n let authorization = URLRequest.kHMACShaTypeString + \" Credential=\" + accessKeyId + \"/\" + credentials + \", SignedHeaders=\" + signedHeaders + \", Signature=\" + signature\n addValue(authorization, forHTTPHeaderField: \"Authorization\")\n }\n}\n\npublic enum SignError: Error {\n case generalError(reason: String?)\n}\n\nextension SignError: LocalizedError {\n public var errorDescription: String? {\n switch self {\n case .generalError(let reason):\n return \"Signing failed! \" + (reason ?? \"No failure reason available\")\n }\n }\n public var localizedDescription: String {\n return errorDescription!\n }\n}\n"},"avg_line_length":{"kind":"number","value":49.0833333333,"string":"49.083333"},"max_line_length":{"kind":"number","value":191,"string":"191"},"alphanum_fraction":{"kind":"number","value":0.6728110599,"string":"0.672811"}}},{"rowIdx":250,"cells":{"hexsha":{"kind":"string","value":"0a202450910f02856a248761d61157cd0a3f4578"},"size":{"kind":"number","value":3499,"string":"3,499"},"content":{"kind":"string","value":"//\n// ContactsSceneController.swift\n// SFSDKStarter\n//\n// Created by Kevin Poorman on 10/16/19.\n// Copyright © 2019 Salesforce. All rights reserved.\n//\n\nimport Foundation\nimport UIKit\nimport SalesforceSDKCore\n\nclass ContactsSceneController: UITableViewController {\n \n // MARK: - Properties\n \n var accountId: String?\n var name: String?\n \n var contactRows = [Dictionary]()\n \n // MARK: - View lifecycle\n override func loadView() {\n super.loadView()\n updateViews()\n fetchContactsFromAPI()\n }\n \n //MARK: - Helper Methods\n \n private func updateViews() {\n if let name = name {\n self.title = name + \"'s Contacts\"\n } else {\n self.title = \"Contacts\"\n }\n \n }\n \n private func fetchContactsFromAPI() {\n \n guard let accountId = accountId else {\n Service.showAlert(on: self, style: .alert, title: Service.errorTitle, message: Service.errorMsg)\n return\n }\n \n let request = RestClient.shared.request(forQuery: \"SELECT Id, Name FROM Contact WHERE accountid = '\\(accountId)'\")\n RestClient.shared.send(request: request, onFailure: { (error, urlResponse) in\n SalesforceLogger.d(type(of:self), message:\"Error invoking: \\(request)\")\n Service.showAlert(on: self, style: .alert, title: Service.errorTitle, message: error?.localizedDescription)\n }) { [weak self] (response, urlResponse) in\n guard let strongSelf = self,\n let jsonResponse = response as? Dictionary,\n let result = jsonResponse [\"records\"] as? [Dictionary] else {\n return\n }\n SalesforceLogger.d(type(of:strongSelf),message:\"Invoked: \\(request)\")\n DispatchQueue.main.async {\n strongSelf.contactRows = result\n strongSelf.tableView.reloadData()\n }\n }\n }\n}\n\nextension ContactsSceneController {\n func numberOfSectionsInTableView(tableView: UITableView) -> Int {\n return 1\n }\n \n override func tableView(_ tableView: UITableView?, numberOfRowsInSection section: Int) -> Int {\n return self.contactRows.count\n }\n \n override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {\n \n let cellIdentifier = \"ContactCell\"\n let cell: UITableViewCell = tableView.dequeueReusableCell(withIdentifier:cellIdentifier) ?? UITableViewCell(style: .subtitle, reuseIdentifier: cellIdentifier)\n \n let contact = contactRows[indexPath.row]\n cell.textLabel?.text = contact[\"Name\"] as? String\n cell.accessoryType = UITableViewCell.AccessoryType.disclosureIndicator\n cell.textLabel?.textColor = .white\n \n return cell\n }\n \n override func prepare(for segue: UIStoryboardSegue, sender: Any?) {\n if segue.identifier == \"toContactDetailSegue\" {\n guard let destination = segue.destination as? ContactDetailsSceneController, let indexPath = self.tableView.indexPathForSelectedRow else {\n return\n }\n if let name = self.contactRows[indexPath.row][\"Name\"] as? String {\n destination.name = name\n }\n if let contactId = self.contactRows[indexPath.row][\"Id\"] as? String {\n destination.contactId = contactId\n }\n }\n }\n}\n"},"avg_line_length":{"kind":"number","value":34.3039215686,"string":"34.303922"},"max_line_length":{"kind":"number","value":166,"string":"166"},"alphanum_fraction":{"kind":"number","value":0.6158902544,"string":"0.61589"}}},{"rowIdx":251,"cells":{"hexsha":{"kind":"string","value":"e618ea25bb698382f6bc7594578f8e5135eb9663"},"size":{"kind":"number","value":5444,"string":"5,444"},"content":{"kind":"string","value":"//\n// AppDelegate.swift\n// Cliptube\n//\n// Created by Daniel Vollmer on 03.10.20.\n//\n\nimport AppKit\nimport XCDYouTubeKit\nimport Combine\n\n\n@NSApplicationMain\nclass AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {\n\n @IBOutlet var watchClipboardMenuItem : NSMenuItem!\n\n let dc: DocumentController\n var pbWatcher: AnyCancellable? // our pasteboard watcher\n var historySizeKVOToken: NSKeyValueObservation?\n\n\n override init() {\n UserDefaults.standard.registerMyDefaults()\n dc = DocumentController()\n }\n\n\n func applicationShouldOpenUntitledFile(_ sender: NSApplication) -> Bool { return false; }\n\n func applicationDidFinishLaunching(_ aNotification: Notification) {\n updateWatcher(shouldWatch: UserDefaults.standard.shouldWatchClipboard)\n historySizeKVOToken = UserDefaults.standard.observe(\\.historySize, options: [.old, .new]) { [weak self] (defaults, change) in\n guard let self = self,\n let oldValue = change.oldValue,\n let newValue = change.newValue\n else { return }\n if oldValue == newValue { return }\n let oldHistoryCount = self.dc.history.count\n self.dc.history.maxSize = newValue\n if newValue < oldHistoryCount {\n // update stored history (because setting the new maxSize has truncated it)\n UserDefaults.standard.history = self.dc.history.items\n }\n }\n }\n\n func applicationWillTerminate(_ aNotification: Notification) {\n pbWatcher = nil\n historySizeKVOToken?.invalidate()\n UserDefaults.standard.history = dc.history.items\n }\n\n\n /// Enables or disables clipboard watching depending on the argument, and sets the menu item appropriately.\n func updateWatcher(shouldWatch: Bool) {\n if shouldWatch {\n watchClipboardMenuItem.state = .on\n if pbWatcher == nil {\n pbWatcher = PasteboardPublisher().sink { maybeURLs in\n self.dc.openAllVideos(maybeURLs: maybeURLs, display: true)\n }\n }\n } else {\n watchClipboardMenuItem.state = .off\n pbWatcher = nil\n }\n }\n\n @IBAction func toggleWatchClipBoard(sender: NSMenuItem) {\n let shouldWatchClipboard = sender.state == .off // we invert the current state to obtain the desired state\n UserDefaults.standard.shouldWatchClipboard = shouldWatchClipboard\n updateWatcher(shouldWatch: shouldWatchClipboard)\n }\n\n\n func menuNeedsUpdate(_ menu: NSMenu) {\n if menu.title == \"History\" {\n menu.removeAllItems()\n let historyItems = dc.history.items\n for (id, title) in historyItems {\n let item = NSMenuItem(title: title, action: #selector(DocumentController.openHistoryItem), keyEquivalent: \"\")\n item.representedObject = id\n menu.addItem(item)\n }\n if historyItems.count > 0 {\n menu.addItem(NSMenuItem.separator())\n }\n menu.addItem(NSMenuItem(title: \"Clear History\", action: #selector(DocumentController.clearHistory), keyEquivalent: \"\"))\n }\n }\n\n @IBAction func showHelp(_ sender: Any?) {\n NSWorkspace.shared.open(URL(string: \"https://www.github.com/q-p/Cliptube\")!)\n }\n\n}\n\n\nextension UserDefaults {\n /// The key associated with the Watch Clipboard.\n static let WatchClipboardKey = \"watchClipboard\"\n /// Synthesized variable for shouldWatchClipboard, backed by the UserDefaults instance.\n var shouldWatchClipboard: Bool {\n get { return self.bool(forKey: UserDefaults.WatchClipboardKey) }\n set { self.set(newValue, forKey: UserDefaults.WatchClipboardKey) }\n }\n\n /// The key associated with the Volume.\n static let VolumeKey = \"volume\"\n /// Synthesized variable for Volume, backed by the UserDefaults instance.\n var volume: Float {\n get { return self.float(forKey: UserDefaults.VolumeKey) }\n set { self.set(newValue, forKey: UserDefaults.VolumeKey) }\n }\n\n /// The key associated with the HistorySize.\n static let HistorySizeKey = \"historySize\"\n /// Synthesized variable for HistorySize, backed by the UserDefaults instance.\n @objc dynamic var historySize: Int {\n get { return self.integer(forKey: UserDefaults.HistorySizeKey) }\n set { self.set(newValue, forKey: UserDefaults.HistorySizeKey) }\n }\n\n static let HistoryKey = \"history\"\n static let HistoryIDKey = \"id\"\n static let HistoryTitleKey = \"title\"\n /// Synthesized variable for History, backed by the UserDefaults instance.\n var history: [(String, String)] {\n get {\n guard let array = self.array(forKey: UserDefaults.HistoryKey) else { return [] }\n let available = min(array.count, self.historySize)\n var result: [(String, String)] = []\n result.reserveCapacity(available)\n for itemAny in array.prefix(available) {\n guard let dict = itemAny as? Dictionary,\n let id = dict[UserDefaults.HistoryIDKey],\n let title = dict[UserDefaults.HistoryTitleKey]\n else { continue }\n result.append((id, title))\n }\n return result\n }\n set {\n let available = min(newValue.count, self.historySize)\n self.set(newValue.prefix(available).map { [UserDefaults.HistoryIDKey: $0, UserDefaults.HistoryTitleKey: $1] },\n forKey: UserDefaults.HistoryKey)\n }\n }\n\n\n /// Registers the defaults for Cliptube.\n func registerMyDefaults() {\n self.register(defaults: [\n UserDefaults.WatchClipboardKey: true,\n UserDefaults.HistorySizeKey: 20,\n UserDefaults.HistoryKey: [],\n UserDefaults.VolumeKey: 0.5,\n// \"NSQuitAlwaysKeepsWindows\": true,\n ])\n }\n}\n"},"avg_line_length":{"kind":"number","value":33.3987730061,"string":"33.398773"},"max_line_length":{"kind":"number","value":129,"string":"129"},"alphanum_fraction":{"kind":"number","value":0.6967303453,"string":"0.69673"}}},{"rowIdx":252,"cells":{"hexsha":{"kind":"string","value":"bb3e05fadd6fce7677b97b360fd2a9f695c458dd"},"size":{"kind":"number","value":2357,"string":"2,357"},"content":{"kind":"string","value":"import UIKit\n\n/// The transition used when layout attributes change for a view during an\n/// update cycle.\n///\n/// **'Inherited' transitions:** the 'inherited' transition is determined by searching up the tree (not literally, but\n/// this is the resulting behavior). The nearest ancestor that defines an animation will be used, following this\n/// logic:\n/// - Ancestors with a layout transition of `none` will result in no inherited animation for their descendents.\n/// - Ancestors in the tree with a layout transition of `inherited` will be skipped, and the search will continue\n/// up the tree.\n/// - Any ancestors in the tree with a layout transition of `inheritedWithFallback` will be used *if* they do not\n/// themselves inherit a layout transition from one of their ancestors.\n/// - Ancestors with a layout transition of `specific` will always be used for their descendents inherited\n/// animation.\n/// - If no ancestor is found that specifies a layout transition, but the containing `BlueprintView` has the `element`\n/// property assigned from within a `UIKit` animation block, that animation will be used as the inherited animation.\npublic enum LayoutTransition {\n\n /// The view will never animate layout changes.\n case none\n\n /// Layout changes will always animate with the given attributes.\n case specific(AnimationAttributes = .default)\n\n /// The view will only animate layout changes if an inherited transition exists.\n case inherited\n\n /// The view will animate along with an inherited transition (if present) or the specified fallback attributes.\n case inheritedWithFallback(AnimationAttributes = .default)\n\n}\n\n\nextension LayoutTransition {\n\n func perform(_ animations: @escaping () -> Void) {\n\n switch self {\n case .inherited:\n animations()\n case .none:\n UIView.performWithoutAnimation(animations)\n case .inheritedWithFallback(let fallback):\n if UIView.isInAnimationBlock {\n animations()\n } else {\n fallback.perform(\n animations: animations,\n completion: {}\n )\n }\n case .specific(let attributes):\n attributes.perform(\n animations: animations,\n completion: {}\n )\n }\n\n }\n\n}\n"},"avg_line_length":{"kind":"number","value":37.4126984127,"string":"37.412698"},"max_line_length":{"kind":"number","value":118,"string":"118"},"alphanum_fraction":{"kind":"number","value":0.6682223165,"string":"0.668222"}}},{"rowIdx":253,"cells":{"hexsha":{"kind":"string","value":"e26ed710c5796cf051c63f8b6719c7a17e5a4d7c"},"size":{"kind":"number","value":1115,"string":"1,115"},"content":{"kind":"string","value":"//\n// AOperationDelegate.swift\n// AOperation\n//\n// Created by Seyed Samad Gholamzadeh on 11/25/20.\n//\n\nimport Foundation\n\n/**\nMethods for react to the changes of operation's lifecycle.\n\n\nUse the methods of this protocol to react to the following states:\n\n* Operation starts to executtion\n* Operation finishes its execution\n*/\npublic protocol AOperationDelegate: class {\n\t\n\t/// Tells the delegate the operation starts to execution\n\t/// - Parameter operation: The operation informing the delegate of this impending event.\n\tfunc operationDidStart(_ operation: AOperation)\n\t\n\t/// Tells the delegate the operation finishes its execution\n\t/// - Parameters:\n\t/// - operation: The operation informing the delegate of this impending event.\n\t/// - errors: The errors published by operation. The array would be empty if operation finishes successfully.\n\tfunc operationDidFinish(_ operation: AOperation, with errors: [AOperationError])\n}\n\npublic extension AOperationDelegate {\n\t\n\tfunc operationDidStart(_ operation: AOperation) {}\n\t\n\tfunc operationDidFinish(_ operation: AOperation, with errors: [AOperationError]) {}\n}\n"},"avg_line_length":{"kind":"number","value":29.3421052632,"string":"29.342105"},"max_line_length":{"kind":"number","value":112,"string":"112"},"alphanum_fraction":{"kind":"number","value":0.7632286996,"string":"0.763229"}}},{"rowIdx":254,"cells":{"hexsha":{"kind":"string","value":"ebf0e308543e521a6c87121c6964f04e2b6aa663"},"size":{"kind":"number","value":2781,"string":"2,781"},"content":{"kind":"string","value":"//\n// Barcode+cgImage.swift\n// RoverExperiences\n//\n// Created by Andrew Clunis on 2018-08-24.\n// Copyright © 2018 Rover Labs Inc. All rights reserved.\n//\n\nimport UIKit\nimport os\n\nextension Barcode {\n /**\n * Render the Barcode to a CGImage.\n *\n * Note that what length and sort of text is valid depends on the Barcode format.\n *\n * Note: you are responsible for freeing the returned CGImage when you are finished with it.\n */\n var cgImage: CGImage? {\n let filterName: String\n switch format {\n case .aztecCode:\n filterName = \"CIAztecCodeGenerator\"\n case .code128:\n filterName = \"CICode128BarcodeGenerator\"\n case .pdf417:\n filterName = \"CIPDF417BarcodeGenerator\"\n case .qrCode:\n filterName = \"CIQRCodeGenerator\"\n }\n\n let data = text.data(using: String.Encoding.ascii)!\n \n var params: [String: Any] = {\n switch format {\n case .pdf417:\n return [\n \"inputCorrectionLevel\": 2,\n \"inputPreferredAspectRatio\": 4\n // inputQuietSpace appears to be 2-ish, but is not configurable.\n ]\n case .qrCode:\n return [\n // // we want a quiet space of 1, however it's not configurable. Thankfully, 1 is the default.\n // \"inputQuietSpace\": 1.0,\n \"inputCorrectionLevel\": \"M\"\n ]\n case .code128:\n return [\n \"inputQuietSpace\": 1\n ]\n case .aztecCode:\n return [\n \"inputCompactStyle\": true,\n // inputQuietSpace appears to be 2-ish, but is not configurable.\n // must be set to 0 or nil, but there is a bug in iOS that prevents us setting it explicitly.\n // However, it is the default.\n // \"inputLayers\": nil,\n \"inputCorrectionLevel\": 33\n ]\n }\n }()\n \n params[\"inputMessage\"] = data\n \n #if swift(>=4.2)\n let filter = CIFilter(name: filterName, parameters: params)!\n #else\n let filter = CIFilter(name: filterName, withInputParameters: params)!\n #endif\n\n guard let outputImage = filter.outputImage else {\n os_log(\"Unable to render barcode - see logs emitted directly by CIFilter for details\", log: .general, type: .error)\n return nil\n }\n \n let context = CIContext.init(options: nil)\n \n let renderedBarcode = context.createCGImage(outputImage, from: outputImage.extent)!\n\n return renderedBarcode\n }\n}\n"},"avg_line_length":{"kind":"number","value":32.7176470588,"string":"32.717647"},"max_line_length":{"kind":"number","value":127,"string":"127"},"alphanum_fraction":{"kind":"number","value":0.5321826681,"string":"0.532183"}}},{"rowIdx":255,"cells":{"hexsha":{"kind":"string","value":"e25f5f76adb8c87f8a0d6dd4bab3a12cc230b9ff"},"size":{"kind":"number","value":4133,"string":"4,133"},"content":{"kind":"string","value":"//\n// RankingRepository.swift\n// NicoApp\n//\n// Created by 林達也 on 2016/03/06.\n// Copyright © 2016年 jp.sora0077. All rights reserved.\n//\n\nimport Foundation\nimport NicoAPI\nimport NicoEntity\nimport RxAPISchema\nimport RxSwift\nimport QueryKit\nimport RealmSwift\nimport Timepiece\nimport NicoRepository\n\n\nprivate func ==(lhs: RankingRepositoryImpl.TokenKey, rhs: RankingRepositoryImpl.TokenKey) -> Bool {\n return lhs.category == rhs.category\n && lhs.period == rhs.period\n && lhs.target == rhs.target\n}\n\n\npublic final class RankingRepositoryImpl: RankingRepository {\n \n private struct TokenKey: Hashable {\n var category: GetRanking.Category\n var period: GetRanking.Category\n var target: GetRanking.Target\n \n private var hashValue: Int {\n return \"\\(category)-\\(period)-\\(target)\".hashValue\n }\n }\n \n private let client: Client\n private var tokens: [TokenKey: NotificationToken] = [:]\n \n public init(client: Client) {\n self.client = client\n }\n \n public func categories() -> [GetRanking.Category] {\n return [\n .All, .Music, .Ent, .Anime, .Game, .Animal, .Science, .Other\n ]\n }\n \n public func list(category: GetRanking.Category, period: GetRanking.Period, target: GetRanking.Target) -> Observable<[Video]> {\n \n func cache() -> Observable<[Video]?> {\n return Observable.create { subscribe in\n do {\n let realm = try Realm()\n let ref = realm.objects(RefRanking)\n .filter(RefRanking.category == category.rawValue\n && RefRanking.period == period.rawValue\n && RefRanking.target == target.rawValue\n && RefRanking.createAt > NSDate() - 30.minutes\n ).first\n subscribe.onNext(ref.map {\n $0.items.map { $0 }\n })\n subscribe.onCompleted()\n } catch {\n subscribe.onError(error)\n }\n return NopDisposable.instance\n }.subscribeOn(mainScheduler)\n }\n \n func get() -> Observable<[Video]> {\n return client\n .start {\n self.client.request(GetRanking(target: target, period: period, category: category))\n }\n .flatMap { ids in\n self.client.request(GetThumbInfo(videos: ids))\n }\n .observeOn(backgroundScheduler)\n .map { videos -> String in\n let ref = RefRanking()\n ref._category = category.rawValue\n ref._period = period.rawValue\n ref._target = target.rawValue\n let realm = try Realm()\n try realm.write {\n realm.delete(\n realm.objects(RefRanking)\n .filter(RefRanking.category == category.rawValue\n && RefRanking.period == period.rawValue\n && RefRanking.target == target.rawValue\n )\n )\n \n let items: [VideoImpl] = videos.map {\n let video = $0 as! VideoImpl\n realm.add(video, update: true)\n return video\n }\n ref.items.appendContentsOf(items)\n realm.add(ref)\n }\n return ref.id\n }\n .observeOn(mainScheduler)\n .map { id in\n let realm = try Realm()\n realm.refresh()\n let ref = realm.objectForPrimaryKey(RefRanking.self, key: id)!\n return ref.items.map { $0 }\n }\n }\n \n return cache() ?? get()\n }\n}\n"},"avg_line_length":{"kind":"number","value":34.1570247934,"string":"34.157025"},"max_line_length":{"kind":"number","value":130,"string":"130"},"alphanum_fraction":{"kind":"number","value":0.4790708928,"string":"0.479071"}}},{"rowIdx":256,"cells":{"hexsha":{"kind":"string","value":"ff9341f3bda77b5e5872754d107547fadfa766f5"},"size":{"kind":"number","value":2020,"string":"2,020"},"content":{"kind":"string","value":"#if os(iOS)\n\nimport Foundation\nimport SwiftUI\n\n@available(iOS 13.0, *)\nopen class HostingController, Content: StateView>: UIHostingController, StatefulView where Content.StateType == State {\n private let viewStore: Store\n private let delegate: Content.Delegate\n public private(set) var renderPolicy: RenderPolicy\n\n public required init(viewStore: Store) {\n self.viewStore = viewStore\n self.renderPolicy = .notPossible(.viewNotReady)\n \n precondition(viewStore is Content.Delegate, \"ViewStore does not conform to Delegate type: \\(type(of: Content.Delegate.self))\")\n \n delegate = viewStore as! Content.Delegate\n \n super.init(rootView: Content(state: viewStore.state, delegate: viewStore as? Content.Delegate))\n \n // SwiftUI does not need time to \"load a view\" like a UIViewController since the view is declarative.\n // The rendering can happen right away.\n self.renderPolicy = .possible\n try! self.viewStore += self\n self.viewStore.viewControllerDidLoad()\n }\n \n public required init?(coder: NSCoder) {\n fatalError(\"HostingController does not support init?(coder:)\")\n }\n\n open override func viewWillAppear(_ animated: Bool) {\n super.viewWillAppear(animated)\n viewStore.viewControllerWillAppear()\n }\n \n open override func viewDidAppear(_ animated: Bool) {\n super.viewDidAppear(animated)\n viewStore.viewControllerDidAppear()\n }\n \n open override func viewWillDisappear(_ animated: Bool) {\n super.viewWillDisappear(animated)\n viewStore.viewControllerWillDisappear()\n }\n \n open override func viewDidDisappear(_ animated: Bool) {\n super.viewDidDisappear(animated)\n viewStore.viewControllerDidDisappear()\n }\n \n public func render(state: State, from distinctState: State.State?) {\n rootView = Content(state: state, delegate: delegate)\n }\n}\n\n#endif\n"},"avg_line_length":{"kind":"number","value":34.2372881356,"string":"34.237288"},"max_line_length":{"kind":"number","value":169,"string":"169"},"alphanum_fraction":{"kind":"number","value":0.6856435644,"string":"0.685644"}}},{"rowIdx":257,"cells":{"hexsha":{"kind":"string","value":"eb2c978ece0788cb82e1a4aa2b365fc41f5198e2"},"size":{"kind":"number","value":613,"string":"613"},"content":{"kind":"string","value":"//\n// ID3TagConfiguration.swift\n//\n// Created by Fabrizio Duroni on 20/02/2018.\n// 2018 Fabrizio Duroni.\n//\n\nimport Foundation\n\nclass ID3TagConfiguration {\n private let headers: [ID3Version : [UInt8]] = [\n .version2 : [UInt8](\"ID3\".utf8) + [0x02, 0x00, 0x00],\n .version3 : [UInt8](\"ID3\".utf8) + [0x03, 0x00, 0x00],\n .version4 : [UInt8](\"ID3\".utf8) + [0x04, 0x00, 0x00]\n ]\n private let tagHeaderSizeInBytes = 10\n\n func headerSize() -> Int {\n return tagHeaderSizeInBytes\n }\n\n func headerFor(version: ID3Version) -> [UInt8] {\n return headers[version]!\n }\n}\n"},"avg_line_length":{"kind":"number","value":23.5769230769,"string":"23.576923"},"max_line_length":{"kind":"number","value":61,"string":"61"},"alphanum_fraction":{"kind":"number","value":0.6084828711,"string":"0.608483"}}},{"rowIdx":258,"cells":{"hexsha":{"kind":"string","value":"fcfce314d2bbd94f05995ec6f2650e1153a9ad25"},"size":{"kind":"number","value":3777,"string":"3,777"},"content":{"kind":"string","value":"//\n// ParseLiveQueryDelegate.swift\n// ParseSwift\n//\n// Created by Corey Baker on 1/4/21.\n// Copyright © 2021 Parse Community. All rights reserved.\n//\n#if !os(Linux) && !os(Android)\nimport Foundation\n#if canImport(FoundationNetworking)\nimport FoundationNetworking\n#endif\n\n// swiftlint:disable line_length\n\n/// Receive/respond to notifications from the ParseLiveQuery Server.\npublic protocol ParseLiveQueryDelegate: AnyObject {\n\n /**\n Respond to authentication requests from a ParseLiveQuery Server. If you become a delegate\n and implement this method you will need to with\n `completionHandler(.performDefaultHandling, nil)` to accept all connections approved\n by the OS. Becoming a delegate allows you to make authentication decisions for all connections in\n the `ParseLiveQuery` session, meaning there can only be one delegate for the whole session. The newest\n instance to become the delegate will be the only one to receive authentication challenges.\n - parameter challenge: An object that contains the request for authentication.\n - parameter completionHandler: A handler that your delegate method must call. Its parameters are:\n - disposition - One of several constants that describes how the challenge should be handled.\n - credential - The credential that should be used for authentication if disposition is\n URLSessionAuthChallengeUseCredential; otherwise, `nil`.\n \n See Apple's [documentation](https://developer.apple.com/documentation/foundation/urlsessiontaskdelegate/1411595-urlsession) for more for details.\n */\n func received(_ challenge: URLAuthenticationChallenge,\n completionHandler: @escaping (URLSession.AuthChallengeDisposition,\n URLCredential?) -> Void)\n\n /**\n Receive errors from the ParseLiveQuery task/connection.\n - parameter error: An error from the session task.\n - note: The type of error received can vary from `ParseError`, `URLError`, `POSIXError`, etc.\n */\n func received(_ error: Error)\n\n /**\n Receive unsupported data from the ParseLiveQuery task/connection.\n - parameter error: An error from the session task.\n */\n func receivedUnsupported(_ data: Data?, socketMessage: URLSessionWebSocketTask.Message?)\n\n #if !os(watchOS)\n /**\n Receive metrics about the ParseLiveQuery task/connection.\n - parameter metrics: An object that encapsualtes the performance metrics collected by the URL\n Loading System during the execution of a session task.\n See Apple's [documentation](https://developer.apple.com/documentation/foundation/urlsessiontasktransactionmetrics) for more for details.\n */\n func received(_ metrics: URLSessionTaskTransactionMetrics)\n #endif\n\n /**\n Receive notifications when the ParseLiveQuery closes a task/connection.\n - parameter code: The close code provided by the server.\n - parameter reason: The close reason provided by the server.\n If the close frame didn’t include a reason, this value is nil.\n */\n func closedSocket(_ code: URLSessionWebSocketTask.CloseCode?, reason: Data?)\n}\n\npublic extension ParseLiveQueryDelegate {\n func received(_ challenge: URLAuthenticationChallenge,\n completionHandler: @escaping (URLSession.AuthChallengeDisposition,\n URLCredential?) -> Void) {\n completionHandler(.performDefaultHandling, nil)\n }\n func received(_ error: Error) { }\n func receivedUnsupported(_ data: Data?, socketMessage: URLSessionWebSocketTask.Message?) { }\n func received(_ metrics: URLSessionTaskTransactionMetrics) { }\n func closedSocket(_ code: URLSessionWebSocketTask.CloseCode?, reason: Data?) { }\n}\n#endif\n"},"avg_line_length":{"kind":"number","value":46.0609756098,"string":"46.060976"},"max_line_length":{"kind":"number","value":150,"string":"150"},"alphanum_fraction":{"kind":"number","value":0.7241196717,"string":"0.72412"}}},{"rowIdx":259,"cells":{"hexsha":{"kind":"string","value":"0904e85a6abf84e622f7af1b17aacf50614ba2b6"},"size":{"kind":"number","value":4236,"string":"4,236"},"content":{"kind":"string","value":"/*\nSee LICENSE folder for this sample’s licensing information.\n\nAbstract:\nCorner segments for the game board's border UI.\n*/\n\nimport SceneKit\n\nextension GameBoard {\n enum Corner: CaseIterable {\n case topLeft\n case topRight\n case bottomLeft\n case bottomRight\n \n var u: Float {\n switch self {\n case .topLeft: return -1\n case .topRight: return 1\n case .bottomLeft: return -1\n case .bottomRight: return 1\n }\n }\n \n var v: Float {\n switch self {\n case .topLeft: return -1\n case .topRight: return -1\n case .bottomLeft: return 1\n case .bottomRight: return 1\n }\n }\n }\n \n enum Alignment: CaseIterable {\n case horizontal\n case vertical\n \n func xOffset(for size: CGSize) -> Float {\n switch self {\n case .horizontal: return Float(size.width / 2 - BorderSegment.thickness) / 2\n case .vertical: return Float(size.width / 2)\n }\n }\n \n func yOffset(for size: CGSize) -> Float {\n switch self {\n case .horizontal: return Float(size.height / 2 - BorderSegment.thickness / 2)\n case .vertical: return Float(size.height / 2) / 2\n }\n }\n }\n \n class BorderSegment: SCNNode {\n \n // MARK: - Configuration & Initialization\n \n /// Thickness of the border lines.\n static let thickness: CGFloat = 0.012\n \n /// The scale of segment's length when in the open state\n static let openScale: Float = 0.4\n \n let corner: Corner\n let alignment: Alignment\n let plane: SCNPlane\n \n init(corner: Corner, alignment: Alignment, borderSize: CGSize) {\n self.corner = corner\n self.alignment = alignment\n \n plane = SCNPlane(width: BorderSegment.thickness, height: BorderSegment.thickness)\n self.borderSize = borderSize\n super.init()\n \n let material = plane.firstMaterial!\n material.diffuse.contents = GameBoard.borderColor\n material.emission.contents = GameBoard.borderColor\n material.isDoubleSided = true\n material.ambient.contents = UIColor.black\n material.lightingModel = .constant\n geometry = plane\n opacity = 0.8\n }\n \n var borderSize: CGSize {\n didSet {\n switch alignment {\n case .horizontal: plane.width = borderSize.width / 2\n case .vertical: plane.height = borderSize.height / 2\n }\n simdScale = float3(1)\n simdPosition = float3(corner.u * alignment.xOffset(for: borderSize),\n corner.v * alignment.yOffset(for: borderSize),\n 0)\n }\n }\n \n required init?(coder aDecoder: NSCoder) {\n fatalError(\"\\(#function) has not been implemented\")\n }\n \n // MARK: - Animating Open/Closed\n \n func open() {\n var offset = float2()\n if alignment == .horizontal {\n simdScale = float3(BorderSegment.openScale, 1, 1)\n offset.x = (1 - BorderSegment.openScale) * Float(borderSize.width) / 4\n } else {\n simdScale = float3(1, BorderSegment.openScale, 1)\n offset.y = (1 - BorderSegment.openScale) * Float(borderSize.height) / 4\n }\n \n simdPosition = float3(corner.u * alignment.xOffset(for: borderSize) + corner.u * offset.x,\n corner.v * alignment.yOffset(for: borderSize) + corner.v * offset.y,\n 0)\n }\n \n func close() {\n simdScale = float3(1)\n simdPosition = float3(corner.u * alignment.xOffset(for: borderSize),\n corner.v * alignment.yOffset(for: borderSize),\n 0)\n }\n }\n}\n"},"avg_line_length":{"kind":"number","value":32.8372093023,"string":"32.837209"},"max_line_length":{"kind":"number","value":102,"string":"102"},"alphanum_fraction":{"kind":"number","value":0.5061378659,"string":"0.506138"}}},{"rowIdx":260,"cells":{"hexsha":{"kind":"string","value":"e9be1f425f7396f449974c97d231e73e9be7256d"},"size":{"kind":"number","value":3454,"string":"3,454"},"content":{"kind":"string","value":"\nimport UIKit\n\npublic final class BreatheView: UIView {\n \n public static let nodeColor: UIColor = UIColor(red: 100/255, green: 190/255, blue: 230/255, alpha: 1)\n \n public override init(frame: CGRect) {\n super.init(frame: frame)\n commonInit()\n }\n \n public required init?(coder aDecoder: NSCoder) {\n super.init(coder: aDecoder)\n commonInit()\n }\n\n override public func layoutSubviews() {\n super.layoutSubviews()\n replicatorLayer.position = center\n }\n \n public var isAnimating: Bool {\n return _isAnimating\n }\n \n public var nodesCount: Int = 9 {\n didSet {\n stopAnimations()\n updateReplicatorLayers()\n }\n }\n \n public func startAnimations() {\n _isAnimating = true\n applyReplicatorLayerAnimations(true)\n }\n \n public func stopAnimations() {\n _isAnimating = false\n applyReplicatorLayerAnimations(false)\n }\n \n private var _isAnimating: Bool = false\n \n private lazy var replicatorLayer = makeReplicatorLayer(withInstanceCount: nodesCount)\n \n private lazy var radius: CGFloat = {\n return min(bounds.width, bounds.height)/2\n }()\n \n private lazy var node: CALayer = {\n let circle = CALayer()\n circle.compositingFilter = \"screenBlendMode\"\n circle.frame = CGRect(origin: CGPoint(x: 0, y: -radius/2), size: CGSize(width: radius, height: radius))\n circle.backgroundColor = BreatheView.nodeColor.withAlphaComponent(0.75).cgColor\n circle.cornerRadius = radius/2\n return circle\n }()\n \n private var nodeAngleTransformValue: CATransform3D {\n let angle = -CGFloat.pi * 2.0 / CGFloat(nodesCount)\n return CATransform3DMakeRotation(angle, 0, 0, -1)\n }\n \n private func commonInit() {\n backgroundColor = UIColor.clear\n layer.backgroundColor = UIColor.clear.cgColor\n layer.addSublayer(replicatorLayer)\n }\n \n private func makeReplicatorLayer(withInstanceCount instanceCount: Int) -> CAReplicatorLayer {\n let replicatorLayer = CAReplicatorLayer()\n replicatorLayer.addSublayer(node)\n replicatorLayer.instanceCount = instanceCount\n replicatorLayer.instanceBlueOffset = (-0.33 / Float(nodesCount))\n replicatorLayer.instanceTransform = nodeAngleTransformValue\n return replicatorLayer\n }\n \n private func updateReplicatorLayers() {\n replicatorLayer.instanceCount = nodesCount\n replicatorLayer.instanceTransform = nodeAngleTransformValue\n }\n \n private func applyReplicatorLayerAnimations(_ apply: Bool) {\n if apply {\n \n let center = CGPoint(x: layer.bounds.width/2 - radius, y: layer.bounds.height/2 - radius)\n node.add(CABasicAnimation.Custom.MoveAndReverse.animation(from: node.position, to: center),\n forKey: CABasicAnimation.Custom.MoveAndReverse.key)\n \n node.add(CABasicAnimation.Custom.ScaleDownAndReverse.animation,\n forKey: CABasicAnimation.Custom.ScaleDownAndReverse.key)\n \n replicatorLayer.add(CABasicAnimation.Custom.RotateAndReverse.animation,\n forKey: CABasicAnimation.Custom.RotateAndReverse.key)\n \n } else {\n node.removeAllAnimations()\n replicatorLayer.removeAllAnimations()\n }\n }\n}\n"},"avg_line_length":{"kind":"number","value":32.8952380952,"string":"32.895238"},"max_line_length":{"kind":"number","value":111,"string":"111"},"alphanum_fraction":{"kind":"number","value":0.6398378691,"string":"0.639838"}}},{"rowIdx":261,"cells":{"hexsha":{"kind":"string","value":"ebf8d2ecf75b49f4e18f430a1ee475ac640e29e9"},"size":{"kind":"number","value":2433,"string":"2,433"},"content":{"kind":"string","value":"//\n// EnterPasscodeState.swift\n// PasscodeLock\n//\n// Created by Yanko Dimitrov on 8/28/15.\n// Copyright © 2015 Yanko Dimitrov. All rights reserved.\n//\n\nimport Foundation\n\npublic let PasscodeLockIncorrectPasscodeNotification = \"passcode.lock.incorrect.passcode.notification\"\n\nstruct EnterPasscodeState: PasscodeLockStateType {\n \n let title: String\n let description: String\n let isCancellableAction: Bool\n var isTouchIDAllowed = true\n \n static let incorrectPasscodeAttemptsKey = \"incorrectPasscodeAttempts\"\n static var incorrectPasscodeAttempts: Int {\n get {\n return UserDefaults.standard.integer(forKey: incorrectPasscodeAttemptsKey)\n }\n set {\n UserDefaults.standard.set(newValue, forKey: incorrectPasscodeAttemptsKey)\n }\n }\n \n private var isNotificationSent = false\n \n init(allowCancellation: Bool = false) {\n \n isCancellableAction = allowCancellation\n title = localizedStringFor(\"PasscodeLockEnterTitle\", comment: \"Enter passcode title\")\n description = localizedStringFor(\"PasscodeLockEnterDescription\", comment: \"Enter passcode description\")\n }\n \n mutating func acceptPasscode(_ passcode: [String], fromLock lock: PasscodeLockType) {\n \n guard let currentPasscode = lock.repository.passcode else {\n return\n }\n \n var incorrectPasscodeAttempts = EnterPasscodeState.incorrectPasscodeAttempts\n if passcode == currentPasscode {\n \n lock.delegate?.passcodeLockDidSucceed(lock)\n incorrectPasscodeAttempts = 0\n } else {\n \n incorrectPasscodeAttempts += 1\n \n if incorrectPasscodeAttempts >= lock.configuration.maximumInccorectPasscodeAttempts {\n \n postNotification()\n incorrectPasscodeAttempts = 0\n }\n \n lock.delegate?.passcodeLockDidFail(lock)\n }\n \n EnterPasscodeState.incorrectPasscodeAttempts = incorrectPasscodeAttempts\n }\n \n fileprivate mutating func postNotification() {\n \n guard !isNotificationSent else { return }\n \n let center = NotificationCenter.default\n \n center.post(name: Notification.Name(rawValue: PasscodeLockIncorrectPasscodeNotification), object: nil)\n \n isNotificationSent = true\n }\n}\n"},"avg_line_length":{"kind":"number","value":31.5974025974,"string":"31.597403"},"max_line_length":{"kind":"number","value":111,"string":"111"},"alphanum_fraction":{"kind":"number","value":0.6522811344,"string":"0.652281"}}},{"rowIdx":262,"cells":{"hexsha":{"kind":"string","value":"e6a1802984b272de1c869bbd6f95fce2a0ca87a4"},"size":{"kind":"number","value":4586,"string":"4,586"},"content":{"kind":"string","value":"//\n// AppDelegate.swift\n// WatsonWasteSorter\n//\n// Created by XiaoguangMo on 1/31/18.\n// Copyright © 2018 IBM Inc. All rights reserved.\n//\n\nimport UIKit\nimport CoreData\n\n@UIApplicationMain\nclass AppDelegate: UIResponder, UIApplicationDelegate {\n\n var window: UIWindow?\n\n\n func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {\n // Override point for customization after application launch.\n return true\n }\n\n func applicationWillResignActive(_ application: UIApplication) {\n // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.\n // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.\n }\n\n func applicationDidEnterBackground(_ application: UIApplication) {\n // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.\n // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.\n }\n\n func applicationWillEnterForeground(_ application: UIApplication) {\n // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.\n }\n\n func applicationDidBecomeActive(_ application: UIApplication) {\n // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.\n }\n\n func applicationWillTerminate(_ application: UIApplication) {\n // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.\n // Saves changes in the application's managed object context before the application terminates.\n self.saveContext()\n }\n\n // MARK: - Core Data stack\n\n lazy var persistentContainer: NSPersistentContainer = {\n /*\n The persistent container for the application. This implementation\n creates and returns a container, having loaded the store for the\n application to it. This property is optional since there are legitimate\n error conditions that could cause the creation of the store to fail.\n */\n let container = NSPersistentContainer(name: \"WatsonWasteSorter\")\n container.loadPersistentStores(completionHandler: { (storeDescription, error) in\n if let error = error as NSError? {\n // Replace this implementation with code to handle the error appropriately.\n // fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.\n\n /*\n Typical reasons for an error here include:\n * The parent directory does not exist, cannot be created, or disallows writing.\n * The persistent store is not accessible, due to permissions or data protection when the device is locked.\n * The device is out of space.\n * The store could not be migrated to the current model version.\n Check the error message to determine what the actual problem was.\n */\n fatalError(\"Unresolved error \\(error), \\(error.userInfo)\")\n }\n })\n return container\n }()\n\n // MARK: - Core Data Saving support\n\n func saveContext () {\n let context = persistentContainer.viewContext\n if context.hasChanges {\n do {\n try context.save()\n } catch {\n // Replace this implementation with code to handle the error appropriately.\n // fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.\n let nserror = error as NSError\n fatalError(\"Unresolved error \\(nserror), \\(nserror.userInfo)\")\n }\n }\n }\n\n}\n"},"avg_line_length":{"kind":"number","value":49.311827957,"string":"49.311828"},"max_line_length":{"kind":"number","value":285,"string":"285"},"alphanum_fraction":{"kind":"number","value":0.6907980811,"string":"0.690798"}}},{"rowIdx":263,"cells":{"hexsha":{"kind":"string","value":"d717b88da11d62d830fb5406daf7c3b2fdfe6d62"},"size":{"kind":"number","value":4719,"string":"4,719"},"content":{"kind":"string","value":"//\n// ServiceInspectionFormFilledCellHeader.swift\n// Pods-StantUiIosLibraryDemo\n//\n// Created by Renato Vieira on 6/4/20.\n//\n\nimport UIKit\n\npublic class ServiceInspectionFormFilledCellHeader: UIView {\n public var statusBadge: CellBadge?\n public var circleView: UIView?\n public var dateView: UIView?\n public var beginAtLabel: UILabel?\n public var separatorView: UIView?\n public var endAtLabel: UILabel?\n\n public func configure(status: ServiceInspectionFormFilledCellTypeEnum,\n beginAt: String,\n endAt: String,\n color: UIColor) {\n \n self.configureStatusBadge(status: status,\n color: color)\n self.configureCircle()\n self.configureDateView(beginAt: beginAt,\n endAt: endAt)\n }\n \n fileprivate func configureStatusBadge(status: ServiceInspectionFormFilledCellTypeEnum, color: UIColor) {\n statusBadge = CellBadge()\n guard let statusBadge = statusBadge else { return }\n\n self.addSubview(statusBadge)\n statusBadge.anchor(top: self.topAnchor,\n leading: self.leadingAnchor)\n \n statusBadge.configureBadge(color: color,\n title: status.stringValue().uppercased(),\n size: CGSize(width: 112, height: 28))\n }\n \n fileprivate func configureCircle() {\n circleView = UIView()\n guard let circleView = circleView else { return }\n circleView.backgroundColor = .blueLightStant\n circleView.layer.cornerRadius = 4\n \n self.addSubview(circleView)\n \n circleView.anchor(top: self.topAnchor,\n leading: statusBadge?.titleLabel?.trailingAnchor,\n padding: UIEdgeInsets(top: 11,\n left: 8,\n bottom: 0,\n right: 0),\n size: CGSize(width: 8,\n height: 8))\n }\n \n fileprivate func configureDateView(beginAt: String, endAt: String) {\n dateView = UIView()\n guard let dateView = dateView else { return }\n dateView.backgroundColor = .lightGrayStant\n dateView.layer.cornerRadius = 3\n \n self.addSubview(dateView)\n dateView.anchor(top: self.topAnchor,\n trailing: self.trailingAnchor,\n padding: UIEdgeInsets(top: 4, left: 0, bottom: 0, right: 14),\n size: CGSize(width: 152, height: 22))\n \n configureDateLabels(beginAt: beginAt, endAt: endAt)\n }\n \n fileprivate func configureDateLabels(beginAt: String, endAt: String) {\n beginAtLabel = UILabel()\n guard let beginAtLabel = beginAtLabel else { return }\n beginAtLabel.text = beginAt\n beginAtLabel.textColor = .darkGrayStant\n beginAtLabel.font = .systemFont(ofSize: 12)\n \n dateView?.addSubview(beginAtLabel)\n beginAtLabel.anchor(top: dateView?.topAnchor,\n leading: dateView?.leadingAnchor,\n bottom: dateView?.bottomAnchor,\n padding: UIEdgeInsets(top: 0, left: 4, bottom: 0, right: 0))\n \n separatorView = UIView()\n guard let separatorView = separatorView else { return }\n separatorView.backgroundColor = .darkGrayStant\n separatorView.layer.cornerRadius = 2\n \n dateView?.addSubview(separatorView)\n separatorView.anchor(top: dateView?.topAnchor,\n leading: beginAtLabel.trailingAnchor,\n padding: UIEdgeInsets(top: 9, left: 4, bottom: 0, right: 0),\n size: CGSize(width: 4, height: 4))\n \n endAtLabel = UILabel()\n guard let endAtLabel = endAtLabel else { return }\n endAtLabel.text = endAt\n endAtLabel.textColor = .darkGrayStant\n endAtLabel.font = .systemFont(ofSize: 12)\n \n dateView?.addSubview(endAtLabel)\n endAtLabel.anchor(top: dateView?.topAnchor,\n leading: separatorView.trailingAnchor,\n bottom: dateView?.bottomAnchor,\n padding: UIEdgeInsets(top: 0, left: 4, bottom: 0, right: 0))\n }\n}\n"},"avg_line_length":{"kind":"number","value":41.7610619469,"string":"41.761062"},"max_line_length":{"kind":"number","value":108,"string":"108"},"alphanum_fraction":{"kind":"number","value":0.530408985,"string":"0.530409"}}},{"rowIdx":264,"cells":{"hexsha":{"kind":"string","value":"6a7c2bd3c9339c8d10bc4801b7c6e97e1c764835"},"size":{"kind":"number","value":4193,"string":"4,193"},"content":{"kind":"string","value":"//\n// ViewController.swift\n// ColoredSquare\n//\n// Created by burt on 2016. 2. 26..\n// Copyright © 2016년 BurtK. All rights reserved.\n//\n\nimport UIKit\nimport GLKit\n\nclass GLKUpdater : NSObject, GLKViewControllerDelegate {\n \n weak var glkViewController : GLKViewController!\n \n init(glkViewController : GLKViewController) {\n self.glkViewController = glkViewController\n }\n \n \n func glkViewControllerUpdate(_ controller: GLKViewController) {\n \n }\n}\n\n\nclass ViewController: GLKViewController {\n \n var glkView: GLKView!\n var glkUpdater: GLKUpdater!\n \n var vertexBuffer : GLuint = 0\n var indexBuffer: GLuint = 0\n var shader : BaseEffect!\n \n let vertices : [Vertex] = [\n Vertex( 1.0, -1.0, 0, 1.0, 0.0, 0.0, 1.0),\n Vertex( 1.0, 1.0, 0, 0.0, 1.0, 0.0, 1.0),\n Vertex(-1.0, 1.0, 0, 0.0, 0.0, 1.0, 1.0),\n Vertex(-1.0, -1.0, 0, 1.0, 1.0, 0.0, 1.0)\n ]\n \n let indices : [GLubyte] = [\n 0, 1, 2,\n 2, 3, 0\n ]\n \n override func viewDidLoad() {\n super.viewDidLoad()\n \n setupGLcontext()\n setupGLupdater()\n setupShader()\n setupVertexBuffer()\n }\n \n override func didReceiveMemoryWarning() {\n super.didReceiveMemoryWarning()\n }\n \n override func glkView(_ view: GLKView, drawIn rect: CGRect) {\n glClearColor(1.0, 0.0, 0.0, 1.0);\n glClear(GLbitfield(GL_COLOR_BUFFER_BIT))\n \n // shader.begin() 이 더 나은거 같다.\n shader.prepareToDraw()\n \n // 이렇게 하면 매 드로잉 콜마다\n // 정점과 인덱스 데이터를 CPU에서 GPU로 복사해야 하므로 성능이 떨이지는 단점이 있다.\n // 이를 해결하기 위해서 VertexArrayObject를 사용하는 것이다.\n // 프로그램 초기에 VAO를 GPU만들어서 거기에 모든 데이터를 CPU에서 GPU로 한번 설정한다.\n // 그리고 매 드로잉콜에서는 VAO를 바인딩해서 사용하면 된다.\n // 즉, 그리고자 하는 모델이 VAO를 가지고 있으면 된다.\n // 모델이 생성될 때, 정점 등의 데이터를 읽어서 자신의 VAO를 GPU에 만들고\n // VAO에 데이터를 전송하면 매 드로잉콜마다 데이터를 전송할 필요 없이\n // 자신의 VAO를 바인딩해서 사용하며 된다.\n glEnableVertexAttribArray(VertexAttributes.position.rawValue)\n glVertexAttribPointer(\n VertexAttributes.position.rawValue,\n 3,\n GLenum(GL_FLOAT),\n GLboolean(GL_FALSE),\n GLsizei(MemoryLayout.size), BUFFER_OFFSET(0))\n\n \n glEnableVertexAttribArray(VertexAttributes.color.rawValue)\n glVertexAttribPointer(\n VertexAttributes.color.rawValue,\n 4,\n GLenum(GL_FLOAT),\n GLboolean(GL_FALSE),\n GLsizei(MemoryLayout.size), BUFFER_OFFSET(3 * MemoryLayout.size)) // x, y, z | r, g, b, a :: offset is 3*sizeof(GLfloat)\n \n glBindBuffer(GLenum(GL_ARRAY_BUFFER), vertexBuffer)\n glBindBuffer(GLenum(GL_ELEMENT_ARRAY_BUFFER), indexBuffer)\n glDrawElements(GLenum(GL_TRIANGLES), GLsizei(indices.count), GLenum(GL_UNSIGNED_BYTE), nil)\n \n glDisableVertexAttribArray(VertexAttributes.position.rawValue)\n \n }\n \n}\n\nextension ViewController {\n \n func setupGLcontext() {\n glkView = self.view as! GLKView\n glkView.context = EAGLContext(api: .openGLES2)!\n EAGLContext.setCurrent(glkView.context)\n }\n \n func setupGLupdater() {\n self.glkUpdater = GLKUpdater(glkViewController: self)\n self.delegate = self.glkUpdater\n }\n \n func setupShader() {\n self.shader = BaseEffect(vertexShader: \"SimpleVertexShader.glsl\", fragmentShader: \"SimpleFragmentShader.glsl\")\n }\n \n func setupVertexBuffer() {\n glGenBuffers(GLsizei(1), &vertexBuffer)\n glBindBuffer(GLenum(GL_ARRAY_BUFFER), vertexBuffer)\n let count = vertices.count\n let size = MemoryLayout.size\n glBufferData(GLenum(GL_ARRAY_BUFFER), count * size, vertices, GLenum(GL_STATIC_DRAW))\n \n glGenBuffers(GLsizei(1), &indexBuffer)\n glBindBuffer(GLenum(GL_ELEMENT_ARRAY_BUFFER), indexBuffer)\n glBufferData(GLenum(GL_ELEMENT_ARRAY_BUFFER), indices.count * MemoryLayout.size, indices, GLenum(GL_STATIC_DRAW))\n }\n \n func BUFFER_OFFSET(_ n: Int) -> UnsafeRawPointer? {\n return UnsafeRawPointer(bitPattern: n)\n }\n}\n"},"avg_line_length":{"kind":"number","value":30.6058394161,"string":"30.605839"},"max_line_length":{"kind":"number","value":149,"string":"149"},"alphanum_fraction":{"kind":"number","value":0.6184116384,"string":"0.618412"}}},{"rowIdx":265,"cells":{"hexsha":{"kind":"string","value":"dd1c4f37f5e46d0f86a9bd923fff577614971ea7"},"size":{"kind":"number","value":2737,"string":"2,737"},"content":{"kind":"string","value":"//\n// BigInt Exponentiation.swift\n//\n// Created by pebble8888 on 2017/05/13.\n//\n//\n\nimport Foundation\nimport BigInt\n\nextension BigInt {\n // 0 or 1\n public func parity() -> Int {\n return self.magnitude.parity()\n }\n\n public init(word: Word) {\n let m = BigUInt(word)\n self.init(sign: .plus, magnitude: m)\n }\n}\n\nextension BigUInt {\n // return value: 0 or 1\n public func parity() -> Int {\n let a = self % BigUInt(2)\n let b = a & 1\n return Int(b)\n }\n}\n\nextension BigInt {\n\n /* python, ruby\n >>> 7 % 3\n 1\n >>> 7 % -3\n -2\n >>> -7 % 3\n 2\n >>> -7 % -3\n -1\n */\n public func modulo(_ divider: BigInt) -> BigInt {\n let v = self.magnitude % divider.magnitude\n if v == 0 {\n return 0\n }\n if self.sign == .plus {\n if divider.sign == .plus {\n return BigInt(sign: .plus, magnitude: v)\n } else {\n return BigInt(sign: .plus, magnitude: v) + divider\n }\n } else {\n if divider.sign == .plus {\n return BigInt(sign: .minus, magnitude: v) + divider\n } else {\n return BigInt(sign: .minus, magnitude: v)\n }\n }\n }\n\n /** python, ruby\n >>> 7 / 2\n 3\n >>> 7 / -2\n -4\n >>> -7 / 2\n -4\n >>> -7 / -2\n 3\n */\n public func divide(_ divider: BigInt) -> BigInt {\n let v = self.magnitude / divider.magnitude\n if self.sign == .plus {\n if divider.sign == .plus {\n return BigInt(sign: .plus, magnitude: v)\n } else {\n if (self.magnitude % divider.magnitude) == 0 {\n return BigInt(sign: .minus, magnitude: v)\n } else {\n return BigInt(sign: .minus, magnitude: v+1)\n }\n }\n } else {\n if divider.sign == .plus {\n if (self.magnitude % divider.magnitude) == 0 {\n return BigInt(sign: .minus, magnitude: v)\n } else {\n return BigInt(sign: .minus, magnitude: v+1)\n }\n } else {\n return BigInt(sign: .plus, magnitude: v)\n }\n }\n }\n\n // return val is less than q\n public static func expmod(_ b: BigInt, _ e: BigInt, _ q: BigInt) -> BigInt {\n if e == 0 { return 1 }\n var t = expmod(b, e.divide(2), q).power(2).modulo(q)\n if e.parity() != 0 {\n t = (t*b).modulo(q)\n }\n return t\n }\n\n // return val is less than q\n public static func inv(_ x: BigInt, _ q: BigInt) -> BigInt {\n return expmod(x, q-2, q)\n }\n}\n"},"avg_line_length":{"kind":"number","value":24.0087719298,"string":"24.008772"},"max_line_length":{"kind":"number","value":80,"string":"80"},"alphanum_fraction":{"kind":"number","value":0.4486664231,"string":"0.448666"}}},{"rowIdx":266,"cells":{"hexsha":{"kind":"string","value":"fe654a8439888133204dde89a6ba1b2c88b582a5"},"size":{"kind":"number","value":214,"string":"214"},"content":{"kind":"string","value":"//\n// AddTagImageError.swift\n// wallpapper\n//\n// Created by Marcin Czachurski on 11/07/2018.\n// Copyright © 2018 Marcin Czachurski. All rights reserved.\n//\n\nimport Foundation\n\nclass AddTagImageError: Error {\n}\n"},"avg_line_length":{"kind":"number","value":16.4615384615,"string":"16.461538"},"max_line_length":{"kind":"number","value":60,"string":"60"},"alphanum_fraction":{"kind":"number","value":0.7196261682,"string":"0.719626"}}},{"rowIdx":267,"cells":{"hexsha":{"kind":"string","value":"e578e0225f6b741149857bb7dec3722170d90a9f"},"size":{"kind":"number","value":630,"string":"630"},"content":{"kind":"string","value":"extension TextOutputStream {\n public mutating func print(_ items: Any..., separator: String = \" \", terminator: String = \"\\n\") {\n let print = unsafeBitCast(\n Swift.print(_:separator:terminator:to:) as VPrintFunction,\n to: PrintFunction.self\n )\n print(items, separator, terminator, &self)\n }\n\n public mutating func debugPrint(_ items: Any..., separator: String = \" \", terminator: String = \"\\n\") {\n let print = unsafeBitCast(\n Swift.debugPrint(_:separator:terminator:to:) as VPrintFunction,\n to: PrintFunction.self\n )\n print(items, separator, terminator, &self)\n }\n}\n"},"avg_line_length":{"kind":"number","value":35,"string":"35"},"max_line_length":{"kind":"number","value":104,"string":"104"},"alphanum_fraction":{"kind":"number","value":0.6682539683,"string":"0.668254"}}},{"rowIdx":268,"cells":{"hexsha":{"kind":"string","value":"e565fe8c40ed85d18f8aa7fbfa2048c1e6f8755a"},"size":{"kind":"number","value":1807,"string":"1,807"},"content":{"kind":"string","value":"//\n// OpportunityDetailViewController.swift\n// helloworld-ios-app\n//\n// Created by Marco Metting on 08.03.18.\n// Copyright © 2018 FeedHenry. All rights reserved.\n//\n\nimport UIKit\nimport FeedHenry\n\nclass OpportunityDetailViewController: UIViewController {\n\n @IBOutlet weak var subscribeButton: UIButton!\n @IBOutlet weak var dealSize: UILabel!\n @IBOutlet weak var status: UILabel!\n @IBOutlet weak var name: UILabel!\n \n var opp : Opportunity!\n \n override func viewDidLoad() {\n super.viewDidLoad()\n }\n \n override func viewWillAppear(_ animated: Bool) {\n self.dealSize.text = String(describing: self.opp.dealSize)\n self.name.text = self.opp.name\n self.status.text = self.opp.status\n \n if (self.opp.subscribed) {\n self.subscribeButton.isHidden = true\n } else {\n self.subscribeButton.isHidden = false\n }\n }\n \n @IBAction func subscribePressed(_ sender: Any) {\n \n let args = [\"data\": self.opp.toJson()] as [String : AnyObject]\n \n UIApplication.shared.isNetworkActivityIndicatorVisible = true\n \n FH.cloud(path: \"opportunities/subscribe\",\n method: HTTPMethod.POST,\n args: args,\n completionHandler: {(resp: Response, error: NSError?) -> Void in\n \n UIApplication.shared.isNetworkActivityIndicatorVisible = false\n \n if error != nil {\n print(\"Cloud Call Failed: \" + (error?.localizedDescription)!)\n return\n }\n print(\"Success\")\n \n self.navigationController?.popViewController(animated: true)\n })\n }\n}\n"},"avg_line_length":{"kind":"number","value":30.1166666667,"string":"30.116667"},"max_line_length":{"kind":"number","value":85,"string":"85"},"alphanum_fraction":{"kind":"number","value":0.5666851134,"string":"0.566685"}}},{"rowIdx":269,"cells":{"hexsha":{"kind":"string","value":"f811e6d08dbecf38995dabc5162c90a5983bc0de"},"size":{"kind":"number","value":7981,"string":"7,981"},"content":{"kind":"string","value":"//\n// CountryPickerView.swift\n// CountryPickerView\n//\n// Created by Kizito Nwose on 18/09/2017.\n// Copyright © 2017 Kizito Nwose. All rights reserved.\n//\n\nimport UIKit\n\npublic typealias CPVCountry = Country\n\npublic enum SearchBarPosition {\n case tableViewHeader, navigationBar, hidden\n}\n\npublic struct Country: Equatable {\n public let name: String\n public let code: String\n public let phoneCode: String\n public func localizedName(_ locale: Locale = Locale.current) -> String? {\n return locale.localizedString(forRegionCode: code)\n }\n public var flag: UIImage {\n return UIImage(named: \"CountryPickerView.bundle/Images/\\(code.uppercased())\",\n in: Bundle(for: CountryPickerView.self), compatibleWith: nil)!\n }\n}\n\npublic func ==(lhs: Country, rhs: Country) -> Bool {\n return lhs.code == rhs.code\n}\npublic func !=(lhs: Country, rhs: Country) -> Bool {\n return lhs.code != rhs.code\n}\n\n\npublic class CountryPickerView: NibView {\n @IBOutlet weak var spacingConstraint: NSLayoutConstraint!\n @IBOutlet public weak var flagImageView: UIImageView! {\n didSet {\n flagImageView.clipsToBounds = true\n flagImageView.layer.masksToBounds = true\n flagImageView.layer.cornerRadius = 2\n }\n }\n @IBOutlet public weak var countryDetailsLabel: UILabel!\n \n /// Show/Hide the country code on the view.\n public var showCountryCodeInView = true {\n didSet {\n if showCountryNameInView && showCountryCodeInView {\n showCountryNameInView = false\n } else {\n setup()\n }\n }\n }\n \n /// Show/Hide the phone code on the view.\n public var showPhoneCodeInView = true {\n didSet { setup() }\n }\n \n /// Show/Hide the country name on the view.\n public var showCountryNameInView = false {\n didSet {\n if showCountryCodeInView && showCountryNameInView {\n showCountryCodeInView = false\n } else {\n setup()\n }\n }\n }\n \n /// Change the font of phone code\n public var font = UIFont.systemFont(ofSize: 17.0) {\n didSet { setup() }\n }\n /// Change the text color of phone code\n public var textColor = UIColor.black {\n didSet { setup() }\n }\n \n /// The spacing between the flag image and the text.\n public var flagSpacingInView: CGFloat {\n get {\n return spacingConstraint.constant\n }\n set {\n spacingConstraint.constant = newValue\n }\n }\n \n weak public var dataSource: CountryPickerViewDataSource?\n weak public var delegate: CountryPickerViewDelegate?\n weak public var hostViewController: UIViewController?\n \n fileprivate var _selectedCountry: Country?\n internal(set) public var selectedCountry: Country {\n get {\n return _selectedCountry\n ?? countries.first(where: { $0.code == Locale.current.regionCode })\n ?? countries.first!\n }\n set {\n _selectedCountry = newValue\n delegate?.countryPickerView(self, didSelectCountry: newValue)\n setup()\n }\n }\n \n override public init(frame: CGRect) {\n super.init(frame: frame)\n setup()\n }\n \n required public init?(coder aDecoder: NSCoder) {\n super.init(coder: aDecoder)\n setup()\n }\n \n func setup() {\n flagImageView.image = selectedCountry.flag\n countryDetailsLabel.font = font\n countryDetailsLabel.textColor = textColor\n if showCountryCodeInView && showPhoneCodeInView {\n countryDetailsLabel.text = \"(\\(selectedCountry.code)) \\(selectedCountry.phoneCode)\"\n } else if showCountryNameInView && showPhoneCodeInView {\n countryDetailsLabel.text = \"(\\(selectedCountry.localizedName() ?? selectedCountry.name)) \\(selectedCountry.phoneCode)\"\n } else if showCountryCodeInView || showPhoneCodeInView || showCountryNameInView {\n countryDetailsLabel.text = showCountryCodeInView ? selectedCountry.code\n : showPhoneCodeInView ? selectedCountry.phoneCode\n : selectedCountry.localizedName() ?? selectedCountry.name\n } else {\n countryDetailsLabel.text = nil\n }\n }\n \n @IBAction func openCountryPickerController(_ sender: Any) {\n if let hostViewController = hostViewController {\n showCountriesList(from: hostViewController)\n return\n }\n if let vc = window?.topViewController {\n if let tabVc = vc as? UITabBarController,\n let selectedVc = tabVc.selectedViewController {\n showCountriesList(from: selectedVc)\n } else {\n showCountriesList(from: vc)\n }\n }\n }\n \n public func showCountriesList(from viewController: UIViewController) {\n let countryVc = CountryPickerViewController(style: .grouped)\n countryVc.countryPickerView = self\n if let viewController = viewController as? UINavigationController {\n delegate?.countryPickerView(self, willShow: countryVc)\n viewController.pushViewController(countryVc, animated: true) {\n self.delegate?.countryPickerView(self, didShow: countryVc)\n }\n } else {\n let navigationVC = UINavigationController(rootViewController: countryVc)\n delegate?.countryPickerView(self, willShow: countryVc)\n viewController.present(navigationVC, animated: true) {\n self.delegate?.countryPickerView(self, didShow: countryVc)\n }\n }\n }\n \n public let countries: [Country] = {\n var countries = [Country]()\n let bundle = Bundle(for: CountryPickerView.self)\n guard let jsonPath = bundle.path(forResource: \"CountryPickerView.bundle/Data/CountryCodes\", ofType: \"json\"),\n let jsonData = try? Data(contentsOf: URL(fileURLWithPath: jsonPath)) else {\n return countries\n }\n \n if let jsonObjects = (try? JSONSerialization.jsonObject(with: jsonData, options: JSONSerialization\n .ReadingOptions.allowFragments)) as? Array {\n \n for jsonObject in jsonObjects {\n \n guard let countryObj = jsonObject as? Dictionary else {\n continue\n }\n \n guard let name = countryObj[\"name\"] as? String,\n let code = countryObj[\"code\"] as? String,\n let phoneCode = countryObj[\"dial_code\"] as? String else {\n continue\n }\n \n let country = Country(name: name, code: code, phoneCode: phoneCode)\n countries.append(country)\n }\n }\n return countries\n }()\n}\n\n//MARK: Helper methods\nextension CountryPickerView {\n public func setCountryByName(_ name: String) {\n if let country = countries.first(where: { $0.name == name }) {\n selectedCountry = country\n }\n }\n \n public func setCountryByPhoneCode(_ phoneCode: String) {\n if let country = countries.first(where: { $0.phoneCode == phoneCode }) {\n selectedCountry = country\n }\n }\n \n public func setCountryByCode(_ code: String) {\n if let country = countries.first(where: { $0.code == code }) {\n selectedCountry = country\n }\n }\n \n public func getCountryByName(_ name: String) -> Country? {\n return countries.first(where: { $0.name == name })\n }\n \n public func getCountryByPhoneCode(_ phoneCode: String) -> Country? {\n return countries.first(where: { $0.phoneCode == phoneCode })\n }\n \n public func getCountryByCode(_ code: String) -> Country? {\n return countries.first(where: { $0.code == code })\n }\n}\n"},"avg_line_length":{"kind":"number","value":33.9617021277,"string":"33.961702"},"max_line_length":{"kind":"number","value":130,"string":"130"},"alphanum_fraction":{"kind":"number","value":0.6034331537,"string":"0.603433"}}},{"rowIdx":270,"cells":{"hexsha":{"kind":"string","value":"ab65d4ef5de052e72c37453e192a3c41fda4395d"},"size":{"kind":"number","value":921,"string":"921"},"content":{"kind":"string","value":"//\n// NewsLoadingFooter.swift\n// NewsClient\n//\n// Created by chihhao on 2019-06-15.\n// Copyright © 2019 ChihHao. All rights reserved.\n//\n\nimport UIKit\n\nclass NewsLoadingFooter: UICollectionReusableView {\n \n override init(frame: CGRect) {\n super.init(frame: frame)\n \n let aiv = UIActivityIndicatorView(style: .large)\n aiv.color = .darkGray\n aiv.startAnimating()\n \n\t\tlet loadingLabel = UILabel(text: \"Loading...\", font: UIFont.preferredFont(forTextStyle: .body), color: .label)\n \n let verticalStack = VerticalStackView(arrangedSubviews: [aiv, loadingLabel], spacing: 8)\n addSubview(verticalStack)\n verticalStack.centerInSuperview(size: .init(width: 200, height: 0))\n verticalStack.alignment = .center\n \n }\n \n required init?(coder aDecoder: NSCoder) {\n fatalError(\"init(coder:) has not been implemented\")\n }\n}\n"},"avg_line_length":{"kind":"number","value":27.9090909091,"string":"27.909091"},"max_line_length":{"kind":"number","value":112,"string":"112"},"alphanum_fraction":{"kind":"number","value":0.6471226927,"string":"0.647123"}}},{"rowIdx":271,"cells":{"hexsha":{"kind":"string","value":"fb2ac5874eff91d879eac17d5b123e223204194c"},"size":{"kind":"number","value":291,"string":"291"},"content":{"kind":"string","value":"import Foundation\nimport CoreData\n\n\nextension Photo {\n\n @nonobjc public class func fetchRequest() -> NSFetchRequest {\n return NSFetchRequest(entityName: \"Photo\")\n }\n\n\n @NSManaged public var photoID: String?\n @NSManaged public var remoteURL: NSObject?\n\n\n\n}\n\n\n"},"avg_line_length":{"kind":"number","value":14.55,"string":"14.55"},"max_line_length":{"kind":"number","value":72,"string":"72"},"alphanum_fraction":{"kind":"number","value":0.6975945017,"string":"0.697595"}}},{"rowIdx":272,"cells":{"hexsha":{"kind":"string","value":"8fe0e24615fb0bcc9a2617c2ad94de1109261b61"},"size":{"kind":"number","value":121,"string":"121"},"content":{"kind":"string","value":"//\n// Cost.swift\n// Example\n//\n\nimport Foundation\n\nstruct Cost {\n\n let amount: Decimal\n let currency: Currency\n}\n"},"avg_line_length":{"kind":"number","value":9.3076923077,"string":"9.307692"},"max_line_length":{"kind":"number","value":26,"string":"26"},"alphanum_fraction":{"kind":"number","value":0.6363636364,"string":"0.636364"}}},{"rowIdx":273,"cells":{"hexsha":{"kind":"string","value":"3a9b825226dffa4977473cf8057cc0277085f65b"},"size":{"kind":"number","value":860,"string":"860"},"content":{"kind":"string","value":"import Foundation\nimport WebKit\nimport ServiceWorkerContainer\nimport ServiceWorker\nimport PromiseKit\n\nclass ServiceWorkerRegistrationCommands {\n\n static func unregister(eventStream: EventStream, json: AnyObject?) throws -> Promise? {\n\n guard let registrationID = json?[\"id\"] as? String else {\n throw ErrorMessage(\"Must provide registration ID in JSON body\")\n }\n\n return eventStream.container.getRegistrations()\n .then { registrations in\n\n guard let registration = registrations.first(where: { $0.id == registrationID }) else {\n throw ErrorMessage(\"Registration does not exist\")\n }\n\n return registration.unregister()\n }\n .then {\n [\n \"success\": true\n ]\n }\n }\n}\n"},"avg_line_length":{"kind":"number","value":27.7419354839,"string":"27.741935"},"max_line_length":{"kind":"number","value":103,"string":"103"},"alphanum_fraction":{"kind":"number","value":0.5825581395,"string":"0.582558"}}},{"rowIdx":274,"cells":{"hexsha":{"kind":"string","value":"e917ab337295ca1e865af2105a49aedc3df608c3"},"size":{"kind":"number","value":4338,"string":"4,338"},"content":{"kind":"string","value":"//\n// Copyright (c) 2021 Adyen N.V.\n//\n// This file is open source and available under the MIT license. See the LICENSE file for more info.\n//\n\nimport SwiftUI\n\n#if canImport(SwiftUI) && canImport(Combine)\n /// :nodoc:\n @available(iOS 13.0, *)\n public extension View {\n\n /// Present a `ViewController` modally.\n ///\n /// - Parameter viewController: A `Binding` instance,\n /// set the `wrappedValue` to a view controller instance to dismiss the previous view controller if it had previously a value\n /// and presents the new one,\n /// set it to `nil` to dismiss the previous view Controller if any.\n func present(viewController: Binding) -> some View {\n modifier(ViewControllerPresenter(viewController: viewController))\n }\n }\n\n /// :nodoc:\n @available(iOS 13.0, *)\n internal struct ViewControllerPresenter: ViewModifier {\n\n @Binding internal var viewController: UIViewController?\n\n internal func body(content: Content) -> some View {\n ZStack {\n FullScreenView(viewController: $viewController)\n content\n }\n }\n }\n\n /// :nodoc:\n @available(iOS 13.0, *)\n internal final class FullScreenView: UIViewControllerRepresentable {\n\n @Binding internal var viewController: UIViewController?\n\n internal init(viewController: Binding) {\n self._viewController = viewController\n }\n\n internal final class Coordinator {\n\n fileprivate var currentlyPresentedViewController: UIViewController?\n }\n\n internal func makeUIViewController(context: UIViewControllerRepresentableContext