<commit_before>//
// This file is part of Nabigeta
//
// Created by JC on 04/11/14.
// For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code
//

import Foundation
import UIKit

public struct Route {
    public let destinationType: UIViewController.Type
    public let storyboardIdentifier: String?

    public fileprivate(set) var presentation: (_ forTrait: UITraitCollection) -> PresentationStrategy

    fileprivate(set) var destination: (_ storyboard: UIStoryboard?) -> AnyNavigableViewController

    public init<Destination: UIViewController>(_ destination: Destination.Type, storyboardIdentifier: String? = nil) where Destination: Navigable {
        self.destinationType = destination
        self.storyboardIdentifier = storyboardIdentifier
        self.presentation = { _ in PresentationPush() }
        self.destination = {
            guard let storyboard = $0, let storyboardIdentifier = storyboardIdentifier else {
                return AnyNavigableViewController(destination.init())
            }

            let viewController = storyboard.instantiateViewController(withIdentifier: storyboardIdentifier)
            return AnyNavigableViewController(viewController as! Destination)
        }
    }

    public mutating func using<Destination: UIViewController>(destination: @escaping () -> Destination) -> Route where Destination: Navigable {
        self.destination = { _ in AnyNavigableViewController(destination()) }

        return self
    }

    public mutating func present(_ presentation: PresentationStrategy) -> Route {
        return self.present { _ in
            presentation
        }
    }

    public mutating func present(when presentation: @escaping (UITraitCollection) -> PresentationStrategy) -> Route {
        self.presentation = presentation

        return self
    }
}<commit_msg>[route] “create” destination at init<commit_after>//
// This file is part of Nabigeta
//
// Created by JC on 04/11/14.
// For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code
//

import Foundation
import UIKit

public struct Route {
    public let destinationType: UIViewController.Type
    public fileprivate(set) var presentation: (_ forTrait: UITraitCollection) -> PresentationStrategy

    let destination: (_ storyboard: UIStoryboard?) -> AnyNavigableViewController

    public init<Destination: UIViewController>(_ destination: Destination.Type, storyboardIdentifier: String? = nil) where Destination: Navigable {
        self.init(destination) {
            guard let storyboard = $0, let storyboardIdentifier = storyboardIdentifier else {
                return destination.init()
            }

            let viewController = storyboard.instantiateViewController(withIdentifier: storyboardIdentifier)
            return viewController as! Destination
        }
    }

    public init<Destination: UIViewController>(_ destination: Destination.Type, using: @escaping (UIStoryboard?) -> Destination) where Destination: Navigable {
        self.destinationType = destination
        self.presentation = { _ in PresentationPush() }
        self.destination = {
            AnyNavigableViewController(using($0))
        }
    }

    public mutating func present(_ presentation: PresentationStrategy) -> Route {
        return self.present { _ in
            presentation
        }
    }

    public mutating func present(when presentation: @escaping (UITraitCollection) -> PresentationStrategy) -> Route {
        self.presentation = presentation

        return self
    }
}
{'fraction_non_alphanumeric': 0.07576173483392808, 'fraction_numerical': 0.0041174855888004395, 'mean_word_length': 3.1788990825688073, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5304939', 'n_tokens_mistral': 902, 'n_tokens_neox': 846, 'n_words': 267}