<commit_before>//
//  AFURLSource.swift
//  ImageSlideshow
//
//  Created by <NAME> on 30.07.15.
//

import AFNetworking

/// Input Source to image using AFNetworking
@objcMembers
public class AFURLSource: NSObject, InputSource {
    /// url to load
    public var url: URL

    /// placeholder used before image is loaded
    public var placeholder: UIImage?

    /// Initializes a new source with URL and placeholder
    /// - parameter url: a url to load
    /// - parameter placeholder: a placeholder used before image is loaded
    public init(url: URL, placeholder: UIImage? = nil) {
        self.url = url
        self.placeholder = placeholder
        super.init()
    }

    /// Initializes a new source with a URL string
    /// - parameter urlString: a string url to load
    /// - parameter placeholder: a placeholder used before image is loaded
    public init?(urlString: String, placeholder: UIImage? = nil) {
        if let validUrl = URL(string: urlString) {
            self.placeholder = placeholder
            self.url = validUrl
            super.init()
        } else {
            return nil
        }
    }

    public func load(to imageView: UIImageView, with callback: @escaping (UIImage?) -> Void) {
        imageView.setImageWith(URLRequest(url: url), placeholderImage: self.placeholder, success: { (_, _, image: UIImage) in
            callback(image)
        }, failure: { _, _, _ in
            callback(nil)
        })
    }
}<commit_msg>Fix missing placeholder on AFURLSource (#218)<commit_after>//
//  AFURLSource.swift
//  ImageSlideshow
//
//  Created by <NAME> on 30.07.15.
//

import AFNetworking

/// Input Source to image using AFNetworking
@objcMembers
public class AFURLSource: NSObject, InputSource {
    /// url to load
    public var url: URL

    /// placeholder used before image is loaded
    public var placeholder: UIImage?

    /// Initializes a new source with URL and placeholder
    /// - parameter url: a url to load
    /// - parameter placeholder: a placeholder used before image is loaded
    public init(url: URL, placeholder: UIImage? = nil) {
        self.url = url
        self.placeholder = placeholder
        super.init()
    }

    /// Initializes a new source with a URL string
    /// - parameter urlString: a string url to load
    /// - parameter placeholder: a placeholder used before image is loaded
    public init?(urlString: String, placeholder: UIImage? = nil) {
        if let validUrl = URL(string: urlString) {
            self.placeholder = placeholder
            self.url = validUrl
            super.init()
        } else {
            return nil
        }
    }

    public func load(to imageView: UIImageView, with callback: @escaping (UIImage?) -> Void) {
        imageView.setImageWith(URLRequest(url: url), placeholderImage: self.placeholder, success: { (_, _, image: UIImage) in
            callback(image)
        }, failure: { _, _, _ in
            callback(self.placeholder)
        })
    }
}
{'fraction_non_alphanumeric': 0.09909608302644794, 'fraction_numerical': 0.0050217609641781055, 'mean_word_length': 2.244299674267101, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '6434996', 'n_tokens_mistral': 815, 'n_tokens_neox': 789, 'n_words': 281}