<commit_before>//
//  StringsFilesSearch.swift
//  BartyCrouch
//
//  Created by <NAME> on 14.02.16.
//  Copyright © 2016 Flinesoft. All rights reserved.
//

import Foundation

/// Searchs for `.strings` files given a base internationalized Storyboard.
public class StringsFilesSearch {
    
    // MARK: - Stored Class Properties
    
    public static let sharedInstance = StringsFilesSearch()
    
    
    // MARK: - Instance Methods
    
    public func findAllIBFiles(baseDirectoryPath: String) -> [String] {
        do {
            let pathsToIgnore = [".git/", "Carthage/", "build/", "docs/"]
            
            let ibFileRegex = try NSRegularExpression(pattern: ".*\\Base.lproj.*\\.(storyboard|xib)\\z", options: .CaseInsensitive)
            let allFilePaths = try NSFileManager.defaultManager().subpathsOfDirectoryAtPath(baseDirectoryPath).filter { !$0.containsAny(ofStrings: pathsToIgnore) }
            let ibFilePaths = allFilePaths.filter { ibFileRegex.matchesInString($0, options: .ReportCompletion, range: NSMakeRange(0, $0.utf16.count)).count > 0 }
            return ibFilePaths.map { baseDirectoryPath + "/" + $0 }
        } catch {
            return []<commit_msg>Clean up IB files pattern<commit_after>//
//  StringsFilesSearch.swift
//  BartyCrouch
//
//  Created by <NAME> on 14.02.16.
//  Copyright © 2016 Flinesoft. All rights reserved.
//

import Foundation

/// Searchs for `.strings` files given a base internationalized Storyboard.
public class StringsFilesSearch {
    
    // MARK: - Stored Class Properties
    
    public static let sharedInstance = StringsFilesSearch()
    
    
    // MARK: - Instance Methods
    
    public func findAllIBFiles(baseDirectoryPath: String) -> [String] {
        do {
            let pathsToIgnore = [".git/", "Carthage/", "build/", "docs/"]
            
            let ibFileRegex = try NSRegularExpression(pattern: ".*\\/Base.lproj.*\\.(storyboard|xib)\\z", options: .CaseInsensitive)
            let allFilePaths = try NSFileManager.defaultManager().subpathsOfDirectoryAtPath(baseDirectoryPath).filter { !$0.containsAny(ofStrings: pathsToIgnore) }
            let ibFilePaths = allFilePaths.filter { ibFileRegex.matchesInString($0, options: .ReportCompletion, range: NSMakeRange(0, $0.utf16.count)).count > 0 }
            return ibFilePaths.map { baseDirectoryPath + "/" + $0 }
        } catch {
            return []
{'fraction_non_alphanumeric': 0.12296790329303876, 'fraction_numerical': 0.015006252605252188, 'mean_word_length': 2.6923076923076925, 'pattern_counts': {'":': 0, '<': 5, '<?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': '2999410', 'n_tokens_mistral': 725, 'n_tokens_neox': 687, 'n_words': 168}