<commit_before>//
//  Kazaguruma.swift
//  Kazaguruma
//
//  Created by nakajijapan on 2016/01/01.
//
//

import UIKit

open class Kazaguruma: UIView {

    var activityIndicatorView = UIActivityIndicatorView(activityIndicatorStyle: .gray)
    var messageLabel = UILabel()

    override init(frame: CGRect) {
        super.init(frame: frame)

        backgroundColor = .white
        addSubview(activityIndicatorView)

        messageLabel.isHidden = true
        messageLabel.font = UIFont.systemFont(ofSize: 14.0)
        addSubview(messageLabel)

        // AutoLayout
        activityIndicatorView.translatesAutoresizingMaskIntoConstraints = false
        messageLabel.translatesAutoresizingMaskIntoConstraints = false
        [
            self.centerXAnchor.constraint(greaterThanOrEqualTo: activityIndicatorView.centerXAnchor),
            self.centerYAnchor.constraint(greaterThanOrEqualTo: activityIndicatorView.centerYAnchor),
            self.centerXAnchor.constraint(greaterThanOrEqualTo: messageLabel.centerXAnchor),
            activityIndicatorView.bottomAnchor.constraint(equalTo: messageLabel.topAnchor, constant: -8.0),
        ].forEach { $0.isActive = true }
    }

    required public convenience init?(coder aDecoder: NSCoder) {
        self.init(frame: CGRect.zero)
    }

    open class func show(_ toView: UIView,
                         backgroundColor: UIColor = .white,
                         indicatorViewStyle: UIActivityIndicatorViewStyle = .gray,
                         message: String? = nil, afterdelay: TimeInterval = 0.0,
                         enableAutolayout: Bool = true) -> Kazaguruma {
        let indicatorView = Kazaguruma(frame: toView.bounds)

        indicatorView.backgroundColor = backgroundColor
        indicatorView.activityIndicatorView.activityIndicatorViewStyle = indicatorViewStyle
        indicatorView.startAnimating()
        toView.addSubview(indicatorView)

        if (enableAutolayout) {
            indicatorView.translatesAutoresizingMaskIntoConstraints = false
            [
                toView.topAnchor.constraint(equalTo: indicatorView.topAnchor),
                toView.bottomAnchor.constraint(equalTo: indicatorView.bottomAnchor),
                toView.leadingAnchor.constraint(equalTo: indicatorView.leadingAnchor),
                toView.trailingAnchor.constraint(equalTo: indicatorView.trailingAnchor),
            ].forEach { $0.isActive = true }

        }

        // Show Message
        if 0.0 < afterdelay && message != nil {
            indicatorView.messageLabel.text = message
            indicatorView.messageLabel.alpha = 0.0
            indicatorView.messageLabel.isHidden = false
<commit_msg>refactoring<commit_after>//
//  Kazaguruma.swift
//  Kazaguruma
//
//  Created by nakajijapan on 2016/01/01.
//
//

import UIKit

open class Kazaguruma: UIView {

    var activityIndicatorView = UIActivityIndicatorView(activityIndicatorStyle: .gray)
    var messageLabel = UILabel()

    override init(frame: CGRect) {
        super.init(frame: frame)

        backgroundColor = .white
        addSubview(activityIndicatorView)

        messageLabel.isHidden = true
        messageLabel.font = UIFont.systemFont(ofSize: 14.0)
        addSubview(messageLabel)

        // AutoLayout
        activityIndicatorView.translatesAutoresizingMaskIntoConstraints = false
        messageLabel.translatesAutoresizingMaskIntoConstraints = false
        [
            self.centerXAnchor.constraint(greaterThanOrEqualTo: activityIndicatorView.centerXAnchor),
            self.centerYAnchor.constraint(greaterThanOrEqualTo: activityIndicatorView.centerYAnchor),
            self.centerXAnchor.constraint(greaterThanOrEqualTo: messageLabel.centerXAnchor),
            activityIndicatorView.bottomAnchor.constraint(equalTo: messageLabel.topAnchor, constant: -8.0)
        ].forEach { $0.isActive = true }
    }

    required public convenience init?(coder aDecoder: NSCoder) {
        self.init(frame: CGRect.zero)
    }

    open class func show(_ toView: UIView,
                         backgroundColor: UIColor = .white,
                         indicatorViewStyle: UIActivityIndicatorViewStyle = .gray,
                         message: String? = nil, afterdelay: TimeInterval = 0.0,
                         enableAutolayout: Bool = true) -> Kazaguruma {
        let indicatorView = Kazaguruma(frame: toView.bounds)

        indicatorView.backgroundColor = backgroundColor
        indicatorView.activityIndicatorView.activityIndicatorViewStyle = indicatorViewStyle
        indicatorView.startAnimating()
        toView.addSubview(indicatorView)

        if enableAutolayout {
            indicatorView.translatesAutoresizingMaskIntoConstraints = false
            [
                toView.topAnchor.constraint(equalTo: indicatorView.topAnchor),
                toView.bottomAnchor.constraint(equalTo: indicatorView.bottomAnchor),
                toView.leadingAnchor.constraint(equalTo: indicatorView.leadingAnchor),
                toView.trailingAnchor.constraint(equalTo: indicatorView.trailingAnchor)
            ].forEach { $0.isActive = true }

        }

        // Show Message
        if 0.0 < afterdelay && message != nil {
            indicatorView.messageLabel.text = message
            indicatorView.messageLabel.alpha = 0.0
            indicatorView.messageLabel.isHidden = false

{'fraction_non_alphanumeric': 0.0788983997022702, 'fraction_numerical': 0.007815407517677708, 'mean_word_length': 2.5953177257525084, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2340686', 'n_tokens_mistral': 1423, 'n_tokens_neox': 1406, 'n_words': 242}