<commit_before>//
//  NetworkNotifier.swift
//  E-App
//
//  Created by <NAME> on 2/17/16.
//  Copyright © 2016 <NAME>. All rights reserved.
//

import Foundation

class NetworkNotifier:NSObject{
    
    let kNetworkNotifierNotification = "kNetworkNotifierNotificationKey"
    
    var remoteHostName:String!
    
    private var _currentStatus:NetworkStatus!
    var currentStatus:NetworkStatus!{
        get{
            return _currentStatus
        }set(newStatus){
            /* Check if it is the same status as previous */
            if newStatus == _currentStatus{
                return
            }
            
            /* The status is not the same */
            _currentStatus = newStatus
            
            /* Post notifications */
            networkStatusChanged()
        }
    }
    
    private var notifierEnabled:Bool = false
    private var reachables:[Reachability]!
    
    init(withHost host:String) {
        /* Call the super */
        super.init()
        
        /* Initialize the array */
        reachables = [Reachability]()
        remoteHostName = host
        
        /* Setup Notifiers */
        setupNotifiers()
    }
    
    deinit {
        /* Remove the notifiers */
        NSNotificationCenter.defaultCenter().removeObserver(self)
    }
    
    func startNotifier(){
        notifierEnabled = true
    }
    
    func stopNotifier(){
        notifierEnabled = false
    }
    
    func setupNotifiers(){
        /* Create the notifcations for reachability */
        NSNotificationCenter.defaultCenter().addObserver(self, selector:"reachabilityChanged:", name: kReachabilityChangedNotification, object: nil)
        
        /* Remote Host */
        let hostReachability:Reachability = Reachability(hostName: remoteHostName)
        hostReachability.startNotifier()
        reachables.append(hostReachability)
        
//        /* Internet Connection */
//        let internetReachability:Reachability = Reachability.reachabilityForInternetConnection()
//        internetReachability.startNotifier()
//        reachables.append(internetReachability)
//
//        /* Wifi */
//        let wifiReachability = Reachability.reachabilityForLocalWiFi()
//        wifiReachability.startNotifier()
//        reachables.append(wifiReachability)
    }
    
    func reachabilityChanged(notification: NSNotification) {
        /* Grab the reachability object */
        if let reachability = notification.object as? Reachability{
            /* Perform updates on the UI */
            let networkStatus = reachability.currentReachabilityStatus()
            
            /* Set the newtwork Status */
            currentStatus = networkStatus
        }
    }
    
    func networkStatusChanged(){
        /* Ensure that have the notification post enabled */
        if !notifierEnabled{
            return
        }
        
        /* Update the status */
        switch(currentStatus){
        case NotReachable:
            print("not reachable")
            break
        case ReachableViaWiFi:
            print("wifi")
            break
        case ReachableViaWWAN:
            print("wan")
            break
        default:
            break
        }
        
        /* Create the user dictionary */
        let userInfo:Dictionary<String, AnyObject> = [
            "networkStatus": currentStatus.rawValue
        ]
        
        /* Post the notification */
        NSNotificationCenter.defaultCenter().postNotificationName(kNetworkNotifierNotification, object: nil, userInfo: userInfo)
    }
}
<commit_msg>- Added licensing<commit_after>//
//  NetworkNotifier.swift
//  E-App
//
//  Created by <NAME> on 2/17/16.
//  Copyright © 2016 <NAME>. All rights reserved.
//  See LICENSE.txt for licensing information
//

import Foundation

class NetworkNotifier:NSObject{
    
    let kNetworkNotifierNotification = "kNetworkNotifierNotificationKey"
    
    var remoteHostName:String!
    
    private var _currentStatus:NetworkStatus!
    var currentStatus:NetworkStatus!{
        get{
            return _currentStatus
        }set(newStatus){
            /* Check if it is the same status as previous */
            if newStatus == _currentStatus{
                return
            }
            
            /* The status is not the same */
            _currentStatus = newStatus
            
            /* Post notifications */
            networkStatusChanged()
        }
    }
    
    private var notifierEnabled:Bool = false
    private var reachables:[Reachability]!
    
    init(withHost host:String) {
        /* Call the super */
        super.init()
        
        /* Initialize the array */
        reachables = [Reachability]()
        remoteHostName = host
        
        /* Setup Notifiers */
        setupNotifiers()
    }
    
    deinit {
        /* Remove the notifiers */
        NSNotificationCenter.defaultCenter().removeObserver(self)
    }
    
    func startNotifier(){
        notifierEnabled = true
    }
    
    func stopNotifier(){
        notifierEnabled = false
    }
    
    func setupNotifiers(){
        /* Create the notifcations for reachability */
        NSNotificationCenter.defaultCenter().addObserver(self, selector:"reachabilityChanged:", name: kReachabilityChangedNotification, object: nil)
        
        /* Remote Host */
        let hostReachability:Reachability = Reachability(hostName: remoteHostName)
        hostReachability.startNotifier()
        reachables.append(hostReachability)
        
//        /* Internet Connection */
//        let internetReachability:Reachability = Reachability.reachabilityForInternetConnection()
//        internetReachability.startNotifier()
//        reachables.append(internetReachability)
//
//        /* Wifi */
//        let wifiReachability = Reachability.reachabilityForLocalWiFi()
//        wifiReachability.startNotifier()
//        reachables.append(wifiReachability)
    }
    
    func reachabilityChanged(notification: NSNotification) {
        /* Grab the reachability object */
        if let reachability = notification.object as? Reachability{
            /* Perform updates on the UI */
            let networkStatus = reachability.currentReachabilityStatus()
            
            /* Set the newtwork Status */
            currentStatus = networkStatus
        }
    }
    
    func networkStatusChanged(){
        /* Ensure that have the notification post enabled */
        if !notifierEnabled{
            return
        }
        
        /* Update the status */
        switch(currentStatus){
        case NotReachable:
            print("not reachable")
            break
        case ReachableViaWiFi:
            print("wifi")
            break
        case ReachableViaWWAN:
            print("wan")
            break
        default:
            break
        }
        
        /* Create the user dictionary */
        let userInfo:Dictionary<String, AnyObject> = [
            "networkStatus": currentStatus.rawValue
        ]
        
        /* Post the notification */
        NSNotificationCenter.defaultCenter().postNotificationName(kNetworkNotifierNotification, object: nil, userInfo: userInfo)
    }
}

{'fraction_non_alphanumeric': 0.08381903968914793, 'fraction_numerical': 0.002497918401332223, 'mean_word_length': 1.8553882725832012, 'pattern_counts': {'":': 2, '<': 9, '<?xml version=': 0, '>': 9, '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': '4398632', 'n_tokens_mistral': 1834, 'n_tokens_neox': 1807, 'n_words': 411}