<commit_before>//
//  Bundle.swift
//  WolmoCore
//
//  Created by <NAME> on 5/7/16.
//  Copyright © 2016 Wolox. All rights reserved.
//

import Foundation

public extension Bundle {
    /**
     Loads a nib from the bundle.
     
     - parameter nibName: Contains a StringRepresentable nib.
     - returns: The loaded NibType or .none if it don't exists.
     - seealso: loadNibNamed()
     - warning: This may through an ObjC NSException if there is no
        nib with that name in that bundle.
     */
    func loadNib<NibType, T: RawRepresentable>(named nibName: T) -> NibType? where T.RawValue == String {
        return loadNibNamed(nibName.rawValue, owner: self, options: .none)?[0] as? NibType
    }
    
    /**
     Returns the value associated with the specified key in the receiver's
     information property list (Info.plist).
     <commit_msg>Added static var for getting app version in Bundle.main (#158)<commit_after>//
//  Bundle.swift
//  WolmoCore
//
//  Created by <NAME> on 5/7/16.
//  Copyright © 2016 Wolox. All rights reserved.
//

import Foundation

public extension Bundle {
    /**
     Gets the version of the app from `Info.plist` file.
     */
    var appVersion: String? {
        infoDictionary?["CFBundleShortVersionString"] as? String
    }
    
    /**
     Static variable used to retrieve app version from `Bundle.main`.
     
     ## Usage
     ```
        let appVersion = Bundle.mainAppVersion
     ```
     */
    static var mainAppVersion: String? {
        Bundle.main.appVersion
    }
    
    /**
     Loads a nib from the bundle.
     
     - parameter nibName: Contains a StringRepresentable nib.
     - returns: The loaded NibType or .none if it don't exists.
     - seealso: loadNibNamed()
     - warning: This may through an ObjC NSException if there is no
        nib with that name in that bundle.
     */
    func loadNib<NibType, T: RawRepresentable>(named nibName: T) -> NibType? where T.RawValue == String {
        return loadNibNamed(nibName.rawValue, owner: self, options: .none)?[0] as? NibType
    }
    
    /**
     Returns the value associated with the specified key in the receiver's
     information property list (Info.plist).
     
{'fraction_non_alphanumeric': 0.0971843778383288, 'fraction_numerical': 0.009536784741144414, 'mean_word_length': 2.3582317073170733, 'pattern_counts': {'":': 0, '<': 7, '<?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': '359944', 'n_tokens_mistral': 692, 'n_tokens_neox': 646, 'n_words': 232}