<commit_before>//
//  Resource.swift
//  Reactor
//
//  Created by <NAME> on 11/03/2016.
//  Copyright © 2016 Mail Online. All rights reserved.
//

import Foundation

public typealias Header = [String: String]
public typealias Query = [String: String]

// Stolen from chriseidhof/github-issues 😅
public struct Resource: Equatable, CustomStringConvertible {
    
    public let path: String
    public let method: Method
    public let headers: Header
    public let body: NSData?
    public let query: Query
    
    public init(path: String, method: Method, body: NSData? = nil, headers: Header = [:], query: Query = [:]) {
        self.path = path
        self.method = method
        self.body = body
        self.headers = headers
        self.query = query
    }
    
    public var description: String {
        return "Path:\(path)\nMethod:\(method.rawValue)\nHeaders:\(headers)"
    }
}

public func == (lhs: Resource, rhs: Resource) -> Bool {
    
    var equalBody = false
    
    switch (lhs.body, rhs.body) {
    case (nil,nil): equalBody = true
    case (nil,_?): equalBody = false
    case (_?,nil): equalBody = false
    case (let l?,let r?): equalBody = l.isEqualToData(r)
    }
    
    return (lhs.path == rhs.path && lhs.method == rhs.method && equalBody)
}

public enum Method: String {
    case OPTIONS = "OPTIONS"
    case GET = "GET"
    case HEAD = "HEAD"
    case POST = "POST"
    case PUT = "PUT"
    case PATCH = "PATCH"
    case DELETE = "DELETE"
    case TRACE = "TRACE"
    case CONNECT = "CONNECT"
}

extension Resource {
    
    public func toRequest(baseURL: NSURL) -> NSURLRequest {<commit_msg>Omit unnecessary values of `Method` enum<commit_after>//
//  Resource.swift
//  Reactor
//
//  Created by <NAME> on 11/03/2016.
//  Copyright © 2016 Mail Online. All rights reserved.
//

import Foundation

public typealias Header = [String: String]
public typealias Query = [String: String]

// Stolen from chriseidhof/github-issues 😅
public struct Resource: Equatable, CustomStringConvertible {
    
    public let path: String
    public let method: Method
    public let headers: Header
    public let body: NSData?
    public let query: Query
    
    public init(path: String, method: Method, body: NSData? = nil, headers: Header = [:], query: Query = [:]) {
        self.path = path
        self.method = method
        self.body = body
        self.headers = headers
        self.query = query
    }
    
    public var description: String {
        return "Path:\(path)\nMethod:\(method.rawValue)\nHeaders:\(headers)"
    }
}

public func == (lhs: Resource, rhs: Resource) -> Bool {
    
    var equalBody = false
    
    switch (lhs.body, rhs.body) {
    case (nil,nil): equalBody = true
    case (nil,_?): equalBody = false
    case (_?,nil): equalBody = false
    case (let l?,let r?): equalBody = l.isEqualToData(r)
    }
    
    return (lhs.path == rhs.path && lhs.method == rhs.method && equalBody)
}

public enum Method: String {
    case OPTIONS
    case GET
    case HEAD
    case POST
    case PUT
    case PATCH
    case DELETE
    case TRACE
    case CONNECT
}

extension Resource {
    
    public func toRequest(baseURL: NSURL) -> NSURLRequest {
{'fraction_non_alphanumeric': 0.1165625, 'fraction_numerical': 0.0075, 'mean_word_length': 2.540929203539823, 'pattern_counts': {'":': 0, '<': 5, '<?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': '6509821', 'n_tokens_mistral': 1021, 'n_tokens_neox': 991, 'n_words': 316}