<commit_before>//
//  EkgClientHelper.swift
//  ekgclient
//
//  Created by <NAME> on 05/09/2015.
//  Copyright © 2015 <NAME>. All rights reserved.
//

import Foundation

let kTokenKey = "ekg.token"

public class EkgClientHelper {
    
    public static func pullAppIdentifierFromBundle(bundle: NSBundle) -> String? {
        guard let info = bundle.infoDictionary else {
            return nil
        }
        let appId = info["CFBundleIdentifier"] as? String
        return appId
    }
    
    internal static func getLocalToken(userDefaults: NSUserDefaults) -> String {
        //check for an existing token
        if let token = userDefaults.stringForKey(kTokenKey) {
            return token
        }
        //generate a new one
        let newToken = NSUUID().UUIDString
        userDefaults.setObject(newToken, forKey: kTokenKey)
        userDefaults.synchronize()
        return newToken
    }
}<commit_msg>more utility functions<commit_after>//
//  EkgClientHelper.swift
//  ekgclient
//
//  Created by <NAME> on 05/09/2015.
//  Copyright © 2015 <NAME>. All rights reserved.
//

import Foundation

let kTokenKey = "ekg.token"

public class EkgClientHelper {
    
    private static func pullStringFromBundle(key: String, bundle: NSBundle) -> String? {
        guard let info = bundle.infoDictionary else {
            return nil
        }
        let appId = info[key] as? String
        return appId
    }
    
    public static func pullAppIdentifierFromBundle(bundle: NSBundle) -> String? {
        return self.pullStringFromBundle("CFBundleIdentifier", bundle: bundle)
    }
    
    public static func pullVersionFromBundle(bundle: NSBundle) -> String? {
        return self.pullStringFromBundle("CFBundleShortVersionString", bundle: bundle)
    }
    
    public static func pullBuildNumberFromBundle(bundle: NSBundle) -> String? {
        return self.pullStringFromBundle("CFBundleVersion", bundle: bundle)
    }
    
    internal static func getLocalToken(userDefaults: NSUserDefaults) -> String {
        //check for an existing token
        if let token = userDefaults.stringForKey(kTokenKey) {
            return token
        }
        //generate a new one
        let newToken = NSUUID().UUIDString
        userDefaults.setObject(newToken, forKey: kTokenKey)
        userDefaults.synchronize()
        return newToken
    }
}
{'fraction_non_alphanumeric': 0.08793542905692438, 'fraction_numerical': 0.010195412064570943, 'mean_word_length': 2.49925705794948, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 14, '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': '3806663', 'n_tokens_mistral': 678, 'n_tokens_neox': 646, 'n_words': 180}