<commit_before>//
//  ContributorAPI.swift
//  Laurine Example Project
//
//  Created by <NAME>
//  Copyright © 2015 <NAME>. All rights reserved.
//

// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
//MARK: - Import

import Foundation
import Alamofire


// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
//MARK: - Definitions

private let BASE_URL_CONTRIBUTORS : String = "https://api.github.com/repos/JiriTrecak/Laurine/contributors"


// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
// MARK: - Protocols


// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
// MARK: - Implementation

// Declare variable to store singleton into
private let _sharedObject = ContributorAPI()

class ContributorAPI {
    
    // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
    // MARK: - Properties
    
    class var sharedInstance: ContributorAPI {
        return _sharedObject;
    }
    
    
    // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
    // MARK: - Public
    
    func getContributors(_ handler : @escaping (_ contributors : [Contributor]?, _ error : NSError?) -> ()) {
        
//        Alamofire.request(BASE_URL_CONTRIBUTORS, method: .get, parameters: nil, encoding: .JSONEncoding.default)
//            .responseJSON { response in
//                
//                if let JSON = response.result.value as? [NSDictionary] {
//                    
//                    // Create contributors
//                    var output : [Contributor] = []
//                    JSON.forEach({ (data) -> () in
//                        output.append(Contributor(fromDictionary: data))
//                    })
//                    
//                    // Notify caller
//                    handler(contributors: output, error: nil)
//                } else {
//                    handler(contributors: nil, error: response.result.error)
//                }
//        }
    }
    
    
    func updateContributor(_ contributor : Contributor, handler : @escaping (_ contributor : Contributor?, _ error : NSError?) -> ()) {
        
//        Alamofire.request(contributor.detailURL, method: .get, parameters: nil, encoding: .JSONEncoding.default)
//            .responseJSON { response in
//                
//                if let JSON = response.result.value as? NSDictionary {
//                    
//                    // Update contributor
//                    contributor.updateWithDictionary(JSON)
//                    
//                    // Notify caller
//                    handler(contributor: contributor, error: nil)
//                } else {
//                    handler(contributor: nil, error: response.result.error)
//                }
//        }
    }
}





<commit_msg>Fixed example alamofire requests to properly download contributors<commit_after>//
//  ContributorAPI.swift
//  Laurine Example Project
//
//  Created by <NAME>
//  Copyright © 2015 <NAME>. All rights reserved.
//

// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
//MARK: - Import

import Foundation
import Alamofire


// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
//MARK: - Definitions

private let BASE_URL_CONTRIBUTORS : String = "https://api.github.com/repos/JiriTrecak/Laurine/contributors"


// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
// MARK: - Protocols


// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
// MARK: - Implementation

// Declare variable to store singleton into
private let _sharedObject = ContributorAPI()

class ContributorAPI {
    
    // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
    // MARK: - Properties
    
    class var sharedInstance: ContributorAPI {
        return _sharedObject;
    }
    
    
    // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
    // MARK: - Public
    
    func getContributors(_ handler : @escaping (_ contributors : [Contributor]?, _ error : NSError?) -> ()) {
        
        Alamofire.request(BASE_URL_CONTRIBUTORS, method: .get, parameters: nil, encoding: JSONEncoding.default).responseJSON { (response:DataResponse<Any>) in
            if let JSON = response.result.value as? [NSDictionary] {
                
                // Create contributors
                var output : [Contributor] = []
                JSON.forEach({ (data) -> () in
                    output.append(Contributor(fromDictionary: data))
                })
                
                // Notify caller
                handler(output, nil)
            } else {
                handler(nil, response.result.error as NSError?)
            }
        }
    }
    
    
    func updateContributor(_ contributor : Contributor, handler : @escaping (_ contributor : Contributor?, _ error : NSError?) -> ()) {
        
        Alamofire.request(contributor.detailURL, method: .get, parameters: nil, encoding: JSONEncoding.default).responseJSON { (response:DataResponse<Any>) in
            
            if let JSON = response.result.value as? NSDictionary {
                
                // Update contributor
                if contributor.updateWithDictionary(JSON) {
                    
                    // Notify caller
                    handler(contributor, nil)
                }
            } else {
                handler(nil, response.result.error as? NSError)
            }
        }
    }
}






{'fraction_non_alphanumeric': 0.24937572831696353, 'fraction_numerical': 0.001331779590477776, 'mean_word_length': 0.897662665824384, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 15, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 37, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6982911', 'n_tokens_mistral': 1640, 'n_tokens_neox': 1531, 'n_words': 280}