<commit_before>//
//  CoreDataManager.swift
//  Pods
//
//  Created by DanielMandea on 3/14/17.
//
//

import Foundation
import CoreData

@available(iOS 10.0, *)
public typealias LoadPersistentStoreCompletion = (NSPersistentStoreDescription, Error?) -> Swift.Void

/**
 Use this protocol in order to manage light weight core data stack
 */
public protocol PersistentStore: class {
  /// Holds persistent coordinator continer name !!!!!
  var persistentContainerName: String! {get set}
  
  /// Holds the configuration for the persistent store
  @available(iOS 10.0, *)
  var persistentStoreDescriptions: Array<NSPersistentStoreDescription>! {get set}
  
  /// Holds a refference to the a saving context (bg context)
  var savingContext: NSManagedObjectContext { get }
  
  // Holds a refference to the main context (bg context)
  var mainContext: NSManagedObjectContext { get }
  
  /// Holds the persistent coordinator
  @available(iOS 10.0, *)
  var persistentContainer: NSPersistentContainer { get set }
  
  @available(iOS 10.0, *)
  func setup(with name: String,
             descriptions:Array<NSPersistentStoreDescription>?,
             comletion block:@escaping LoadPersistentStoreCompletion)
}

public let kDefatultContainerName = "Model"

/**
 This is a singletone that enhances work with core data stack
 */

@available(iOS 10.0, *)
private let sharedManager = Persistence()

@available(iOS 10.0, *)
public class Persistence: PersistentStore {
  
  // MARK: - Singletone
  
  public class var store: Persistence {
    return sharedManager
  }
  
  // MARK: - Initialization
  
  init() {
    persistentContainerName = kDefatultContainerName
    let description = NSPersistentStoreDescription()
    description.type = NSSQLiteStoreType
    persistentStoreDescriptions = [description]
  }
  
  // MARK: - PersistentStore
  
  public var persistentContainerName: String!
  public var persistentStoreDescriptions: Array<NSPersistentStoreDescription>!
  
  public var savingContext: NSManagedObjectContext {
    get {
      let context = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
      context.persistentStoreCoordinator = self.persistentContainer.persistentStoreCoordinator
      context.automaticallyMergesChangesFromParent = true
      context.mergePolicy = NSMergeByPropertyObjectTrumpMergePolicy
      return context
    }
  }
  
  public var mainContext: NSManagedObjectContext {
    get {
      let context = NSManagedObjectContext(concurrencyType: .mainQueueConcurrencyType)
      context.persistentStoreCoordinator = self.persistentContainer.persistentStoreCoordinator
      context.automaticallyMergesChangesFromParent = true
      context.mergePolicy = NSMergeByPropertyObjectTrumpMergePolicy
      return context
    }
  }
  
  /**
   The persistent container for the application. This implementation
   creates and returns a container, having loaded the store for the
   application to it. This property is optional since there are legitimate
   error conditions that could cause the creation of the store to fail.
   */
  @available(iOS 10.0, *)
  lazy public var persistentContainer: NSPersistentContainer = {
    let container = NSPersistentContainer(name: persistentContainerName)
    container.persistentStoreDescriptions = persistentStoreDescriptions
    return container
  }()
  
  /**
   Use this method in order to load the persistent store
   - parameter name:          The name of the container
   - parameter descriptions:  The descriptions related to NSPersistentStoreDescription
   - parameter block:         The block that is called after completing the process
   */
  @available(iOS 10.0, *)
  public func setup(with name: String = kDefatultContainerName,
                    descriptions:Array<NSPersistentStoreDescription>?,
                    comletion block:@escaping LoadPersistentStoreCompletion) {
    persistentContainerName = name
    if descriptions != nil {
      persistentStoreDescriptions = descriptions
    }
    persistentContainer.loadPersistentStores(completionHandler: block)
  }
}
<commit_msg>task removed default sql storage.<commit_after>//
//  CoreDataManager.swift
//  Pods
//
//  Created by DanielMandea on 3/14/17.
//
//

import Foundation
import CoreData

