<commit_before>//
//  DebugController.swift
//  shared-utils
//
//  Created by <NAME> on 4/5/17.
//  Copyright © 2017 Two Ring Software. All rights reserved.
//

import Anchorage
import UIKit

enum DebugControllerError: Error {
    case databaseExportError(message: String, underlyingError: Error)
    case noAppsToImportDatabase
}

protocol DebugControllerDelegate {
    func exportedDatabaseData() -> Data?
    func failedToExportDatabase(error: DebugControllerError)
}

class DebugController: NSObject {

    weak var presentingVC: UIViewController!
    fileprivate var delegate: DebugControllerDelegate!

    var documentInteractionController: UIDocumentInteractionController!

    init(delegate: DebugControllerDelegate) {
        super.init()
        self.delegate = delegate
    }

    func displayDebugMenu(fromViewController viewController: UIViewController, databaseFilename: String) {
        presentingVC = viewController
        let alert = UIAlertController(title: "\(Bundle.getAppName()) Debugging", message: nil, preferredStyle: .actionSheet)
        alert.addAction(UIAlertAction(title: "Export Database", style: .default, handler: { action in
            self.exportDatabase(databaseFileName: databaseFilename)
        }))
        alert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: { action in
            self.presentingVC.dismiss(animated: true)
        }))
        presentingVC.present(alert, animated: true)
    }

}

// MARK: Private
private extension DebugController {<commit_msg>update access for DebugController member vars<commit_after>//
//  DebugController.swift
//  shared-utils
//
//  Created by <NAME> on 4/5/17.
//  Copyright © 2017 Two Ring Software. All rights reserved.
//

import Anchorage
import UIKit

enum DebugControllerError: Error {
    case databaseExportError(message: String, underlyingError: Error)
    case noAppsToImportDatabase
}

protocol DebugControllerDelegate {
    func exportedDatabaseData() -> Data?
    func failedToExportDatabase(error: DebugControllerError)
}

class DebugController: NSObject {

    private weak var presentingVC: UIViewController!
    private var delegate: DebugControllerDelegate!

    var documentInteractionController: UIDocumentInteractionController!

    init(delegate: DebugControllerDelegate) {
        super.init()
        self.delegate = delegate
    }

    func displayDebugMenu(fromViewController viewController: UIViewController, databaseFilename: String) {
        presentingVC = viewController
        let alert = UIAlertController(title: "\(Bundle.getAppName()) Debugging", message: nil, preferredStyle: .actionSheet)
        alert.addAction(UIAlertAction(title: "Export Database", style: .default, handler: { action in
            self.exportDatabase(databaseFileName: databaseFilename)
        }))
        alert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: { action in
            self.presentingVC.dismiss(animated: true)
        }))
        presentingVC.present(alert, animated: true)
    }

}

// MARK: Private
private extension DebugController {
{'fraction_non_alphanumeric': 0.08878807517822424, 'fraction_numerical': 0.005184705119896306, 'mean_word_length': 3.8009331259720063, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '402884', 'n_tokens_mistral': 815, 'n_tokens_neox': 780, 'n_words': 210}