Skip to content

Commit

Permalink
Fix lint error
Browse files Browse the repository at this point in the history
  • Loading branch information
joeblau committed Jun 24, 2018
1 parent 3777bc1 commit fe164ee
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 29 deletions.
8 changes: 4 additions & 4 deletions Sources/App/Controllers/TemplateController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ internal struct TemplateController: ReadOnlyTemplateManagerProtocol {
internal var order = [String: Int]()
internal var count = 0
internal var templates = [String: IgnoreTemplateModel]()

/// Create Template Controller
///
/// - Returns: Template Controller
Expand All @@ -27,9 +27,9 @@ internal struct TemplateController: ReadOnlyTemplateManagerProtocol {
print("‼️ You might not have done a recursive clone to update your submodules:\n‼️ `git submodule update --init --recursive`")
}
}

// MARK: - Private

/// Parse file which defines template order precedence
///
/// - Parameter orderFile: The dependency order file
Expand All @@ -51,7 +51,7 @@ internal struct TemplateController: ReadOnlyTemplateManagerProtocol {
return mutableOrderedDict
})
}

/// Parse template directory
///
/// - Parameter dataDirectory: The path to the data directory
Expand Down
4 changes: 2 additions & 2 deletions Sources/App/Enum/TemplateSuffix.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
/// Template Suffix Enum
internal enum TemplateSuffix {
case template, patch, stack

internal var `extension`: String {
switch self {
case .template: return "gitignore"
case .patch: return "patch"
case .stack: return "stack"
}
}

internal func header(name: String) -> String {
switch self {
case .template: return "\n### \(name) ###\n"
Expand Down
4 changes: 2 additions & 2 deletions Sources/App/Extensions/Dictionary+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation

internal extension Dictionary where Key: ExpressibleByStringLiteral, Value: IgnoreTemplateModeling {

/// Append template patches to template contents
///
/// - Parameter dataDirectory: The path to the data directory
Expand All @@ -27,7 +27,7 @@ internal extension Dictionary where Key: ExpressibleByStringLiteral, Value: Igno
}
})
}

/// Append stacks to template contents
///
/// - Parameter dataDictionary: The path to the data dictionary
Expand Down
2 changes: 1 addition & 1 deletion Sources/App/Extensions/String+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ internal extension String {
/// - Returns: String with duplicate lines removed
internal func removeDuplicateLines() -> String {
return self.components(separatedBy: "\n")
.reduce([String]()){
.reduce([String]()) {
if !$1.isEmpty && !$1.hasPrefix("#") && $0.contains($1) {
return $0
}
Expand Down
6 changes: 3 additions & 3 deletions Sources/App/Extensions/URL+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
import Foundation

internal extension URL {

/// Name of file without extension
internal var name: String {
return self.deletingPathExtension().lastPathComponent
}

/// Name of file first component
internal var stackName: String? {
return self.deletingPathExtension().lastPathComponent.components(separatedBy: ".").first
Expand All @@ -24,5 +24,5 @@ internal extension URL {
internal var fileName: String {
return self.lastPathComponent
}

}
1 change: 0 additions & 1 deletion Sources/App/Models/IgnoreTemplateModeling.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
//
//


internal protocol IgnoreTemplateModeling: Codable {
var key: String { get set }
var name: String { get set }
Expand Down
2 changes: 0 additions & 2 deletions Sources/App/RouteHandlers/APIRouteHandlers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import Lingo
// var hello = Encaps()
//}


internal class APIHandlers {
private let splitSize = 5
private var order: [String: Int]!
Expand Down Expand Up @@ -79,7 +78,6 @@ internal class APIHandlers {
return response
}


switch format {
case "lines": try response.content.encode(templateKeys.joined(separator: "\n"))
case "json": try response.content.encode(json: self.templates)
Expand Down
6 changes: 3 additions & 3 deletions Sources/App/RouteHandlers/SiteRouteHandlers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ internal class SiteHandlers {
"videoDescriptionString": lingo.localize("videoDescription", locale: locale),
"videoTitleString": lingo.localize("videoTitle", locale: locale),
"footerString": lingo.localize("footer", locale: locale, interpolations: ["templateCount": self.count])]

return leaf.render("index", context)
}
}
Expand All @@ -60,11 +60,11 @@ internal class SiteHandlers {
let leaf = try request.make(LeafRenderer.self)
let lingo = try request.make(Lingo.self)
let locale = request.http.headers.firstValue(name: .acceptLanguage) ?? "en-us"

let context = ["enableCarbon": self.env.isRelease.description,
"titleString": lingo.localize("title", locale: locale),
"descriptionString": lingo.localize("description", locale: locale, interpolations: ["templateCount": self.count])]

return leaf.render("docs", context)
}
}
Expand Down
17 changes: 6 additions & 11 deletions Sources/App/Server.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,35 @@ public class Gitignore {
fileprivate var services: Services
fileprivate let lingoProvider: LingoProvider
fileprivate var middlewares: MiddlewareConfig

public init() {
config = Config.default()
services = Services.default()
middlewares = MiddlewareConfig()
lingoProvider = LingoProvider(defaultLocale: "en", localizationsDir: "Localizations")
}

public func app(_ env: Environment) throws -> Application {
try configure(env: env)
let app = try Application(config: config, environment: env, services: services)

return app
}

private func configure(env: Environment) throws {
let router = EngineRouter.default()
try routes(router, env: env)

services.register(router, as: Router.self)

try services.register(LeafProvider())
try services.register(lingoProvider)

middlewares.use(FileMiddleware.self)
middlewares.use(ErrorMiddleware.self)
services.register(middlewares)
}

/// Register your application's routes here.
private func routes(_ router: Router, env: Environment) throws {
let dataDirectory = URL(fileURLWithPath: DirectoryConfig.detect().workDir, isDirectory: true)
Expand All @@ -53,7 +53,6 @@ public class Gitignore {

let templateController = TemplateController(dataDirectory: dataDirectory, orderFile: orderFile)


let siteHandlers = SiteHandlers(templateController: templateController, env: env)
siteHandlers.createIndexPage(router: router)
siteHandlers.createDocumentsPage(router: router)
Expand All @@ -67,7 +66,3 @@ public class Gitignore {
}

}




0 comments on commit fe164ee

Please sign in to comment.