<commit_before>//
//  BitBucketServer.swift
//  Buildasaur
//
//  Created by <NAME> on 1/27/16.
//  Copyright © 2016 <NAME>. All rights reserved.
//

import Foundation
import BuildaUtils
import ReactiveCocoa

class BitBucketServer : GitServer {
    
    let endpoints: BitBucketEndpoints
    let cache = InMemoryURLCache()
    
    init(endpoints: BitBucketEndpoints, http: HTTP? = nil) {
        
        self.endpoints = endpoints
        super.init(service: .GitHub, http: http)
    }
    
    override func authChangedSignal() -> Signal<ProjectAuthenticator?, NoError> {
        var res: Signal<ProjectAuthenticator?, NoError>?
        self.endpoints.auth.producer.startWithSignal { res = $0.0 }
        return res!
    }
}

extension BitBucketServer: SourceServerType {
    
    func createStatusFromState(state: BuildState, description: String?, targetUrl: String?) -> StatusType {
        
        let bbState = BitBucketStatus.BitBucketState.fromBuildState(state)
        let key = "Buildasaur"
        let url = targetUrl ?? "https://github.com/czechboy0/Buildasaur"
        return BitBucketStatus(state: bbState, key: key, name: key, description: description, url: url)
    }
    <commit_msg>fix main thread UI calls<commit_after>//
//  BitBucketServer.swift
//  Buildasaur
//
//  Created by <NAME> on 1/27/16.
//  Copyright © 2016 <NAME>. All rights reserved.
//

import Foundation
import BuildaUtils
import ReactiveCocoa

class BitBucketServer : GitServer {
    
    let endpoints: BitBucketEndpoints
    let cache = InMemoryURLCache()
    
    init(endpoints: BitBucketEndpoints, http: HTTP? = nil) {
        
        self.endpoints = endpoints
        super.init(service: .GitHub, http: http)
    }
    
    override func authChangedSignal() -> Signal<ProjectAuthenticator?, NoError> {
        var res: Signal<ProjectAuthenticator?, NoError>?
        self.endpoints.auth.producer.startWithSignal { res = $0.0 }
        return res!.observeOn(UIScheduler())
    }
}

extension BitBucketServer: SourceServerType {
    
    func createStatusFromState(state: BuildState, description: String?, targetUrl: String?) -> StatusType {
        
        let bbState = BitBucketStatus.BitBucketState.fromBuildState(state)
        let key = "Buildasaur"
        let url = targetUrl ?? "https://github.com/czechboy0/Buildasaur"
        return BitBucketStatus(state: bbState, key: key, name: key, description: description, url: url)
    }
    
{'fraction_non_alphanumeric': 0.10368852459016394, 'fraction_numerical': 0.009836065573770493, 'mean_word_length': 2.9626623376623376, 'pattern_counts': {'":': 0, '<': 11, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3512803', 'n_tokens_mistral': 746, 'n_tokens_neox': 719, 'n_words': 178}