content_type
stringclasses 8
values | main_lang
stringclasses 7
values | message
stringlengths 1
50
| sha
stringlengths 40
40
| patch
stringlengths 52
962k
| file_count
int64 1
300
|
|---|---|---|---|---|---|
Javascript
|
Javascript
|
fix uiexplorer header
|
25f78020e1443518887c91ed5d77e3fc911c4609
|
<ide><path>Examples/UIExplorer/UIExplorerApp.ios.js
<ide> class UIExplorerApp extends React.Component {
<ide> _renderNavigation: Function;
<ide> _renderOverlay: Function;
<ide> _renderScene: Function;
<add> _renderCard: Function;
<ide> componentWillMount() {
<ide> this._renderNavigation = this._renderNavigation.bind(this);
<ide> this._renderOverlay = this._renderOverlay.bind(this);
<ide> this._renderScene = this._renderScene.bind(this);
<add> this._renderCard = this._renderCard.bind(this);
<ide> }
<ide> render() {
<ide> return (
<ide> class UIExplorerApp extends React.Component {
<ide> navigationState={stack}
<ide> style={styles.container}
<ide> renderOverlay={this._renderOverlay}
<del> renderScene={this._renderScene}
<add> renderScene={this._renderCard}
<ide> />
<ide> );
<ide> }
<ide> class UIExplorerApp extends React.Component {
<ide> );
<ide> }
<ide>
<del> _renderOverlay(props: NavigationStateRendererProps): ReactElement {
<add> _renderCard(props: NavigationStateRendererProps): ReactElement {
<ide> return (
<ide> <NavigationCard
<ide> index={props.index}
| 1
|
Javascript
|
Javascript
|
move query parameter cofiguration into the route
|
0738330bc1575b2515bdee1c9721e49b93c57cf5
|
<ide><path>packages/ember-routing-views/lib/views/link.js
<ide> var LinkComponent = EmberComponent.extend({
<ide> return false;
<ide> }
<ide>
<del> get(this, '_routing').transitionTo(get(this, 'targetRouteName'), get(this, 'models'), get(this, 'queryParams.values'), get(this, 'attrs.replace'));
<add> var routing = get(this, '_routing');
<add> var targetRouteName = get(this, 'targetRouteName');
<add> var models = get(this, 'models');
<add> var queryParamValues = get(this, 'queryParams.values');
<add> var shouldReplace = get(this, 'attrs.replace');
<add>
<add> routing.transitionTo(targetRouteName, models, queryParamValues, shouldReplace);
<ide> },
<ide>
<ide> queryParams: null,
<ide> var LinkComponent = EmberComponent.extend({
<ide> @property href
<ide> **/
<ide> href: computed('models', 'targetRouteName', '_routing.currentState', function computeLinkViewHref() {
<add>
<ide> if (get(this, 'tagName') !== 'a') { return; }
<ide>
<ide> var targetRouteName = get(this, 'targetRouteName');
<ide> var LinkComponent = EmberComponent.extend({
<ide> if (get(this, 'loading')) { return get(this, 'loadingHref'); }
<ide>
<ide> var routing = get(this, '_routing');
<del> return routing.generateURL(targetRouteName, models, get(this, 'queryParams.values'));
<add> var queryParams = get(this, 'queryParams.values');
<add> return routing.generateURL(targetRouteName, models, queryParams);
<ide> }),
<ide>
<ide> loading: computed('models', 'targetRouteName', function() {
<ide><path>packages/ember-routing/lib/ext/controller.js
<ide> import Ember from "ember-metal/core"; // FEATURES, deprecate
<ide> import { get } from "ember-metal/property_get";
<del>import { set } from "ember-metal/property_set";
<del>import { computed } from "ember-metal/computed";
<del>import { meta } from "ember-metal/utils";
<del>import merge from "ember-metal/merge";
<del>
<ide> import ControllerMixin from "ember-runtime/mixins/controller";
<ide>
<ide> /**
<ide> import ControllerMixin from "ember-runtime/mixins/controller";
<ide> ControllerMixin.reopen({
<ide> concatenatedProperties: ['queryParams'],
<ide>
<del> init() {
<del> this._super(...arguments);
<del> listenForQueryParamChanges(this);
<del> },
<del>
<ide> /**
<ide> Defines which query parameters the controller accepts.
<ide> If you give the names ['category','page'] it will bind
<ide> ControllerMixin.reopen({
<ide> @property _qpDelegate
<ide> @private
<ide> */
<del> _qpDelegate: null,
<del>
<del> /**
<del> @property _normalizedQueryParams
<del> @private
<del> */
<del> _normalizedQueryParams: computed(function() {
<del> var m = meta(this);
<del> if (m.proto !== this) {
<del> return get(m.proto, '_normalizedQueryParams');
<del> }
<del>
<del> var queryParams = get(this, 'queryParams');
<del> if (queryParams._qpMap) {
<del> return queryParams._qpMap;
<del> }
<del>
<del> var qpMap = queryParams._qpMap = {};
<del>
<del> for (var i = 0, len = queryParams.length; i < len; ++i) {
<del> accumulateQueryParamDescriptors(queryParams[i], qpMap);
<del> }
<del>
<del> return qpMap;
<del> }),
<del>
<del> /**
<del> @property _cacheMeta
<del> @private
<del> */
<del> _cacheMeta: computed(function() {
<del> var m = meta(this);
<del> if (m.proto !== this) {
<del> return get(m.proto, '_cacheMeta');
<del> }
<del>
<del> var cacheMeta = {};
<del> var qpMap = get(this, '_normalizedQueryParams');
<del> for (var prop in qpMap) {
<del> if (!qpMap.hasOwnProperty(prop)) { continue; }
<del>
<del> var qp = qpMap[prop];
<del> var scope = qp.scope;
<del> var parts;
<del>
<del> if (scope === 'controller') {
<del> parts = [];
<del> }
<del>
<del> cacheMeta[prop] = {
<del> parts: parts, // provided by route if 'model' scope
<del> values: null, // provided by route
<del> scope: scope,
<del> prefix: "",
<del> def: get(this, prop)
<del> };
<del> }
<del>
<del> return cacheMeta;
<del> }),
<del>
<del> /**
<del> @method _updateCacheParams
<del> @private
<del> */
<del> _updateCacheParams(params) {
<del> var cacheMeta = get(this, '_cacheMeta');
<del> for (var prop in cacheMeta) {
<del> if (!cacheMeta.hasOwnProperty(prop)) { continue; }
<del> var propMeta = cacheMeta[prop];
<del> propMeta.values = params;
<del>
<del> var cacheKey = this._calculateCacheKey(propMeta.prefix, propMeta.parts, propMeta.values);
<del> var cache = this._bucketCache;
<del>
<del> if (cache) {
<del> var value = cache.lookup(cacheKey, prop, propMeta.def);
<del> set(this, prop, value);
<del> }
<del> }
<del> },
<add> _qpDelegate: null, // set by route
<ide>
<ide> /**
<ide> @method _qpChanged
<ide> @private
<ide> */
<ide> _qpChanged(controller, _prop) {
<ide> var prop = _prop.substr(0, _prop.length-3);
<del> var cacheMeta = get(controller, '_cacheMeta');
<del> var propCache = cacheMeta[prop];
<del> var cacheKey = controller._calculateCacheKey(propCache.prefix || "", propCache.parts, propCache.values);
<del> var value = get(controller, prop);
<del>
<del> // 1. Update model-dep cache
<del> var cache = this._bucketCache;
<del> if (cache) {
<del> controller._bucketCache.stash(cacheKey, prop, value);
<del> }
<ide>
<del> // 2. Notify a delegate (e.g. to fire a qp transition)
<ide> var delegate = controller._qpDelegate;
<del> if (delegate) {
<del> delegate(controller, prop);
<del> }
<del> },
<del>
<del> /**
<del> @method _calculateCacheKey
<del> @private
<del> */
<del> _calculateCacheKey(prefix, _parts, values) {
<del> var parts = _parts || [];
<del> var suffixes = "";
<del> for (var i = 0, len = parts.length; i < len; ++i) {
<del> var part = parts[i];
<del> var value = get(values, part);
<del> suffixes += "::" + part + ":" + value;
<del> }
<del> return prefix + suffixes.replace(ALL_PERIODS_REGEX, '-');
<add> var value = get(controller, prop);
<add> delegate(prop, value);
<ide> },
<ide>
<ide> /**
<ide> ControllerMixin.reopen({
<ide> }
<ide> });
<ide>
<del>var ALL_PERIODS_REGEX = /\./g;
<del>
<del>function accumulateQueryParamDescriptors(_desc, accum) {
<del> var desc = _desc;
<del> var tmp;
<del> if (typeof desc === 'string') {
<del> tmp = {};
<del> tmp[desc] = { as: null };
<del> desc = tmp;
<del> }
<del>
<del> for (var key in desc) {
<del> if (!desc.hasOwnProperty(key)) { return; }
<del>
<del> var singleDesc = desc[key];
<del> if (typeof singleDesc === 'string') {
<del> singleDesc = { as: singleDesc };
<del> }
<del>
<del> tmp = accum[key] || { as: null, scope: 'model' };
<del> merge(tmp, singleDesc);
<del>
<del> accum[key] = tmp;
<del> }
<del>}
<del>
<del>function listenForQueryParamChanges(controller) {
<del> var qpMap = get(controller, '_normalizedQueryParams');
<del> for (var prop in qpMap) {
<del> if (!qpMap.hasOwnProperty(prop)) { continue; }
<del> controller.addObserver(prop + '.[]', controller, controller._qpChanged);
<del> }
<del>}
<del>
<del>
<ide> export default ControllerMixin;
<ide><path>packages/ember-routing/lib/services/routing.js
<ide> var RoutingService = Service.extend({
<ide> },
<ide>
<ide> normalizeQueryParams(routeName, models, queryParams) {
<del> get(this, 'router')._prepareQueryParams(routeName, models, queryParams);
<add> var router = get(this, 'router');
<add> router._prepareQueryParams(routeName, models, queryParams);
<ide> },
<ide>
<ide> generateURL(routeName, models, queryParams) {
<ide><path>packages/ember-routing/lib/system/generate_controller.js
<ide> export function generateControllerFactory(container, controllerName, context) {
<ide> */
<ide> export default function generateController(container, controllerName, context) {
<ide> generateControllerFactory(container, controllerName, context);
<add>
<ide> var fullName = `controller:${controllerName}`;
<ide> var instance = container.lookup(fullName);
<ide>
<ide><path>packages/ember-routing/lib/system/route.js
<ide> import EmberObject from "ember-runtime/system/object";
<ide> import Evented from "ember-runtime/mixins/evented";
<ide> import ActionHandler from "ember-runtime/mixins/action_handler";
<ide> import generateController from "ember-routing/system/generate_controller";
<del>import { stashParamNames } from "ember-routing/utils";
<add>import {
<add> generateControllerFactory
<add>} from "ember-routing/system/generate_controller";
<add>import {
<add> stashParamNames,
<add> normalizeControllerQueryParams,
<add> calculateCacheKey
<add>} from "ember-routing/utils";
<ide>
<ide> var slice = Array.prototype.slice;
<ide>
<ide> var Route = EmberObject.extend(ActionHandler, Evented, {
<ide> @property _qp
<ide> */
<ide> _qp: computed(function() {
<del> var controllerName = this.controllerName || this.routeName;
<del> var controllerClass = this.container.lookupFactory(`controller:${controllerName}`);
<add> var controllerProto, combinedQueryParameterConfiguration;
<ide>
<del> if (!controllerClass) {
<del> return defaultQPMeta;
<add> var controllerName = this.controllerName || this.routeName;
<add> var definedControllerClass = this.container.lookupFactory(`controller:${controllerName}`);
<add> var queryParameterConfiguraton = get(this, 'queryParams');
<add> var hasRouterDefinedQueryParams = !!keys(queryParameterConfiguraton).length;
<add>
<add> if (definedControllerClass) {
<add> // the developer has authored a controller class in their application for this route
<add> // access the prototype, find its query params and normalize their object shape
<add> // them merge in the query params for the route. As a mergedProperty, Route#queryParams is always
<add> // at least `{}`
<add> controllerProto = definedControllerClass.proto();
<add>
<add> var controllerDefinedQueryParameterConfiguration = get(controllerProto, 'queryParams');
<add> var normalizedControllerQueryParameterConfiguration = normalizeControllerQueryParams(controllerDefinedQueryParameterConfiguration);
<add>
<add> combinedQueryParameterConfiguration = mergeEachQueryParams(normalizedControllerQueryParameterConfiguration, queryParameterConfiguraton);
<add>
<add> } else if (hasRouterDefinedQueryParams) {
<add> // the developer has not defined a controller but has supplied route query params.
<add> // Generate a class for them so we can later insert default values
<add> var generatedControllerClass = generateControllerFactory(this.container, controllerName);
<add> controllerProto = generatedControllerClass.proto();
<add> combinedQueryParameterConfiguration = queryParameterConfiguraton;
<ide> }
<ide>
<del> var controllerProto = controllerClass.proto();
<del> var qpProps = get(controllerProto, '_normalizedQueryParams');
<del> var cacheMeta = get(controllerProto, '_cacheMeta');
<del>
<ide> var qps = [];
<ide> var map = {};
<del> for (var propName in qpProps) {
<del> if (!qpProps.hasOwnProperty(propName)) { continue; }
<add> var propertyNames = [];
<add>
<add> for (var propName in combinedQueryParameterConfiguration) {
<add> if (!combinedQueryParameterConfiguration.hasOwnProperty(propName)) { continue; }
<add>
<add> // to support the dubious feature of using unknownProperty
<add> // on queryParams configuration
<add> if (propName === 'unknownProperty' || propName === '_super') {
<add> // possible todo: issue deprecation warning?
<add> continue;
<add> }
<add>
<add> var desc = combinedQueryParameterConfiguration[propName];
<add>
<add> // apply default values to controllers
<add> // detect that default value defined on router config
<add> if (desc.hasOwnProperty('defaultValue')) {
<add> // detect that property was not defined on controller
<add> if (controllerProto[propName] === undefined) {
<add> controllerProto[propName] = desc.defaultValue;
<add> }
<add> // else { TODO
<add> // // the default value was set both on route and controller. Throw error;
<add> // }
<add> }
<add>
<add> var scope = desc.scope || 'model';
<add> var parts;
<add>
<add> if (scope === 'controller') {
<add> parts = [];
<add> }
<ide>
<del> var desc = qpProps[propName];
<ide> var urlKey = desc.as || this.serializeQueryParamKey(propName);
<ide> var defaultValue = get(controllerProto, propName);
<ide>
<ide> if (isArray(defaultValue)) {
<ide> defaultValue = Ember.A(defaultValue.slice());
<ide> }
<ide>
<del> var type = typeOf(defaultValue);
<add> var type = desc.type || typeOf(defaultValue);
<add>
<ide> var defaultValueSerialized = this.serializeQueryParam(defaultValue, urlKey, type);
<del> var fprop = `${controllerName}:${propName}`;
<add> var scopedPropertyName = `${controllerName}:${propName}`;
<ide> var qp = {
<del> def: defaultValue,
<del> sdef: defaultValueSerialized,
<add> undecoratedDefaultValue: get(controllerProto, propName),
<add> defaultValue: defaultValue,
<add> serializedDefaultValue: defaultValueSerialized,
<add> serializedValue: defaultValueSerialized,
<add>
<ide> type: type,
<ide> urlKey: urlKey,
<ide> prop: propName,
<del> fprop: fprop,
<add> scopedPropertyName: scopedPropertyName,
<ide> ctrl: controllerName,
<del> cProto: controllerProto,
<del> svalue: defaultValueSerialized,
<del> cacheType: desc.scope,
<ide> route: this,
<del> cacheMeta: cacheMeta[propName]
<add> parts: parts, // provided later when stashNames is called if 'model' scope
<add> values: null, // provided later when setup is called. no idea why.
<add> scope: scope,
<add> prefix: ""
<ide> };
<ide>
<del> map[propName] = map[urlKey] = map[fprop] = qp;
<add> map[propName] = map[urlKey] = map[scopedPropertyName] = qp;
<ide> qps.push(qp);
<add> propertyNames.push(propName);
<ide> }
<ide>
<ide> return {
<ide> qps: qps,
<ide> map: map,
<add> propertyNames: propertyNames,
<ide> states: {
<del> active: (controller, prop) => {
<del> return this._activeQPChanged(controller, map[prop]);
<add> /*
<add> Called when a query parameter changes in the URL, this route cares
<add> about that query parameter, but the route is not currently
<add> in the active route hierarchy.
<add> */
<add> inactive: (prop, value) => {
<add> var qp = map[prop];
<add> this._qpChanged(prop, value, qp);
<add> },
<add> /*
<add> Called when a query parameter changes in the URL, this route cares
<add> about that query parameter, and the route is currently
<add> in the active route hierarchy.
<add> */
<add> active: (prop, value) => {
<add> var qp = map[prop];
<add> this._qpChanged(prop, value, qp);
<add> return this._activeQPChanged(map[prop], value);
<ide> },
<del> allowOverrides: (controller, prop) => {
<del> return this._updatingQPChanged(controller, map[prop]);
<add> /*
<add> Called when a value of a query parameter this route handles changes in a controller
<add> and the route is currently in the active route hierarchy.
<add> */
<add> allowOverrides: (prop, value) => {
<add> var qp = map[prop];
<add> this._qpChanged(prop, value, qp);
<add> return this._updatingQPChanged(map[prop]);
<ide> }
<ide> }
<ide> };
<ide> var Route = EmberObject.extend(ActionHandler, Evented, {
<ide>
<ide> for (var i = 0; i < len; ++i) {
<ide> var qp = qps[i];
<del> var cacheMeta = qp.cacheMeta;
<del> if (cacheMeta.scope === 'model') {
<del> cacheMeta.parts = namePaths;
<add> if (qp.scope === 'model') {
<add> qp.parts = namePaths;
<ide> }
<del> cacheMeta.prefix = qp.ctrl;
<add> qp.prefix = qp.ctrl;
<ide> }
<ide> },
<ide>
<del> /**
<del> @private
<del>
<del> @property _updateSerializedQPValue
<del> */
<del> _updateSerializedQPValue(controller, qp) {
<del> var value = get(controller, qp.prop);
<del> qp.svalue = this.serializeQueryParam(value, qp.urlKey, qp.type);
<del> },
<del>
<ide> /**
<ide> @private
<ide>
<ide> @property _activeQPChanged
<ide> */
<del> _activeQPChanged(controller, qp) {
<del> var value = get(controller, qp.prop);
<del> this.router._queuedQPChanges[qp.fprop] = value;
<del> run.once(this, this._fireQueryParamTransition);
<add> _activeQPChanged(qp, value) {
<add> var router = this.router;
<add> router._activeQPChanged(qp.scopedPropertyName, value);
<ide> },
<ide>
<ide> /**
<ide> @private
<ide> @method _updatingQPChanged
<ide> */
<del> _updatingQPChanged(controller, qp) {
<add> _updatingQPChanged(qp) {
<ide> var router = this.router;
<del> if (!router._qpUpdates) {
<del> router._qpUpdates = {};
<del> }
<del> router._qpUpdates[qp.urlKey] = true;
<add> router._updatingQPChanged(qp.urlKey);
<ide> },
<ide>
<ide> mergedProperties: ['events', 'queryParams'],
<ide> var Route = EmberObject.extend(ActionHandler, Evented, {
<ide> return value;
<ide> },
<ide>
<del>
<del> /**
<del> @private
<del> @property _fireQueryParamTransition
<del> */
<del> _fireQueryParamTransition() {
<del> this.transitionTo({ queryParams: this.router._queuedQPChanges });
<del> this.router._queuedQPChanges = {};
<del> },
<del>
<ide> /**
<ide> @private
<ide>
<ide> var Route = EmberObject.extend(ActionHandler, Evented, {
<ide> */
<ide> _reset(isExiting, transition) {
<ide> var controller = this.controller;
<del>
<del> controller._qpDelegate = null;
<add> controller._qpDelegate = get(this, '_qp.states.inactive');
<ide>
<ide> this.resetController(controller, isExiting, transition);
<ide> },
<ide> var Route = EmberObject.extend(ActionHandler, Evented, {
<ide> value = route.deserializeQueryParam(svalue, qp.urlKey, qp.type);
<ide> } else {
<ide> // No QP provided; use default value.
<del> svalue = qp.sdef;
<del> value = copyDefaultValue(qp.def);
<add> svalue = qp.serializedDefaultValue;
<add> value = copyDefaultValue(qp.defaultValue);
<ide> }
<ide> }
<ide>
<del> controller._qpDelegate = null;
<ide>
<del> var thisQueryParamChanged = (svalue !== qp.svalue);
<add> controller._qpDelegate = get(this, '_qp.states.inactive');
<add>
<add> var thisQueryParamChanged = (svalue !== qp.serializedValue);
<ide> if (thisQueryParamChanged) {
<ide> if (transition.queryParamsOnly && replaceUrl !== false) {
<ide> var options = route._optionsForQueryParam(qp);
<ide> var Route = EmberObject.extend(ActionHandler, Evented, {
<ide> }
<ide>
<ide> // Stash current serialized value of controller.
<del> qp.svalue = svalue;
<add> qp.serializedValue = svalue;
<ide>
<del> var thisQueryParamHasDefaultValue = (qp.sdef === svalue);
<add> var thisQueryParamHasDefaultValue = (qp.serializedDefaultValue === svalue);
<ide> if (!thisQueryParamHasDefaultValue) {
<ide> finalParams.push({
<ide> value: svalue,
<ide> var Route = EmberObject.extend(ActionHandler, Evented, {
<ide> @method setup
<ide> */
<ide> setup(context, transition) {
<add> var controller;
<add>
<ide> var controllerName = this.controllerName || this.routeName;
<del> var controller = this.controllerFor(controllerName, true);
<add> var definedController = this.controllerFor(controllerName, true);
<ide>
<del> if (!controller) {
<add> if (!definedController) {
<ide> controller = this.generateController(controllerName, context);
<add> } else {
<add> controller = definedController;
<ide> }
<ide>
<ide> // Assign the route's controller so that it can more easily be
<del> // referenced in action handlers
<del> this.controller = controller;
<add> // referenced in action handlers. Side effects. Side effects everywhere.
<add> if (!this.controller) {
<add> var propNames = get(this, '_qp.propertyNames');
<add> addQueryParamsObservers(controller, propNames);
<add> this.controller = controller;
<add> }
<ide>
<ide> if (this.setupControllers) {
<ide> Ember.deprecate("Ember.Route.setupControllers is deprecated. Please use Ember.Route.setupController(controller, model) instead.");
<ide> this.setupControllers(controller, context);
<ide> } else {
<del> var states = get(this, '_qp.states');
<add> var queryParams = get(this, '_qp');
<add>
<add> var states = queryParams.states;
<ide> if (transition) {
<ide> // Update the model dep values used to calculate cache keys.
<ide> stashParamNames(this.router, transition.state.handlerInfos);
<del> controller._updateCacheParams(transition.params);
<add>
<add> var params = transition.params;
<add> var allParams = queryParams.propertyNames;
<add> var cache = this._bucketCache;
<add>
<add> forEach(allParams, function(prop) {
<add> var aQp = queryParams.map[prop];
<add>
<add> aQp.values = params;
<add> var cacheKey = calculateCacheKey(aQp.prefix, aQp.parts, aQp.values);
<add>
<add> if (cache) {
<add> var value = cache.lookup(cacheKey, prop, aQp.undecoratedDefaultValue);
<add> set(controller, prop, value);
<add> }
<add> });
<add>
<ide> }
<add>
<ide> controller._qpDelegate = states.allowOverrides;
<ide>
<ide> if (transition) {
<ide> var Route = EmberObject.extend(ActionHandler, Evented, {
<ide> }
<ide> },
<ide>
<add> /*
<add> Called when a query parameter for this route changes, regardless of whether the route
<add> is currently part of the active route hierarchy. This will update the query parameter's
<add> value in the cache so if this route becomes active, the cache value has been updated.
<add> */
<add> _qpChanged(prop, value, qp) {
<add> if (!qp) { return; }
<add>
<add> var cacheKey = calculateCacheKey(qp.prefix || "", qp.parts, qp.values);
<add>
<add> // Update model-dep cache
<add> var cache = this._bucketCache;
<add> if (cache) {
<add> cache.stash(cacheKey, prop, value);
<add> }
<add>
<add> },
<ide> /**
<ide> This hook is the first of the route entry validation hooks
<ide> called when an attempt is made to transition into a route
<ide> var Route = EmberObject.extend(ActionHandler, Evented, {
<ide> */
<ide> model(params, transition) {
<ide> var match, name, sawParams, value;
<del>
<ide> var queryParams = get(this, '_qp.map');
<ide>
<ide> for (var prop in params) {
<ide> var Route = EmberObject.extend(ActionHandler, Evented, {
<ide> in order to populate the URL.
<ide>
<ide> @method serialize
<del> @param {Object} model the route's model
<add> @param {Object} model the routes model
<ide> @param {Array} params an Array of parameter names for the current
<ide> route (in the example, `['post_id']`.
<ide> @return {Object} the serialized parameters
<ide> var Route = EmberObject.extend(ActionHandler, Evented, {
<ide> }
<ide> });
<ide>
<del>var defaultQPMeta = {
<del> qps: [],
<del> map: {},
<del> states: {}
<del>};
<del>
<ide> function parentRoute(route) {
<ide> var handlerInfo = handlerInfoFor(route, route.router.router.state.handlerInfos, -1);
<ide> return handlerInfo && handlerInfo.handler;
<ide> function getQueryParamsFor(route, state) {
<ide> var qpValueWasPassedIn = (qp.prop in fullQueryParams);
<ide> params[qp.prop] = qpValueWasPassedIn ?
<ide> fullQueryParams[qp.prop] :
<del> copyDefaultValue(qp.def);
<add> copyDefaultValue(qp.defaultValue);
<ide> }
<ide>
<ide> return params;
<ide> function copyDefaultValue(value) {
<ide> return value;
<ide> }
<ide>
<add>/*
<add> Merges all query parameters from a controller with those from
<add> a route, returning a new object and avoiding any mutations to
<add> the existing objects.
<add>*/
<add>function mergeEachQueryParams(controllerQP, routeQP) {
<add> var keysMerged = {};
<add>
<add> // needs to be an Ember.Object to support
<add> // getting a query params property unknownProperty.
<add> // It'd be great to deprecate this for 2.0
<add> var qps = {};
<add>
<add> // first loop over all controller qps, merging them any matching route qps
<add> // into a new empty object to avoid mutating.
<add> for (var cqpName in controllerQP) {
<add> if (!controllerQP.hasOwnProperty(cqpName)) { continue; }
<add>
<add> var newControllerParameterConfiguration = {};
<add> merge(newControllerParameterConfiguration, controllerQP[cqpName], routeQP[cqpName]);
<add>
<add> qps[cqpName] = newControllerParameterConfiguration;
<add>
<add> // allows us to skip this QP when we check route QPs.
<add> keysMerged[cqpName] = true;
<add> }
<add>
<add> // loop over all route qps, skipping those that were merged in the first pass
<add> // because they also appear in controller qps
<add> for (var rqpName in routeQP) {
<add> if (!routeQP.hasOwnProperty(rqpName) || keysMerged[rqpName]) { continue; }
<add>
<add> var newRouteParameterConfiguration = {};
<add> merge(newRouteParameterConfiguration, routeQP[rqpName], controllerQP[rqpName]);
<add> qps[rqpName] = newRouteParameterConfiguration;
<add> }
<add>
<add> return qps;
<add>}
<add>
<add>function addQueryParamsObservers(controller, propNames) {
<add> forEach(propNames, function(prop) {
<add> controller.addObserver(prop + '.[]', controller, controller._qpChanged);
<add> });
<add>}
<add>
<ide> export default Route;
<ide><path>packages/ember-routing/lib/system/router.js
<ide> import { defineProperty } from "ember-metal/properties";
<ide> import { computed } from "ember-metal/computed";
<ide> import merge from "ember-metal/merge";
<ide> import run from "ember-metal/run_loop";
<del>
<ide> import { fmt } from "ember-runtime/system/string";
<ide> import EmberObject from "ember-runtime/system/object";
<ide> import Evented from "ember-runtime/mixins/evented";
<ide> import EmberLocation from "ember-routing/location/api";
<ide> import {
<ide> routeArgs,
<ide> getActiveTargetName,
<del> stashParamNames
<add> stashParamNames,
<add> calculateCacheKey
<ide> } from "ember-routing/utils";
<ide> import create from 'ember-metal/platform/create';
<del>
<ide> import RouterState from "./router_state";
<ide>
<ide> /**
<ide> var EmberRouter = EmberObject.extend(Evented, {
<ide> init() {
<ide> this._activeViews = {};
<ide> this._qpCache = {};
<add> this._resetQueuedQueryParameterChanges();
<add> },
<add>
<add> /*
<add> Resets all pending query paramter changes.
<add> Called after transitioning to a new route
<add> based on query parameter changes.
<add> */
<add> _resetQueuedQueryParameterChanges() {
<ide> this._queuedQPChanges = {};
<ide> },
<ide>
<ide> var EmberRouter = EmberObject.extend(Evented, {
<ide> return this._activeViews[templateName];
<ide> },
<ide>
<add> /*
<add> Called when an active route's query parameter has changed.
<add> These changes are batched into a runloop run and trigger
<add> a single transition.
<add> */
<add> _activeQPChanged(queryParameterName, newValue) {
<add> this._queuedQPChanges[queryParameterName] = newValue;
<add> run.once(this, this._fireQueryParamTransition);
<add> },
<add>
<add> _updatingQPChanged(queryParameterName) {
<add> if (!this._qpUpdates) {
<add> this._qpUpdates = {};
<add> }
<add> this._qpUpdates[queryParameterName] = true;
<add> },
<add>
<add> /*
<add> Triggers a transition to a route based on query parameter changes.
<add> This is called once per runloop, to batch changes.
<add>
<add> e.g.
<add>
<add> if these methods are called in succession:
<add> this._activeQPChanged('foo', '10');
<add> // results in _queuedQPChanges = {foo: '10'}
<add> this._activeQPChanged('bar', false);
<add> // results in _queuedQPChanges = {foo: '10', bar: false}
<add>
<add>
<add> _queuedQPChanges will represent both of these changes
<add> and the transition using `transitionTo` will be triggered
<add> once.
<add> */
<add> _fireQueryParamTransition() {
<add> this.transitionTo({ queryParams: this._queuedQPChanges });
<add> this._resetQueuedQueryParameterChanges();
<add> },
<add>
<ide> _connectActiveComponentNode(templateName, componentNode) {
<ide> Ember.assert('cannot connect an activeView that already exists', !this._activeViews[templateName]);
<ide>
<ide> var EmberRouter = EmberObject.extend(Evented, {
<ide> "`%@` and `%@` map to `%@`. You can fix this by mapping " +
<ide> "one of the controller properties to a different query " +
<ide> "param key via the `as` config option, e.g. `%@: { as: 'other-%@' }`",
<del> [qps[0].qp.fprop, qps[1] ? qps[1].qp.fprop : "", qps[0].qp.urlKey, qps[0].qp.prop, qps[0].qp.prop]), qps.length <= 1);
<add> [qps[0].qp.scopedPropertyName, qps[1] ? qps[1].qp.scopedPropertyName : "", qps[0].qp.urlKey, qps[0].qp.prop, qps[0].qp.prop]), qps.length <= 1);
<ide> var qp = qps[0].qp;
<ide> queryParams[qp.urlKey] = qp.route.serializeQueryParam(qps[0].value, qp.urlKey, qp.type);
<ide> }
<ide> var EmberRouter = EmberObject.extend(Evented, {
<ide> var qps = this._queryParamsFor(targetRouteName);
<ide> for (var key in queryParams) {
<ide> var qp = qps.map[key];
<del> if (qp && qp.sdef === queryParams[key]) {
<add> if (qp && qp.serializedDefaultValue === queryParams[key]) {
<ide> delete queryParams[key];
<ide> }
<ide> }
<ide> var EmberRouter = EmberObject.extend(Evented, {
<ide> };
<ide> },
<ide>
<del> /*
<del> becomeResolved: function(payload, resolvedContext) {
<del> var params = this.serialize(resolvedContext);
<del>
<del> if (payload) {
<del> this.stashResolvedModel(payload, resolvedContext);
<del> payload.params = payload.params || {};
<del> payload.params[this.name] = params;
<del> }
<del>
<del> return this.factory('resolved', {
<del> context: resolvedContext,
<del> name: this.name,
<del> handler: this.handler,
<del> params: params
<del> });
<del> },
<del> */
<del>
<ide> _hydrateUnsuppliedQueryParams(leafRouteName, contexts, queryParams) {
<ide> var state = calculatePostTransitionState(this, leafRouteName, contexts);
<ide> var handlerInfos = state.handlerInfos;
<ide> var appCache = this._bucketCache;
<del>
<ide> stashParamNames(this, handlerInfos);
<ide>
<ide> for (var i = 0, len = handlerInfos.length; i < len; ++i) {
<ide> var EmberRouter = EmberObject.extend(Evented, {
<ide>
<ide> for (var j = 0, qpLen = qpMeta.qps.length; j < qpLen; ++j) {
<ide> var qp = qpMeta.qps[j];
<add>
<ide> var presentProp = qp.prop in queryParams && qp.prop ||
<del> qp.fprop in queryParams && qp.fprop;
<add> qp.scopedPropertyName in queryParams && qp.scopedPropertyName;
<ide>
<ide> if (presentProp) {
<del> if (presentProp !== qp.fprop) {
<del> queryParams[qp.fprop] = queryParams[presentProp];
<add> if (presentProp !== qp.scopedPropertyName) {
<add> queryParams[qp.scopedPropertyName] = queryParams[presentProp];
<ide> delete queryParams[presentProp];
<ide> }
<ide> } else {
<del> var controllerProto = qp.cProto;
<del> var cacheMeta = get(controllerProto, '_cacheMeta');
<del>
<del> var cacheKey = controllerProto._calculateCacheKey(qp.ctrl, cacheMeta[qp.prop].parts, state.params);
<del> queryParams[qp.fprop] = appCache.lookup(cacheKey, qp.prop, qp.def);
<add> var cacheKey = calculateCacheKey(qp.ctrl, qp.parts, state.params);
<add> queryParams[qp.scopedPropertyName] = appCache.lookup(cacheKey, qp.prop, qp.defaultValue);
<ide> }
<ide> }
<ide> }
<ide><path>packages/ember-routing/lib/utils.js
<add>import merge from "ember-metal/merge";
<add>import { get } from "ember-metal/property_get";
<add>
<ide> export function routeArgs(targetRouteName, models, queryParams) {
<ide> var args = [];
<ide> if (typeof targetRouteName === 'string') {
<ide> export function stashParamNames(router, handlerInfos) {
<ide>
<ide> handlerInfos._namesStashed = true;
<ide> }
<add>
<add>/*
<add> Stolen from Controller
<add>*/
<add>export function calculateCacheKey(prefix, _parts, values) {
<add> var parts = _parts || [];
<add> var suffixes = "";
<add> for (var i = 0, len = parts.length; i < len; ++i) {
<add> var part = parts[i];
<add> var value = get(values, part);
<add> suffixes += "::" + part + ":" + value;
<add> }
<add> return prefix + suffixes.replace(ALL_PERIODS_REGEX, '-');
<add>}
<add>var ALL_PERIODS_REGEX = /\./g;
<add>
<add>
<add>/*
<add> Controller-defined query parameters can come in three shapes:
<add>
<add> Array
<add> queryParams: ['foo', 'bar']
<add> Array of simple objects where value is an alias
<add> queryParams: [
<add> {
<add> 'foo': 'rename_foo_to_this'
<add> },
<add> {
<add> 'bar': 'call_bar_this_instead'
<add> }
<add> ]
<add> Array of fully defined objects
<add> queryParams: [
<add> {
<add> 'foo': {
<add> as: 'rename_foo_to_this'
<add> },
<add> }
<add> {
<add> 'bar': {
<add> as: 'call_bar_this_instead',
<add> scope: 'controller'
<add> }
<add> }
<add> ]
<add>
<add> This helper normalizes all three possible styles into the
<add> 'Array of fully defined objects' style.
<add>*/
<add>export function normalizeControllerQueryParams(queryParams) {
<add> if (queryParams._qpMap) {
<add> return queryParams._qpMap;
<add> }
<add>
<add> var qpMap = queryParams._qpMap = {};
<add>
<add> for (var i = 0, len = queryParams.length; i < len; ++i) {
<add> accumulateQueryParamDescriptors(queryParams[i], qpMap);
<add> }
<add>
<add> return qpMap;
<add>}
<add>
<add>function accumulateQueryParamDescriptors(_desc, accum) {
<add> var desc = _desc;
<add> var tmp;
<add> if (typeof desc === 'string') {
<add> tmp = {};
<add> tmp[desc] = { as: null };
<add> desc = tmp;
<add> }
<add>
<add> for (var key in desc) {
<add> if (!desc.hasOwnProperty(key)) { return; }
<add>
<add> var singleDesc = desc[key];
<add> if (typeof singleDesc === 'string') {
<add> singleDesc = { as: singleDesc };
<add> }
<add>
<add> tmp = accum[key] || { as: null, scope: 'model' };
<add> merge(tmp, singleDesc);
<add>
<add> accum[key] = tmp;
<add> }
<add>}
<ide><path>packages/ember-routing/tests/utils_test.js
<add>import {
<add> normalizeControllerQueryParams
<add>} from "ember-routing/utils";
<add>
<add>
<add>QUnit.module("Routing query parameter utils - normalizeControllerQueryParams");
<add>
<add>QUnit.test("returns the cached value if that has been previously set", function(assert) {
<add> var cached = {};
<add> var params = ['foo'];
<add> params._qpMap = cached;
<add>
<add> var normalized = normalizeControllerQueryParams(params);
<add> equal(cached, normalized, "cached value returned if previously set");
<add>});
<add>
<add>QUnit.test("converts array style into verbose object style", function(assert) {
<add> var paramName = 'foo';
<add> var params = [paramName];
<add> var normalized = normalizeControllerQueryParams(params);
<add>
<add> ok(normalized[paramName], "turns the query param name into key");
<add> equal(normalized[paramName].as, null, "includes a blank alias in 'as' key");
<add> equal(normalized[paramName].scope, "model", "defaults scope to model");
<add>});
<add>
<add>QUnit.test("converts object stlye [{foo: 'an_alias'}]", function(assert) {
<add> var paramName = 'foo';
<add> var params = [{ 'foo': 'an_alias' }];
<add> var normalized = normalizeControllerQueryParams(params);
<add>
<add> ok(normalized[paramName], "retains the query param name as key");
<add> equal(normalized[paramName].as, 'an_alias', "includes the provided alias in 'as' key");
<add> equal(normalized[paramName].scope, "model", "defaults scope to model");
<add>});
<add>
<add>QUnit.test("retains maximally verbose object stlye [{foo: {as: 'foo'}}]", function(assert) {
<add> var paramName = 'foo';
<add> var params = [{ 'foo': { as: 'an_alias' } }];
<add> var normalized = normalizeControllerQueryParams(params);
<add>
<add> ok(normalized[paramName], "retains the query param name as key");
<add> equal(normalized[paramName].as, 'an_alias', "includes the provided alias in 'as' key");
<add> equal(normalized[paramName].scope, "model", "defaults scope to model");
<add>});
<ide><path>packages/ember/tests/helpers/link_to_test.js
<ide> QUnit.test("supplied QP properties can be bound (booleans)", function() {
<ide> });
<ide>
<ide> QUnit.test("href updates when unsupplied controller QP props change", function() {
<add> Ember.TEMPLATES.index = compile("{{#link-to (query-params foo='lol') id='the-link'}}Index{{/link-to}}");
<add>
<add> bootApplication();
<ide> var indexController = container.lookup('controller:index');
<add>
<add> equal(Ember.$('#the-link').attr('href'), '/?foo=lol');
<add> Ember.run(indexController, 'set', 'bar', 'BORF');
<add> equal(Ember.$('#the-link').attr('href'), '/?bar=BORF&foo=lol');
<add> Ember.run(indexController, 'set', 'foo', 'YEAH');
<add> equal(Ember.$('#the-link').attr('href'), '/?bar=BORF&foo=lol');
<add>});
<add>
<add>QUnit.test("The {{link-to}} applies activeClass when query params are not changed", function() {
<add> Ember.TEMPLATES.index = compile(
<add> "{{#link-to (query-params foo='cat') id='cat-link'}}Index{{/link-to}} " +
<add> "{{#link-to (query-params foo='dog') id='dog-link'}}Index{{/link-to}} " +
<add> "{{#link-to 'index' id='change-nothing'}}Index{{/link-to}}"
<add> );
<add>
<add> Ember.TEMPLATES.search = compile(
<add> "{{#link-to (query-params search='same') id='same-search'}}Index{{/link-to}} " +
<add> "{{#link-to (query-params search='change') id='change-search'}}Index{{/link-to}} " +
<add> "{{#link-to (query-params search='same' archive=true) id='same-search-add-archive'}}Index{{/link-to}} " +
<add> "{{#link-to (query-params archive=true) id='only-add-archive'}}Index{{/link-to}} " +
<add> "{{#link-to (query-params search='same' archive=true) id='both-same'}}Index{{/link-to}} " +
<add> "{{#link-to (query-params search='different' archive=true) id='change-one'}}Index{{/link-to}} " +
<add> "{{#link-to (query-params search='different' archive=false) id='remove-one'}}Index{{/link-to}} " +
<add> "{{outlet}}"
<add> );
<add>
<add> Ember.TEMPLATES['search/results'] = compile(
<add> "{{#link-to (query-params sort='title') id='same-sort-child-only'}}Index{{/link-to}} " +
<add> "{{#link-to (query-params search='same') id='same-search-parent-only'}}Index{{/link-to}} " +
<add> "{{#link-to (query-params search='change') id='change-search-parent-only'}}Index{{/link-to}} " +
<add> "{{#link-to (query-params search='same' sort='title') id='same-search-same-sort-child-and-parent'}}Index{{/link-to}} " +
<add> "{{#link-to (query-params search='same' sort='author') id='same-search-different-sort-child-and-parent'}}Index{{/link-to}} " +
<add> "{{#link-to (query-params search='change' sort='title') id='change-search-same-sort-child-and-parent'}}Index{{/link-to}} " +
<add> "{{#link-to (query-params foo='dog') id='dog-link'}}Index{{/link-to}} "
<add> );
<add>
<add> Router.map(function() {
<add> this.resource("search", function() {
<add> this.route("results");
<add> });
<add> });
<add>
<add> App.SearchController = Ember.Controller.extend({
<add> queryParams: ['search', 'archive'],
<add> search: '',
<add> archive: false
<add> });
<add>
<add> App.SearchResultsController = Ember.Controller.extend({
<add> queryParams: ['sort', 'showDetails'],
<add> sort: 'title',
<add> showDetails: true
<add> });
<add>
<add> bootApplication();
<add>
<add> //Basic tests
<add> shouldNotBeActive('#cat-link');
<add> shouldNotBeActive('#dog-link');
<add> Ember.run(router, 'handleURL', '/?foo=cat');
<add> shouldBeActive('#cat-link');
<add> shouldNotBeActive('#dog-link');
<add> Ember.run(router, 'handleURL', '/?foo=dog');
<add> shouldBeActive('#dog-link');
<add> shouldNotBeActive('#cat-link');
<add> shouldBeActive('#change-nothing');
<add>
<add> //Multiple params
<add> Ember.run(function() {
<add> router.handleURL("/search?search=same");
<add> });
<add> shouldBeActive('#same-search');
<add> shouldNotBeActive('#change-search');
<add> shouldNotBeActive('#same-search-add-archive');
<add> shouldNotBeActive('#only-add-archive');
<add> shouldNotBeActive('#remove-one');
<add>
<add> Ember.run(function() {
<add> router.handleURL("/search?search=same&archive=true");
<add> });
<add> shouldBeActive('#both-same');
<add> shouldNotBeActive('#change-one');
<add>
<add> //Nested Controllers
<add> Ember.run(function() {
<add> // Note: this is kind of a strange case; sort's default value is 'title',
<add> // so this URL shouldn't have been generated in the first place, but
<add> // we should also be able to gracefully handle these cases.
<add> router.handleURL("/search/results?search=same&sort=title&showDetails=true");
<add> });
<add> //shouldBeActive('#same-sort-child-only');
<add> shouldBeActive('#same-search-parent-only');
<add> shouldNotBeActive('#change-search-parent-only');
<add> shouldBeActive('#same-search-same-sort-child-and-parent');
<add> shouldNotBeActive('#same-search-different-sort-child-and-parent');
<add> shouldNotBeActive('#change-search-same-sort-child-and-parent');
<add>});
<add>
<add>QUnit.test("The {{link-to}} applies active class when query-param is number", function() {
<add> Ember.TEMPLATES.index = compile(
<add> "{{#link-to (query-params page=pageNumber) id='page-link'}}Index{{/link-to}} ");
<add>
<add> App.IndexController = Ember.Controller.extend({
<add> queryParams: ['page'],
<add> page: 1,
<add> pageNumber: 5
<add> });
<add>
<add> bootApplication();
<add>
<add> shouldNotBeActive('#page-link');
<add> Ember.run(router, 'handleURL', '/?page=5');
<add> shouldBeActive('#page-link');
<add>});
<add>
<add>QUnit.test("The {{link-to}} applies active class when query-param is array", function() {
<add> Ember.TEMPLATES.index = compile(
<add> "{{#link-to (query-params pages=pagesArray) id='array-link'}}Index{{/link-to}} " +
<add> "{{#link-to (query-params pages=biggerArray) id='bigger-link'}}Index{{/link-to}} " +
<add> "{{#link-to (query-params pages=emptyArray) id='empty-link'}}Index{{/link-to}} "
<add> );
<add>
<add> App.IndexController = Ember.Controller.extend({
<add> queryParams: ['pages'],
<add> pages: [],
<add> pagesArray: [1,2],
<add> biggerArray: [1,2,3],
<add> emptyArray: []
<add> });
<add>
<add> bootApplication();
<add>
<add> shouldNotBeActive('#array-link');
<add> Ember.run(router, 'handleURL', '/?pages=%5B1%2C2%5D');
<add> shouldBeActive('#array-link');
<add> shouldNotBeActive('#bigger-link');
<add> shouldNotBeActive('#empty-link');
<add> Ember.run(router, 'handleURL', '/?pages=%5B2%2C1%5D');
<add> shouldNotBeActive('#array-link');
<add> shouldNotBeActive('#bigger-link');
<add> shouldNotBeActive('#empty-link');
<add> Ember.run(router, 'handleURL', '/?pages=%5B1%2C2%2C3%5D');
<add> shouldBeActive('#bigger-link');
<add> shouldNotBeActive('#array-link');
<add> shouldNotBeActive('#empty-link');
<add>});
<add>
<add>QUnit.test("The {{link-to}} helper applies active class to parent route", function() {
<add> App.Router.map(function() {
<add> this.resource('parent', function() {
<add> this.route('child');
<add> });
<add> });
<add>
<add> Ember.TEMPLATES.application = compile(
<add> "{{#link-to 'parent' id='parent-link'}}Parent{{/link-to}} " +
<add> "{{#link-to 'parent.child' id='parent-child-link'}}Child{{/link-to}} " +
<add> "{{#link-to 'parent' (query-params foo=cat) id='parent-link-qp'}}Parent{{/link-to}} " +
<add> "{{outlet}}"
<add> );
<add>
<add> App.ParentChildController = Ember.Controller.extend({
<add> queryParams: ['foo'],
<add> foo: 'bar'
<add> });
<add>
<add> bootApplication();
<add> shouldNotBeActive('#parent-link');
<add> shouldNotBeActive('#parent-child-link');
<add> shouldNotBeActive('#parent-link-qp');
<add> Ember.run(router, 'handleURL', '/parent/child?foo=dog');
<add> shouldBeActive('#parent-link');
<add> shouldNotBeActive('#parent-link-qp');
<add>});
<add>
<add>QUnit.test("The {{link-to}} helper disregards query-params in activeness computation when current-when specified", function() {
<add> App.Router.map(function() {
<add> this.route('parent');
<add> });
<add>
<add> Ember.TEMPLATES.application = compile(
<add> "{{#link-to 'parent' (query-params page=1) current-when='parent' id='app-link'}}Parent{{/link-to}} {{outlet}}");
<add> Ember.TEMPLATES.parent = compile(
<add> "{{#link-to 'parent' (query-params page=1) current-when='parent' id='parent-link'}}Parent{{/link-to}} {{outlet}}");
<add>
<add> App.ParentController = Ember.Controller.extend({
<add> queryParams: ['page'],
<add> page: 1
<add> });
<add>
<add> bootApplication();
<add> equal(Ember.$('#app-link').attr('href'), '/parent');
<add> shouldNotBeActive('#app-link');
<add>
<add> Ember.run(router, 'handleURL', '/parent?page=2');
<add> equal(Ember.$('#app-link').attr('href'), '/parent');
<add> shouldBeActive('#app-link');
<add> equal(Ember.$('#parent-link').attr('href'), '/parent');
<add> shouldBeActive('#parent-link');
<add>
<add> var parentController = container.lookup('controller:parent');
<add> equal(parentController.get('page'), 2);
<add> Ember.run(parentController, 'set', 'page', 3);
<add> equal(router.get('location.path'), '/parent?page=3');
<add> shouldBeActive('#app-link');
<add> shouldBeActive('#parent-link');
<add>
<add> Ember.$('#app-link').click();
<add> equal(router.get('location.path'), '/parent');
<add>});
<add>
<add>QUnit.module("The {{link-to}} helper: invoking with query params when defined on a route", {
<add> setup() {
<add> Ember.run(function() {
<add> sharedSetup();
<add> App.IndexController = Ember.Controller.extend({
<add> boundThing: 'OMG'
<add> });
<add>
<add> App.IndexRoute = Ember.Route.extend({
<add> queryParams: {
<add> foo: {
<add> defaultValue: '123'
<add> },
<add> bar: {
<add> defaultValue: 'abc'
<add> },
<add> abool: {
<add> defaultValue: true
<add> }
<add> }
<add> });
<add>
<add> App.AboutRoute = Ember.Route.extend({
<add> queryParams: {
<add> baz: {
<add> defaultValue: 'alex'
<add> },
<add> bat: {
<add> defaultValue: 'borf'
<add> }
<add> }
<add> });
<add>
<add> registry.unregister('router:main');
<add> registry.register('router:main', Router);
<add> });
<add> },
<add>
<add> teardown: sharedTeardown
<add>});
<add>
<add>QUnit.test("doesn't update controller QP properties on current route when invoked", function() {
<add> Ember.TEMPLATES.index = compile("{{#link-to 'index' id='the-link'}}Index{{/link-to}}");
<add> bootApplication();
<add>
<add> Ember.run(Ember.$('#the-link'), 'click');
<add> var indexController = container.lookup('controller:index');
<add> deepEqual(indexController.getProperties('foo', 'bar'), { foo: '123', bar: 'abc' }, "controller QP properties not");
<add>});
<add>
<add>QUnit.test("doesn't update controller QP properties on current route when invoked (empty query-params obj)", function() {
<add> Ember.TEMPLATES.index = compile("{{#link-to 'index' (query-params) id='the-link'}}Index{{/link-to}}");
<add> bootApplication();
<add>
<add> Ember.run(Ember.$('#the-link'), 'click');
<add> var indexController = container.lookup('controller:index');
<add> deepEqual(indexController.getProperties('foo', 'bar'), { foo: '123', bar: 'abc' }, "controller QP properties not");
<add>});
<add>
<add>QUnit.test("link-to with no params throws", function() {
<add> Ember.TEMPLATES.index = compile("{{#link-to id='the-link'}}Index{{/link-to}}");
<add> expectAssertion(function() {
<add> bootApplication();
<add> }, /one or more/);
<add>});
<add>
<add>QUnit.test("doesn't update controller QP properties on current route when invoked (empty query-params obj, inferred route)", function() {
<add> Ember.TEMPLATES.index = compile("{{#link-to (query-params) id='the-link'}}Index{{/link-to}}");
<add> bootApplication();
<add>
<add> Ember.run(Ember.$('#the-link'), 'click');
<add> var indexController = container.lookup('controller:index');
<add> deepEqual(indexController.getProperties('foo', 'bar'), { foo: '123', bar: 'abc' }, "controller QP properties not");
<add>});
<add>
<add>QUnit.test("updates controller QP properties on current route when invoked", function() {
<add> Ember.TEMPLATES.index = compile("{{#link-to 'index' (query-params foo='456') id='the-link'}}Index{{/link-to}}");
<add> bootApplication();
<add>
<add> Ember.run(Ember.$('#the-link'), 'click');
<add> var indexController = container.lookup('controller:index');
<add> deepEqual(indexController.getProperties('foo', 'bar'), { foo: '456', bar: 'abc' }, "controller QP properties updated");
<add>});
<add>
<add>QUnit.test("updates controller QP properties on current route when invoked (inferred route)", function() {
<add> Ember.TEMPLATES.index = compile("{{#link-to (query-params foo='456') id='the-link'}}Index{{/link-to}}");
<add> bootApplication();
<add>
<add> Ember.run(Ember.$('#the-link'), 'click');
<add> var indexController = container.lookup('controller:index');
<add> deepEqual(indexController.getProperties('foo', 'bar'), { foo: '456', bar: 'abc' }, "controller QP properties updated");
<add>});
<add>
<add>QUnit.test("updates controller QP properties on other route after transitioning to that route", function() {
<add> Router.map(function() {
<add> this.route('about');
<add> });
<add>
<add> Ember.TEMPLATES.index = compile("{{#link-to 'about' (query-params baz='lol') id='the-link'}}About{{/link-to}}");
<add> bootApplication();
<add>
<add> equal(Ember.$('#the-link').attr('href'), '/about?baz=lol');
<add> Ember.run(Ember.$('#the-link'), 'click');
<add> var aboutController = container.lookup('controller:about');
<add> deepEqual(aboutController.getProperties('baz', 'bat'), { baz: 'lol', bat: 'borf' }, "about controller QP properties updated");
<add>
<add> equal(container.lookup('controller:application').get('currentPath'), "about");
<add>});
<add>
<add>QUnit.test("supplied QP properties can be bound", function() {
<add> Ember.TEMPLATES.index = compile("{{#link-to (query-params foo=boundThing) id='the-link'}}Index{{/link-to}}");
<add> bootApplication();
<add>
<add> var indexController = container.lookup('controller:index');
<add>
<add>
<add> equal(Ember.$('#the-link').attr('href'), '/?foo=OMG');
<add> Ember.run(indexController, 'set', 'boundThing', "ASL");
<add> equal(Ember.$('#the-link').attr('href'), '/?foo=ASL');
<add>});
<add>
<add>QUnit.test("supplied QP properties can be bound (booleans)", function() {
<add> var indexController = container.lookup('controller:index');
<add> Ember.TEMPLATES.index = compile("{{#link-to (query-params abool=boundThing) id='the-link'}}Index{{/link-to}}");
<add>
<add> bootApplication();
<add>
<add> equal(Ember.$('#the-link').attr('href'), '/?abool=OMG');
<add> Ember.run(indexController, 'set', 'boundThing', false);
<add> equal(Ember.$('#the-link').attr('href'), '/?abool=false');
<add>
<add> Ember.run(Ember.$('#the-link'), 'click');
<add>
<add> deepEqual(indexController.getProperties('foo', 'bar', 'abool'), { foo: '123', bar: 'abc', abool: false });
<add>});
<add>
<add>QUnit.test("href updates when unsupplied controller QP props change", function() {
<ide> Ember.TEMPLATES.index = compile("{{#link-to (query-params foo='lol') id='the-link'}}Index{{/link-to}}");
<ide>
<ide> bootApplication();
<ide>
<add> var indexController = container.lookup('controller:index');
<add>
<ide> equal(Ember.$('#the-link').attr('href'), '/?foo=lol');
<ide> Ember.run(indexController, 'set', 'bar', 'BORF');
<ide> equal(Ember.$('#the-link').attr('href'), '/?bar=BORF&foo=lol');
<ide> QUnit.test("The {{link-to}} helper disregards query-params in activeness computa
<ide> equal(router.get('location.path'), '/parent');
<ide> });
<ide>
<add>
<ide> function basicEagerURLUpdateTest(setTagName) {
<ide> expect(6);
<ide>
<ide><path>packages/ember/tests/routing/query_params_test.js
<ide> QUnit.module("Routing w/ Query Params", {
<ide> }
<ide> });
<ide>
<add>QUnit.test("a query param can have define a `type` for type casting", function() {
<add> Router.map(function() {
<add> this.route("home", { path: '/' });
<add> });
<add>
<add> App.HomeRoute = Ember.Route.extend({
<add> queryParams: {
<add> page: {
<add> defaultValue: null,
<add> type: 'number'
<add> }
<add> }
<add> });
<add>
<add> bootApplication();
<add>
<add> var controller = container.lookup('controller:home');
<add>
<add> Ember.run(router, 'transitionTo', 'home', { queryParams: { page: '4' } });
<add> equal(controller.get('page'), 4);
<add>
<add>});
<add>
<ide> QUnit.test("Single query params can be set on ObjectController [DEPRECATED]", function() {
<ide> expectDeprecation("Ember.ObjectController is deprecated, please use Ember.Controller and use `model.propertyName`.");
<ide>
<ide> QUnit.test("Single query params can be set on ObjectController [DEPRECATED]", fu
<ide> equal(router.get('location.path'), "/?foo=987");
<ide> });
<ide>
<del>QUnit.test("Single query params can be set", function() {
<add>QUnit.test("Single query params can be set on the controller [DEPRECATED]", function() {
<ide> Router.map(function() {
<ide> this.route("home", { path: '/' });
<ide> });
<ide> QUnit.test("Single query params can be set", function() {
<ide> equal(router.get('location.path'), "/?foo=987");
<ide> });
<ide>
<del>QUnit.test("Query params can map to different url keys", function() {
<add>QUnit.test("Single query params can be set on the route", function() {
<add> Router.map(function() {
<add> this.route("home", { path: '/' });
<add> });
<add>
<add> App.HomeRoute = Ember.Route.extend({
<add> queryParams: {
<add> foo: {
<add> defaultValue: "123"
<add> }
<add> }
<add> });
<add>
<add> bootApplication();
<add>
<add> var controller = container.lookup('controller:home');
<add>
<add> setAndFlush(controller, 'foo', '456');
<add>
<add> equal(router.get('location.path'), "/?foo=456");
<add>
<add> setAndFlush(controller, 'foo', '987');
<add> equal(router.get('location.path'), "/?foo=987");
<add>});
<add>
<add>QUnit.test("Query params can map to different url keys configured on the controller [DEPRECATED]", function() {
<ide> App.IndexController = Ember.Controller.extend({
<ide> queryParams: [{ foo: 'other_foo', bar: { as: 'other_bar' } }],
<ide> foo: "FOO",
<ide> QUnit.test("Query params can map to different url keys", function() {
<ide> Ember.run(router, 'transitionTo', '/?other_bar=NERK&other_foo=NAW');
<ide> });
<ide>
<add>QUnit.test("Query params can map to different url keys configured on the route", function() {
<add> App.IndexRoute = Ember.Route.extend({
<add> queryParams: {
<add> foo: { as: 'other_foo', defaultValue: "FOO" },
<add> bar: { as: 'other_bar', defaultValue: "BAR" }
<add> }
<add> });
<add>
<add> bootApplication();
<add> equal(router.get('location.path'), "");
<add>
<add> var controller = container.lookup('controller:index');
<add>
<add> setAndFlush(controller, 'foo', 'LEX');
<add>
<add> equal(router.get('location.path'), "/?other_foo=LEX");
<add> setAndFlush(controller, 'foo', 'WOO');
<add> equal(router.get('location.path'), "/?other_foo=WOO");
<add>
<add> Ember.run(router, 'transitionTo', '/?other_foo=NAW');
<add> equal(controller.get('foo'), "NAW");
<add>
<add> setAndFlush(controller, 'bar', 'NERK');
<add> Ember.run(router, 'transitionTo', '/?other_bar=NERK&other_foo=NAW');
<add>});
<ide>
<ide> QUnit.test("Routes have overridable serializeQueryParamKey hook", function() {
<ide> App.IndexRoute = Ember.Route.extend({
<ide> QUnit.test("Routes have overridable serializeQueryParamKey hook", function() {
<ide> equal(router.get('location.path'), "/?fun-times=woot");
<ide> });
<ide>
<add>QUnit.test("Routes have overridable serializeQueryParamKey hook and it works with route-configured query params", function() {
<add> App.IndexRoute = Ember.Route.extend({
<add> queryParams: {
<add> funTimes: {
<add> defaultValue: ""
<add> }
<add> },
<add> serializeQueryParamKey: Ember.String.dasherize
<add> });
<add>
<add> bootApplication();
<add> equal(router.get('location.path'), "");
<add>
<add> var controller = container.lookup('controller:index');
<add> setAndFlush(controller, 'funTimes', 'woot');
<add>
<add> equal(router.get('location.path'), "/?fun-times=woot");
<add>});
<add>
<ide> QUnit.test("No replaceURL occurs on startup because default values don't show up in URL", function() {
<ide> expect(0);
<ide>
<ide> QUnit.test("No replaceURL occurs on startup because default values don't show up
<ide> bootApplication();
<ide> });
<ide>
<add>QUnit.test("No replaceURL occurs on startup when configured via Route because default values don't show up in URL", function() {
<add> expect(0);
<add>
<add> App.IndexRoute = Ember.Route.extend({
<add> queryParams: {
<add> foo: {
<add> defaultValue: "123"
<add> }
<add> }
<add> });
<add>
<add> expectedReplaceURL = "/?foo=123";
<add>
<add> bootApplication();
<add>});
<add>
<ide> QUnit.test("Can override inherited QP behavior by specifying queryParams as a computed property", function() {
<ide> expect(0);
<ide> var SharedMixin = Ember.Mixin.create({
<ide> QUnit.test("model hooks receives query params", function() {
<ide> equal(router.get('location.path'), "");
<ide> });
<ide>
<add>QUnit.test("model hooks receives query params when configred on Route", function() {
<add> App.IndexRoute = Ember.Route.extend({
<add> queryParams: {
<add> omg: {
<add> defaultValue: "lol"
<add> }
<add> },
<add> model(params) {
<add> deepEqual(params, { omg: 'lol' });
<add> }
<add> });
<add>
<add> bootApplication();
<add>
<add> equal(router.get('location.path'), "");
<add>});
<add>
<add>
<ide> QUnit.test("controllers won't be eagerly instantiated by internal query params logic", function() {
<ide> expect(10);
<ide> Router.map(function() {
<ide> QUnit.test("controllers won't be eagerly instantiated by internal query params l
<ide> equal(router.get('location.path'), "/cats?name=domino", 'url is correct');
<ide> });
<ide>
<add>
<ide> QUnit.test("model hooks receives query params (overridden by incoming url value)", function() {
<ide> App.IndexController = Ember.Controller.extend({
<ide> queryParams: ['omg'],
<ide> QUnit.test("model hooks receives query params (overridden by incoming url value)
<ide> equal(router.get('location.path'), "/?omg=yes");
<ide> });
<ide>
<add>QUnit.test("model hooks receives query params (overridden by incoming url value) when configured on route", function() {
<add> App.IndexRoute = Ember.Route.extend({
<add> queryParams: {
<add> omg: {
<add> defaultValue: 'lol'
<add> }
<add> },
<add> model(params) {
<add> deepEqual(params, { omg: 'yes' });
<add> }
<add> });
<add>
<add> startingURL = "/?omg=yes";
<add> bootApplication();
<add>
<add> equal(router.get('location.path'), "/?omg=yes");
<add>});
<add>
<ide> QUnit.test("Route#paramsFor fetches query params", function() {
<ide> expect(1);
<ide>
<ide> QUnit.test("Route#paramsFor fetches query params", function() {
<ide> bootApplication();
<ide> });
<ide>
<add>QUnit.test("Route#paramsFor fetches query params when configured on the route", function() {
<add> expect(1);
<add>
<add> Router.map(function() {
<add> this.route('index', { path: '/:something' });
<add> });
<add>
<add> App.IndexRoute = Ember.Route.extend({
<add> queryParams: {
<add> foo: {
<add> defaultValue: 'fooapp'
<add> }
<add> },
<add> model(params, transition) {
<add> deepEqual(this.paramsFor('index'), { something: 'omg', foo: 'fooapp' }, "could retrieve params for index");
<add> }
<add> });
<add>
<add> startingURL = "/omg";
<add> bootApplication();
<add>});
<add>
<ide> QUnit.test("Route#paramsFor fetches falsy query params", function() {
<ide> expect(1);
<ide>
<ide> QUnit.test("Route#paramsFor fetches falsy query params", function() {
<ide> bootApplication();
<ide> });
<ide>
<add>QUnit.test("Route#paramsFor fetches falsy query params when they're configured on the route", function() {
<add> expect(1);
<add>
<add> App.IndexRoute = Ember.Route.extend({
<add> queryParams: {
<add> foo: {
<add> defaultValue: true
<add> }
<add> },
<add> model(params, transition) {
<add> equal(params.foo, false);
<add> }
<add> });
<add>
<add> startingURL = "/?foo=false";
<add> bootApplication();
<add>});
<add>
<ide> QUnit.test("model hook can query prefix-less application params", function() {
<ide> App.ApplicationController = Ember.Controller.extend({
<ide> queryParams: ['appomg'],
<ide> QUnit.test("model hook can query prefix-less application params", function() {
<ide> equal(router.get('location.path'), "");
<ide> });
<ide>
<add>QUnit.test("model hook can query prefix-less application params when they're configured on the route", function() {
<add> App.ApplicationRoute = Ember.Route.extend({
<add> queryParams: {
<add> appomg: {
<add> defaultValue: 'applol'
<add> }
<add> },
<add> model(params) {
<add> deepEqual(params, { appomg: 'applol' });
<add> }
<add> });
<add>
<add> App.IndexRoute = Ember.Route.extend({
<add> queryParams: {
<add> omg: {
<add> defaultValue: 'lol'
<add> }
<add> },
<add> model(params) {
<add> deepEqual(params, { omg: 'lol' });
<add> deepEqual(this.paramsFor('application'), { appomg: 'applol' });
<add> }
<add> });
<add>
<add> bootApplication();
<add>
<add> equal(router.get('location.path'), "");
<add>});
<add>
<ide> QUnit.test("model hook can query prefix-less application params (overridden by incoming url value)", function() {
<ide> App.ApplicationController = Ember.Controller.extend({
<ide> queryParams: ['appomg'],
<ide> QUnit.test("model hook can query prefix-less application params (overridden by i
<ide> equal(router.get('location.path'), "/?appomg=appyes&omg=yes");
<ide> });
<ide>
<add>QUnit.test("model hook can query prefix-less application params (overridden by incoming url value) when they're configured on the route", function() {
<add> App.ApplicationRoute = Ember.Route.extend({
<add> queryParams: {
<add> appomg: {
<add> defaultValue: 'applol'
<add> }
<add> },
<add> model(params) {
<add> deepEqual(params, { appomg: 'appyes' });
<add> }
<add> });
<add>
<add> App.IndexRoute = Ember.Route.extend({
<add> queryParams: {
<add> omg: {
<add> defaultValue: 'lol'
<add> }
<add> },
<add> model(params) {
<add> deepEqual(params, { omg: 'yes' });
<add> deepEqual(this.paramsFor('application'), { appomg: 'appyes' });
<add> }
<add> });
<add>
<add> startingURL = "/?appomg=appyes&omg=yes";
<add> bootApplication();
<add>
<add> equal(router.get('location.path'), "/?appomg=appyes&omg=yes");
<add>});
<add>
<add>
<ide> QUnit.test("can opt into full transition by setting refreshModel in route queryParams", function() {
<ide> expect(6);
<ide> App.ApplicationController = Ember.Controller.extend({
<ide> QUnit.test("can opt into full transition by setting refreshModel in route queryP
<ide> equal(indexModelCount, 2);
<ide> });
<ide>
<add>QUnit.test("can opt into full transition by setting refreshModel in route queryParams when all configuration is in route", function() {
<add> expect(6);
<add>
<add> var appModelCount = 0;
<add> App.ApplicationRoute = Ember.Route.extend({
<add> queryParams: {
<add> 'appomg': {
<add> defaultValue: 'applol'
<add> }
<add> },
<add> model(params) {
<add> appModelCount++;
<add> }
<add> });
<add>
<add> var indexModelCount = 0;
<add> App.IndexRoute = Ember.Route.extend({
<add> queryParams: {
<add> omg: {
<add> refreshModel: true,
<add> defaultValue: 'lol'
<add> }
<add> },
<add> model(params) {
<add> indexModelCount++;
<add>
<add> if (indexModelCount === 1) {
<add> deepEqual(params, { omg: 'lol' });
<add> } else if (indexModelCount === 2) {
<add> deepEqual(params, { omg: 'lex' });
<add> }
<add> }
<add> });
<add>
<add> bootApplication();
<add>
<add> equal(appModelCount, 1);
<add> equal(indexModelCount, 1);
<add>
<add> var indexController = container.lookup('controller:index');
<add> setAndFlush(indexController, 'omg', 'lex');
<add>
<add> equal(appModelCount, 1);
<add> equal(indexModelCount, 2);
<add>});
<add>
<ide> QUnit.test("Use Ember.get to retrieve query params 'refreshModel' configuration", function() {
<ide> expect(6);
<ide> App.ApplicationController = Ember.Controller.extend({
<ide> QUnit.test("Use Ember.get to retrieve query params 'refreshModel' configuration"
<ide> equal(indexModelCount, 2);
<ide> });
<ide>
<add>
<ide> QUnit.test("can use refreshModel even w URL changes that remove QPs from address bar", function() {
<ide> expect(4);
<ide>
<ide> QUnit.test("can use refreshModel even w URL changes that remove QPs from address
<ide> equal(indexController.get('omg'), 'lol');
<ide> });
<ide>
<del>QUnit.test("warn user that routes query params configuration must be an Object, not an Array", function() {
<add>QUnit.test("can use refreshModel even w URL changes that remove QPs from address bar when QP configured on route", function() {
<add> expect(4);
<add>
<add> var indexModelCount = 0;
<add> App.IndexRoute = Ember.Route.extend({
<add> queryParams: {
<add> omg: {
<add> defaultValue: 'lol',
<add> refreshModel: true
<add> }
<add> },
<add> model(params) {
<add> indexModelCount++;
<add>
<add> var data;
<add> if (indexModelCount === 1) {
<add> data = 'foo';
<add> } else if (indexModelCount === 2) {
<add> data = 'lol';
<add> }
<add>
<add> deepEqual(params, { omg: data }, "index#model receives right data");
<add> }
<add> });
<add>
<add> startingURL = '/?omg=foo';
<add> bootApplication();
<add> handleURL('/');
<add>
<add> var indexController = container.lookup('controller:index');
<add> equal(indexController.get('omg'), 'lol');
<add>});
<add>
<add>QUnit.test("warn user that routes query params configuration must be an Object, not an Array", function() {
<ide> expect(1);
<ide>
<ide> App.ApplicationRoute = Ember.Route.extend({
<ide> QUnit.test("can opt into a replace query by specifying replace:true in the Route
<ide> setAndFlush(appController, 'alex', 'wallace');
<ide> });
<ide>
<add>QUnit.test("can opt into a replace query by specifying replace:true in the Router config hash when all configuration lives on route", function() {
<add> expect(2);
<add>
<add> App.ApplicationRoute = Ember.Route.extend({
<add> queryParams: {
<add> alex: {
<add> defaultValue: 'matchneer',
<add> replace: true
<add> }
<add> }
<add> });
<add>
<add> bootApplication();
<add>
<add> equal(router.get('location.path'), "");
<add>
<add> var appController = container.lookup('controller:application');
<add> expectedReplaceURL = "/?alex=wallace";
<add> setAndFlush(appController, 'alex', 'wallace');
<add>});
<add>
<ide> QUnit.test("Route query params config can be configured using property name instead of URL key", function() {
<ide> expect(2);
<ide> App.ApplicationController = Ember.Controller.extend({
<ide> QUnit.test("Route query params config can be configured using property name inst
<ide> setAndFlush(appController, 'commitBy', 'igor_seb');
<ide> });
<ide>
<add>QUnit.test("Route query params config can be configured using property name instead of URL key when configured on the route", function() {
<add> expect(2);
<add>
<add> App.ApplicationRoute = Ember.Route.extend({
<add> queryParams: {
<add> commitBy: {
<add> as: 'commit_by',
<add> replace: true
<add> }
<add> }
<add> });
<add>
<add> bootApplication();
<add>
<add> equal(router.get('location.path'), "");
<add>
<add> var appController = container.lookup('controller:application');
<add> expectedReplaceURL = "/?commit_by=igor_seb";
<add> setAndFlush(appController, 'commitBy', 'igor_seb');
<add>});
<add>
<ide> QUnit.test("An explicit replace:false on a changed QP always wins and causes a pushState", function() {
<ide> expect(3);
<ide> App.ApplicationController = Ember.Controller.extend({
<ide> QUnit.test("An explicit replace:false on a changed QP always wins and causes a p
<ide> Ember.run(appController, 'setProperties', { alex: 'sriracha' });
<ide> });
<ide>
<add>QUnit.test("An explicit replace:false on a changed QP always wins and causes a pushState even when configuration is all on the route", function() {
<add> expect(3);
<add>
<add> App.ApplicationRoute = Ember.Route.extend({
<add> queryParams: {
<add> alex: {
<add> replace: true,
<add> defaultValue: 'matchneer'
<add> },
<add> steely: {
<add> replace: false,
<add> defaultValue: 'dan'
<add> }
<add> }
<add> });
<add>
<add> bootApplication();
<add>
<add> var appController = container.lookup('controller:application');
<add> expectedPushURL = "/?alex=wallace&steely=jan";
<add> Ember.run(appController, 'setProperties', { alex: 'wallace', steely: 'jan' });
<add>
<add> expectedPushURL = "/?alex=wallace&steely=fran";
<add> Ember.run(appController, 'setProperties', { steely: 'fran' });
<add>
<add> expectedReplaceURL = "/?alex=sriracha&steely=fran";
<add> Ember.run(appController, 'setProperties', { alex: 'sriracha' });
<add>});
<add>
<ide> QUnit.test("can opt into full transition by setting refreshModel in route queryParams when transitioning from child to parent", function() {
<ide> Ember.TEMPLATES.parent = compile('{{outlet}}');
<ide> Ember.TEMPLATES['parent/child'] = compile("{{link-to 'Parent' 'parent' (query-params foo='change') id='parent-link'}}");
<ide> QUnit.test("can opt into full transition by setting refreshModel in route queryP
<ide> equal(parentModelCount, 2);
<ide> });
<ide>
<add>QUnit.test("can opt into full transition by setting refreshModel in route queryParams when transitioning from child to parent when all configuration is on route", function() {
<add> Ember.TEMPLATES.parent = compile('{{outlet}}');
<add> Ember.TEMPLATES['parent/child'] = compile("{{link-to 'Parent' 'parent' (query-params foo='change') id='parent-link'}}");
<add>
<add> App.Router.map(function() {
<add> this.resource('parent', function() {
<add> this.route('child');
<add> });
<add> });
<add>
<add> var parentModelCount = 0;
<add> App.ParentRoute = Ember.Route.extend({
<add> model() {
<add> parentModelCount++;
<add> },
<add> queryParams: {
<add> foo: {
<add> refreshModel: true,
<add> defaultValue: 'abc'
<add> }
<add> }
<add> });
<add>
<add> startingURL = '/parent/child?foo=lol';
<add> bootApplication();
<add>
<add> equal(parentModelCount, 1);
<add>
<add> container.lookup('controller:parent');
<add>
<add> Ember.run(Ember.$('#parent-link'), 'click');
<add>
<add> equal(parentModelCount, 2);
<add>});
<add>
<ide> QUnit.test("Use Ember.get to retrieve query params 'replace' configuration", function() {
<ide> expect(2);
<ide> App.ApplicationController = Ember.Controller.extend({
<ide> QUnit.test("URL transitions that remove QPs still register as QP changes", funct
<ide> equal(indexController.get('omg'), 'lol');
<ide> });
<ide>
<add>QUnit.test("URL transitions that remove QPs still register as QP changes when configuration lives on the route", function() {
<add> expect(2);
<add>
<add> App.IndexRoute = Ember.Route.extend({
<add> queryParams: {
<add> omg: {
<add> defaultValue: 'lol'
<add> }
<add> }
<add> });
<add>
<add> startingURL = "/?omg=borf";
<add> bootApplication();
<add>
<add> var indexController = container.lookup('controller:index');
<add> equal(indexController.get('omg'), 'borf');
<add> Ember.run(router, 'transitionTo', '/');
<add> equal(indexController.get('omg'), 'lol');
<add>});
<add>
<add>
<ide> QUnit.test("Subresource naming style is supported", function() {
<ide>
<ide> Router.map(function() {
<ide> QUnit.test("Subresource naming style is supported", function() {
<ide> equal(router.get('location.path'), "/abcdef/zoo?bar=456&foo=123");
<ide> });
<ide>
<add>QUnit.test("Subresource naming style is supported when configuration is all on the route", function() {
<add>
<add> Router.map(function() {
<add> this.resource('abc.def', { path: '/abcdef' }, function() {
<add> this.route('zoo');
<add> });
<add> });
<add>
<add> Ember.TEMPLATES.application = compile("{{link-to 'A' 'abc.def' (query-params foo='123') id='one'}}{{link-to 'B' 'abc.def.zoo' (query-params foo='123' bar='456') id='two'}}{{outlet}}");
<add>
<add> App.AbcDefRoute = Ember.Route.extend({
<add> queryParams: {
<add> foo: 'lol'
<add> }
<add> });
<add>
<add> App.AbcDefZooRoute = Ember.Route.extend({
<add> queryParams: {
<add> bar: {
<add> defaultValue: 'haha'
<add> }
<add> }
<add> });
<add>
<add> bootApplication();
<add> equal(router.get('location.path'), "");
<add> equal(Ember.$('#one').attr('href'), "/abcdef?foo=123");
<add> equal(Ember.$('#two').attr('href'), "/abcdef/zoo?bar=456&foo=123");
<add>
<add> Ember.run(Ember.$('#one'), 'click');
<add> equal(router.get('location.path'), "/abcdef?foo=123");
<add> Ember.run(Ember.$('#two'), 'click');
<add> equal(router.get('location.path'), "/abcdef/zoo?bar=456&foo=123");
<add>});
<add>
<ide> QUnit.test("transitionTo supports query params", function() {
<ide> App.IndexController = Ember.Controller.extend({
<ide> queryParams: ['foo'],
<ide> QUnit.test("transitionTo supports query params", function() {
<ide> equal(router.get('location.path'), "/?foo=false", "shorhand supported (bool)");
<ide> });
<ide>
<add>QUnit.test("transitionTo supports query params when configuration occurs on the route", function() {
<add> App.IndexRoute = Ember.Route.extend({
<add> queryParams: {
<add> foo: {
<add> defaultValue: 'lol'
<add> }
<add> }
<add> });
<add>
<add> bootApplication();
<add>
<add> equal(router.get('location.path'), "");
<add>
<add> Ember.run(router, 'transitionTo', { queryParams: { foo: "borf" } });
<add> equal(router.get('location.path'), "/?foo=borf", "shorthand supported");
<add> Ember.run(router, 'transitionTo', { queryParams: { 'index:foo': "blaf" } });
<add> equal(router.get('location.path'), "/?foo=blaf", "longform supported");
<add> Ember.run(router, 'transitionTo', { queryParams: { 'index:foo': false } });
<add> equal(router.get('location.path'), "/?foo=false", "longform supported (bool)");
<add> Ember.run(router, 'transitionTo', { queryParams: { foo: false } });
<add> equal(router.get('location.path'), "/?foo=false", "shorhand supported (bool)");
<add>});
<add>
<ide> QUnit.test("transitionTo supports query params (multiple)", function() {
<ide> App.IndexController = Ember.Controller.extend({
<ide> queryParams: ['foo', 'bar'],
<ide> QUnit.test("transitionTo supports query params (multiple)", function() {
<ide> equal(router.get('location.path'), "/?foo=false", "shorhand supported (bool)");
<ide> });
<ide>
<add>QUnit.test("transitionTo supports query params (multiple) when configuration occurs on the route", function() {
<add> App.IndexRoute = Ember.Route.extend({
<add> queryParams: {
<add> foo: {
<add> defaultValue: 'lol'
<add> },
<add> bar: {
<add> defaultValue: 'wat'
<add> }
<add> }
<add> });
<add>
<add> bootApplication();
<add>
<add> equal(router.get('location.path'), "");
<add>
<add> Ember.run(router, 'transitionTo', { queryParams: { foo: "borf" } });
<add> equal(router.get('location.path'), "/?foo=borf", "shorthand supported");
<add> Ember.run(router, 'transitionTo', { queryParams: { 'index:foo': "blaf" } });
<add> equal(router.get('location.path'), "/?foo=blaf", "longform supported");
<add> Ember.run(router, 'transitionTo', { queryParams: { 'index:foo': false } });
<add> equal(router.get('location.path'), "/?foo=false", "longform supported (bool)");
<add> Ember.run(router, 'transitionTo', { queryParams: { foo: false } });
<add> equal(router.get('location.path'), "/?foo=false", "shorhand supported (bool)");
<add>});
<add>
<ide> QUnit.test("setting controller QP to empty string doesn't generate null in URL", function() {
<ide> expect(1);
<ide> App.IndexController = Ember.Controller.extend({
<ide> QUnit.test("setting controller QP to empty string doesn't generate null in URL",
<ide> setAndFlush(controller, 'foo', '');
<ide> });
<ide>
<add>QUnit.test("setting QP to empty string doesn't generate null in URL", function() {
<add> expect(1);
<add> App.IndexRoute = Ember.Route.extend({
<add> queryParams: {
<add> foo: {
<add> defaultValue: "123"
<add> }
<add> }
<add> });
<add>
<add> bootApplication();
<add> var controller = container.lookup('controller:index');
<add>
<add> expectedPushURL = "/?foo=";
<add> setAndFlush(controller, 'foo', '');
<add>});
<add>
<ide> QUnit.test("A default boolean value deserializes QPs as booleans rather than strings", function() {
<ide> App.IndexController = Ember.Controller.extend({
<ide> queryParams: ['foo'],
<ide> QUnit.test("A default boolean value deserializes QPs as booleans rather than str
<ide> equal(controller.get('foo'), false);
<ide> });
<ide>
<add>QUnit.test("A default boolean value deserializes QPs as booleans rather than strings when configuration occurs on the route", function() {
<add> App.IndexRoute = Ember.Route.extend({
<add> queryParams: {
<add> foo: {
<add> defaultValue: false
<add> }
<add> },
<add> model(params) {
<add> equal(params.foo, true, "model hook received foo as boolean true");
<add> }
<add> });
<add>
<add> startingURL = "/?foo=true";
<add> bootApplication();
<add>
<add> var controller = container.lookup('controller:index');
<add> equal(controller.get('foo'), true);
<add>
<add> handleURL('/?foo=false');
<add> equal(controller.get('foo'), false);
<add>});
<add>
<ide> QUnit.test("Query param without value are empty string", function() {
<ide> App.IndexController = Ember.Controller.extend({
<ide> queryParams: ['foo'],
<ide> QUnit.test("Query param without value are empty string", function() {
<ide> equal(controller.get('foo'), "");
<ide> });
<ide>
<del>QUnit.test("Array query params can be set", function() {
<del> Router.map(function() {
<del> this.route("home", { path: '/' });
<del> });
<add>QUnit.test("Query param without value are empty string when configuration occurs on the route", function() {
<add> App.IndexRoute = Ember.Route.extend({
<add> queryParams: {
<add> foo: {
<add> defaultValue: ''
<add> }
<add> }
<add> });
<add>
<add> startingURL = "/?foo=";
<add> bootApplication();
<add>
<add> var controller = container.lookup('controller:index');
<add> equal(controller.get('foo'), "");
<add>});
<add>
<add>QUnit.test("Array query params can be set", function() {
<add> Router.map(function() {
<add> this.route("home", { path: '/' });
<add> });
<ide>
<ide> App.HomeController = Ember.Controller.extend({
<ide> queryParams: ['foo'],
<ide> QUnit.test("Array query params can be set", function() {
<ide> equal(router.get('location.path'), "/?foo=%5B3%2C4%5D");
<ide> });
<ide>
<add>QUnit.test("Array query params can be set when configured on the route", function() {
<add> Router.map(function() {
<add> this.route("home", { path: '/' });
<add> });
<add>
<add> App.HomeRoute = Ember.Route.extend({
<add> queryParams: {
<add> foo: {
<add> defaultValue: []
<add> }
<add> }
<add> });
<add>
<add> bootApplication();
<add>
<add> var controller = container.lookup('controller:home');
<add>
<add> setAndFlush(controller, 'foo', [1,2]);
<add>
<add> equal(router.get('location.path'), "/?foo=%5B1%2C2%5D");
<add>
<add> setAndFlush(controller, 'foo', [3,4]);
<add> equal(router.get('location.path'), "/?foo=%5B3%2C4%5D");
<add>});
<add>
<ide> QUnit.test("(de)serialization: arrays", function() {
<ide> App.IndexController = Ember.Controller.extend({
<ide> queryParams: ['foo'],
<ide> QUnit.test("(de)serialization: arrays", function() {
<ide> equal(router.get('location.path'), "/?foo=%5B%5D", "longform supported");
<ide> });
<ide>
<add>QUnit.test("(de)serialization: arrays when configuration occurs on the route", function() {
<add> App.IndexRoute = Ember.Route.extend({
<add> queryParams: {
<add> foo: {
<add> defaultValue: [1]
<add> }
<add> }
<add> });
<add>
<add> bootApplication();
<add>
<add> equal(router.get('location.path'), "");
<add>
<add> Ember.run(router, 'transitionTo', { queryParams: { foo: [2,3] } });
<add> equal(router.get('location.path'), "/?foo=%5B2%2C3%5D", "shorthand supported");
<add> Ember.run(router, 'transitionTo', { queryParams: { 'index:foo': [4,5] } });
<add> equal(router.get('location.path'), "/?foo=%5B4%2C5%5D", "longform supported");
<add> Ember.run(router, 'transitionTo', { queryParams: { foo: [] } });
<add> equal(router.get('location.path'), "/?foo=%5B%5D", "longform supported");
<add>});
<add>
<ide> QUnit.test("Url with array query param sets controller property to array", function() {
<ide> App.IndexController = Ember.Controller.extend({
<ide> queryParams: ['foo'],
<ide> QUnit.test("Url with array query param sets controller property to array", funct
<ide> deepEqual(controller.get('foo'), ["1","2","3"]);
<ide> });
<ide>
<add>QUnit.test("Url with array query param sets controller property to array when configuration occurs on the route", function() {
<add> App.IndexRoute = Ember.Route.extend({
<add> queryParams: {
<add> foo: {
<add> defaultValue: ''
<add> }
<add> }
<add> });
<add>
<add> startingURL = "/?foo[]=1&foo[]=2&foo[]=3";
<add> bootApplication();
<add>
<add> var controller = container.lookup('controller:index');
<add> deepEqual(controller.get('foo'), ["1","2","3"]);
<add>});
<add>
<add>QUnit.test("Url with array query param sets controller property to array when configuration occurs on the route and there is still a controller", function() {
<add> App.IndexController = Ember.Controller.extend();
<add>
<add> App.IndexRoute = Ember.Route.extend({
<add> queryParams: {
<add> foo: {
<add> defaultValue: ''
<add> }
<add> }
<add> });
<add>
<add> startingURL = "/?foo[]=1&foo[]=2&foo[]=3";
<add> bootApplication();
<add>
<add> var controller = container.lookup('controller:index');
<add> deepEqual(controller.get('foo'), ["1","2","3"]);
<add>});
<add>
<ide> QUnit.test("Array query params can be pushed/popped", function() {
<ide> Router.map(function() {
<ide> this.route("home", { path: '/' });
<ide> QUnit.test("Array query params can be pushed/popped", function() {
<ide> deepEqual(controller.foo, ['lol', 1]);
<ide> });
<ide>
<add>QUnit.test("Array query params can be pushed/popped when configuration occurs on the route but there is still a controller", function() {
<add> Router.map(function() {
<add> this.route("home", { path: '/' });
<add> });
<add>
<add> App.HomeController = Ember.Controller.extend({
<add> foo: Ember.A([])
<add> });
<add>
<add> App.HomeRoute = Ember.Route.extend({
<add> queryParams: {
<add> foo: {}
<add> }
<add> });
<add>
<add> bootApplication();
<add>
<add> equal(router.get('location.path'), "");
<add>
<add> var controller = container.lookup('controller:home');
<add>
<add> Ember.run(controller.foo, 'pushObject', 1);
<add> equal(router.get('location.path'), "/?foo=%5B1%5D");
<add> deepEqual(controller.foo, [1]);
<add> Ember.run(controller.foo, 'popObject');
<add> equal(router.get('location.path'), "/");
<add> deepEqual(controller.foo, []);
<add> Ember.run(controller.foo, 'pushObject', 1);
<add> equal(router.get('location.path'), "/?foo=%5B1%5D");
<add> deepEqual(controller.foo, [1]);
<add> Ember.run(controller.foo, 'popObject');
<add> equal(router.get('location.path'), "/");
<add> deepEqual(controller.foo, []);
<add> Ember.run(controller.foo, 'pushObject', 1);
<add> equal(router.get('location.path'), "/?foo=%5B1%5D");
<add> deepEqual(controller.foo, [1]);
<add> Ember.run(controller.foo, 'pushObject', 2);
<add> equal(router.get('location.path'), "/?foo=%5B1%2C2%5D");
<add> deepEqual(controller.foo, [1, 2]);
<add> Ember.run(controller.foo, 'popObject');
<add> equal(router.get('location.path'), "/?foo=%5B1%5D");
<add> deepEqual(controller.foo, [1]);
<add> Ember.run(controller.foo, 'unshiftObject', 'lol');
<add> equal(router.get('location.path'), "/?foo=%5B%22lol%22%2C1%5D");
<add> deepEqual(controller.foo, ['lol', 1]);
<add>});
<add>
<ide> QUnit.test("Overwriting with array with same content shouldn't refire update", function() {
<ide> expect(3);
<ide> var modelCount = 0;
<ide> QUnit.test("Overwriting with array with same content shouldn't refire update", f
<ide> equal(router.get('location.path'), "");
<ide> });
<ide>
<add>QUnit.test("Overwriting with array with same content shouldn't refire update when configuration occurs on router but there is still a controller", function() {
<add> expect(3);
<add> var modelCount = 0;
<add>
<add> Router.map(function() {
<add> this.route("home", { path: '/' });
<add> });
<add>
<add> App.HomeRoute = Ember.Route.extend({
<add> queryParams: {
<add> foo: {}
<add> },
<add> model() {
<add> modelCount++;
<add> }
<add> });
<add>
<add> App.HomeController = Ember.Controller.extend({
<add> foo: Ember.A([1])
<add> });
<add>
<add> bootApplication();
<add>
<add> equal(modelCount, 1);
<add> var controller = container.lookup('controller:home');
<add> setAndFlush(controller, 'model', Ember.A([1]));
<add> equal(modelCount, 1);
<add> equal(router.get('location.path'), "");
<add>});
<add>
<ide> QUnit.test("Defaulting to params hash as the model should not result in that params object being watched", function() {
<ide> expect(1);
<ide>
<ide> QUnit.test("A child of a resource route still defaults to parent route's model e
<ide> bootApplication();
<ide> });
<ide>
<add>QUnit.test("A child of a resource route still defaults to parent route's model even if the child route has a query param when configuration occurs on the router", function() {
<add> expect(1);
<add>
<add> App.IndexRoute = Ember.Route.extend({
<add> queryParams: {
<add> woot: {}
<add> }
<add> });
<add>
<add> App.ApplicationRoute = Ember.Route.extend({
<add> model(p, trans) {
<add> return { woot: true };
<add> }
<add> });
<add>
<add> App.IndexRoute = Ember.Route.extend({
<add> setupController(controller, model) {
<add> deepEqual(withoutMeta(model), { woot: true }, "index route inherited model route from parent route");
<add> }
<add> });
<add>
<add> bootApplication();
<add>});
<add>
<ide> QUnit.test("opting into replace does not affect transitions between routes", function() {
<ide> expect(5);
<ide> Ember.TEMPLATES.application = compile(
<ide> QUnit.test("opting into replace does not affect transitions between routes", fun
<ide> this.route('bar');
<ide> });
<ide>
<del> App.BarController = Ember.Controller.extend({
<del> queryParams: ['raytiley'],
<del> raytiley: 'israd'
<del> });
<add> App.BarController = Ember.Controller.extend({
<add> queryParams: ['raytiley'],
<add> raytiley: 'israd'
<add> });
<add>
<add> App.BarRoute = Ember.Route.extend({
<add> queryParams: {
<add> raytiley: {
<add> replace: true
<add> }
<add> }
<add> });
<add>
<add> bootApplication();
<add> var controller = container.lookup('controller:bar');
<add>
<add> expectedPushURL = '/foo';
<add> Ember.run(Ember.$('#foo-link'), 'click');
<add>
<add> expectedPushURL = '/bar';
<add> Ember.run(Ember.$('#bar-no-qp-link'), 'click');
<add>
<add> expectedReplaceURL = '/bar?raytiley=woot';
<add> setAndFlush(controller, 'raytiley', 'woot');
<add>
<add> expectedPushURL = '/foo';
<add> Ember.run(Ember.$('#foo-link'), 'click');
<add>
<add> expectedPushURL = '/bar?raytiley=isthebest';
<add> Ember.run(Ember.$('#bar-link'), 'click');
<add>});
<add>
<add>QUnit.test("opting into replace does not affect transitions between routes when configuration occurs on the route", function() {
<add> expect(5);
<add> Ember.TEMPLATES.application = compile(
<add> "{{link-to 'Foo' 'foo' id='foo-link'}}" +
<add> "{{link-to 'Bar' 'bar' id='bar-no-qp-link'}}" +
<add> "{{link-to 'Bar' 'bar' (query-params raytiley='isthebest') id='bar-link'}}" +
<add> "{{outlet}}"
<add> );
<add> App.Router.map(function() {
<add> this.route('foo');
<add> this.route('bar');
<add> });
<add>
<add> App.BarRoute = Ember.Route.extend({
<add> queryParams: {
<add> raytiley: {
<add> replace: true,
<add> defaultValue: 'israd'
<add> }
<add> }
<add> });
<add>
<add> bootApplication();
<add> var controller = container.lookup('controller:bar');
<add>
<add> expectedPushURL = '/foo';
<add> Ember.run(Ember.$('#foo-link'), 'click');
<add>
<add> expectedPushURL = '/bar';
<add> Ember.run(Ember.$('#bar-no-qp-link'), 'click');
<add>
<add> expectedReplaceURL = '/bar?raytiley=woot';
<add> setAndFlush(controller, 'raytiley', 'woot');
<add>
<add> expectedPushURL = '/foo';
<add> Ember.run(Ember.$('#foo-link'), 'click');
<add>
<add> expectedPushURL = '/bar?raytiley=isthebest';
<add> Ember.run(Ember.$('#bar-link'), 'click');
<add>});
<add>
<add>QUnit.test("Undefined isn't deserialized into a string", function() {
<add> expect(3);
<add> Router.map(function() {
<add> this.route("example");
<add> });
<add>
<add> Ember.TEMPLATES.application = compile("{{link-to 'Example' 'example' id='the-link'}}");
<add>
<add> App.ExampleController = Ember.Controller.extend({
<add> queryParams: ['foo']
<add> // uncommon to not support default value, but should assume undefined.
<add> });
<add>
<add> App.ExampleRoute = Ember.Route.extend({
<add> model(params) {
<add> deepEqual(params, { foo: undefined });
<add> }
<add> });
<add>
<add> bootApplication();
<add>
<add> var $link = Ember.$('#the-link');
<add> equal($link.attr('href'), "/example");
<add> Ember.run($link, 'click');
<add>
<add> var controller = container.lookup('controller:example');
<add> equal(get(controller, 'foo'), undefined);
<add>});
<add>
<add>QUnit.test("Undefined isn't deserialized into a string when configuration occurs on the route", function() {
<add> expect(3);
<add> Router.map(function() {
<add> this.route("example");
<add> });
<add>
<add> Ember.TEMPLATES.application = compile("{{link-to 'Example' 'example' id='the-link'}}");
<add>
<add> App.ExampleRoute = Ember.Route.extend({
<add> queryParams: {
<add> // uncommon to not support default value, but should assume undefined.
<add> foo: {
<add> defaultValue: undefined
<add> }
<add> },
<add> model(params) {
<add> deepEqual(params, { foo: undefined });
<add> }
<add> });
<add>
<add> bootApplication();
<add>
<add> var $link = Ember.$('#the-link');
<add> equal($link.attr('href'), "/example");
<add> Ember.run($link, 'click');
<add>
<add> var controller = container.lookup('controller:example');
<add> equal(get(controller, 'foo'), undefined);
<add>});
<add>
<add>QUnit.test("query params have been set by the time setupController is called", function() {
<add> expect(1);
<add>
<add> App.ApplicationController = Ember.Controller.extend({
<add> queryParams: ['foo'],
<add> foo: "wat"
<add> });
<add>
<add> App.ApplicationRoute = Ember.Route.extend({
<add> setupController(controller) {
<add> equal(controller.get('foo'), 'YEAH', "controller's foo QP property set before setupController called");
<add> }
<add> });
<add>
<add> startingURL = '/?foo=YEAH';
<add> bootApplication();
<add>});
<add>
<add>QUnit.test("query params have been set by the time setupController is called when configuration occurs on the router", function() {
<add> expect(1);
<add>
<add> App.ApplicationRoute = Ember.Route.extend({
<add> queryParams: {
<add> foo: {
<add> defaultValue: 'wat'
<add> }
<add> },
<add> setupController(controller) {
<add> equal(controller.get('foo'), 'YEAH', "controller's foo QP property set before setupController called");
<add> }
<add> });
<add>
<add> startingURL = '/?foo=YEAH';
<add> bootApplication();
<add>});
<add>
<add>QUnit.test("query params have been set by the time setupController is called when configuration occurs on the router and there is still a controller", function() {
<add> expect(1);
<add>
<add> App.ApplicationController = Ember.Controller.extend();
<add>
<add> App.ApplicationRoute = Ember.Route.extend({
<add> queryParams: {
<add> foo: {
<add> defaultValue: 'wat'
<add> }
<add> },
<add> setupController(controller) {
<add> equal(controller.get('foo'), 'YEAH', "controller's foo QP property set before setupController called");
<add> }
<add> });
<add>
<add> startingURL = '/?foo=YEAH';
<add> bootApplication();
<add>});
<add>
<add>var testParamlessLinks = function(routeName) {
<add> QUnit.test("param-less links in an app booted with query params in the URL don't reset the query params: " + routeName, function() {
<add> expect(1);
<add>
<add> Ember.TEMPLATES[routeName] = compile("{{link-to 'index' 'index' id='index-link'}}");
<add>
<add> App[capitalize(routeName) + "Controller"] = Ember.Controller.extend({
<add> queryParams: ['foo'],
<add> foo: "wat"
<add> });
<add>
<add> startingURL = '/?foo=YEAH';
<add> bootApplication();
<add>
<add> equal(Ember.$('#index-link').attr('href'), '/?foo=YEAH');
<add> });
<add>};
<add>
<add>testParamlessLinks('application');
<add>testParamlessLinks('index');
<add>
<add>var testParamlessLinksWithRouteConfig = function(routeName) {
<add> QUnit.test("param-less links in an app booted with query params in the URL don't reset the query params: " + routeName, function() {
<add> expect(1);
<add>
<add> Ember.TEMPLATES[routeName] = compile("{{link-to 'index' 'index' id='index-link'}}");
<add>
<add> App[capitalize(routeName) + "Route"] = Ember.Route.extend({
<add> queryParams: {
<add> foo: {
<add> defaultValue: "wat"
<add> }
<add> }
<add> });
<add>
<add> startingURL = '/?foo=YEAH';
<add> bootApplication();
<add>
<add> equal(Ember.$('#index-link').attr('href'), '/?foo=YEAH');
<add> });
<add>};
<add>
<add>testParamlessLinksWithRouteConfig('application');
<add>testParamlessLinksWithRouteConfig('index');
<add>
<add>QUnit.module("Model Dep Query Params", {
<add> setup() {
<add> sharedSetup();
<add>
<add> App.Router.map(function() {
<add> this.resource('article', { path: '/a/:id' }, function() {
<add> this.resource('comments');
<add> });
<add> });
<add>
<add> var articles = this.articles = Ember.A([{ id: 'a-1' }, { id: 'a-2' }, { id: 'a-3' }]);
<add>
<add> App.ApplicationController = Ember.Controller.extend({
<add> articles: this.articles
<add> });
<add>
<add> var self = this;
<add> App.ArticleRoute = Ember.Route.extend({
<add> model(params) {
<add> if (self.expectedModelHookParams) {
<add> deepEqual(params, self.expectedModelHookParams, "the ArticleRoute model hook received the expected merged dynamic segment + query params hash");
<add> self.expectedModelHookParams = null;
<add> }
<add> return articles.findProperty('id', params.id);
<add> }
<add> });
<add>
<add> App.ArticleController = Ember.Controller.extend({
<add> queryParams: ['q', 'z'],
<add> q: 'wat',
<add> z: 0
<add> });
<add>
<add> App.CommentsController = Ember.Controller.extend({
<add> queryParams: 'page',
<add> page: 1
<add> });
<add>
<add> Ember.TEMPLATES.application = compile("{{#each a in articles}} {{link-to 'Article' 'article' a id=a.id}} {{/each}} {{outlet}}");
<add>
<add> this.boot = function() {
<add> bootApplication();
<add>
<add> self.$link1 = Ember.$('#a-1');
<add> self.$link2 = Ember.$('#a-2');
<add> self.$link3 = Ember.$('#a-3');
<add>
<add> equal(self.$link1.attr('href'), '/a/a-1');
<add> equal(self.$link2.attr('href'), '/a/a-2');
<add> equal(self.$link3.attr('href'), '/a/a-3');
<add>
<add> self.controller = container.lookup('controller:article');
<add> };
<add> },
<add>
<add> teardown() {
<add> sharedTeardown();
<add> ok(!this.expectedModelHookParams, "there should be no pending expectation of expected model hook params");
<add> }
<add>});
<add>
<add>QUnit.test("query params have 'model' stickiness by default", function() {
<add> this.boot();
<add>
<add> Ember.run(this.$link1, 'click');
<add> equal(router.get('location.path'), '/a/a-1');
<add>
<add> setAndFlush(this.controller, 'q', 'lol');
<add>
<add> equal(this.$link1.attr('href'), '/a/a-1?q=lol');
<add> equal(this.$link2.attr('href'), '/a/a-2');
<add> equal(this.$link3.attr('href'), '/a/a-3');
<add>
<add> Ember.run(this.$link2, 'click');
<add>
<add> equal(this.controller.get('q'), 'wat');
<add> equal(this.controller.get('z'), 0);
<add> deepEqual(withoutMeta(this.controller.get('model')), { id: 'a-2' });
<add> equal(this.$link1.attr('href'), '/a/a-1?q=lol');
<add> equal(this.$link2.attr('href'), '/a/a-2');
<add> equal(this.$link3.attr('href'), '/a/a-3');
<add>});
<add>
<add>QUnit.test("query params have 'model' stickiness by default (url changes)", function() {
<add> this.boot();
<add>
<add> this.expectedModelHookParams = { id: 'a-1', q: 'lol', z: 0 };
<add> handleURL('/a/a-1?q=lol');
<add>
<add> deepEqual(withoutMeta(this.controller.get('model')), { id: 'a-1' });
<add> equal(this.controller.get('q'), 'lol');
<add> equal(this.controller.get('z'), 0);
<add> equal(this.$link1.attr('href'), '/a/a-1?q=lol');
<add> equal(this.$link2.attr('href'), '/a/a-2');
<add> equal(this.$link3.attr('href'), '/a/a-3');
<add>
<add> this.expectedModelHookParams = { id: 'a-2', q: 'lol', z: 0 };
<add> handleURL('/a/a-2?q=lol');
<add>
<add> deepEqual(withoutMeta(this.controller.get('model')), { id: 'a-2' }, "controller's model changed to a-2");
<add> equal(this.controller.get('q'), 'lol');
<add> equal(this.controller.get('z'), 0);
<add> equal(this.$link1.attr('href'), '/a/a-1?q=lol');
<add> equal(this.$link2.attr('href'), '/a/a-2?q=lol'); // fail
<add> equal(this.$link3.attr('href'), '/a/a-3');
<add>
<add> this.expectedModelHookParams = { id: 'a-3', q: 'lol', z: 123 };
<add> handleURL('/a/a-3?q=lol&z=123');
<add>
<add> equal(this.controller.get('q'), 'lol');
<add> equal(this.controller.get('z'), 123);
<add> equal(this.$link1.attr('href'), '/a/a-1?q=lol');
<add> equal(this.$link2.attr('href'), '/a/a-2?q=lol');
<add> equal(this.$link3.attr('href'), '/a/a-3?q=lol&z=123');
<add>});
<add>
<add>
<add>QUnit.test("query params have 'model' stickiness by default (params-based transitions)", function() {
<add> Ember.TEMPLATES.application = compile("{{#each a in articles}} {{link-to 'Article' 'article' a.id id=a.id}} {{/each}}");
<add>
<add> this.boot();
<add>
<add> this.expectedModelHookParams = { id: 'a-1', q: 'wat', z: 0 };
<add> Ember.run(router, 'transitionTo', 'article', 'a-1');
<add>
<add> deepEqual(withoutMeta(this.controller.get('model')), { id: 'a-1' });
<add> equal(this.controller.get('q'), 'wat');
<add> equal(this.controller.get('z'), 0);
<add> equal(this.$link1.attr('href'), '/a/a-1');
<add> equal(this.$link2.attr('href'), '/a/a-2');
<add> equal(this.$link3.attr('href'), '/a/a-3');
<add>
<add> this.expectedModelHookParams = { id: 'a-2', q: 'lol', z: 0 };
<add> Ember.run(router, 'transitionTo', 'article', 'a-2', { queryParams: { q: 'lol' } });
<add>
<add> deepEqual(withoutMeta(this.controller.get('model')), { id: 'a-2' });
<add> equal(this.controller.get('q'), 'lol');
<add> equal(this.controller.get('z'), 0);
<add> equal(this.$link1.attr('href'), '/a/a-1');
<add> equal(this.$link2.attr('href'), '/a/a-2?q=lol');
<add> equal(this.$link3.attr('href'), '/a/a-3');
<add>
<add> this.expectedModelHookParams = { id: 'a-3', q: 'hay', z: 0 };
<add> Ember.run(router, 'transitionTo', 'article', 'a-3', { queryParams: { q: 'hay' } });
<add>
<add> deepEqual(withoutMeta(this.controller.get('model')), { id: 'a-3' });
<add> equal(this.controller.get('q'), 'hay');
<add> equal(this.controller.get('z'), 0);
<add> equal(this.$link1.attr('href'), '/a/a-1');
<add> equal(this.$link2.attr('href'), '/a/a-2?q=lol');
<add> equal(this.$link3.attr('href'), '/a/a-3?q=hay');
<add>
<add> this.expectedModelHookParams = { id: 'a-2', q: 'lol', z: 1 };
<add> Ember.run(router, 'transitionTo', 'article', 'a-2', { queryParams: { z: 1 } });
<add>
<add> deepEqual(withoutMeta(this.controller.get('model')), { id: 'a-2' });
<add> equal(this.controller.get('q'), 'lol');
<add> equal(this.controller.get('z'), 1);
<add> equal(this.$link1.attr('href'), '/a/a-1');
<add> equal(this.$link2.attr('href'), '/a/a-2?q=lol&z=1');
<add> equal(this.$link3.attr('href'), '/a/a-3?q=hay');
<add>});
<add>
<add>QUnit.test("'controller' stickiness shares QP state between models", function() {
<add> App.ArticleController.reopen({
<add> queryParams: { q: { scope: 'controller' } }
<add> });
<add>
<add> this.boot();
<add>
<add> Ember.run(this.$link1, 'click');
<add> equal(router.get('location.path'), '/a/a-1');
<add>
<add> setAndFlush(this.controller, 'q', 'lol');
<add>
<add> equal(this.$link1.attr('href'), '/a/a-1?q=lol');
<add> equal(this.$link2.attr('href'), '/a/a-2?q=lol');
<add> equal(this.$link3.attr('href'), '/a/a-3?q=lol');
<add>
<add> Ember.run(this.$link2, 'click');
<ide>
<del> App.BarRoute = Ember.Route.extend({
<del> queryParams: {
<del> raytiley: {
<del> replace: true
<del> }
<del> }
<del> });
<add> equal(this.controller.get('q'), 'lol');
<add> equal(this.controller.get('z'), 0);
<add> deepEqual(withoutMeta(this.controller.get('model')), { id: 'a-2' });
<ide>
<del> bootApplication();
<del> var controller = container.lookup('controller:bar');
<add> equal(this.$link1.attr('href'), '/a/a-1?q=lol');
<add> equal(this.$link2.attr('href'), '/a/a-2?q=lol');
<add> equal(this.$link3.attr('href'), '/a/a-3?q=lol');
<ide>
<del> expectedPushURL = '/foo';
<del> Ember.run(Ember.$('#foo-link'), 'click');
<add> this.expectedModelHookParams = { id: 'a-3', q: 'haha', z: 123 };
<add> handleURL('/a/a-3?q=haha&z=123');
<ide>
<del> expectedPushURL = '/bar';
<del> Ember.run(Ember.$('#bar-no-qp-link'), 'click');
<add> deepEqual(withoutMeta(this.controller.get('model')), { id: 'a-3' });
<add> equal(this.controller.get('q'), 'haha');
<add> equal(this.controller.get('z'), 123);
<ide>
<del> expectedReplaceURL = '/bar?raytiley=woot';
<del> setAndFlush(controller, 'raytiley', 'woot');
<add> equal(this.$link1.attr('href'), '/a/a-1?q=haha');
<add> equal(this.$link2.attr('href'), '/a/a-2?q=haha');
<add> equal(this.$link3.attr('href'), '/a/a-3?q=haha&z=123');
<ide>
<del> expectedPushURL = '/foo';
<del> Ember.run(Ember.$('#foo-link'), 'click');
<add> setAndFlush(this.controller, 'q', 'woot');
<ide>
<del> expectedPushURL = '/bar?raytiley=isthebest';
<del> Ember.run(Ember.$('#bar-link'), 'click');
<add> equal(this.$link1.attr('href'), '/a/a-1?q=woot');
<add> equal(this.$link2.attr('href'), '/a/a-2?q=woot');
<add> equal(this.$link3.attr('href'), '/a/a-3?q=woot&z=123');
<ide> });
<ide>
<del>QUnit.test("Undefined isn't deserialized into a string", function() {
<del> expect(3);
<del> Router.map(function() {
<del> this.route("example");
<del> });
<add>QUnit.test("'model' stickiness is scoped to current or first dynamic parent route", function() {
<add> this.boot();
<ide>
<del> Ember.TEMPLATES.application = compile("{{link-to 'Example' 'example' id='the-link'}}");
<add> Ember.run(router, 'transitionTo', 'comments', 'a-1');
<ide>
<del> App.ExampleController = Ember.Controller.extend({
<del> queryParams: ['foo']
<del> // uncommon to not support default value, but should assume undefined.
<del> });
<add> var commentsCtrl = container.lookup('controller:comments');
<add> equal(commentsCtrl.get('page'), 1);
<add> equal(router.get('location.path'), '/a/a-1/comments');
<ide>
<del> App.ExampleRoute = Ember.Route.extend({
<del> model(params) {
<del> deepEqual(params, { foo: undefined });
<del> }
<del> });
<add> setAndFlush(commentsCtrl, 'page', 2);
<add> equal(router.get('location.path'), '/a/a-1/comments?page=2');
<ide>
<del> bootApplication();
<add> setAndFlush(commentsCtrl, 'page', 3);
<add> equal(router.get('location.path'), '/a/a-1/comments?page=3');
<ide>
<del> var $link = Ember.$('#the-link');
<del> equal($link.attr('href'), "/example");
<del> Ember.run($link, 'click');
<add> Ember.run(router, 'transitionTo', 'comments', 'a-2');
<add> equal(commentsCtrl.get('page'), 1);
<add> equal(router.get('location.path'), '/a/a-2/comments');
<ide>
<del> var controller = container.lookup('controller:example');
<del> equal(get(controller, 'foo'), undefined);
<add> Ember.run(router, 'transitionTo', 'comments', 'a-1');
<add> equal(commentsCtrl.get('page'), 3);
<add> equal(router.get('location.path'), '/a/a-1/comments?page=3');
<ide> });
<ide>
<del>QUnit.test("query params have been set by the time setupController is called", function() {
<del> expect(1);
<del>
<del> App.ApplicationController = Ember.Controller.extend({
<del> queryParams: ['foo'],
<del> foo: "wat"
<add>QUnit.test("can reset query params using the resetController hook", function() {
<add> App.Router.map(function() {
<add> this.resource('article', { path: '/a/:id' }, function() {
<add> this.resource('comments');
<add> });
<add> this.route('about');
<ide> });
<ide>
<del> App.ApplicationRoute = Ember.Route.extend({
<del> setupController(controller) {
<del> equal(controller.get('foo'), 'YEAH', "controller's foo QP property set before setupController called");
<add> App.ArticleRoute.reopen({
<add> resetController(controller, isExiting) {
<add> this.controllerFor('comments').set('page', 1);
<add> if (isExiting) {
<add> controller.set('q', 'imdone');
<add> }
<ide> }
<ide> });
<ide>
<del> startingURL = '/?foo=YEAH';
<del> bootApplication();
<del>});
<add> Ember.TEMPLATES.about = compile("{{link-to 'A' 'comments' 'a-1' id='one'}} {{link-to 'B' 'comments' 'a-2' id='two'}}");
<ide>
<del>var testParamlessLinks = function(routeName) {
<del> QUnit.test("param-less links in an app booted with query params in the URL don't reset the query params: " + routeName, function() {
<del> expect(1);
<add> this.boot();
<add> Ember.run(router, 'transitionTo', 'comments', 'a-1');
<ide>
<del> Ember.TEMPLATES[routeName] = compile("{{link-to 'index' 'index' id='index-link'}}");
<add> var commentsCtrl = container.lookup('controller:comments');
<add> equal(commentsCtrl.get('page'), 1);
<add> equal(router.get('location.path'), '/a/a-1/comments');
<ide>
<del> App[capitalize(routeName) + "Controller"] = Ember.Controller.extend({
<del> queryParams: ['foo'],
<del> foo: "wat"
<del> });
<add> setAndFlush(commentsCtrl, 'page', 2);
<add> equal(router.get('location.path'), '/a/a-1/comments?page=2');
<ide>
<del> startingURL = '/?foo=YEAH';
<del> bootApplication();
<ide>
<del> equal(Ember.$('#index-link').attr('href'), '/?foo=YEAH');
<del> });
<del>};
<add> Ember.run(router, 'transitionTo', 'comments', 'a-2');
<add> equal(commentsCtrl.get('page'), 1);
<add> equal(this.controller.get('q'), 'wat');
<ide>
<del>testParamlessLinks('application');
<del>testParamlessLinks('index');
<add> Ember.run(router, 'transitionTo', 'comments', 'a-1');
<ide>
<del>QUnit.module("Model Dep Query Params", {
<add> equal(router.get('location.path'), '/a/a-1/comments');
<add> equal(commentsCtrl.get('page'), 1);
<add>
<add> Ember.run(router, 'transitionTo', 'about');
<add>
<add> equal(Ember.$('#one').attr('href'), "/a/a-1/comments?q=imdone");
<add> equal(Ember.$('#two').attr('href'), "/a/a-2/comments");
<add>});
<add>
<add>QUnit.test("can unit test without bucket cache", function() {
<add> var controller = container.lookup('controller:article');
<add> controller._bucketCache = null;
<add>
<add> controller.set('q', "i used to break");
<add> equal(controller.get('q'), "i used to break");
<add>});
<add>
<add>QUnit.module("Model Dep Query Params with Route-based configuration", {
<ide> setup() {
<ide> sharedSetup();
<ide>
<ide> QUnit.module("Model Dep Query Params", {
<ide>
<ide> var self = this;
<ide> App.ArticleRoute = Ember.Route.extend({
<del> queryParams: {},
<add> queryParams: {
<add> q: {
<add> defaultValue: 'wat'
<add> },
<add> z: {
<add> defaultValue: 0
<add> }
<add> },
<ide> model(params) {
<ide> if (self.expectedModelHookParams) {
<ide> deepEqual(params, self.expectedModelHookParams, "the ArticleRoute model hook received the expected merged dynamic segment + query params hash");
<ide> QUnit.module("Model Dep Query Params", {
<ide> }
<ide> });
<ide>
<del> App.ArticleController = Ember.Controller.extend({
<del> queryParams: ['q', 'z'],
<del> q: 'wat',
<del> z: 0
<del> });
<del>
<del> App.CommentsController = Ember.Controller.extend({
<del> queryParams: 'page',
<del> page: 1
<add> App.CommentsRoute = Ember.Route.extend({
<add> queryParams: {
<add> page: {
<add> defaultValue: 1
<add> }
<add> }
<ide> });
<ide>
<ide> Ember.TEMPLATES.application = compile("{{#each a in articles}} {{link-to 'Article' 'article' a id=a.id}} {{/each}} {{outlet}}");
<ide> QUnit.test("query params have 'model' stickiness by default (url changes)", func
<ide> equal(this.$link3.attr('href'), '/a/a-3?q=lol&z=123');
<ide> });
<ide>
<del>
<ide> QUnit.test("query params have 'model' stickiness by default (params-based transitions)", function() {
<ide> Ember.TEMPLATES.application = compile("{{#each a in articles}} {{link-to 'Article' 'article' a.id id=a.id}} {{/each}}");
<ide>
<ide> QUnit.test("query params have 'model' stickiness by default (params-based transi
<ide> });
<ide>
<ide> QUnit.test("'controller' stickiness shares QP state between models", function() {
<del> App.ArticleController.reopen({
<add> App.ArticleRoute.reopen({
<ide> queryParams: { q: { scope: 'controller' } }
<ide> });
<ide>
<ide> QUnit.test("can reset query params using the resetController hook", function() {
<ide> equal(Ember.$('#two').attr('href'), "/a/a-2/comments");
<ide> });
<ide>
<del>QUnit.test("can unit test without bucket cache", function() {
<del> var controller = container.lookup('controller:article');
<del> controller._bucketCache = null;
<del>
<del> controller.set('q', "i used to break");
<del> equal(controller.get('q'), "i used to break");
<del>});
<del>
<ide> QUnit.module("Query Params - overlapping query param property names", {
<ide> setup() {
<ide> sharedSetup();
<ide> QUnit.test("Support shared but overridable mixin pattern", function() {
<ide> equal(parentController.get('page'), 2);
<ide> equal(parentChildController.get('page'), 2);
<ide> });
<add>
<add>QUnit.module("Query Params - overlapping query param property names when configured on the route", {
<add> setup() {
<add> sharedSetup();
<add>
<add> App.Router.map(function() {
<add> this.resource('parent', function() {
<add> this.route('child');
<add> });
<add> });
<add>
<add> this.boot = function() {
<add> bootApplication();
<add> Ember.run(router, 'transitionTo', 'parent.child');
<add> };
<add> },
<add>
<add> teardown() {
<add> sharedTeardown();
<add> }
<add>});
<add>
<add>QUnit.test("can remap same-named qp props", function() {
<add> App.ParentRoute = Ember.Route.extend({
<add> queryParams: {
<add> page: {
<add> as: 'parentPage',
<add> defaultValue: 1
<add> }
<add> }
<add> });
<add>
<add> App.ParentChildRoute = Ember.Route.extend({
<add> queryParams: {
<add> page: {
<add> as: 'childPage',
<add> defaultValue: 1
<add> }
<add> }
<add> });
<add>
<add> this.boot();
<add>
<add> equal(router.get('location.path'), '/parent/child');
<add>
<add> var parentController = container.lookup('controller:parent');
<add> var parentChildController = container.lookup('controller:parent.child');
<add>
<add> setAndFlush(parentController, 'page', 2);
<add> equal(router.get('location.path'), '/parent/child?parentPage=2');
<add> setAndFlush(parentController, 'page', 1);
<add> equal(router.get('location.path'), '/parent/child');
<add>
<add> setAndFlush(parentChildController, 'page', 2);
<add> equal(router.get('location.path'), '/parent/child?childPage=2');
<add> setAndFlush(parentChildController, 'page', 1);
<add> equal(router.get('location.path'), '/parent/child');
<add>
<add> Ember.run(function() {
<add> parentController.set('page', 2);
<add> parentChildController.set('page', 2);
<add> });
<add>
<add> equal(router.get('location.path'), '/parent/child?childPage=2&parentPage=2');
<add>
<add> Ember.run(function() {
<add> parentController.set('page', 1);
<add> parentChildController.set('page', 1);
<add> });
<add>
<add> equal(router.get('location.path'), '/parent/child');
<add>});
<add>
<add>QUnit.test("query params in the same route hierarchy with the same url key get auto-scoped", function() {
<add> App.ParentRoute = Ember.Route.extend({
<add> queryParams: {
<add> foo: {
<add> as: 'shared',
<add> defaultValue: 1
<add> }
<add> }
<add> });
<add>
<add> App.ParentChildRoute= Ember.Route.extend({
<add> queryParams: {
<add> bar: {
<add> as: 'shared',
<add> defaultValue: 1
<add> }
<add> }
<add> });
<add>
<add> var self = this;
<add> expectAssertion(function() {
<add> self.boot();
<add> }, "You're not allowed to have more than one controller property map to the same query param key, but both `parent:foo` and `parent.child:bar` map to `shared`. You can fix this by mapping one of the controller properties to a different query param key via the `as` config option, e.g. `foo: { as: 'other-foo' }`");
<add>});
| 10
|
Java
|
Java
|
use pathpatternparser in function.server
|
febed19bf477321c4546f6c2c251eba73605727d
|
<ide><path>spring-webflux/src/main/java/org/springframework/web/reactive/function/server/DefaultHandlerStrategiesBuilder.java
<ide> public void applicationContext(ApplicationContext applicationContext) {
<ide> applicationContext.getBeansOfType(HttpMessageReader.class).values().forEach(this::messageReader);
<ide> applicationContext.getBeansOfType(HttpMessageWriter.class).values().forEach(this::messageWriter);
<ide> applicationContext.getBeansOfType(ViewResolver.class).values().forEach(this::viewResolver);
<add> localeResolver(DEFAULT_LOCALE_RESOLVER);
<ide> }
<ide>
<ide> @Override
<ide><path>spring-webflux/src/main/java/org/springframework/web/reactive/function/server/RequestPredicates.java
<ide> import java.util.Map;
<ide> import java.util.Optional;
<ide> import java.util.Set;
<add>import java.util.function.Function;
<ide> import java.util.function.Predicate;
<ide>
<ide> import reactor.core.publisher.Flux;
<ide> import org.springframework.http.MediaType;
<ide> import org.springframework.http.server.reactive.ServerHttpRequest;
<ide> import org.springframework.util.Assert;
<del>import org.springframework.util.PathMatcher;
<ide> import org.springframework.web.reactive.function.BodyExtractor;
<ide> import org.springframework.web.server.WebSession;
<del>import org.springframework.web.util.ParsingPathMatcher;
<ide> import org.springframework.web.util.UriUtils;
<add>import org.springframework.web.util.patterns.PathPattern;
<add>import org.springframework.web.util.patterns.PathPatternParser;
<ide>
<ide> /**
<ide> * Implementations of {@link RequestPredicate} that implement various useful request matching operations, such as
<ide> */
<ide> public abstract class RequestPredicates {
<ide>
<del> private static final PathMatcher DEFAULT_PATH_MATCHER = new ParsingPathMatcher();
<add> private static final PathPatternParser DEFAULT_PATTERN_PARSER = new PathPatternParser();
<ide>
<ide> /**
<ide> * Returns a {@code RequestPredicate} that always matches.
<ide> public static RequestPredicate method(HttpMethod httpMethod) {
<ide> * @return a predicate that tests against the given path pattern
<ide> */
<ide> public static RequestPredicate path(String pattern) {
<del> return path(pattern, DEFAULT_PATH_MATCHER);
<add> Assert.notNull(pattern, "'pattern' must not be null");
<add> return new PathPatternPredicate(DEFAULT_PATTERN_PARSER.parse(pattern));
<ide> }
<ide>
<ide> /**
<del> * Return a {@code RequestPredicate} that tests against the given path pattern using the given matcher.
<add> * Return a function that creates new path-matching {@code RequestPredicates} from pattern
<add> * Strings using the given {@link PathPatternParser}. This method can be used to specify a
<add> * non-default, customized {@code PathPatternParser} when resolving path patterns.
<ide> *
<del> * @param pattern the pattern to match to
<del> * @param pathMatcher the path matcher to use
<del> * @return a predicate that tests against the given path pattern
<add> * @param patternParser the parser used to parse patterns given to the returned function
<add> * @return a function that resolves patterns Strings into path-matching
<add> * {@code RequestPredicate}s
<ide> */
<del> public static RequestPredicate path(String pattern, PathMatcher pathMatcher) {
<del> Assert.notNull(pattern, "'pattern' must not be null");
<del> Assert.notNull(pathMatcher, "'pathMatcher' must not be null");
<del>
<del> return new PathMatchingPredicate(pattern, pathMatcher);
<add> public static Function<String, RequestPredicate> pathPredicates(PathPatternParser patternParser) {
<add> Assert.notNull(patternParser, "'patternParser' must not be null");
<add> return pattern -> new PathPatternPredicate(patternParser.parse(pattern));
<ide> }
<ide>
<ide> /**
<ide> public boolean test(ServerRequest request) {
<ide> }
<ide> }
<ide>
<del> private static class PathMatchingPredicate implements RequestPredicate {
<del>
<del> private final String pattern;
<add> private static class PathPatternPredicate implements RequestPredicate {
<ide>
<del> private final PathMatcher pathMatcher;
<add> private final PathPattern pattern;
<ide>
<del> public PathMatchingPredicate(String pattern, PathMatcher pathMatcher) {
<add> public PathPatternPredicate(PathPattern pattern) {
<ide> Assert.notNull(pattern, "'pattern' must not be null");
<del> Assert.notNull(pathMatcher, "'pathMatcher' must not be null");
<ide> this.pattern = pattern;
<del> this.pathMatcher = pathMatcher;
<ide> }
<ide>
<ide> @Override
<ide> public boolean test(ServerRequest request) {
<ide> String path = request.path();
<del> if (this.pathMatcher.match(this.pattern, path)) {
<add> if (this.pattern.matches(path)) {
<ide> if (request instanceof DefaultServerRequest) {
<ide> DefaultServerRequest defaultRequest = (DefaultServerRequest) request;
<del> Map<String, String> uriTemplateVariables = this.pathMatcher.extractUriTemplateVariables(this.pattern, path);
<add> Map<String, String> uriTemplateVariables = this.pattern.matchAndExtract(path);
<ide> defaultRequest.exchange().getAttributes().put(RouterFunctions.URI_TEMPLATE_VARIABLES_ATTRIBUTE, uriTemplateVariables);
<ide> }
<ide> return true;
<ide> public boolean test(ServerRequest request) {
<ide> @Override
<ide> public ServerRequest subRequest(ServerRequest request) {
<ide> String requestPath = request.path();
<del> String subPath = this.pathMatcher.extractPathWithinPattern(this.pattern, requestPath);
<add> String subPath = this.pattern.extractPathWithinPattern(requestPath);
<ide> return new SubPathServerRequestWrapper(request, subPath);
<ide> }
<ide> }
<ide><path>spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RequestPredicatesTests.java
<ide>
<ide> import java.net.URI;
<ide> import java.util.Collections;
<add>import java.util.function.Function;
<ide>
<ide> import org.junit.Test;
<ide>
<ide> import org.springframework.http.HttpMethod;
<ide> import org.springframework.http.MediaType;
<add>import org.springframework.web.util.patterns.PathPatternParser;
<ide>
<ide> import static org.junit.Assert.assertFalse;
<ide> import static org.junit.Assert.assertTrue;
<ide> public void path() throws Exception {
<ide> assertFalse(predicate.test(request));
<ide> }
<ide>
<add> @Test
<add> public void pathPredicates() throws Exception {
<add> PathPatternParser parser = new PathPatternParser();
<add> parser.setCaseSensitive(false);
<add> Function<String, RequestPredicate> pathPredicates = RequestPredicates.pathPredicates(parser);
<add>
<add> URI uri = URI.create("http://localhost/path");
<add> RequestPredicate predicate = pathPredicates.apply("/P*");
<add> MockServerRequest request = MockServerRequest.builder().uri(uri).build();
<add> assertTrue(predicate.test(request));
<add> }
<add>
<ide> @Test
<ide> public void headers() throws Exception {
<ide> String name = "MyHeader";
| 3
|
Python
|
Python
|
use notimplementederror instead
|
7899015eee1a3b717e04ec3dc0e68cbff843b7b4
|
<ide><path>libcloud/storage/drivers/scaleway.py
<ide> # See the License for the specific language governing permissions and
<ide> # limitations under the License.
<ide>
<del>from libcloud.common.types import LibcloudError
<ide> from libcloud.storage.drivers.s3 import S3SignatureV4Connection
<ide> from libcloud.storage.drivers.s3 import BaseS3StorageDriver
<ide>
<ide> def list_regions(self):
<ide> return REGION_TO_HOST_MAP.keys()
<ide>
<ide> def get_object_cdn_url(self, *argv):
<del> raise LibcloudError(NO_CDN_SUPPORT_ERROR, driver=self)
<add> raise NotImplementedError("cdn_url not implemented for this driver")
<ide><path>libcloud/test/storage/test_scaleway.py
<ide> import sys
<ide> import unittest
<ide>
<del>from libcloud.common.types import LibcloudError
<ide> from libcloud.storage.drivers.s3 import S3SignatureV4Connection
<ide> from libcloud.storage.drivers.scaleway import (
<ide> ScalewayStorageDriver,
<ide> def test_get_object_cdn_url(self):
<ide> self.mock_response_klass.type = "get_object"
<ide> obj = self.driver.get_object(container_name="test2", object_name="test")
<ide>
<del> with self.assertRaises(LibcloudError):
<add> with self.assertRaises(NotImplementedError):
<ide> self.driver.get_object_cdn_url(obj)
<ide>
<ide>
| 2
|
Javascript
|
Javascript
|
move nonambient generation to build script
|
c5de35c01751631e12557a73593433aab3f4420a
|
<ide><path>Gruntfile.js
<ide> module.exports = function(grunt) {
<ide> });
<ide> });
<ide>
<add> grunt.registerTask('typedefs', function () {
<add> var fileContents = fs.readFileSync('type-definitions/Immutable.d.ts', 'utf8');
<add> var nonAmbientSource = fileContents
<add> .replace(
<add> /declare\s+module\s+Immutable\s*\{/,
<add> '')
<add> .replace(
<add> /\}[\s\n\r]*declare\s+module\s*.immutable.[\s\n\r]*{[\s\n\r]*export\s*=\s*Immutable[\s\n\r]*\}/m,
<add> '');
<add> fs.writeFileSync('dist/immutable-nonambient.d.ts', nonAmbientSource);
<add> });
<ide>
<ide> var Promise = require("bluebird");
<ide> var exec = require('child_process').exec;
<ide> module.exports = function(grunt) {
<ide> grunt.loadNpmTasks('grunt-release');
<ide>
<ide> grunt.registerTask('lint', 'Lint all source javascript', ['jshint']);
<del> grunt.registerTask('build', 'Build distributed javascript', ['clean', 'bundle', 'copy']);
<add> grunt.registerTask('build', 'Build distributed javascript', ['clean', 'bundle', 'copy', 'typedefs']);
<ide> grunt.registerTask('default', 'Lint, build.', ['lint', 'build', 'stats']);
<ide> }
<ide><path>gulpfile.js
<ide> gulp.task('typedefs', function() {
<ide> var contents = JSON.stringify(genTypeDefData(typeDefPath, fileSource));
<ide>
<ide> fs.writeFileSync(writePath, contents);
<del>
<del> var nonAmbientSource = fileContents
<del> .replace(
<del> /declare\s+module\s+Immutable\s*\{/,
<del> '')
<del> .replace(
<del> /\}[\s\n\r]*declare\s+module\s*.immutable.[\s\n\r]*{[\s\n\r]*export\s*=\s*Immutable[\s\n\r]*\}/m,
<del> '');
<del> var distPath = path.join(__dirname, 'dist');
<del> try { fs.mkdirSync(distPath); } catch (x) { }
<del> var nonAmbientPath = path.join(distPath, 'immutable-nonambient.d.ts');
<del> fs.writeFileSync(nonAmbientPath, nonAmbientSource);
<del>
<ide> });
<ide>
<ide> gulp.task('lint', function() {
| 2
|
Python
|
Python
|
fix ticket 1679
|
67ed62e086f8979fa2c49e60ba5c89a3e8feae41
|
<ide><path>numpy/f2py/crackfortran.py
<ide> def appenddecl(decl,decl2,force=1):
<ide> return decl
<ide>
<ide> selectpattern=re.compile(r'\s*(?P<this>(@\(@.*?@\)@|[*][\d*]+|[*]\s*@\(@.*?@\)@|))(?P<after>.*)\Z',re.I)
<del>nameargspattern=re.compile(r'\s*(?P<name>\b[\w$]+\b)\s*(@\(@\s*(?P<args>[\w\s,]*)\s*@\)@|)\s*(result(\s*@\(@\s*(?P<result>\b[\w$]+\b)\s*@\)@|))*\s*\Z',re.I)
<add>nameargspattern=re.compile(r'\s*(?P<name>\b[\w$]+\b)\s*(@\(@\s*(?P<args>[\w\s,]*)\s*@\)@|)\s*((result(\s*@\(@\s*(?P<result>\b[\w$]+\b)\s*@\)@|))|(bind\s*@\(@\s*(?P<bind>.*)\s*@\)@))*\s*\Z',re.I)
<ide> callnameargspattern=re.compile(r'\s*(?P<name>\b[\w$]+\b)\s*@\(@\s*(?P<args>.*)\s*@\)@\s*\Z',re.I)
<ide> real16pattern = re.compile(r'([-+]?(?:\d+(?:\.\d*)?|\d*\.\d+))[dD]((?:[-+]?\d+)?)')
<ide> real8pattern = re.compile(r'([-+]?((?:\d+(?:\.\d*)?|\d*\.\d+))[eE]((?:[-+]?\d+)?)|(\d+\.\d*))')
<ide> def _is_intent_callback(vdecl):
<ide> def _resolvenameargspattern(line):
<ide> line = markouterparen(line)
<ide> m1=nameargspattern.match(line)
<del> if m1: return m1.group('name'),m1.group('args'),m1.group('result')
<add> if m1:
<add> return m1.group('name'),m1.group('args'),m1.group('result'), m1.group('bind')
<ide> m1=callnameargspattern.match(line)
<del> if m1: return m1.group('name'),m1.group('args'),None
<del> return None,[],None
<add> if m1:
<add> return m1.group('name'),m1.group('args'),None, None
<add> return None,[],None, None
<ide>
<ide> def analyzeline(m,case,line):
<ide> global groupcounter,groupname,groupcache,grouplist,filepositiontext,\
<ide> def analyzeline(m,case,line):
<ide> block = block.lower()
<ide> if re.match(r'block\s*data',block,re.I): block='block data'
<ide> if re.match(r'python\s*module',block,re.I): block='python module'
<del> name,args,result = _resolvenameargspattern(m.group('after'))
<add> name,args,result,bind = _resolvenameargspattern(m.group('after'))
<ide> if name is None:
<ide> if block=='block data':
<ide> name = '_BLOCK_DATA_'
<ide> def analyzeline(m,case,line):
<ide> if f77modulename and neededmodule==-1 and groupcounter<=1:
<ide> neededmodule=groupcounter+2
<ide> needmodule=1
<del> needinterface=1
<add> if block != 'interface':
<add> needinterface=1
<ide> # Create new block(s)
<ide> groupcounter=groupcounter+1
<ide> groupcache[groupcounter]={}
<ide> def analyzeline(m,case,line):
<ide> del grouplist[groupcounter]
<ide> groupcounter=groupcounter-1 # end interface
<ide> elif case=='entry':
<del> name,args,result=_resolvenameargspattern(m.group('after'))
<add> name,args,result,bind=_resolvenameargspattern(m.group('after'))
<ide> if name is not None:
<ide> if args:
<ide> args=rmbadname([x.strip() for x in markoutercomma(args).split('@,@')])
| 1
|
Javascript
|
Javascript
|
convert `src/display/metadata.js` to es6 syntax
|
bc9afdf3c4d799c9d5ddd21351d74a2c990fcc0d
|
<ide><path>src/display/metadata.js
<ide> * limitations under the License.
<ide> */
<ide>
<del>function fixMetadata(meta) {
<del> return meta.replace(/>\\376\\377([^<]+)/g, function(all, codes) {
<del> var bytes = codes.replace(/\\([0-3])([0-7])([0-7])/g,
<del> function(code, d1, d2, d3) {
<del> return String.fromCharCode(d1 * 64 + d2 * 8 + d3 * 1);
<del> });
<del> var chars = '';
<del> for (var i = 0; i < bytes.length; i += 2) {
<del> var code = bytes.charCodeAt(i) * 256 + bytes.charCodeAt(i + 1);
<del> chars += (code >= 32 && code < 127 && code !== 60 && code !== 62 &&
<del> code !== 38) ? String.fromCharCode(code) :
<del> '&#x' + (0x10000 + code).toString(16).substring(1) + ';';
<add>class Metadata {
<add> constructor(data) {
<add> if (typeof data === 'string') {
<add> // Ghostscript may produce invalid metadata, so try to repair that first.
<add> data = this._repair(data);
<add>
<add> // Convert the string to a DOM `Document`.
<add> let parser = new DOMParser();
<add> data = parser.parseFromString(data, 'application/xml');
<add> } else if (!(data instanceof Document)) {
<add> throw new Error('Metadata: input is not a string or `Document`');
<ide> }
<del> return '>' + chars;
<del> });
<del>}
<ide>
<del>function Metadata(meta) {
<del> if (typeof meta === 'string') {
<del> // Ghostscript produces invalid metadata
<del> meta = fixMetadata(meta);
<add> this._metadata = Object.create(null);
<ide>
<del> var parser = new DOMParser();
<del> meta = parser.parseFromString(meta, 'application/xml');
<del> } else if (!(meta instanceof Document)) {
<del> throw new Error('Metadata: Invalid metadata object');
<add> this._parse(data);
<ide> }
<ide>
<del> this.metaDocument = meta;
<del> this.metadata = Object.create(null);
<del> this.parse();
<del>}
<add> _repair(data) {
<add> return data.replace(/>\\376\\377([^<]+)/g, function(all, codes) {
<add> let bytes = codes.replace(/\\([0-3])([0-7])([0-7])/g,
<add> function(code, d1, d2, d3) {
<add> return String.fromCharCode(d1 * 64 + d2 * 8 + d3 * 1);
<add> });
<add>
<add> let chars = '';
<add> for (let i = 0, ii = bytes.length; i < ii; i += 2) {
<add> let code = bytes.charCodeAt(i) * 256 + bytes.charCodeAt(i + 1);
<add> if (code >= 32 && code < 127 && code !== 60 && code !== 62 &&
<add> code !== 38) {
<add> chars += String.fromCharCode(code);
<add> } else {
<add> chars += '&#x' + (0x10000 + code).toString(16).substring(1) + ';';
<add> }
<add> }
<add>
<add> return '>' + chars;
<add> });
<add> }
<ide>
<del>Metadata.prototype = {
<del> parse: function Metadata_parse() {
<del> var doc = this.metaDocument;
<del> var rdf = doc.documentElement;
<add> _parse(domDocument) {
<add> let rdf = domDocument.documentElement;
<ide>
<ide> if (rdf.nodeName.toLowerCase() !== 'rdf:rdf') { // Wrapped in <xmpmeta>
<ide> rdf = rdf.firstChild;
<ide> Metadata.prototype = {
<ide> }
<ide> }
<ide>
<del> var nodeName = (rdf) ? rdf.nodeName.toLowerCase() : null;
<add> let nodeName = rdf ? rdf.nodeName.toLowerCase() : null;
<ide> if (!rdf || nodeName !== 'rdf:rdf' || !rdf.hasChildNodes()) {
<ide> return;
<ide> }
<ide>
<del> var children = rdf.childNodes, desc, entry, name, i, ii, length, iLength;
<del> for (i = 0, length = children.length; i < length; i++) {
<del> desc = children[i];
<add> let children = rdf.childNodes;
<add> for (let i = 0, ii = children.length; i < ii; i++) {
<add> let desc = children[i];
<ide> if (desc.nodeName.toLowerCase() !== 'rdf:description') {
<ide> continue;
<ide> }
<ide>
<del> for (ii = 0, iLength = desc.childNodes.length; ii < iLength; ii++) {
<del> if (desc.childNodes[ii].nodeName.toLowerCase() !== '#text') {
<del> entry = desc.childNodes[ii];
<del> name = entry.nodeName.toLowerCase();
<del> this.metadata[name] = entry.textContent.trim();
<add> for (let j = 0, jj = desc.childNodes.length; j < jj; j++) {
<add> if (desc.childNodes[j].nodeName.toLowerCase() !== '#text') {
<add> let entry = desc.childNodes[j];
<add> let name = entry.nodeName.toLowerCase();
<add>
<add> this._metadata[name] = entry.textContent.trim();
<ide> }
<ide> }
<ide> }
<del> },
<add> }
<ide>
<del> get: function Metadata_get(name) {
<del> return this.metadata[name] || null;
<del> },
<add> get(name) {
<add> return this._metadata[name] || null;
<add> }
<ide>
<del> has: function Metadata_has(name) {
<del> return typeof this.metadata[name] !== 'undefined';
<del> },
<del>};
<add> has(name) {
<add> return typeof this._metadata[name] !== 'undefined';
<add> }
<add>}
<ide>
<ide> export {
<ide> Metadata,
| 1
|
Javascript
|
Javascript
|
add 2nd argument to throws in test-assert
|
262400fd618b7a2ac90357c7c5fb253cb08f23ae
|
<ide><path>test/parallel/test-assert.js
<ide> assert.throws(makeBlock(a.deepEqual, /a/igm, /a/im),
<ide> /^AssertionError: \/a\/gim deepEqual \/a\/im$/);
<ide>
<ide> {
<del> const re1 = /a/;
<add> const re1 = /a/g;
<ide> re1.lastIndex = 3;
<del> assert.throws(makeBlock(a.deepEqual, re1, /a/));
<add>
<add> assert.throws(makeBlock(a.deepEqual, re1, /a/g),
<add> /^AssertionError: \/a\/g deepEqual \/a\/g$/);
<ide> }
<ide>
<ide>
| 1
|
Javascript
|
Javascript
|
add parameters to text-decoder benchmark
|
86a5b71dc98bcd2e2eff59a9cdd64243b467136d
|
<ide><path>benchmark/util/text-decoder.js
<ide> const bench = common.createBenchmark(main, {
<ide> encoding: ['utf-8', 'latin1', 'iso-8859-3'],
<ide> ignoreBOM: [0, 1],
<ide> len: [256, 1024 * 16, 1024 * 512],
<del> n: [1e6]
<add> n: [1e2],
<add> type: ['SharedArrayBuffer', 'ArrayBuffer', 'Buffer']
<ide> });
<ide>
<del>function main({ encoding, len, n, ignoreBOM }) {
<del> const buf = Buffer.allocUnsafe(len);
<add>function main({ encoding, len, n, ignoreBOM, type }) {
<ide> const decoder = new TextDecoder(encoding, { ignoreBOM });
<add> let buf;
<add>
<add> switch (type) {
<add> case 'SharedArrayBuffer': {
<add> buf = new SharedArrayBuffer(len);
<add> break;
<add> }
<add> case 'ArrayBuffer': {
<add> buf = new ArrayBuffer(len);
<add> break;
<add> }
<add> case 'Buffer': {
<add> buf = Buffer.allocUnsafe(len);
<add> break;
<add> }
<add> }
<ide>
<ide> bench.start();
<ide> for (let i = 0; i < n; i++) {
| 1
|
Text
|
Text
|
make minor edits to pull request text
|
1efa8fe1aaf3c7bd827a70ffa414bc9e615e4ade
|
<ide><path>doc/guides/contributing/pull-requests.md
<ide> repository includes changes to one or more of the following:
<ide> * the documentation in `doc/api`
<ide> * tests within the `test` directory.
<ide>
<del>If you are modifying code, please be sure to run `make lint` from time to
<del>time to ensure that the changes follow the Node.js code style guide.
<add>If you are modifying code, please be sure to run `make lint` (or
<add>`vcbuild.bat lint` on Windows) to ensure that the changes follow the Node.js
<add>code style guide.
<ide>
<ide> Any documentation you write (including code comments and API documentation)
<ide> should follow the [Style Guide](../doc-style-guide.md). Code samples
<ide> added: REPLACEME
<ide>
<ide> For contributing C++ code, you may want to look at the
<ide> [C++ Style Guide](../cpp-style-guide.md), as well as the
<del>[README of `src/`](../../../src/README.md) for an overview over Node.js
<add>[README of `src/`](../../../src/README.md) for an overview of Node.js
<ide> C++ internals.
<ide>
<ide> ### Step 4: Commit
| 1
|
Javascript
|
Javascript
|
fix an incorrect test setup
|
37249e4375dde042d573f1a18aabe188aa2de1fa
|
<ide><path>test/controller.line.tests.js
<ide> describe('Line controller tests', function() {
<ide> chartArea: {
<ide> bottom: 200,
<ide> left: xScale.left,
<del> right: 200,
<add> right: xScale.left + 200,
<ide> top: 0
<ide> },
<ide> data: data,
| 1
|
Python
|
Python
|
add tests for oauth2 authentication
|
468b5e43e2582513c4ae862efa4511ea8313031e
|
<ide><path>rest_framework/tests/authentication.py
<ide> from __future__ import unicode_literals
<add>from django.core.urlresolvers import reverse
<ide> from django.contrib.auth.models import User
<ide> from django.http import HttpResponse
<ide> from django.test import Client, TestCase
<ide> from rest_framework import HTTP_HEADER_ENCODING
<ide> from rest_framework import permissions
<ide> from rest_framework import status
<ide> from rest_framework.authtoken.models import Token
<del>from rest_framework.authentication import TokenAuthentication, BasicAuthentication, SessionAuthentication
<del>from rest_framework.compat import patterns
<add>from rest_framework.authentication import TokenAuthentication, BasicAuthentication, SessionAuthentication, OAuth2Authentication
<add>from rest_framework.compat import patterns, url, include
<add>from rest_framework.compat import oauth2
<add>from rest_framework.compat import oauth2_provider
<ide> from rest_framework.views import APIView
<ide> import json
<ide> import base64
<add>import datetime
<add>import unittest
<ide>
<ide>
<ide> class MockView(APIView):
<ide> def post(self, request):
<ide> def put(self, request):
<ide> return HttpResponse({'a': 1, 'b': 2, 'c': 3})
<ide>
<add> def get(self, request):
<add> return HttpResponse({'a': 1, 'b': 2, 'c': 3})
<add>
<ide> urlpatterns = patterns('',
<ide> (r'^session/$', MockView.as_view(authentication_classes=[SessionAuthentication])),
<ide> (r'^basic/$', MockView.as_view(authentication_classes=[BasicAuthentication])),
<ide> (r'^token/$', MockView.as_view(authentication_classes=[TokenAuthentication])),
<ide> (r'^auth-token/$', 'rest_framework.authtoken.views.obtain_auth_token'),
<add> url(r'^oauth2/', include('provider.oauth2.urls', namespace = 'oauth2')),
<add> url(r'^oauth2-test/$', MockView.as_view(authentication_classes=[OAuth2Authentication])),
<ide> )
<ide>
<ide>
<ide> def test_token_login_form(self):
<ide> {'username': self.username, 'password': self.password})
<ide> self.assertEqual(response.status_code, status.HTTP_200_OK)
<ide> self.assertEqual(json.loads(response.content.decode('ascii'))['token'], self.key)
<add>
<add>
<add>class OAuth2Tests(TestCase):
<add> """OAuth 2.0 authentication"""
<add> urls = 'rest_framework.tests.authentication'
<add>
<add> def setUp(self):
<add> self.csrf_client = Client(enforce_csrf_checks=True)
<add> self.username = 'john'
<add> self.email = 'lennon@thebeatles.com'
<add> self.password = 'password'
<add> self.user = User.objects.create_user(self.username, self.email, self.password)
<add>
<add> self.CLIENT_ID = 'client_key'
<add> self.CLIENT_SECRET = 'client_secret'
<add> self.ACCESS_TOKEN = "access_token"
<add> self.REFRESH_TOKEN = "refresh_token"
<add>
<add> self.oauth2_client = oauth2.models.Client.objects.create(
<add> client_id=self.CLIENT_ID,
<add> client_secret=self.CLIENT_SECRET,
<add> redirect_uri='',
<add> client_type=0,
<add> name='example',
<add> user=None,
<add> )
<add>
<add> self.access_token = oauth2.models.AccessToken.objects.create(
<add> token=self.ACCESS_TOKEN,
<add> client=self.oauth2_client,
<add> user=self.user,
<add> )
<add> self.refresh_token = oauth2.models.RefreshToken.objects.create(
<add> user=self.user,
<add> access_token=self.access_token,
<add> client=self.oauth2_client
<add> )
<add>
<add> def _create_authorization_header(self, token=None):
<add> return "Bearer {0}".format(token or self.access_token.token)
<add>
<add> def _client_credentials_params(self):
<add> return {'client_id': self.CLIENT_ID, 'client_secret': self.CLIENT_SECRET}
<add>
<add> @unittest.skipUnless(oauth2, 'django-oauth2-provider not installed')
<add> def test_get_form_with_wrong_client_data_failing_auth(self):
<add> """Ensure GETing form over OAuth with incorrect client credentials fails"""
<add> auth = self._create_authorization_header()
<add> params = self._client_credentials_params()
<add> params['client_id'] += 'a'
<add> response = self.csrf_client.get('/oauth2-test/', params, HTTP_AUTHORIZATION=auth)
<add> self.assertEqual(response.status_code, 401)
<add>
<add> @unittest.skipUnless(oauth2, 'django-oauth2-provider not installed')
<add> def test_get_form_passing_auth(self):
<add> """Ensure GETing form over OAuth with correct client credentials succeed"""
<add> auth = self._create_authorization_header()
<add> params = self._client_credentials_params()
<add> response = self.csrf_client.get('/oauth2-test/', params, HTTP_AUTHORIZATION=auth)
<add> self.assertEqual(response.status_code, 200)
<add>
<add> @unittest.skipUnless(oauth2, 'django-oauth2-provider not installed')
<add> def test_post_form_passing_auth(self):
<add> """Ensure POSTing form over OAuth with correct credentials passes and does not require CSRF"""
<add> auth = self._create_authorization_header()
<add> params = self._client_credentials_params()
<add> response = self.csrf_client.post('/oauth2-test/', params, HTTP_AUTHORIZATION=auth)
<add> self.assertEqual(response.status_code, 200)
<add>
<add> @unittest.skipUnless(oauth2, 'django-oauth2-provider not installed')
<add> def test_post_form_token_removed_failing_auth(self):
<add> """Ensure POSTing when there is no OAuth access token in db fails"""
<add> self.access_token.delete()
<add> auth = self._create_authorization_header()
<add> params = self._client_credentials_params()
<add> response = self.csrf_client.post('/oauth2-test/', params, HTTP_AUTHORIZATION=auth)
<add> self.assertIn(response.status_code, (status.HTTP_401_UNAUTHORIZED, status.HTTP_403_FORBIDDEN))
<add>
<add> @unittest.skipUnless(oauth2, 'django-oauth2-provider not installed')
<add> def test_post_form_with_refresh_token_failing_auth(self):
<add> """Ensure POSTing with refresh token instead of access token fails"""
<add> auth = self._create_authorization_header(token=self.refresh_token.token)
<add> params = self._client_credentials_params()
<add> response = self.csrf_client.post('/oauth2-test/', params, HTTP_AUTHORIZATION=auth)
<add> self.assertIn(response.status_code, (status.HTTP_401_UNAUTHORIZED, status.HTTP_403_FORBIDDEN))
<add>
<add> @unittest.skipUnless(oauth2, 'django-oauth2-provider not installed')
<add> def test_post_form_with_expired_access_token_failing_auth(self):
<add> """Ensure POSTing with expired access token fails with an 'Invalid token' error"""
<add> self.access_token.expires = datetime.datetime.now() - datetime.timedelta(seconds=10) # 10 seconds late
<add> self.access_token.save()
<add> auth = self._create_authorization_header()
<add> params = self._client_credentials_params()
<add> response = self.csrf_client.post('/oauth2-test/', params, HTTP_AUTHORIZATION=auth)
<add> self.assertIn(response.status_code, (status.HTTP_401_UNAUTHORIZED, status.HTTP_403_FORBIDDEN))
<add> self.assertIn('Invalid token', response.content)
| 1
|
Text
|
Text
|
modify javascript example in readme
|
ebe51482b57b55bdf55990517ec55feb12fbcc23
|
<ide><path>test/README.md
<ide> Please follow the approach described bellow:
<ide> * write your test code in `statsCases/` folder by creating a separate folder for it, for example `statsCases/some-file-import-stats/index.js`
<ide>
<ide> ```javascript
<del>import(./someModule);
<add>import("./someModule");
<ide> ```
<ide> * don't forget the `webpack.config.js`
<ide> * run the test
| 1
|
Javascript
|
Javascript
|
remove typos in code example
|
42290bd66c38ce78122b66789eb3c898cd532dc8
|
<ide><path>lib/ember.js
<ide> Ember.Array = Ember.Mixin.create(Ember.Enumerable, /** @scope Ember.Array.protot
<ide> arr.indexOf("a", -1); // 4
<ide> arr.indexOf("b", 3); // -1
<ide> arr.indexOf("a", 100); // -1
<del> ```javascript
<add> ```
<ide>
<ide> @method indexOf
<ide> @param {Object} object the item to search for
<ide> Ember.MutableArray = Ember.Mixin.create(Ember.Array, Ember.MutableEnumerable,
<ide> var colors = ["red", "green", "blue"];
<ide> colors.insertAt(2, "yellow"); // ["red", "green", "yellow", "blue"]
<ide> colors.insertAt(5, "orange"); // Error: Index out of range
<del> ```javascript
<add> ```
<ide>
<ide> @method insertAt
<ide> @param {Number} idx index of insert the object at.
<ide><path>packages/ember-old-router/lib/router.js
<ide> var merge = function(original, hash) {
<ide> })
<ide> });
<ide> App.initialize();
<del> ```javascript
<add> ```
<ide>
<ide> And application code:
<ide>
<ide><path>packages/ember-runtime/lib/mixins/array.js
<ide> Ember.Array = Ember.Mixin.create(Ember.Enumerable, /** @scope Ember.Array.protot
<ide> arr.indexOf("a", -1); // 4
<ide> arr.indexOf("b", 3); // -1
<ide> arr.indexOf("a", 100); // -1
<del> ```javascript
<add> ```
<ide>
<ide> @method indexOf
<ide> @param {Object} object the item to search for
<ide><path>packages/ember-runtime/lib/mixins/mutable_array.js
<ide> Ember.MutableArray = Ember.Mixin.create(Ember.Array, Ember.MutableEnumerable,
<ide> var colors = ["red", "green", "blue"];
<ide> colors.insertAt(2, "yellow"); // ["red", "green", "yellow", "blue"]
<ide> colors.insertAt(5, "orange"); // Error: Index out of range
<del> ```javascript
<add> ```
<ide>
<ide> @method insertAt
<ide> @param {Number} idx index of insert the object at.
| 4
|
Python
|
Python
|
use subprocess, not execv
|
e1f3bdf72c2f1ecb3e1da66902b3a1da998306f5
|
<ide><path>runtests.py
<ide> def main(argv):
<ide> if args.shell:
<ide> shell = os.environ.get('SHELL', 'sh')
<ide> print("Spawning a Unix shell...")
<del> os.execv(shell, [shell] + extra_argv)
<del> sys.exit(1)
<add> subprocess.call([shell] + extra_argv)
<add> sys.exit(0)
<ide>
<ide> if args.coverage:
<ide> dst_dir = os.path.join(ROOT_DIR, 'build', 'coverage')
| 1
|
Javascript
|
Javascript
|
fix preview bug in case of long lines
|
2986068c5a168dc314b696d2cad4155675f741e5
|
<ide><path>lib/internal/repl/utils.js
<ide> function setupPreview(repl, contextSymbol, bufferSymbol, active) {
<ide> return;
<ide> }
<ide>
<add> // Do not show previews in case the current line is longer than the column
<add> // width.
<add> // TODO(BridgeAR): Fix me. This should not be necessary. It currently breaks
<add> // the output though. We also have to check for characters that have more
<add> // than a single byte as length. Check Interface.prototype._moveCursor. It
<add> // contains the necessary logic.
<add> if (repl.line.length + repl._prompt.length > repl.columns) {
<add> return;
<add> }
<add>
<ide> // Add the autocompletion preview.
<ide> // TODO(BridgeAR): Trigger the input preview after the completion preview.
<ide> // That way it's possible to trigger the input prefix including the
| 1
|
Python
|
Python
|
save some changes
|
bbcfd6bae069aa8d59dbbd0be2fcb271084f3b13
|
<ide><path>research/object_detection/core/box_predictor.py
<ide> def _predict(self, image_features, num_predictions_per_location, **params):
<ide> pass
<ide>
<ide>
<del>class KerasBoxPredictor(tf.keras.Model):
<add>class KerasBoxPredictor(tf.keras.layers.Layer):
<ide> """Keras-based BoxPredictor."""
<ide>
<ide> def __init__(self, is_training, num_classes, freeze_batchnorm,
<ide><path>research/object_detection/dataset_tools/context_rcnn/add_context_to_examples.py
<ide> import itertools
<ide> import json
<ide> import os
<del>
<del>import apache_beam as beam
<ide> import numpy as np
<ide> import PIL.Image
<ide> import six
<ide> import tensorflow.compat.v1 as tf
<ide>
<add>try:
<add> import apache_beam as beam # pylint:disable=g-import-not-at-top
<add>except ModuleNotFoundError:
<add> pass
<add>
<ide>
<ide> class ReKeyDataFn(beam.DoFn):
<ide> """Re-keys tfrecords by sequence_key.
<ide><path>research/object_detection/dataset_tools/context_rcnn/add_context_to_examples_tf1_test.py
<ide> import os
<ide> import tempfile
<ide> import unittest
<del>import apache_beam as beam
<add>
<ide> import numpy as np
<ide> import six
<ide> import tensorflow.compat.v1 as tf
<ide> from object_detection.utils import tf_version
<ide>
<ide>
<add>try:
<add> import apache_beam as beam # pylint:disable=g-import-not-at-top
<add>except ModuleNotFoundError:
<add> pass
<add>
<add>
<ide> @contextlib.contextmanager
<ide> def InMemoryTFRecord(entries):
<ide> temp = tempfile.NamedTemporaryFile(delete=False)
<ide><path>research/object_detection/dataset_tools/context_rcnn/create_cococameratraps_tfexample_main.py
<ide> import json
<ide> import logging
<ide> import os
<del>import apache_beam as beam
<ide> import numpy as np
<ide> import PIL.Image
<ide> import tensorflow.compat.v1 as tf
<ide> from object_detection.utils import dataset_util
<ide>
<add>try:
<add> import apache_beam as beam # pylint:disable=g-import-not-at-top
<add>except ModuleNotFoundError:
<add> pass
<add>
<ide>
<ide> class ParseImage(beam.DoFn):
<ide> """A DoFn that parses a COCO-CameraTraps json and emits TFRecords."""
<ide><path>research/object_detection/dataset_tools/context_rcnn/create_cococameratraps_tfexample_tf1_test.py
<ide> import tempfile
<ide> import unittest
<ide>
<del>import apache_beam as beam
<ide> import numpy as np
<ide>
<ide> from PIL import Image
<ide> import tensorflow.compat.v1 as tf
<ide> from object_detection.dataset_tools.context_rcnn import create_cococameratraps_tfexample_main
<ide> from object_detection.utils import tf_version
<ide>
<add>try:
<add> import apache_beam as beam # pylint:disable=g-import-not-at-top
<add>except ModuleNotFoundError:
<add> pass
<add>
<ide>
<ide> @unittest.skipIf(tf_version.is_tf2(), 'Skipping TF1.X only test.')
<ide> class CreateCOCOCameraTrapsTfexampleTest(tf.test.TestCase):
<ide><path>research/object_detection/dataset_tools/context_rcnn/generate_detection_data.py
<ide> class label in the tf.Example.
<ide> import argparse
<ide> import os
<ide> import threading
<del>import apache_beam as beam
<ide> import tensorflow.compat.v1 as tf
<add>try:
<add> import apache_beam as beam # pylint:disable=g-import-not-at-top
<add>except ModuleNotFoundError:
<add> pass
<ide>
<ide>
<ide> class GenerateDetectionDataFn(beam.DoFn):
<ide><path>research/object_detection/dataset_tools/context_rcnn/generate_detection_data_tf1_test.py
<ide> import os
<ide> import tempfile
<ide> import unittest
<del>import apache_beam as beam
<ide> import numpy as np
<ide> import six
<ide> import tensorflow.compat.v1 as tf
<ide> else:
<ide> mock = unittest.mock
<ide>
<add>try:
<add> import apache_beam as beam # pylint:disable=g-import-not-at-top
<add>except ModuleNotFoundError:
<add> pass
<add>
<ide>
<ide> class FakeModel(model.DetectionModel):
<ide> """A Fake Detection model with expected output nodes from post-processing."""
<ide><path>research/object_detection/dataset_tools/context_rcnn/generate_embedding_data.py
<ide> --input_type tf_example \
<ide> --pipeline_config_path path/to/faster_rcnn_model.config \
<ide> --trained_checkpoint_prefix path/to/model.ckpt \
<del> --output_directory path/to/exported_model_directory
<add> --output_directory path/to/exported_model_directory \
<add> --additional_output_tensor_names detection_features
<ide>
<ide> python generate_embedding_data.py \
<ide> --alsologtostderr \
<ide> import os
<ide> import threading
<ide>
<del>import apache_beam as beam
<ide> import numpy as np
<ide> import six
<ide> import tensorflow.compat.v1 as tf
<ide>
<add>try:
<add> import apache_beam as beam # pylint:disable=g-import-not-at-top
<add>except ModuleNotFoundError:
<add> pass
<add>
<ide>
<ide> class GenerateEmbeddingDataFn(beam.DoFn):
<ide> """Generates embedding data for camera trap images.
<ide><path>research/object_detection/dataset_tools/context_rcnn/generate_embedding_data_tf1_test.py
<ide> import os
<ide> import tempfile
<ide> import unittest
<del>import apache_beam as beam
<ide> import numpy as np
<ide> import six
<ide> import tensorflow.compat.v1 as tf
<ide> else:
<ide> mock = unittest.mock
<ide>
<add>try:
<add> import apache_beam as beam # pylint:disable=g-import-not-at-top
<add>except ModuleNotFoundError:
<add> pass
<add>
<ide>
<ide> class FakeModel(model.DetectionModel):
<ide> """A Fake Detection model with expected output nodes from post-processing."""
<ide><path>research/object_detection/predictors/heads/head.py
<ide> def predict(self, features, num_predictions_per_location):
<ide> pass
<ide>
<ide>
<del>class KerasHead(tf.keras.Model):
<add>class KerasHead(tf.keras.layers.Layer):
<ide> """Keras head base class."""
<ide>
<ide> def call(self, features):
| 10
|
Ruby
|
Ruby
|
build fix for sharedgeneratortests
|
1206e88a7535d29487b416121c31b23762a12abd
|
<ide><path>railties/test/generators/shared_generator_tests.rb
<ide> def test_dev_option
<ide> generator([destination_root], :dev => true).expects(:bundle_command).with('install').once
<ide> quietly { generator.invoke_all }
<ide> rails_path = File.expand_path('../../..', Rails.root)
<del> assert_file 'Gemfile', /^gem\s+["']rails["'],\s+:path\s+=>\s+["']#{Regexp.escape(rails_path)}["']$/
<add> assert_file 'Gemfile', /^gem\s+["']rails["'],\s+:path\s+:\s+["']#{Regexp.escape(rails_path)}["']$/
<ide> end
<ide>
<ide> def test_edge_option
<ide> generator([destination_root], :edge => true).expects(:bundle_command).with('install').once
<ide> quietly { generator.invoke_all }
<del> assert_file 'Gemfile', %r{^gem\s+["']rails["'],\s+:github\s+=>\s+["']#{Regexp.escape("rails/rails")}["']$}
<add> assert_file 'Gemfile', %r{^gem\s+["']rails["'],\s+:github\s+:\s+["']#{Regexp.escape("rails/rails")}["']$}
<ide> end
<ide>
<ide> def test_skip_gemfile
| 1
|
Javascript
|
Javascript
|
make createclass 10-15% faster on complex specs
|
50c81d5fe68096fec9e4c5ff6c6cee73cd07704e
|
<ide><path>src/isomorphic/classic/class/ReactClass.js
<ide> function validateTypeDef(Constructor, typeDef, location) {
<ide> }
<ide> }
<ide>
<del>function validateMethodOverride(proto, name) {
<add>function validateMethodOverride(isAlreadyDefined, name) {
<ide> var specPolicy = ReactClassInterface.hasOwnProperty(name) ?
<ide> ReactClassInterface[name] :
<ide> null;
<ide> function validateMethodOverride(proto, name) {
<ide> }
<ide>
<ide> // Disallow defining methods more than once unless explicitly allowed.
<del> if (proto.hasOwnProperty(name)) {
<add> if (isAlreadyDefined) {
<ide> invariant(
<ide> specPolicy === SpecPolicy.DEFINE_MANY ||
<ide> specPolicy === SpecPolicy.DEFINE_MANY_MERGED,
<ide> function mixSpecIntoComponent(Constructor, spec) {
<ide> );
<ide>
<ide> var proto = Constructor.prototype;
<add> var autoBindPairs = proto.__reactAutoBindPairs;
<ide>
<ide> // By handling mixins before any other properties, we ensure the same
<ide> // chaining order is applied to methods with DEFINE_MANY policy, whether
<ide> function mixSpecIntoComponent(Constructor, spec) {
<ide> }
<ide>
<ide> var property = spec[name];
<del> validateMethodOverride(proto, name);
<add> var isAlreadyDefined = proto.hasOwnProperty(name);
<add> validateMethodOverride(isAlreadyDefined, name);
<ide>
<ide> if (RESERVED_SPEC_KEYS.hasOwnProperty(name)) {
<ide> RESERVED_SPEC_KEYS[name](Constructor, property);
<ide> function mixSpecIntoComponent(Constructor, spec) {
<ide> // 2. Overridden methods (that were mixed in).
<ide> var isReactClassMethod =
<ide> ReactClassInterface.hasOwnProperty(name);
<del> var isAlreadyDefined = proto.hasOwnProperty(name);
<ide> var isFunction = typeof property === 'function';
<ide> var shouldAutoBind =
<ide> isFunction &&
<ide> function mixSpecIntoComponent(Constructor, spec) {
<ide> spec.autobind !== false;
<ide>
<ide> if (shouldAutoBind) {
<del> if (!proto.__reactAutoBindMap) {
<del> proto.__reactAutoBindMap = {};
<del> }
<del> proto.__reactAutoBindMap[name] = property;
<add> autoBindPairs.push(name, property);
<ide> proto[name] = property;
<ide> } else {
<ide> if (isAlreadyDefined) {
<ide> function bindAutoBindMethod(component, method) {
<ide> * @param {object} component Component whose method is going to be bound.
<ide> */
<ide> function bindAutoBindMethods(component) {
<del> for (var autoBindKey in component.__reactAutoBindMap) {
<del> if (component.__reactAutoBindMap.hasOwnProperty(autoBindKey)) {
<del> var method = component.__reactAutoBindMap[autoBindKey];
<del> component[autoBindKey] = bindAutoBindMethod(
<del> component,
<del> method
<del> );
<del> }
<add> var pairs = component.__reactAutoBindPairs;
<add> for (var i = 0; i < pairs.length; i += 2) {
<add> var autoBindKey = pairs[i];
<add> var method = pairs[i + 1];
<add> component[autoBindKey] = bindAutoBindMethod(
<add> component,
<add> method
<add> );
<ide> }
<ide> }
<ide>
<ide> var ReactClass = {
<ide> }
<ide>
<ide> // Wire up auto-binding
<del> if (this.__reactAutoBindMap) {
<add> if (this.__reactAutoBindPairs.length) {
<ide> bindAutoBindMethods(this);
<ide> }
<ide>
<ide> var ReactClass = {
<ide> };
<ide> Constructor.prototype = new ReactClassComponent();
<ide> Constructor.prototype.constructor = Constructor;
<add> Constructor.prototype.__reactAutoBindPairs = [];
<ide>
<ide> injectedMixins.forEach(
<ide> mixSpecIntoComponent.bind(null, Constructor)
| 1
|
Python
|
Python
|
improve model tester
|
f69eb24b5a88f057a70f6ca95e9374e4ed599959
|
<ide><path>tests/models/albert/test_modeling_albert.py
<ide> class AlbertModelTester:
<ide> def __init__(
<ide> self,
<ide> parent,
<add> batch_size=13,
<add> seq_length=7,
<add> is_training=True,
<add> use_input_mask=True,
<add> use_token_type_ids=True,
<add> use_labels=True,
<add> vocab_size=99,
<add> embedding_size=16,
<add> hidden_size=36,
<add> num_hidden_layers=6,
<add> num_hidden_groups=6,
<add> num_attention_heads=6,
<add> intermediate_size=37,
<add> hidden_act="gelu",
<add> hidden_dropout_prob=0.1,
<add> attention_probs_dropout_prob=0.1,
<add> max_position_embeddings=512,
<add> type_vocab_size=16,
<add> type_sequence_label_size=2,
<add> initializer_range=0.02,
<add> num_labels=3,
<add> num_choices=4,
<add> scope=None,
<ide> ):
<ide> self.parent = parent
<del> self.batch_size = 13
<del> self.seq_length = 7
<del> self.is_training = True
<del> self.use_input_mask = True
<del> self.use_token_type_ids = True
<del> self.use_labels = True
<del> self.vocab_size = 99
<del> self.embedding_size = 16
<del> self.hidden_size = 36
<del> self.num_hidden_layers = 6
<del> self.num_hidden_groups = 6
<del> self.num_attention_heads = 6
<del> self.intermediate_size = 37
<del> self.hidden_act = "gelu"
<del> self.hidden_dropout_prob = 0.1
<del> self.attention_probs_dropout_prob = 0.1
<del> self.max_position_embeddings = 512
<del> self.type_vocab_size = 16
<del> self.type_sequence_label_size = 2
<del> self.initializer_range = 0.02
<del> self.num_labels = 3
<del> self.num_choices = 4
<del> self.scope = None
<add> self.batch_size = batch_size
<add> self.seq_length = seq_length
<add> self.is_training = is_training
<add> self.use_input_mask = use_input_mask
<add> self.use_token_type_ids = use_token_type_ids
<add> self.use_labels = use_labels
<add> self.vocab_size = vocab_size
<add> self.embedding_size = embedding_size
<add> self.hidden_size = hidden_size
<add> self.num_hidden_layers = num_hidden_layers
<add> self.num_hidden_groups = num_hidden_groups
<add> self.num_attention_heads = num_attention_heads
<add> self.intermediate_size = intermediate_size
<add> self.hidden_act = hidden_act
<add> self.hidden_dropout_prob = hidden_dropout_prob
<add> self.attention_probs_dropout_prob = attention_probs_dropout_prob
<add> self.max_position_embeddings = max_position_embeddings
<add> self.type_vocab_size = type_vocab_size
<add> self.type_sequence_label_size = type_sequence_label_size
<add> self.initializer_range = initializer_range
<add> self.num_labels = num_labels
<add> self.num_choices = num_choices
<add> self.scope = scope
<ide>
<ide> def prepare_config_and_inputs(self):
<ide> input_ids = ids_tensor([self.batch_size, self.seq_length], self.vocab_size)
<ide><path>tests/models/canine/test_modeling_canine.py
<ide> def __init__(
<ide> use_input_mask=True,
<ide> use_token_type_ids=True,
<ide> use_labels=True,
<add> # let's use a vocab size that's way bigger than BERT's one
<add> vocab_size=100000,
<ide> hidden_size=32,
<ide> num_hidden_layers=5,
<ide> num_attention_heads=4,
<ide> def __init__(
<ide> self.use_input_mask = use_input_mask
<ide> self.use_token_type_ids = use_token_type_ids
<ide> self.use_labels = use_labels
<add> self.vocab_size = vocab_size
<ide> self.hidden_size = hidden_size
<ide> self.num_hidden_layers = num_hidden_layers
<ide> self.num_attention_heads = num_attention_heads
<ide> def __init__(
<ide> self.scope = scope
<ide>
<ide> def prepare_config_and_inputs(self):
<del> # let's use a vocab size that's way bigger than BERT's one
<del> input_ids = ids_tensor([self.batch_size, self.seq_length], 100000)
<add> input_ids = ids_tensor([self.batch_size, self.seq_length], self.vocab_size)
<ide>
<ide> input_mask = None
<ide> if self.use_input_mask:
<ide><path>tests/models/ctrl/test_modeling_ctrl.py
<ide> class CTRLModelTester:
<ide> def __init__(
<ide> self,
<ide> parent,
<add> batch_size=14,
<add> seq_length=7,
<add> is_training=True,
<add> use_token_type_ids=True,
<add> use_input_mask=True,
<add> use_labels=True,
<add> use_mc_token_ids=True,
<add> vocab_size=99,
<add> hidden_size=32,
<add> num_hidden_layers=5,
<add> num_attention_heads=4,
<add> intermediate_size=37,
<add> hidden_act="gelu",
<add> hidden_dropout_prob=0.1,
<add> attention_probs_dropout_prob=0.1,
<add> max_position_embeddings=512,
<add> type_vocab_size=16,
<add> type_sequence_label_size=2,
<add> initializer_range=0.02,
<add> num_labels=3,
<add> num_choices=4,
<add> scope=None,
<ide> ):
<ide> self.parent = parent
<del> self.batch_size = 14
<del> self.seq_length = 7
<del> self.is_training = True
<del> self.use_token_type_ids = True
<del> self.use_input_mask = True
<del> self.use_labels = True
<del> self.use_mc_token_ids = True
<del> self.vocab_size = 99
<del> self.hidden_size = 32
<del> self.num_hidden_layers = 5
<del> self.num_attention_heads = 4
<del> self.intermediate_size = 37
<del> self.hidden_act = "gelu"
<del> self.hidden_dropout_prob = 0.1
<del> self.attention_probs_dropout_prob = 0.1
<del> self.max_position_embeddings = 512
<del> self.type_vocab_size = 16
<del> self.type_sequence_label_size = 2
<del> self.initializer_range = 0.02
<del> self.num_labels = 3
<del> self.num_choices = 4
<del> self.scope = None
<add> self.batch_size = batch_size
<add> self.seq_length = seq_length
<add> self.is_training = is_training
<add> self.use_token_type_ids = use_token_type_ids
<add> self.use_input_mask = use_input_mask
<add> self.use_labels = use_labels
<add> self.use_mc_token_ids = use_mc_token_ids
<add> self.vocab_size = vocab_size
<add> self.hidden_size = hidden_size
<add> self.num_hidden_layers = num_hidden_layers
<add> self.num_attention_heads = num_attention_heads
<add> self.intermediate_size = intermediate_size
<add> self.hidden_act = hidden_act
<add> self.hidden_dropout_prob = hidden_dropout_prob
<add> self.attention_probs_dropout_prob = attention_probs_dropout_prob
<add> self.max_position_embeddings = max_position_embeddings
<add> self.type_vocab_size = type_vocab_size
<add> self.type_sequence_label_size = type_sequence_label_size
<add> self.initializer_range = initializer_range
<add> self.num_labels = num_labels
<add> self.num_choices = num_choices
<add> self.scope = scope
<ide> self.pad_token_id = self.vocab_size - 1
<ide>
<ide> def prepare_config_and_inputs(self):
<ide><path>tests/models/data2vec/test_modeling_data2vec_text.py
<ide> class Data2VecTextModelTester:
<ide> def __init__(
<ide> self,
<ide> parent,
<add> batch_size=13,
<add> seq_length=7,
<add> is_training=True,
<add> use_input_mask=True,
<add> use_token_type_ids=True,
<add> use_labels=True,
<add> vocab_size=99,
<add> hidden_size=32,
<add> num_hidden_layers=5,
<add> num_attention_heads=4,
<add> intermediate_size=37,
<add> hidden_act="gelu",
<add> hidden_dropout_prob=0.1,
<add> attention_probs_dropout_prob=0.1,
<add> max_position_embeddings=512,
<add> type_vocab_size=16,
<add> type_sequence_label_size=2,
<add> initializer_range=0.02,
<add> num_labels=3,
<add> num_choices=4,
<add> scope=None,
<ide> ):
<ide> self.parent = parent
<del> self.batch_size = 13
<del> self.seq_length = 7
<del> self.is_training = True
<del> self.use_input_mask = True
<del> self.use_token_type_ids = True
<del> self.use_labels = True
<del> self.vocab_size = 99
<del> self.hidden_size = 32
<del> self.num_hidden_layers = 5
<del> self.num_attention_heads = 4
<del> self.intermediate_size = 37
<del> self.hidden_act = "gelu"
<del> self.hidden_dropout_prob = 0.1
<del> self.attention_probs_dropout_prob = 0.1
<del> self.max_position_embeddings = 512
<del> self.type_vocab_size = 16
<del> self.type_sequence_label_size = 2
<del> self.initializer_range = 0.02
<del> self.num_labels = 3
<del> self.num_choices = 4
<del> self.scope = None
<add> self.batch_size = batch_size
<add> self.seq_length = seq_length
<add> self.is_training = is_training
<add> self.use_input_mask = use_input_mask
<add> self.use_token_type_ids = use_token_type_ids
<add> self.use_labels = use_labels
<add> self.vocab_size = vocab_size
<add> self.hidden_size = hidden_size
<add> self.num_hidden_layers = num_hidden_layers
<add> self.num_attention_heads = num_attention_heads
<add> self.intermediate_size = intermediate_size
<add> self.hidden_act = hidden_act
<add> self.hidden_dropout_prob = hidden_dropout_prob
<add> self.attention_probs_dropout_prob = attention_probs_dropout_prob
<add> self.max_position_embeddings = max_position_embeddings
<add> self.type_vocab_size = type_vocab_size
<add> self.type_sequence_label_size = type_sequence_label_size
<add> self.initializer_range = initializer_range
<add> self.num_labels = num_labels
<add> self.num_choices = num_choices
<add> self.scope = scope
<ide>
<ide> def prepare_config_and_inputs(self):
<ide> input_ids = ids_tensor([self.batch_size, self.seq_length], self.vocab_size)
<ide><path>tests/models/electra/test_modeling_electra.py
<ide> class ElectraModelTester:
<ide> def __init__(
<ide> self,
<ide> parent,
<add> batch_size=13,
<add> seq_length=7,
<add> is_training=True,
<add> use_input_mask=True,
<add> use_token_type_ids=True,
<add> use_labels=True,
<add> vocab_size=99,
<add> hidden_size=32,
<add> num_hidden_layers=5,
<add> num_attention_heads=4,
<add> intermediate_size=37,
<add> hidden_act="gelu",
<add> hidden_dropout_prob=0.1,
<add> attention_probs_dropout_prob=0.1,
<add> max_position_embeddings=512,
<add> type_vocab_size=16,
<add> type_sequence_label_size=2,
<add> initializer_range=0.02,
<add> num_labels=3,
<add> num_choices=4,
<add> scope=None,
<ide> ):
<ide> self.parent = parent
<del> self.batch_size = 13
<del> self.seq_length = 7
<del> self.is_training = True
<del> self.use_input_mask = True
<del> self.use_token_type_ids = True
<del> self.use_labels = True
<del> self.vocab_size = 99
<del> self.hidden_size = 32
<del> self.num_hidden_layers = 5
<del> self.num_attention_heads = 4
<del> self.intermediate_size = 37
<del> self.hidden_act = "gelu"
<del> self.hidden_dropout_prob = 0.1
<del> self.attention_probs_dropout_prob = 0.1
<del> self.max_position_embeddings = 512
<del> self.type_vocab_size = 16
<del> self.type_sequence_label_size = 2
<del> self.initializer_range = 0.02
<del> self.num_labels = 3
<del> self.num_choices = 4
<del> self.scope = None
<add> self.batch_size = batch_size
<add> self.seq_length = seq_length
<add> self.is_training = is_training
<add> self.use_input_mask = use_input_mask
<add> self.use_token_type_ids = use_token_type_ids
<add> self.use_labels = use_labels
<add> self.vocab_size = vocab_size
<add> self.hidden_size = hidden_size
<add> self.num_hidden_layers = num_hidden_layers
<add> self.num_attention_heads = num_attention_heads
<add> self.intermediate_size = intermediate_size
<add> self.hidden_act = hidden_act
<add> self.hidden_dropout_prob = hidden_dropout_prob
<add> self.attention_probs_dropout_prob = attention_probs_dropout_prob
<add> self.max_position_embeddings = max_position_embeddings
<add> self.type_vocab_size = type_vocab_size
<add> self.type_sequence_label_size = type_sequence_label_size
<add> self.initializer_range = initializer_range
<add> self.num_labels = num_labels
<add> self.num_choices = num_choices
<add> self.scope = scope
<ide>
<ide> def prepare_config_and_inputs(self):
<ide> input_ids = ids_tensor([self.batch_size, self.seq_length], self.vocab_size)
<ide><path>tests/models/esm/test_modeling_esm.py
<ide> class EsmModelTester:
<ide> def __init__(
<ide> self,
<ide> parent,
<add> batch_size=13,
<add> seq_length=7,
<add> is_training=False,
<add> use_input_mask=True,
<add> use_token_type_ids=False,
<add> use_labels=True,
<add> vocab_size=33,
<add> hidden_size=32,
<add> num_hidden_layers=5,
<add> num_attention_heads=4,
<add> intermediate_size=37,
<add> hidden_act="gelu",
<add> hidden_dropout_prob=0.1,
<add> attention_probs_dropout_prob=0.1,
<add> max_position_embeddings=512,
<add> type_vocab_size=16,
<add> type_sequence_label_size=2,
<add> initializer_range=0.02,
<add> num_labels=3,
<add> num_choices=4,
<add> scope=None,
<ide> ):
<ide> self.parent = parent
<del> self.batch_size = 13
<del> self.seq_length = 7
<del> self.is_training = False
<del> self.use_input_mask = True
<del> self.use_token_type_ids = False
<del> self.use_labels = True
<del> self.vocab_size = 33
<del> self.hidden_size = 32
<del> self.num_hidden_layers = 5
<del> self.num_attention_heads = 4
<del> self.intermediate_size = 37
<del> self.hidden_act = "gelu"
<del> self.hidden_dropout_prob = 0.1
<del> self.attention_probs_dropout_prob = 0.1
<del> self.max_position_embeddings = 512
<del> self.type_vocab_size = 16
<del> self.type_sequence_label_size = 2
<del> self.initializer_range = 0.02
<del> self.num_labels = 3
<del> self.num_choices = 4
<del> self.scope = None
<add> self.batch_size = batch_size
<add> self.seq_length = seq_length
<add> self.is_training = is_training
<add> self.use_input_mask = use_input_mask
<add> self.use_token_type_ids = use_token_type_ids
<add> self.use_labels = use_labels
<add> self.vocab_size = vocab_size
<add> self.hidden_size = hidden_size
<add> self.num_hidden_layers = num_hidden_layers
<add> self.num_attention_heads = num_attention_heads
<add> self.intermediate_size = intermediate_size
<add> self.hidden_act = hidden_act
<add> self.hidden_dropout_prob = hidden_dropout_prob
<add> self.attention_probs_dropout_prob = attention_probs_dropout_prob
<add> self.max_position_embeddings = max_position_embeddings
<add> self.type_vocab_size = type_vocab_size
<add> self.type_sequence_label_size = type_sequence_label_size
<add> self.initializer_range = initializer_range
<add> self.num_labels = num_labels
<add> self.num_choices = num_choices
<add> self.scope = scope
<ide>
<ide> def prepare_config_and_inputs(self):
<ide> input_ids = ids_tensor([self.batch_size, self.seq_length], self.vocab_size)
<ide><path>tests/models/esm/test_modeling_esmfold.py
<ide> class EsmFoldModelTester:
<ide> def __init__(
<ide> self,
<ide> parent,
<add> batch_size=13,
<add> seq_length=7,
<add> is_training=False,
<add> use_input_mask=True,
<add> use_token_type_ids=False,
<add> use_labels=False,
<add> vocab_size=19,
<add> hidden_size=32,
<add> num_hidden_layers=5,
<add> num_attention_heads=4,
<add> intermediate_size=37,
<add> hidden_act="gelu",
<add> hidden_dropout_prob=0.1,
<add> attention_probs_dropout_prob=0.1,
<add> max_position_embeddings=512,
<add> type_vocab_size=16,
<add> type_sequence_label_size=2,
<add> initializer_range=0.02,
<add> num_labels=3,
<add> num_choices=4,
<add> scope=None,
<ide> ):
<ide> self.parent = parent
<del> self.batch_size = 13
<del> self.seq_length = 7
<del> self.is_training = False
<del> self.use_input_mask = True
<del> self.use_token_type_ids = False
<del> self.use_labels = False
<del> self.vocab_size = 19
<del> self.hidden_size = 32
<del> self.num_hidden_layers = 5
<del> self.num_attention_heads = 4
<del> self.intermediate_size = 37
<del> self.hidden_act = "gelu"
<del> self.hidden_dropout_prob = 0.1
<del> self.attention_probs_dropout_prob = 0.1
<del> self.max_position_embeddings = 512
<del> self.type_vocab_size = 16
<del> self.type_sequence_label_size = 2
<del> self.initializer_range = 0.02
<del> self.num_labels = 3
<del> self.num_choices = 4
<del> self.scope = None
<add> self.batch_size = batch_size
<add> self.seq_length = seq_length
<add> self.is_training = is_training
<add> self.use_input_mask = use_input_mask
<add> self.use_token_type_ids = use_token_type_ids
<add> self.use_labels = use_labels
<add> self.vocab_size = vocab_size
<add> self.hidden_size = hidden_size
<add> self.num_hidden_layers = num_hidden_layers
<add> self.num_attention_heads = num_attention_heads
<add> self.intermediate_size = intermediate_size
<add> self.hidden_act = hidden_act
<add> self.hidden_dropout_prob = hidden_dropout_prob
<add> self.attention_probs_dropout_prob = attention_probs_dropout_prob
<add> self.max_position_embeddings = max_position_embeddings
<add> self.type_vocab_size = type_vocab_size
<add> self.type_sequence_label_size = type_sequence_label_size
<add> self.initializer_range = initializer_range
<add> self.num_labels = num_labels
<add> self.num_choices = num_choices
<add> self.scope = scope
<ide>
<ide> def prepare_config_and_inputs(self):
<ide> input_ids = ids_tensor([self.batch_size, self.seq_length], self.vocab_size)
<ide><path>tests/models/flaubert/test_modeling_flaubert.py
<ide> class FlaubertModelTester(object):
<ide> def __init__(
<ide> self,
<ide> parent,
<add> batch_size=13,
<add> seq_length=7,
<add> is_training=True,
<add> use_input_lengths=True,
<add> use_token_type_ids=True,
<add> use_labels=True,
<add> gelu_activation=True,
<add> sinusoidal_embeddings=False,
<add> causal=False,
<add> asm=False,
<add> n_langs=2,
<add> vocab_size=99,
<add> n_special=0,
<add> hidden_size=32,
<add> num_hidden_layers=5,
<add> num_attention_heads=4,
<add> hidden_dropout_prob=0.1,
<add> attention_probs_dropout_prob=0.1,
<add> max_position_embeddings=512,
<add> type_vocab_size=12,
<add> type_sequence_label_size=2,
<add> initializer_range=0.02,
<add> num_labels=3,
<add> num_choices=4,
<add> summary_type="last",
<add> use_proj=None,
<add> scope=None,
<ide> ):
<ide> self.parent = parent
<del> self.batch_size = 13
<del> self.seq_length = 7
<del> self.is_training = True
<del> self.use_input_lengths = True
<del> self.use_token_type_ids = True
<del> self.use_labels = True
<del> self.gelu_activation = True
<del> self.sinusoidal_embeddings = False
<del> self.causal = False
<del> self.asm = False
<del> self.n_langs = 2
<del> self.vocab_size = 99
<del> self.n_special = 0
<del> self.hidden_size = 32
<del> self.num_hidden_layers = 5
<del> self.num_attention_heads = 4
<del> self.hidden_dropout_prob = 0.1
<del> self.attention_probs_dropout_prob = 0.1
<del> self.max_position_embeddings = 512
<del> self.type_vocab_size = 12
<del> self.type_sequence_label_size = 2
<del> self.initializer_range = 0.02
<del> self.num_labels = 3
<del> self.num_choices = 4
<del> self.summary_type = "last"
<del> self.use_proj = None
<del> self.scope = None
<add> self.batch_size = batch_size
<add> self.seq_length = seq_length
<add> self.is_training = is_training
<add> self.use_input_lengths = use_input_lengths
<add> self.use_token_type_ids = use_token_type_ids
<add> self.use_labels = use_labels
<add> self.gelu_activation = gelu_activation
<add> self.sinusoidal_embeddings = sinusoidal_embeddings
<add> self.causal = causal
<add> self.asm = asm
<add> self.n_langs = n_langs
<add> self.vocab_size = vocab_size
<add> self.n_special = n_special
<add> self.hidden_size = hidden_size
<add> self.num_hidden_layers = num_hidden_layers
<add> self.num_attention_heads = num_attention_heads
<add> self.hidden_dropout_prob = hidden_dropout_prob
<add> self.attention_probs_dropout_prob = attention_probs_dropout_prob
<add> self.max_position_embeddings = max_position_embeddings
<add> self.type_vocab_size = type_vocab_size
<add> self.type_sequence_label_size = type_sequence_label_size
<add> self.initializer_range = initializer_range
<add> self.num_labels = num_labels
<add> self.num_choices = num_choices
<add> self.summary_type = summary_type
<add> self.use_proj = use_proj
<add> self.scope = scope
<ide>
<ide> def prepare_config_and_inputs(self):
<ide> input_ids = ids_tensor([self.batch_size, self.seq_length], self.vocab_size)
<ide><path>tests/models/fsmt/test_modeling_fsmt.py
<ide> class FSMTModelTester:
<ide> def __init__(
<ide> self,
<ide> parent,
<add> src_vocab_size=99,
<add> tgt_vocab_size=99,
<add> langs=["ru", "en"],
<add> batch_size=13,
<add> seq_length=7,
<add> is_training=False,
<add> use_labels=False,
<add> hidden_size=16,
<add> num_hidden_layers=2,
<add> num_attention_heads=4,
<add> intermediate_size=4,
<add> hidden_act="relu",
<add> hidden_dropout_prob=0.1,
<add> attention_probs_dropout_prob=0.1,
<add> max_position_embeddings=20,
<add> bos_token_id=0,
<add> pad_token_id=1,
<add> eos_token_id=2,
<ide> ):
<ide> self.parent = parent
<del> self.src_vocab_size = 99
<del> self.tgt_vocab_size = 99
<del> self.langs = ["ru", "en"]
<del> self.batch_size = 13
<del> self.seq_length = 7
<del> self.is_training = False
<del> self.use_labels = False
<del> self.hidden_size = 16
<del> self.num_hidden_layers = 2
<del> self.num_attention_heads = 4
<del> self.intermediate_size = 4
<del> self.hidden_act = "relu"
<del> self.hidden_dropout_prob = 0.1
<del> self.attention_probs_dropout_prob = 0.1
<del> self.max_position_embeddings = 20
<del> self.bos_token_id = 0
<del> self.pad_token_id = 1
<del> self.eos_token_id = 2
<add> self.src_vocab_size = src_vocab_size
<add> self.tgt_vocab_size = tgt_vocab_size
<add> self.langs = langs
<add> self.batch_size = batch_size
<add> self.seq_length = seq_length
<add> self.is_training = is_training
<add> self.use_labels = use_labels
<add> self.hidden_size = hidden_size
<add> self.num_hidden_layers = num_hidden_layers
<add> self.num_attention_heads = num_attention_heads
<add> self.intermediate_size = intermediate_size
<add> self.hidden_act = hidden_act
<add> self.hidden_dropout_prob = hidden_dropout_prob
<add> self.attention_probs_dropout_prob = attention_probs_dropout_prob
<add> self.max_position_embeddings = max_position_embeddings
<add> self.bos_token_id = bos_token_id
<add> self.pad_token_id = pad_token_id
<add> self.eos_token_id = eos_token_id
<ide> torch.manual_seed(0)
<ide>
<ide> # hack needed for modeling_common tests - despite not really having this attribute in this model
<ide><path>tests/models/ibert/test_modeling_ibert.py
<ide> class IBertModelTester:
<ide> def __init__(
<ide> self,
<ide> parent,
<add> batch_size=13,
<add> seq_length=7,
<add> is_training=True,
<add> use_input_mask=True,
<add> use_token_type_ids=True,
<add> use_labels=True,
<add> vocab_size=99,
<add> hidden_size=32,
<add> num_hidden_layers=5,
<add> num_attention_heads=4,
<add> intermediate_size=37,
<add> hidden_act="gelu",
<add> hidden_dropout_prob=0.1,
<add> attention_probs_dropout_prob=0.1,
<add> max_position_embeddings=512,
<add> type_vocab_size=16,
<add> type_sequence_label_size=2,
<add> initializer_range=0.02,
<add> num_labels=3,
<add> num_choices=4,
<add> scope=None,
<ide> ):
<ide> self.parent = parent
<del> self.batch_size = 13
<del> self.seq_length = 7
<del> self.is_training = True
<del> self.use_input_mask = True
<del> self.use_token_type_ids = True
<del> self.use_labels = True
<del> self.vocab_size = 99
<del> self.hidden_size = 32
<del> self.num_hidden_layers = 5
<del> self.num_attention_heads = 4
<del> self.intermediate_size = 37
<del> self.hidden_act = "gelu"
<del> self.hidden_dropout_prob = 0.1
<del> self.attention_probs_dropout_prob = 0.1
<del> self.max_position_embeddings = 512
<del> self.type_vocab_size = 16
<del> self.type_sequence_label_size = 2
<del> self.initializer_range = 0.02
<del> self.num_labels = 3
<del> self.num_choices = 4
<del> self.scope = None
<add> self.batch_size = batch_size
<add> self.seq_length = seq_length
<add> self.is_training = is_training
<add> self.use_input_mask = use_input_mask
<add> self.use_token_type_ids = use_token_type_ids
<add> self.use_labels = use_labels
<add> self.vocab_size = vocab_size
<add> self.hidden_size = hidden_size
<add> self.num_hidden_layers = num_hidden_layers
<add> self.num_attention_heads = num_attention_heads
<add> self.intermediate_size = intermediate_size
<add> self.hidden_act = hidden_act
<add> self.hidden_dropout_prob = hidden_dropout_prob
<add> self.attention_probs_dropout_prob = attention_probs_dropout_prob
<add> self.max_position_embeddings = max_position_embeddings
<add> self.type_vocab_size = type_vocab_size
<add> self.type_sequence_label_size = type_sequence_label_size
<add> self.initializer_range = initializer_range
<add> self.num_labels = num_labels
<add> self.num_choices = num_choices
<add> self.scope = scope
<ide>
<ide> def prepare_config_and_inputs(self):
<ide> input_ids = ids_tensor([self.batch_size, self.seq_length], self.vocab_size)
<ide><path>tests/models/longformer/test_modeling_longformer.py
<ide> class LongformerModelTester:
<ide> def __init__(
<ide> self,
<ide> parent,
<add> batch_size=13,
<add> seq_length=7,
<add> is_training=True,
<add> use_input_mask=True,
<add> use_token_type_ids=True,
<add> use_labels=True,
<add> vocab_size=99,
<add> hidden_size=32,
<add> num_hidden_layers=5,
<add> num_attention_heads=4,
<add> intermediate_size=37,
<add> hidden_act="gelu",
<add> hidden_dropout_prob=0.1,
<add> attention_probs_dropout_prob=0.1,
<add> max_position_embeddings=512,
<add> type_vocab_size=16,
<add> type_sequence_label_size=2,
<add> initializer_range=0.02,
<add> num_labels=3,
<add> num_choices=4,
<add> scope=None,
<add> attention_window=4,
<ide> ):
<ide> self.parent = parent
<del> self.batch_size = 13
<del> self.seq_length = 7
<del> self.is_training = True
<del> self.use_input_mask = True
<del> self.use_token_type_ids = True
<del> self.use_labels = True
<del> self.vocab_size = 99
<del> self.hidden_size = 32
<del> self.num_hidden_layers = 5
<del> self.num_attention_heads = 4
<del> self.intermediate_size = 37
<del> self.hidden_act = "gelu"
<del> self.hidden_dropout_prob = 0.1
<del> self.attention_probs_dropout_prob = 0.1
<del> self.max_position_embeddings = 512
<del> self.type_vocab_size = 16
<del> self.type_sequence_label_size = 2
<del> self.initializer_range = 0.02
<del> self.num_labels = 3
<del> self.num_choices = 4
<del> self.scope = None
<del> self.attention_window = 4
<add> self.batch_size = batch_size
<add> self.seq_length = seq_length
<add> self.is_training = is_training
<add> self.use_input_mask = use_input_mask
<add> self.use_token_type_ids = use_token_type_ids
<add> self.use_labels = use_labels
<add> self.vocab_size = vocab_size
<add> self.hidden_size = hidden_size
<add> self.num_hidden_layers = num_hidden_layers
<add> self.num_attention_heads = num_attention_heads
<add> self.intermediate_size = intermediate_size
<add> self.hidden_act = hidden_act
<add> self.hidden_dropout_prob = hidden_dropout_prob
<add> self.attention_probs_dropout_prob = attention_probs_dropout_prob
<add> self.max_position_embeddings = max_position_embeddings
<add> self.type_vocab_size = type_vocab_size
<add> self.type_sequence_label_size = type_sequence_label_size
<add> self.initializer_range = initializer_range
<add> self.num_labels = num_labels
<add> self.num_choices = num_choices
<add> self.scope = scope
<add> self.attention_window = attention_window
<ide>
<ide> # `ModelTesterMixin.test_attention_outputs` is expecting attention tensors to be of size
<ide> # [num_attention_heads, encoder_seq_length, encoder_key_length], but LongformerSelfAttention
<ide><path>tests/models/openai/test_modeling_openai.py
<ide> class OpenAIGPTModelTester:
<ide> def __init__(
<ide> self,
<ide> parent,
<add> batch_size=13,
<add> seq_length=7,
<add> is_training=True,
<add> use_token_type_ids=True,
<add> use_labels=True,
<add> vocab_size=99,
<add> hidden_size=32,
<add> num_hidden_layers=5,
<add> num_attention_heads=4,
<add> intermediate_size=37,
<add> hidden_act="gelu",
<add> hidden_dropout_prob=0.1,
<add> attention_probs_dropout_prob=0.1,
<add> max_position_embeddings=512,
<add> type_vocab_size=16,
<add> type_sequence_label_size=2,
<add> initializer_range=0.02,
<add> num_labels=3,
<add> num_choices=4,
<add> scope=None,
<ide> ):
<ide> self.parent = parent
<del> self.batch_size = 13
<del> self.seq_length = 7
<del> self.is_training = True
<del> self.use_token_type_ids = True
<del> self.use_labels = True
<del> self.vocab_size = 99
<del> self.hidden_size = 32
<del> self.num_hidden_layers = 5
<del> self.num_attention_heads = 4
<del> self.intermediate_size = 37
<del> self.hidden_act = "gelu"
<del> self.hidden_dropout_prob = 0.1
<del> self.attention_probs_dropout_prob = 0.1
<del> self.max_position_embeddings = 512
<del> self.type_vocab_size = 16
<del> self.type_sequence_label_size = 2
<del> self.initializer_range = 0.02
<del> self.num_labels = 3
<del> self.num_choices = 4
<del> self.scope = None
<add> self.batch_size = batch_size
<add> self.seq_length = seq_length
<add> self.is_training = is_training
<add> self.use_token_type_ids = use_token_type_ids
<add> self.use_labels = use_labels
<add> self.vocab_size = vocab_size
<add> self.hidden_size = hidden_size
<add> self.num_hidden_layers = num_hidden_layers
<add> self.num_attention_heads = num_attention_heads
<add> self.intermediate_size = intermediate_size
<add> self.hidden_act = hidden_act
<add> self.hidden_dropout_prob = hidden_dropout_prob
<add> self.attention_probs_dropout_prob = attention_probs_dropout_prob
<add> self.max_position_embeddings = max_position_embeddings
<add> self.type_vocab_size = type_vocab_size
<add> self.type_sequence_label_size = type_sequence_label_size
<add> self.initializer_range = initializer_range
<add> self.num_labels = num_labels
<add> self.num_choices = num_choices
<add> self.scope = scope
<ide> self.pad_token_id = self.vocab_size - 1
<ide>
<ide> def prepare_config_and_inputs(self):
<ide><path>tests/models/roberta/test_modeling_roberta.py
<ide> class RobertaModelTester:
<ide> def __init__(
<ide> self,
<ide> parent,
<add> batch_size=13,
<add> seq_length=7,
<add> is_training=True,
<add> use_input_mask=True,
<add> use_token_type_ids=True,
<add> use_labels=True,
<add> vocab_size=99,
<add> hidden_size=32,
<add> num_hidden_layers=5,
<add> num_attention_heads=4,
<add> intermediate_size=37,
<add> hidden_act="gelu",
<add> hidden_dropout_prob=0.1,
<add> attention_probs_dropout_prob=0.1,
<add> max_position_embeddings=512,
<add> type_vocab_size=16,
<add> type_sequence_label_size=2,
<add> initializer_range=0.02,
<add> num_labels=3,
<add> num_choices=4,
<add> scope=None,
<ide> ):
<ide> self.parent = parent
<del> self.batch_size = 13
<del> self.seq_length = 7
<del> self.is_training = True
<del> self.use_input_mask = True
<del> self.use_token_type_ids = True
<del> self.use_labels = True
<del> self.vocab_size = 99
<del> self.hidden_size = 32
<del> self.num_hidden_layers = 5
<del> self.num_attention_heads = 4
<del> self.intermediate_size = 37
<del> self.hidden_act = "gelu"
<del> self.hidden_dropout_prob = 0.1
<del> self.attention_probs_dropout_prob = 0.1
<del> self.max_position_embeddings = 512
<del> self.type_vocab_size = 16
<del> self.type_sequence_label_size = 2
<del> self.initializer_range = 0.02
<del> self.num_labels = 3
<del> self.num_choices = 4
<del> self.scope = None
<add> self.batch_size = batch_size
<add> self.seq_length = seq_length
<add> self.is_training = is_training
<add> self.use_input_mask = use_input_mask
<add> self.use_token_type_ids = use_token_type_ids
<add> self.use_labels = use_labels
<add> self.vocab_size = vocab_size
<add> self.hidden_size = hidden_size
<add> self.num_hidden_layers = num_hidden_layers
<add> self.num_attention_heads = num_attention_heads
<add> self.intermediate_size = intermediate_size
<add> self.hidden_act = hidden_act
<add> self.hidden_dropout_prob = hidden_dropout_prob
<add> self.attention_probs_dropout_prob = attention_probs_dropout_prob
<add> self.max_position_embeddings = max_position_embeddings
<add> self.type_vocab_size = type_vocab_size
<add> self.type_sequence_label_size = type_sequence_label_size
<add> self.initializer_range = initializer_range
<add> self.num_labels = num_labels
<add> self.num_choices = num_choices
<add> self.scope = scope
<ide>
<ide> def prepare_config_and_inputs(self):
<ide> input_ids = ids_tensor([self.batch_size, self.seq_length], self.vocab_size)
<ide><path>tests/models/transfo_xl/test_modeling_transfo_xl.py
<ide> class TransfoXLModelTester:
<ide> def __init__(
<ide> self,
<ide> parent,
<add> batch_size=14,
<add> seq_length=7,
<add> mem_len=30,
<add> clamp_len=15,
<add> is_training=False,
<add> use_labels=True,
<add> vocab_size=99,
<add> cutoffs=[10, 50, 80],
<add> hidden_size=32,
<add> d_embed=32,
<add> num_attention_heads=4,
<add> d_head=8,
<add> d_inner=128,
<add> div_val=2,
<add> num_hidden_layers=5,
<add> scope=None,
<add> seed=1,
<add> eos_token_id=0,
<add> num_labels=3,
<ide> ):
<ide> self.parent = parent
<del> self.batch_size = 14
<del> self.seq_length = 7
<del> self.mem_len = 30
<add> self.batch_size = batch_size
<add> self.seq_length = seq_length
<add> self.mem_len = mem_len
<ide> self.key_length = self.seq_length + self.mem_len
<del> self.clamp_len = 15
<del> self.is_training = False
<del> self.use_labels = True
<del> self.vocab_size = 99
<del> self.cutoffs = [10, 50, 80]
<del> self.hidden_size = 32
<del> self.d_embed = 32
<del> self.num_attention_heads = 4
<del> self.d_head = 8
<del> self.d_inner = 128
<del> self.div_val = 2
<del> self.num_hidden_layers = 5
<del> self.scope = None
<del> self.seed = 1
<del> self.eos_token_id = 0
<del> self.num_labels = 3
<add> self.clamp_len = clamp_len
<add> self.is_training = is_training
<add> self.use_labels = use_labels
<add> self.vocab_size = vocab_size
<add> self.cutoffs = cutoffs
<add> self.hidden_size = hidden_size
<add> self.d_embed = d_embed
<add> self.num_attention_heads = num_attention_heads
<add> self.d_head = d_head
<add> self.d_inner = d_inner
<add> self.div_val = div_val
<add> self.num_hidden_layers = num_hidden_layers
<add> self.scope = scope
<add> self.seed = seed
<add> self.eos_token_id = eos_token_id
<add> self.num_labels = num_labels
<ide> self.pad_token_id = self.vocab_size - 1
<ide>
<ide> def prepare_config_and_inputs(self):
<ide><path>tests/models/xlm/test_modeling_xlm.py
<ide> class XLMModelTester:
<ide> def __init__(
<ide> self,
<ide> parent,
<add> batch_size=13,
<add> seq_length=7,
<add> is_training=True,
<add> use_input_lengths=True,
<add> use_token_type_ids=True,
<add> use_labels=True,
<add> gelu_activation=True,
<add> sinusoidal_embeddings=False,
<add> causal=False,
<add> asm=False,
<add> n_langs=2,
<add> vocab_size=99,
<add> n_special=0,
<add> hidden_size=32,
<add> num_hidden_layers=5,
<add> num_attention_heads=4,
<add> hidden_dropout_prob=0.1,
<add> attention_probs_dropout_prob=0.1,
<add> max_position_embeddings=512,
<add> type_sequence_label_size=2,
<add> initializer_range=0.02,
<add> num_labels=2,
<add> num_choices=4,
<add> summary_type="last",
<add> use_proj=True,
<add> scope=None,
<add> bos_token_id=0,
<ide> ):
<ide> self.parent = parent
<del> self.batch_size = 13
<del> self.seq_length = 7
<del> self.is_training = True
<del> self.use_input_lengths = True
<del> self.use_token_type_ids = True
<del> self.use_labels = True
<del> self.gelu_activation = True
<del> self.sinusoidal_embeddings = False
<del> self.causal = False
<del> self.asm = False
<del> self.n_langs = 2
<del> self.vocab_size = 99
<del> self.n_special = 0
<del> self.hidden_size = 32
<del> self.num_hidden_layers = 5
<del> self.num_attention_heads = 4
<del> self.hidden_dropout_prob = 0.1
<del> self.attention_probs_dropout_prob = 0.1
<del> self.max_position_embeddings = 512
<del> self.type_sequence_label_size = 2
<del> self.initializer_range = 0.02
<del> self.num_labels = 2
<del> self.num_choices = 4
<del> self.summary_type = "last"
<del> self.use_proj = True
<del> self.scope = None
<del> self.bos_token_id = 0
<add> self.batch_size = batch_size
<add> self.seq_length = seq_length
<add> self.is_training = is_training
<add> self.use_input_lengths = use_input_lengths
<add> self.use_token_type_ids = use_token_type_ids
<add> self.use_labels = use_labels
<add> self.gelu_activation = gelu_activation
<add> self.sinusoidal_embeddings = sinusoidal_embeddings
<add> self.causal = causal
<add> self.asm = asm
<add> self.n_langs = n_langs
<add> self.vocab_size = vocab_size
<add> self.n_special = n_special
<add> self.hidden_size = hidden_size
<add> self.num_hidden_layers = num_hidden_layers
<add> self.num_attention_heads = num_attention_heads
<add> self.hidden_dropout_prob = hidden_dropout_prob
<add> self.attention_probs_dropout_prob = attention_probs_dropout_prob
<add> self.max_position_embeddings = max_position_embeddings
<add> self.type_sequence_label_size = type_sequence_label_size
<add> self.initializer_range = initializer_range
<add> self.num_labels = num_labels
<add> self.num_choices = num_choices
<add> self.summary_type = summary_type
<add> self.use_proj = use_proj
<add> self.scope = scope
<add> self.bos_token_id = bos_token_id
<ide>
<ide> def prepare_config_and_inputs(self):
<ide> input_ids = ids_tensor([self.batch_size, self.seq_length], self.vocab_size)
<ide><path>tests/models/xlm_roberta_xl/test_modeling_xlm_roberta_xl.py
<ide> class XLMRobertaXLModelTester:
<ide> def __init__(
<ide> self,
<ide> parent,
<add> batch_size=13,
<add> seq_length=7,
<add> is_training=True,
<add> use_input_mask=True,
<add> use_token_type_ids=True,
<add> use_labels=True,
<add> vocab_size=99,
<add> hidden_size=32,
<add> num_hidden_layers=5,
<add> num_attention_heads=4,
<add> intermediate_size=37,
<add> hidden_act="gelu",
<add> hidden_dropout_prob=0.1,
<add> attention_probs_dropout_prob=0.1,
<add> max_position_embeddings=512,
<add> type_vocab_size=16,
<add> type_sequence_label_size=2,
<add> initializer_range=0.02,
<add> num_labels=3,
<add> num_choices=4,
<add> scope=None,
<ide> ):
<ide> self.parent = parent
<del> self.batch_size = 13
<del> self.seq_length = 7
<del> self.is_training = True
<del> self.use_input_mask = True
<del> self.use_token_type_ids = True
<del> self.use_labels = True
<del> self.vocab_size = 99
<del> self.hidden_size = 32
<del> self.num_hidden_layers = 5
<del> self.num_attention_heads = 4
<del> self.intermediate_size = 37
<del> self.hidden_act = "gelu"
<del> self.hidden_dropout_prob = 0.1
<del> self.attention_probs_dropout_prob = 0.1
<del> self.max_position_embeddings = 512
<del> self.type_vocab_size = 16
<del> self.type_sequence_label_size = 2
<del> self.initializer_range = 0.02
<del> self.num_labels = 3
<del> self.num_choices = 4
<del> self.scope = None
<add> self.batch_size = batch_size
<add> self.seq_length = seq_length
<add> self.is_training = is_training
<add> self.use_input_mask = use_input_mask
<add> self.use_token_type_ids = use_token_type_ids
<add> self.use_labels = use_labels
<add> self.vocab_size = vocab_size
<add> self.hidden_size = hidden_size
<add> self.num_hidden_layers = num_hidden_layers
<add> self.num_attention_heads = num_attention_heads
<add> self.intermediate_size = intermediate_size
<add> self.hidden_act = hidden_act
<add> self.hidden_dropout_prob = hidden_dropout_prob
<add> self.attention_probs_dropout_prob = attention_probs_dropout_prob
<add> self.max_position_embeddings = max_position_embeddings
<add> self.type_vocab_size = type_vocab_size
<add> self.type_sequence_label_size = type_sequence_label_size
<add> self.initializer_range = initializer_range
<add> self.num_labels = num_labels
<add> self.num_choices = num_choices
<add> self.scope = scope
<ide>
<ide> def prepare_config_and_inputs(self):
<ide> input_ids = ids_tensor([self.batch_size, self.seq_length], self.vocab_size)
| 16
|
Javascript
|
Javascript
|
remove dead code
|
9f4d99f4eaa53ea4b186a2954b23ce4c86643947
|
<ide><path>src/ng/compile.js
<ide> function $CompileProvider($provide) {
<ide> }
<ide> };
<ide>
<del> var urlSanitizationNode = $document[0].createElement('a'),
<del> startSymbol = $interpolate.startSymbol(),
<add> var startSymbol = $interpolate.startSymbol(),
<ide> endSymbol = $interpolate.endSymbol(),
<ide> denormalizeTemplate = (startSymbol == '{{' || endSymbol == '}}')
<ide> ? identity
| 1
|
Javascript
|
Javascript
|
give error message if `write()` cb called twice
|
d111d7b91c16ec420f231da4f6877a9b446de6d8
|
<ide><path>lib/_stream_writable.js
<ide> const { getHighWaterMark } = require('internal/streams/state');
<ide> const {
<ide> ERR_INVALID_ARG_TYPE,
<ide> ERR_METHOD_NOT_IMPLEMENTED,
<add> ERR_MULTIPLE_CALLBACK,
<ide> ERR_STREAM_CANNOT_PIPE,
<ide> ERR_STREAM_DESTROYED,
<ide> ERR_STREAM_NULL_VALUES,
<ide> function onwrite(stream, er) {
<ide> var sync = state.sync;
<ide> var cb = state.writecb;
<ide>
<add> if (typeof cb !== 'function')
<add> throw new ERR_MULTIPLE_CALLBACK();
<add>
<ide> onwriteStateUpdate(state);
<ide>
<ide> if (er)
<ide><path>test/parallel/test-stream-writable-write-cb-twice.js
<add>'use strict';
<add>const common = require('../common');
<add>const { Writable } = require('stream');
<add>
<add>{
<add> // Sync + Sync
<add> const writable = new Writable({
<add> write: common.mustCall((buf, enc, cb) => {
<add> cb();
<add> common.expectsError(cb, {
<add> code: 'ERR_MULTIPLE_CALLBACK',
<add> type: Error
<add> });
<add> })
<add> });
<add> writable.write('hi');
<add>}
<add>
<add>{
<add> // Sync + Async
<add> const writable = new Writable({
<add> write: common.mustCall((buf, enc, cb) => {
<add> cb();
<add> process.nextTick(() => {
<add> common.expectsError(cb, {
<add> code: 'ERR_MULTIPLE_CALLBACK',
<add> type: Error
<add> });
<add> });
<add> })
<add> });
<add> writable.write('hi');
<add>}
<add>
<add>{
<add> // Async + Async
<add> const writable = new Writable({
<add> write: common.mustCall((buf, enc, cb) => {
<add> process.nextTick(cb);
<add> process.nextTick(() => {
<add> common.expectsError(cb, {
<add> code: 'ERR_MULTIPLE_CALLBACK',
<add> type: Error
<add> });
<add> });
<add> })
<add> });
<add> writable.write('hi');
<add>}
| 2
|
PHP
|
PHP
|
apply fixes from styleci
|
334d5a618e7b76ef5c5d90151a05af22e0e32057
|
<ide><path>src/Illuminate/Http/Request.php
<ide> public function userAgent()
<ide> public function merge(array $input)
<ide> {
<ide> $this->getInputSource()->add($input);
<del>
<add>
<ide> return $this;
<ide> }
<ide>
<ide> public function merge(array $input)
<ide> public function replace(array $input)
<ide> {
<ide> $this->getInputSource()->replace($input);
<del>
<add>
<ide> return $this;
<ide> }
<ide>
| 1
|
PHP
|
PHP
|
remove duplicate test
|
8e51f90ac428d47821dfb7d1b1ed6b2b86541acc
|
<ide><path>tests/TestCase/I18n/TimeTest.php
<ide> public function testTimeAgoInWordsWithFormat()
<ide> $result = $time->timeAgoInWords(['format' => 'yyyy-MM-dd']);
<ide> $this->assertEquals('on 2007-09-25', $result);
<ide>
<del> $time = new Time('2007-9-25');
<del> $result = $time->timeAgoInWords(['format' => 'yyyy-MM-dd']);
<del> $this->assertEquals('on 2007-09-25', $result);
<del>
<ide> $time = new Time('+2 weeks +2 days');
<ide> $result = $time->timeAgoInWords(['format' => 'yyyy-MM-dd']);
<ide> $this->assertRegExp('/^2 weeks, [1|2] day(s)?$/', $result);
| 1
|
PHP
|
PHP
|
use old date format for monolog formatter instance
|
aa30f39716cdbad3b3200ea507d346fb570fb1ab
|
<ide><path>src/Illuminate/Log/LogManager.php
<ide> class LogManager implements LoggerInterface
<ide> */
<ide> protected $customCreators = [];
<ide>
<add> /**
<add> * The date format for Monolog formatter instance.
<add> *
<add> * @var string
<add> */
<add> protected $dateFormat = "Y-m-d H:i:s";
<add>
<ide> /**
<ide> * Create a new Log manager instance.
<ide> *
<ide> protected function prepareHandler(HandlerInterface $handler, array $config = [])
<ide> */
<ide> protected function formatter()
<ide> {
<del> return tap(new LineFormatter(null, null, true, true), function ($formatter) {
<add> return tap(new LineFormatter(null, $this->dateFormat, true, true), function ($formatter) {
<ide> $formatter->includeStacktraces();
<ide> });
<ide> }
| 1
|
PHP
|
PHP
|
add ability to define model factories statically
|
fccfc6ec39d1740e26ba77354a68e14453820a10
|
<ide><path>config/bootstrap.php
<ide> * @license http://www.opensource.org/licenses/mit-license.php MIT License
<ide> */
<ide>
<add>use Cake\Datasource\FactoryLocator;
<ide> use Cake\Routing\Router;
<ide>
<ide> define('TIME_START', microtime(true));
<ide><path>src/Datasource/FactoryLocator.php
<add><?php
<add>/**
<add> * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
<add> * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
<add> *
<add> * Licensed under The MIT License
<add> * For full copyright and license information, please see the LICENSE.txt
<add> * Redistributions of files must retain the above copyright notice.
<add> *
<add> * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
<add> * @link http://cakephp.org CakePHP(tm) Project
<add> * @since 3.3.0
<add> * @license http://www.opensource.org/licenses/mit-license.php MIT License
<add> */
<add>namespace Cake\Datasource;
<add>
<add>use Cake\ORM\TableRegistry;
<add>use InvalidArgumentException;
<add>
<add>class FactoryLocator
<add>{
<add> /**
<add> * A list of model factory functions.
<add> *
<add> * @var callable[]
<add> */
<add> protected static $_modelFactories = [];
<add>
<add> /**
<add> * Register a callable to generate repositories of a given type.
<add> *
<add> * @param string $type The name of the repository type the factory function is for.
<add> * @param callable $factory The factory function used to create instances.
<add> * @return void
<add> */
<add> public static function add($type, callable $factory)
<add> {
<add> static::$_modelFactories[$type] = $factory;
<add> }
<add>
<add> /**
<add> * Drop a model factory.
<add> *
<add> * @param string $type The name of the repository type to drop the factory for.
<add> * @return void
<add> */
<add> public static function drop($type)
<add> {
<add> unset(static::$_modelFactories[$type]);
<add> }
<add>
<add> /**
<add> * Get the factory for the specified repository type.
<add> *
<add> * @param string $type The repository type to get the factory for.
<add> * @throws InvalidArgumentException If the specified repository type has no factory.
<add> * @return callable The factory for the repository type.
<add> */
<add> public static function get($type)
<add> {
<add> if (!isset(static::$_modelFactories['Table'])) {
<add> static::$_modelFactories['Table'] = [TableRegistry::locator(), 'get'];
<add> }
<add>
<add> if (!isset(static::$_modelFactories[$type])) {
<add> throw new InvalidArgumentException(sprintf(
<add> 'Unknown repository type "%s". Make sure you register a type before trying to use it.',
<add> $type
<add> ));
<add> }
<add>
<add> return static::$_modelFactories[$type];
<add> }
<add>}
<ide><path>src/Datasource/ModelAwareTrait.php
<ide> trait ModelAwareTrait
<ide> public $modelClass;
<ide>
<ide> /**
<del> * A list of model factory functions.
<add> * A list of overridden model factory functions.
<ide> *
<ide> * @var array
<ide> */
<ide> public function loadModel($modelClass = null, $modelType = null)
<ide> return $this->{$alias};
<ide> }
<ide>
<del> if (!isset($this->_modelFactories[$modelType])) {
<del> throw new InvalidArgumentException(sprintf(
<del> 'Unknown repository type "%s". Make sure you register a type before trying to use it.',
<del> $modelType
<del> ));
<add> if (isset($this->_modelFactories[$modelType])) {
<add> $factory = $this->_modelFactories[$modelType];
<add> }
<add> if (!isset($factory)) {
<add> $factory = FactoryLocator::get($modelType);
<ide> }
<del> $factory = $this->_modelFactories[$modelType];
<ide> $this->{$alias} = $factory($modelClass);
<ide> if (!$this->{$alias}) {
<ide> throw new MissingModelException([$modelClass, $modelType]);
<ide> public function loadModel($modelClass = null, $modelType = null)
<ide> }
<ide>
<ide> /**
<del> * Register a callable to generate repositories of a given type.
<add> * Override a existing callable to generate repositories of a given type.
<ide> *
<ide> * @param string $type The name of the repository type the factory function is for.
<ide> * @param callable $factory The factory function used to create instances.
<ide><path>tests/TestCase/Datasource/FactoryLocatorTest.php
<add><?php
<add>/**
<add> * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
<add> * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
<add> *
<add> * Licensed under The MIT License
<add> * Redistributions of files must retain the above copyright notice.
<add> *
<add> * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
<add> * @link http://cakephp.org CakePHP(tm) Project
<add> * @since 3.3.0
<add> * @license http://www.opensource.org/licenses/mit-license.php MIT License
<add> */
<add>namespace Cake\Test\TestCase\Datasource;
<add>
<add>use Cake\Datasource\FactoryLocator;
<add>use Cake\TestSuite\TestCase;
<add>
<add>/**
<add> * FactoryLocatorTest test case
<add> */
<add>class FactoryLocatorTest extends TestCase
<add>{
<add> /**
<add> * Test get factory
<add> *
<add> * @return void
<add> */
<add> public function testGet()
<add> {
<add> $this->assertInternalType('callable', FactoryLocator::get('Table'));
<add> }
<add>
<add> /**
<add> * Test get non existing factory
<add> *
<add> * @return void
<add> * @expectedException \InvalidArgumentException
<add> * @expectedExceptionMessage Unknown repository type "Test". Make sure you register a type before trying to use it.
<add> */
<add> public function testGetNonExisting()
<add> {
<add> FactoryLocator::get('Test');
<add> }
<add>
<add> /**
<add> * test add()
<add> *
<add> * @return void
<add> */
<add> public function testAdd()
<add> {
<add> FactoryLocator::add('Test', function ($name) {
<add> $mock = new \StdClass();
<add> $mock->name = $name;
<add> return $mock;
<add> });
<add>
<add> $this->assertInternalType('callable', FactoryLocator::get('Test'));
<add> }
<add>
<add> /**
<add> * test drop()
<add> *
<add> * @return void
<add> * @expectedException \InvalidArgumentException
<add> * @expectedExceptionMessage Unknown repository type "Test". Make sure you register a type before trying to use it.
<add> */
<add> public function testDrop()
<add> {
<add> FactoryLocator::drop('Test');
<add>
<add> FactoryLocator::get('Test');
<add> }
<add>
<add> /**
<add> * test loadModel() with plugin prefixed models
<add> *
<add> * Load model should not be called with Foo.Model Bar.Model Model
<add> * But if it is, the first call wins.
<add> *
<add> * @return void
<add> */
<add> public function testLoadModelPlugin()
<add> {
<add> $stub = new Stub();
<add> $stub->setProps('Articles');
<add> $stub->modelType('Table');
<add>
<add> $result = $stub->loadModel('TestPlugin.Comments');
<add> $this->assertInstanceOf('TestPlugin\Model\Table\CommentsTable', $result);
<add> $this->assertInstanceOf('TestPlugin\Model\Table\CommentsTable', $stub->Comments);
<add>
<add> $result = $stub->loadModel('Comments');
<add> $this->assertInstanceOf('TestPlugin\Model\Table\CommentsTable', $result);
<add> $this->assertInstanceOf('TestPlugin\Model\Table\CommentsTable', $stub->Comments);
<add> }
<add>
<add> /**
<add> * test alternate model factories.
<add> *
<add> * @return void
<add> */
<add> public function testModelFactory()
<add> {
<add> $stub = new Stub();
<add> $stub->setProps('Articles');
<add>
<add> $stub->modelFactory('Table', function ($name) {
<add> $mock = new \StdClass();
<add> $mock->name = $name;
<add> return $mock;
<add> });
<add>
<add> $result = $stub->loadModel('Magic', 'Table');
<add> $this->assertInstanceOf('\StdClass', $result);
<add> $this->assertInstanceOf('\StdClass', $stub->Magic);
<add> $this->assertEquals('Magic', $stub->Magic->name);
<add> }
<add>
<add> /**
<add> * test alternate default model type.
<add> *
<add> * @return void
<add> */
<add> public function testModelType()
<add> {
<add> $stub = new Stub();
<add> $stub->setProps('Articles');
<add>
<add> FactoryLocator::add('Test', function ($name) {
<add> $mock = new \StdClass();
<add> $mock->name = $name;
<add> return $mock;
<add> });
<add> $stub->modelType('Test');
<add>
<add> $result = $stub->loadModel('Magic');
<add> $this->assertInstanceOf('\StdClass', $result);
<add> $this->assertInstanceOf('\StdClass', $stub->Magic);
<add> $this->assertEquals('Magic', $stub->Magic->name);
<add> }
<add>
<add> /**
<add> * test MissingModelException being thrown
<add> *
<add> * @return void
<add> * @expectedException \Cake\Datasource\Exception\MissingModelException
<add> * @expectedExceptionMessage Model class "Magic" of type "Test" could not be found.
<add> */
<add> public function testMissingModelException()
<add> {
<add> $stub = new Stub();
<add>
<add> FactoryLocator::add('Test', function ($name) {
<add> return false;
<add> });
<add>
<add> $stub->loadModel('Magic', 'Test');
<add> }
<add>
<add> public function tearDown()
<add> {
<add> FactoryLocator::drop('Test');
<add>
<add> parent::tearDown();
<add> }
<add>}
<ide><path>tests/TestCase/Datasource/ModelAwareTraitTest.php
<ide> */
<ide> namespace Cake\Test\TestCase\Datasource;
<ide>
<add>use Cake\Datasource\FactoryLocator;
<ide> use Cake\Datasource\ModelAwareTrait;
<ide> use Cake\TestSuite\TestCase;
<ide>
<ide> public function testLoadModel()
<ide> {
<ide> $stub = new Stub();
<ide> $stub->setProps('Articles');
<del> $stub->modelFactory('Table', ['\Cake\ORM\TableRegistry', 'get']);
<ide> $stub->modelType('Table');
<ide>
<ide> $result = $stub->loadModel();
<ide> public function testLoadModelPlugin()
<ide> {
<ide> $stub = new Stub();
<ide> $stub->setProps('Articles');
<del> $stub->modelFactory('Table', ['\Cake\ORM\TableRegistry', 'get']);
<ide> $stub->modelType('Table');
<ide>
<ide> $result = $stub->loadModel('TestPlugin.Comments');
<ide> public function testModelFactory()
<ide> $stub = new Stub();
<ide> $stub->setProps('Articles');
<ide>
<del> $stub->modelFactory('Test', function ($name) {
<add> $stub->modelFactory('Table', function ($name) {
<ide> $mock = new \StdClass();
<ide> $mock->name = $name;
<ide> return $mock;
<ide> });
<ide>
<del> $result = $stub->loadModel('Magic', 'Test');
<add> $result = $stub->loadModel('Magic', 'Table');
<ide> $this->assertInstanceOf('\StdClass', $result);
<ide> $this->assertInstanceOf('\StdClass', $stub->Magic);
<ide> $this->assertEquals('Magic', $stub->Magic->name);
<ide> public function testModelType()
<ide> $stub = new Stub();
<ide> $stub->setProps('Articles');
<ide>
<del> $stub->modelFactory('Test', function ($name) {
<add> FactoryLocator::add('Test', function ($name) {
<ide> $mock = new \StdClass();
<ide> $mock->name = $name;
<ide> return $mock;
<ide> public function testMissingModelException()
<ide> {
<ide> $stub = new Stub();
<ide>
<del> $stub->modelFactory('Test', function ($name) {
<add> FactoryLocator::add('Test', function ($name) {
<ide> return false;
<ide> });
<ide>
<ide> $stub->loadModel('Magic', 'Test');
<ide> }
<add>
<add> public function tearDown()
<add> {
<add> FactoryLocator::drop('Test');
<add>
<add> parent::tearDown();
<add> }
<ide> }
| 5
|
Text
|
Text
|
add note about websocket attach streams
|
d4a0a422da27493aab8f4e49c22aa9fe2f95e1b0
|
<ide><path>docs/api/version-history.md
<ide> keywords: "API, Docker, rcli, REST, documentation"
<ide> * The `Volume` type, as returned by `Added new `ClusterVolume` fields
<ide> * Added a new `PUT /volumes{name}` endpoint to update cluster volumes (CNI).
<ide> Cluster volumes are only supported if the daemon is a Swarm manager.
<del>* `/containers/{name}/attach/ws` endpoint only attach to configured streams
<del> according to `stdin`, `stdout` and `stderr` parameters.
<add>* `GET /containers/{name}/attach/ws` endpoint now accepts `stdin`, `stdout` and
<add> `stderr` query parameters to only attach to configured streams.
<add>
<add> NOTE: These parameters were documented before in older API versions, but not
<add> actually supported. API versions before v1.42 continue to ignore these parameters
<add> and default to attaching to all streams. To preserve the pre-v1.42 behavior,
<add> set all three query parameters (`?stdin=1,stdout=1,stderr=1`).
<ide>
<ide> ## v1.41 API changes
<ide>
| 1
|
Javascript
|
Javascript
|
remove unused code
|
e522c25fd4927e32d1d304d8ac4f77f4b03ab77c
|
<ide><path>docs/app/assets/js/angular-bootstrap/bootstrap-prettify.js
<del>'use strict';
<del>
<del>var directive = {};
<del>var service = { value: {} };
<del>
<del>var DEPENDENCIES = {
<del> 'angular.js': 'http://code.angularjs.org/' + angular.version.full + '/angular.min.js',
<del> 'angular-resource.js': 'http://code.angularjs.org/' + angular.version.full + '/angular-resource.min.js',
<del> 'angular-route.js': 'http://code.angularjs.org/' + angular.version.full + '/angular-route.min.js',
<del> 'angular-animate.js': 'http://code.angularjs.org/' + angular.version.full + '/angular-animate.min.js',
<del> 'angular-sanitize.js': 'http://code.angularjs.org/' + angular.version.full + '/angular-sanitize.min.js',
<del> 'angular-cookies.js': 'http://code.angularjs.org/' + angular.version.full + '/angular-cookies.min.js'
<del>};
<del>
<del>
<del>function escape(text) {
<del> return text.
<del> replace(/\&/g, '&').
<del> replace(/\</g, '<').
<del> replace(/\>/g, '>').
<del> replace(/"/g, '"');
<del>}
<del>
<del>/**
<del> * http://stackoverflow.com/questions/451486/pre-tag-loses-line-breaks-when-setting-innerhtml-in-ie
<del> * http://stackoverflow.com/questions/195363/inserting-a-newline-into-a-pre-tag-ie-javascript
<del> */
<del>function setHtmlIe8SafeWay(element, html) {
<del> var newElement = angular.element('<pre>' + html + '</pre>');
<del>
<del> element.empty();
<del> element.append(newElement.contents());
<del> return element;
<del>}
<del>
<del>
<del>directive.jsFiddle = function(getEmbeddedTemplate, escape, script) {
<del> return {
<del> terminal: true,
<del> link: function(scope, element, attr) {
<del> var name = '',
<del> stylesheet = '<link rel="stylesheet" href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css">\n',
<del> fields = {
<del> html: '',
<del> css: '',
<del> js: ''
<del> };
<del>
<del> angular.forEach(attr.jsFiddle.split(' '), function(file, index) {
<del> var fileType = file.split('.')[1];
<del>
<del> if (fileType == 'html') {
<del> if (index == 0) {
<del> fields[fileType] +=
<del> '<div ng-app' + (attr.module ? '="' + attr.module + '"' : '') + '>\n' +
<del> getEmbeddedTemplate(file, 2);
<del> } else {
<del> fields[fileType] += '\n\n\n <!-- CACHE FILE: ' + file + ' -->\n' +
<del> ' <script type="text/ng-template" id="' + file + '">\n' +
<del> getEmbeddedTemplate(file, 4) +
<del> ' </script>\n';
<del> }
<del> } else {
<del> fields[fileType] += getEmbeddedTemplate(file) + '\n';
<del> }
<del> });
<del>
<del> fields.html += '</div>\n';
<del>
<del> setHtmlIe8SafeWay(element,
<del> '<form class="jsfiddle" method="post" action="http://jsfiddle.net/api/post/library/pure/" target="_blank">' +
<del> hiddenField('title', 'AngularJS Example: ' + name) +
<del> hiddenField('css', '</style> <!-- Ugly Hack due to jsFiddle issue: http://goo.gl/BUfGZ --> \n' +
<del> stylesheet +
<del> script.angular +
<del> (attr.resource ? script.resource : '') +
<del> '<style>\n' +
<del> fields.css) +
<del> hiddenField('html', fields.html) +
<del> hiddenField('js', fields.js) +
<del> '<button class="btn btn-primary"><i class="icon-white icon-pencil"></i> Edit Me</button>' +
<del> '</form>');
<del>
<del> function hiddenField(name, value) {
<del> return '<input type="hidden" name="' + name + '" value="' + escape(value) + '">';
<del> }
<del> }
<del> }
<del>};
<del>
<del>
<del>
<del>directive.ngSetText = ['getEmbeddedTemplate', function(getEmbeddedTemplate) {
<del> return {
<del> restrict: 'CA',
<del> priority: 10,
<del> compile: function(element, attr) {
<del> setHtmlIe8SafeWay(element, escape(getEmbeddedTemplate(attr.ngSetText)));
<del> }
<del> }
<del>}]
<del>
<del>
<del>directive.ngHtmlWrap = ['reindentCode', 'templateMerge', function(reindentCode, templateMerge) {
<del> return {
<del> compile: function(element, attr) {
<del> var properties = {
<del> head: '',
<del> module: '',
<del> body: element.text()
<del> },
<del> html = "<!doctype html>\n<html ng-app{{module}}>\n <head>\n{{head:4}} </head>\n <body>\n{{body:4}} </body>\n</html>";
<del>
<del> angular.forEach((attr.ngHtmlWrap || '').split(' '), function(dep) {
<del> if (!dep) return;
<del> dep = DEPENDENCIES[dep] || dep;
<del>
<del> var ext = dep.split(/\./).pop();
<del>
<del> if (ext == 'css') {
<del> properties.head += '<link rel="stylesheet" href="' + dep + '" type="text/css">\n';
<del> } else if(ext == 'js') {
<del> properties.head += '<script src="' + dep + '"></script>\n';
<del> } else {
<del> properties.module = '="' + dep + '"';
<del> }
<del> });
<del>
<del> setHtmlIe8SafeWay(element, escape(templateMerge(html, properties)));
<del> }
<del> }
<del>}];
<del>
<del>
<del>directive.ngSetHtml = ['getEmbeddedTemplate', function(getEmbeddedTemplate) {
<del> return {
<del> restrict: 'CA',
<del> priority: 10,
<del> compile: function(element, attr) {
<del> setHtmlIe8SafeWay(element, getEmbeddedTemplate(attr.ngSetHtml));
<del> }
<del> }
<del>}];
<del>
<del>
<del>directive.ngEvalJavascript = ['getEmbeddedTemplate', function(getEmbeddedTemplate) {
<del> return {
<del> compile: function (element, attr) {
<del> var fileNames = attr.ngEvalJavascript.split(' ');
<del> angular.forEach(fileNames, function(fileName) {
<del> var script = getEmbeddedTemplate(fileName);
<del> try {
<del> if (window.execScript) { // IE
<del> window.execScript(script || '""'); // IE complains when evaling empty string
<del> } else {
<del> window.eval(script + '//@ sourceURL=' + fileName);
<del> }
<del> } catch (e) {
<del> if (window.console) {
<del> window.console.log(script, '\n', e);
<del> } else {
<del> window.alert(e);
<del> }
<del> }
<del> });
<del> }
<del> };
<del>}];
<del>
<del>
<del>directive.ngEmbedApp = ['$templateCache', '$browser', '$rootScope', '$location', '$sniffer', '$animate',
<del> function($templateCache, $browser, docsRootScope, $location, $sniffer, $animate) {
<del> return {
<del> terminal: true,
<del> link: function(scope, element, attrs) {
<del> var modules = ['ngAnimate'],
<del> embedRootScope,
<del> deregisterEmbedRootScope;
<del>
<del> modules.push(['$provide', function($provide) {
<del> $provide.value('$templateCache', $templateCache);
<del> $provide.value('$anchorScroll', angular.noop);
<del> $provide.value('$browser', $browser);
<del> $provide.value('$sniffer', $sniffer);
<del> $provide.value('$animate', $animate);
<del> $provide.provider('$location', function() {
<del> this.$get = ['$rootScope', function($rootScope) {
<del> docsRootScope.$on('$locationChangeSuccess', function(event, oldUrl, newUrl) {
<del> $rootScope.$broadcast('$locationChangeSuccess', oldUrl, newUrl);
<del> });
<del> return $location;
<del> }];
<del> this.html5Mode = angular.noop;
<del> });
<del>
<del> $provide.decorator('$rootScope', ['$delegate', function($delegate) {
<del> embedRootScope = $delegate;
<del>
<del> // Since we are teleporting the $animate service, which relies on the $$postDigestQueue
<del> // we need the embedded scope to use the same $$postDigestQueue as the outer scope
<del> embedRootScope.$$postDigestQueue = docsRootScope.$$postDigestQueue;
<del>
<del> deregisterEmbedRootScope = docsRootScope.$watch(function embedRootScopeDigestWatch() {
<del> embedRootScope.$digest();
<del> });
<del>
<del> return embedRootScope;
<del> }]);
<del> }]);
<del> if (attrs.ngEmbedApp) modules.push(attrs.ngEmbedApp);
<del>
<del> element.on('click', function(event) {
<del> if (event.target.attributes.getNamedItem('ng-click')) {
<del> event.preventDefault();
<del> }
<del> });
<del>
<del> element.on('$destroy', function() {
<del> deregisterEmbedRootScope();
<del> embedRootScope.$destroy();
<del> });
<del>
<del> element.data('$injector', null);
<del> angular.bootstrap(element, modules);
<del> }
<del> };
<del>}];
<del>
<del>service.reindentCode = function() {
<del> return function (text, spaces) {
<del> if (!text) return text;
<del> var lines = text.split(/\r?\n/);
<del> var prefix = ' '.substr(0, spaces || 0);
<del> var i;
<del>
<del> // remove any leading blank lines
<del> while (lines.length && lines[0].match(/^\s*$/)) lines.shift();
<del> // remove any trailing blank lines
<del> while (lines.length && lines[lines.length - 1].match(/^\s*$/)) lines.pop();
<del> var minIndent = 999;
<del> for (i = 0; i < lines.length; i++) {
<del> var line = lines[0];
<del> var reindentCode = line.match(/^\s*/)[0];
<del> if (reindentCode !== line && reindentCode.length < minIndent) {
<del> minIndent = reindentCode.length;
<del> }
<del> }
<del>
<del> for (i = 0; i < lines.length; i++) {
<del> lines[i] = prefix + lines[i].substring(minIndent);
<del> }
<del> lines.push('');
<del> return lines.join('\n');
<del> }
<del>};
<del>
<del>service.templateMerge = ['reindentCode', function(indentCode) {
<del> return function(template, properties) {
<del> return template.replace(/\{\{(\w+)(?:\:(\d+))?\}\}/g, function(_, key, indent) {
<del> var value = properties[key];
<del>
<del> if (indent) {
<del> value = indentCode(value, indent);
<del> }
<del>
<del> return value == undefined ? '' : value;
<del> });
<del> };
<del>}];
<del>
<del>service.getEmbeddedTemplate = ['reindentCode', function(reindentCode) {
<del> return function (id) {
<del> var element = document.getElementById(id);
<del>
<del> if (!element) {
<del> return null;
<del> }
<del>
<del> return reindentCode(angular.element(element).html(), 0);
<del> }
<del>}];
<del>
<del>
<del>angular.module('bootstrapPrettify', []).directive(directive).factory(service);
<ide><path>docs/app/src/app.js
<ide> angular.module('docsApp', [
<ide> 'tutorials',
<ide> 'versions',
<ide> 'bootstrap',
<del> 'bootstrapPrettify',
<ide> 'ui.bootstrap.dropdown'
<ide> ])
<ide>
<ide><path>docs/app/src/tutorials.js
<ide> angular.module('tutorials', [])
<ide>
<del>.directive('docTutorialNav', ['templateMerge' ,function(templateMerge) {
<add>.directive('docTutorialNav', function() {
<ide> var pages = [
<ide> '',
<ide> 'step_00', 'step_01', 'step_02', 'step_03', 'step_04',
<ide> 'step_05', 'step_06', 'step_07', 'step_08', 'step_09',
<ide> 'step_10', 'step_11', 'step_12', 'the_end'
<ide> ];
<ide> return {
<del> compile: function(element, attrs) {
<del> var seq = 1 * attrs.docTutorialNav,
<del> props = {
<del> seq: seq,
<del> prev: pages[seq],
<del> next: pages[2 + seq],
<del> diffLo: seq ? (seq - 1): '0~1',
<del> diffHi: seq
<del> };
<add> scope: {},
<add> template:
<add> '<a ng-href="tutorial/{{prev}}"><li class="btn btn-primary"><i class="glyphicon glyphicon-step-backward"></i> Previous</li></a>\n' +
<add> '<a ng-href="http://angular.github.io/angular-phonecat/step-{{seq}}/app"><li class="btn btn-primary"><i class="glyphicon glyphicon-play"></i> Live Demo</li></a>\n' +
<add> '<a ng-href="https://github.com/angular/angular-phonecat/compare/step-{{diffLo}}...step-{{diffHi}}"><li class="btn btn-primary"><i class="glyphicon glyphicon-search"></i> Code Diff</li></a>\n' +
<add> '<a ng-href="tutorial/{{next}}"><li class="btn btn-primary">Next <i class="glyphicon glyphicon-step-forward"></i></li></a>',
<add> link: function(scope, element, attrs) {
<add> var seq = 1 * attrs.docTutorialNav;
<add> scope.seq = seq;
<add> scope.prev = pages[seq];
<add> scope.next = pages[2 + seq];
<add> scope.diffLo = seq ? (seq - 1): '0~1';
<add> scope.diffHi = seq;
<ide>
<ide> element.addClass('btn-group');
<ide> element.addClass('tutorial-nav');
<del> element.append(templateMerge(
<del> '<a href="tutorial/{{prev}}"><li class="btn btn-primary"><i class="glyphicon glyphicon-step-backward"></i> Previous</li></a>\n' +
<del> '<a href="http://angular.github.io/angular-phonecat/step-{{seq}}/app"><li class="btn btn-primary"><i class="glyphicon glyphicon-play"></i> Live Demo</li></a>\n' +
<del> '<a href="https://github.com/angular/angular-phonecat/compare/step-{{diffLo}}...step-{{diffHi}}"><li class="btn btn-primary"><i class="glyphicon glyphicon-search"></i> Code Diff</li></a>\n' +
<del> '<a href="tutorial/{{next}}"><li class="btn btn-primary">Next <i class="glyphicon glyphicon-step-forward"></i></li></a>', props));
<ide> }
<ide> };
<del>}])
<add>})
<ide>
<ide>
<ide> .directive('docTutorialReset', function() {
<ide> angular.module('tutorials', [])
<ide> '<a ng-href="https://github.com/angular/angular-phonecat/compare/step-{{step ? (step - 1): \'0~1\'}}...step-{{step}}">GitHub</a>\n' +
<ide> '</p>'
<ide> };
<del>});
<add>});
<ide>\ No newline at end of file
<ide><path>docs/config/services/deployments/debug.js
<ide> module.exports = function debugDeployment(getVersion) {
<ide> '../angular-animate.js',
<ide> 'components/marked-' + getVersion('marked', 'node_modules', 'package.json') + '/lib/marked.js',
<ide> 'js/angular-bootstrap/bootstrap.js',
<del> 'js/angular-bootstrap/bootstrap-prettify.js',
<ide> 'js/angular-bootstrap/dropdown-toggle.js',
<ide> 'components/lunr.js-' + getVersion('lunr.js') + '/lunr.js',
<ide> 'components/google-code-prettify-' + getVersion('google-code-prettify') + '/src/prettify.js',
<ide><path>docs/config/services/deployments/default.js
<ide> module.exports = function defaultDeployment(getVersion) {
<ide> '../angular-animate.min.js',
<ide> 'components/marked-' + getVersion('marked', 'node_modules', 'package.json') + '/lib/marked.js',
<ide> 'js/angular-bootstrap/bootstrap.min.js',
<del> 'js/angular-bootstrap/bootstrap-prettify.min.js',
<ide> 'js/angular-bootstrap/dropdown-toggle.min.js',
<ide> 'components/lunr.js-' + getVersion('lunr.js') + '/lunr.min.js',
<ide> 'components/google-code-prettify-' + getVersion('google-code-prettify') + '/src/prettify.js',
<ide><path>docs/config/services/deployments/jquery.js
<ide> module.exports = function jqueryDeployment(getVersion) {
<ide> '../angular-animate.min.js',
<ide> 'components/marked-' + getVersion('marked', 'node_modules', 'package.json') + '/lib/marked.js',
<ide> 'js/angular-bootstrap/bootstrap.min.js',
<del> 'js/angular-bootstrap/bootstrap-prettify.min.js',
<ide> 'js/angular-bootstrap/dropdown-toggle.min.js',
<ide> 'components/lunr.js-' + getVersion('lunr.js') + '/lunr.min.js',
<ide> 'components/google-code-prettify-' + getVersion('google-code-prettify') + '/src/prettify.js',
<ide><path>docs/config/services/deployments/production.js
<ide> module.exports = function productionDeployment(getVersion) {
<ide> cdnUrl + '/angular-animate.min.js',
<ide> 'components/marked-' + getVersion('marked', 'node_modules', 'package.json') + '/lib/marked.js',
<ide> 'js/angular-bootstrap/bootstrap.min.js',
<del> 'js/angular-bootstrap/bootstrap-prettify.min.js',
<ide> 'js/angular-bootstrap/dropdown-toggle.min.js',
<ide> 'components/lunr.js-' + getVersion('lunr.js') + '/lunr.min.js',
<ide> 'components/google-code-prettify-' + getVersion('google-code-prettify') + '/src/prettify.js',
| 7
|
Ruby
|
Ruby
|
fold dirlist helper into check_m4
|
28f89c59a2b39738df5a6fc85711be9af250fb53
|
<ide><path>Library/Homebrew/formula_installer.rb
<ide> def paths
<ide> @paths ||= ENV['PATH'].split(':').map{ |p| File.expand_path p }
<ide> end
<ide>
<del> def in_aclocal_dirlist?
<del> File.open("/usr/share/aclocal/dirlist") do |dirlist|
<del> dirlist.grep(%r{^#{HOMEBREW_PREFIX}/share/aclocal$}).length > 0
<del> end rescue false
<del> end
<del>
<ide> def check_PATH
<ide> # warn the user if stuff was installed outside of their PATH
<ide> [f.bin, f.sbin].each do |bin|
<ide> def audit_lib
<ide> def check_m4
<ide> return if MacOS.xcode_version.to_f >= 4.3
<ide>
<add> return if File.open("/usr/share/aclocal/dirlist") do |dirlist|
<add> dirlist.grep(%r{^#{HOMEBREW_PREFIX}/share/aclocal$}).length > 0
<add> end rescue false
<add>
<ide> # Check for m4 files
<del> if Dir[f.share+"aclocal/*.m4"].length > 0 and not in_aclocal_dirlist?
<add> if Dir[f.share+"aclocal/*.m4"].length > 0
<ide> opoo 'm4 macros were installed to "share/aclocal".'
<ide> puts "Homebrew does not append \"#{HOMEBREW_PREFIX}/share/aclocal\""
<ide> puts "to \"/usr/share/aclocal/dirlist\". If an autoconf script you use"
| 1
|
Go
|
Go
|
fix bug in bridge driver
|
dd8570000504c1893fe0c14262624f585e0418b4
|
<ide><path>libnetwork/drivers/bridge/bridge.go
<ide> func (d *driver) DeleteNetwork(nid string) error {
<ide>
<ide> // We only delete the bridge when it's not the default bridge. This is keep the backward compatible behavior.
<ide> if !config.DefaultBridge {
<del> err = netlink.LinkDel(n.bridge.Link)
<add> if err := netlink.LinkDel(n.bridge.Link); err != nil {
<add> logrus.Warnf("Failed to remove bridge interface %s on network %s delete: %v", config.BridgeName, nid, err)
<add> }
<ide> }
<ide>
<ide> return d.storeDelete(config)
<ide> func (d *driver) DeleteEndpoint(nid, eid string) error {
<ide> // Remove port mappings. Do not stop endpoint delete on unmap failure
<ide> n.releasePorts(ep)
<ide>
<del> // Try removal of link. Discard error: link pair might have
<del> // already been deleted by sandbox delete. Make sure defer
<del> // does not see this error either.
<add> // Try removal of link. Discard error: it is a best effort.
<add> // Also make sure defer does not see this error either.
<ide> if link, err := netlink.LinkByName(ep.srcName); err == nil {
<ide> netlink.LinkDel(link)
<ide> }
| 1
|
Go
|
Go
|
fix content-type for pushimagejsonindex
|
d93023daa9db2b6d38f7eefc8611e8226d75bbaf
|
<ide><path>registry/registry.go
<ide> func (r *Registry) PushImageJSONIndex(indexEp, remote string, imgList []*ImgData
<ide> if err != nil {
<ide> return nil, err
<ide> }
<add> req.Header.Add("Content-type", "application/json")
<ide> req.SetBasicAuth(r.authConfig.Username, r.authConfig.Password)
<ide> req.ContentLength = int64(len(imgListJSON))
<ide> req.Header.Set("X-Docker-Token", "true")
| 1
|
Text
|
Text
|
restore proper ordering of docs in the sidebar
|
71c812ae0e4ba7fb33dc3a797e9fd9749e0482ba
|
<ide><path>docs/ComponentsAndAPIs.md
<ide> title: Components and APIs
<ide> layout: docs
<ide> category: Guides
<ide> permalink: docs/components-and-apis.html
<del>next: handling-touches
<add>next: platform-specific-code
<ide> previous: more-resources
<ide> ---
<ide>
<ide><path>docs/MoreResources.md
<ide> title: More Resources
<ide> layout: docs
<ide> category: The Basics
<ide> permalink: docs/more-resources.html
<del>next: platform-specific-code
<add>next: components
<ide> previous: network
<ide> ---
<ide>
<ide><path>docs/PlatformSpecificInformation.md
<ide> layout: docs
<ide> category: Guides
<ide> permalink: docs/platform-specific-code.html
<ide> next: navigation
<del>previous: more-resources
<add>previous: components
<ide> ---
<ide>
<ide> When building a cross-platform app, you'll want to re-use as much code as possible. Scenarios may arise where it makes sense for the code to be different, for example you may want to implement separate visual components for iOS and Android.
| 3
|
Go
|
Go
|
add unit tests for the running state check
|
8c36e6920a9e17171dc67a79ab20d39886404e73
|
<ide><path>runtime_test.go
<ide> func TestRestore(t *testing.T) {
<ide> t.Fatal(err)
<ide> }
<ide> defer runtime1.Destroy(container1)
<del> if len(runtime1.List()) != 1 {
<del> t.Errorf("Expected 1 container, %v found", len(runtime1.List()))
<add>
<add> // Create a second container meant to be killed
<add> container1_1, err := runtime1.Create(&Config{
<add> Image: GetTestImage(runtime1).Id,
<add> Cmd: []string{"/bin/cat"},
<add> OpenStdin: true,
<add> },
<add> )
<add> if err != nil {
<add> t.Fatal(err)
<add> }
<add> defer runtime1.Destroy(container1_1)
<add>
<add> // Start the container non blocking
<add> if err := container1_1.Start(); err != nil {
<add> t.Fatal(err)
<add> }
<add>
<add> // Simulate a crash/manual quit of dockerd: process dies, states stays 'Running'
<add> if err := exec.Command("lxc-kill", "-n", container1_1.Id, "9").Run(); err == nil {
<add> t.Fatalf("container supposed to be killed (return error 255). Success received.")
<add> }
<add> container1_1.State.Running = true
<add>
<add> if len(runtime1.List()) != 2 {
<add> t.Errorf("Expected 2 container, %v found", len(runtime1.List()))
<ide> }
<ide> if err := container1.Run(); err != nil {
<ide> t.Fatal(err)
<ide> func TestRestore(t *testing.T) {
<ide> t.Fatal(err)
<ide> }
<ide> defer nuke(runtime2)
<del> if len(runtime2.List()) != 1 {
<del> t.Errorf("Expected 1 container, %v found", len(runtime2.List()))
<add> if len(runtime2.List()) != 2 {
<add> t.Errorf("Expected 2 container, %v found", len(runtime2.List()))
<add> }
<add> runningCount := 0
<add> for _, c := range runtime2.List() {
<add> if c.State.Running {
<add> runningCount++
<add> }
<add> }
<add> if runningCount != 0 {
<add> t.Fatalf("Expected 0 container alive, %d found", runningCount)
<ide> }
<ide> container2 := runtime2.Get(container1.Id)
<ide> if container2 == nil {
| 1
|
Javascript
|
Javascript
|
add marker segment (plt, plm) and refactor tlm
|
3d01c345a1e43d96cc62256bc47edb75a55d6e16
|
<ide><path>src/core/jpx.js
<ide> var JpxImage = (function JpxImageClosure() {
<ide> context.QCC = [];
<ide> context.COC = [];
<ide> break;
<del> case 0xFF55: // Tile-part lengths, main header (TLM)
<del> var Ltlm = readUint16(data, position); // Marker segment length
<del> // Skip tile length markers
<del> position += Ltlm;
<del> break;
<ide> case 0xFF5C: // Quantization default (QCD)
<ide> length = readUint16(data, position);
<ide> var qcd = {};
<ide> var JpxImage = (function JpxImageClosure() {
<ide> length = tile.dataEnd - position;
<ide> parseTilePackets(context, data, position, length);
<ide> break;
<add> case 0xFF55: // Tile-part lengths, main header (TLM)
<add> case 0xFF57: // Packet length, main header (PLM)
<add> case 0xFF58: // Packet length, tile-part header (PLT)
<ide> case 0xFF64: // Comment (COM)
<ide> length = readUint16(data, position);
<ide> // skipping content
<ide> var JpxImage = (function JpxImageClosure() {
<ide> r = 0;
<ide> c = 0;
<ide> p = 0;
<del>
<add>
<ide> this.nextPacket = function JpxImage_nextPacket() {
<ide> // Section B.12.1.3 Resolution-position-component-layer
<ide> for (; r <= maxDecompositionLevelsCount; r++) {
<ide> var JpxImage = (function JpxImageClosure() {
<ide> var componentsCount = siz.Csiz;
<ide> var precinctsSizes = getPrecinctSizesInImageScale(tile);
<ide> var l = 0, r = 0, c = 0, px = 0, py = 0;
<del>
<add>
<ide> this.nextPacket = function JpxImage_nextPacket() {
<ide> // Section B.12.1.5 Component-position-resolution-layer
<ide> for (; c < componentsCount; ++c) {
| 1
|
Ruby
|
Ruby
|
set verbose if --verbose
|
6c6e82a721f04f3aa4af66130d3e5d80ddb342c8
|
<ide><path>Library/Homebrew/superenv.rb
<ide> def setup_build_environment
<ide> ENV['CMAKE_FRAMEWORK_PATH'] = "#{MacOS.sdk_path}/System/Library/Frameworks" if MacSystem.xcode43_without_clt?
<ide> ENV['CMAKE_INCLUDE_PATH'] = determine_cmake_include_path
<ide> ENV['ACLOCAL_PATH'] = determine_aclocal_path
<add> ENV['VERBOSE'] = '1' if ARGV.verbose?
<ide> end
<ide>
<ide> def universal_binary
| 1
|
Text
|
Text
|
add missing header in changelog [ci skip]
|
20d07ad548a72de1546eeb03635eb074bb0cfbc5
|
<ide><path>CHANGELOG.md
<ide> # Ember Changelog
<ide>
<add>### 2.11.0-beta.4 (December 14, 2016)
<add>
<ide> - [#14685](https://github.com/emberjs/ember.js/pull/14685) [BUGFIX] Fix `this.$()` returning `undefined` in `willDestroyElement`.
<ide> - [#14717](https://github.com/emberjs/ember.js/pull/14717) [BUGFIX] Fix an issue with block params named `attrs`.
<ide>
| 1
|
Python
|
Python
|
check all output dimensions for compatibility
|
6b04add93209f557e265bbd04ab34d5491d463f0
|
<ide><path>keras/engine/training.py
<ide> def check_array_lengths(X, Y, W):
<ide>
<ide>
<ide> def check_loss_and_target_compatibility(targets, losses, output_shapes):
<del> assert len(targets) == len(losses) == len(output_shapes)
<ide> key_losses = {'mean_square_error',
<ide> 'binary_crossentropy',
<ide> 'categorical_crossentropy'}
<ide> for y, loss, shape in zip(targets, losses, output_shapes):
<ide> if loss.__name__ == 'categorical_crossentropy':
<del> if y.shape[1] == 1:
<add> if y.shape[-1] == 1:
<ide> raise Exception('You are passing a target array of shape ' + str(y.shape) +
<ide> ' while using as loss `categorical_crossentropy`. '
<ide> '`categorical_crossentropy` expects '
<ide> def check_loss_and_target_compatibility(targets, losses, output_shapes):
<ide> 'Alternatively, you can use the loss function '
<ide> '`sparse_categorical_crossentropy` instead, '
<ide> 'which does expect integer targets.')
<del> if loss.__name__ in key_losses and shape[1] is not None and y.shape[1] != shape[1]:
<del> raise Exception('A target array with shape ' + str(y.shape) +
<del> ' was passed for an output of shape ' + str(shape) +
<del> ' while using as loss `' + loss.__name__ + '`. '
<del> 'This loss expects '
<del> 'targets to have the same shape '
<del> 'as the output.')
<add> if loss.__name__ in key_losses:
<add> for target_dim, out_dim in zip(y.shape[1:], shape[1:]):
<add> if target_dim is not None and target_dim != out_dim:
<add> raise Exception('A target array with shape ' + str(y.shape) +
<add> ' was passed for an output of shape ' + str(shape) +
<add> ' while using as loss `' + loss.__name__ + '`. '
<add> 'This loss expects '
<add> 'targets to have the same shape '
<add> 'as the output.')
<ide>
<ide>
<ide> def collect_metrics(metrics, output_names):
<ide><path>tests/keras/engine/test_training.py
<ide>
<ide> from keras.layers import Dense, Dropout
<ide> from keras.engine.topology import merge, Input
<del>from keras.engine.training import Model
<add>from keras.engine.training import Model, check_loss_and_target_compatibility
<ide> from keras.models import Sequential
<ide> from keras import backend as K
<ide> from keras.utils.test_utils import keras_test
<ide> def test_trainable_argument():
<ide> assert_allclose(out, out_2)
<ide>
<ide>
<add>@keras_test
<add>def test_check_not_last_is_one():
<add> a = np.random.random((2, 1, 3))
<add> check_loss_and_target_compatibility([a], [K.categorical_crossentropy], [a.shape])
<add>
<add>
<add>@keras_test
<add>def test_check_last_is_one():
<add> a = np.random.random((2, 3, 1))
<add> with pytest.raises(Exception) as exc:
<add> check_loss_and_target_compatibility([a], [K.categorical_crossentropy], [a.shape])
<add>
<add> assert "You are passing a target array" in str(exc)
<add>
<add>
<add>@keras_test
<add>def test_check_bad_shape():
<add> a = np.random.random((2, 3, 5))
<add> with pytest.raises(Exception) as exc:
<add> check_loss_and_target_compatibility([a], [K.categorical_crossentropy], [(2, 3, 6)])
<add>
<add> assert "targets to have the same shape" in str(exc)
<add>
<add>
<ide> if __name__ == '__main__':
<ide> pytest.main([__file__])
| 2
|
Text
|
Text
|
fix documentation of 'path' in tokenizer.to_disk
|
aa50aca519a793120401cbeb7f8f7b882da78038
|
<ide><path>website/docs/api/tokenizer.md
<ide> the
<ide> > tokenizer = nlp.Defaults.create_tokenizer(nlp)
<ide> > ```
<ide>
<del>| Name | Type | Description |
<add>| Name | Type | Description |
<ide> | ---------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------ |
<ide> | `vocab` | `Vocab` | A storage container for lexical types. |
<ide> | `rules` | dict | Exceptions and special-cases for the tokenizer. |
<ide> produced are identical to `Tokenizer.__call__` except for whitespace tokens.
<ide> > assert [t[1] for t in tok_exp] == ["(", "do", "n't", ")"]
<ide> > ```
<ide>
<del>| Name | Type | Description |
<del>| ------------| -------- | --------------------------------------------------- |
<del>| `string` | unicode | The string to tokenize with the debugging tokenizer |
<del>| **RETURNS** | list | A list of `(pattern_string, token_string)` tuples |
<add>| Name | Type | Description |
<add>| ----------- | ------- | --------------------------------------------------- |
<add>| `string` | unicode | The string to tokenize with the debugging tokenizer |
<add>| **RETURNS** | list | A list of `(pattern_string, token_string)` tuples |
<ide>
<ide> ## Tokenizer.to_disk {#to_disk tag="method"}
<ide>
<ide> Serialize the tokenizer to disk.
<ide> > tokenizer.to_disk("/path/to/tokenizer")
<ide> > ```
<ide>
<del>| Name | Type | Description |
<del>| --------- | ---------------- | --------------------------------------------------------------------------------------------------------------------- |
<del>| `path` | unicode / `Path` | A path to a directory, which will be created if it doesn't exist. Paths may be either strings or `Path`-like objects. |
<del>| `exclude` | list | String names of [serialization fields](#serialization-fields) to exclude. |
<add>| Name | Type | Description |
<add>| --------- | ---------------- | ---------------------------------------------------------------------------------------------------------------- |
<add>| `path` | unicode / `Path` | A path to a file, which will be created if it doesn't exist. Paths may be either strings or `Path`-like objects. |
<add>| `exclude` | list | String names of [serialization fields](#serialization-fields) to exclude. |
<ide>
<ide> ## Tokenizer.from_disk {#from_disk tag="method"}
<ide>
<ide> it.
<ide>
<ide> ## Attributes {#attributes}
<ide>
<del>| Name | Type | Description |
<del>| ---------------- | ------- | --------------------------------------------------------------------------------------------------------------------------- |
<del>| `vocab` | `Vocab` | The vocab object of the parent `Doc`. |
<del>| `prefix_search` | - | A function to find segment boundaries from the start of a string. Returns the length of the segment, or `None`. |
<del>| `suffix_search` | - | A function to find segment boundaries from the end of a string. Returns the length of the segment, or `None`. |
<del>| `infix_finditer` | - | A function to find internal segment separators, e.g. hyphens. Returns a (possibly empty) list of `re.MatchObject` objects. |
<del>| `token_match` | - | A function matching the signature of `re.compile(string).match to find token matches. Returns an `re.MatchObject` or `None. |
<del>| `rules` | dict | A dictionary of tokenizer exceptions and special cases. |
<add>| Name | Type | Description |
<add>| ---------------- | ------- | -------------------------------------------------------------------------------------------------------------------------- |
<add>| `vocab` | `Vocab` | The vocab object of the parent `Doc`. |
<add>| `prefix_search` | - | A function to find segment boundaries from the start of a string. Returns the length of the segment, or `None`. |
<add>| `suffix_search` | - | A function to find segment boundaries from the end of a string. Returns the length of the segment, or `None`. |
<add>| `infix_finditer` | - | A function to find internal segment separators, e.g. hyphens. Returns a (possibly empty) list of `re.MatchObject` objects. |
<add>| `token_match` | - | A function matching the signature of `re.compile(string).match to find token matches. Returns an`re.MatchObject`or`None. |
<add>| `rules` | dict | A dictionary of tokenizer exceptions and special cases. |
<ide>
<ide> ## Serialization fields {#serialization-fields}
<ide>
| 1
|
Java
|
Java
|
fix scrollview bounce back bug in open source
|
36ca1a078acbaba770c196847254e7a6e80c6918
|
<ide><path>ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollView.java
<ide>
<ide> import javax.annotation.Nullable;
<ide>
<add>import java.lang.reflect.Field;
<add>
<ide> import android.content.Context;
<ide> import android.graphics.Canvas;
<ide> import android.graphics.Color;
<ide> import android.graphics.Rect;
<ide> import android.graphics.drawable.ColorDrawable;
<ide> import android.graphics.drawable.Drawable;
<add>import android.util.Log;
<ide> import android.view.MotionEvent;
<ide> import android.view.View;
<add>import android.widget.OverScroller;
<ide> import android.widget.ScrollView;
<ide>
<add>import com.facebook.react.common.ReactConstants;
<ide> import com.facebook.react.uimanager.MeasureSpecAssertions;
<ide> import com.facebook.react.uimanager.events.NativeGestureUtil;
<ide> import com.facebook.react.views.view.ReactClippingViewGroup;
<ide> */
<ide> public class ReactScrollView extends ScrollView implements ReactClippingViewGroup {
<ide>
<add> private static Field sScrollerField;
<add> private static boolean sTriedToGetScrollerField = false;
<add>
<ide> private final OnScrollDispatchHelper mOnScrollDispatchHelper = new OnScrollDispatchHelper();
<add> private final OverScroller mScroller;
<ide>
<ide> private @Nullable Rect mClippingRect;
<ide> private boolean mDoneFlinging;
<ide> public ReactScrollView(Context context) {
<ide> public ReactScrollView(Context context, @Nullable FpsListener fpsListener) {
<ide> super(context);
<ide> mFpsListener = fpsListener;
<add>
<add> if (!sTriedToGetScrollerField) {
<add> sTriedToGetScrollerField = true;
<add> try {
<add> sScrollerField = ScrollView.class.getDeclaredField("mScroller");
<add> sScrollerField.setAccessible(true);
<add> } catch (NoSuchFieldException e) {
<add> Log.w(
<add> ReactConstants.TAG,
<add> "Failed to get mScroller field for ScrollView! " +
<add> "This app will exhibit the bounce-back scrolling bug :(");
<add> }
<add> }
<add>
<add> if (sScrollerField != null) {
<add> try {
<add> mScroller = (OverScroller) sScrollerField.get(this);
<add> } catch (IllegalAccessException e) {
<add> throw new RuntimeException("Failed to get mScroller from ScrollView!", e);
<add> }
<add> } else {
<add> mScroller = null;
<add> }
<ide> }
<ide>
<ide> public void setSendMomentumEvents(boolean sendMomentumEvents) {
<ide> public void getClippingRect(Rect outClippingRect) {
<ide>
<ide> @Override
<ide> public void fling(int velocityY) {
<del> super.fling(velocityY);
<add> if (mScroller != null) {
<add> // FB SCROLLVIEW CHANGE
<add>
<add> // We provide our own version of fling that uses a different call to the standard OverScroller
<add> // which takes into account the possibility of adding new content while the ScrollView is
<add> // animating. Because we give essentially no max Y for the fling, the fling will continue as long
<add> // as there is content. See #onOverScrolled() to see the second part of this change which properly
<add> // aborts the scroller animation when we get to the bottom of the ScrollView content.
<add>
<add> int scrollWindowHeight = getHeight() - getPaddingBottom() - getPaddingTop();
<add>
<add> mScroller.fling(
<add> getScrollX(),
<add> getScrollY(),
<add> 0,
<add> velocityY,
<add> 0,
<add> 0,
<add> 0,
<add> Integer.MAX_VALUE,
<add> 0,
<add> scrollWindowHeight / 2);
<add>
<add> postInvalidateOnAnimation();
<add>
<add> // END FB SCROLLVIEW CHANGE
<add> } else {
<add> super.fling(velocityY);
<add> }
<add>
<ide> if (mSendMomentumEvents || isScrollPerfLoggingEnabled()) {
<ide> mFlinging = true;
<ide> enableFpsListener();
<ide> public void setEndFillColor(int color) {
<ide> mEndBackground = new ColorDrawable(mEndFillColor);
<ide> }
<ide> }
<add>
<add> @Override
<add> protected void onOverScrolled(int scrollX, int scrollY, boolean clampedX, boolean clampedY) {
<add> if (mScroller != null) {
<add> // FB SCROLLVIEW CHANGE
<add>
<add> // This is part two of the reimplementation of fling to fix the bounce-back bug. See #fling() for
<add> // more information.
<add>
<add> if (!mScroller.isFinished() && mScroller.getCurrY() != mScroller.getFinalY()) {
<add> int scrollRange = Math.max(
<add> 0,
<add> getChildAt(0).getHeight() - (getHeight() - getPaddingBottom() - getPaddingTop()));
<add> if (scrollY >= scrollRange) {
<add> mScroller.abortAnimation();
<add> }
<add> }
<add>
<add> // END FB SCROLLVIEW CHANGE
<add> }
<add>
<add> super.onOverScrolled(scrollX, scrollY, clampedX, clampedY);
<add> }
<ide> }
| 1
|
Javascript
|
Javascript
|
remove trailing comma
|
be6bf4cb16d9a79b2f9a6f78430b4af054e49f91
|
<ide><path>lang/is.js
<ide> M : translate,
<ide> MM : translate,
<ide> y : translate,
<del> yy : translate,
<add> yy : translate
<ide> },
<ide> ordinal : function (number) {
<ide> return '.';
| 1
|
Javascript
|
Javascript
|
fix typo in test/parallel/test-icu-punycode.js
|
a1faa8d8521886c6a444ed2c6ba8cd735448bb8c
|
<ide><path>test/parallel/test-icu-punycode.js
<ide> const assert = require('assert');
<ide>
<ide> // Test hasConverter method
<ide> assert(icu.hasConverter('utf-8'),
<del> 'hasConverter should report coverter exists for utf-8');
<add> 'hasConverter should report converter exists for utf-8');
<ide> assert(!icu.hasConverter('x'),
<del> 'hasConverter should report coverter does not exist for x');
<add> 'hasConverter should report converter does not exist for x');
<ide>
<ide> const tests = require('../fixtures/url-idna.js');
<ide> const fixtures = require('../common/fixtures');
| 1
|
Javascript
|
Javascript
|
fix few early returns in parser.js
|
d2303493fe1a2376d5484c195609a2bef79e14ad
|
<ide><path>src/parser.js
<ide> var Parser = (function parserParser() {
<ide> return new PredictorStream(new FlateStream(stream), params);
<ide> }
<ide> return new FlateStream(stream);
<del> } else if (name == 'LZWDecode' || name == 'LZW') {
<add> }
<add> if (name == 'LZWDecode' || name == 'LZW') {
<ide> var earlyChange = 1;
<ide> if (params) {
<ide> if (params.has('EarlyChange'))
<ide> var Parser = (function parserParser() {
<ide> new LZWStream(stream, earlyChange), params);
<ide> }
<ide> return new LZWStream(stream, earlyChange);
<del> } else if (name == 'DCTDecode' || name == 'DCT') {
<add> }
<add> if (name == 'DCTDecode' || name == 'DCT') {
<ide> var bytes = stream.getBytes(length);
<ide> return new JpegStream(bytes, stream.dict, this.xref);
<del> } else if (name == 'ASCII85Decode' || name == 'A85') {
<add> }
<add> if (name == 'ASCII85Decode' || name == 'A85') {
<ide> return new Ascii85Stream(stream);
<del> } else if (name == 'ASCIIHexDecode' || name == 'AHx') {
<add> }
<add> if (name == 'ASCIIHexDecode' || name == 'AHx') {
<ide> return new AsciiHexStream(stream);
<del> } else if (name == 'CCITTFaxDecode' || name == 'CCF') {
<add> }
<add> if (name == 'CCITTFaxDecode' || name == 'CCF') {
<ide> return new CCITTFaxStream(stream, params);
<del> } else {
<del> TODO('filter "' + name + '" not supported yet');
<ide> }
<add> TODO('filter "' + name + '" not supported yet');
<ide> return stream;
<ide> }
<ide> };
| 1
|
Text
|
Text
|
add the guide contribution instructions
|
ce0c9ae9f945228877a41ab25cea04a3c6df1fc6
|
<ide><path>CONTRIBUTING.md
<ide> If you would like work on these, follow along these guidelines:
<ide>
<ide> **[TODO]**
<ide>
<add>### [How to work on Curriculum Challenges.](/docs/how-to-work-on-curriculum-challenges.md)
<add>
<ide> #### Translate guide articles and curriculum challenges
<ide>
<ide> You can help us translate our Guide articles and Curriculum challenges for a language that you speak. Currently we have translated versions in:
<ide><path>docs/how-to-work-on-guide-articles.md
<add># How to work on Guide articles
<add>
<add>With your help, we can create a comprehensive reference tool that will help millions of people who are learning to code for years to come. 💛
<add>
<add><!-- TOC -->
<add>
<add>- [How to work on Guide articles](#how-to-work-on-guide-articles)
<add> - [Steps](#steps)
<add> - [Creating a PR](#creating-a-pr)
<add> - [Using GitHub.com](#using-githubcom)
<add> - [Cloning Locally](#cloning-locally)
<add> - [Running Locally](#running-locally)
<add> - [Getting PR Accepted](#getting-pr-accepted)
<add> - [Labels](#labels)
<add> - [Conflicting/Duplicate Content](#conflictingduplicate-content)
<add> - [Requesting Changes](#requesting-changes)
<add> - [Travis CI Build](#travis-ci-build)
<add> - [Closing](#closing)
<add> - [Getting Help](#getting-help)
<add> - [Article Style Guide](#article-style-guide)
<add> - [Title](#title)
<add> - [Modularity](#modularity)
<add> - [Code Blocks](#code-blocks)
<add> - [Links](#links)
<add> - [Images](#images)
<add> - [Attributions](#attributions)
<add> - [Resources](#resources)
<add> - [Formatting](#formatting)
<add> - [Technical Writing](#technical-writing)
<add> - [Outline](#outline)
<add> - [Intro](#intro)
<add> - [Content](#content)
<add> - [Clarity](#clarity)
<add> - [Voice](#voice)
<add> - [Passive](#passive)
<add> - [Active](#active)
<add> - [Point of View](#point-of-view)
<add> - [Abbreviations](#abbreviations)
<add> - [Proper nouns](#proper-nouns)
<add> - [Third-Party Tools](#third-party-tools)
<add>- [Reviewing PRs](#reviewing-prs)
<add> - [Squash and Merge](#squash-and-merge)
<add> - [Filtering PRs](#filtering-prs)
<add> - [Templates](#templates)
<add> - [Thank you](#thank-you)
<add> - [Thank you and congrats](#thank-you-and-congrats)
<add> - [Build Error](#build-error)
<add> - [Syncing Fork](#syncing-fork)
<add> - [Merge Conflicts](#merge-conflicts)
<add> - [Duplicate](#duplicate)
<add> - [Closing](#closing)
<add>
<add><!-- /TOC -->
<add>
<add>## Steps
<add>
<add>1. 🍴 [Fork this repo](https://github.com/freeCodeCamp/guide#fork-destination-box)
<add>2. 👀️ Follow the contributing guidelines outlined below.
<add>3. 🔧 Make some awesome changes!
<add>4. 👉 [Make a pull request](https://github.com/freeCodeCamp/guide/compare)
<add>5. 🎉 Get your pull request approved - success!
<add>
<add>Or just [create an issue](https://github.com/freeCodeCamp/guide/issues) - any little bit of help counts! 😊
<add>
<add>## Creating a PR
<add>
<add>### Using GitHub.com
<add>
<add>Watch the video demonstration or follow the steps below it:
<add>
<add>
<add>
<add>1. Go into the **"pages"** folder (located in [`client/src/pages/guide`](/client/src/pages/guide)) and find the article stub you'd like to write or edit.
<add>
<add> > All stubs will be in an index.md file
<add>
<add>2. Click the <kbd>Edit this file</kbd> pencil icon and make your changes to the file in GitHub-flavored Markdown.
<add>
<add> > If the icon is greyed out and giving you the warning "You must be on a branch to make or propose changes to this file", then you are likely on another person's tree. At the top left of the page, there is a drop down box which says "Tree: #######". Click on the drop down and change the branch to "master". The pencil icon should now be clickable.
<add>
<add>3. Scroll to the bottom of the screen and add a commit message explaining your changes.
<add>
<add>4. Then select the radio button option for **"Create a new branch for this commit and start a pull request"** and click <kbd>Propose file changes</kbd>.
<add>
<add>5. On the next screen, you can add any other details about your PR, then click <kbd>Create pull request</kbd>.
<add>
<add>### Cloning Locally
<add>
<add>1. Fork this repository
<add>
<add>2. Copy it to your local machine by running the following command:
<add>
<add> ```bash
<add> git clone https://github.com/YOUR-GITHUB-USERNAME/guide.git
<add> ```
<add>
<add>3. Add a remote upstream so git knows where the official freeCodeCamp guide repository is located by running the following command in the local folder where the repository is stored at:
<add>
<add> ```bash
<add> git remote add upstream https://github.com/freeCodeCamp/guide.git
<add> ```
<add>
<add>4. Create a new branch for your work with the command `git checkout -b NEW-BRANCH-NAME`.
<add>
<add> > Try to name your branch in a way that describes your article topic, like `fix/article-html`
<add>
<add>5. Write your article, commit your changes locally, and push your new branch to GitHub with the command `git push origin NEW-BRANCH-NAME`
<add>
<add>6. Go to your repository on GitHub and open a PR
<add>
<add>Make sure to maintain your local fork going forward so it stays up-to-date with the freeCodeCamp guide repository.
<add>
<add>The next time you want to contribute, checkout your local `master` branch and run the command `git pull --rebase upstream master` before creating a new branch.
<add>
<add>This will grab all the changes on the official `master` branch without making an additional commit in your local repository.
<add>
<add>### Running Locally
<add>
<add>Make sure to have yarn installed (follow these [instructions](https://yarnpkg.com/en/docs/install) if needed).
<add>
<add>```bash
<add># fork repo
<add>
<add># clone down your repo
<add>git clone https://github.com/YOUR-GITHUB-USERNAME/guide.git
<add>
<add># navigate to root folder
<add>cd guide
<add>
<add># install dependencies
<add>yarn install
<add>
<add># run locally
<add>yarn develop
<add>```
<add>
<add>In this project, we are using `yarn` because `netlify` builds our site with `yarn`.
<add>
<add>## Getting PR Accepted
<add>
<add>Here are a few guidelines the reviewers follow when reviewing PRs:
<add>
<add>- there is a relevant description and title
<add>- PR respects the [Article style guide](./CONTRIBUTING.md/#article-style-guide)
<add>- we follow general QA tips found in [Moderator guidelines](https://forum.freecodecamp.org/t/freecodecamp-moderator-guidelines/18295)
<add>- as long as a pull request improves or expands the guide, we accept it even if it contains imperfect English or partial content
<add>- older pull requests are reviewed first
<add>
<add>### Labels
<add>
<add>- **content** is for pull requests that modify the content of articles on the guide (they add a new article or update an existing article)
<add>- **duplicate** is for pull requests that have the same content as another open PR
<add>- **changes requested** is for pull requests that need a change before getting merged
<add>- **stale** is for pull requests with _"changes requested"_ label that doesn't get activity after about 2 weeks and will subsequently be closed.
<add> - A _stale_ pull request should be closed.
<add> - Here is [an example](https://github.com/freeCodeCamp/guide/pull/235).
<add>
<add>### Conflicting/Duplicate Content
<add>
<add>A PR is considered a **duplicate** if it makes changes to the same article as another PR.
<add>
<add>In general, a reviewer will:
<add>
<add>1. Sort PR from the oldest
<add>2. Search for PRs with similar content
<add>3. Merge from the oldest to the newest
<add>
<add>It is very likely there will be merge conflicts with duplicate PRs.
<add>
<add>Reviewers will make every effort to resolve these conflicts and merge duplicate PRs.
<add>
<add>### Requesting Changes
<add>
<add>If a pull request is not perfect, the reviewer may:
<add>
<add>- request changes to the contributor and add the *changes requested* label
<add>- fix minor issues and make a commit on top of the PR
<add>
<add>### Travis CI Build
<add>
<add>All PRs must pass the Travis CI checks before we can merge it.
<add>
<add>If a PR breaks the build (a Travis CI check fails and shows a red "X") there are three likely sources.
<add>
<add>You will need to fix the issue before we can merge your PR:
<add>
<add>1. Your PR creates a new article and it's missing an `index.md` file somewhere.
<add> - Every folder in `src/pages` needs an `index.md` file in it (and the name has to be `index.md`).
<add> - Two likely scenarios are
<add> - you named the new article file something other than `index.md`, or
<add> - you created both a new folder, then a sub-folder, you wrote the new article in the sub-folder but forget to put a stub `index.md` file in the new folder
<add>2. Your PR creates a new folder and the folder name isn't formatted correctly.
<add> - Your folder name should be all lowercase and formated in kebab-case (i.e. my-new-folder).
<add>3. The article doesn't have a `title` field at the top.
<add> - Please refer to [Title](#title) section below under [Article Style Guide](#article-style-guide).
<add>
<add>### Closing
<add>
<add>We close a pull request
<add>
<add>- if an older PR for the same article is merged, and your PR doesn't add new content
<add>- if there is zero/little effort in it (e.g: copy pasting from another source like Wikipedia)
<add>- if there is copied text from a copyrighted source - see [Citation issue](https://github.com/freeCodeCamp/guide/issues/2503)
<add>- if it does not respect the [Article Style Guide](#article-style-guide)
<add>- if it does not respect the [Academic Honesty policy](https://www.freecodecamp.org/academic-honesty)
<add>- if it is stale (if a change is requested and there is no activity for about 2 weeks)
<add>
<add>Also, if you're working off a "stub" article, your changes must be substantial enough to replace the stub text.
<add>
<add>We won't accept a PR that only adds links to the "More Information:" section.
<add>
<add>The repository has a `Normalise.js` script that adds attributes to links, but also checks for "This is a stub..." text via a RegEx.
<add>
<add>If found, it will revert the article text back to the generic stub text (and erase your changes).
<add>
<add>This is intended behavior, since it allows us to update all stubs if the template stub changed for any reason.
<add>
<add>### Getting Help
<add>
<add>There's a community of support from a whole team of contributors, whom you can bounce ideas off of and ask for input on your writing.
<add>
<add>Stay active in the [contributors chat room](https://gitter.im/freecodecamp/contributors) and ask lots of questions.
<add>
<add>## Article Style Guide
<add>
<add>We've written the following guide to writing Guide articles to help you get started contributing.
<add>
<add>### Title
<add>
<add>Article titles should be as short, concise, and to-the-point as possible.
<add>
<add>We want campers to quickly find the information they're looking for, and the title should reflect the main theme of the article.
<add>
<add>Folder name is used in the URL, so only use dashes -, numbers 0-9, and lowercase letters a-z for it.
<add>
<add>However, you can include special characters in the article title.
<add>
<add>Here are some examples of properly named titles:
<add>
<add>> [`src/pages/html/tables/index.md`](https://github.com/freeCodeCamp/guide/blob/master/src/pages/html/tables/index.md)
<add>
<add>```markdown
<add>---
<add>title: Tables
<add>---
<add>```
<add>
<add>> [`src/pages/css/borders/index.md`](https://github.com/freeCodeCamp/guide/blob/master/src/pages/css/borders/index.md)
<add>
<add>```markdown
<add>---
<add>title: Borders
<add>---
<add>```
<add>
<add>> [`src/pages/javascript/loops/for-loop/index.md`](https://github.com/freeCodeCamp/guide/blob/master/src/pages/javascript/loops/for-loop/index.md)
<add>
<add>```markdown
<add>---
<add>title: For Loop
<add>---
<add>```
<add>
<add>### Modularity
<add>
<add>Each article should explain exactly one concept, and that concept should be apparent from the article's title.
<add>
<add>We can reference other articles by linking to them inline, or in an "Other Resources" section at the end of the article.
<add>
<add>Our goal is to have thousands of articles that cover a broad range of technical topics.
<add>
<add>### Code Blocks
<add>
<add>Campers will likely use Guide articles as a quick reference to look up syntax. Articles should have simple real-world examples that show common-use cases of that syntax.
<add>
<add>GitHub-flavored markdown supports [syntax highlighting in code blocks](https://help.github.com/articles/creating-and-highlighting-code-blocks/#syntax-highlighting) for many programming languages.
<add>
<add>To use it, indicate the language after ```.
<add>
<add>For example, the following Markdown
<add>
<add>```markdown
<add> ```html
<add> <div class='awesome' id='more-awesome'>
<add> <p>This is text in html</p>
<add> </div>
<add> ```
<add>```
<add>
<add>will output the following code block with `HTML` syntax highlighting since we indicated the language `html` after the ```.
<add>
<add>```html
<add><div class='awesome' id='more-awesome'>
<add> <p>This is text in html</p>
<add></div>
<add>```
<add>
<add>The following represents two other examples using JavaScript and CSS syntax highlighting.
<add>
<add>```markdown
<add> ```javascript
<add> function logTheThings(stuff) {
<add> console.log(stuff);
<add> }
<add> ```
<add>
<add> ```css
<add> .awesome {
<add> background-color: #FCCFCC;
<add> }
<add> ```
<add>```
<add>
<add>Please keep the following recommendations in mind:
<add>
<add>- To ensure correct rendering, each codeblock must have a language label. You can find a list of supported languages [here](http://prismjs.com/#languages-list ).
<add>- For codeblocks with no appropriate language, use generic labels like ` ```text `, or ` ```code `.
<add>- You may know about markdown's four-space indentation syntax for writing codeblocks. However, this is currently __not__ supported by our rendering system.
<add>
<add>Finally, here are some suggested formatting guidelines when writing code blocks:
<add>
<add>- JavaScript statements should end with a `;` semicolon
<add>- Comments made should have a space between the comment characters and the comment themselves
<add> ```javascript
<add> // Like this
<add> ```
<add>
<add>### Links
<add>
<add>Use Markdown style links in your articles to link to other websites.
<add>
<add>```markdown
<add>[freeCodeCamp](https://www.freecodecamp.org/)
<add>```
<add>
<add>### Images
<add>
<add>For including images, if they aren't already hosted somewhere else on the web, you will need to put them online yourself using a platform like [Imgur](https://imgur.com/) or [Flickr](https://www.flickr.com). You can also host images by committing them to a git repository and pushing it to GitHub. Then you can right-click the image and copy its URL.
<add>
<add>We don't allow hosting images directly in the git repository because it would make it far too big (people pulling it to their local system to make changes would end up downloading all the images), and because it is easier to change an image by just changing the URL in an article than by putting the new image in the repository.
<add>
<add>To include the image in your article, use the appropriate markdown syntax:
<add>
<add>```markdown
<add>
<add>```
<add>
<add>Then the images should show up when you click the <kcd>Preview</kcd> tab.
<add>
<add>You can also add diagrams, graphics, or visualizations as necessary.
<add>
<add>You can even embed relevant YouTube videos and interactive [REPL.it](https://repl.it/) code editors.
<add>
<add>Don't use emojis or emoticons in the Guide. freeCodeCamp has a global community, and the cultural meaning of an emoji or emoticon may be different around the world. Also, emojis can render differently on different systems.
<add>
<add>### Attributions
<add>
<add>To minimize the potential for plagiarism and maintain integrity in this guide, it is important to give credit where necessary.
<add>
<add>Any material quoted, or used directly and unchanged, from source material should be wrapped in quotation marks and be adequately cited. Material that is not a direct quote but is still paraphrased from a different resource should also be cited.
<add>
<add>You can create superscript numerals to mark content that is cited using `<sup></sup>` tags.
<add>
<add>Like so: <sup>1</sup>
<add>
<add>1. freeCodeCamp - Attributions
<add>
<add>Then, at the bottom of your article, place a
<add>
<add>```markdown
<add>### Sources
<add>```
<add>
<add>heading and include all of your citations numbered to correspond with your sources.
<add>
<add>An example is highlighted below.
<add>
<add>```markdown
<add>Here is some content that should be cited.<sup>1</sup>
<add>
<add>And here is even more that should be cited from another source.<sup>2</sup>
<add>
<add>### Sources
<add>
<add>1. [Doe, John. "Authoring Words." *WikiCoder*. January 1, 1970. Accessed: October 20, 2017](#)
<add>2. [Purdue OWL Staff. "MLA Works Cited: Electronic Sources." *Purdue Online Writing Lab.* October 12, 2017. Accessed: October 20, 2017.](https://owl.english.purdue.edu/owl/resource/747/08/)
<add>```
<add>
<add>You can check out the Purdue link above to see how to properly cite web sources (they even show how to cite tweets!).
<add>
<add>Typically, an attribution has a structure like the following:
<add>
<add>> Author Last Name, Author First Name. "Article Title." *Publication.* Publisher. Date Published. Date Accessed.
<add>
<add>If you cannot find an author or published date, which is common, simply omit these.
<add>
<add>Use of proper citations will not only keep the guide reputable, but these citations and links will also provide valuable resources should the reader want to learn more about the topic.
<add>
<add>Also note that instances of blatant plagiarism will be either removed or have their pull requests declined, and the user will receive a warning.
<add>
<add>Please refer to and review freeCodeCamp's [Academic Honesty Policy](https://www.freecodecamp.org/academic-honesty) before contributing.
<add>
<add>### Resources
<add>
<add>If there are other Guide resources you think campers would benefit from, add them at the bottom in a "Resources" section with a bulleted list.
<add>
<add>```markdown
<add>### Resources
<add>
<add>- [A New Resource](#link)
<add>```
<add>
<add>### Formatting
<add>
<add>Use double quotes where applicable.
<add>
<add>Format language keywords as code - this is done with the backtick key (located to the left of the "1" key on a US keyboard) in GitHub-flavored markdown. For example, put back ticks around HTML tag names or CSS property names.
<add>
<add>Use the Oxford Comma when possible (it is a comma used after the penultimate item in a list of three or more items, before ‘and’ or ‘or’ e.g. an Italian painter, sculptor, and architect). It makes things easier, clearer, and prettier to read.
<add>
<add>## Technical Writing
<add>
<add>Technical writing, or the literature of science and technology, is hard.
<add>
<add>You'll need to take a technical (usually abstract) topic and explain it in a clear, accurate, and objective manner.
<add>
<add>You'll likely go through several rounds of proofreading and editing before you're happy with the result.
<add>
<add>### Outline
<add>
<add>Before you begin writing, create an outline of the topic and think about any coding examples you'll use (if applicable).
<add>
<add>This helps to organize your thoughts and make the writing process easier.
<add>
<add>### Intro
<add>
<add>The introduction paragraph should only be 1-2 sentences long and be a simple explanation of the main topic. It should limit the use of any links to other Guide articles, as they can be distracting.
<add>
<add>### Content
<add>
<add>Keep paragraphs short (around 1-4 sentences). People are more likely to read several short paragraphs over a wall of text.
<add>
<add>### Clarity
<add>
<add>Articles should be written with short, clear sentences, and use as little jargon as necessary.
<add>
<add>All jargon should be defined immediately in plain English.
<add>
<add>### Voice
<add>
<add>Use active voice instead of passive voice. Generally, it's a stronger and more straightforward way to communicate a subject. For example:
<add>
<add>#### Passive
<add>
<add>The `for` loop in JavaScript is used by programmers to...
<add>
<add>#### Active
<add>
<add>Programmers use the `for` loop in JavaScript to...
<add>
<add>### Point of View
<add>
<add>Text should use the second person ("you") to help to give it a conversational tone.
<add>
<add>This way, the text and instructions seem to speak directly to the camper reading it.
<add>
<add>Try to avoid using the first person ("I", "we", "let's", and "us").
<add>
<add>### Abbreviations
<add>
<add>If you want to abbreviate a term in your article, write it out fully first, then put the abbreviation in parentheses.
<add>
<add>For example, `"In computer science, an abstract syntax tree (AST) is ..."`
<add>
<add>### Proper nouns
<add>
<add>Proper nouns should use correct capitalization when possible. Below is a list of words as they should appear in Guide articles.
<add>
<add>- JavaScript (capital letters in "J" and "S" and no abbreviations)
<add>- Node.js
<add>
<add>Front-end development (adjective form with a dash) is when you working on the front end (noun form with no dash). The same goes with the back end, full stack, and many other compound terms.
<add>
<add>### Third-Party Tools
<add>
<add>To check for grammar and spelling, we recommend using an app like [Grammarly](https://grammarly.com) or a built in extension/plugin that checks for this within your text editor.
<add>
<add>- [VS Code](https://code.visualstudio.com/) - [Code Spell Checker](https://marketplace.visualstudio.com/items?itemName=streetsidesoftware.code-spell-checker)
<add>- [Sublime Text 3](https://www.sublimetext.com/docs/3/spell_checking.html)
<add>
<add>To check your writing style, we recommend the [Hemingway App](http://www.hemingwayapp.com/).
<add>
<add>There’s nothing magical about this simple tool, but it will automatically detect widely agreed-upon style issues:
<add>
<add>- passive voice
<add>- unnecessary adverbs
<add>- words that have more common equivalents
<add>
<add>The Hemingway App will assign a "grade level" for your writing.
<add>
<add>You should aim for a grade level of 6.
<add>
<add>Another tool available is the [De-Jargonizer](http://scienceandpublic.com/), originally designed for scientific communication but might help avoid overspecialized wording.
<add>
<add>---
<add>
<add># Reviewing PRs
<add>
<add>> This section is targeted at reviewers of this repo.
<add>
<add>## Squash and Merge
<add>
<add>We use the <kcd>Squash and merge</kcd> option when merging the PR which keeps the commit history clean.
<add>
<add>
<add>
<add>## Filtering PRs
<add>
<add>> PR, Open, Oldest First, Travis CI Build successful, no one assigned, no comments
<add>
<add>[`is:pr is:open sort:updated-asc status:success no:assignee comments:0`](https://github.com/freeCodeCamp/guide/pulls?utf8=%E2%9C%93&q=is%3Apr%20is%3Aopen%20sort%3Aupdated-asc%20status%3Asuccess%20no%3Aassignee%20comments%3A0)
<add>
<add>> PR, Open, Oldest First, Does not have labels: `platform`, `enhancement`, `invalid` or `changes requested`
<add>
<add>[`is:pr is:open sort:updated-asc -label:platform -label:enhancement -label:invalid -label:"changes requested"`](https://github.com/freeCodeCamp/guide/pulls?utf8=%E2%9C%93&q=is%3Apr%20is%3Aopen%20sort%3Aupdated-asc%20-label%3Aplatform%20-label%3Aenhancement%20-label%3Ainvalid%20-label%3A%22changes%20requested%22).
<add>
<add>## Templates
<add>
<add>> You can make your own with GitHub's built in [**Saved replies**](https://github.com/settings/replies/) feature or use the ones below.
<add>
<add>### Thank you
<add>
<add>```markdown
<add>Thank you for your contribution to the page! 👍
<add>We're happy to accept these changes, and look forward to future contributions. 🎉
<add>```
<add>
<add>### Thank you and congrats
<add>
<add>> For thanking and encouraging first-time contributors.
<add>
<add>```markdown
<add>Hi @username. Congrats on your first pull request (PR)! 🎉
<add>
<add>Thank you for your contribution to the page! 👍
<add>We're happy to accept these changes, and look forward to future contributions. 📝
<add>```
<add>
<add>### Build Error
<add>
<add>```markdown
<add>Hey @username
<add>
<add>So I'd love to be able to merge your changes but it looks like there is an error with the Travis CI build. ⚠️
<add>
<add>Once you resolve these issues, I will be able to review your PR and merge it. 😊
<add>
<add>---
<add>
<add>> Feel free to reference the [Article Style Guide](https://github.com/freeCodeCamp/guide#article-title) for this repo on formatting an article correctly so your Travis CI build passes. ✅
<add>>
<add>> Also, it's good practice on GitHub to write a brief description of your changes when creating a PR. 📝
<add>```
<add>
<add>### Syncing Fork
<add>
<add>> When PR is not up to date with `master` branch.
<add>
<add>``````markdown
<add>Hey @username
<add>
<add>So I'd love to be able to merge your changes but it looks like there is an error with the Travis CI build. ⚠️
<add>
<add>```bash
<add>Error: ENOTDIR: not a directory, open 'src/pages/java/data-abstraction/index.md'
<add>```
<add>
<add>This particular error was not actually caused by your file but was an old error caused by merging faulty code to the `master` branch. It has since been resolved.
<add>
<add>To pass the build, you will have to sync the latest changes from the `master` branch of the `freeCodeCamp/guide` repo.
<add>
<add>Using the command line, you can do this in three easy steps:
<add>
<add>```bash
<add>git remote add upstream git://github.com/freeCodeCamp/guide.git
<add>
<add>git fetch upstream
<add>
<add>git pull upstream master
<add>```
<add>
<add>If you're using a GUI, you can simply `Add a new remote...` and use the link `git://github.com/freeCodeCamp/guide.git` from above.
<add>
<add>Once you sync your fork and pass the build, I will be able to review your PR and merge it. 😊
<add>
<add>---
<add>
<add>> Feel free to reference the [Syncing a Fork](https://help.github.com/articles/syncing-a-fork/) article on GitHub for more insight on how to keep your fork up-to-date with the upstream repository. 🔄
<add>>
<add>> Also, it's good practice on GitHub to write a brief description of your changes when creating a PR. 📝
<add>``````
<add>
<add>### Merge Conflicts
<add>
<add>> When PR has merge conflicts that need to be resolved.¹
<add>
<add>```markdown
<add>Hey @username
<add>
<add>So I'd love to be able to merge your changes but it looks like you have some merge conflicts. ⚠️
<add>
<add>Once you resolve these conflicts, I will be able to review your PR and merge it. 😊
<add>
<add>---
<add>
<add>> If you're not familiar with the merge conflict process, feel free to look over GitHub's guide on ["Resolving a merge conflict"](https://help.github.com/articles/resolving-a-merge-conflict-on-github/). 🔍️
<add>>
<add>> Also, it's good practice on GitHub to write a brief description of your changes when creating a PR. 📝
<add>```
<add>¹ If a first-time-contributor has a merge conflict maintainers will resolve the conflict for them.
<add>
<add>### Duplicate
<add>
<add>> When PR is repetitive or a duplicate.
<add>
<add>```markdown
<add>Hey @username
<add>
<add>It seems that similar changes have already been accepted earlier for this article you're editing, sorry about that. 😓
<add>
<add>If you feel you have more to add, please feel free to open up a new PR.
<add>
<add>Thanks again! 😊
<add>
<add>---
<add>
<add>> If you have any questions, feel free to reach out through [Gitter](https://gitter.im/FreeCodeCamp/Contributors) or by commenting below. 💬
<add>```
<add>
<add>### Closing
<add>
<add>> When PR is invalid.
<add>
<add>```markdown
<add>Hey @username
<add>
<add>You haven't actually added any content so I will be closing this PR and marking it as `invalid`. 😓️
<add>
<add>Feel free to open another PR though! 👍
<add>```
<ide>\ No newline at end of file
| 2
|
Python
|
Python
|
fix code style
|
66b2c6149ed0121b1064fe42615aaa8d75aa5d8b
|
<ide><path>tests/test_model_serializer.py
<ide> class Meta:
<ide> assert not serializer.is_valid()
<ide> assert serializer.errors == {'name': ['unique choice model with this name already exists.']}
<ide>
<add>
<ide> class TestFieldSource(TestCase):
<del>
<ide> def test_named_field_source(self):
<ide> class TestSerializer(serializers.ModelSerializer):
<ide>
<ide> class Meta:
<del> model = RegularFieldsModel
<add> model = RegularFieldsModel
<ide> fields = ('number_field',)
<ide> extra_kwargs = {
<ide> 'number_field': {
<ide> class Meta:
<ide> """)
<ide> self.maxDiff = None
<ide> self.assertEqual(unicode_repr(TestSerializer()), expected)
<del>
| 1
|
Javascript
|
Javascript
|
expose missing angular public methods
|
dbf8afcba0cfc0e341e3ebd2dadeba627c083f0a
|
<ide><path>src/AngularPublic.js
<ide> angularService('$browser', function($log){
<ide> extend(angular, {
<ide> // disabled for now until we agree on public name
<ide> //'annotate': annotate,
<del> 'element': jqLite,
<ide> 'compile': compile,
<ide> 'scope': createScope,
<ide> 'copy': copy,
<ide> extend(angular, {
<ide> 'isObject': isObject,
<ide> 'isNumber': isNumber,
<ide> 'isArray': isArray,
<del> 'version': version
<add> 'version': version,
<add> 'isDate': isDate,
<add> 'lowercase': lowercase,
<add> 'uppercase': uppercase
<ide> });
<ide>
<ide> //try to bind to jquery now so that one can write angular.element().read()
| 1
|
PHP
|
PHP
|
make note if route cache file exists
|
2101129d386268813b2ab70abb045a5f5551879f
|
<ide><path>src/Illuminate/Foundation/Console/RouteCacheCommand.php
<ide> public function fire()
<ide> return $this->error("Your application doesn't have any routes.");
<ide> }
<ide>
<add> if ($this->laravel->routesAreCached())
<add> {
<add> return $this->error("Route cache file already exists!");
<add> }
<add>
<ide> foreach ($this->routes as $route)
<ide> {
<ide> $route->prepareForSerialization();
| 1
|
Python
|
Python
|
fix ja morph values
|
a3b7519aba438df736a269e44adeaef1d165d7ee
|
<ide><path>spacy/lang/ja/__init__.py
<ide> import srsly
<ide> from collections import namedtuple
<ide> from thinc.api import Model
<add>import re
<ide>
<ide> from .stop_words import STOP_WORDS
<ide> from .syntax_iterators import SYNTAX_ITERATORS
<ide> def __call__(self, text: str) -> Doc:
<ide> # if there's no lemma info (it's an unk) just use the surface
<ide> token.lemma_ = dtoken.lemma if dtoken.lemma else dtoken.surface
<ide> morph = {}
<del> morph["inflection"] = dtoken.inf
<add> if dtoken.inf:
<add> # it's normal for this to be empty for non-inflecting types
<add> morph["inflection"] = dtoken.inf
<ide> token.norm_ = dtoken.norm
<ide> if dtoken.reading:
<del> morph["reading"] = dtoken.reading
<add> # punctuation is its own reading, but we don't want values like
<add> # "=" here
<add> morph["reading"] = re.sub("[=|]", "_", dtoken.reading)
<ide> token.morph = MorphAnalysis(self.vocab, morph)
<ide> if self.need_subtokens:
<ide> doc.user_data["sub_tokens"] = sub_tokens_list
<ide><path>spacy/tests/lang/ja/test_tokenizer.py
<ide> def test_ja_tokenizer_sub_tokens(
<ide> [
<ide> (
<ide> "取ってつけた",
<del> ("五段-ラ行;連用形-促音便", "", "下一段-カ行;連用形-一般", "助動詞-タ;終止形-一般"),
<del> ("トッ", "テ", "ツケ", "タ"),
<add> (["五段-ラ行;連用形-促音便"], [], ["下一段-カ行;連用形-一般"], ["助動詞-タ;終止形-一般"]),
<add> (["トッ"], ["テ"], ["ツケ"], ["タ"]),
<add> ),
<add> (
<add> "2=3",
<add> ([], [], []),
<add> (["ニ"], ["_"], ["サン"])
<ide> ),
<ide> ],
<ide> )
<ide> def test_ja_tokenizer_inflections_reading_forms(
<ide> ja_tokenizer, text, inflections, reading_forms
<ide> ):
<ide> tokens = ja_tokenizer(text)
<del> test_inflections = [tt.morph.get("inflection")[0] for tt in tokens]
<add> test_inflections = [tt.morph.get("inflection") for tt in tokens]
<ide> assert test_inflections == list(inflections)
<del> test_readings = [tt.morph.get("reading")[0] for tt in tokens]
<add> test_readings = [tt.morph.get("reading") for tt in tokens]
<ide> assert test_readings == list(reading_forms)
<ide>
<ide>
| 2
|
Ruby
|
Ruby
|
fix directory leaks in formula prefix tests
|
f25f6fbb3981b64022b07e453a1583aa6915185a
|
<ide><path>Library/Homebrew/test/test_formula.rb
<ide> def test_installed_prefix_head_installed
<ide> prefix.mkpath
<ide> assert_equal prefix, f.installed_prefix
<ide> ensure
<del> prefix.rmtree
<add> f.rack.rmtree
<ide> end
<ide>
<ide> def test_installed_prefix_devel_installed
<ide> def test_installed_prefix_devel_installed
<ide> prefix.mkpath
<ide> assert_equal prefix, f.installed_prefix
<ide> ensure
<del> prefix.rmtree
<add> f.rack.rmtree
<ide> end
<ide>
<ide> def test_installed_prefix_stable_installed
<ide> def test_installed_prefix_stable_installed
<ide> prefix.mkpath
<ide> assert_equal prefix, f.installed_prefix
<ide> ensure
<del> prefix.rmtree
<add> f.rack.rmtree
<ide> end
<ide>
<ide> def test_installed_prefix_head_active_spec
| 1
|
Text
|
Text
|
add slack, forum links and remove google group
|
1dc96f358ec05eecd1dcd68686665b3ea1b578fc
|
<ide><path>README.md
<ide> tests for CakePHP by doing the following:
<ide>
<ide> ## Get Support!
<ide>
<add>[Slack](http://cakesf.herokuapp.com/) - Join us on Slack.
<add>
<ide> [#cakephp](http://webchat.freenode.net/?channels=#cakephp) on irc.freenode.net - Come chat with us, we have cake.
<ide>
<del>[Google Group](https://groups.google.com/group/cake-php) - Community mailing list and forum.
<add>[Forum](http://discourse.cakephp.org/) - Offical CakePHP forum.
<ide>
<ide> [GitHub Issues](https://github.com/cakephp/cakephp/issues) - Got issues? Please tell us!
<ide>
| 1
|
PHP
|
PHP
|
add methods to support editor links
|
de37d43b8ee99e1d703e5c4a910c4cc57eb20357
|
<ide><path>src/Error/Debugger.php
<ide> use Cake\Utility\Hash;
<ide> use Cake\Utility\Security;
<ide> use Cake\Utility\Text;
<add>use Closure;
<ide> use Exception;
<ide> use InvalidArgumentException;
<ide> use ReflectionObject;
<ide> class Debugger
<ide> protected $_defaultConfig = [
<ide> 'outputMask' => [],
<ide> 'exportFormatter' => null,
<add> 'editor' => 'phpstorm',
<ide> ];
<ide>
<ide> /**
<ide> class Debugger
<ide> ],
<ide> ];
<ide>
<add> /**
<add> * A map of editors to their link templates.
<add> *
<add> * @var array
<add> */
<add> protected $editors = [
<add> 'sublime' => 'subl://open?url=file://{file}&line={line}',
<add> 'phpstorm' => 'phpstorm://open?file={file}&line={line}',
<add> 'macvim' => 'mvim://open/?url=file://{file}&line={line}',
<add> 'emacs' => 'emacs://open?url=file://{file}&line={line}',
<add> 'vscode' => 'vscode://file/{file}:{line}',
<add> ];
<add>
<ide> /**
<ide> * Holds current output data when outputFormat is false.
<ide> *
<ide> public static function setOutputMask(array $value, bool $merge = true): void
<ide> static::configInstance('outputMask', $value, $merge);
<ide> }
<ide>
<add> /**
<add> * Add an editor link format
<add> *
<add> * Template strings can use the `{file}` and `{line}` placeholders.
<add> * Closures templates must return a string, and accept two parameters:
<add> * The file and line.
<add> *
<add> * @param string $name The name of the editor.
<add> * @param string|\Closure $template The string template or closure
<add> * @return void
<add> */
<add> public static function addEditor(string $name, $template): void
<add> {
<add> $instance = static::getInstance();
<add> if (!is_string($template) && !($template instanceof Closure)) {
<add> $type = getTypeName($template);
<add> throw new RuntimeException("Invalid editor type of `{$type}`. Expected string or Closure.");
<add> }
<add> $instance->editors[$name] = $template;
<add> }
<add>
<add> /**
<add> * Choose the editor link style you want to use.
<add> *
<add> * @param string $name The editor name.
<add> * @return void
<add> */
<add> public static function setEditor(string $name): void
<add> {
<add> $instance = static::getInstance();
<add> if (!isset($instance->editors[$name])) {
<add> $known = implode(', ', array_keys($instance->editors));
<add> throw new RuntimeException("Unknown editor `{$name}`. Known editors are {$known}");
<add> }
<add> $instance->setConfig('editor', $name);
<add> }
<add>
<add> /**
<add> * Get a formatted URL for the active editor.
<add> *
<add> * @param string $file The file to create a link for.
<add> * @param int $line The line number to create a link for.
<add> * @return string The formatted URL.
<add> */
<add> public static function editorUrl(string $file, int $line): string
<add> {
<add> $instance = static::getInstance();
<add> $editor = $instance->getConfig('editor');
<add> if (!isset($instance->editors[$editor])) {
<add> throw new RuntimeException("Cannot format editor URL `{$editor}` is not a known editor.");
<add> }
<add>
<add> $template = $instance->editors[$editor];
<add> if (is_string($template)) {
<add> return str_replace(['{file}', '{line}'], [$file, $line], $template);
<add> }
<add> return $template($file, $line);
<add> }
<add>
<ide> /**
<ide> * Recursively formats and outputs the contents of the supplied variable.
<ide> *
<ide><path>tests/TestCase/Error/DebuggerTest.php
<ide> use Cake\Error\Debugger;
<ide> use Cake\Log\Log;
<ide> use Cake\TestSuite\TestCase;
<add>use RuntimeException;
<ide> use stdClass;
<ide> use TestApp\Error\TestDebugger;
<ide> use TestApp\Error\Thing\DebuggableThing;
<ide> public function testFormatHtmlMessage()
<ide> $output
<ide> );
<ide> }
<add>
<add> /**
<add> * test adding invalid editor
<add> *
<add> * @return void
<add> */
<add> public function testAddEditorInvalid()
<add> {
<add> $this->expectException(RuntimeException::class);
<add> Debugger::addEditor('nope', ['invalid']);
<add> }
<add>
<add> /**
<add> * test choosing an unknown editor
<add> *
<add> * @return void
<add> */
<add> public function testSetEditorInvalid()
<add> {
<add> $this->expectException(RuntimeException::class);
<add> Debugger::setEditor('nope');
<add> }
<add>
<add> /**
<add> * test choosing a default editor
<add> *
<add> * @return void
<add> */
<add> public function testSetEditorPredefined()
<add> {
<add> Debugger::setEditor('phpstorm');
<add> Debugger::setEditor('macvim');
<add> Debugger::setEditor('sublime');
<add> Debugger::setEditor('emacs');
<add> // No exceptions raised.
<add> $this->assertTrue(true);
<add> }
<add>
<add> /**
<add> * test using a valid editor.
<add> *
<add> * @return void
<add> */
<add> public function testEditorUrlValid()
<add> {
<add> Debugger::addEditor('open', 'open://{file}:{line}');
<add> Debugger::setEditor('open');
<add> $this->assertSame('open://test.php:123', Debugger::editorUrl('test.php', 123));
<add> }
<add>
<add> /**
<add> * test using a valid editor.
<add> *
<add> * @return void
<add> */
<add> public function testEditorUrlClosure()
<add> {
<add> Debugger::addEditor('open', function (string $file, int $line) {
<add> return "${file}/${line}";
<add> });
<add> Debugger::setEditor('open');
<add> $this->assertSame('test.php/123', Debugger::editorUrl('test.php', 123));
<add> }
<ide> }
| 2
|
Ruby
|
Ruby
|
use slice to avoid range allocation
|
9a4adb4b05dafa9d61ec88acdd089b79585ce10e
|
<ide><path>actionpack/lib/abstract_controller/rendering.rb
<ide> def view_assigns
<ide> variables = instance_variables
<ide> variables -= protected_instance_variables
<ide> variables -= DEFAULT_PROTECTED_INSTANCE_VARIABLES
<del> variables.each { |name| hash[name[1..-1]] = instance_variable_get(name) }
<add> variables.each { |name|
<add> hash[name.slice(1, name.length)] = instance_variable_get(name)
<add> }
<ide> hash
<ide> end
<ide>
| 1
|
PHP
|
PHP
|
fix handling of `html` and `htm` extensions
|
54be88929a2eb328f4bb583955fa7fc93f345fe3
|
<ide><path>src/Controller/Component/RequestHandlerComponent.php
<ide> public function beforeRender(Event $event)
<ide> $response = $controller->getResponse();
<ide> $request = $controller->getRequest();
<ide>
<del> $isRecognized = (
<del> !in_array($this->ext, ['html', 'htm']) &&
<del> $response->getMimeType($this->ext)
<del> );
<del> if ($this->ext && !$isRecognized) {
<del> throw new NotFoundException('Invoked extension not recognized/configured: ' . $this->ext);
<del> }
<add> if ($this->ext && !in_array($this->ext, ['html', 'htm'])) {
<add> if (!$response->getMimeType($this->ext)) {
<add> throw new NotFoundException('Invoked extension not recognized/configured: ' . $this->ext);
<add> }
<ide>
<del> if ($this->ext) {
<ide> $this->renderAs($controller, $this->ext);
<ide> $response = $controller->response;
<ide> } else {
<ide><path>tests/TestCase/Controller/Component/RequestHandlerComponentTest.php
<ide> use Cake\View\JsonView;
<ide> use Cake\View\XmlView;
<ide> use TestApp\Controller\RequestHandlerTestController;
<add>use TestApp\View\AppView;
<ide> use Zend\Diactoros\Stream;
<ide>
<ide> /**
<ide> public function testAutoAjaxLayout()
<ide> $this->assertNotEquals(AjaxView::class, $this->Controller->viewBuilder()->getClassName());
<ide> }
<ide>
<add> /**
<add> * @return array
<add> */
<add> public function defaultExtensionsProvider()
<add> {
<add> return [['html'], ['htm']];
<add> }
<add>
<add> /**
<add> * Tests that the default extensions are using the default view.
<add> *
<add> * @param string $extension Extension to test.
<add> * @dataProvider defaultExtensionsProvider
<add> * @return void
<add> */
<add> public function testDefaultExtensions($extension)
<add> {
<add> Router::extensions([$extension], false);
<add>
<add> $this->Controller->request = $this->Controller->request->withParam('_ext', $extension);
<add> $this->RequestHandler->startup(new Event('Controller.startup', $this->Controller));
<add> $this->RequestHandler->beforeRender(new Event('Controller.beforeRender', $this->Controller));
<add>
<add> $this->assertEquals($extension, $this->RequestHandler->ext);
<add> $this->assertEquals('text/html', $this->Controller->response->getType());
<add>
<add> $view = $this->Controller->createView();
<add> $this->assertInstanceOf(AppView::class, $view);
<add> $this->assertEmpty($view->getLayoutPath());
<add> $this->assertEmpty($view->getSubDir());
<add> }
<add>
<add> /**
<add> * Tests that the default extensions can be overwritten by the accept header.
<add> *
<add> * @param string $extension Extension to test.
<add> * @dataProvider defaultExtensionsProvider
<add> * @return void
<add> */
<add> public function testDefaultExtensionsOverwrittenByAcceptHeader($extension)
<add> {
<add> Router::extensions([$extension], false);
<add>
<add> $this->Controller->request = $this->request->withHeader(
<add> 'Accept',
<add> 'application/xml'
<add> );
<add> $this->Controller->request = $this->Controller->request->withParam('_ext', $extension);
<add> $this->RequestHandler->startup(new Event('Controller.startup', $this->Controller));
<add> $this->RequestHandler->beforeRender(new Event('Controller.beforeRender', $this->Controller));
<add>
<add> $this->assertEquals('xml', $this->RequestHandler->ext);
<add> $this->assertEquals('application/xml', $this->Controller->response->getType());
<add>
<add> $view = $this->Controller->createView();
<add> $this->assertInstanceOf(XmlView::class, $view);
<add> $this->assertEquals('xml', $view->getLayoutPath());
<add> $this->assertEquals('xml', $view->getSubDir());
<add> }
<add>
<ide> /**
<ide> * test custom JsonView class is loaded and correct.
<ide> *
| 2
|
PHP
|
PHP
|
add failing test for
|
76aab0a6356f2f6be3cff496391670b01802afe1
|
<ide><path>lib/Cake/Test/Case/Cache/Engine/FileEngineTest.php
<ide> public function testClearWithPrefixes() {
<ide> $FileTwo->clear(false);
<ide> }
<ide>
<add>/**
<add> * Test that clear() also removes files with group tags.
<add> *
<add> * @return void
<add> */
<add> public function testClearWithGroups() {
<add> $engine = new FileEngine();
<add> $engine->init(array(
<add> 'prefix' => 'cake_test_',
<add> 'duration' => DAY,
<add> 'groups' => array('short')
<add> ));
<add> $engine->write('test_key', 'it works', DAY);
<add> $engine->clear(false);
<add> $this->assertFalse($engine->read('test_key'), 'Key should have been removed');
<add> }
<add>
<ide> /**
<ide> * testKeyPath method
<ide> *
| 1
|
Text
|
Text
|
fix typo in changelog
|
21567e538a408717468ce755bb1b054ecda1fb61
|
<ide><path>CHANGELOG-5.7.md
<ide> - Fix `be` method in `InteractsWithAuthentication` trait ([#25873](https://github.com/laravel/framework/pull/25873))
<ide> - Fixes the error when $resource is null ([#25838](https://github.com/laravel/framework/pull/25838))
<ide> - Attach all disk attachments and not only first one in the `Mail/Mailable.php` ([#25793](https://github.com/laravel/framework/pull/25793))
<del>- Fixed: in case if one job throw exception, than we will proceed to nex one ([#25820](https://github.com/laravel/framework/pull/25820))
<add>- Fixed: in case if one job throw exception, than we will proceed to next one ([#25820](https://github.com/laravel/framework/pull/25820))
<ide>
<ide> ### Changed
<ide> - Trim model class name when passing in `Authorize.php` middleware ([#25849](https://github.com/laravel/framework/pull/25849))
| 1
|
Javascript
|
Javascript
|
fix most lint issues
|
8f3c3e39723dbcf58787f16af4c2b2c5125a650c
|
<ide><path>client/commonFramework.js
<ide> var editor = (function(CodeMirror, emmetCodeMirror, common) {
<ide>
<ide> var tests = tests || [];
<ide>
<del>var libraryIncludes = "<script src='//ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>" +
<del> "<script src='/js/lib/chai/chai.js'></script>" +
<del> "<script src='/js/lib/chai/chai-jquery.js'></script>" +
<del> "<script src='//cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.min.js'></script>" +
<del> "<link rel='stylesheet' href='//cdnjs.cloudflare.com/ajax/libs/animate.css/3.2.0/animate.min.css'/>" +
<del> "<link rel='stylesheet' href='//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css'/>" +
<del> "<link rel='stylesheet' href='//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css'/>" +
<del> '<style>body { padding: 0px 3px 0px 3px; }</style>' +
<del> '<script>var expect = chai.expect; var should = chai.should(); var assert = chai.assert;</script>';
<add>var libraryIncludes =
<add> "<script src='//ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js'>" +
<add> '</script>' +
<add> "<script src='/js/lib/chai/chai.js'></script>" +
<add> "<script src='/js/lib/chai/chai-jquery.js'></script>" +
<add> "<script src='//cdnjs.cloudflare.com/ajax/libs/lodash.js/" +
<add> "2.4.1/lodash.min.js'></script>" +
<add> "<link rel='stylesheet' href='//cdnjs.cloudflare.com/ajax/" +
<add> "libs/animate.css/3.2.0/animate.min.css'/>" +
<add> "<link rel='stylesheet' href='//maxcdn.bootstrapcdn.com/" +
<add> "bootstrap/3.3.1/css/bootstrap.min.css'/>" +
<add> "<link rel='stylesheet' href='//maxcdn.bootstrapcdn.com/" +
<add> "font-awesome/4.2.0/css/font-awesome.min.css'/>" +
<add> '<style>body { padding: 0px 3px 0px 3px; }</style>' +
<add> '<script>var expect = chai.expect; var should = ' +
<add> 'chai.should(); var assert = chai.assert;</script>';
<ide>
<ide> var editorValueForIFrame;
<ide> var iFrameScript = "<script src='/js/iFrameScripts.js'></script>";
<ide> function workerError(error) {
<ide>
<ide> housing.prepend(
<ide> '<div class="runTimeError" style="font-size: 18px;"><code>' +
<del> error.replace(/j\$/gi, '$').replace(/jdocument/gi, 'document').replace(/jjQuery/gi, 'jQuery') +
<add> error
<add> .replace(/j\$/gi, '$')
<add> .replace(/jdocument/gi, 'document')
<add> .replace(/jjQuery/gi, 'jQuery') +
<ide> '</code></div>'
<ide> );
<add>
<ide> display.hide().fadeIn(function() {
<ide> setTimeout(function() {
<ide> display.fadeOut(function() {
<ide> function safeHTMLRun(test) {
<ide> .split(/\<\s?\/\s?script\s?\>/gi)[0];
<ide>
<ide> // add feuxQuery
<del> s = 'var document = \"\"; var $ = function() {return(new function() {this.add=function() {return(this);};this.addBack=function() {return(this);};this.addClass=function() {return(this);};this.after=function() {return(this);};this.ajaxComplete=function() {return(this);};this.ajaxError=function() {return(this);};this.ajaxSend=function() {return(this);};this.ajaxStart=function() {return(this);};this.ajaxStop=function() {return(this);};this.ajaxSuccess=function() {return(this);};this.andSelf=function() {return(this);};this.animate=function() {return(this);};this.append=function() {return(this);};this.appendTo=function() {return(this);};this.attr=function() {return(this);};this.before=function() {return(this);};this.bind=function() {return(this);};this.blur=function() {return(this);};this.callbacksadd=function() {return(this);};this.callbacksdisable=function() {return(this);};this.callbacksdisabled=function() {return(this);};this.callbacksempty=function() {return(this);};this.callbacksfire=function() {return(this);};this.callbacksfired=function() {return(this);};this.callbacksfireWith=function() {return(this);};this.callbackshas=function() {return(this);};this.callbackslock=function() {return(this);};this.callbackslocked=function() {return(this);};this.callbacksremove=function() {return(this);};this.change=function() {return(this);};this.children=function() {return(this);};this.clearQueue=function() {return(this);};this.click=function() {return(this);};this.clone=function() {return(this);};this.closest=function() {return(this);};this.contents=function() {return(this);};this.context=function() {return(this);};this.css=function() {return(this);};this.data=function() {return(this);};this.dblclick=function() {return(this);};this.delay=function() {return(this);};this.delegate=function() {return(this);};this.dequeue=function() {return(this);};this.detach=function() {return(this);};this.die=function() {return(this);};this.each=function() {return(this);};this.empty=function() {return(this);};this.end=function() {return(this);};this.eq=function() {return(this);};this.error=function() {return(this);};this.fadeIn=function() {return(this);};this.fadeOut=function() {return(this);};this.fadeTo=function() {return(this);};this.fadeToggle=function() {return(this);};this.filter=function() {return(this);};this.find=function() {return(this);};this.finish=function() {return(this);};this.first=function() {return(this);};this.focus=function() {return(this);};this.focusin=function() {return(this);};this.focusout=function() {return(this);};this.get=function() {return(this);};this.has=function() {return(this);};this.hasClass=function() {return(this);};this.height=function() {return(this);};this.hide=function() {return(this);};this.hover=function() {return(this);};this.html=function() {return(this);};this.index=function() {return(this);};this.innerHeight=function() {return(this);};this.innerWidth=function() {return(this);};this.insertAfter=function() {return(this);};this.insertBefore=function() {return(this);};this.is=function() {return(this);};this.jQuery=function() {return(this);};this.jquery=function() {return(this);};this.keydown=function() {return(this);};this.keypress=function() {return(this);};this.keyup=function() {return(this);};this.last=function() {return(this);};this.length=function() {return(this);};this.live=function() {return(this);};this.load=function() {return(this);};this.load=function() {return(this);};this.map=function() {return(this);};this.mousedown=function() {return(this);};this.mouseenter=function() {return(this);};this.mouseleave=function() {return(this);};this.mousemove=function() {return(this);};this.mouseout=function() {return(this);};this.mouseover=function() {return(this);};this.mouseup=function() {return(this);};this.next=function() {return(this);};this.nextAll=function() {return(this);};this.nextUntil=function() {return(this);};this.not=function() {return(this);};this.off=function() {return(this);};this.offset=function() {return(this);};this.offsetParent=function() {return(this);};this.on=function() {return(this);};this.one=function() {return(this);};this.outerHeight=function() {return(this);};this.outerWidth=function() {return(this);};this.parent=function() {return(this);};this.parents=function() {return(this);};this.parentsUntil=function() {return(this);};this.position=function() {return(this);};this.prepend=function() {return(this);};this.prependTo=function() {return(this);};this.prev=function() {return(this);};this.prevAll=function() {return(this);};this.prevUntil=function() {return(this);};this.promise=function() {return(this);};this.prop=function() {return(this);};this.pushStack=function() {return(this);};this.queue=function() {return(this);};this.ready=function() {return(this);};this.remove=function() {return(this);};this.removeAttr=function() {return(this);};this.removeClass=function() {return(this);};this.removeData=function() {return(this);};this.removeProp=function() {return(this);};this.replaceAll=function() {return(this);};this.replaceWith=function() {return(this);};this.resize=function() {return(this);};this.scroll=function() {return(this);};this.scrollLeft=function() {return(this);};this.scrollTop=function() {return(this);};this.select=function() {return(this);};this.selector=function() {return(this);};this.serialize=function() {return(this);};this.serializeArray=function() {return(this);};this.show=function() {return(this);};this.siblings=function() {return(this);};this.size=function() {return(this);};this.slice=function() {return(this);};this.slideDown=function() {return(this);};this.slideToggle=function() {return(this);};this.slideUp=function() {return(this);};this.stop=function() {return(this);};this.submit=function() {return(this);};this.text=function() {return(this);};this.toArray=function() {return(this);};this.toggle=function() {return(this);};this.toggle=function() {return(this);};this.toggleClass=function() {return(this);};this.trigger=function() {return(this);};this.triggerHandler=function() {return(this);};this.unbind=function() {return(this);};this.undelegate=function() {return(this);};this.unload=function() {return(this);};this.unwrap=function() {return(this);};this.val=function() {return(this);};this.width=function() {return(this);};this.wrap=function() {return(this);};this.wrapAll=function() {return(this);};this.wrapInner=function() {return(this);}});};$.ajax=function() {return($);};$.ajaxPrefilter=function() {return($);};$.ajaxSetup=function() {return($);};$.ajaxTransport=function() {return($);};$.boxModel=function() {return($);};$.browser=function() {return($);};$.Callbacks=function() {return($);};$.contains=function() {return($);};$.cssHooks=function() {return($);};$.cssNumber=function() {return($);};$.data=function() {return($);};$.Deferred=function() {return($);};$.dequeue=function() {return($);};$.each=function() {return($);};$.error=function() {return($);};$.extend=function() {return($);};$.fnextend=function() {return($);};$.fxinterval=function() {return($);};$.fxoff=function() {return($);};$.get=function() {return($);};$.getJSON=function() {return($);};$.getScript=function() {return($);};$.globalEval=function() {return($);};$.grep=function() {return($);};$.hasData=function() {return($);};$.holdReady=function() {return($);};$.inArray=function() {return($);};$.isArray=function() {return($);};$.isEmptyObject=function() {return($);};$.isFunction=function() {return($);};$.isNumeric=function() {return($);};$.isPlainObject=function() {return($);};$.isWindow=function() {return($);};$.isXMLDoc=function() {return($);};$.makeArray=function() {return($);};$.map=function() {return($);};$.merge=function() {return($);};$.noConflict=function() {return($);};$.noop=function() {return($);};$.now=function() {return($);};$.param=function() {return($);};$.parseHTML=function() {return($);};$.parseJSON=function() {return($);};$.parseXML=function() {return($);};$.post=function() {return($);};$.proxy=function() {return($);};$.queue=function() {return($);};$.removeData=function() {return($);};$.sub=function() {return($);};$.support=function() {return($);};$.trim=function() {return($);};$.type=function() {return($);};$.unique=function() {return($);};$.when=function() {return($);};$.always=function() {return($);};$.done=function() {return($);};$.fail=function() {return($);};$.isRejected=function() {return($);};$.isResolved=function() {return($);};$.notify=function() {return($);};$.notifyWith=function() {return($);};$.pipe=function() {return($);};$.progress=function() {return($);};$.promise=function() {return($);};$.reject=function() {return($);};$.rejectWith=function() {return($);};$.resolve=function() {return($);};$.resolveWith=function() {return($);};$.state=function() {return($);};$.then=function() {return($);};$.currentTarget=function() {return($);};$.data=function() {return($);};$.delegateTarget=function() {return($);};$.isDefaultPrevented=function() {return($);};$.isImmediatePropagationStopped=function() {return($);};$.isPropagationStopped=function() {return($);};$.metaKey=function() {return($);};$.namespace=function() {return($);};$.pageX=function() {return($);};$.pageY=function() {return($);};$.preventDefault=function() {return($);};$.relatedTarget=function() {return($);};$.result=function() {return($);};$.stopImmediatePropagation=function() {return($);};$.stopPropagation=function() {return($);};$.target=function() {return($);};$.timeStamp=function() {return($);};$.type=function() {return($);};$.which=function() {return($);};' + s;
<add> s = 'var document = ""; ' +
<add> 'var $ = function() {' +
<add> 'return new function() { this.add=function() { return this; };' +
<add> 'this.addBack=function() {return this; };' +
<add> 'this.addClass=function() {return this; };' +
<add> 'this.after=function() {return this; };' +
<add> 'this.ajaxComplete=function() {return this; };' +
<add> 'this.ajaxError=function() {return this; };' +
<add> 'this.ajaxSend=function() {return this; };' +
<add> 'this.ajaxStart=function() {return this; };' +
<add> 'this.ajaxStop=function() {return this; };' +
<add> 'this.ajaxSuccess=function() {return this; };' +
<add> 'this.andSelf=function() {return this; };' +
<add> 'this.animate=function() {return this; };' +
<add> 'this.append=function() {return this; };' +
<add> 'this.appendTo=function() {return this; };' +
<add> 'this.attr=function() {return this; };' +
<add> 'this.before=function() {return this; };' +
<add> 'this.bind=function() {return this; };' +
<add> 'this.blur=function() {return this; };' +
<add> 'this.callbacksadd=function() {return this; };' +
<add> 'this.callbacksdisable=function() {return this; };' +
<add> 'this.callbacksdisabled=function() {return this; };' +
<add> 'this.callbacksempty=function() {return this; };' +
<add> 'this.callbacksfire=function() {return this; };' +
<add> 'this.callbacksfired=function() {return this; };' +
<add> 'this.callbacksfireWith=function() {return this; };' +
<add> 'this.callbackshas=function() {return this; };' +
<add> 'this.callbackslock=function() {return this; };' +
<add> 'this.callbackslocked=function() {return this; };' +
<add> 'this.callbacksremove=function() {return this; };' +
<add> 'this.change=function() {return this; };' +
<add> 'this.children=function() {return this; };' +
<add> 'this.clearQueue=function() {return this; };' +
<add> 'this.click=function() {return this; };' +
<add> 'this.clone=function() {return this; };' +
<add> 'this.closest=function() {return this; };' +
<add> 'this.contents=function() {return this; };' +
<add> 'this.context=function() {return this; };' +
<add> 'this.css=function() {return this; };' +
<add> 'this.data=function() {return this; };' +
<add> 'this.dblclick=function() {return this; };' +
<add> 'this.delay=function() {return this; };' +
<add> 'this.delegate=function() {return this; };' +
<add> 'this.dequeue=function() {return this; };' +
<add> 'this.detach=function() {return this; };' +
<add> 'this.die=function() {return this; };' +
<add> 'this.each=function() {return this; };' +
<add> 'this.empty=function() {return this; };' +
<add> 'this.end=function() {return this; };' +
<add> 'this.eq=function() {return this; };' +
<add> 'this.error=function() {return this; };' +
<add> 'this.fadeIn=function() {return this; };' +
<add> 'this.fadeOut=function() {return this; };' +
<add> 'this.fadeTo=function() {return this; };' +
<add> 'this.fadeToggle=function() {return this; };' +
<add> 'this.filter=function() {return this; };' +
<add> 'this.find=function() {return this; };' +
<add> 'this.finish=function() {return this; };' +
<add> 'this.first=function() {return this; };' +
<add> 'this.focus=function() {return this; };' +
<add> 'this.focusin=function() {return this; };' +
<add> 'this.focusout=function() {return this; };' +
<add> 'this.get=function() {return this; };' +
<add> 'this.has=function() {return this; };' +
<add> 'this.hasClass=function() {return this; };' +
<add> 'this.height=function() {return this; };' +
<add> 'this.hide=function() {return this; };' +
<add> 'this.hover=function() {return this; };' +
<add> 'this.html=function() {return this; };' +
<add> 'this.index=function() {return this; };' +
<add> 'this.innerHeight=function() {return this; };' +
<add> 'this.innerWidth=function() {return this; };' +
<add> 'this.insertAfter=function() {return this; };' +
<add> 'this.insertBefore=function() {return this; };' +
<add> 'this.is=function() {return this; };' +
<add> 'this.jQuery=function() {return this; };' +
<add> 'this.jquery=function() {return this; };' +
<add> 'this.keydown=function() {return this; };' +
<add> 'this.keypress=function() {return this; };' +
<add> 'this.keyup=function() {return this; };' +
<add> 'this.last=function() {return this; };' +
<add> 'this.length=function() {return this; };' +
<add> 'this.live=function() {return this; };' +
<add> 'this.load=function() {return this; };' +
<add> 'this.load=function() {return this; };' +
<add> 'this.map=function() {return this; };' +
<add> 'this.mousedown=function() {return this; };' +
<add> 'this.mouseenter=function() {return this; };' +
<add> 'this.mouseleave=function() {return this; };' +
<add> 'this.mousemove=function() {return this; };' +
<add> 'this.mouseout=function() {return this; };' +
<add> 'this.mouseover=function() {return this; };' +
<add> 'this.mouseup=function() {return this; };' +
<add> 'this.next=function() {return this; };' +
<add> 'this.nextAll=function() {return this; };' +
<add> 'this.nextUntil=function() {return this; };' +
<add> 'this.not=function() {return this; };' +
<add> 'this.off=function() {return this; };' +
<add> 'this.offset=function() {return this; };' +
<add> 'this.offsetParent=function() {return this; };' +
<add> 'this.on=function() {return this; };' +
<add> 'this.one=function() {return this; };' +
<add> 'this.outerHeight=function() {return this; };' +
<add> 'this.outerWidth=function() {return this; };' +
<add> 'this.parent=function() {return this; };' +
<add> 'this.parents=function() {return this; };' +
<add> 'this.parentsUntil=function() {return this; };' +
<add> 'this.position=function() {return this; };' +
<add> 'this.prepend=function() {return this; };' +
<add> 'this.prependTo=function() {return this; };' +
<add> 'this.prev=function() {return this; };' +
<add> 'this.prevAll=function() {return this; };' +
<add> 'this.prevUntil=function() {return this; };' +
<add> 'this.promise=function() {return this; };' +
<add> 'this.prop=function() {return this; };' +
<add> 'this.pushStack=function() {return this; };' +
<add> 'this.queue=function() {return this; };' +
<add> 'this.ready=function() {return this; };' +
<add> 'this.remove=function() {return this; };' +
<add> 'this.removeAttr=function() {return this; };' +
<add> 'this.removeClass=function() {return this; };' +
<add> 'this.removeData=function() {return this; };' +
<add> 'this.removeProp=function() {return this; };' +
<add> 'this.replaceAll=function() {return this; };' +
<add> 'this.replaceWith=function() {return this; };' +
<add> 'this.resize=function() {return this; };' +
<add> 'this.scroll=function() {return this; };' +
<add> 'this.scrollLeft=function() {return this; };' +
<add> 'this.scrollTop=function() {return this; };' +
<add> 'this.select=function() {return this; };' +
<add> 'this.selector=function() {return this; };' +
<add> 'this.serialize=function() {return this; };' +
<add> 'this.serializeArray=function() {return this; };' +
<add> 'this.show=function() {return this; };' +
<add> 'this.siblings=function() {return this; };' +
<add> 'this.size=function() {return this; };' +
<add> 'this.slice=function() {return this; };' +
<add> 'this.slideDown=function() {return this; };' +
<add> 'this.slideToggle=function() {return this; };' +
<add> 'this.slideUp=function() {return this; };' +
<add> 'this.stop=function() {return this; };' +
<add> 'this.submit=function() {return this; };' +
<add> 'this.text=function() {return this; };' +
<add> 'this.toArray=function() {return this; };' +
<add> 'this.toggle=function() {return this; };' +
<add> 'this.toggle=function() {return this; };' +
<add> 'this.toggleClass=function() {return this; };' +
<add> 'this.trigger=function() {return this; };' +
<add> 'this.triggerHandler=function() {return this; };' +
<add> 'this.unbind=function() {return this; };' +
<add> 'this.undelegate=function() {return this; };' +
<add> 'this.unload=function() {return this; };' +
<add> 'this.unwrap=function() {return this; };' +
<add> 'this.val=function() {return this; };' +
<add> 'this.width=function() {return this; };' +
<add> 'this.wrap=function() {return this; };' +
<add> 'this.wrapAll=function() {return this; };' +
<add> 'this.wrapInner=function() {return this; };};};' +
<add> '$.ajax=function() {return $;};' +
<add> '$.ajaxPrefilter=function() {return $; };' +
<add> '$.ajaxSetup=function() {return $; };' +
<add> '$.ajaxTransport=function() {return $; };' +
<add> '$.boxModel=function() {return $; };' +
<add> '$.browser=function() {return $; };' +
<add> '$.Callbacks=function() {return $; };' +
<add> '$.contains=function() {return $; };' +
<add> '$.cssHooks=function() {return $; };' +
<add> '$.cssNumber=function() {return $; };' +
<add> '$.data=function() {return $; };' +
<add> '$.Deferred=function() {return $; };' +
<add> '$.dequeue=function() {return $; };' +
<add> '$.each=function() {return $; };' +
<add> '$.error=function() {return $; };' +
<add> '$.extend=function() {return $; };' +
<add> '$.fnextend=function() {return $; };' +
<add> '$.fxinterval=function() {return $; };' +
<add> '$.fxoff=function() {return $; };' +
<add> '$.get=function() {return $; };' +
<add> '$.getJSON=function() {return $; };' +
<add> '$.getScript=function() {return $; };' +
<add> '$.globalEval=function() {return $; };' +
<add> '$.grep=function() {return $; };' +
<add> '$.hasData=function() {return $; };' +
<add> '$.holdReady=function() {return $; };' +
<add> '$.inArray=function() {return $; };' +
<add> '$.isArray=function() {return $; };' +
<add> '$.isEmptyObject=function() {return $; };' +
<add> '$.isFunction=function() {return $; };' +
<add> '$.isNumeric=function() {return $; };' +
<add> '$.isPlainObject=function() {return $; };' +
<add> '$.isWindow=function() {return $; };' +
<add> '$.isXMLDoc=function() {return $; };' +
<add> '$.makeArray=function() {return $; };' +
<add> '$.map=function() {return $; };' +
<add> '$.merge=function() {return $; };' +
<add> '$.noConflict=function() {return $; };' +
<add> '$.noop=function() {return $; };' +
<add> '$.now=function() {return $; };' +
<add> '$.param=function() {return $; };' +
<add> '$.parseHTML=function() {return $; };' +
<add> '$.parseJSON=function() {return $; };' +
<add> '$.parseXML=function() {return $; };' +
<add> '$.post=function() {return $; };' +
<add> '$.proxy=function() {return $; };' +
<add> '$.queue=function() {return $; };' +
<add> '$.removeData=function() {return $; };' +
<add> '$.sub=function() {return $; };' +
<add> '$.support=function() {return $; };' +
<add> '$.trim=function() {return $; };' +
<add> '$.type=function() {return $; };' +
<add> '$.unique=function() {return $; };' +
<add> '$.when=function() {return $; };' +
<add> '$.always=function() {return $; };' +
<add> '$.done=function() {return $; };' +
<add> '$.fail=function() {return $; };' +
<add> '$.isRejected=function() {return $; };' +
<add> '$.isResolved=function() {return $; };' +
<add> '$.notify=function() {return $; };' +
<add> '$.notifyWith=function() {return $; };' +
<add> '$.pipe=function() {return $; };' +
<add> '$.progress=function() {return $; };' +
<add> '$.promise=function() {return $; };' +
<add> '$.reject=function() {return $; };' +
<add> '$.rejectWith=function() {return $; };' +
<add> '$.resolve=function() {return $; };' +
<add> '$.resolveWith=function() {return $; };' +
<add> '$.state=function() {return $; };' +
<add> '$.then=function() {return $; };' +
<add> '$.currentTarget=function() {return $; };' +
<add> '$.data=function() {return $; };' +
<add> '$.delegateTarget=function() {return $; };' +
<add> '$.isDefaultPrevented=function() {return $; };' +
<add> '$.isImmediatePropagationStopped=function() {return $; };' +
<add> '$.isPropagationStopped=function() {return $; };' +
<add> '$.metaKey=function() {return $; };' +
<add> '$.namespace=function() {return $; };' +
<add> '$.pageX=function() {return $; };' +
<add> '$.pageY=function() {return $; };' +
<add> '$.preventDefault=function() {return $; };' +
<add> '$.relatedTarget=function() {return $; };' +
<add> '$.result=function() {return $; };' +
<add> '$.stopImmediatePropagation=function() {return $; };' +
<add> '$.stopPropagation=function() {return $; };' +
<add> '$.target=function() {return $; };' +
<add> '$.timeStamp=function() {return $; };' +
<add> '$.type=function() {return $; };' +
<add> '$.which=function() {return $; };' +
<add> '' + s;
<ide>
<ide> // add spoofigator
<ide>
<del> s = " var navigator = " +
<del> "function(){" +
<del> " this.geolocation=function(){" +
<del> " this.getCurrentPosition=function(){" +
<del> " this.coords = {latitude: \"\", longitude: \"\"};" +
<del> " return(this);" +
<del> " };" +
<del> " return(this);" +
<del> " };" +
<del> " return(this);" +
<del> "};" + s;
<add> s = ' var navigator = ' +
<add> 'function() {' +
<add> ' this.geolocation=function() {' +
<add> ' this.getCurrentPosition=function() {' +
<add> ' this.coords = {latitude: "", longitude: ""};' +
<add> ' return this;' +
<add> ' };' +
<add> ' return this;' +
<add> ' };' +
<add> ' return this;' +
<add> '};' + s;
<ide>
<ide> sandBox.submit(scopejQuery(s), function(cls, message) {
<ide> if (cls) {
<ide> function safeHTMLRun(test) {
<ide> function updatePreview() {
<ide> editorValueForIFrame = editor.getValue();
<ide> var failedCommentTest = false;
<add> var openingComments = editorValueForIFrame.match(/\<\!\-\-/gi);
<add> var closingComments = editorValueForIFrame.match(/\-\-\>/gi);
<ide> if (
<del> editorValueForIFrame.match(/\<\!\-\-/gi) &&
<del> editorValueForIFrame.match(/\-\-\>/gi) == null
<del> ) {
<del> failedCommentTest = true;
<del> } else if (
<del> editorValueForIFrame.match(/\<\!\-\-/gi) &&
<del> editorValueForIFrame.match(/\<\!\-\-/gi).length > editorValueForIFrame.match(/\-\-\>/gi).length
<add> openingComments &&
<add> (
<add> !closingComments ||
<add> openingComments.length > closingComments.length
<add> )
<ide> ) {
<ide> failedCommentTest = true;
<ide> }
<ide> var postSuccess = function(data) {
<ide>
<ide> var testDoc = document.createElement('div');
<ide> $(testDoc).html(
<del> "<div class='row'><div class='col-xs-2 text-center'><i class='ion-checkmark-circled big-success-icon'></i></div><div class='col-xs-10 test-output test-vertical-center wrappable'>" +
<add> "<div class='row'><div class='col-xs-2 text-center'>" +
<add> "<i class='ion-checkmark-circled big-success-icon'></i></div>" +
<add> "<div class='col-xs-10 test-output test-vertical-center wrappable'>" +
<ide> JSON.parse(data) +
<ide> '</div>'
<ide> );
<ide> var postSuccess = function(data) {
<ide> testSuccess();
<ide> };
<ide>
<add>/* eslint-disable no-unused-vars */
<ide> var postError = function(data) {
<add>/* eslint-enable no-unused-vars */
<ide> var testDoc = document.createElement('div');
<ide>
<ide> $(testDoc).html(
<del> "<div class='row'><div class='col-xs-2 text-center'><i class='ion-close-circled big-error-icon'></i></div><div class='col-xs-10 test-vertical-center test-output wrappable'>" +
<add> "<div class='row'><div class='col-xs-2 text-center'>" +
<add> "<i class='ion-close-circled big-error-icon'></i></div>" +
<add> "<div class='col-xs-10 test-vertical-center test-output wrappable'>" +
<ide> JSON.parse(data) +
<ide> '</div>'
<ide> );
<ide> function bonfireExecute(shouldTest) {
<ide> var userJavaScript = editor.getValue();
<ide> var failedCommentTest = false;
<ide>
<add> var openingComments = userJavaScript.match(/\/\*/gi);
<ide> // checks if the number of opening comments(/*) matches the number of
<ide> // closing comments(*/)
<ide> if (
<del> userJavaScript.match(/\/\*/gi) &&
<del> userJavaScript.match(/\/\*/gi).length > userJavaScript.match(/\*\//gi).length
<add> openingComments &&
<add> openingComments.length > userJavaScript.match(/\*\//gi).length
<ide> ) {
<ide> failedCommentTest = true;
<ide> }
<ide><path>client/iFrameScripts.js
<add>/* eslint-disable no-undef, no-unused-vars, no-native-reassign */
<ide> (function() {
<ide> var expect = chai.expect;
<ide> var tests = parent.tests;
<ide> for (var i = 0; i < tests.length; i++) {
<ide> var thisTest = true;
<ide> try {
<add> /* eslint-disable no-eval */
<ide> eval(parent.tests[i]);
<add> /* eslint-enable no-eval */
<ide> } catch (err) {
<ide> allTestsGood = false;
<ide> thisTest = false;
<ide><path>client/plugin.js
<ide> function run(code) {
<ide> var codeExec = runHidden(code);
<ide> result.type = typeof codeExec;
<ide> result.output = stringify(codeExec);
<del> } catch(e) {
<add> } catch (e) {
<ide> result.error = e.message;
<ide> }
<ide>
| 3
|
Text
|
Text
|
remove active record reference
|
9624081cbab605b9f41224b8f2503b074d59a40a
|
<ide><path>README.md
<ide> [](https://packagist.org/packages/cakephp/cakephp)
<ide>
<ide> [CakePHP](http://www.cakephp.org) is a rapid development framework for PHP which
<del>uses commonly known design patterns like Active Record, Association Data
<del>Mapping, Front Controller and MVC. Our primary goal is to provide a structured
<add>uses commonly known design patterns like Associative Data
<add>Mapping, Front Controller, and MVC. Our primary goal is to provide a structured
<ide> framework that enables PHP users at all levels to rapidly develop robust web
<ide> applications, without any loss to flexibility.
<ide>
| 1
|
Javascript
|
Javascript
|
checkpoint new test framework using vows
|
0e9589d1f246b85d85746810fdbe0ea34203bb43
|
<ide><path>test/core/select-test.js
<add>require("../env");
<add>require("../../d3");
<add>
<add>var vows = require("vows"),
<add> assert = require("assert");
<add>
<add>var suite = vows.describe("d3.select");
<add>
<add>suite.addBatch({
<add> "style": {
<add> topic: function() {
<add> return d3.select("body");
<add> },
<add> "can set a property as a string": function(body) {
<add> body.style("background-color", "red");
<add> assert.equal(body[0][0].style["background-color"], "red");
<add> },
<add> "can set a property as a number": function(body) {
<add> body.style("opacity", .3);
<add> assert.equal(body[0][0].style["opacity"], ".3");
<add> },
<add> "can set a property as a function": function(body) {
<add> body.style("background-color", function() { return "orange"; });
<add> assert.equal(body[0][0].style["background-color"], "orange");
<add> },
<add> "can get a property value": function(body) {
<add> body[0][0].style.setProperty("background-color", "yellow", "");
<add> assert.equal(body.style("background-color"), "yellow");
<add> },
<add> "observes the specified priority": function(body) {
<add> body.style("background-color", "green", "important");
<add> assert.equal(body[0][0].style.getPropertyPriority("background-color"), "important");
<add> }
<add> },
<add> "attr": {
<add> topic: function() {
<add> return d3.select("body");
<add> },
<add> "can set an attribute as a string": function(body) {
<add> body.attr("bgcolor", "red");
<add> assert.equal(body[0][0].getAttribute("bgcolor"), "red");
<add> },
<add> "can set an attribute as a number": function(body) {
<add> body.attr("opacity", 1);
<add> assert.equal(body[0][0].getAttribute("opacity"), "1");
<add> },
<add> "can set an attribute as a function": function(body) {
<add> body.attr("bgcolor", function() { return "orange"; });
<add> assert.equal(body[0][0].getAttribute("bgcolor"), "orange");
<add> },
<add> "can get an attribute value": function(body) {
<add> body[0][0].setAttribute("bgcolor", "yellow");
<add> assert.equal(body.attr("bgcolor"), "yellow");
<add> }
<add> }
<add>});
<add>
<add>suite.export(module);
<ide><path>test/core/selectAll-test.js
<add>require("../env");
<add>require("../../d3");
<add>
<add>var vows = require("vows"),
<add> assert = require("assert");
<add>
<add>var suite = vows.describe("d3.selectAll");
<add>
<add>suite.addBatch({
<add> "style": {
<add> topic: function() {
<add> return d3.select("body").selectAll("div").data(d3.range(2)).enter().append("div");
<add> },
<add> "can set a property as a string": function(div) {
<add> div.style("background-color", "red");
<add> assert.equal(div[0][0].style["background-color"], "red");
<add> assert.equal(div[0][1].style["background-color"], "red");
<add> },
<add> "can set a property as a number": function(div) {
<add> div.style("opacity", .5);
<add> assert.equal(div[0][0].style["opacity"], ".5");
<add> assert.equal(div[0][1].style["opacity"], ".5");
<add> },
<add> "can set a property as a function": function(div) {
<add> div.style("background-color", d3.interpolateRgb("orange", "yellow"));
<add> assert.equal(div[0][0].style["background-color"], "rgb(255,165,0)");
<add> assert.equal(div[0][1].style["background-color"], "rgb(255,255,0)");
<add> },
<add> "can get a property value": function(div) {
<add> div[0][0].style.setProperty("background-color", "green", "");
<add> assert.equal(div.style("background-color"), "green");
<add> },
<add> "observes the specified priority": function(div) {
<add> div.style("background-color", "blue", "important");
<add> assert.equal(div[0][0].style.getPropertyPriority("background-color"), "important");
<add> assert.equal(div[0][1].style.getPropertyPriority("background-color"), "important");
<add> }
<add> }
<add>});
<add>
<add>suite.addBatch({
<add> "attr": {
<add> topic: function() {
<add> return d3.select("body").selectAll("div");
<add> },
<add> "can set an attribute as a string": function(div) {
<add> div.attr("bgcolor", "red");
<add> assert.equal(div[0][0].getAttribute("bgcolor"), "red");
<add> assert.equal(div[0][1].getAttribute("bgcolor"), "red");
<add> },
<add> "can set an attribute as a number": function(div) {
<add> div.attr("opacity", 0.4);
<add> assert.equal(div[0][0].getAttribute("opacity"), "0.4");
<add> assert.equal(div[0][1].getAttribute("opacity"), "0.4");
<add> },
<add> "can set an attribute as a function": function(div) {
<add> div.attr("bgcolor", d3.interpolateRgb("brown", "steelblue"));
<add> assert.equal(div[0][0].getAttribute("bgcolor"), "rgb(165,42,42)");
<add> assert.equal(div[0][1].getAttribute("bgcolor"), "rgb(70,130,180)");
<add> },
<add> "can get an attribute value": function(div) {
<add> div[0][0].setAttribute("bgcolor", "purple");
<add> assert.equal(div.attr("bgcolor"), "purple");
<add> }
<add> }
<add>});
<add>
<add>suite.export(module);
<ide><path>test/env.js
<add>document = require("jsdom").jsdom("<html><head></head><body></body></html>", null, {features: {QuerySelector: true}});
<add>window = document.createWindow();
<add>navigator = window.navigator;
<add>
<add>process.env.TZ = "America/Los_Angeles";
<ide><path>test/scale/linear-test.js
<add>require("../env");
<add>require("../../d3");
<add>
<add>var vows = require("vows"),
<add> assert = require("assert");
<add>
<add>vows.describe("d3.scale.linear").addBatch({
<add> "default instance": {
<add> topic: d3.scale.linear,
<add> "has the domain [0, 1]": function(x) {
<add> assert.deepEqual(x.domain(), [0, 1]);
<add> },
<add> "has the range [0, 1]": function(x) {
<add> assert.deepEqual(x.range(), [0, 1]);
<add> }
<add> }
<add>}).export(module);
| 4
|
Javascript
|
Javascript
|
clear the translusion point before transcluding
|
eed299a31b5a6dd0363133c5f9271bf33d090c94
|
<ide><path>src/ng/directive/ngTransclude.js
<ide> * @name ng.directive:ngTransclude
<ide> *
<ide> * @description
<del> * Insert the transcluded DOM here.
<add> * Directive that marks the insertion point for the transcluded DOM of the nearest parent directive that uses transclusion.
<add> *
<add> * Any existing content of the element that this directive is placed on will be removed before the transcluded content is inserted.
<ide> *
<ide> * @element ANY
<ide> *
<ide> var ngTranscludeDirective = ngDirective({
<ide>
<ide> link: function($scope, $element, $attrs, controller) {
<ide> controller.$transclude(function(clone) {
<add> $element.html('');
<ide> $element.append(clone);
<ide> });
<ide> }
<ide><path>test/ng/compileSpec.js
<ide> describe('$compile', function() {
<ide> element = $compile('<div parent-directive><div child-directive></div>childContentText;</div>')($rootScope);
<ide> $rootScope.$apply();
<ide> expect(log).toEqual('parentController; childController');
<del> expect(element.text()).toBe('parentTemplateText;childTemplateText;childContentText;')
<add> expect(element.text()).toBe('childTemplateText;childContentText;')
<ide> });
<ide> });
<ide>
<ide> describe('$compile', function() {
<ide> '</div>')($rootScope);
<ide> $rootScope.$apply();
<ide> expect(log).toEqual('parentController; childController; babyController');
<del> expect(element.text()).toBe('parentTemplateText;childTemplateText;childContentText;babyTemplateText;')
<add> expect(element.text()).toBe('childContentText;babyTemplateText;')
<ide> });
<ide> });
<ide>
<ide> describe('$compile', function() {
<ide> });
<ide>
<ide>
<add> it('should clear contents of the ng-translude element before appending transcluded content',
<add> function() {
<add> module(function() {
<add> directive('trans', function() {
<add> return {
<add> transclude: true,
<add> template: '<div ng-transclude>old stuff! </div>'
<add> };
<add> });
<add> });
<add> inject(function(log, $rootScope, $compile) {
<add> element = $compile('<div trans>unicorn!</div>')($rootScope);
<add> $rootScope.$apply();
<add> expect(sortedHtml(element.html())).toEqual('<div ng-transclude=""><span>unicorn!</span></div>');
<add> });
<add> });
<add>
<add>
<ide> it('should make the result of a transclusion available to the parent directive in post-linking phase (template)',
<ide> function() {
<ide> module(function() {
| 2
|
Ruby
|
Ruby
|
add documentation for system tests
|
b44320254167152383b1fa8792cb17847a51fb49
|
<ide><path>actionpack/lib/system_test_case.rb
<ide> require 'system_testing/driver_adapter'
<ide>
<ide> module Rails
<add> # System tests are similar to Integration tests in that they incorporate multiple
<add> # controllers and actions, but can be used to similate a real user experience.
<add> # System tests are also known as Acceptance tests.
<add> #
<add> # To create a System Test in your application extend your test class from
<add> # <tt>Rails::SystemTestCase</tt>. System tests use Capybara as a base and
<add> # allows you to configure the driver. The default driver is RackTest.
<add> #
<add> # require 'test_helper'
<add> #
<add> # class Users::CreateTest < Rails::SystemTestCase
<add> # def adding_a_new_user
<add> # visit users_path
<add> # click_on 'New User'
<add> #
<add> # fill_in 'Name', with: 'Arya'
<add> # click_on 'Create User'
<add> #
<add> # assert_text 'Arya'
<add> # end
<add> # end
<add> #
<add> # System tests in your application can be configured to use different drivers.
<add> #
<add> # To specify a driver, add the following to your Rails' configuration file for
<add> # the test environment.
<add> #
<add> # config.system_testing.driver = :capybara_selenium_driver
<add> #
<add> # You can also specify a driver with a new driver object. Through this method
<add> # you can also change the default settings for the driver you're setting.
<add> #
<add> # config.system_testing.driver = SystemTesting::DriverAdapters::CapybaraRackTestDriver.new(
<add> # useragent: 'My Useragent'
<add> # )
<add> #
<add> # A list of supported adapters can be found in DriverAdapters.
<add> #
<add> # If you want to use a driver that is not supported by Rails but is available
<add> # in Capybara, you can override Rails settings and use Capybara directly by
<add> # setting the +Capybara.default_driver+ and +Capybara.javascript_driver+ in
<add> # your test_help file.
<add> #
<add> # You can also skip using Rails system tests completely by not inheriting from
<add> # <tt>Rails::SystemTestCase</tt> and following Capybara's instructions.
<ide> class SystemTestCase < ActionDispatch::IntegrationTest
<ide> include SystemTesting::TestHelper
<ide> include SystemTesting::DriverAdapter
<ide><path>actionpack/lib/system_testing/driver_adapter.rb
<ide> require 'system_testing/driver_adapters'
<ide>
<ide> module SystemTesting
<add> # The <tt>SystemTesting::DriverAdapter</tt> module is used to load the driver
<add> # set in your Rails' test configuration file.
<add> #
<add> # The default driver adapters is the +:capybara_rack_test_driver+.
<ide> module DriverAdapter
<ide> extend ActiveSupport::Concern
<ide>
<ide> module ClassMethods
<del> def default_driver
<add> def default_driver # :nodoc
<ide> :capybara_rack_test_driver
<ide> end
<ide>
<add> # Returns the current driver that is set. If no driver is set in the
<add> # Rails' configuration file then +:capybara_rack_test_driver+ will be
<add> # initialized.
<ide> def driver
<ide> @driver ||= DriverAdapters.lookup(default_driver).new
<ide> end
<ide>
<add> # Specify the adapter and settings for the system test driver set in the
<add> # Rails' configuration file.
<ide> def driver=(adapter)
<ide> @driver = case adapter
<ide> when Symbol
<ide><path>actionpack/lib/system_testing/driver_adapters.rb
<ide> module SystemTesting
<add> # == System Testing Driver Adapters
<add> #
<add> # System testing supports the following drivers:
<add> #
<add> # * {RackTest}[https://github.com/brynary/rack-test]
<add> # * {Selenium}[https://github.com/SeleniumHQ/selenium]
<ide> module DriverAdapters
<ide> extend ActiveSupport::Autoload
<ide>
<ide> autoload :CapybaraRackTestDriver
<ide> autoload :CapybaraSeleniumDriver
<ide>
<ide> class << self
<add> # Returns driver for specified name.
<add> #
<add> # SystemTesting::DriverAdapters.lookup(:capybara_selenium_driver)
<add> # # => SystemTesting::DriverAdapters::CapybaraSeleniumDriver
<ide> def lookup(name)
<ide> const_get(name.to_s.camelize)
<ide> end
<ide><path>actionpack/lib/system_testing/driver_adapters/capybara_rack_test_driver.rb
<ide> module SystemTesting
<ide> module DriverAdapters
<add> # == CapybaraRackTestDriver for System Testing
<add> #
<add> # This is the default driver for Capybara. This driver does not support
<add> # JavaScript because it doesn't open a browser when running the test suite.
<add> #
<add> # Although it does not support JavaScript testing the
<add> # <tt>CapybaraRackTestDriver</tt> is fast and efficient. This driver requires
<add> # no setup and becasue it does not need a webserver, additional configuration
<add> # is not required.
<add> #
<add> # The <tt>CapybaraRackTestDriver</tt> only takes one argument for initialization
<add> # which is +:useragent+.
<add> #
<add> # To set the useragent add the following to your
<add> # Rails' configuration file:
<add> #
<add> # config.system_testing.driver = SystemTesting::DriverAdapters::CapybaraRackTestDriver.new(
<add> # useragent: 'My UserAgent'
<add> # )
<ide> class CapybaraRackTestDriver
<ide> attr_reader :useragent
<ide>
<del> def initialize(useragent: 'Capybara')
<add> def initialize(useragent: 'Capybara') # :nodoc:
<ide> @useragent = useragent
<ide> end
<ide>
<del> def call
<add> def call # :nodoc:
<ide> registration
<ide> end
<ide>
<ide><path>actionpack/lib/system_testing/driver_adapters/capybara_selenium_driver.rb
<ide>
<ide> module SystemTesting
<ide> module DriverAdapters
<add> # == CapybaraSeleniumDriver for System Testing
<add> #
<add> # The <tt>CapybaraSeleniumDriver</t> uses the Selenium 2.0 webdriver. The
<add> # selenium-webdriver gem is required by this driver.
<add> #
<add> # The CapybaraSeleniumDriver is useful for real browser testing and
<add> # support Chrome and Firefox.
<add> #
<add> # To set your system testing to use the Selenium web driver add the
<add> # following to your Rails' configuration test environment:
<add> #
<add> # config.system_testing.driver = :capybara_selenium_driver
<add> #
<add> # Because this driver supports real browser testing it is required that a
<add> # server is configured.
<add> #
<add> # If no server is specified when the driver is initialized, Puma will be used
<add> # by default. The default settings for the <tt>CapybaraSeleniumDriver</tt>
<add> # are:
<add> #
<add> # #<SystemTesting::DriverAdapters::CapybaraSeleniumDriver:0x007ff0e992c1d8
<add> # @browser=:chrome,
<add> # @server=:puma,
<add> # @port=28100,
<add> # @screen_size=[ 1400, 1400 ]
<add> # >
<add> #
<add> # The settings for the <tt>CapybaraSeleniumDriver</tt> can be changed from
<add> # Rails' configuration file.
<add> #
<add> # config.system_testing.driver = SystemTesting::DriverAdapters::CapybaraSeleniumDriver.new(
<add> # server: :webkit,
<add> # port: 28100,
<add> # screen_size: [ 800, 800 ]
<add> # )
<add> #
<add> # The default browser is set to chrome because the current version of
<add> # Firefox does not work with selenium-webdriver. If you want to use Firefox,
<add> # you will need to use Firefox 45.0esr or 47.0 and ensure
<add> # that selenium-webdriver is version 2.53.4. To change the browser from
<add> # +:chrome+ to +:firefox+, initialize the selenium driver in your Rails'
<add> # test environment:
<add> #
<add> # config.system_testing.driver = SystemTesting::DriverAdapters::CapybaraSeleniumDriver.new(
<add> # browser: :firefox
<add> # )
<ide> class CapybaraSeleniumDriver
<ide> attr_reader :browser, :server, :port, :screen_size
<ide>
<del> def initialize(browser: :chrome, server: :puma, port: 28100, screen_size: [1400,1400])
<add> def initialize(browser: :chrome, server: :puma, port: 28100, screen_size: [1400,1400]) # :nodoc:
<ide> @browser = browser
<ide> @server = server
<ide> @port = port
<ide> @screen_size = screen_size
<ide> end
<ide>
<del> def call
<add> def call # :nodoc:
<ide> registration
<ide> setup
<ide> end
<ide><path>actionpack/lib/system_testing/railtie.rb
<ide> require 'system_test_case'
<ide>
<ide> module SystemTesting
<del> class Railtie < Rails::Railtie
<add> # = System Testing Railtie
<add> class Railtie < Rails::Railtie # :nodoc:
<ide> config.system_testing = ActiveSupport::OrderedOptions.new
<ide>
<ide> initializer "system_testing.set_configs" do |app|
<ide><path>actionpack/lib/system_testing/test_helper.rb
<ide> require 'system_testing/test_helpers'
<ide>
<ide> module SystemTesting
<del> module TestHelper
<add> module TestHelper # :nodoc:
<ide> include TestHelpers::FormHelper
<ide> include TestHelpers::Assertions
<ide> include Capybara::DSL
<ide><path>actionpack/lib/system_testing/test_helpers/assertions.rb
<ide> module SystemTesting
<ide> module TestHelpers
<add> # Assertions for system testing that aren't included by default in Capybara.
<add> # These are assertions that are useful specifically for Rails applications.
<ide> module Assertions
<add> # Asserts that all of the provided selectors are present on the given page.
<add> #
<add> # assert_all_of_selectors('p', 'td')
<ide> def assert_all_of_selectors(*items)
<ide> options = items.extract_options!
<ide> type = type_for_selector(items)
<ide> def assert_all_of_selectors(*items)
<ide> end
<ide> end
<ide>
<add> # Asserts that none of the provided selectors are present on the page.
<add> #
<add> # assert_none_of_selectors('ul', 'ol')
<ide> def assert_none_of_selectors(*items)
<ide> options = items.extract_options!
<ide> type = type_for_selector(items)
<ide><path>actionpack/lib/system_testing/test_helpers/form_helper.rb
<ide> module SystemTesting
<ide> module TestHelpers
<add> # Form helpers for system testing that aren't included by default in
<add> # Capybara.
<ide> module FormHelper
<add> # Finds all provided fields or text areas and fills in with supplied values.
<add> #
<add> # fill_in_all_fields('Name' => 'Eileen', 'Job Title' => 'Programmer')
<ide> def fill_in_all_fields(fields)
<ide> fields.each do |name, value|
<ide> fill_in name, with: value
<ide> end
<ide> end
<ide>
<add> # Locates a checkbox that is present inside a label and checks it. When
<add> # using styled boxes Selenium may not be able to see the checkbox. This
<add> # form helper looks inside the checkbox and clicks the label instead of
<add> # setting the value of the checkbox.
<add> #
<add> # click_checkbox_label 'Admin'
<add> #
<add> # By default +click_checkbox_label+ looks for checkboxes that are not
<add> # checked by default. To locate an already checked box and uncheck it
<add> # set checked to true:
<add> #
<add> # click_checkbox_label 'Admin', checked: true
<ide> def click_checkbox_label(name, checked: false)
<ide> field = find_checkbox(name, checked)
<ide> label = find_label_wrapper(field)
<ide> label.click
<ide> end
<ide>
<add> # In lieu of locating a button and calling +click_on+, +press_enter+ will
<add> # submit the form via enter. This method will only work for drivers that
<add> # load a browser like Selenium.
<add> #
<add> # test 'Adding a User' do
<add> # fill_in 'Name', with: 'Arya'
<add> #
<add> # press_enter
<add> #
<add> # assert_text 'Arya'
<add> # end
<ide> def press_enter
<ide> page.driver.browser.action.send_keys(:enter).perform
<ide> end
| 9
|
Python
|
Python
|
improve nparray.ctypes example
|
b4f97068e60e9be62b3461bac4e0383a6c3ee216
|
<ide><path>numpy/core/_add_newdocs.py
<ide> Examples
<ide> --------
<ide> >>> import ctypes
<add> >>> x = np.array([[0, 1], [2, 3]], dtype=np.int32)
<ide> >>> x
<ide> array([[0, 1],
<del> [2, 3]])
<add> [2, 3]], dtype=int32)
<ide> >>> x.ctypes.data
<del> 30439712
<del> >>> x.ctypes.data_as(ctypes.POINTER(ctypes.c_long))
<del> <ctypes.LP_c_long object at 0x01F01300>
<del> >>> x.ctypes.data_as(ctypes.POINTER(ctypes.c_long)).contents
<del> c_long(0)
<del> >>> x.ctypes.data_as(ctypes.POINTER(ctypes.c_longlong)).contents
<del> c_longlong(4294967296L)
<add> 31962608 # may vary
<add> >>> x.ctypes.data_as(ctypes.POINTER(ctypes.c_uint32))
<add> <__main__.LP_c_uint object at 0x7ff2fc1fc200> # may vary
<add> >>> x.ctypes.data_as(ctypes.POINTER(ctypes.c_uint32)).contents
<add> c_uint(0)
<add> >>> x.ctypes.data_as(ctypes.POINTER(ctypes.c_uint64)).contents
<add> c_ulong(4294967296)
<ide> >>> x.ctypes.shape
<del> <numpy.core._internal.c_long_Array_2 object at 0x01FFD580>
<del> >>> x.ctypes.shape_as(ctypes.c_long)
<del> <numpy.core._internal.c_long_Array_2 object at 0x01FCE620>
<add> <numpy.core._internal.c_long_Array_2 object at 0x7ff2fc1fce60> # may vary
<ide> >>> x.ctypes.strides
<del> <numpy.core._internal.c_long_Array_2 object at 0x01FCE620>
<del> >>> x.ctypes.strides_as(ctypes.c_longlong)
<del> <numpy.core._internal.c_longlong_Array_2 object at 0x01F01300>
<add> <numpy.core._internal.c_long_Array_2 object at 0x7ff2fc1ff320> # may vary
<ide>
<ide> """))
<ide>
| 1
|
Go
|
Go
|
update the testbuild with new format
|
15ea5a479a78d1011cda9bd55fd442d810234eb6
|
<ide><path>builder_test.go
<ide> import (
<ide>
<ide> const Dockerfile = `
<ide> # VERSION 0.1
<del># DOCKER-VERSION 0.1.6
<add># DOCKER-VERSION 0.2
<ide>
<del>from docker-ut
<del>run sh -c 'echo root:testpass > /tmp/passwd'
<del>run mkdir -p /var/run/sshd
<del>copy https://raw.github.com/dotcloud/docker/master/CHANGELOG.md /tmp/CHANGELOG.md
<add>from docker-ut
<add>run sh -c 'echo root:testpass > /tmp/passwd'
<add>run mkdir -p /var/run/sshd
<add>insert https://raw.github.com/dotcloud/docker/master/CHANGELOG.md /tmp/CHANGELOG.md
<ide> `
<ide>
<ide> func TestBuild(t *testing.T) {
| 1
|
Javascript
|
Javascript
|
make proptypes define_many_merged
|
4fe784de1f0d59b8a234fe4595ed9ac1bb8ba59f
|
<ide><path>src/core/ReactCompositeComponent.js
<ide> var ReactCompositeComponentInterface = {
<ide> * @type {object}
<ide> * @optional
<ide> */
<del> propTypes: SpecPolicy.DEFINE_ONCE,
<add> propTypes: SpecPolicy.DEFINE_MANY_MERGED,
<ide>
<ide>
<ide>
| 1
|
Javascript
|
Javascript
|
use arrow function for callback in stream test
|
ac43427ba70740265923488899ad2d175d40ec41
|
<ide><path>test/sequential/test-stream-writable-clear-buffer.js
<ide> const testStream = new StreamWritable();
<ide> testStream.cork();
<ide>
<ide> for (let i = 1; i <= 5; i++) {
<del> testStream.write(i, function() {
<add> testStream.write(i, () => {
<ide> assert.strictEqual(
<ide> testStream._writableState.bufferedRequestCount,
<ide> testStream._writableState.getBuffer().length,
| 1
|
Go
|
Go
|
add gotestyourself to vendor
|
0a7ff351b76f369b1cb1bc741e54b0d9018e7410
|
<ide><path>vendor/github.com/gotestyourself/gotestyourself/icmd/command.go
<add>/*Package icmd executes binaries and provides convenient assertions for testing the results.
<add> */
<add>package icmd
<add>
<add>import (
<add> "bytes"
<add> "fmt"
<add> "io"
<add> "os/exec"
<add> "path/filepath"
<add> "runtime"
<add> "strings"
<add> "sync"
<add> "time"
<add>)
<add>
<add>type testingT interface {
<add> Fatalf(string, ...interface{})
<add>}
<add>
<add>// None is a token to inform Result.Assert that the output should be empty
<add>const None string = "[NOTHING]"
<add>
<add>type lockedBuffer struct {
<add> m sync.RWMutex
<add> buf bytes.Buffer
<add>}
<add>
<add>func (buf *lockedBuffer) Write(b []byte) (int, error) {
<add> buf.m.Lock()
<add> defer buf.m.Unlock()
<add> return buf.buf.Write(b)
<add>}
<add>
<add>func (buf *lockedBuffer) String() string {
<add> buf.m.RLock()
<add> defer buf.m.RUnlock()
<add> return buf.buf.String()
<add>}
<add>
<add>// Result stores the result of running a command
<add>type Result struct {
<add> Cmd *exec.Cmd
<add> ExitCode int
<add> Error error
<add> // Timeout is true if the command was killed because it ran for too long
<add> Timeout bool
<add> outBuffer *lockedBuffer
<add> errBuffer *lockedBuffer
<add>}
<add>
<add>// Assert compares the Result against the Expected struct, and fails the test if
<add>// any of the expectations are not met.
<add>func (r *Result) Assert(t testingT, exp Expected) *Result {
<add> err := r.Compare(exp)
<add> if err == nil {
<add> return r
<add> }
<add> _, file, line, ok := runtime.Caller(1)
<add> if ok {
<add> t.Fatalf("at %s:%d - %s\n", filepath.Base(file), line, err.Error())
<add> } else {
<add> t.Fatalf("(no file/line info) - %s", err.Error())
<add> }
<add> return nil
<add>}
<add>
<add>// Compare returns a formatted error with the command, stdout, stderr, exit
<add>// code, and any failed expectations
<add>// nolint: gocyclo
<add>func (r *Result) Compare(exp Expected) error {
<add> errors := []string{}
<add> add := func(format string, args ...interface{}) {
<add> errors = append(errors, fmt.Sprintf(format, args...))
<add> }
<add>
<add> if exp.ExitCode != r.ExitCode {
<add> add("ExitCode was %d expected %d", r.ExitCode, exp.ExitCode)
<add> }
<add> if exp.Timeout != r.Timeout {
<add> if exp.Timeout {
<add> add("Expected command to timeout")
<add> } else {
<add> add("Expected command to finish, but it hit the timeout")
<add> }
<add> }
<add> if !matchOutput(exp.Out, r.Stdout()) {
<add> add("Expected stdout to contain %q", exp.Out)
<add> }
<add> if !matchOutput(exp.Err, r.Stderr()) {
<add> add("Expected stderr to contain %q", exp.Err)
<add> }
<add> switch {
<add> // If a non-zero exit code is expected there is going to be an error.
<add> // Don't require an error message as well as an exit code because the
<add> // error message is going to be "exit status <code> which is not useful
<add> case exp.Error == "" && exp.ExitCode != 0:
<add> case exp.Error == "" && r.Error != nil:
<add> add("Expected no error")
<add> case exp.Error != "" && r.Error == nil:
<add> add("Expected error to contain %q, but there was no error", exp.Error)
<add> case exp.Error != "" && !strings.Contains(r.Error.Error(), exp.Error):
<add> add("Expected error to contain %q", exp.Error)
<add> }
<add>
<add> if len(errors) == 0 {
<add> return nil
<add> }
<add> return fmt.Errorf("%s\nFailures:\n%s", r, strings.Join(errors, "\n"))
<add>}
<add>
<add>func matchOutput(expected string, actual string) bool {
<add> switch expected {
<add> case None:
<add> return actual == ""
<add> default:
<add> return strings.Contains(actual, expected)
<add> }
<add>}
<add>
<add>func (r *Result) String() string {
<add> var timeout string
<add> if r.Timeout {
<add> timeout = " (timeout)"
<add> }
<add>
<add> return fmt.Sprintf(`
<add>Command: %s
<add>ExitCode: %d%s
<add>Error: %v
<add>Stdout: %v
<add>Stderr: %v
<add>`,
<add> strings.Join(r.Cmd.Args, " "),
<add> r.ExitCode,
<add> timeout,
<add> r.Error,
<add> r.Stdout(),
<add> r.Stderr())
<add>}
<add>
<add>// Expected is the expected output from a Command. This struct is compared to a
<add>// Result struct by Result.Assert().
<add>type Expected struct {
<add> ExitCode int
<add> Timeout bool
<add> Error string
<add> Out string
<add> Err string
<add>}
<add>
<add>// Success is the default expected result. A Success result is one with a 0
<add>// ExitCode.
<add>var Success = Expected{}
<add>
<add>// Stdout returns the stdout of the process as a string
<add>func (r *Result) Stdout() string {
<add> return r.outBuffer.String()
<add>}
<add>
<add>// Stderr returns the stderr of the process as a string
<add>func (r *Result) Stderr() string {
<add> return r.errBuffer.String()
<add>}
<add>
<add>// Combined returns the stdout and stderr combined into a single string
<add>func (r *Result) Combined() string {
<add> return r.outBuffer.String() + r.errBuffer.String()
<add>}
<add>
<add>func (r *Result) setExitError(err error) {
<add> if err == nil {
<add> return
<add> }
<add> r.Error = err
<add> r.ExitCode = processExitCode(err)
<add>}
<add>
<add>// Cmd contains the arguments and options for a process to run as part of a test
<add>// suite.
<add>type Cmd struct {
<add> Command []string
<add> Timeout time.Duration
<add> Stdin io.Reader
<add> Stdout io.Writer
<add> Dir string
<add> Env []string
<add>}
<add>
<add>// Command create a simple Cmd with the specified command and arguments
<add>func Command(command string, args ...string) Cmd {
<add> return Cmd{Command: append([]string{command}, args...)}
<add>}
<add>
<add>// RunCmd runs a command and returns a Result
<add>func RunCmd(cmd Cmd, cmdOperators ...CmdOp) *Result {
<add> for _, op := range cmdOperators {
<add> op(&cmd)
<add> }
<add> result := StartCmd(cmd)
<add> if result.Error != nil {
<add> return result
<add> }
<add> return WaitOnCmd(cmd.Timeout, result)
<add>}
<add>
<add>// RunCommand runs a command with default options, and returns a result
<add>func RunCommand(command string, args ...string) *Result {
<add> return RunCmd(Command(command, args...))
<add>}
<add>
<add>// StartCmd starts a command, but doesn't wait for it to finish
<add>func StartCmd(cmd Cmd) *Result {
<add> result := buildCmd(cmd)
<add> if result.Error != nil {
<add> return result
<add> }
<add> result.setExitError(result.Cmd.Start())
<add> return result
<add>}
<add>
<add>func buildCmd(cmd Cmd) *Result {
<add> var execCmd *exec.Cmd
<add> switch len(cmd.Command) {
<add> case 1:
<add> execCmd = exec.Command(cmd.Command[0])
<add> default:
<add> execCmd = exec.Command(cmd.Command[0], cmd.Command[1:]...)
<add> }
<add> outBuffer := new(lockedBuffer)
<add> errBuffer := new(lockedBuffer)
<add>
<add> execCmd.Stdin = cmd.Stdin
<add> execCmd.Dir = cmd.Dir
<add> execCmd.Env = cmd.Env
<add> if cmd.Stdout != nil {
<add> execCmd.Stdout = io.MultiWriter(outBuffer, cmd.Stdout)
<add> } else {
<add> execCmd.Stdout = outBuffer
<add> }
<add> execCmd.Stderr = errBuffer
<add> return &Result{
<add> Cmd: execCmd,
<add> outBuffer: outBuffer,
<add> errBuffer: errBuffer,
<add> }
<add>}
<add>
<add>// WaitOnCmd waits for a command to complete. If timeout is non-nil then
<add>// only wait until the timeout.
<add>func WaitOnCmd(timeout time.Duration, result *Result) *Result {
<add> if timeout == time.Duration(0) {
<add> result.setExitError(result.Cmd.Wait())
<add> return result
<add> }
<add>
<add> done := make(chan error, 1)
<add> // Wait for command to exit in a goroutine
<add> go func() {
<add> done <- result.Cmd.Wait()
<add> }()
<add>
<add> select {
<add> case <-time.After(timeout):
<add> killErr := result.Cmd.Process.Kill()
<add> if killErr != nil {
<add> fmt.Printf("failed to kill (pid=%d): %v\n", result.Cmd.Process.Pid, killErr)
<add> }
<add> result.Timeout = true
<add> case err := <-done:
<add> result.setExitError(err)
<add> }
<add> return result
<add>}
<ide><path>vendor/github.com/gotestyourself/gotestyourself/icmd/exitcode.go
<add>package icmd
<add>
<add>import (
<add> "os/exec"
<add> "syscall"
<add>
<add> "github.com/pkg/errors"
<add>)
<add>
<add>// getExitCode returns the ExitStatus of a process from the error returned by
<add>// exec.Run(). If the exit status could not be parsed an error is returned.
<add>func getExitCode(err error) (int, error) {
<add> if exiterr, ok := err.(*exec.ExitError); ok {
<add> if procExit, ok := exiterr.Sys().(syscall.WaitStatus); ok {
<add> return procExit.ExitStatus(), nil
<add> }
<add> }
<add> return 0, errors.Wrap(err, "failed to get exit code")
<add>}
<add>
<add>func processExitCode(err error) (exitCode int) {
<add> if err == nil {
<add> return 0
<add> }
<add> exitCode, exiterr := getExitCode(err)
<add> if exiterr != nil {
<add> // TODO: Fix this so we check the error's text.
<add> // we've failed to retrieve exit code, so we set it to 127
<add> return 127
<add> }
<add> return exitCode
<add>}
<ide><path>vendor/github.com/gotestyourself/gotestyourself/icmd/ops.go
<add>package icmd
<add>
<add>// CmdOp is an operation which modified a Cmd structure used to execute commands
<add>type CmdOp func(*Cmd)
| 3
|
Javascript
|
Javascript
|
hide children of offscreen after destroy effects
|
99eef9e2df7b6aade461a1a958eb3838239e72c4
|
<ide><path>packages/react-reconciler/src/ReactFiberCommitWork.new.js
<ide> import {
<ide> enableUpdaterTracking,
<ide> enableCache,
<ide> enableTransitionTracing,
<add> enableFlipOffscreenUnhideOrder,
<ide> } from 'shared/ReactFeatureFlags';
<ide> import {
<ide> FunctionComponent,
<ide> function commitMutationEffectsOnFiber(
<ide> const isHidden = newState !== null;
<ide> const offscreenBoundary: Fiber = finishedWork;
<ide>
<del> if (supportsMutation) {
<del> // TODO: This needs to run whenever there's an insertion or update
<del> // inside a hidden Offscreen tree.
<del> hideOrUnhideAllChildren(offscreenBoundary, isHidden);
<del> }
<del>
<del> if (enableSuspenseLayoutEffectSemantics) {
<del> if (isHidden) {
<del> if (!wasHidden) {
<del> if ((offscreenBoundary.mode & ConcurrentMode) !== NoMode) {
<del> nextEffect = offscreenBoundary;
<del> let offscreenChild = offscreenBoundary.child;
<del> while (offscreenChild !== null) {
<del> nextEffect = offscreenChild;
<del> disappearLayoutEffects_begin(offscreenChild);
<del> offscreenChild = offscreenChild.sibling;
<add> if (enableFlipOffscreenUnhideOrder) {
<add> if (enableSuspenseLayoutEffectSemantics) {
<add> if (isHidden) {
<add> if (!wasHidden) {
<add> if ((offscreenBoundary.mode & ConcurrentMode) !== NoMode) {
<add> nextEffect = offscreenBoundary;
<add> let offscreenChild = offscreenBoundary.child;
<add> while (offscreenChild !== null) {
<add> nextEffect = offscreenChild;
<add> disappearLayoutEffects_begin(offscreenChild);
<add> offscreenChild = offscreenChild.sibling;
<add> }
<ide> }
<ide> }
<add> } else {
<add> if (wasHidden) {
<add> // TODO: Move re-appear call here for symmetry?
<add> }
<ide> }
<del> } else {
<del> if (wasHidden) {
<del> // TODO: Move re-appear call here for symmetry?
<add> }
<add>
<add> if (supportsMutation) {
<add> // TODO: This needs to run whenever there's an insertion or update
<add> // inside a hidden Offscreen tree.
<add> hideOrUnhideAllChildren(offscreenBoundary, isHidden);
<add> }
<add> } else {
<add> if (supportsMutation) {
<add> // TODO: This needs to run whenever there's an insertion or update
<add> // inside a hidden Offscreen tree.
<add> hideOrUnhideAllChildren(offscreenBoundary, isHidden);
<add> }
<add>
<add> if (enableSuspenseLayoutEffectSemantics) {
<add> if (isHidden) {
<add> if (!wasHidden) {
<add> if ((offscreenBoundary.mode & ConcurrentMode) !== NoMode) {
<add> nextEffect = offscreenBoundary;
<add> let offscreenChild = offscreenBoundary.child;
<add> while (offscreenChild !== null) {
<add> nextEffect = offscreenChild;
<add> disappearLayoutEffects_begin(offscreenChild);
<add> offscreenChild = offscreenChild.sibling;
<add> }
<add> }
<add> }
<add> } else {
<add> if (wasHidden) {
<add> // TODO: Move re-appear call here for symmetry?
<add> }
<ide> }
<ide> }
<ide> }
<ide><path>packages/react-reconciler/src/ReactFiberCommitWork.old.js
<ide> import {
<ide> enableUpdaterTracking,
<ide> enableCache,
<ide> enableTransitionTracing,
<add> enableFlipOffscreenUnhideOrder,
<ide> } from 'shared/ReactFeatureFlags';
<ide> import {
<ide> FunctionComponent,
<ide> function commitMutationEffectsOnFiber(
<ide> const isHidden = newState !== null;
<ide> const offscreenBoundary: Fiber = finishedWork;
<ide>
<del> if (supportsMutation) {
<del> // TODO: This needs to run whenever there's an insertion or update
<del> // inside a hidden Offscreen tree.
<del> hideOrUnhideAllChildren(offscreenBoundary, isHidden);
<del> }
<del>
<del> if (enableSuspenseLayoutEffectSemantics) {
<del> if (isHidden) {
<del> if (!wasHidden) {
<del> if ((offscreenBoundary.mode & ConcurrentMode) !== NoMode) {
<del> nextEffect = offscreenBoundary;
<del> let offscreenChild = offscreenBoundary.child;
<del> while (offscreenChild !== null) {
<del> nextEffect = offscreenChild;
<del> disappearLayoutEffects_begin(offscreenChild);
<del> offscreenChild = offscreenChild.sibling;
<add> if (enableFlipOffscreenUnhideOrder) {
<add> if (enableSuspenseLayoutEffectSemantics) {
<add> if (isHidden) {
<add> if (!wasHidden) {
<add> if ((offscreenBoundary.mode & ConcurrentMode) !== NoMode) {
<add> nextEffect = offscreenBoundary;
<add> let offscreenChild = offscreenBoundary.child;
<add> while (offscreenChild !== null) {
<add> nextEffect = offscreenChild;
<add> disappearLayoutEffects_begin(offscreenChild);
<add> offscreenChild = offscreenChild.sibling;
<add> }
<ide> }
<ide> }
<add> } else {
<add> if (wasHidden) {
<add> // TODO: Move re-appear call here for symmetry?
<add> }
<ide> }
<del> } else {
<del> if (wasHidden) {
<del> // TODO: Move re-appear call here for symmetry?
<add> }
<add>
<add> if (supportsMutation) {
<add> // TODO: This needs to run whenever there's an insertion or update
<add> // inside a hidden Offscreen tree.
<add> hideOrUnhideAllChildren(offscreenBoundary, isHidden);
<add> }
<add> } else {
<add> if (supportsMutation) {
<add> // TODO: This needs to run whenever there's an insertion or update
<add> // inside a hidden Offscreen tree.
<add> hideOrUnhideAllChildren(offscreenBoundary, isHidden);
<add> }
<add>
<add> if (enableSuspenseLayoutEffectSemantics) {
<add> if (isHidden) {
<add> if (!wasHidden) {
<add> if ((offscreenBoundary.mode & ConcurrentMode) !== NoMode) {
<add> nextEffect = offscreenBoundary;
<add> let offscreenChild = offscreenBoundary.child;
<add> while (offscreenChild !== null) {
<add> nextEffect = offscreenChild;
<add> disappearLayoutEffects_begin(offscreenChild);
<add> offscreenChild = offscreenChild.sibling;
<add> }
<add> }
<add> }
<add> } else {
<add> if (wasHidden) {
<add> // TODO: Move re-appear call here for symmetry?
<add> }
<ide> }
<ide> }
<ide> }
<ide><path>packages/shared/ReactFeatureFlags.js
<ide> export const skipUnmountedBoundaries = true;
<ide> //
<ide> // TODO: Finish rolling out in www
<ide> export const enableSuspenseLayoutEffectSemantics = true;
<add>export const enableFlipOffscreenUnhideOrder = false;
<ide>
<ide> // TODO: Finish rolling out in www
<ide> export const enableClientRenderFallbackOnTextMismatch = true;
<ide><path>packages/shared/forks/ReactFeatureFlags.native-fb.js
<ide> export const disableNativeComponentFrames = false;
<ide> export const skipUnmountedBoundaries = false;
<ide> export const deletedTreeCleanUpLevel = 3;
<ide> export const enableSuspenseLayoutEffectSemantics = false;
<add>export const enableFlipOffscreenUnhideOrder = false;
<ide> export const enableGetInspectorDataForInstanceInProduction = true;
<ide> export const enableNewReconciler = false;
<ide> export const deferRenderPhaseUpdateToNextBatch = false;
<ide><path>packages/shared/forks/ReactFeatureFlags.native-oss.js
<ide> export const disableNativeComponentFrames = false;
<ide> export const skipUnmountedBoundaries = false;
<ide> export const deletedTreeCleanUpLevel = 3;
<ide> export const enableSuspenseLayoutEffectSemantics = false;
<add>export const enableFlipOffscreenUnhideOrder = false;
<ide> export const enableGetInspectorDataForInstanceInProduction = false;
<ide> export const enableNewReconciler = false;
<ide> export const deferRenderPhaseUpdateToNextBatch = false;
<ide><path>packages/shared/forks/ReactFeatureFlags.test-renderer.js
<ide> export const disableNativeComponentFrames = false;
<ide> export const skipUnmountedBoundaries = false;
<ide> export const deletedTreeCleanUpLevel = 3;
<ide> export const enableSuspenseLayoutEffectSemantics = false;
<add>export const enableFlipOffscreenUnhideOrder = false;
<ide> export const enableGetInspectorDataForInstanceInProduction = false;
<ide> export const enableNewReconciler = false;
<ide> export const deferRenderPhaseUpdateToNextBatch = false;
<ide><path>packages/shared/forks/ReactFeatureFlags.test-renderer.native.js
<ide> export const disableNativeComponentFrames = false;
<ide> export const skipUnmountedBoundaries = false;
<ide> export const deletedTreeCleanUpLevel = 3;
<ide> export const enableSuspenseLayoutEffectSemantics = false;
<add>export const enableFlipOffscreenUnhideOrder = false;
<ide> export const enableGetInspectorDataForInstanceInProduction = false;
<ide> export const enableNewReconciler = false;
<ide> export const deferRenderPhaseUpdateToNextBatch = false;
<ide><path>packages/shared/forks/ReactFeatureFlags.test-renderer.www.js
<ide> export const disableNativeComponentFrames = false;
<ide> export const skipUnmountedBoundaries = false;
<ide> export const deletedTreeCleanUpLevel = 3;
<ide> export const enableSuspenseLayoutEffectSemantics = false;
<add>export const enableFlipOffscreenUnhideOrder = false;
<ide> export const enableGetInspectorDataForInstanceInProduction = false;
<ide> export const enableNewReconciler = false;
<ide> export const deferRenderPhaseUpdateToNextBatch = false;
<ide><path>packages/shared/forks/ReactFeatureFlags.testing.js
<ide> export const disableNativeComponentFrames = false;
<ide> export const skipUnmountedBoundaries = false;
<ide> export const deletedTreeCleanUpLevel = 3;
<ide> export const enableSuspenseLayoutEffectSemantics = false;
<add>export const enableFlipOffscreenUnhideOrder = false;
<ide> export const enableGetInspectorDataForInstanceInProduction = false;
<ide> export const enableNewReconciler = false;
<ide> export const deferRenderPhaseUpdateToNextBatch = false;
<ide><path>packages/shared/forks/ReactFeatureFlags.testing.www.js
<ide> export const disableNativeComponentFrames = false;
<ide> export const skipUnmountedBoundaries = true;
<ide> export const deletedTreeCleanUpLevel = 3;
<ide> export const enableSuspenseLayoutEffectSemantics = false;
<add>export const enableFlipOffscreenUnhideOrder = false;
<ide> export const enableGetInspectorDataForInstanceInProduction = false;
<ide> export const enableNewReconciler = false;
<ide> export const deferRenderPhaseUpdateToNextBatch = false;
<ide><path>packages/shared/forks/ReactFeatureFlags.www-dynamic.js
<ide> export const enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay = __
<ide> export const enableClientRenderFallbackOnTextMismatch = __VARIANT__;
<ide> export const enableTransitionTracing = __VARIANT__;
<ide> export const enableSymbolFallbackForWWW = __VARIANT__;
<add>export const enableFlipOffscreenUnhideOrder = __VARIANT__;
<ide> // Enable this flag to help with concurrent mode debugging.
<ide> // It logs information to the console about React scheduling, rendering, and commit phases.
<ide> //
<ide><path>packages/shared/forks/ReactFeatureFlags.www.js
<ide> export const {
<ide> enableSyncDefaultUpdates,
<ide> enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay,
<ide> enableClientRenderFallbackOnTextMismatch,
<add> enableFlipOffscreenUnhideOrder,
<ide> } = dynamicFeatureFlags;
<ide>
<ide> // On WWW, __EXPERIMENTAL__ is used for a new modern build.
| 12
|
Javascript
|
Javascript
|
move function declaration to top-level
|
0b0b72c2fab5bdf32f5476e47a1e7f2da9db2064
|
<ide><path>lib/readline.js
<ide> Interface.prototype._tabComplete = function() {
<ide> return a.length > b.length ? a : b;
<ide> }).length + 2; // 2 space padding
<ide> var maxColumns = Math.floor(self.columns / width) || 1;
<del>
<del> function handleGroup(group) {
<del> if (group.length == 0) {
<del> return;
<del> }
<del> var minRows = Math.ceil(group.length / maxColumns);
<del> for (var row = 0; row < minRows; row++) {
<del> for (var col = 0; col < maxColumns; col++) {
<del> var idx = row * maxColumns + col;
<del> if (idx >= group.length) {
<del> break;
<del> }
<del> var item = group[idx];
<del> self.output.write(item);
<del> if (col < maxColumns - 1) {
<del> for (var s = 0, itemLen = item.length; s < width - itemLen;
<del> s++) {
<del> self.output.write(' ');
<del> }
<del> }
<del> }
<del> self.output.write('\r\n');
<del> }
<del> self.output.write('\r\n');
<del> }
<del>
<ide> var group = [], c;
<ide> for (var i = 0, compLen = completions.length; i < compLen; i++) {
<ide> c = completions[i];
<ide> if (c === '') {
<del> handleGroup(group);
<add> handleGroup.call(self, group);
<ide> group = [];
<ide> } else {
<ide> group.push(c);
<ide> }
<ide> }
<del> handleGroup(group);
<add> handleGroup.call(self, group);
<ide>
<ide> // If there is a common prefix to all matches, then apply that
<ide> // portion.
<ide> Interface.prototype._tabComplete = function() {
<ide> });
<ide> };
<ide>
<add>// this = Interface instance
<add>function handleGroup(group) {
<add> var self = this;
<add> if (group.length == 0) {
<add> return;
<add> }
<add> var minRows = Math.ceil(group.length / maxColumns);
<add> for (var row = 0; row < minRows; row++) {
<add> for (var col = 0; col < maxColumns; col++) {
<add> var idx = row * maxColumns + col;
<add> if (idx >= group.length) {
<add> break;
<add> }
<add> var item = group[idx];
<add> self.output.write(item);
<add> if (col < maxColumns - 1) {
<add> for (var s = 0, itemLen = item.length; s < width - itemLen;
<add> s++) {
<add> self.output.write(' ');
<add> }
<add> }
<add> }
<add> self.output.write('\r\n');
<add> }
<add> self.output.write('\r\n');
<add>}
<ide>
<ide> function commonPrefix(strings) {
<ide> if (!strings || strings.length == 0) {
| 1
|
PHP
|
PHP
|
fix formrequest tests
|
f322d52ce9b41b6b543a49ad0196a7599e1c2f28
|
<add><path>tests/Foundation/FoundationFormRequestTest.php
<del><path>tests/Foundation/FoundationFormRequestTestCase.php
<ide> use Mockery as m;
<ide> use Illuminate\Container\Container;
<ide>
<del>class FoundationFormRequestTestCase extends PHPUnit_Framework_TestCase
<add>class FoundationFormRequestTest extends PHPUnit_Framework_TestCase
<ide> {
<ide> public function tearDown()
<ide> {
<ide> m::close();
<del> unset($_SERVER['__request.validated']);
<ide> }
<ide>
<ide> public function testValidateFunctionRunsValidatorOnSpecifiedRules()
<ide> {
<ide> $request = FoundationTestFormRequestStub::create('/', 'GET', ['name' => 'abigail']);
<del> $request->setContainer(new Container);
<add> $request->setContainer($container = new Container);
<ide> $factory = m::mock('Illuminate\Validation\Factory');
<del> $factory->shouldReceive('make')->once()->with(['name' => 'abigail'], ['name' => 'required'])->andReturn(
<add> $factory->shouldReceive('make')->once()->with(['name' => 'abigail'], ['name' => 'required'], [], [])->andReturn(
<ide> $validator = m::mock('Illuminate\Validation\Validator')
<ide> );
<del> $validator->shouldReceive('fails')->once()->andReturn(false);
<add> $container->instance('Illuminate\Contracts\Validation\Factory', $factory);
<add> $validator->shouldReceive('passes')->once()->andReturn(true);
<ide>
<ide> $request->validate($factory);
<del>
<del> $this->assertTrue($_SERVER['__request.validated']);
<ide> }
<ide>
<ide> /**
<ide> public function testValidateFunctionThrowsHttpResponseExceptionIfValidationFails
<ide> {
<ide> $request = m::mock('FoundationTestFormRequestStub[response]');
<ide> $request->initialize(['name' => null]);
<del> $request->setContainer(new Container);
<add> $request->setContainer($container = new Container);
<ide> $factory = m::mock('Illuminate\Validation\Factory');
<del> $factory->shouldReceive('make')->once()->with(['name' => null], ['name' => 'required'])->andReturn(
<add> $factory->shouldReceive('make')->once()->with(['name' => null], ['name' => 'required'], [], [])->andReturn(
<ide> $validator = m::mock('Illuminate\Validation\Validator')
<ide> );
<del> $validator->shouldReceive('fails')->once()->andReturn(true);
<del> $validator->shouldReceive('errors')->once()->andReturn($messages = m::mock('StdClass'));
<del> $messages->shouldReceive('all')->once()->andReturn([]);
<add> $container->instance('Illuminate\Contracts\Validation\Factory', $factory);
<add> $validator->shouldReceive('passes')->once()->andReturn(false);
<add> $validator->shouldReceive('getMessageBag')->once()->andReturn($messages = m::mock('Illuminate\Support\MessageBag'));
<add> $messages->shouldReceive('toArray')->once()->andReturn(['name' => ['Name required']]);
<ide> $request->shouldReceive('response')->once()->andReturn(new Illuminate\Http\Response);
<ide>
<ide> $request->validate($factory);
<ide> public function testValidateFunctionThrowsHttpResponseExceptionIfAuthorizationFa
<ide> {
<ide> $request = m::mock('FoundationTestFormRequestForbiddenStub[forbiddenResponse]');
<ide> $request->initialize(['name' => null]);
<del> $request->setContainer(new Container);
<add> $request->setContainer($container = new Container);
<ide> $factory = m::mock('Illuminate\Validation\Factory');
<del> $factory->shouldReceive('make')->once()->with(['name' => null], ['name' => 'required'])->andReturn(
<add> $factory->shouldReceive('make')->once()->with(['name' => null], ['name' => 'required'], [], [])->andReturn(
<ide> $validator = m::mock('Illuminate\Validation\Validator')
<ide> );
<del> $validator->shouldReceive('fails')->once()->andReturn(false);
<add> $container->instance('Illuminate\Contracts\Validation\Factory', $factory);
<add> $validator->shouldReceive('passes')->never();
<ide> $request->shouldReceive('forbiddenResponse')->once()->andReturn(new Illuminate\Http\Response);
<ide>
<ide> $request->validate($factory);
<ide> public function testRedirectResponseIsProperlyCreatedWithGivenErrors()
<ide> $redirector->shouldReceive('getUrlGenerator')->andReturn($url = m::mock('StdClass'));
<ide> $url->shouldReceive('previous')->once()->andReturn('previous');
<ide> $response->shouldReceive('withInput')->andReturn($response);
<del> $response->shouldReceive('withErrors')->with(['errors'])->andReturn($response);
<add> $response->shouldReceive('withErrors')->with(['errors'], 'default')->andReturn($response);
<ide>
<ide> $request->response(['errors']);
<ide> }
<ide> }
<ide>
<ide> class FoundationTestFormRequestStub extends Illuminate\Foundation\Http\FormRequest
<ide> {
<del> public function rules(StdClass $dep)
<add> public function rules()
<ide> {
<ide> return ['name' => 'required'];
<ide> }
<ide>
<del> public function authorize(StdClass $dep)
<add> public function authorize()
<ide> {
<ide> return true;
<ide> }
<del>
<del> public function validated(StdClass $dep)
<del> {
<del> $_SERVER['__request.validated'] = true;
<del> }
<ide> }
<ide>
<ide> class FoundationTestFormRequestForbiddenStub extends Illuminate\Foundation\Http\FormRequest
| 1
|
Java
|
Java
|
fix typo in package-info.java
|
e3137f11dfc90743a13202ff1b4e12871761636f
|
<ide><path>spring-messaging/src/main/java/org/springframework/messaging/simp/package-info.java
<ide> /**
<del> * Generic support for SImple Messaging Protocols including protocols such as STOMP.
<add> * Generic support for Simple Messaging Protocols including protocols such as STOMP.
<ide> */
<ide> @NonNullApi
<ide> @NonNullFields
| 1
|
Javascript
|
Javascript
|
convert keyboardavoidingview to use export default
|
7f3f8680205d24b4c1001b54355af29596f169cf
|
<ide><path>Libraries/Components/Keyboard/KeyboardAvoidingView.js
<ide> class KeyboardAvoidingView extends React.Component<Props, State> {
<ide> }
<ide> }
<ide>
<del>module.exports = KeyboardAvoidingView;
<add>export default KeyboardAvoidingView;
<ide><path>index.js
<ide> module.exports = {
<ide> return require('./Libraries/Components/TextInput/InputAccessoryView');
<ide> },
<ide> get KeyboardAvoidingView(): KeyboardAvoidingView {
<del> return require('./Libraries/Components/Keyboard/KeyboardAvoidingView');
<add> return require('./Libraries/Components/Keyboard/KeyboardAvoidingView')
<add> .default;
<ide> },
<ide> get MaskedViewIOS(): MaskedViewIOS {
<ide> warnOnce(
| 2
|
Python
|
Python
|
add a list of all api dicts which define the c api
|
726fb0abae756d03d023e80d35e2c237fe4160af
|
<ide><path>numpy/core/code_generators/numpy_api.py
<ide> 'PyUFunc_FromFuncAndDataAndSignature': 31,
<ide> 'PyUFunc_SetUsesArraysAsData': 32,
<ide> }
<add>
<add># List of all the dicts which define the C API
<add>full_api = (
<add> multiarray_global_vars,
<add> multiarray_global_vars_types,
<add> multiarray_scalar_bool_values,
<add> multiarray_types_api,
<add> multiarray_funcs_api,
<add> ufunc_funcs_api,
<add> ufunc_types_api
<add>)
<add>
| 1
|
Javascript
|
Javascript
|
simplify the `pdfdocument` constructor
|
6a78f20b17b39be0b17aea9eeb11498b82ff9b88
|
<ide><path>src/core/document.js
<ide> import {
<ide> FormatError,
<ide> info,
<ide> InvalidPDFException,
<del> isArrayBuffer,
<ide> isArrayEqual,
<ide> OPS,
<ide> PageActionEventType,
<ide> import {
<ide> } from "./core_utils.js";
<ide> import { Dict, isName, Name, Ref } from "./primitives.js";
<ide> import { getXfaFontDict, getXfaFontName } from "./xfa_fonts.js";
<del>import { NullStream, Stream } from "./stream.js";
<ide> import { AnnotationFactory } from "./annotation.js";
<ide> import { BaseStream } from "./base_stream.js";
<ide> import { calculateMD5 } from "./crypto.js";
<ide> import { Catalog } from "./catalog.js";
<ide> import { clearGlobalCaches } from "./cleanup_helper.js";
<ide> import { Linearization } from "./parser.js";
<add>import { NullStream } from "./stream.js";
<ide> import { ObjectLoader } from "./object_loader.js";
<ide> import { OperatorList } from "./operator_list.js";
<ide> import { PartialEvaluator } from "./evaluator.js";
<ide> function find(stream, signature, limit = 1024, backwards = false) {
<ide> * The `PDFDocument` class holds all the (worker-thread) data of the PDF file.
<ide> */
<ide> class PDFDocument {
<del> constructor(pdfManager, arg) {
<del> let stream;
<del> if (arg instanceof BaseStream) {
<del> stream = arg;
<del> } else if (isArrayBuffer(arg)) {
<del> stream = new Stream(arg);
<del> } else {
<del> throw new Error("PDFDocument: Unknown argument type");
<add> constructor(pdfManager, stream) {
<add> if (
<add> typeof PDFJSDev === "undefined" ||
<add> PDFJSDev.test("!PRODUCTION || TESTING")
<add> ) {
<add> assert(
<add> stream instanceof BaseStream,
<add> 'PDFDocument: Invalid "stream" argument.'
<add> );
<ide> }
<ide> if (stream.length <= 0) {
<ide> throw new InvalidPDFException(
| 1
|
Javascript
|
Javascript
|
add additional field for art reconciler
|
61349eb5a6cd23f49b330500aba17077f134d354
|
<ide><path>src/core/ReactComponent.js
<ide> var ReactComponent = {
<ide> // We keep the old element and a reference to the pending element
<ide> // to track updates.
<ide> this._currentElement = element;
<add> // These two fields are used by the DOM and ART diffing algorithms
<add> // respectively. Instead of using expandos on components, we should be
<add> // storing the state needed by the diffing algorithms elsewhere.
<ide> this._mountIndex = 0;
<add> this._mountImage = null;
<ide> },
<ide>
<ide> /**
| 1
|
Javascript
|
Javascript
|
fix missing movetos in svg paths
|
52e8e9b059e682dfecfa762957d3ffcccacbeddb
|
<ide><path>src/display/svg.js
<ide> SVGGraphics = (function SVGGraphicsClosure() {
<ide> constructPath: function SVGGraphics_constructPath(ops, args) {
<ide> var current = this.current;
<ide> var x = current.x, y = current.y;
<del> current.path = this.svgFactory.createElement('svg:path');
<ide> var d = [];
<ide> var opLength = ops.length;
<ide>
<ide> SVGGraphics = (function SVGGraphicsClosure() {
<ide> break;
<ide> }
<ide> }
<del> current.path.setAttributeNS(null, 'd', d.join(' '));
<del> current.path.setAttributeNS(null, 'fill', 'none');
<ide>
<del> this._ensureTransformGroup().appendChild(current.path);
<add> d = d.join(' ');
<add>
<add> if (current.path && opLength > 0 && ops[0] !== OPS.rectangle &&
<add> ops[0] !== OPS.moveTo) {
<add> // If a path does not start with an OPS.rectangle or OPS.moveTo, it has
<add> // probably been divided into two OPS.constructPath operators by
<add> // OperatorList. Append the commands to the previous path element.
<add> d = current.path.getAttributeNS(null, 'd') + d;
<add> } else {
<add> current.path = this.svgFactory.createElement('svg:path');
<add> this._ensureTransformGroup().appendChild(current.path);
<add> }
<add>
<add> current.path.setAttributeNS(null, 'd', d);
<add> current.path.setAttributeNS(null, 'fill', 'none');
<ide>
<ide> // Saving a reference in current.element so that it can be addressed
<ide> // in 'fill' and 'stroke'
<ide> SVGGraphics = (function SVGGraphicsClosure() {
<ide> },
<ide>
<ide> endPath: function SVGGraphics_endPath() {
<add> // Painting operators end a path.
<add> this.current.path = null;
<add>
<ide> if (!this.pendingClip) {
<ide> return;
<ide> }
| 1
|
Javascript
|
Javascript
|
add support for common object methods to proxies
|
5411be10a02e09189a3db9feadd277ce9e014003
|
<ide><path>src/helpers/helpers.config.js
<ide> export function _createResolver(scopes, prefixes = ['']) {
<ide> override: (scope) => _createResolver([scope].concat(scopes), prefixes),
<ide> };
<ide> return new Proxy(cache, {
<add> /**
<add> * A trap for getting property values.
<add> */
<ide> get(target, prop) {
<ide> return _cached(target, prop,
<ide> () => _resolveWithPrefixes(prop, prefixes, scopes));
<ide> },
<ide>
<del> ownKeys(target) {
<del> return getKeysFromAllScopes(target);
<del> },
<del>
<add> /**
<add> * A trap for Object.getOwnPropertyDescriptor.
<add> * Also used by Object.hasOwnProperty.
<add> */
<ide> getOwnPropertyDescriptor(target, prop) {
<ide> return Reflect.getOwnPropertyDescriptor(target._scopes[0], prop);
<ide> },
<ide>
<add> /**
<add> * A trap for Object.getPrototypeOf.
<add> */
<add> getPrototypeOf() {
<add> return Reflect.getPrototypeOf(scopes[0]);
<add> },
<add>
<add> /**
<add> * A trap for the in operator.
<add> */
<add> has(target, prop) {
<add> return getKeysFromAllScopes(target).includes(prop);
<add> },
<add>
<add> /**
<add> * A trap for Object.getOwnPropertyNames and Object.getOwnPropertySymbols.
<add> */
<add> ownKeys(target) {
<add> return getKeysFromAllScopes(target);
<add> },
<add>
<add> /**
<add> * A trap for setting property values.
<add> */
<ide> set(target, prop, value) {
<ide> scopes[0][prop] = value;
<ide> return delete target[prop];
<ide> export function _attachContext(proxy, context, subProxy) {
<ide> override: (scope) => _attachContext(proxy.override(scope), context, subProxy)
<ide> };
<ide> return new Proxy(cache, {
<add> /**
<add> * A trap for getting property values.
<add> */
<ide> get(target, prop, receiver) {
<ide> return _cached(target, prop,
<ide> () => _resolveWithContext(target, prop, receiver));
<ide> },
<ide>
<del> ownKeys() {
<del> return Reflect.ownKeys(proxy);
<add> /**
<add> * A trap for Object.getOwnPropertyDescriptor.
<add> * Also used by Object.hasOwnProperty.
<add> */
<add> getOwnPropertyDescriptor(target, prop) {
<add> return Reflect.getOwnPropertyDescriptor(proxy, prop);
<ide> },
<ide>
<del> getOwnPropertyDescriptor(target, prop) {
<del> return Reflect.getOwnPropertyDescriptor(proxy._scopes[0], prop);
<add> /**
<add> * A trap for Object.getPrototypeOf.
<add> */
<add> getPrototypeOf() {
<add> return Reflect.getPrototypeOf(proxy);
<add> },
<add>
<add> /**
<add> * A trap for the in operator.
<add> */
<add> has(target, prop) {
<add> return Reflect.has(proxy, prop);
<add> },
<add>
<add> /**
<add> * A trap for Object.getOwnPropertyNames and Object.getOwnPropertySymbols.
<add> */
<add> ownKeys() {
<add> return Reflect.ownKeys(proxy);
<ide> },
<ide>
<add> /**
<add> * A trap for setting property values.
<add> */
<ide> set(target, prop, value) {
<ide> proxy[prop] = value;
<ide> return delete target[prop];
<ide><path>test/specs/helpers.config.tests.js
<ide> describe('Chart.helpers.config', function() {
<ide> option3: 'defaults3'
<ide> });
<ide> });
<add>
<add> it('should support common object methods', function() {
<add> const defaults = {
<add> option1: 'defaults'
<add> };
<add> class Options {
<add> constructor() {
<add> this.option2 = 'options';
<add> }
<add> get getter() {
<add> return 'options getter';
<add> }
<add> }
<add> const options = new Options();
<add>
<add> const resolver = _createResolver([options, defaults]);
<add>
<add> expect(Object.prototype.hasOwnProperty.call(resolver, 'option2')).toBeTrue();
<add>
<add> expect(Object.prototype.hasOwnProperty.call(resolver, 'option1')).toBeFalse();
<add> expect(Object.prototype.hasOwnProperty.call(resolver, 'getter')).toBeFalse();
<add> expect(Object.prototype.hasOwnProperty.call(resolver, 'nonexistent')).toBeFalse();
<add>
<add> expect(Object.keys(resolver)).toEqual(['option2']);
<add> expect(Object.getOwnPropertyNames(resolver)).toEqual(['option2', 'option1']);
<add>
<add> expect('option2' in resolver).toBeTrue();
<add> expect('option1' in resolver).toBeTrue();
<add> expect('getter' in resolver).toBeFalse();
<add> expect('nonexistent' in resolver).toBeFalse();
<add>
<add> expect(resolver instanceof Options).toBeTrue();
<add>
<add> expect(resolver.getter).toEqual('options getter');
<add> });
<ide> });
<ide>
<ide> describe('_attachContext', function() {
<ide> describe('Chart.helpers.config', function() {
<ide> expect(opts.fn).toEqual(1);
<ide> });
<ide>
<add> it('should support common object methods', function() {
<add> const defaults = {
<add> option1: 'defaults'
<add> };
<add> class Options {
<add> constructor() {
<add> this.option2 = () => 'options';
<add> }
<add> get getter() {
<add> return 'options getter';
<add> }
<add> }
<add> const options = new Options();
<add> const resolver = _createResolver([options, defaults]);
<add> const opts = _attachContext(resolver, {index: 1});
<add>
<add> expect(Object.prototype.hasOwnProperty.call(opts, 'option2')).toBeTrue();
<add>
<add> expect(Object.prototype.hasOwnProperty.call(opts, 'option1')).toBeFalse();
<add> expect(Object.prototype.hasOwnProperty.call(opts, 'getter')).toBeFalse();
<add> expect(Object.prototype.hasOwnProperty.call(opts, 'nonexistent')).toBeFalse();
<add>
<add> expect(Object.keys(opts)).toEqual(['option2']);
<add> expect(Object.getOwnPropertyNames(opts)).toEqual(['option2', 'option1']);
<add>
<add> expect('option2' in opts).toBeTrue();
<add> expect('option1' in opts).toBeTrue();
<add> expect('getter' in opts).toBeFalse();
<add> expect('nonexistent' in opts).toBeFalse();
<add>
<add> expect(opts instanceof Options).toBeTrue();
<add>
<add> expect(opts.getter).toEqual('options getter');
<add> });
<add>
<ide> describe('_indexable and _scriptable', function() {
<ide> it('should default to true', function() {
<ide> const options = {
| 2
|
PHP
|
PHP
|
remove "mobile" detector
|
f6072396b4764b3b4c4a671b7efbda200489a977
|
<ide><path>src/Network/Request.php
<ide> class Request implements \ArrayAccess {
<ide> 'ssl' => array('env' => 'HTTPS', 'value' => 1),
<ide> 'ajax' => array('env' => 'HTTP_X_REQUESTED_WITH', 'value' => 'XMLHttpRequest'),
<ide> 'flash' => array('env' => 'HTTP_USER_AGENT', 'pattern' => '/^(Shockwave|Adobe) Flash/'),
<del> 'mobile' => array('env' => 'HTTP_USER_AGENT', 'options' => array(
<del> 'Android', 'AvantGo', 'BlackBerry', 'DoCoMo', 'Fennec', 'iPod', 'iPhone', 'iPad',
<del> 'J2ME', 'MIDP', 'NetFront', 'Nokia', 'Opera Mini', 'Opera Mobi', 'PalmOS', 'PalmSource',
<del> 'portalmmm', 'Plucker', 'ReqwirelessWeb', 'SonyEricsson', 'Symbian', 'UP\\.Browser',
<del> 'webOS', 'Windows CE', 'Windows Phone OS', 'Xiino'
<del> )),
<ide> 'requested' => array('param' => 'requested', 'value' => 1)
<ide> );
<ide>
<ide><path>tests/TestCase/Network/RequestTest.php
<ide> public function testisAjaxFlashAndFriends() {
<ide> $request->env('HTTP_X_REQUESTED_WITH', 'XMLHTTPREQUEST');
<ide> $this->assertFalse($request->is('ajax'));
<ide> $this->assertFalse($request->isAjax());
<del>
<del> $request->env('HTTP_USER_AGENT', 'Android 2.0');
<del> $this->assertTrue($request->is('mobile'));
<del> $this->assertTrue($request->isMobile());
<del>
<del> $request->env(
<del> 'HTTP_USER_AGENT',
<del> 'Mozilla/5.0 (Windows NT 5.1; rv:2.0b6pre) Gecko/20100902 Firefox/4.0b6pre Fennec/2.0b1pre'
<del> );
<del> $this->assertTrue($request->is('mobile'));
<del> $this->assertTrue($request->isMobile());
<del>
<del> $request->env(
<del> 'HTTP_USER_AGENT',
<del> 'Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0; SAMSUNG; OMNIA7)'
<del> );
<del> $this->assertTrue($request->is('mobile'));
<del> $this->assertTrue($request->isMobile());
<ide> }
<ide>
<ide> /**
<ide> public function testAddDetector() {
<ide> $request->env('TEST_VAR', 'wrong value');
<ide> $this->assertFalse($request->isBanana());
<ide>
<del> Request::addDetector('mobile', array('options' => array('Imagination')));
<add> Request::addDetector('mobile', array('env' => 'HTTP_USER_AGENT', 'options' => array('Imagination')));
<ide> $request->env('HTTP_USER_AGENT', 'Imagination land');
<ide> $this->assertTrue($request->isMobile());
<ide>
<del> $request->env('HTTP_USER_AGENT', 'iPhone 3.0');
<del> $this->assertTrue($request->isMobile());
<del>
<ide> Request::addDetector('callme', array('env' => 'TEST_VAR', 'callback' => array($this, 'detectCallback')));
<ide>
<ide> Request::addDetector('index', array('param' => 'action', 'value' => 'index'));
| 2
|
Python
|
Python
|
prepare 2.1.5 release
|
2fae46169239287796d44523deb5e2ac38712ba3
|
<ide><path>keras/__init__.py
<ide> from .models import Model
<ide> from .models import Sequential
<ide>
<del>__version__ = '2.1.4'
<add>__version__ = '2.1.5'
<ide><path>setup.py
<ide>
<ide>
<ide> setup(name='Keras',
<del> version='2.1.4',
<add> version='2.1.5',
<ide> description='Deep Learning for humans',
<ide> author='Francois Chollet',
<ide> author_email='francois.chollet@gmail.com',
<ide> url='https://github.com/keras-team/keras',
<del> download_url='https://github.com/keras-team/keras/tarball/2.1.4',
<add> download_url='https://github.com/keras-team/keras/tarball/2.1.5',
<ide> license='MIT',
<ide> install_requires=['numpy>=1.9.1',
<ide> 'scipy>=0.14',
| 2
|
Text
|
Text
|
simplify code examples for dynamic api routes
|
a289d3805724099862ca477c4d4719d8e5078c4d
|
<ide><path>docs/api-routes/dynamic-api-routes.md
<ide> For example, the API route `pages/api/post/[pid].js` has the following code:
<ide>
<ide> ```js
<ide> export default function handler(req, res) {
<del> const {
<del> query: { pid },
<del> } = req
<del>
<add> const { pid } = req.query
<ide> res.end(`Post: ${pid}`)
<ide> }
<ide> ```
<ide> An API route for `pages/api/post/[...slug].js` could look like this:
<ide>
<ide> ```js
<ide> export default function handler(req, res) {
<del> const {
<del> query: { slug },
<del> } = req
<del>
<add> const { slug } = req.query
<ide> res.end(`Post: ${slug.join(', ')}`)
<ide> }
<ide> ```
| 1
|
Ruby
|
Ruby
|
add tests for dependencies
|
cfc423e1839442f605072db14aac42f6f5fa6174
|
<ide><path>Library/Homebrew/rubocops/lines_cop.rb
<ide> def audit_formula(_node, _class_node, _parent_class_node, body_node)
<ide> problem "Use ENV instead of invoking '#{match[1]}' to modify the environment"
<ide> end
<ide>
<del> # find_every_method_call_by_name(body_node, :depends_on).each do |m|
<del> # next unless modifier?(m)
<del> # dep, option = hash_dep(m)
<del> # next if dep.nil? || option.nil?
<del> # problem "Dependency #{string_content(dep)} should not use option #{string_content(option)}"
<del> # end
<del> #
<add> find_every_method_call_by_name(body_node, :depends_on).each do |m|
<add> next if modifier?(m.parent)
<add> param = parameters(m).first
<add> dep, option = hash_dep(param)
<add> next if dep.nil? || option.nil?
<add> offending_node(param)
<add> problem "Dependency #{string_content(dep)} should not use option #{string_content(option)}"
<add> end
<add>
<ide> # find_instance_method_call(body_node, :version, :==) do |m|
<ide> # next unless parameters_passed?(m, "HEAD")
<ide> # problem "Use 'build.head?' instead of inspecting 'version'"
<ide> def unless_modifier?(node)
<ide> end
<ide>
<ide> def modifier?(node)
<add> return false unless node.if_type?
<ide> node.modifier_form?
<ide> end
<ide>
<ide> def modifier?(node)
<ide> EOS
<ide>
<ide> # Match depends_on with hash as argument
<del> def_node_search :hash_dep, <<-EOS.undent
<del> {$(hash (pair $(str _) $(str _)))
<del> $(hash (pair $(str _) (array $(str _) ...)))}
<add> def_node_matcher :hash_dep, <<-EOS.undent
<add> {(hash (pair $(str _) $(str _)))
<add> (hash (pair $(str _) (array $(str _) ...)))}
<ide> EOS
<ide>
<ide> def_node_matcher :destructure_hash, <<-EOS.undent
<ide><path>Library/Homebrew/test/rubocops/lines_cop_spec.rb
<ide> class Foo < Formula
<ide> end
<ide> end
<ide>
<add> it "with dependencies with invalid options" do
<add> source = <<-EOS.undent
<add> class Foo < Formula
<add> desc "foo"
<add> url 'http://example.com/foo-1.0.tgz'
<add> depends_on "foo" => "with-bar"
<add> end
<add> EOS
<add>
<add> expected_offenses = [{ message: "Dependency foo should not use option with-bar",
<add> severity: :convention,
<add> line: 4,
<add> column: 13,
<add> source: source }]
<add>
<add> inspect_source(cop, source)
<add>
<add> expected_offenses.zip(cop.offenses).each do |expected, actual|
<add> expect_offense(expected, actual)
<add> end
<add> end
<add>
<ide> end
<ide> def expect_offense(expected, actual)
<ide> expect(actual.message).to eq(expected[:message])
| 2
|
Python
|
Python
|
fix gzipfile wrapper to be <= 2.5 compatible
|
8fa2591fee88937b81c39a6c529fa66975f88856
|
<ide><path>numpy/lib/npyio.py
<ide> def tell(self):
<ide> f = GzipFile(f)
<ide> elif isinstance(f, gzip.GzipFile):
<ide> # cast to our GzipFile if its already a gzip.GzipFile
<del> g = GzipFile(fileobj=f.fileobj)
<del> g.name = f.name
<del> g.mode = f.mode
<ide>
<del> f = g
<add> try:
<add> name = f.name
<add> except AttributeError:
<add> # Backward compatibility for <= 2.5
<add> name = f.filename
<add> mode = f.mode
<add>
<add> f = GzipFile(fileobj=f.fileobj, filename=name)
<add> f.mode = mode
<ide>
<ide> return f
<ide>
| 1
|
Text
|
Text
|
update challengetype 10 to hidden
|
cdabd9073691d949d6d35076a92e306a07399a96
|
<ide><path>curriculum/challenges/english/07-scientific-computing-with-python/scientific-computing-with-python-projects/arithmetic-formatter.english.md
<ide> id: 5e44412c903586ffb414c94c
<ide> title: Arithmetic Formatter
<ide> challengeType: 10
<add>isHidden: true
<ide> isRequired: true
<ide> ---
<ide>
<ide> We are still developing the interactive instructional part of the Python curricu
<ide> </li>
<ide> <li>
<ide> <a href='https://www.freecodecamp.org/news/learn-python-basics-in-depth-video-course/'>Learn Python Video Course</a> (2 hours)
<del> </li>
<add> </li>
<ide> <ul>
<ide>
<ide> </section>
<ide> tests:
<ide>
<ide> ```js
<ide> /**
<del> Backend challenges don't need solutions,
<del> because they would need to be tested against a full working project.
<add> Backend challenges don't need solutions,
<add> because they would need to be tested against a full working project.
<ide> Please check our contributing guidelines to learn more.
<ide> */
<ide> ```
<ide><path>curriculum/challenges/english/07-scientific-computing-with-python/scientific-computing-with-python-projects/budget-app.english.md
<ide> id: 5e44413e903586ffb414c94e
<ide> title: Budget App
<ide> challengeType: 10
<add>isHidden: true
<ide> isRequired: true
<ide> ---
<ide>
<ide> We are still developing the interactive instructional part of the Python curricu
<ide> </li>
<ide> <li>
<ide> <a href='https://www.freecodecamp.org/news/learn-python-basics-in-depth-video-course/'>Learn Python Video Course</a> (2 hours)
<del> </li>
<add> </li>
<ide> <ul>
<ide>
<ide> </section>
<ide> tests:
<ide>
<ide> ```js
<ide> /**
<del> Backend challenges don't need solutions,
<del> because they would need to be tested against a full working project.
<add> Backend challenges don't need solutions,
<add> because they would need to be tested against a full working project.
<ide> Please check our contributing guidelines to learn more.
<ide> */
<ide> ```
<ide><path>curriculum/challenges/english/07-scientific-computing-with-python/scientific-computing-with-python-projects/polygon-area-calculator.english.md
<ide> id: 5e444147903586ffb414c94f
<ide> title: Polygon Area Calculator
<ide> challengeType: 10
<add>isHidden: true
<ide> isRequired: true
<ide> ---
<ide>
<ide> We are still developing the interactive instructional part of the Python curricu
<ide> </li>
<ide> <li>
<ide> <a href='https://www.freecodecamp.org/news/learn-python-basics-in-depth-video-course/'>Learn Python Video Course</a> (2 hours)
<del> </li>
<add> </li>
<ide> <ul>
<ide>
<ide> </section>
<ide> tests:
<ide>
<ide> ```js
<ide> /**
<del> Backend challenges don't need solutions,
<del> because they would need to be tested against a full working project.
<add> Backend challenges don't need solutions,
<add> because they would need to be tested against a full working project.
<ide> Please check our contributing guidelines to learn more.
<ide> */
<ide> ```
<ide><path>curriculum/challenges/english/07-scientific-computing-with-python/scientific-computing-with-python-projects/probability-calculator.english.md
<ide> id: 5e44414f903586ffb414c950
<ide> title: Probability Calculator
<ide> challengeType: 10
<add>isHidden: true
<ide> isRequired: true
<ide> ---
<ide>
<ide> We are still developing the interactive instructional part of the Python curricu
<ide> </li>
<ide> <li>
<ide> <a href='https://www.freecodecamp.org/news/learn-python-basics-in-depth-video-course/'>Learn Python Video Course</a> (2 hours)
<del> </li>
<add> </li>
<ide> <ul>
<ide>
<ide> </section>
<ide> tests:
<ide>
<ide> ```js
<ide> /**
<del> Backend challenges don't need solutions,
<del> because they would need to be tested against a full working project.
<add> Backend challenges don't need solutions,
<add> because they would need to be tested against a full working project.
<ide> Please check our contributing guidelines to learn more.
<ide> */
<ide> ```
<ide><path>curriculum/challenges/english/07-scientific-computing-with-python/scientific-computing-with-python-projects/time-calculator.english.md
<ide> id: 5e444136903586ffb414c94d
<ide> title: Time Calculator
<ide> challengeType: 10
<add>isHidden: true
<ide> isRequired: true
<ide> ---
<ide>
<ide> We are still developing the interactive instructional part of the Python curricu
<ide> </li>
<ide> <li>
<ide> <a href='https://www.freecodecamp.org/news/learn-python-basics-in-depth-video-course/'>Learn Python Video Course</a> (2 hours)
<del> </li>
<add> </li>
<ide> <ul>
<ide>
<ide> </section>
<ide> tests:
<ide>
<ide> ```js
<ide> /**
<del> Backend challenges don't need solutions,
<del> because they would need to be tested against a full working project.
<add> Backend challenges don't need solutions,
<add> because they would need to be tested against a full working project.
<ide> Please check our contributing guidelines to learn more.
<ide> */
<ide> ```
<ide><path>curriculum/challenges/english/08-data-analysis-with-python/data-analysis-with-python-projects/demographic-data-analyzer.english.md
<ide> id: 5e46f7e5ac417301a38fb929
<ide> title: Demographic Data Analyzer
<ide> challengeType: 10
<add>isHidden: true
<ide> isRequired: true
<ide> ---
<ide>
<ide> tests:
<ide> <section id='solution'>
<ide>
<ide> ```py
<del> # Python challenges don't need solutions,
<del> # because they would need to be tested against a full working project.
<add> # Python challenges don't need solutions,
<add> # because they would need to be tested against a full working project.
<ide> # Please check our contributing guidelines to learn more.
<ide> ```
<ide>
<ide><path>curriculum/challenges/english/08-data-analysis-with-python/data-analysis-with-python-projects/mean-variance-standard-deviation-calculator.english.md
<ide> id: 5e46f7e5ac417301a38fb928
<ide> title: Mean-Variance-Standard Deviation Calculator
<ide> challengeType: 10
<add>isHidden: true
<ide> isRequired: true
<ide> ---
<ide>
<ide> tests:
<ide> <section id='solution'>
<ide>
<ide> ```py
<del> # Python challenges don't need solutions,
<del> # because they would need to be tested against a full working project.
<add> # Python challenges don't need solutions,
<add> # because they would need to be tested against a full working project.
<ide> # Please check our contributing guidelines to learn more.
<ide> ```
<ide>
<ide><path>curriculum/challenges/english/08-data-analysis-with-python/data-analysis-with-python-projects/medical-data-visualizer.english.md
<ide> id: 5e46f7f8ac417301a38fb92a
<ide> title: Medical Data Visualizer
<ide> challengeType: 10
<add>isHidden: true
<ide> isRequired: true
<ide> ---
<ide>
<ide> tests:
<ide> <section id='solution'>
<ide>
<ide> ```py
<del> # Python challenges don't need solutions,
<del> # because they would need to be tested against a full working project.
<add> # Python challenges don't need solutions,
<add> # because they would need to be tested against a full working project.
<ide> # Please check our contributing guidelines to learn more.
<ide> ```
<ide>
<ide><path>curriculum/challenges/english/08-data-analysis-with-python/data-analysis-with-python-projects/page-view-time-series-visualizer.english.md
<ide> id: 5e46f802ac417301a38fb92b
<ide> title: Page View Time Series Visualizer
<ide> challengeType: 10
<add>isHidden: true
<ide> isRequired: true
<ide> ---
<ide>
<ide> tests:
<ide> <section id='solution'>
<ide>
<ide> ```py
<del> # Python challenges don't need solutions,
<del> # because they would need to be tested against a full working project.
<add> # Python challenges don't need solutions,
<add> # because they would need to be tested against a full working project.
<ide> # Please check our contributing guidelines to learn more.
<ide> ```
<ide>
<ide><path>curriculum/challenges/english/08-data-analysis-with-python/data-analysis-with-python-projects/sea-level-predictor.english.md
<ide> id: 5e4f5c4b570f7e3a4949899f
<ide> title: Sea Level Predictor
<ide> challengeType: 10
<add>isHidden: true
<ide> isRequired: true
<ide> ---
<ide>
<ide> tests:
<ide> <section id='solution'>
<ide>
<ide> ```py
<del> # Python challenges don't need solutions,
<del> # because they would need to be tested against a full working project.
<add> # Python challenges don't need solutions,
<add> # because they would need to be tested against a full working project.
<ide> # Please check our contributing guidelines to learn more.
<ide> ```
<ide>
<ide><path>curriculum/challenges/english/09-information-security/information-security-projects/port-scanner.english.md
<ide> id: 5e46f979ac417301a38fb932
<ide> title: Port Scanner
<ide> challengeType: 10
<add>isHidden: true
<ide> isRequired: true
<ide> ---
<ide>
<ide> We are still developing the interactive instructional part of the Python curricu
<ide> </li>
<ide> <li>
<ide> <a href='https://www.freecodecamp.org/news/learn-python-basics-in-depth-video-course/'>Learn Python Video Course</a> (2 hours)
<del> </li>
<add> </li>
<ide> <ul>
<ide>
<ide> </section>
<ide> tests:
<ide> <section id='solution'>
<ide>
<ide> ```py
<del> # Python challenges don't need solutions,
<del> # because they would need to be tested against a full working project.
<add> # Python challenges don't need solutions,
<add> # because they would need to be tested against a full working project.
<ide> # Please check our contributing guidelines to learn more.
<ide> ```
<ide>
<ide><path>curriculum/challenges/english/09-information-security/information-security-projects/sha-1-password-cracker.english.md
<ide> id: 5e46f983ac417301a38fb933
<ide> title: SHA-1 Password Cracker
<ide> challengeType: 10
<add>isHidden: true
<ide> isRequired: true
<ide> ---
<ide>
<ide> We are still developing the interactive instructional part of the Python curricu
<ide> </li>
<ide> <li>
<ide> <a href='https://www.freecodecamp.org/news/learn-python-basics-in-depth-video-course/'>Learn Python Video Course</a> (2 hours)
<del> </li>
<add> </li>
<ide> <ul>
<ide> </section>
<ide>
<ide> tests:
<ide> <section id='solution'>
<ide>
<ide> ```py
<del> # Python challenges don't need solutions,
<del> # because they would need to be tested against a full working project.
<add> # Python challenges don't need solutions,
<add> # because they would need to be tested against a full working project.
<ide> # Please check our contributing guidelines to learn more.
<ide> ```
<ide>
<ide><path>curriculum/challenges/english/11-machine-learning-with-python/machine-learning-with-python-projects/book-recommendation-engine-using-knn.english.md
<ide> id: 5e46f8e3ac417301a38fb92f
<ide> title: Book Recommendation Engine using KNN
<ide> challengeType: 10
<add>isHidden: true
<ide> isRequired: true
<ide> ---
<ide>
<ide> In this challenge, you will create a book recommendation algorithm using K-Neare
<ide>
<ide> You will use the Book-Crossings dataset. This dataset contains 1.1 million ratings (scale of 1-10) of 270,000 books by 90,000 users.
<ide>
<del>You can access <a href='https://colab.research.google.com/drive/1TDgXyXqZwsiGlnuF-bmQ2Rh3x5NcrHEn' target='_blank'>the full project instructions and starter code on Google Colaboratory</a>.
<add>You can access <a href='https://colab.research.google.com/drive/1TDgXyXqZwsiGlnuF-bmQ2Rh3x5NcrHEn' target='_blank'>the full project instructions and starter code on Google Colaboratory</a>.
<ide>
<ide> After going to that link, create a copy of the notebook either in your own account or locally. Once you complete the project and it passes the test (included at that link), submit your project link below. If you are submitting a Google Colaboratory link, make sure to turn on link sharing for "anyone with the link."
<ide>
<ide> We are still developing the interactive instructional content for the machine le
<ide> </li>
<ide> <li>
<ide> <a href='https://www.youtube.com/playlist?list=PLWKjhJtqVAblStefaz_YOVpDWqcRScc2s'>Machine learning playlist</a>
<del> </li>
<add> </li>
<ide> <ul>
<ide>
<ide> </section>
<ide> tests:
<ide> <section id='solution'>
<ide>
<ide> ```py
<del> # Python challenges don't need solutions,
<del> # because they would need to be tested against a full working project.
<add> # Python challenges don't need solutions,
<add> # because they would need to be tested against a full working project.
<ide> # Please check our contributing guidelines to learn more.
<ide> ```
<ide>
<ide><path>curriculum/challenges/english/11-machine-learning-with-python/machine-learning-with-python-projects/cat-and-dog-image-classifier.english.md
<ide> id: 5e46f8dcac417301a38fb92e
<ide> title: Cat and Dog Image Classifier
<ide> challengeType: 10
<add>isHidden: true
<ide> isRequired: true
<ide> ---
<ide>
<ide> We are still developing the interactive instructional content for the machine le
<ide> </li>
<ide> <li>
<ide> <a href='https://www.youtube.com/playlist?list=PLWKjhJtqVAblStefaz_YOVpDWqcRScc2s'>Machine learning playlist</a>
<del> </li>
<add> </li>
<ide> <ul>
<ide>
<ide> </section>
<ide> tests:
<ide> <section id='solution'>
<ide>
<ide> ```py
<del> # Python challenges don't need solutions,
<del> # because they would need to be tested against a full working project.
<add> # Python challenges don't need solutions,
<add> # because they would need to be tested against a full working project.
<ide> # Please check our contributing guidelines to learn more.
<ide> ```
<ide>
<ide><path>curriculum/challenges/english/11-machine-learning-with-python/machine-learning-with-python-projects/linear-regression-health-costs-calculator.english.md
<ide> id: 5e46f8edac417301a38fb930
<ide> title: Linear Regression Health Costs Calculator
<ide> challengeType: 10
<add>isHidden: true
<ide> isRequired: true
<ide> ---
<ide>
<ide> We are still developing the interactive instructional content for the machine le
<ide> </li>
<ide> <li>
<ide> <a href='https://www.youtube.com/playlist?list=PLWKjhJtqVAblStefaz_YOVpDWqcRScc2s'>Machine learning playlist</a>
<del> </li>
<add> </li>
<ide> <ul>
<ide>
<ide> </section>
<ide> tests:
<ide> <section id='solution'>
<ide>
<ide> ```py
<del> # Python challenges don't need solutions,
<del> # because they would need to be tested against a full working project.
<add> # Python challenges don't need solutions,
<add> # because they would need to be tested against a full working project.
<ide> # Please check our contributing guidelines to learn more.
<ide> ```
<ide>
<ide><path>curriculum/challenges/english/11-machine-learning-with-python/machine-learning-with-python-projects/neural-network-sms-text-classifier.md
<ide> id: 5e46f8edac417301a38fb931
<ide> title: Neural Network SMS Text Classifier
<ide> challengeType: 10
<add>isHidden: true
<ide> isRequired: true
<ide> ---
<ide>
<ide> We are still developing the interactive instructional content for the machine le
<ide> </li>
<ide> <li>
<ide> <a href='https://www.youtube.com/playlist?list=PLWKjhJtqVAblStefaz_YOVpDWqcRScc2s'>Machine learning playlist</a>
<del> </li>
<add> </li>
<ide> <ul>
<ide>
<ide> </section>
<ide> tests:
<ide> <section id='solution'>
<ide>
<ide> ```py
<del> # Python challenges don't need solutions,
<del> # because they would need to be tested against a full working project.
<add> # Python challenges don't need solutions,
<add> # because they would need to be tested against a full working project.
<ide> # Please check our contributing guidelines to learn more.
<ide> ```
<ide>
<ide><path>curriculum/challenges/english/11-machine-learning-with-python/machine-learning-with-python-projects/rock-paper-scissors.english.md
<ide> id: 5e46f8d6ac417301a38fb92d
<ide> title: Rock Paper Scissors
<ide> challengeType: 10
<add>isHidden: true
<ide> isRequired: true
<ide> ---
<ide>
<ide> tests:
<ide> <section id='solution'>
<ide>
<ide> ```py
<del> # Python challenges don't need solutions,
<del> # because they would need to be tested against a full working project.
<add> # Python challenges don't need solutions,
<add> # because they would need to be tested against a full working project.
<ide> # Please check our contributing guidelines to learn more.
<ide> ```
<ide>
| 17
|
Javascript
|
Javascript
|
remove unused {@installmodule} tags
|
cc1f7539d414038212b83dca86cf04f71731f24b
|
<ide><path>src/ngAnimate/animate.js
<ide> *
<ide> * The `ngAnimate` module provides support for JavaScript, CSS3 transition and CSS3 keyframe animation hooks within existing core and custom directives.
<ide> *
<del> * {@installModule animate}
<ide> *
<ide> * <div doc-module-components="ngAnimate"></div>
<ide> *
<ide><path>src/ngCookies/cookies.js
<ide> *
<ide> * The `ngCookies` module provides a convenient wrapper for reading and writing browser cookies.
<ide> *
<del> * {@installModule cookies}
<ide> *
<ide> * <div doc-module-components="ngCookies"></div>
<ide> *
<ide><path>src/ngMock/angular-mocks.js
<ide> angular.mock.$RootElementProvider = function() {
<ide> * In addition, ngMock also extends various core ng services such that they can be
<ide> * inspected and controlled in a synchronous manner within test code.
<ide> *
<del> * {@installModule mock}
<ide> *
<ide> * <div doc-module-components="ngMock"></div>
<ide> *
<ide><path>src/ngResource/resource.js
<ide> function shallowClearAndCopy(src, dst) {
<ide> * The `ngResource` module provides interaction support with RESTful services
<ide> * via the $resource service.
<ide> *
<del> * {@installModule resource}
<ide> *
<ide> * <div doc-module-components="ngResource"></div>
<ide> *
<ide><path>src/ngRoute/route.js
<ide> * ## Example
<ide> * See {@link ngRoute.$route#example $route} for an example of configuring and using `ngRoute`.
<ide> *
<del> * {@installModule route}
<ide> *
<ide> * <div doc-module-components="ngRoute"></div>
<ide> */
<ide><path>src/ngSanitize/sanitize.js
<ide> var $sanitizeMinErr = angular.$$minErr('$sanitize');
<ide> *
<ide> * The `ngSanitize` module provides functionality to sanitize HTML.
<ide> *
<del> * {@installModule sanitize}
<ide> *
<ide> * <div doc-module-components="ngSanitize"></div>
<ide> *
<ide><path>src/ngTouch/touch.js
<ide> * The implementation is based on jQuery Mobile touch event handling
<ide> * ([jquerymobile.com](http://jquerymobile.com/)).
<ide> *
<del> * {@installModule touch}
<ide> *
<ide> * See {@link ngTouch.$swipe `$swipe`} for usage.
<ide> *
| 7
|
Python
|
Python
|
add reconcile_metadata to reconcile_pods
|
3c374a42c0d123fc3af9559e15515fd6a4e8430c
|
<ide><path>airflow/kubernetes/pod_generator.py
<ide> def reconcile_pods(base_pod: k8s.V1Pod, client_pod: Optional[k8s.V1Pod]) -> k8s.
<ide>
<ide> client_pod_cp = copy.deepcopy(client_pod)
<ide> client_pod_cp.spec = PodGenerator.reconcile_specs(base_pod.spec, client_pod_cp.spec)
<del>
<del> client_pod_cp.metadata = merge_objects(base_pod.metadata, client_pod_cp.metadata)
<add> client_pod_cp.metadata = PodGenerator.reconcile_metadata(base_pod.metadata, client_pod_cp.metadata)
<ide> client_pod_cp = merge_objects(base_pod, client_pod_cp)
<ide>
<ide> return client_pod_cp
<ide>
<add> @staticmethod
<add> def reconcile_metadata(base_meta, client_meta):
<add> """
<add> Merge kubernetes Metadata objects
<add> :param base_meta: has the base attributes which are overwritten if they exist
<add> in the client_meta and remain if they do not exist in the client_meta
<add> :type base_meta: k8s.V1ObjectMeta
<add> :param client_meta: the spec that the client wants to create.
<add> :type client_meta: k8s.V1ObjectMeta
<add> :return: the merged specs
<add> """
<add> if base_meta and not client_meta:
<add> return base_meta
<add> if not base_meta and client_meta:
<add> return client_meta
<add> elif client_meta and base_meta:
<add> client_meta.labels = merge_objects(base_meta.labels, client_meta.labels)
<add> client_meta.annotations = merge_objects(base_meta.annotations, client_meta.annotations)
<add> extend_object_field(base_meta, client_meta, 'managed_fields')
<add> extend_object_field(base_meta, client_meta, 'finalizers')
<add> extend_object_field(base_meta, client_meta, 'owner_references')
<add> return merge_objects(base_meta, client_meta)
<add>
<add> return None
<add>
<ide> @staticmethod
<ide> def reconcile_specs(base_spec: Optional[k8s.V1PodSpec],
<ide> client_spec: Optional[k8s.V1PodSpec]) -> Optional[k8s.V1PodSpec]:
<ide> def merge_objects(base_obj, client_obj):
<ide>
<ide> client_obj_cp = copy.deepcopy(client_obj)
<ide>
<add> if isinstance(base_obj, dict) and isinstance(client_obj_cp, dict):
<add> client_obj_cp.update(base_obj)
<add> return client_obj_cp
<add>
<ide> for base_key in base_obj.to_dict().keys():
<ide> base_val = getattr(base_obj, base_key, None)
<ide> if not getattr(client_obj, base_key, None) and base_val:
<del> setattr(client_obj_cp, base_key, base_val)
<add> if not isinstance(client_obj_cp, dict):
<add> setattr(client_obj_cp, base_key, base_val)
<add> else:
<add> client_obj_cp[base_key] = base_val
<ide> return client_obj_cp
<ide>
<ide>
<ide><path>tests/kubernetes/test_pod_generator.py
<ide> def test_reconcile_pods(self, mock_uuid):
<ide> 'hostPath': {'path': '/tmp/'},
<ide> 'name': 'example-kubernetes-test-volume1'
<ide> }],
<add> labels={"foo": "bar"},
<ide> volume_mounts=[{
<ide> 'mountPath': '/foo/',
<ide> 'name': 'example-kubernetes-test-volume1'
<ide> def test_reconcile_pods(self, mock_uuid):
<ide> envs={'key2': 'val2'},
<ide> image='',
<ide> name='name2',
<add> labels={"bar": "baz"},
<ide> cmds=['/bin/command2.sh', 'arg2'],
<ide> volumes=[{
<ide> 'hostPath': {'path': '/tmp/'},
<ide> def test_reconcile_pods(self, mock_uuid):
<ide> self.assertEqual({
<ide> 'apiVersion': 'v1',
<ide> 'kind': 'Pod',
<del> 'metadata': {'name': 'name2-' + self.static_uuid.hex},
<add> 'metadata': {'name': 'name2-' + self.static_uuid.hex,
<add> 'labels': {'foo': 'bar', "bar": "baz"}},
<ide> 'spec': {
<ide> 'containers': [{
<ide> 'args': [],
| 2
|
Go
|
Go
|
move authconfig to registry types
|
818ee962196d668b6d405835c88c1ac6cdab7423
|
<ide><path>api/types/auth.go
<ide> package types // import "github.com/docker/docker/api/types"
<add>import "github.com/docker/docker/api/types/registry"
<ide>
<del>// AuthConfig contains authorization information for connecting to a Registry
<del>type AuthConfig struct {
<del> Username string `json:"username,omitempty"`
<del> Password string `json:"password,omitempty"`
<del> Auth string `json:"auth,omitempty"`
<del>
<del> // Email is an optional value associated with the username.
<del> // This field is deprecated and will be removed in a later
<del> // version of docker.
<del> Email string `json:"email,omitempty"`
<del>
<del> ServerAddress string `json:"serveraddress,omitempty"`
<del>
<del> // IdentityToken is used to authenticate the user and get
<del> // an access token for the registry.
<del> IdentityToken string `json:"identitytoken,omitempty"`
<del>
<del> // RegistryToken is a bearer token to be sent to a registry
<del> RegistryToken string `json:"registrytoken,omitempty"`
<del>}
<add>// AuthConfig contains authorization information for connecting to a Registry.
<add>//
<add>// Deprecated: use github.com/docker/docker/api/types/registry.AuthConfig
<add>type AuthConfig = registry.AuthConfig
<ide><path>api/types/backend/build.go
<ide> import (
<ide> "io"
<ide>
<ide> "github.com/docker/docker/api/types"
<add> "github.com/docker/docker/api/types/registry"
<ide> "github.com/docker/docker/pkg/streamformatter"
<ide> specs "github.com/opencontainers/image-spec/specs-go/v1"
<ide> )
<ide> type BuildConfig struct {
<ide> // GetImageAndLayerOptions are the options supported by GetImageAndReleasableLayer
<ide> type GetImageAndLayerOptions struct {
<ide> PullOption PullOption
<del> AuthConfig map[string]types.AuthConfig
<add> AuthConfig map[string]registry.AuthConfig
<ide> Output io.Writer
<ide> Platform *specs.Platform
<ide> }
<ide><path>api/types/client.go
<ide> import (
<ide>
<ide> "github.com/docker/docker/api/types/container"
<ide> "github.com/docker/docker/api/types/filters"
<add> "github.com/docker/docker/api/types/registry"
<ide> units "github.com/docker/go-units"
<ide> )
<ide>
<ide> type ImageBuildOptions struct {
<ide> // at all (nil). See the parsing of buildArgs in
<ide> // api/server/router/build/build_routes.go for even more info.
<ide> BuildArgs map[string]*string
<del> AuthConfigs map[string]AuthConfig
<add> AuthConfigs map[string]registry.AuthConfig
<ide> Context io.Reader
<ide> Labels map[string]string
<ide> // squash the resulting image's layers to the parent
<ide><path>api/types/registry/authconfig.go
<ide> package registry // import "github.com/docker/docker/api/types/registry"
<ide> // AuthHeader is the name of the header used to send encoded registry
<ide> // authorization credentials for registry operations (push/pull).
<ide> const AuthHeader = "X-Registry-Auth"
<add>
<add>// AuthConfig contains authorization information for connecting to a Registry.
<add>type AuthConfig struct {
<add> Username string `json:"username,omitempty"`
<add> Password string `json:"password,omitempty"`
<add> Auth string `json:"auth,omitempty"`
<add>
<add> // Email is an optional value associated with the username.
<add> // This field is deprecated and will be removed in a later
<add> // version of docker.
<add> Email string `json:"email,omitempty"`
<add>
<add> ServerAddress string `json:"serveraddress,omitempty"`
<add>
<add> // IdentityToken is used to authenticate the user and get
<add> // an access token for the registry.
<add> IdentityToken string `json:"identitytoken,omitempty"`
<add>
<add> // RegistryToken is a bearer token to be sent to a registry
<add> RegistryToken string `json:"registrytoken,omitempty"`
<add>}
| 4
|
Ruby
|
Ruby
|
add `formatter` module
|
75e8b59aad4814112a53119f68ed629d60b3f97b
|
<ide><path>Library/Homebrew/brew.rb
<ide> def require?(path)
<ide> Utils::Analytics.report_exception(e)
<ide> onoe e
<ide> if internal_cmd && defined?(OS::ISSUES_URL)
<del> $stderr.puts "Please report this bug:"
<del> $stderr.puts " #{Tty.underline}#{OS::ISSUES_URL}#{Tty.reset}"
<add> $stderr.puts "#{Tty.bold}Please report this bug:#{Tty.reset}"
<add> $stderr.puts " #{Formatter.url(OS::ISSUES_URL)}"
<ide> end
<ide> $stderr.puts e.backtrace
<ide> exit 1
<ide><path>Library/Homebrew/cask/lib/hbc/artifact/moved.rb
<ide> def summarize_artifact(artifact_spec)
<ide> load_specification artifact_spec
<ide>
<ide> if target.exist?
<del> target_abv = " (#{target.abv})"
<add> "#{printable_target} (#{target.abv})"
<ide> else
<del> error = "#{Tty.red}Missing #{self.class.artifact_english_name}:#{Tty.reset} "
<add> Formatter.error(printable_target, label: "Missing #{self.class.artifact_english_name}")
<ide> end
<del>
<del> "#{error}#{printable_target}#{target_abv}"
<ide> end
<ide> end
<ide> end
<ide><path>Library/Homebrew/cask/lib/hbc/artifact/symlinked.rb
<ide> def create_filesystem_link(source, target)
<ide> def summarize_artifact(artifact_spec)
<ide> load_specification artifact_spec
<ide>
<del> return unless self.class.islink?(target)
<del>
<del> link_description = "#{Tty.red}Broken Link#{Tty.reset}: " unless target.exist?
<del> target_readlink_abv = " (#{target.readlink.abv})" if target.readlink.exist?
<add> if self.class.islink?(target) && target.exist? && target.readlink.exist?
<add> "#{printable_target} -> #{target.readlink} (#{target.readlink.abv})"
<add> else
<add> string = if self.class.islink?(target)
<add> "#{printable_target} -> #{target.readlink}"
<add> else
<add> printable_target
<add> end
<ide>
<del> "#{link_description}#{printable_target} -> #{target.readlink}#{target_readlink_abv}"
<add> Formatter.error(string, label: "Broken Link")
<add> end
<ide> end
<ide> end
<ide> end
<ide><path>Library/Homebrew/cask/lib/hbc/checkable.rb
<ide> def warnings?
<ide>
<ide> def result
<ide> if errors?
<del> "#{Tty.red}failed#{Tty.reset}"
<add> Formatter.error("failed")
<ide> elsif warnings?
<del> "#{Tty.yellow}warning#{Tty.reset}"
<add> Formatter.warning("warning")
<ide> else
<del> "#{Tty.green}passed#{Tty.reset}"
<add> Formatter.success("passed")
<ide> end
<ide> end
<ide>
<ide> def summary
<ide> summary = ["#{summary_header}: #{result}"]
<ide>
<ide> errors.each do |error|
<del> summary << " #{Tty.red}-#{Tty.reset} #{error}"
<add> summary << " #{Formatter.error("-")} #{error}"
<ide> end
<ide>
<ide> warnings.each do |warning|
<del> summary << " #{Tty.yellow}-#{Tty.reset} #{warning}"
<add> summary << " #{Formatter.warning("-")} #{warning}"
<ide> end
<ide>
<ide> summary.join("\n")
<ide><path>Library/Homebrew/cask/lib/hbc/cli/doctor.rb
<ide> def self.legacy_tap_pattern
<ide> end
<ide>
<ide> def self.notfound_string
<del> "#{Tty.red}Not Found - Unknown Error#{Tty.reset}"
<add> Formatter.error("Not Found - Unknown Error")
<ide> end
<ide>
<ide> def self.error_string(string = "Error")
<del> "#{Tty.red}(#{string})#{Tty.reset}"
<add> Formatter.error("(#{string})")
<ide> end
<ide>
<ide> def self.render_with_none(string)
<ide><path>Library/Homebrew/cask/lib/hbc/cli/info.rb
<ide> def self.help
<ide>
<ide> def self.info(cask)
<ide> puts "#{cask.token}: #{cask.version}"
<del> puts formatted_url(cask.homepage) if cask.homepage
<add> puts Formatter.url(cask.homepage) if cask.homepage
<ide> installation_info(cask)
<del> puts "From: #{formatted_url(github_info(cask))}" if github_info(cask)
<add> puts "From: #{Formatter.url(github_info(cask))}" if github_info(cask)
<ide> name_info(cask)
<ide> artifact_info(cask)
<ide> Installer.print_caveats(cask)
<ide> def self.installation_info(cask)
<ide>
<ide> puts versioned_staged_path.to_s
<ide> .concat(" (")
<del> .concat(versioned_staged_path.exist? ? versioned_staged_path.abv : "#{Tty.red}does not exist#{Tty.reset}")
<add> .concat(versioned_staged_path.exist? ? versioned_staged_path.abv : Formatter.error("does not exist"))
<ide> .concat(")")
<ide> end
<ide> else
<ide> def self.installation_info(cask)
<ide>
<ide> def self.name_info(cask)
<ide> ohai cask.name.size > 1 ? "Names" : "Name"
<del> puts cask.name.empty? ? "#{Tty.red}None#{Tty.reset}" : cask.name
<add> puts cask.name.empty? ? Formatter.error("None") : cask.name
<ide> end
<ide>
<ide> def self.github_info(cask)
<ide><path>Library/Homebrew/cask/lib/hbc/installer.rb
<ide> def summary
<ide> s = if MacOS.version >= :lion && !ENV["HOMEBREW_NO_EMOJI"]
<ide> (ENV["HOMEBREW_INSTALL_BADGE"] || "\xf0\x9f\x8d\xba") + " "
<ide> else
<del> "#{Tty.blue}==>#{Tty.reset} #{Tty.bold}Success!#{Tty.reset} "
<add> Formatter.headline("Success! ", color: :blue)
<ide> end
<ide> s << "#{@cask} was successfully installed!"
<ide> end
<ide><path>Library/Homebrew/cask/lib/hbc/utils.rb
<ide> def tty?
<ide> def odebug(title, *sput)
<ide> return unless Hbc.respond_to?(:debug)
<ide> return unless Hbc.debug
<del> puts "#{Tty.magenta}==>#{Tty.reset} #{Tty.white}#{title}#{Tty.reset}"
<add> puts Formatter.headline(title, color: :magenta)
<ide> puts sput unless sput.empty?
<ide> end
<ide>
<ide> def self.path_occupied?(path)
<ide> def self.error_message_with_suggestions
<ide> <<-EOS.undent
<ide> Most likely, this means you have an outdated version of Homebrew-Cask. Please run:
<del>
<del> #{Tty.green}#{UPDATE_CMD}#{Tty.reset}
<add> #{UPDATE_CMD}
<ide>
<ide> If this doesn’t fix the problem, please report this bug:
<del>
<del> #{Tty.underline}#{ISSUES_URL}#{Tty.reset}
<add> #{Formatter.url(ISSUES_URL)}
<ide>
<ide> EOS
<ide> end
<ide><path>Library/Homebrew/cmd/doctor.rb
<ide> def doctor
<ide> next if out.nil? || out.empty?
<ide> if first_warning
<ide> $stderr.puts <<-EOS.undent
<del> #{Tty.bold}Please note that these warnings are just used to help the Homebrew maintainers
<del> with debugging if you file an issue. If everything you use Homebrew for is
<del> working fine: please don't worry and just ignore them. Thanks!#{Tty.reset}
<add> #{Tty.bold}Please note that these warnings are just used to help the Homebrew maintainers
<add> with debugging if you file an issue. If everything you use Homebrew for is
<add> working fine: please don't worry and just ignore them. Thanks!#{Tty.reset}
<ide> EOS
<ide> end
<ide>
<ide><path>Library/Homebrew/cmd/info.rb
<ide> def info_formula(f)
<ide>
<ide> puts "#{f.full_name}: #{specs * ", "}#{" [#{attrs * ", "}]" unless attrs.empty?}"
<ide> puts f.desc if f.desc
<del> puts "#{Tty.underline}#{f.homepage}#{Tty.reset}" if f.homepage
<add> puts Formatter.url(f.homepage) if f.homepage
<ide>
<ide> conflicts = f.conflicts.map(&:name).sort!
<ide> puts "Conflicts with: #{conflicts*", "}" unless conflicts.empty?
<ide> def info_formula(f)
<ide> end
<ide> end
<ide>
<del> puts "From: #{Tty.underline}#{github_info(f)}#{Tty.reset}"
<add> puts "From: #{Formatter.url(github_info(f))}"
<ide>
<ide> unless f.deps.empty?
<ide> ohai "Dependencies"
<ide><path>Library/Homebrew/descriptions.rb
<ide> def initialize(descriptions)
<ide> # Take search results -- a hash mapping formula names to descriptions -- and
<ide> # print them.
<ide> def print
<del> blank = "#{Tty.yellow}[no description]#{Tty.reset}"
<add> blank = Formatter.warning("[no description]")
<ide> @descriptions.keys.sort.each do |full_name|
<ide> short_name = short_names[full_name]
<ide> printed_name = short_name_counts[short_name] == 1 ? short_name : full_name
<ide><path>Library/Homebrew/dev-cmd/bottle.rb
<ide> def print_filename(string, filename)
<ide>
<ide> return if @put_filenames.include? filename
<ide>
<del> puts "#{Tty.red}#{filename}#{Tty.reset}"
<add> puts Formatter.error(filename.to_s)
<ide> @put_filenames << filename
<ide> end
<ide>
<ide><path>Library/Homebrew/exceptions.rb
<ide> def fetch_issues
<ide> def dump
<ide> if !ARGV.verbose?
<ide> puts
<del> puts "#{Tty.red.underline}READ THIS#{Tty.reset.red}:#{Tty.reset} #{Tty.underline}#{OS::ISSUES_URL}#{Tty.reset}"
<add> puts Formatter.error("READ THIS: #{Formatter.url(OS::ISSUES_URL)}")
<ide> if formula.tap
<ide> case formula.tap.name
<ide> when "homebrew/boneyard"
<ide><path>Library/Homebrew/formula_installer.rb
<ide> def install
<ide> opoo "#{formula.full_name}: #{old_flag} was deprecated; using #{new_flag} instead!"
<ide> end
<ide>
<del> oh1 "Installing #{Tty.green}#{formula.full_name}#{Tty.reset}" if show_header?
<add> oh1 "Installing #{Formatter.identifier(formula.full_name)}" if show_header?
<ide>
<ide> if formula.tap && !formula.tap.private?
<ide> options = []
<ide> def install_dependencies(deps)
<ide> if deps.empty? && only_deps?
<ide> puts "All dependencies for #{formula.full_name} are satisfied."
<ide> elsif !deps.empty?
<del> oh1 "Installing dependencies for #{formula.full_name}: #{Tty.green}#{deps.map(&:first)*", "}#{Tty.reset}",
<add> oh1 "Installing dependencies for #{formula.full_name}: #{deps.map(&:first).map(&Formatter.method(:identifier)).join(", ")}",
<ide> truncate: false
<ide> deps.each { |dep, options| install_dependency(dep, options) }
<ide> end
<ide> def install_dependency(dep, inherited_options)
<ide> fi.verbose = verbose? && !quieter?
<ide> fi.debug = debug?
<ide> fi.prelude
<del> oh1 "Installing #{formula.full_name} dependency: #{Tty.green}#{dep.name}#{Tty.reset}"
<add> oh1 "Installing #{formula.full_name} dependency: #{Formatter.identifier(dep.name)}"
<ide> fi.install
<ide> fi.finish
<ide> rescue Exception
<ide><path>Library/Homebrew/migrator.rb
<ide> def migrate
<ide> end
<ide>
<ide> begin
<del> oh1 "Migrating #{Tty.green}#{oldname}#{Tty.reset} to #{Tty.green.bold}#{newname}#{Tty.reset}"
<add> oh1 "Migrating #{Formatter.identifier(oldname)} to #{Formatter.identifier(newname)}"
<ide> lock
<ide> unlink_oldname
<ide> move_to_new_directory
<ide> def repin
<ide> end
<ide>
<ide> def unlink_oldname
<del> oh1 "Unlinking #{Tty.green}#{oldname}#{Tty.reset}"
<add> oh1 "Unlinking #{Formatter.identifier(oldname)}"
<ide> old_cellar.subdirs.each do |d|
<ide> keg = Keg.new(d)
<ide> keg.unlink
<ide> end
<ide> end
<ide>
<ide> def link_newname
<del> oh1 "Linking #{Tty.green}#{newname}#{Tty.reset}"
<add> oh1 "Linking #{Formatter.identifier(newname)}"
<ide> new_keg = Keg.new(new_linked_keg_record)
<ide>
<ide> # If old_keg wasn't linked then we just optlink a keg.
<ide><path>Library/Homebrew/utils.rb
<ide> require "pathname"
<ide> require "emoji"
<ide> require "exceptions"
<add>require "utils/formatter"
<ide> require "utils/hash"
<ide> require "utils/json"
<ide> require "utils/inreplace"
<ide>
<ide> def ohai(title, *sput)
<ide> title = Tty.truncate(title) if $stdout.tty? && !ARGV.verbose?
<del> puts "#{Tty.blue}==>#{Tty.reset} #{Tty.bold}#{title}#{Tty.reset}"
<add> puts Formatter.headline(title, color: :blue)
<ide> puts sput
<ide> end
<ide>
<ide> def oh1(title, options = {})
<ide> if $stdout.tty? && !ARGV.verbose? && options.fetch(:truncate, :auto) == :auto
<ide> title = Tty.truncate(title)
<ide> end
<del> puts "#{Tty.green}==>#{Tty.reset} #{Tty.bold}#{title}#{Tty.reset}"
<add> puts Formatter.headline(title, color: :green)
<ide> end
<ide>
<ide> # Print a warning (do this rarely)
<del>def opoo(warning)
<del> $stderr.puts "#{Tty.yellow.underline}Warnin#{Tty.reset.yellow}g:#{Tty.reset} #{warning}"
<add>def opoo(message)
<add> $stderr.puts Formatter.warning(message, label: "Warning")
<ide> end
<ide>
<del>def onoe(error)
<del> $stderr.puts "#{Tty.red.underline}Error#{Tty.reset.red}:#{Tty.reset} #{error}"
<add>def onoe(message)
<add> $stderr.puts Formatter.error(message, label: "Error")
<ide> end
<ide>
<ide> def ofail(error)
<ide> def pretty_installed(f)
<ide> if !$stdout.tty?
<ide> f.to_s
<ide> elsif Emoji.enabled?
<del> "#{Tty.bold}#{f} #{Tty.green}#{Emoji.tick}#{Tty.reset}"
<add> "#{Tty.bold}#{f} #{Formatter.success(Emoji.tick)}#{Tty.reset}"
<ide> else
<del> "#{Tty.green.bold}#{f} (installed)#{Tty.reset}"
<add> Formatter.success("#{Tty.bold}#{f} (installed)#{Tty.reset}")
<ide> end
<ide> end
<ide>
<ide> def pretty_uninstalled(f)
<ide> if !$stdout.tty?
<ide> f.to_s
<ide> elsif Emoji.enabled?
<del> "#{Tty.bold}#{f} #{Tty.red}#{Emoji.cross}#{Tty.reset}"
<add> "#{Tty.bold}#{f} #{Formatter.error(Emoji.cross)}#{Tty.reset}"
<ide> else
<del> "#{Tty.red.bold}#{f} (uninstalled)#{Tty.reset}"
<add> Formatter.error("#{Tty.bold}#{f} (uninstalled)#{Tty.reset}")
<ide> end
<ide> end
<ide>
<ide><path>Library/Homebrew/utils/formatter.rb
<add>require "utils/tty"
<add>
<add>module Formatter
<add> module_function
<add>
<add> def arrow(string, color: nil)
<add> prefix("==>", string, color)
<add> end
<add>
<add> def headline(string, color: nil)
<add> arrow("#{Tty.bold}#{string}#{Tty.reset}", color: color)
<add> end
<add>
<add> def identifier(string)
<add> "#{Tty.green}#{string}#{Tty.reset}"
<add> end
<add>
<add> def success(string, label: nil)
<add> label(label, string, :green)
<add> end
<add>
<add> def warning(string, label: nil)
<add> label(label, string, :yellow)
<add> end
<add>
<add> def error(string, label: nil)
<add> label(label, string, :red)
<add> end
<add>
<add> def url(string)
<add> "#{Tty.underline}#{string}#{Tty.no_underline}"
<add> end
<add>
<add> def label(label, string, color)
<add> label = "#{label}:" unless label.nil?
<add> prefix(label, string, color)
<add> end
<add> private_class_method :label
<add>
<add> def prefix(prefix, string, color)
<add> if prefix.nil? && color.nil?
<add> string
<add> elsif prefix.nil?
<add> "#{Tty.send(color)}#{string}#{Tty.reset}"
<add> elsif color.nil?
<add> "#{prefix} #{string}"
<add> else
<add> "#{Tty.send(color)}#{prefix}#{Tty.reset} #{string}"
<add> end
<add> end
<add> private_class_method :prefix
<add>end
<ide><path>Library/Homebrew/utils/github.rb
<ide> def initialize(reset, error)
<ide> super <<-EOS.undent
<ide> GitHub API Error: #{error}
<ide> Try again in #{pretty_ratelimit_reset(reset)}, or create a personal access token:
<del> #{Tty.underline}https://github.com/settings/tokens/new?scopes=&description=Homebrew#{Tty.reset}
<add> #{Formatter.url("https://github.com/settings/tokens/new?scopes=&description=Homebrew")}
<ide> and then set the token as: export HOMEBREW_GITHUB_API_TOKEN="your_new_token"
<ide> EOS
<ide> end
<ide> def initialize(error)
<ide> if ENV["HOMEBREW_GITHUB_API_TOKEN"]
<ide> message << <<-EOS.undent
<ide> HOMEBREW_GITHUB_API_TOKEN may be invalid or expired; check:
<del> #{Tty.underline}https://github.com/settings/tokens#{Tty.reset}
<add> #{Formatter.url("https://github.com/settings/tokens")}
<ide> EOS
<ide> else
<ide> message << <<-EOS.undent
<ide> The GitHub credentials in the macOS keychain may be invalid.
<ide> Clear them with:
<ide> printf "protocol=https\\nhost=github.com\\n" | git credential-osxkeychain erase
<ide> Or create a personal access token:
<del> #{Tty.underline}https://github.com/settings/tokens/new?scopes=&description=Homebrew#{Tty.reset}
<add> #{Formatter.url("https://github.com/settings/tokens/new?scopes=&description=Homebrew")}
<ide> and then set the token as: export HOMEBREW_GITHUB_API_TOKEN="your_new_token"
<ide> EOS
<ide> end
| 18
|
Python
|
Python
|
update tokenizer exceptions for spanish
|
d60380418e78a76065305af21cba5f95fb32504a
|
<ide><path>spacy/es/tokenizer_exceptions.py
<ide>
<ide> TOKENIZER_EXCEPTIONS = {
<ide> "accidentarse": [
<del> {ORTH: "accidentar", LEMMA: "accidentar", POS: AUX},
<del> {ORTH: "se", LEMMA: PRON_LEMMA, POS: PRON}
<add> {ORTH: "accidentar", LEMMA: "accidentar", TAG: AUX},
<add> {ORTH: "se", LEMMA: PRON_LEMMA, TAG: "PRON"}
<ide> ],
<ide>
<ide> "aceptarlo": [
<del> {ORTH: "aceptar", LEMMA: "aceptar", POS: AUX},
<del> {ORTH: "lo", LEMMA: PRON_LEMMA, POS: PRON}
<add> {ORTH: "aceptar", LEMMA: "aceptar", TAG: AUX},
<add> {ORTH: "lo", LEMMA: PRON_LEMMA, TAG: "PRON"}
<ide> ],
<ide>
<ide> "acompañarla": [
<del> {ORTH: "acompañar", LEMMA: "acompañar", POS: AUX},
<del> {ORTH: "la", LEMMA: PRON_LEMMA, POS: PRON}
<add> {ORTH: "acompañar", LEMMA: "acompañar", TAG: AUX},
<add> {ORTH: "la", LEMMA: PRON_LEMMA, TAG: "PRON"}
<ide> ],
<ide>
<ide> "advertirle": [
<del> {ORTH: "advertir", LEMMA: "advertir", POS: AUX},
<del> {ORTH: "le", LEMMA: PRON_LEMMA, POS: PRON}
<add> {ORTH: "advertir", LEMMA: "advertir", TAG: AUX},
<add> {ORTH: "le", LEMMA: PRON_LEMMA, TAG: "PRON"}
<ide> ],
<ide>
<ide> "al": [
<del> {ORTH: "a", LEMMA: "a", POS: ADP},
<del> {ORTH: "el", LEMMA: "el", POS: DET}
<add> {ORTH: "a", LEMMA: "a", TAG: ADP},
<add> {ORTH: "el", LEMMA: "el", TAG: DET}
<ide> ],
<ide>
<ide> "anunciarnos": [
<del> {ORTH: "anunciar", LEMMA: "anunciar", POS: AUX},
<del> {ORTH: "nos", LEMMA: PRON_LEMMA, POS: PRON}
<add> {ORTH: "anunciar", LEMMA: "anunciar", TAG: AUX},
<add> {ORTH: "nos", LEMMA: PRON_LEMMA, TAG: "PRON"}
<ide> ],
<ide>
<ide> "asegurándole": [
<del> {ORTH: "asegurando", LEMMA: "asegurar", POS: AUX},
<del> {ORTH: "le", LEMMA: PRON_LEMMA, POS: PRON}
<add> {ORTH: "asegurando", LEMMA: "asegurar", TAG: AUX},
<add> {ORTH: "le", LEMMA: PRON_LEMMA, TAG: "PRON"}
<ide> ],
<ide>
<ide> "considerarle": [
<del> {ORTH: "considerar", LEMMA: "considerar", POS: AUX},
<del> {ORTH: "le", LEMMA: PRON_LEMMA, POS: PRON}
<add> {ORTH: "considerar", LEMMA: "considerar", TAG: AUX},
<add> {ORTH: "le", LEMMA: PRON_LEMMA, TAG: "PRON"}
<ide> ],
<ide>
<ide> "decirle": [
<del> {ORTH: "decir", LEMMA: "decir", POS: AUX},
<del> {ORTH: "le", LEMMA: PRON_LEMMA, POS: PRON}
<add> {ORTH: "decir", LEMMA: "decir", TAG: AUX},
<add> {ORTH: "le", LEMMA: PRON_LEMMA, TAG: "PRON"}
<ide> ],
<ide>
<ide> "decirles": [
<del> {ORTH: "decir", LEMMA: "decir", POS: AUX},
<del> {ORTH: "les", LEMMA: PRON_LEMMA, POS: PRON}
<add> {ORTH: "decir", LEMMA: "decir", TAG: AUX},
<add> {ORTH: "les", LEMMA: PRON_LEMMA, TAG: "PRON"}
<ide> ],
<ide>
<ide> "decirte": [
<del> {ORTH: "Decir", LEMMA: "decir", POS: AUX},
<del> {ORTH: "te", LEMMA: PRON_LEMMA, POS: PRON}
<add> {ORTH: "Decir", LEMMA: "decir", TAG: AUX},
<add> {ORTH: "te", LEMMA: PRON_LEMMA, TAG: "PRON"}
<ide> ],
<ide>
<ide> "dejarla": [
<del> {ORTH: "dejar", LEMMA: "dejar", POS: AUX},
<del> {ORTH: "la", LEMMA: PRON_LEMMA, POS: PRON}
<add> {ORTH: "dejar", LEMMA: "dejar", TAG: AUX},
<add> {ORTH: "la", LEMMA: PRON_LEMMA, TAG: "PRON"}
<ide> ],
<ide>
<ide> "dejarnos": [
<del> {ORTH: "dejar", LEMMA: "dejar", POS: AUX},
<del> {ORTH: "nos", LEMMA: PRON_LEMMA, POS: PRON}
<add> {ORTH: "dejar", LEMMA: "dejar", TAG: AUX},
<add> {ORTH: "nos", LEMMA: PRON_LEMMA, TAG: "PRON"}
<ide> ],
<ide>
<ide> "dejándole": [
<del> {ORTH: "dejando", LEMMA: "dejar", POS: AUX},
<del> {ORTH: "le", LEMMA: PRON_LEMMA, POS: PRON}
<add> {ORTH: "dejando", LEMMA: "dejar", TAG: AUX},
<add> {ORTH: "le", LEMMA: PRON_LEMMA, TAG: "PRON"}
<ide> ],
<ide>
<ide> "del": [
<del> {ORTH: "de", LEMMA: "de", POS: ADP},
<del> {ORTH: "el", LEMMA: "el", POS: DET}
<add> {ORTH: "de", LEMMA: "de", TAG: ADP},
<add> {ORTH: "el", LEMMA: "el", TAG: DET}
<ide> ],
<ide>
<ide> "demostrarles": [
<del> {ORTH: "demostrar", LEMMA: "demostrar", POS: AUX},
<del> {ORTH: "les", LEMMA: PRON_LEMMA, POS: PRON}
<add> {ORTH: "demostrar", LEMMA: "demostrar", TAG: AUX},
<add> {ORTH: "les", LEMMA: PRON_LEMMA, TAG: "PRON"}
<ide> ],
<ide>
<ide> "diciéndole": [
<del> {ORTH: "diciendo", LEMMA: "decir", POS: AUX},
<del> {ORTH: "le", LEMMA: PRON_LEMMA, POS: PRON}
<add> {ORTH: "diciendo", LEMMA: "decir", TAG: AUX},
<add> {ORTH: "le", LEMMA: PRON_LEMMA, TAG: "PRON"}
<ide> ],
<ide>
<ide> "diciéndoles": [
<del> {ORTH: "diciendo", LEMMA: "decir", POS: AUX},
<del> {ORTH: "les", LEMMA: PRON_LEMMA, POS: PRON}
<add> {ORTH: "diciendo", LEMMA: "decir", TAG: AUX},
<add> {ORTH: "les", LEMMA: PRON_LEMMA, TAG: "PRON"}
<ide> ],
<ide>
<ide> "diferenciarse": [
<del> {ORTH: "diferenciar", LEMMA: "diferenciar", POS: AUX},
<del> {ORTH: "se", LEMMA: "él", POS: PRON}
<add> {ORTH: "diferenciar", LEMMA: "diferenciar", TAG: AUX},
<add> {ORTH: "se", LEMMA: "él", TAG: "PRON"}
<ide> ],
<ide>
<ide> "divirtiéndome": [
<del> {ORTH: "divirtiendo", LEMMA: "divertir", POS: AUX},
<del> {ORTH: "me", LEMMA: PRON_LEMMA, POS: PRON}
<add> {ORTH: "divirtiendo", LEMMA: "divertir", TAG: AUX},
<add> {ORTH: "me", LEMMA: PRON_LEMMA, TAG: "PRON"}
<ide> ],
<ide>
<ide> "ensanchándose": [
<del> {ORTH: "ensanchando", LEMMA: "ensanchar", POS: AUX},
<del> {ORTH: "se", LEMMA: PRON_LEMMA, POS: PRON}
<add> {ORTH: "ensanchando", LEMMA: "ensanchar", TAG: AUX},
<add> {ORTH: "se", LEMMA: PRON_LEMMA, TAG: "PRON"}
<ide> ],
<ide>
<ide> "explicarles": [
<del> {ORTH: "explicar", LEMMA: "explicar", POS: AUX},
<del> {ORTH: "les", LEMMA: PRON_LEMMA, POS: PRON}
<add> {ORTH: "explicar", LEMMA: "explicar", TAG: AUX},
<add> {ORTH: "les", LEMMA: PRON_LEMMA, TAG: "PRON"}
<ide> ],
<ide>
<ide> "haberla": [
<del> {ORTH: "haber", LEMMA: "haber", POS: AUX},
<del> {ORTH: "la", LEMMA: PRON_LEMMA, POS: PRON}
<add> {ORTH: "haber", LEMMA: "haber", TAG: AUX},
<add> {ORTH: "la", LEMMA: PRON_LEMMA, TAG: "PRON"}
<ide> ],
<ide>
<ide> "haberlas": [
<del> {ORTH: "haber", LEMMA: "haber", POS: AUX},
<del> {ORTH: "las", LEMMA: PRON_LEMMA, POS: PRON}
<add> {ORTH: "haber", LEMMA: "haber", TAG: AUX},
<add> {ORTH: "las", LEMMA: PRON_LEMMA, TAG: "PRON"}
<ide> ],
<ide>
<ide> "haberlo": [
<del> {ORTH: "haber", LEMMA: "haber", POS: AUX},
<del> {ORTH: "lo", LEMMA: PRON_LEMMA, POS: PRON}
<add> {ORTH: "haber", LEMMA: "haber", TAG: AUX},
<add> {ORTH: "lo", LEMMA: PRON_LEMMA, TAG: "PRON"}
<ide> ],
<ide>
<ide> "haberlos": [
<del> {ORTH: "haber", LEMMA: "haber", POS: AUX},
<del> {ORTH: "los", LEMMA: PRON_LEMMA, POS: PRON}
<add> {ORTH: "haber", LEMMA: "haber", TAG: AUX},
<add> {ORTH: "los", LEMMA: PRON_LEMMA, TAG: "PRON"}
<ide> ],
<ide>
<ide> "haberme": [
<del> {ORTH: "haber", LEMMA: "haber", POS: AUX},
<del> {ORTH: "me", LEMMA: PRON_LEMMA, POS: PRON}
<add> {ORTH: "haber", LEMMA: "haber", TAG: AUX},
<add> {ORTH: "me", LEMMA: PRON_LEMMA, TAG: "PRON"}
<ide> ],
<ide>
<ide> "haberse": [
<del> {ORTH: "haber", LEMMA: "haber", POS: AUX},
<del> {ORTH: "se", LEMMA: PRON_LEMMA, POS: PRON}
<add> {ORTH: "haber", LEMMA: "haber", TAG: AUX},
<add> {ORTH: "se", LEMMA: PRON_LEMMA, TAG: "PRON"}
<ide> ],
<ide>
<ide> "hacerle": [
<del> {ORTH: "hacer", LEMMA: "hacer", POS: AUX},
<del> {ORTH: "le", LEMMA: PRON_LEMMA, POS: PRON}
<add> {ORTH: "hacer", LEMMA: "hacer", TAG: AUX},
<add> {ORTH: "le", LEMMA: PRON_LEMMA, TAG: "PRON"}
<ide> ],
<ide>
<ide> "hacerles": [
<del> {ORTH: "hacer", LEMMA: "hacer", POS: AUX},
<del> {ORTH: "les", LEMMA: PRON_LEMMA, POS: PRON}
<add> {ORTH: "hacer", LEMMA: "hacer", TAG: AUX},
<add> {ORTH: "les", LEMMA: PRON_LEMMA, TAG: "PRON"}
<ide> ],
<ide>
<ide> "hallarse": [
<del> {ORTH: "hallar", LEMMA: "hallar", POS: AUX},
<del> {ORTH: "se", LEMMA: PRON_LEMMA, POS: PRON}
<add> {ORTH: "hallar", LEMMA: "hallar", TAG: AUX},
<add> {ORTH: "se", LEMMA: PRON_LEMMA, TAG: "PRON"}
<ide> ],
<ide>
<ide> "imaginaros": [
<del> {ORTH: "imaginar", LEMMA: "imaginar", POS: AUX},
<del> {ORTH: "os", LEMMA: PRON_LEMMA, POS: PRON}
<add> {ORTH: "imaginar", LEMMA: "imaginar", TAG: AUX},
<add> {ORTH: "os", LEMMA: PRON_LEMMA, TAG: "PRON"}
<ide> ],
<ide>
<ide> "insinuarle": [
<del> {ORTH: "insinuar", LEMMA: "insinuar", POS: AUX},
<del> {ORTH: "le", LEMMA: PRON_LEMMA, POS: PRON}
<add> {ORTH: "insinuar", LEMMA: "insinuar", TAG: AUX},
<add> {ORTH: "le", LEMMA: PRON_LEMMA, TAG: "PRON"}
<ide> ],
<ide>
<ide> "justificarla": [
<del> {ORTH: "justificar", LEMMA: "justificar", POS: AUX},
<del> {ORTH: "la", LEMMA: PRON_LEMMA, POS: PRON}
<add> {ORTH: "justificar", LEMMA: "justificar", TAG: AUX},
<add> {ORTH: "la", LEMMA: PRON_LEMMA, TAG: "PRON"}
<ide> ],
<ide>
<ide> "mantenerlas": [
<del> {ORTH: "mantener", LEMMA: "mantener", POS: AUX},
<del> {ORTH: "las", LEMMA: PRON_LEMMA, POS: PRON}
<add> {ORTH: "mantener", LEMMA: "mantener", TAG: AUX},
<add> {ORTH: "las", LEMMA: PRON_LEMMA, TAG: "PRON"}
<ide> ],
<ide>
<ide> "mantenerlos": [
<del> {ORTH: "mantener", LEMMA: "mantener", POS: AUX},
<del> {ORTH: "los", LEMMA: PRON_LEMMA, POS: PRON}
<add> {ORTH: "mantener", LEMMA: "mantener", TAG: AUX},
<add> {ORTH: "los", LEMMA: PRON_LEMMA, TAG: "PRON"}
<ide> ],
<ide>
<ide> "mantenerme": [
<del> {ORTH: "mantener", LEMMA: "mantener", POS: AUX},
<del> {ORTH: "me", LEMMA: PRON_LEMMA, POS: PRON}
<add> {ORTH: "mantener", LEMMA: "mantener", TAG: AUX},
<add> {ORTH: "me", LEMMA: PRON_LEMMA, TAG: "PRON"}
<ide> ],
<ide>
<ide> "pasarte": [
<del> {ORTH: "pasar", LEMMA: "pasar", POS: AUX},
<del> {ORTH: "te", LEMMA: PRON_LEMMA, POS: PRON}
<add> {ORTH: "pasar", LEMMA: "pasar", TAG: AUX},
<add> {ORTH: "te", LEMMA: PRON_LEMMA, TAG: "PRON"}
<ide> ],
<ide>
<ide> "pedirle": [
<del> {ORTH: "pedir", LEMMA: "pedir", POS: AUX},
<del> {ORTH: "le", LEMMA: "él", POS: PRON}
<add> {ORTH: "pedir", LEMMA: "pedir", TAG: AUX},
<add> {ORTH: "le", LEMMA: "él", TAG: "PRON"}
<ide> ],
<ide>
<ide> "pel": [
<del> {ORTH: "per", LEMMA: "per", POS: ADP},
<del> {ORTH: "el", LEMMA: "el", POS: DET}
<add> {ORTH: "per", LEMMA: "per", TAG: ADP},
<add> {ORTH: "el", LEMMA: "el", TAG: DET}
<ide> ],
<ide>
<ide> "pidiéndonos": [
<del> {ORTH: "pidiendo", LEMMA: "pedir", POS: AUX},
<del> {ORTH: "nos", LEMMA: PRON_LEMMA, POS: PRON}
<add> {ORTH: "pidiendo", LEMMA: "pedir", TAG: AUX},
<add> {ORTH: "nos", LEMMA: PRON_LEMMA, TAG: "PRON"}
<ide> ],
<ide>
<ide> "poderle": [
<del> {ORTH: "poder", LEMMA: "poder", POS: AUX},
<del> {ORTH: "le", LEMMA: PRON_LEMMA, POS: PRON}
<add> {ORTH: "poder", LEMMA: "poder", TAG: AUX},
<add> {ORTH: "le", LEMMA: PRON_LEMMA, TAG: "PRON"}
<ide> ],
<ide>
<ide> "preguntarse": [
<del> {ORTH: "preguntar", LEMMA: "preguntar", POS: AUX},
<del> {ORTH: "se", LEMMA: PRON_LEMMA, POS: PRON}
<add> {ORTH: "preguntar", LEMMA: "preguntar", TAG: AUX},
<add> {ORTH: "se", LEMMA: PRON_LEMMA, TAG: "PRON"}
<ide> ],
<ide>
<ide> "preguntándose": [
<del> {ORTH: "preguntando", LEMMA: "preguntar", POS: AUX},
<del> {ORTH: "se", LEMMA: PRON_LEMMA, POS: PRON}
<add> {ORTH: "preguntando", LEMMA: "preguntar", TAG: AUX},
<add> {ORTH: "se", LEMMA: PRON_LEMMA, TAG: "PRON"}
<ide> ],
<ide>
<ide> "presentarla": [
<del> {ORTH: "presentar", LEMMA: "presentar", POS: AUX},
<del> {ORTH: "la", LEMMA: PRON_LEMMA, POS: PRON}
<add> {ORTH: "presentar", LEMMA: "presentar", TAG: AUX},
<add> {ORTH: "la", LEMMA: PRON_LEMMA, TAG: "PRON"}
<ide> ],
<ide>
<ide> "pudiéndolo": [
<del> {ORTH: "pudiendo", LEMMA: "poder", POS: AUX},
<del> {ORTH: "lo", LEMMA: PRON_LEMMA, POS: PRON}
<add> {ORTH: "pudiendo", LEMMA: "poder", TAG: AUX},
<add> {ORTH: "lo", LEMMA: PRON_LEMMA, TAG: "PRON"}
<ide> ],
<ide>
<ide> "pudiéndose": [
<del> {ORTH: "pudiendo", LEMMA: "poder", POS: AUX},
<del> {ORTH: "se", LEMMA: PRON_LEMMA, POS: PRON}
<add> {ORTH: "pudiendo", LEMMA: "poder", TAG: AUX},
<add> {ORTH: "se", LEMMA: PRON_LEMMA, TAG: "PRON"}
<ide> ],
<ide>
<ide> "quererle": [
<del> {ORTH: "querer", LEMMA: "querer", POS: AUX},
<del> {ORTH: "le", LEMMA: PRON_LEMMA, POS: PRON}
<add> {ORTH: "querer", LEMMA: "querer", TAG: AUX},
<add> {ORTH: "le", LEMMA: PRON_LEMMA, TAG: "PRON"}
<ide> ],
<ide>
<ide> "rasgarse": [
<del> {ORTH: "Rasgar", LEMMA: "rasgar", POS: AUX},
<del> {ORTH: "se", LEMMA: PRON_LEMMA, POS: PRON}
<add> {ORTH: "Rasgar", LEMMA: "rasgar", TAG: AUX},
<add> {ORTH: "se", LEMMA: PRON_LEMMA, TAG: "PRON"}
<ide> ],
<ide>
<ide> "repetirlo": [
<del> {ORTH: "repetir", LEMMA: "repetir", POS: AUX},
<del> {ORTH: "lo", LEMMA: PRON_LEMMA, POS: PRON}
<add> {ORTH: "repetir", LEMMA: "repetir", TAG: AUX},
<add> {ORTH: "lo", LEMMA: PRON_LEMMA, TAG: "PRON"}
<ide> ],
<ide>
<ide> "robarle": [
<del> {ORTH: "robar", LEMMA: "robar", POS: AUX},
<del> {ORTH: "le", LEMMA: PRON_LEMMA, POS: PRON}
<add> {ORTH: "robar", LEMMA: "robar", TAG: AUX},
<add> {ORTH: "le", LEMMA: PRON_LEMMA, TAG: "PRON"}
<ide> ],
<ide>
<ide> "seguirlos": [
<del> {ORTH: "seguir", LEMMA: "seguir", POS: AUX},
<del> {ORTH: "los", LEMMA: PRON_LEMMA, POS: PRON}
<add> {ORTH: "seguir", LEMMA: "seguir", TAG: AUX},
<add> {ORTH: "los", LEMMA: PRON_LEMMA, TAG: "PRON"}
<ide> ],
<ide>
<ide> "serle": [
<del> {ORTH: "ser", LEMMA: "ser", POS: AUX},
<del> {ORTH: "le", LEMMA: PRON_LEMMA, POS: PRON}
<add> {ORTH: "ser", LEMMA: "ser", TAG: AUX},
<add> {ORTH: "le", LEMMA: PRON_LEMMA, TAG: "PRON"}
<ide> ],
<ide>
<ide> "serlo": [
<del> {ORTH: "ser", LEMMA: "ser", POS: AUX},
<del> {ORTH: "lo", LEMMA: PRON_LEMMA, POS: PRON}
<add> {ORTH: "ser", LEMMA: "ser", TAG: AUX},
<add> {ORTH: "lo", LEMMA: PRON_LEMMA, TAG: "PRON"}
<ide> ],
<ide>
<ide> "señalándole": [
<del> {ORTH: "señalando", LEMMA: "señalar", POS: AUX},
<del> {ORTH: "le", LEMMA: PRON_LEMMA, POS: PRON}
<add> {ORTH: "señalando", LEMMA: "señalar", TAG: AUX},
<add> {ORTH: "le", LEMMA: PRON_LEMMA, TAG: "PRON"}
<ide> ],
<ide>
<ide> "suplicarle": [
<del> {ORTH: "suplicar", LEMMA: "suplicar", POS: AUX},
<del> {ORTH: "le", LEMMA: PRON_LEMMA, POS: PRON}
<add> {ORTH: "suplicar", LEMMA: "suplicar", TAG: AUX},
<add> {ORTH: "le", LEMMA: PRON_LEMMA, TAG: "PRON"}
<ide> ],
<ide>
<ide> "tenerlos": [
<del> {ORTH: "tener", LEMMA: "tener", POS: AUX},
<del> {ORTH: "los", LEMMA: PRON_LEMMA, POS: PRON}
<add> {ORTH: "tener", LEMMA: "tener", TAG: AUX},
<add> {ORTH: "los", LEMMA: PRON_LEMMA, TAG: "PRON"}
<ide> ],
<ide>
<ide> "vengarse": [
<del> {ORTH: "vengar", LEMMA: "vengar", POS: AUX},
<del> {ORTH: "se", LEMMA: PRON_LEMMA, POS: PRON}
<add> {ORTH: "vengar", LEMMA: "vengar", TAG: AUX},
<add> {ORTH: "se", LEMMA: PRON_LEMMA, TAG: "PRON"}
<ide> ],
<ide>
<ide> "verla": [
<del> {ORTH: "ver", LEMMA: "ver", POS: AUX},
<del> {ORTH: "la", LEMMA: PRON_LEMMA, POS: PRON}
<add> {ORTH: "ver", LEMMA: "ver", TAG: AUX},
<add> {ORTH: "la", LEMMA: PRON_LEMMA, TAG: "PRON"}
<ide> ],
<ide>
<ide> "verle": [
<del> {ORTH: "ver", LEMMA: "ver", POS: AUX},
<del> {ORTH: "le", LEMMA: PRON_LEMMA, POS: PRON}
<add> {ORTH: "ver", LEMMA: "ver", TAG: AUX},
<add> {ORTH: "le", LEMMA: PRON_LEMMA, TAG: "PRON"}
<ide> ],
<ide>
<ide> "volverlo": [
<del> {ORTH: "volver", LEMMA: "volver", POS: AUX},
<del> {ORTH: "lo", LEMMA: PRON_LEMMA, POS: PRON}
<add> {ORTH: "volver", LEMMA: "volver", TAG: AUX},
<add> {ORTH: "lo", LEMMA: PRON_LEMMA, TAG: "PRON"}
<add> ],
<add>
<add> "aprox.": [
<add> {ORTH: "aprox.", LEMMA: "aproximadamente"}
<add> ],
<add>
<add> "dna.": [
<add> {ORTH: "dna.", LEMMA: "docena"}
<add> ],
<add>
<add> "esq.": [
<add> {ORTH: "esq.", LEMMA: "esquina"}
<add> ],
<add>
<add> "pág.": [
<add> {ORTH: "pág.", LEMMA: "página"}
<add> ],
<add>
<add> "p.ej.": [
<add> {ORTH: "p.ej.", LEMMA: "por ejemplo"}
<add> ],
<add>
<add> "Ud.": [
<add> {ORTH: "Ud.", LEMMA: PRON_LEMMA, NORM: "usted"}
<add> ],
<add>
<add> "Vd.": [
<add> {ORTH: "Vd.", LEMMA: PRON_LEMMA, NORM: "usted"}
<add> ],
<add>
<add> "Uds.": [
<add> {ORTH: "Uds.", LEMMA: PRON_LEMMA, NORM: "ustedes"}
<add> ],
<add>
<add> "Vds.": [
<add> {ORTH: "Vds.", LEMMA: PRON_LEMMA, NORM: "ustedes"}
<ide> ]
<ide> }
<ide>
<ide>
<ide> ORTH_ONLY = [
<del>
<add> "a.",
<add> "a.C.",
<add> "a.J.C.",
<add> "apdo.",
<add> "Av.",
<add> "Avda.",
<add> "b.",
<add> "c.",
<add> "Cía.",
<add> "d.",
<add> "e.",
<add> "etc.",
<add> "f.",
<add> "g.",
<add> "Gob.",
<add> "Gral.",
<add> "h.",
<add> "i.",
<add> "Ing.",
<add> "j.",
<add> "J.C.",
<add> "k.",
<add> "l.",
<add> "Lic.",
<add> "m.",
<add> "m.n.",
<add> "n.",
<add> "no.",
<add> "núm.",
<add> "o.",
<add> "p.",
<add> "P.D.",
<add> "Prof.",
<add> "Profa.",
<add> "q.",
<add> "q.e.p.d."
<add> "r.",
<add> "s.",
<add> "S.A.",
<add> "S.L.",
<add> "s.s.s.",
<add> "Sr.",
<add> "Sra.",
<add> "Srta.",
<add> "t.",
<add> "u.",
<add> "v.",
<add> "w.",
<add> "x.",
<add> "y.",
<add> "z."
<ide> ]
| 1
|
Java
|
Java
|
update javadoc of logformatutils
|
c5de5c99390a69f23e7682b7748c273b01a63907
|
<ide><path>spring-core/src/main/java/org/springframework/core/log/LogFormatUtils.java
<ide> public abstract class LogFormatUtils {
<ide>
<ide> /**
<del> * Variant of {@link #formatValue(Object, int, boolean)} and a convenience
<del> * method that truncates at 100 characters when {@code limitLength} is set.
<add> * Convenience variant of {@link #formatValue(Object, int, boolean)} that
<add> * limits the length of a log message to 100 characters and also replaces
<add> * newline characters if {@code limitLength} is set to "true".
<ide> * @param value the value to format
<ide> * @param limitLength whether to truncate the value at a length of 100
<ide> * @return the formatted value
| 1
|
Text
|
Text
|
update upgrade guide for https proxy setting
|
962f9ab7129f38024f73a75e2869feaa6eb2d260
|
<ide><path>UPGRADE_GUIDE.md
<ide> # Upgrade Guide
<ide>
<add>### 0.18.x -> 0.19.0
<add>
<add>#### HTTPS Proxies
<add>
<add>Routing through an https proxy now requires setting the `protocol` attribute of the proxy configuration to `https`
<add>
<ide> ### 0.15.x -> 0.16.0
<ide>
<ide> #### `Promise` Type Declarations
| 1
|
Go
|
Go
|
tell the user not to run from osx
|
fe445a2447e701cc91ef77d7bcb0978a5d373940
|
<ide><path>docker/docker.go
<ide> func main() {
<ide> }
<ide>
<ide> if *flDaemon {
<add> if runtime.GOOS != "linux" {
<add> log.Fatalf("The Docker daemon is only supported on linux")
<add> }
<ide> if os.Geteuid() != 0 {
<ide> log.Fatalf("The Docker daemon needs to be run as root")
<ide> }
| 1
|
Python
|
Python
|
allow callables as the argument to runpython
|
fe9f342d8ceae96a03295e56ec743ed2e2e5fb51
|
<ide><path>django/db/migrations/operations/special.py
<ide> import re
<ide> import textwrap
<ide> from .base import Operation
<add>from django.utils import six
<ide>
<ide>
<ide> class SeparateDatabaseAndState(Operation):
<ide> class RunPython(Operation):
<ide> reversible = False
<ide>
<ide> def __init__(self, code):
<del> # Trim any leading whitespace that is at the start of all code lines
<del> # so users can nicely indent code in migration files
<del> code = textwrap.dedent(code)
<del> # Run the code through a parser first to make sure it's at least
<del> # syntactically correct
<del> self.code = compile(code, "<string>", "exec")
<add> if isinstance(code, six.string_types):
<add> # Trim any leading whitespace that is at the start of all code lines
<add> # so users can nicely indent code in migration files
<add> code = textwrap.dedent(code)
<add> # Run the code through a parser first to make sure it's at least
<add> # syntactically correct
<add> self.code = compile(code, "<string>", "exec")
<add> self.is_callable = False
<add> else:
<add> self.code = code
<add> self.is_callable = True
<ide>
<ide> def state_forwards(self, app_label, state):
<ide> # RunPython objects have no state effect. To add some, combine this
<ide> def database_forwards(self, app_label, schema_editor, from_state, to_state):
<ide> # object, representing the versioned models as an AppCache.
<ide> # We could try to override the global cache, but then people will still
<ide> # use direct imports, so we go with a documentation approach instead.
<del> context = {
<del> "models": from_state.render(),
<del> "schema_editor": schema_editor,
<del> }
<del> eval(self.code, context)
<add> if self.is_callable:
<add> self.code(models=from_state.render(), schema_editor=schema_editor)
<add> else:
<add> context = {
<add> "models": from_state.render(),
<add> "schema_editor": schema_editor,
<add> }
<add> eval(self.code, context)
<ide>
<ide> def database_backwards(self, app_label, schema_editor, from_state, to_state):
<ide> raise NotImplementedError("You cannot reverse this operation")
<ide><path>tests/migrations/test_operations.py
<ide> def test_run_python(self):
<ide> # And test reversal fails
<ide> with self.assertRaises(NotImplementedError):
<ide> operation.database_backwards("test_runpython", None, new_state, project_state)
<add> # Now test we can do it with a callable
<add> def inner_method(models, schema_editor):
<add> Pony = models.get_model("test_runpython", "Pony")
<add> Pony.objects.create(pink=1, weight=3.55)
<add> Pony.objects.create(weight=5)
<add> operation = migrations.RunPython(inner_method)
<add> with connection.schema_editor() as editor:
<add> operation.database_forwards("test_runpython", editor, project_state, new_state)
<add> self.assertEqual(project_state.render().get_model("test_runpython", "Pony").objects.count(), 4)
<ide>
<ide>
<ide> class MigrateNothingRouter(object):
| 2
|
Ruby
|
Ruby
|
reimplement strategy and improve tests
|
5b770e99651c15e9835356a9a3d59a6ffcd91584
|
<ide><path>Library/Homebrew/livecheck/strategy/cpan.rb
<ide> # typed: false
<ide> # frozen_string_literal: true
<ide>
<del>require "uri"
<del>
<ide> module Homebrew
<ide> module Livecheck
<ide> module Strategy
<ide> # The {Cpan} strategy identifies versions of software at
<ide> # cpan.metacpan.org by checking directory listing pages.
<ide> #
<del> # CPAN URLs take the following format:
<add> # CPAN URLs take the following formats:
<add> #
<add> # * `https://cpan.metacpan.org/authors/id/H/HO/HOMEBREW/Brew-v1.2.3.tar.gz`
<add> # * `https://cpan.metacpan.org/authors/id/H/HO/HOMEBREW/brew/brew-v1.2.3.tar.gz`
<ide> #
<del> # * `https://cpan.metacpan.org/authors/id/M/MI/MIYAGAWA/Carton-v1.0.34.tar.gz`
<add> # In these examples, `HOMEBREW` is the author name and the preceding `H`
<add> # and `HO` directories correspond to the first letter(s). Some authors
<add> # also store files in subdirectories, as in the second example above.
<ide> #
<ide> # @api public
<ide> class Cpan
<ide> NICE_NAME = "CPAN"
<ide>
<del> # The allowlist used to determine if the strategy applies to the URL.
<del> HOST_ALLOWLIST = ["cpan.metacpan.org"].freeze
<add> # The `Regexp` used to determine if the strategy applies to the URL.
<add> URL_MATCH_REGEX = %r{^https?://cpan\.metacpan\.org/authors/id(?:/[^/]+){3,}/[^/]+}i.freeze
<ide>
<ide> # Whether the strategy can be applied to the provided URL.
<ide> #
<ide> # @param url [String] the URL to match against
<ide> # @return [Boolean]
<ide> def self.match?(url)
<del> uri = URI.parse url
<del> HOST_ALLOWLIST.include? uri.host
<del> rescue URI::InvalidURIError
<del> false
<add> URL_MATCH_REGEX.match?(url)
<ide> end
<ide>
<ide> # Generates a URL and regex (if one isn't provided) and passes them
<ide> def self.match?(url)
<ide> # @return [Hash]
<ide> def self.find_versions(url, regex = nil)
<ide> %r{
<del> /authors/id/(?<author_path>(?:[^/](?:/[^/]+){2})) # The author path (e.g. M/MI/MIYAGAWA)
<del> /(?<package_path>.+) # The package path (e.g. Carton-v1.0.34.tar.gz)
<add> (?<path>/authors/id(?:/[^/]+){3,}/) # Path before the filename
<add> (?<prefix>[^/]+) # Filename text before the version
<add> -v?\d+(?:\.\d+)* # The numeric version
<add> (?<suffix>[^/]+) # Filename text after the version
<ide> }ix =~ url
<ide>
<del> # We need a Pathname because we've monkeypatched extname to support
<del> # double extensions (e.g. tar.gz).
<del> pathname = Pathname.new(package_path)
<del>
<del> # Exteract package name
<del> /^(?<package_name>.+)-v?\d+/ =~ pathname.basename(pathname.extname)
<ide> # Use `\.t` instead of specific tarball extensions (e.g. .tar.gz)
<del> suffix = pathname.extname.sub!(/\.t(?:ar\..+|[a-z0-9]+)$/i, "\.t")
<add> suffix.sub!(/\.t(?:ar\..+|[a-z0-9]+)$/i, "\.t")
<ide>
<del> # A page containing a directory listing of the latest source tarball
<del> package_dir = Pathname.new(author_path).join(pathname.dirname)
<del> page_url = "https://cpan.metacpan.org/authors/id/#{package_dir}/"
<add> # The directory listing page where the archive files are found
<add> page_url = "https://cpan.metacpan.org#{path}"
<ide>
<del> # Example regex: `%r{href=.*?Carton-v?(\d+(?:\.\d+)*).t}i`
<del> regex ||= /href=.*?#{package_name}-v?(\d+(?:\.\d+)*)#{Regexp.escape(suffix)}/i
<add> # Example regex: `/href=.*?Brew[._-]v?(\d+(?:\.\d+)*)\.t/i`
<add> regex ||= /href=.*?#{prefix}[._-]v?(\d+(?:\.\d+)*)#{Regexp.escape(suffix)}/i
<ide>
<ide> Homebrew::Livecheck::Strategy::PageMatch.find_versions(page_url, regex)
<ide> end
<ide><path>Library/Homebrew/test/livecheck/strategy/cpan_spec.rb
<ide> describe Homebrew::Livecheck::Strategy::Cpan do
<ide> subject(:cpan) { described_class }
<ide>
<del> let(:cpan_url) { "https://cpan.metacpan.org/authors/id/M/MI/MIYAGAWA/Carton-v1.0.34.tar.gz" }
<add> let(:cpan_url_no_subdirectory) { "https://cpan.metacpan.org/authors/id/H/HO/HOMEBREW/Brew-v1.2.3.tar.gz" }
<add> let(:cpan_url_with_subdirectory) { "https://cpan.metacpan.org/authors/id/H/HO/HOMEBREW/brew/brew-v1.2.3.tar.gz" }
<ide> let(:non_cpan_url) { "https://brew.sh/test" }
<ide>
<ide> describe "::match?" do
<ide> it "returns true if the argument provided is a CPAN URL" do
<del> expect(cpan.match?(cpan_url)).to be true
<add> expect(cpan.match?(cpan_url_no_subdirectory)).to be true
<add> expect(cpan.match?(cpan_url_with_subdirectory)).to be true
<ide> end
<ide>
<ide> it "returns false if the argument provided is not a CPAN URL" do
| 2
|
Javascript
|
Javascript
|
reduce delay on gulp
|
20475ffcc45b0bf69d731828e652437745384146
|
<ide><path>gulpfile.js
<ide> var gulp = require('gulp'),
<ide> sync = require('browser-sync'),
<ide> reload = sync.reload,
<ide> inject = require('gulp-inject'),
<del> reloadDelay = 7000;
<add> reloadDelay = 3000;
<ide>
<ide> var paths = {
<ide> server: './app.js',
| 1
|
Javascript
|
Javascript
|
fix randomint bias
|
4db9854d6e6f1adb9f7240d937e6d1aaeddd1e3d
|
<ide><path>lib/internal/crypto/random.js
<ide> function randomInt(min, max, callback) {
<ide> `<= ${RAND_MAX}`, range);
<ide> }
<ide>
<del> const excess = RAND_MAX % range;
<del> const randLimit = RAND_MAX - excess;
<add> // For (x % range) to produce an unbiased value greater than or equal to 0 and
<add> // less than range, x must be drawn randomly from the set of integers greater
<add> // than or equal to 0 and less than randLimit.
<add> const randLimit = RAND_MAX - (RAND_MAX % range);
<ide>
<ide> if (isSync) {
<ide> // Sync API
<ide> while (true) {
<ide> const x = randomBytes(6).readUIntBE(0, 6);
<del> // If x > (maxVal - (maxVal % range)), we will get "modulo bias"
<del> if (x > randLimit) {
<del> // Try again
<add> if (x >= randLimit) {
<add> // Try again.
<ide> continue;
<ide> }
<del> const n = (x % range) + min;
<del> return n;
<add> return (x % range) + min;
<ide> }
<ide> } else {
<ide> // Async API
<ide> const pickAttempt = () => {
<ide> randomBytes(6, (err, bytes) => {
<ide> if (err) return callback(err);
<ide> const x = bytes.readUIntBE(0, 6);
<del> // If x > (maxVal - (maxVal % range)), we will get "modulo bias"
<del> if (x > randLimit) {
<del> // Try again
<add> if (x >= randLimit) {
<add> // Try again.
<ide> return pickAttempt();
<ide> }
<ide> const n = (x % range) + min;
| 1
|
PHP
|
PHP
|
fix failing tests on apishell
|
b825a52459e59b384c62b44e1c0f7f694554c699
|
<ide><path>lib/Cake/Console/Command/ApiShell.php
<ide> <?php
<ide> /**
<del> * API shell to get CakePHP core method signatures.
<del> *
<del> * Implementation of a Cake Shell to show CakePHP core method signatures.
<del> *
<del> * PHP 5
<del> *
<ide> * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
<ide> * Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
<ide> *
<ide> * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
<ide> */
<ide> namespace Cake\Console\Command;
<add>
<ide> use Cake\Console\Shell;
<ide> use Cake\Core\App;
<ide> use Cake\Utility\Inflector;
<ide> public function main() {
<ide> $file = Inflector::underscore($this->args[1]);
<ide> $class = Inflector::camelize($this->args[1]);
<ide> }
<del> $objects = App::objects('class', $path);
<del> if (in_array($class, $objects)) {
<del> if (in_array($type, array('behavior', 'component', 'helper')) && $type !== $file) {
<del> if (!preg_match('/' . Inflector::camelize($type) . '$/', $class)) {
<del> $class .= Inflector::camelize($type);
<del> }
<del> }
<add> $path = $path . Inflector::camelize($type);
<add> $file = $path . '.php';
<add> $classPath = str_replace(CORE_PATH, '', $path);
<add> $className = str_replace(DS, '\\', $classPath);
<ide>
<del> } else {
<del> $this->error(__d('cake_console', '%s not found', $class));
<add> if (!class_exists($className)) {
<add> return $this->error(__d('cake_console', '%s not found', $class));
<ide> }
<ide>
<del> $parsed = $this->_parseClass($path . $class . '.php', $class);
<add> $parsed = $this->_parseClass($className);
<ide>
<ide> if (!empty($parsed)) {
<ide> if (isset($this->params['method'])) {
<ide> public function help() {
<ide> * Parse a given class (located on given file) and get public methods and their
<ide> * signatures.
<ide> *
<del> * @param string $path File path
<ide> * @param string $class Class name
<ide> * @return array Methods and signatures indexed by method name
<ide> */
<del> protected function _parseClass($path, $class) {
<add> protected function _parseClass($class) {
<ide> $parsed = array();
<ide>
<del> if (!class_exists($class)) {
<del> if (!include_once $path) {
<del> $this->err(__d('cake_console', '%s could not be found', $path));
<del> }
<del> }
<del>
<ide> $reflection = new \ReflectionClass($class);
<ide>
<ide> foreach ($reflection->getMethods() as $method) {
<del> if (!$method->isPublic() || strpos($method->getName(), '_') === 0) {
<add> if (!$method->isPublic()) {
<ide> continue;
<ide> }
<ide> if ($method->getDeclaringClass()->getName() != $class) {
<ide><path>lib/Cake/Test/TestCase/Console/Command/ApiShellTest.php
<ide> <?php
<ide> /**
<del> * ApiShellTest file
<del> *
<del> * PHP 5
<del> *
<ide> * CakePHP : Rapid Development Framework (http://cakephp.org)
<ide> * Copyright 2005-2012, Cake Software Foundation, Inc.
<ide> *
<ide> * @since CakePHP v 1.2.0.7726
<ide> * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
<ide> */
<del>
<ide> namespace Cake\Test\TestCase\Console\Command;
<add>
<ide> use Cake\Console\Command\ApiShellShell;
<ide> use Cake\TestSuite\TestCase;
<ide>
<ide> class ApiShellTest extends TestCase {
<ide> */
<ide> public function setUp() {
<ide> parent::setUp();
<del> $out = $this->getMock('Cake\Console\ConsoleOutput', array(), array(), '', false);
<del> $in = $this->getMock('Cake\Console\ConsoleInput', array(), array(), '', false);
<add> $out = $this->getMock('Cake\Console\ConsoleOutput', [], [], '', false);
<add> $in = $this->getMock('Cake\Console\ConsoleInput', [], [], '', false);
<ide>
<ide> $this->Shell = $this->getMock(
<ide> 'Cake\Console\Command\ApiShell',
<del> array('in', 'out', 'createFile', 'hr', '_stop'),
<del> array( $out, $out, $in)
<add> ['in', 'out', 'createFile', 'hr', '_stop'],
<add> [$out, $out, $in]
<ide> );
<ide> }
<ide>
<ide> public function setUp() {
<ide> * @return void
<ide> */
<ide> public function testMethodNameDetection() {
<del> $this->Shell->expects($this->any())->method('in')->will($this->returnValue('q'));
<del> $this->Shell->expects($this->at(0))->method('out')->with('Controller');
<add> $this->Shell->expects($this->any())
<add> ->method('in')->will($this->returnValue('q'));
<add> $this->Shell->expects($this->at(0))
<add> ->method('out')->with('Controller');
<ide>
<del> $expected = array(
<del> '1. afterFilter()',
<del> '2. afterScaffoldSave($method)',
<del> '3. afterScaffoldSaveError($method)',
<del> '4. beforeFilter()',
<del> '5. beforeRedirect($url, $status = NULL, $exit = true)',
<del> '6. beforeRender()',
<del> '7. beforeScaffold($method)',
<del> '8. constructClasses()',
<del> '9. disableCache()',
<del> '10. flash($message, $url, $pause = 1, $layout = \'flash\')',
<del> '11. getEventManager()',
<del> '12. header($status)',
<del> '13. httpCodes($code = NULL)',
<del> '14. implementedEvents()',
<del> '15. invokeAction($request)',
<del> '16. loadModel($modelClass = NULL, $id = NULL)',
<del> '17. paginate($object = NULL, $scope = array (), $whitelist = array ())',
<del> '18. postConditions($data = array (), $op = NULL, $bool = \'AND\', $exclusive = false)',
<del> '19. redirect($url, $status = NULL, $exit = true)',
<del> '20. referer($default = NULL, $local = false)',
<del> '21. render($view = NULL, $layout = NULL)',
<del> '22. scaffoldError($method)',
<del> '23. set($one, $two = NULL)',
<del> '24. setAction($action)',
<del> '25. setRequest($request)',
<del> '26. shutdownProcess()',
<del> '27. startupProcess()',
<del> '28. validate()',
<del> '29. validateErrors()'
<del> );
<del> $this->Shell->expects($this->at(2))->method('out')->with($expected);
<add> $this->Shell->expects($this->at(2))
<add> ->method('out')
<add> ->with($this->logicalAnd(
<add> $this->contains('8. beforeFilter()'),
<add> $this->contains('24. render($view = NULL, $layout = NULL)')
<add> ));
<ide>
<del> $this->Shell->args = array('controller');
<add> $this->Shell->args = ['controller'];
<ide> $this->Shell->paths['controller'] = CAKE . 'Controller/';
<ide> $this->Shell->main();
<ide> }
| 2
|
Text
|
Text
|
change links to gitter channel
|
663d559fb49682ce002a924ad0b1c116cad1a333
|
<ide><path>README.md
<ide> Our campers (students) start by working through our free, self-paced, browser-ba
<ide>
<ide> 80% of our campers are over 25, and nearly a fifth of our campers are women.
<ide>
<del>This code is running live at [FreeCodeCamp.com](http://www.FreeCodeCamp.com). We also have [Slack](http://freecodecamp.slack.com), a [blog](http://blog.freecodecamp.com), and even a [Twitch.tv channel](http://twitch.tv/freecodecamp).
<add>This code is running live at [FreeCodeCamp.com](http://www.FreeCodeCamp.com). We also have [Gitter](https://gitter.im/FreeCodeCamp/FreeCodeCamp), a [blog](http://blog.freecodecamp.com), and even a [Twitch.tv channel](http://twitch.tv/freecodecamp).
<ide>
<ide> [Join our community](http://www.freecodecamp.com/signin)!
<ide>
<ide> Contributing
<ide> We welcome pull requests from Free Code Camp campers (our students) and seasoned JavaScript developers alike! Follow these steps to contribute:
<ide>
<ide> 1. Check our [public Waffle Board](https://waffle.io/freecodecamp/freecodecamp).
<del>2. Pick an issue that nobody has claimed and start working on it. If your issue isn't on the board, open an issue. If you think you can fix it yourself, start working on it. Feel free to ask for help in our [Slack](http://freecodecamp.slack.com).
<add>2. Pick an issue that nobody has claimed and start working on it. If your issue isn't on the board, open an issue. If you think you can fix it yourself, start working on it. Feel free to ask for help in our [Gitter](https://gitter.im/FreeCodeCamp/FreeCodeCamp)
<ide> 3. Fork the project ([Need help with forking a project?](https://help.github.com/articles/fork-a-repo/)). You'll do all of your work on your forked copy.
<ide> 4. Create a branch specific to the issue or feature you are working on. Push your work to that branch. ([Need help with branching?](https://github.com/Kunena/Kunena-Forum/wiki/Create-a-new-branch-with-git-and-manage-branches))
<ide> 5. Name the branch something like `user-xxx` where user is your username and xxx is the issue number you are addressing.
| 1
|
Javascript
|
Javascript
|
preserve reference fragment in chromium url router
|
a1671fa512f01b8dbb1fb90d65772f34b4360b6e
|
<ide><path>extensions/chromium/extension-router.js
<ide> limitations under the License.
<ide> var url = parseExtensionURL(details.url);
<ide> if (url) {
<ide> url = VIEWER_URL + '?file=' + url;
<add> var i = details.url.indexOf('#');
<add> if (i > 0) {
<add> url += details.url.slice(i);
<add> }
<ide> console.log('Redirecting ' + details.url + ' to ' + url);
<ide> return { redirectUrl: url };
<ide> }
| 1
|
Javascript
|
Javascript
|
remove information for ie7
|
f2f9843ea8dea803a7c48b1ed22a6be929e87f35
|
<ide><path>src/ng/directive/ngCloak.js
<ide> * document; alternatively, the css rule above must be included in the external stylesheet of the
<ide> * application.
<ide> *
<del> * Legacy browsers, like IE7, do not provide attribute selector support (added in CSS 2.1) so they
<del> * cannot match the `[ng\:cloak]` selector. To work around this limitation, you must add the css
<del> * class `ng-cloak` in addition to the `ngCloak` directive as shown in the example below.
<del> *
<ide> * @element ANY
<ide> *
<ide> * @example
<ide> <example>
<ide> <file name="index.html">
<ide> <div id="template1" ng-cloak>{{ 'hello' }}</div>
<del> <div id="template2" ng-cloak class="ng-cloak">{{ 'hello IE7' }}</div>
<add> <div id="template2" class="ng-cloak">{{ 'world' }}</div>
<ide> </file>
<ide> <file name="protractor.js" type="protractor">
<ide> it('should remove the template directive and css class', function() {
| 1
|
Text
|
Text
|
fix portal link
|
706d2f4f9c52a27a2a1a8e423caf388cefec732c
|
<ide><path>docs/docs/portals.md
<ide> Portals provide a first-class way to render children into a DOM node that exists
<ide> ReactDOM.createPortal(child, container)
<ide> ```
<ide>
<del>The first argument (`child`) is any [renderable React child](/docs/react-component.html#render), such as an element, string, or fragment. The second argument (`container`) is a DOM element.
<add>The first argument (`child`) is any [renderable React child](/react/docs/react-component.html#render), such as an element, string, or fragment. The second argument (`container`) is a DOM element.
<ide>
<ide> ## Usage
<ide>
| 1
|
PHP
|
PHP
|
add missing property to controller
|
98ff98e2b3d535f2f9fe70f8778a092a19463442
|
<ide><path>src/Controller/Controller.php
<ide> class Controller implements EventListener {
<ide> */
<ide> public $viewClass = 'Cake\View\View';
<ide>
<add>/**
<add> * The path to this controllers view templates.
<add> * Example `Articles`
<add> *
<add> * Set automatically using conventions in Controller::__construct().
<add> *
<add> * @var string
<add> */
<add> public $viewPath;
<add>
<add>/**
<add> * The name of the view file to render. The name specified
<add> * is the filename in /app/Template/<SubFolder> without the .ctp extension.
<add> *
<add> * @var string
<add> */
<add> public $view = null;
<add>
<ide> /**
<ide> * Instance of the View created during rendering. Won't be set until after
<ide> * Controller::render() is called.
<ide> class Controller implements EventListener {
<ide> */
<ide> public $methods = array();
<ide>
<del>/**
<del> * The path to this controllers view templates.
<del> * Example `Articles`
<del> *
<del> * Set automatically using conventions in Controller::__construct().
<del> *
<del> * @var string
<del> */
<del> public $viewPath;
<del>
<ide> /**
<ide> * Constructor.
<ide> *
| 1
|
Javascript
|
Javascript
|
expand test coverage for url.js
|
cad2a2f9f7da59c89112ab9e12efafeed5606ad6
|
<ide><path>test/parallel/test-url.js
<ide> var parseTests = {
<ide> path: '/Y'
<ide> },
<ide>
<add> // whitespace in the front
<add> ' http://www.example.com/': {
<add> href: 'http://www.example.com/',
<add> protocol: 'http:',
<add> slashes: true,
<add> host: 'www.example.com',
<add> hostname: 'www.example.com',
<add> pathname: '/',
<add> path: '/'
<add> },
<add>
<ide> // + not an invalid host character
<ide> // per https://url.spec.whatwg.org/#host-parsing
<ide> 'http://x.y.com+a/b/c': {
| 1
|
Text
|
Text
|
sync the initial docs from b2d
|
23dd221e5250398d4120a1f3d1bcb591923f4892
|
<ide><path>docs/sources/installation/mac.md
<ide> $ ./boot2docker
<ide> Usage: ./boot2docker [<options>] {help|init|up|ssh|save|down|poweroff|reset|restart|config|status|info|delete|download|version} [<args>]
<ide> ```
<ide>
<add>## Container port redirection
<add>
<add>The latest version of `boot2docker` sets up two network adaptors: one using NAT
<add>to allow the VM to download images and files from the Internet, and one host only
<add>network adaptor to which the container's ports will be exposed on.
<add>
<add>If you run a container with an exposed port:
<add>
<add>```
<add> docker run --rm -i -t -p 80:80 apache
<add>```
<add>
<add>Then you should be able to access that Apache server using the IP address reported
<add>to you using:
<add>
<add>```
<add> boot2docker ssh ip addr show dev eth1
<add>```
<add>
<add>Typically, it is 192.168.59.103, but at this point it can change.
<add>
<add>If you want to share container ports with other computers on your LAN, you will
<add>need to set up [NAT adaptor based port forwarding](
<add>https://github.com/boot2docker/boot2docker/blob/master/doc/WORKAROUNDS.md)
<add>
<add>
<ide>
<ide> For further information or to report issues, please see the [Boot2Docker site](http://boot2docker.io).
<ide><path>docs/sources/installation/windows.md
<ide> $ ./boot2docker
<ide> Usage: ./boot2docker [<options>] {help|init|up|ssh|save|down|poweroff|reset|restart|config|status|info|delete|download|version} [<args>]
<ide> ```
<ide>
<add>## Container port redirection
<add>
<add>The latest version of `boot2docker` sets up two network adaptors: one using NAT
<add>to allow the VM to download images and files from the Internet, and one host only
<add>network adaptor to which the container's ports will be exposed on.
<add>
<add>If you run a container with an exposed port:
<add>
<add>```
<add> docker run --rm -i -t -p 80:80 apache
<add>```
<add>
<add>Then you should be able to access that Apache server using the IP address reported
<add>to you using:
<add>
<add>```
<add> boot2docker ssh ip addr show dev eth1
<add>```
<add>
<add>Typically, it is 192.168.59.103, but at this point it can change.
<add>
<add>If you want to share container ports with other computers on your LAN, you will
<add>need to set up [NAT adaptor based port forwarding](
<add>https://github.com/boot2docker/boot2docker/blob/master/doc/WORKAROUNDS.md)
<add>
<add>
<ide>
<ide> For further information or to report issues, please see the [Boot2Docker site](http://boot2docker.io)
| 2
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.