<commit_before>//
//  Created by <NAME> on 11/18/15.
//  Copyright © 2015 <NAME>. All rights reserved.
//

import UIKit

public protocol BorderDesignable {
  /**
    `border-color`, border color
  */
  var borderColor: UIColor? { get set }

  /**
   `border-width`, border width
   */
  var borderWidth: CGFloat { get set }
  
  /**
   border side: Top, Right, Bottom or Left, if not specified, all border sides will display,
   */
  var borderSide: String? { get set }
  
}

public extension BorderDesignable where Self: UIView {
  public func configBorder() {
    // Clear borders
    layer.sublayers?.filter  { $0.name == "borderSideLayer" || $0.name == "borderAllSides" }
        .forEach { $0.removeFromSuperlayer() }      

    guard let unwrappedBorderColor = borderColor where borderWidth > 0 else {
      return
    }
    
    if let unwrappedBorderSide = borderSide, side = BorderSide(rawValue: unwrappedBorderSide) {
      configBorderWithSide(side, borderColor: unwrappedBorderColor)
    } else {
      configBorderForAllSides(unwrappedBorderColor)
    }
  }
  
  private func configBorderWithSide(side: BorderSide, borderColor: UIColor) {
    let border = CALayer()
    border.name = "borderSideLayer"
    border.backgroundColor = borderColor.CGColor
    
    switch side {
    case .Top:
      border.frame = CGRect(x: 0, y: 0, width: bounds.size.width, height: borderWidth)
    case .Right:
      border.frame = CGRect(x: bounds.size.width - borderWidth, y: 0, width: borderWidth, height: bounds.size.height)
    case .Bottom:
      border.frame = CGRect(x: 0, y: bounds.size.height - borderWidth, width: bounds.size.width, height: borderWidth)
    case .Left:
      border.frame = CGRect(x: 0, y: 0, width: borderWidth, height: bounds.size.height)<commit_msg>Better Border Reset<commit_after>//
//  Created by <NAME> on 11/18/15.
//  Copyright © 2015 <NAME>. All rights reserved.
//

import UIKit

public protocol BorderDesignable {
  /**
    `border-color`, border color
  */
  var borderColor: UIColor? { get set }

  /**
   `border-width`, border width
   */
  var borderWidth: CGFloat { get set }
  
  /**
   border side: Top, Right, Bottom or Left, if not specified, all border sides will display,
   */
  var borderSide: String? { get set }
  
}

public extension BorderDesignable where Self: UIView {
  public func configBorder() {
    // Clear borders
    layer.borderColor = nil
    layer.borderWidth = 0
    layer.sublayers?.filter  { $0.name == "borderSideLayer" || $0.name == "borderAllSides" }
        .forEach { $0.removeFromSuperlayer() }      

    guard let unwrappedBorderColor = borderColor where borderWidth > 0 else {
      return
    }
    
    if let unwrappedBorderSide = borderSide, side = BorderSide(rawValue: unwrappedBorderSide) {
      configBorderWithSide(side, borderColor: unwrappedBorderColor)
    } else {
      configBorderForAllSides(unwrappedBorderColor)
    }
  }
  
  private func configBorderWithSide(side: BorderSide, borderColor: UIColor) {
    let border = CALayer()
    border.name = "borderSideLayer"
    border.backgroundColor = borderColor.CGColor
    
    switch side {
    case .Top:
      border.frame = CGRect(x: 0, y: 0, width: bounds.size.width, height: borderWidth)
    case .Right:
      border.frame = CGRect(x: bounds.size.width - borderWidth, y: 0, width: borderWidth, height: bounds.size.height)
    case .Bottom:
      border.frame = CGRect(x: 0, y: bounds.size.height - borderWidth, width: bounds.size.width, height: borderWidth)
    case .Left:
      border.frame = CGRect(x: 0, y: 0, width: borderWidth, height: bounds.size.height)
{'fraction_non_alphanumeric': 0.11191135734072022, 'fraction_numerical': 0.011357340720221607, 'mean_word_length': 3.061867266591676, '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': '6521277', 'n_tokens_mistral': 1170, 'n_tokens_neox': 1109, 'n_words': 313}