<commit_before>//
//  DecisionLibraryViewController.swift
//  Flowchart
//
//  Created by <NAME> on 5/10/16.
//  Copyright © 2016 <NAME>. All rights reserved.
//

import UIKit

class DecisionLibraryViewController: UICollectionViewController {

    var decisions: [Decision] = [
        Decision(operation: { x in x % 2 == 0 }, title: "Is Even?"),
        Decision(operation: { x in x == 0 }, title: "Is equal to 0?")
    ]


    var didSelectDecision: (Decision) -> () = { _ in }

    override func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        return decisions.count
    }

    override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
        guard let cell = collectionView.dequeueReusableCellWithReuseIdentifier("DecisionCell", forIndexPath: indexPath) as? DecisionCell else { fatalError() }
        return decisions[indexPath.row].configure(cell)
    }

    override func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
        didSelectDecision(decisions[indexPath.row])
    }


}

class DecisionCell: UICollectionViewCell {

    @IBOutlet weak var label: UILabel!

}


extension Decision {

    func configure(cell: DecisionCell) -> DecisionCell {
        cell.label.text = self.title
        return cell
    }

}<commit_msg>Consequences of retyping Decision to Enum<commit_after>//
//  DecisionLibraryViewController.swift
//  Flowchart
//
//  Created by <NAME> on 5/10/16.
//  Copyright © 2016 <NAME>. All rights reserved.
//

import UIKit

class DecisionLibraryViewController: UICollectionViewController {

    var decisions: [Decision] = [
        Decision.IsEven,
        Decision.IsEqualTo(0),
        Decision.IsLessThan(0),
        Decision.IsGreaterThan(0)
    ]

    var didSelectDecision: (Decision) -> () = { _ in }

    override func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        return decisions.count
    }

    override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
        guard let cell = collectionView.dequeueReusableCellWithReuseIdentifier("DecisionCell", forIndexPath: indexPath) as? DecisionCell else { fatalError() }
        cell.layer.borderColor = UIColor.Steel.CGColor
        cell.layer.borderWidth = 1.0
        cell.layer.cornerRadius = 5.0
        cell.backgroundColor = UIColor.Mercury
        return decisions[indexPath.row].configure(cell)
    }

    override func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
        didSelectDecision(decisions[indexPath.row])
    }

}

class DecisionCell: UICollectionViewCell {
    @IBOutlet weak var label: UILabel!
}


extension Decision {

    func configure(cell: DecisionCell) -> DecisionCell {
        cell.label.text = self.title.stringByReplacingOccurrencesOfString(" {Input} ", withString: " ")
        return cell
    }

}
{'fraction_non_alphanumeric': 0.09647134995144059, 'fraction_numerical': 0.009388151505341535, 'mean_word_length': 3.5441176470588234, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 15, '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': '5213306', 'n_tokens_mistral': 924, 'n_tokens_neox': 882, 'n_words': 204}