@available(iOS 10.0, *)
public typealias LoadPersistentStoreCompletion = (NSPersistentStoreDescription, Error?) -> Swift.Void

/**
 Use this protocol in order to manage light weight core data stack
 */
public protocol PersistentStore: class {
  /// Holds persistent coordinator continer name !!!!!
  var persistentContainerName: String! {get set}
  
  /// Holds the configuration for the persistent store
  @available(iOS 10.0, *)
  var persistentStoreDescriptions: Array<NSPersistentStoreDescription>? {get set}
  
  /// Holds a refference to the a saving context (bg context)
  var savingContext: NSManagedObjectContext { get }
  
  // Holds a refference to the main context (bg context)
  var mainContext: NSManagedObjectContext { get }
  
  /// Holds the persistent coordinator
  @available(iOS 10.0, *)
  var persistentContainer: NSPersistentContainer { get set }
  
  @available(iOS 10.0, *)
  func setup(with name: String,
             descriptions:Array<NSPersistentStoreDescription>?,
             comletion block:@escaping LoadPersistentStoreCompletion)
}

public let kDefatultContainerName = "Model"

/**
 This is a singletone that enhances work with core data stack
 */

@available(iOS 10.0, *)
private let sharedManager = Persistence()

@available(iOS 10.0, *)
public class Persistence: PersistentStore {
  
  // MARK: - Singletone
  
  public class var store: Persistence {
    return sharedManager
  }
  
  // MARK: - Initialization
  
  init() {
    persistentContainerName = kDefatultContainerName
    //    let description = NSPersistentStoreDescription()
    //    description.type = NSSQLiteStoreType
    //    persistentStoreDescriptions = [description]
  }
  
  // MARK: - PersistentStore
  
  public var persistentContainerName: String!
  public var persistentStoreDescriptions: Array<NSPersistentStoreDescription>?
  
  public var savingContext: NSManagedObjectContext {
    get {
      let context = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
      context.persistentStoreCoordinator = self.persistentContainer.persistentStoreCoordinator
      context.automaticallyMergesChangesFromParent = true
      context.mergePolicy = NSMergeByPropertyObjectTrumpMergePolicy
      return context
    }
  }
  
  public var mainContext: NSManagedObjectContext {
    get {
      let context = NSManagedObjectContext(concurrencyType: .mainQueueConcurrencyType)
      context.persistentStoreCoordinator = self.persistentContainer.persistentStoreCoordinator
      context.automaticallyMergesChangesFromParent = true
      context.mergePolicy = NSMergeByPropertyObjectTrumpMergePolicy
      return context
    }
  }
  
  /**
   The persistent container for the application. This implementation
   creates and returns a container, having loaded the store for the
   application to it. This property is optional since there are legitimate
   error conditions that could cause the creation of the store to fail.
   */
  @available(iOS 10.0, *)
  lazy public var persistentContainer: NSPersistentContainer = {
    let container = NSPersistentContainer(name: persistentContainerName)
    if let descriptions = persistentStoreDescriptions {
      container.persistentStoreDescriptions = descriptions
    }
    return container
  }()
  
  /**
   Use this method in order to load the persistent store
   - parameter name:          The name of the container
   - parameter descriptions:  The descriptions related to NSPersistentStoreDescription
   - parameter block:         The block that is called after completing the process
   */
  @available(iOS 10.0, *)
  public func setup(with name: String = kDefatultContainerName,
                    descriptions:Array<NSPersistentStoreDescription>?,
                    comletion block:@escaping LoadPersistentStoreCompletion) {
    persistentContainerName = name
    if descriptions != nil {
      persistentStoreDescriptions = descriptions
    }
    persistentContainer.loadPersistentStores(completionHandler: block)
  }
}
{'fraction_non_alphanumeric': 0.06865599223677826, 'fraction_numerical': 0.007035419699175158, 'mean_word_length': 3.716819221967963, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, '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': '2970049', 'n_tokens_mistral': 2215, 'n_tokens_neox': 2132, 'n_words': 634}