<commit_before>/* jshint node: true */
'use strict';

module.exports = {
  name: 'ember-cli-page-object',

  options: {
    nodeAssets: {
      ceibo: function() {
        return {
          enabled: this._shouldIncludeFiles(),
          import: ['index.js']
        };
      },
      jquery: function() {
        return {
          enabled: this._shouldIncludeFiles(),
          vendor: ['dist/jquery.js'],
          destDir: 'ecpo-jquery'
        }
      }
    }
  },

  included: function() {
    this.app = this._findHost();

    if (this._shouldIncludeFiles()) {
      this.importJquery();
    }

    this._super.included.apply(this, arguments);
  },

  /*
   * Import an amd '-jquery' shim which is used by ember-cli-page-object internally
   * 
   * We don't want ember-cli-page-object's jquery ocassionaly leak into a real application.
   * The following combo of shims supposed to isolate `ember-cli-page-object`'s `jquery` 
   * from the rest of application and expose internal version via amd module.
   */
  importJquery: function() {
    // jquery itself is included in the very beggining of vendor.js.
    // At this point we don't have `define()` defined so we can't create an amd shim here.
    //
    // However we have to store reference to jquery and dispose it from the window
    // in order to prevent its leakage to the application.
    this.import('vendor/shims/ecpo-jquery-global.js', {
      prepend: true
    });
    this.import('vendor/ecpo-jquery/dist/jquery.js', {
      prepend: true
    });

    // finally define an amd shim for our internal jquery version
    this.import('vendor/shims/ecpo-jquery.js');
  },

  treeFor: function(/*name*/) {
    if (!this._shouldIncludeFiles()) {
      return;
    }

    return this._super.treeFor.apply(this, arguments);
  },

  _shouldIncludeFiles: function() {
    return !!this.app.tests;
  },

  _findHost() {
    let current = this;
    let app;<commit_msg>Make it work in EmberTwiddle<commit_after>/* jshint node: true */
'use strict';

module.exports = {
  name: 'ember-cli-page-object',

  options: {
    nodeAssets: {
      ceibo: function() {
        return {
          enabled: this._shouldIncludeFiles(),
          import: ['index.js']
        };
      },
      jquery: function() {
        return {
          enabled: this._shouldIncludeFiles(),
          vendor: ['dist/jquery.js'],
          destDir: 'ecpo-jquery'
        }
      }
    }
  },

  included: function() {
    this.app = this._findHost();

    if (this._shouldIncludeFiles()) {
      this.importJquery();
    }

    this._super.included.apply(this, arguments);
  },

  /*
   * Import an amd '-jquery' shim which is used by ember-cli-page-object internally
   *
   * We don't want ember-cli-page-object's jquery ocassionaly leak into a real application.
   * The following combo of shims supposed to isolate `ember-cli-page-object`'s `jquery`
   * from the rest of application and expose internal version via amd module.
   */
  importJquery: function() {
    // jquery itself is included in the very beggining of vendor.js.
    // At this point we don't have `define()` defined so we can't create an amd shim here.
    //
    // However we have to store reference to jquery and dispose it from the window
    // in order to prevent its leakage to the application.
    this.import('vendor/shims/ecpo-jquery-global.js', {
      prepend: true
    });
    this.import('vendor/ecpo-jquery/dist/jquery.js', {
      prepend: true
    });

    // finally define an amd shim for our internal jquery version
    this.import('vendor/shims/ecpo-jquery.js');
  },

  treeFor: function(/*name*/) {
    if (!this._shouldIncludeFiles()) {
      return;
    }

    return this._super.treeFor.apply(this, arguments);
  },

  _shouldIncludeFiles: function() {
    // TODO: In order to make the addon work in EmberTwiddle, we cannot use // the `tests` prop til
    // https://github.com/joostdevries/twiddle-backend/pull/28 is merged.
    // return !!this.app.tests;
    return this.app.env !== 'production';
  },

  _findHost() {
    let current = this;
    let app;
{'fraction_non_alphanumeric': 0.1259765625, 'fraction_numerical': 0.00048828125, 'mean_word_length': 2.4370805369127515, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, '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': '3445234', 'n_tokens_mistral': 1286, 'n_tokens_neox': 1227, 'n_words': 359}