Skip to content

Commit

Permalink
Revert "LeafKit 1.0.0.tau (#72)"
Browse files Browse the repository at this point in the history
This reverts commit 61d6928.
  • Loading branch information
0xTim committed Nov 8, 2020
1 parent 382fbe1 commit 595434b
Show file tree
Hide file tree
Showing 103 changed files with 5,768 additions and 11,912 deletions.
13 changes: 4 additions & 9 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,20 @@ import PackageDescription
let package = Package(
name: "leaf-kit",
platforms: [
.macOS(.v10_15)
.macOS(.v10_15)
],
products: [
.library(name: "LeafKit", targets: ["LeafKit"]),
.library(name: "XCTLeafKit", targets: ["XCTLeafKit"])
],
dependencies: [
.package(url: "https://github.com/apple/swift-nio.git", from: "2.20.2"),
.package(url: "https://github.com/apple/swift-nio.git", from: "2.2.0"),
],
targets: [
.target(name: "LeafKit", dependencies: [
.product(name: "NIO", package: "swift-nio"),
.product(name: "NIOFoundationCompat", package: "swift-nio")
]),
.target(name: "XCTLeafKit", dependencies: [
.target(name: "LeafKit")
]),
.testTarget(name: "LeafKitTests", dependencies: [
.target(name: "XCTLeafKit")
])
.target(name: "LeafKit"),
]),
]
)
57 changes: 57 additions & 0 deletions Sources/LeafKit/Deprecated.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// MARK: Subject to change prior to 1.0.0 release
// MARK: -

extension LeafRenderer {
/// Deprecated in Leaf-Kit 1.0.0rc-1.2
@available(*, deprecated, message: "Use files instead of fileio")
public var fileio: NonBlockingFileIO {
guard let source = self.sources.sources["default"],
let nio = source as? NIOLeafFiles else {
fatalError("Unexpected non-NIO LeafFiles.")
}
return nio.fileio
}

/// Deprecated in Leaf-Kit 1.0.0rc-1.2
@available(*, deprecated, message: "Use files instead of fileio")
public convenience init(
configuration: LeafConfiguration,
cache: LeafCache = DefaultLeafCache(),
fileio: NonBlockingFileIO,
eventLoop: EventLoop
) {
let sources = LeafSources()
try! sources.register(using: NIOLeafFiles(fileio: fileio))

self.init(
configuration: configuration,
cache: cache,
sources: sources,
eventLoop: eventLoop
)
}
}

extension LeafSource {
/// Default implementation for non-adhering protocol implementations mimicing older LeafRenderer expansion
/// This wrapper will be removed in a future release.
@available(*, deprecated, message: "Update to adhere to `file(template, escape, eventLoop)`")
func file(template: String, escape: Bool, on eventLoop: EventLoop) throws -> EventLoopFuture<ByteBuffer> {
var path = template
if path.split(separator: "/").last?.split(separator: ".").count ?? 1 < 2,
!path.hasSuffix(".leaf") { path += ".leaf" }
if !path.hasPrefix("/") { path = "/" + path }
return try self.file(path: path, on: eventLoop)
}

/// Deprecated in Leaf-Kit 1.0.0rc-1.11
/// Default implementation for newer adherants to allow older adherents to be called until upgraded
@available(*, deprecated, message: "This default implementation should never be called")
public func file(path: String, on eventLoop: EventLoop) throws -> EventLoopFuture<ByteBuffer> {
fatalError("This default implementation should never be called")
}
}

/// Deprecated in Leaf-Kit 1.0.0rc-1.11
@available(*, deprecated, renamed: "LeafSource")
typealias LeafFiles = LeafSource
30 changes: 0 additions & 30 deletions Sources/LeafKit/Exports+Helpers.swift

This file was deleted.

119 changes: 119 additions & 0 deletions Sources/LeafKit/Exports.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
// MARK: Subject to change prior to 1.0.0 release
// MARK: -

@_exported import NIO

/// Various helper identities for convenience
extension Character {
// MARK: - Leaf-Kit specific static identities (Public)

/// Global setting of `tagIndicator` for Leaf-Kit - by default, `#`
public internal(set) static var tagIndicator: Character = .octothorpe

// MARK: - LeafToken specific identities (Internal)

var isValidInTagName: Bool {
return self.isLowercaseLetter
|| self.isUppercaseLetter
}

var isValidInParameter: Bool {
return self.isValidInTagName
|| self.isValidOperator
|| self.isValidInNumeric
}

var canStartNumeric: Bool {
return (.zero ... .nine) ~= self
}

var isValidInNumeric: Bool {
return self.canStartNumeric
|| self == .underscore
|| self == .binaryNotation
|| self == .octalNotation
|| self == .hexNotation
|| self.isHexadecimal
|| self == .period
}

var isValidOperator: Bool {
switch self {
case .plus,
.minus,
.star,
.forwardSlash,
.equals,
.exclamation,
.lessThan,
.greaterThan,
.ampersand,
.vertical: return true
default: return false
}
}

// MARK: - General group-membership identities (Internal)

var isHexadecimal: Bool {
return (.zero ... .nine).contains(self)
|| (.A ... .F).contains(self.uppercased().first!)
|| self == .hexNotation
}

var isOctal: Bool {
return (.zero ... .seven).contains(self)
|| self == .octalNotation
}

var isBinary: Bool {
return (.zero ... .one).contains(self)
|| self == .binaryNotation
}

var isUppercaseLetter: Bool {
return (.A ... .Z).contains(self)
}

var isLowercaseLetter: Bool {
return (.a ... .z).contains(self)
}

// MARK: - General static identities (Internal)

static let newLine = "\n".first!
static let quote = "\"".first!
static let octothorpe = "#".first!
static let leftParenthesis = "(".first!
static let backSlash = "\\".first!
static let rightParenthesis = ")".first!
static let comma = ",".first!
static let space = " ".first!
static let colon = ":".first!
static let period = ".".first!
static let A = "A".first!
static let F = "F".first!
static let Z = "Z".first!
static let a = "a".first!
static let z = "z".first!

static let zero = "0".first!
static let one = "1".first!
static let seven = "7".first!
static let nine = "9".first!
static let binaryNotation = "b".first!
static let octalNotation = "o".first!
static let hexNotation = "x".first!

static let plus = "+".first!
static let minus = "-".first!
static let star = "*".first!
static let forwardSlash = "/".first!
static let equals = "=".first!
static let exclamation = "!".first!
static let lessThan = "<".first!
static let greaterThan = ">".first!
static let ampersand = "&".first!
static let vertical = "|".first!
static let underscore = "_".first!
}
85 changes: 0 additions & 85 deletions Sources/LeafKit/LKHelpers/RWLock.swift

This file was deleted.

Loading

0 comments on commit 595434b

Please sign in to comment.