<commit_before>'use strict';

const _ = require('lodash');

/**
 * Class GadgetController
 */
class GadgetController {

    /**
     * Constructor
     * @param {Jovo} jovo
     */
    constructor(jovo) {
        this.response = jovo.alexaSkill().getResponse();
    }

    /**
     * Sets animations
     * @param {array} animationArray
     * @return {GadgetController}
     */
    setAnimations(animationArray) {
        this.animations = this.animations || [];

        _.forEach(animationArray, (animation) => {
            if (animation instanceof AnimationsBuilder) {
                this.animations.push(animation.build());
            } else {
                this.animations.push(animation);
            }
        });

        return this;
    }

    /**
     * Sets triggerEvent to buttonDown
     * @return {GadgetController}
     */
    setButtonDownTriggerEvent() {
        this.triggerEvent = 'buttonDown';
        return this;
    }

    /**
     * Sets triggerEvent to buttonUp
     * @return {GadgetController}
     */
    setButtonUpTriggerEvent() {
        this.triggerEvent = 'buttonUp';
        return this;
    }

    /**
     * Sets triggerEvent to none
     * @return {GadgetController}
     */
    setNoneTriggerEvent() {
        this.triggerEvent = 'none';
        return this;
    }

    /**
     * Checks if triggerEvent is one of the possible values
     * Throws error if not
     * @param {string} triggerEvent Either 'buttonDown', 'buttonUp' or 'none'
     * @return {GadgetController}
     */
    setTriggerEvent(triggerEvent) {
        let possibleTriggerEventValues = ['buttonDown', 'buttonUp', 'none'];
        if (possibleTriggerEventValues.indexOf(triggerEvent) === -1) {
            throw new Error('report has to be either \'buttonDown\', \'buttonUp\' or \'none\'');
        }
        this.triggerEvent = triggerEvent;
        return this;

    }

    /**
     * Gets AnimationsBuilder instance
     * @return {AnimationsBuilder}
     */
    getAnimationsBuilder() {
        return new AnimationsBuilder();
    }

    /**
     * Gets SequenceBuilder instance
     * @return {SequenceBuilder}
     */
    getSequenceBuilder() {
        return new SequenceBuilder();
    }

    /**
     * Sends GadgetController.StartInputHandler directive
     * @param {array} targetGadgets ids that will receive the command
     * @param {string} triggerEvent Either 'buttonDown', 'buttonUp' or 'none'
     * @param {number} triggerEventTimeMs delay in milliseconds. Minimum: 0. Maximum: 65,535.
     * @param {array} animations one or more animations.
     */
    setLight(targetGadgets, triggerEventTimeMs, triggerEvent,  animations) {
        if (triggerEvent && animations) {
            this.setTriggerEvent(triggerEvent).setAnimations(animations);<commit_msg>:rotating_light: Fixes linter warnings<commit_after>'use strict';

const _ = require('lodash');

/**
 * Class GadgetController
 */
class GadgetController {

    /**
     * Constructor
     * @param {Jovo} jovo
     */
    constructor(jovo) {
        this.response = jovo.alexaSkill().getResponse();
    }

    /**
     * Sets animations
     * @param {array} animationArray
     * @return {GadgetController}
     */
    setAnimations(animationArray) {
        this.animations = this.animations || [];

        _.forEach(animationArray, (animation) => {
            if (animation instanceof AnimationsBuilder) {
                this.animations.push(animation.build());
            } else {
                this.animations.push(animation);
            }
        });

        return this;
    }

    /**
     * Sets triggerEvent to buttonDown
     * @return {GadgetController}
     */
    setButtonDownTriggerEvent() {
        this.triggerEvent = 'buttonDown';
        return this;
    }

    /**
     * Sets triggerEvent to buttonUp
     * @return {GadgetController}
     */
    setButtonUpTriggerEvent() {
        this.triggerEvent = 'buttonUp';
        return this;
    }

    /**
     * Sets triggerEvent to none
     * @return {GadgetController}
     */
    setNoneTriggerEvent() {
        this.triggerEvent = 'none';
        return this;
    }

    /**
     * Checks if triggerEvent is one of the possible values
     * Throws error if not
     * @param {string} triggerEvent Either 'buttonDown', 'buttonUp' or 'none'
     * @return {GadgetController}
     */
    setTriggerEvent(triggerEvent) {
        let possibleTriggerEventValues = ['buttonDown', 'buttonUp', 'none'];
        if (possibleTriggerEventValues.indexOf(triggerEvent) === -1) {
            throw new Error('report has to be either \'buttonDown\', \'buttonUp\' or \'none\'');
        }
        this.triggerEvent = triggerEvent;
        return this;

    }

    /**
     * Gets AnimationsBuilder instance
     * @return {AnimationsBuilder}
     */
    getAnimationsBuilder() {
        return new AnimationsBuilder();
    }

    /**
     * Gets SequenceBuilder instance
     * @return {SequenceBuilder}
     */
    getSequenceBuilder() {
        return new SequenceBuilder();
    }

    /**
     * Sends GadgetController.StartInputHandler directive
     * @param {array} targetGadgets ids that will receive the command
     * @param {number} triggerEventTimeMs delay in milliseconds. Minimum: 0. Maximum: 65,535.
     * @param {string} triggerEvent Either 'buttonDown', 'buttonUp' or 'none'
     * @param {array} animations one or more animations.
     */
    setLight(targetGadgets, triggerEventTimeMs, triggerEvent, animations) {
        if (triggerEvent && animations) {
            this.setTriggerEvent(triggerEvent).setAnimations(animations);
{'fraction_non_alphanumeric': 0.11424491253123885, 'fraction_numerical': 0.0024991074616208496, 'mean_word_length': 2.313424009461857, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '6710015', 'n_tokens_mistral': 1583, 'n_tokens_neox': 1529, 'n_words': 360}