<commit_before>_ = require 'underscore'
uuid = require 'node-uuid'

class CouchMuffin
    constructor: (options) ->
        @_dataSourceName = options?.dataSourceName || 'default'
        @_type = options?.type
        @_validate = options?.validate
        @_skipMatch = options?.skipMatch
        @_keyPrefix = options?.keyPrefix || ''
        @_autoId = options?.autoId || ''
        @_trackDates = options?.trackDates
        @_manualId = options?.manualId || false
        @_skipId = options?skipId || false
        @_method = ''

    init: ->
        @_dataSource = @component 'DataSource.Couchbase', @_dataSourceName
        @_validator = @component 'Validator',
            validate: @_validate
            skipMatch: @_skipMatch
        @_cherries = @component 'Cherries'

    _addType: (data) ->
        data._type = @_type if @_type? and data?

    _addCreatedAt: (data) ->
        data._createdAt = new Date().toISOString() if @_trackDates

    _addLastUpdate: (data) ->
        data._lastUpdate = new Date().toISOString() if @_trackDates

    _addId: (data, id) ->
        data._id = id unless @_skipId

    _query: (query, callback) ->
        @_dataSource.bucket.query (new @_dataSource.n1ql.fromString query), (error, result) ->
            callback error if error
            callback null, result

    _createCounter: (callback) ->
        data =
            id: 'counter'
            data: 1
            options:
                validate: false
                match: false
        @insert data, (error) ->
            return callback error if error
            return callback null, 1

    _uuid: ->
        uuid.v4()

    _counter: (callback) ->
        @_dataSource.bucket.counter "#{@_keyPrefix}counter", 1, (error, result) =>
            return @_createCounter callback if error and error.code is 13
            return callback error if error<commit_msg>Rule isArray was added to Validator<commit_after>_ = require 'underscore'
uuid = require 'node-uuid'

class CouchMuffin
    constructor: (options) ->
        @_dataSourceName = options?.dataSourceName || 'default'
        @_type = options?.type
        @_validate = options?.validate
        @_skipMatch = options?.skipMatch
        @_keyPrefix = options?.keyPrefix || ''
        @_autoId = options?.autoId || ''
        @_trackDates = options?.trackDates
        @_manualId = options?.manualId || false
        @_skipId = options?skipId || false
        @_method = ''

    init: ->
        @_dataSource = @component 'DataSource.Couchbase', @_dataSourceName
        @_validator = @component 'Validator',
            validate: @_validate
            skipMatch: @_skipMatch
        @_cherries = @component 'Cherries'

    _addType: (data) ->
        data._type = @_type if @_type? and data?

    _addCreatedAt: (data) ->
        data._createdAt = new Date().toISOString() if @_trackDates

    _addLastUpdate: (data) ->
        data._lastUpdate = new Date().toISOString() if @_trackDates

    _addId: (data, id) ->
        data._id = id unless @_skipId

    _query: (query, callback) ->
        @_dataSource.bucket.query (new @_dataSource.n1ql.fromString query), (error, result) ->
            return callback error if error
            return callback null, result

    _createCounter: (callback) ->
        data =
            id: 'counter'
            data: 1
            options:
                validate: false
                match: false
        @insert data, (error) ->
            return callback error if error
            return callback null, 1

    _uuid: ->
        uuid.v4()

    _counter: (callback) ->
        @_dataSource.bucket.counter "#{@_keyPrefix}counter", 1, (error, result) =>
            return @_createCounter callback if error and error.code is 13
            return callback error if error
{'fraction_non_alphanumeric': 0.11181434599156118, 'fraction_numerical': 0.003691983122362869, 'mean_word_length': 2.1141215106732347, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 29, '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': '1886248', 'n_tokens_mistral': 1104, 'n_tokens_neox': 1067, 'n_words': 284}