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
compress ajax. close gh-1041
a938d7b1282fc0e5c52502c225ae8f0cef219f0a
<ide><path>src/ajax.js <ide> var <ide> ajaxLocParts, <ide> ajaxLocation, <ide> <del> antiCacheValue = jQuery.now(), <add> ajax_nonce = jQuery.now(), <ide> <add> ajax_rquery = /\?/, <ide> rhash = /#.*$/, <add> rts = /([?&])_=[^&]*/, <ide> rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL <ide> // #7653, #8125, #8152: local protocol detection <del> rlocalProtocol = /^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/, <add> rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/, <ide> rnoContent = /^(?:GET|HEAD)$/, <ide> rprotocol = /^\/\//, <del> rquery = /\?/, <del> rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, <del> rts = /([?&])_=[^&]*/, <ide> rurl = /^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/, <ide> <ide> // Keep a copy of the old load method <ide> var <ide> transports = {}, <ide> <ide> // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression <del> allTypes = ["*/"] + ["*"]; <add> allTypes = "*/".concat("*"); <ide> <ide> // #8138, IE may throw an exception when accessing <ide> // a field from window.location if document.domain has been set <ide> function addToPrefiltersOrTransports( structure ) { <ide> dataTypeExpression = "*"; <ide> } <ide> <del> var dataType, list, placeBefore, <del> dataTypes = dataTypeExpression.toLowerCase().split( core_rspace ), <add> var dataType, <ide> i = 0, <del> length = dataTypes.length; <add> dataTypes = dataTypeExpression.toLowerCase().split( core_rspace ); <ide> <ide> if ( jQuery.isFunction( func ) ) { <ide> // For each dataType in the dataTypeExpression <del> for ( ; i < length; i++ ) { <del> dataType = dataTypes[ i ]; <del> // We control if we're asked to add before <del> // any existing element <del> placeBefore = /^\+/.test( dataType ); <del> if ( placeBefore ) { <del> dataType = dataType.substr( 1 ) || "*"; <add> while ( (dataType = dataTypes[i++]) ) { <add> // Prepend if requested <add> if ( dataType[0] === "+" ) { <add> dataType = dataType.slice( 1 ) || "*"; <add> (structure[ dataType ] = structure[ dataType ] || []).unshift( func ); <add> <add> // Otherwise append <add> } else { <add> (structure[ dataType ] = structure[ dataType ] || []).push( func ); <ide> } <del> list = structure[ dataType ] = structure[ dataType ] || []; <del> // then we add to the structure accordingly <del> list[ placeBefore ? "unshift" : "push" ]( func ); <ide> } <ide> } <ide> }; <ide> function inspectPrefiltersOrTransports( structure, options, originalOptions, jqX <ide> function ajaxExtend( target, src ) { <ide> var key, deep, <ide> flatOptions = jQuery.ajaxSettings.flatOptions || {}; <add> <ide> for ( key in src ) { <ide> if ( src[ key ] !== undefined ) { <del> ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ]; <add> ( flatOptions[ key ] ? target : ( deep || (deep = {}) ) )[ key ] = src[ key ]; <ide> } <ide> } <ide> if ( deep ) { <ide> jQuery.extend( true, target, deep ); <ide> } <add> <add> return target; <ide> } <ide> <ide> jQuery.fn.load = function( url, params, callback ) { <ide> if ( typeof url !== "string" && _load ) { <ide> return _load.apply( this, arguments ); <ide> } <ide> <del> // Don't do a request if no elements are being requested <del> if ( !this.length ) { <del> return this; <del> } <del> <ide> var selector, type, response, <ide> self = this, <ide> off = url.indexOf(" "); <ide> jQuery.fn.load = function( url, params, callback ) { <ide> type = "POST"; <ide> } <ide> <del> // Request the remote document <del> jQuery.ajax({ <del> url: url, <del> <del> // if "type" variable is undefined, then "GET" method will be used <del> type: type, <del> dataType: "html", <del> data: params, <del> complete: function( jqXHR, status ) { <del> if ( callback ) { <del> self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] ); <del> } <del> } <del> }).done(function( responseText ) { <del> <del> // Save response for use in complete callback <del> response = arguments; <add> // If we have elements to modify, make the request <add> if ( self.length > 0 ) { <add> jQuery.ajax({ <add> url: url, <ide> <del> // See if a selector was specified <del> self.html( selector ? <add> // if "type" variable is undefined, then "GET" method will be used <add> type: type, <add> dataType: "html", <add> data: params <add> }).done(function( responseText ) { <ide> <del> // Create a dummy div to hold the results <del> jQuery("<div>") <add> // Save response for use in complete callback <add> response = arguments; <ide> <del> // inject the contents of the document in, removing the scripts <del> // to avoid any 'Permission Denied' errors in IE <del> .append( responseText.replace( rscript, "" ) ) <add> self.html( selector ? <ide> <del> // Locate the specified elements <del> .find( selector ) : <add> // If a selector was specified, locate the right elements in a dummy div <add> // Exclude scripts to avoid IE 'Permission Denied' errors <add> jQuery("<div>").append( jQuery.parseHTML( responseText ) ).find( selector ) : <ide> <del> // If not, just inject the full result <del> responseText ); <add> // Otherwise use the full result <add> responseText ); <ide> <del> }); <add> }).complete( callback && function( jqXHR, status ) { <add> self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] ); <add> }); <add> } <ide> <ide> return this; <ide> }; <ide> <ide> // Attach a bunch of functions for handling common AJAX events <del>jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split( " " ), function( i, o ){ <del> jQuery.fn[ o ] = function( f ){ <del> return this.on( o, f ); <add>jQuery.each( [ "ajaxStart", "ajaxStop", "ajaxComplete", "ajaxError", "ajaxSuccess", "ajaxSend" ], function( i, type ){ <add> jQuery.fn[ type ] = function( fn ){ <add> return this.on( type, fn ); <ide> }; <ide> }); <ide> <ide> jQuery.each( [ "get", "post" ], function( i, method ) { <ide> } <ide> <ide> return jQuery.ajax({ <del> type: method, <ide> url: url, <add> type: method, <add> dataType: type, <ide> data: data, <del> success: callback, <del> dataType: type <add> success: callback <ide> }); <ide> }; <ide> }); <ide> <ide> jQuery.extend({ <ide> <del> getScript: function( url, callback ) { <del> return jQuery.get( url, undefined, callback, "script" ); <del> }, <del> <del> getJSON: function( url, data, callback ) { <del> return jQuery.get( url, data, callback, "json" ); <del> }, <del> <del> // Creates a full fledged settings object into target <del> // with both ajaxSettings and settings fields. <del> // If target is omitted, writes into ajaxSettings. <del> ajaxSetup: function( target, settings ) { <del> if ( settings ) { <del> // Building a settings object <del> ajaxExtend( target, jQuery.ajaxSettings ); <del> } else { <del> // Extending ajaxSettings <del> settings = target; <del> target = jQuery.ajaxSettings; <del> } <del> ajaxExtend( target, settings ); <add> // Counter for holding the number of active queries <add> active: 0, <ide> <del> return target; <del> }, <add> // Last-Modified header cache for next request <add> lastModified: {}, <add> etag: {}, <ide> <ide> ajaxSettings: { <ide> url: ajaxLocation, <add> type: "GET", <ide> isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ), <ide> global: true, <del> type: "GET", <del> contentType: "application/x-www-form-urlencoded; charset=UTF-8", <ide> processData: true, <ide> async: true, <add> contentType: "application/x-www-form-urlencoded; charset=UTF-8", <ide> /* <ide> timeout: 0, <ide> data: null, <ide> jQuery.extend({ <ide> */ <ide> <ide> accepts: { <del> xml: "application/xml, text/xml", <del> html: "text/html", <add> "*": allTypes, <ide> text: "text/plain", <del> json: "application/json, text/javascript", <del> "*": allTypes <add> html: "text/html", <add> xml: "application/xml, text/xml", <add> json: "application/json, text/javascript" <ide> }, <ide> <ide> contents: { <ide> jQuery.extend({ <ide> text: "responseText" <ide> }, <ide> <del> // List of data converters <del> // 1) key format is "source_type destination_type" (a single space in-between) <del> // 2) the catchall symbol "*" can be used for source_type <add> // Data converters <add> // Keys separate source (or catchall "*") and destination types with a single space <ide> converters: { <ide> <ide> // Convert anything to text <ide> jQuery.extend({ <ide> // and when you create one that shouldn't be <ide> // deep extended (see ajaxExtend) <ide> flatOptions: { <del> context: true, <del> url: true <add> url: true, <add> context: true <ide> } <ide> }, <ide> <add> // Creates a full fledged settings object into target <add> // with both ajaxSettings and settings fields. <add> // If target is omitted, writes into ajaxSettings. <add> ajaxSetup: function( target, settings ) { <add> return settings ? <add> <add> // Building a settings object <add> ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) : <add> <add> // Extending ajaxSettings <add> ajaxExtend( jQuery.ajaxSettings, target ); <add> }, <add> <ide> ajaxPrefilter: addToPrefiltersOrTransports( prefilters ), <ide> ajaxTransport: addToPrefiltersOrTransports( transports ), <ide> <ide> jQuery.extend({ <ide> // Force options to be an object <ide> options = options || {}; <ide> <del> var // ifModified key <add> var transport, <add> // ifModified key <ide> ifModifiedKey, <ide> // Response headers <ide> responseHeadersString, <ide> responseHeaders, <del> // transport <del> transport, <ide> // timeout handle <ide> timeoutTimer, <ide> // Cross-domain detection vars <ide> jQuery.extend({ <ide> s = jQuery.ajaxSetup( {}, options ), <ide> // Callbacks context <ide> callbackContext = s.context || s, <del> // Context for global events <del> // It's the callbackContext if one was provided in the options <del> // and if it's a DOM node or a jQuery collection <del> globalEventContext = callbackContext !== s && <del> ( callbackContext.nodeType || callbackContext instanceof jQuery ) ? <del> jQuery( callbackContext ) : jQuery.event, <add> // Context for global events is callbackContext if it is a DOM node or jQuery collection <add> globalEventContext = s.context && ( callbackContext.nodeType || callbackContext.jquery ) ? <add> jQuery( callbackContext ) : <add> jQuery.event, <ide> // Deferreds <ide> deferred = jQuery.Deferred(), <del> completeDeferred = jQuery.Callbacks( "once memory" ), <add> completeDeferred = jQuery.Callbacks("once memory"), <ide> // Status-dependent callbacks <ide> statusCode = s.statusCode || {}, <ide> // Headers (they are sent all at once) <ide> jQuery.extend({ <ide> strAbort = "canceled", <ide> // Fake xhr <ide> jqXHR = { <del> <ide> readyState: 0, <ide> <del> // Caches the header <del> setRequestHeader: function( name, value ) { <del> if ( !state ) { <del> var lname = name.toLowerCase(); <del> name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name; <del> requestHeaders[ name ] = value; <del> } <del> return this; <del> }, <del> <del> // Raw string <del> getAllResponseHeaders: function() { <del> return state === 2 ? responseHeadersString : null; <del> }, <del> <ide> // Builds headers hashtable if needed <ide> getResponseHeader: function( key ) { <ide> var match; <ide> if ( state === 2 ) { <ide> if ( !responseHeaders ) { <ide> responseHeaders = {}; <del> while( ( match = rheaders.exec( responseHeadersString ) ) ) { <add> while ( (match = rheaders.exec( responseHeadersString )) ) { <ide> responseHeaders[ match[1].toLowerCase() ] = match[ 2 ]; <ide> } <ide> } <ide> match = responseHeaders[ key.toLowerCase() ]; <ide> } <del> return match === undefined ? null : match; <add> return match == null ? null : match; <add> }, <add> <add> // Raw string <add> getAllResponseHeaders: function() { <add> return state === 2 ? responseHeadersString : null; <add> }, <add> <add> // Caches the header <add> setRequestHeader: function( name, value ) { <add> var lname = name.toLowerCase(); <add> if ( !state ) { <add> name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name; <add> requestHeaders[ name ] = value; <add> } <add> return this; <ide> }, <ide> <ide> // Overrides response content-type header <ide> jQuery.extend({ <ide> return this; <ide> }, <ide> <add> // Status-dependent callbacks <add> statusCode: function( map ) { <add> var code; <add> if ( map ) { <add> if ( state < 2 ) { <add> for ( code in map ) { <add> // Lazy-add the new callback in a way that preserves old ones <add> statusCode[ code ] = [ statusCode[ code ], map[ code ] ]; <add> } <add> } else { <add> // Execute the appropriate callbacks <add> jqXHR.always( map[ jqXHR.status ] ); <add> } <add> } <add> return this; <add> }, <add> <ide> // Cancel the request <ide> abort: function( statusText ) { <del> statusText = statusText || strAbort; <add> var finalText = statusText || strAbort; <ide> if ( transport ) { <del> transport.abort( statusText ); <add> transport.abort( finalText ); <ide> } <del> done( 0, statusText ); <add> done( 0, finalText ); <ide> return this; <ide> } <ide> }; <ide> <del> // Callback for when everything is done <del> // It is defined here because jslint complains if it is declared <del> // at the end of the function (which would be more logical and readable) <del> function done( status, nativeStatusText, responses, headers ) { <del> var isSuccess, success, error, response, modified, <del> statusText = nativeStatusText; <del> <del> // Called once <del> if ( state === 2 ) { <del> return; <del> } <del> <del> // State is "done" now <del> state = 2; <del> <del> // Clear timeout if it exists <del> if ( timeoutTimer ) { <del> clearTimeout( timeoutTimer ); <del> } <del> <del> // Dereference transport for early garbage collection <del> // (no matter how long the jqXHR object will be used) <del> transport = undefined; <del> <del> // Cache response headers <del> responseHeadersString = headers || ""; <del> <del> // Set readyState <del> jqXHR.readyState = status > 0 ? 4 : 0; <del> <del> // Get response data <del> if ( responses ) { <del> response = ajaxHandleResponses( s, jqXHR, responses ); <del> } <del> <del> // If successful, handle type chaining <del> if ( status >= 200 && status < 300 || status === 304 ) { <del> <del> // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. <del> if ( s.ifModified ) { <del> <del> modified = jqXHR.getResponseHeader("Last-Modified"); <del> if ( modified ) { <del> jQuery.lastModified[ ifModifiedKey ] = modified; <del> } <del> modified = jqXHR.getResponseHeader("Etag"); <del> if ( modified ) { <del> jQuery.etag[ ifModifiedKey ] = modified; <del> } <del> } <del> <del> // If not modified <del> if ( status === 304 ) { <del> <del> statusText = "notmodified"; <del> isSuccess = true; <del> <del> // If we have data <del> } else { <del> <del> isSuccess = ajaxConvert( s, response ); <del> statusText = isSuccess.state; <del> success = isSuccess.data; <del> error = isSuccess.error; <del> isSuccess = !error; <del> } <del> } else { <del> // We extract error from statusText <del> // then normalize statusText and status for non-aborts <del> error = statusText; <del> if ( !statusText || status ) { <del> statusText = "error"; <del> if ( status < 0 ) { <del> status = 0; <del> } <del> } <del> } <del> <del> // Set data for the fake xhr object <del> jqXHR.status = status; <del> jqXHR.statusText = ( nativeStatusText || statusText ) + ""; <del> <del> // Success/Error <del> if ( isSuccess ) { <del> deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] ); <del> } else { <del> deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] ); <del> } <del> <del> // Status-dependent callbacks <del> jqXHR.statusCode( statusCode ); <del> statusCode = undefined; <del> <del> if ( fireGlobals ) { <del> globalEventContext.trigger( "ajax" + ( isSuccess ? "Success" : "Error" ), <del> [ jqXHR, s, isSuccess ? success : error ] ); <del> } <del> <del> // Complete <del> completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] ); <del> <del> if ( fireGlobals ) { <del> globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] ); <del> // Handle the global AJAX counter <del> if ( !( --jQuery.active ) ) { <del> jQuery.event.trigger( "ajaxStop" ); <del> } <del> } <del> } <del> <ide> // Attach deferreds <del> deferred.promise( jqXHR ); <add> deferred.promise( jqXHR ).complete = completeDeferred.add; <ide> jqXHR.success = jqXHR.done; <ide> jqXHR.error = jqXHR.fail; <del> jqXHR.complete = completeDeferred.add; <del> <del> // Status-dependent callbacks <del> jqXHR.statusCode = function( map ) { <del> if ( map ) { <del> var tmp; <del> if ( state < 2 ) { <del> for ( tmp in map ) { <del> statusCode[ tmp ] = [ statusCode[tmp], map[tmp] ]; <del> } <del> } else { <del> tmp = map[ jqXHR.status ]; <del> jqXHR.always( tmp ); <del> } <del> } <del> return this; <del> }; <ide> <ide> // Remove hash character (#7531: and string promotion) <ide> // Add protocol if not provided (#5866: IE7 issue with protocol-less urls) <ide> jQuery.extend({ <ide> // We can fire global events as of now if asked to <ide> fireGlobals = s.global; <ide> <add> // Watch for a new set of requests <add> if ( fireGlobals && jQuery.active++ === 0 ) { <add> jQuery.event.trigger("ajaxStart"); <add> } <add> <ide> // Uppercase the type <ide> s.type = s.type.toUpperCase(); <ide> <ide> // Determine if request has content <ide> s.hasContent = !rnoContent.test( s.type ); <ide> <del> // Watch for a new set of requests <del> if ( fireGlobals && jQuery.active++ === 0 ) { <del> jQuery.event.trigger( "ajaxStart" ); <del> } <del> <ide> // More options handling for requests with no content <ide> if ( !s.hasContent ) { <ide> <ide> // If data is available, append data to url <ide> if ( s.data ) { <del> s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.data; <add> s.url += ( ajax_rquery.test( s.url ) ? "&" : "?" ) + s.data; <ide> // #9682: remove data so that it's not used in an eventual retry <ide> delete s.data; <ide> } <ide> jQuery.extend({ <ide> <ide> // Add anti-cache in url if needed <ide> if ( s.cache === false ) { <add> s.url = rts.test( ifModifiedKey ) ? <ide> <del> var ts = antiCacheValue++, <del> // try replacing _= if it is there <del> ret = s.url.replace( rts, "$1_=" + ts ); <add> // If there is already a '_' parameter, set its value <add> ifModifiedKey.replace( rts, "$1_=" + ajax_nonce++ ) : <ide> <del> // if nothing was replaced, add timestamp to the end <del> s.url = ret + ( ( ret === s.url ) ? ( rquery.test( s.url ) ? "&" : "?" ) + "_=" + ts : "" ); <add> // Otherwise add one to the end <add> ifModifiedKey + ( ajax_rquery.test( ifModifiedKey ) ? "&" : "?" ) + "_=" + ajax_nonce++; <ide> } <ide> } <ide> <del> // Set the correct header, if data is being sent <del> if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) { <del> jqXHR.setRequestHeader( "Content-Type", s.contentType ); <del> } <del> <ide> // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. <ide> if ( s.ifModified ) { <ide> ifModifiedKey = ifModifiedKey || s.url; <ide> jQuery.extend({ <ide> } <ide> } <ide> <add> // Set the correct header, if data is being sent <add> if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) { <add> jqXHR.setRequestHeader( "Content-Type", s.contentType ); <add> } <add> <ide> // Set the Accepts header for the server, depending on the dataType <ide> jqXHR.setRequestHeader( <ide> "Accept", <ide> jQuery.extend({ <ide> done( -1, "No Transport" ); <ide> } else { <ide> jqXHR.readyState = 1; <add> <ide> // Send global event <ide> if ( fireGlobals ) { <ide> globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] ); <ide> } <ide> // Timeout <ide> if ( s.async && s.timeout > 0 ) { <del> timeoutTimer = setTimeout( function(){ <del> jqXHR.abort( "timeout" ); <add> timeoutTimer = setTimeout(function() { <add> jqXHR.abort("timeout"); <ide> }, s.timeout ); <ide> } <ide> <ide> try { <ide> state = 1; <ide> transport.send( requestHeaders, done ); <del> } catch (e) { <add> } catch ( e ) { <ide> // Propagate exception as error if not done <ide> if ( state < 2 ) { <ide> done( -1, e ); <ide> jQuery.extend({ <ide> } <ide> } <ide> <add> // Callback for when everything is done <add> function done( status, nativeStatusText, responses, headers ) { <add> var isSuccess, success, error, response, modified, <add> statusText = nativeStatusText; <add> <add> // Called once <add> if ( state === 2 ) { <add> return; <add> } <add> <add> // State is "done" now <add> state = 2; <add> <add> // Clear timeout if it exists <add> if ( timeoutTimer ) { <add> clearTimeout( timeoutTimer ); <add> } <add> <add> // Dereference transport for early garbage collection <add> // (no matter how long the jqXHR object will be used) <add> transport = undefined; <add> <add> // Cache response headers <add> responseHeadersString = headers || ""; <add> <add> // Set readyState <add> jqXHR.readyState = status > 0 ? 4 : 0; <add> <add> // Get response data <add> if ( responses ) { <add> response = ajaxHandleResponses( s, jqXHR, responses ); <add> } <add> <add> // If successful, handle type chaining <add> if ( status >= 200 && status < 300 || status === 304 ) { <add> <add> // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. <add> if ( s.ifModified ) { <add> modified = jqXHR.getResponseHeader("Last-Modified"); <add> if ( modified ) { <add> jQuery.lastModified[ ifModifiedKey ] = modified; <add> } <add> modified = jqXHR.getResponseHeader("etag"); <add> if ( modified ) { <add> jQuery.etag[ ifModifiedKey ] = modified; <add> } <add> } <add> <add> // If not modified <add> if ( status === 304 ) { <add> isSuccess = true; <add> statusText = "notmodified"; <add> <add> // If we have data <add> } else { <add> isSuccess = ajaxConvert( s, response ); <add> statusText = isSuccess.state; <add> success = isSuccess.data; <add> error = isSuccess.error; <add> isSuccess = !error; <add> } <add> } else { <add> // We extract error from statusText <add> // then normalize statusText and status for non-aborts <add> error = statusText; <add> if ( status || !statusText ) { <add> statusText = "error"; <add> if ( status < 0 ) { <add> status = 0; <add> } <add> } <add> } <add> <add> // Set data for the fake xhr object <add> jqXHR.status = status; <add> jqXHR.statusText = ( nativeStatusText || statusText ) + ""; <add> <add> // Success/Error <add> if ( isSuccess ) { <add> deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] ); <add> } else { <add> deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] ); <add> } <add> <add> // Status-dependent callbacks <add> jqXHR.statusCode( statusCode ); <add> statusCode = undefined; <add> <add> if ( fireGlobals ) { <add> globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError", <add> [ jqXHR, s, isSuccess ? success : error ] ); <add> } <add> <add> // Complete <add> completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] ); <add> <add> if ( fireGlobals ) { <add> globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] ); <add> // Handle the global AJAX counter <add> if ( !( --jQuery.active ) ) { <add> jQuery.event.trigger("ajaxStop"); <add> } <add> } <add> } <add> <ide> return jqXHR; <ide> }, <ide> <del> // Counter for holding the number of active queries <del> active: 0, <del> <del> // Last-Modified header cache for next request <del> lastModified: {}, <del> etag: {} <add> getScript: function( url, callback ) { <add> return jQuery.get( url, undefined, callback, "script" ); <add> }, <ide> <add> getJSON: function( url, data, callback ) { <add> return jQuery.get( url, data, callback, "json" ); <add> } <ide> }); <ide> <ide> /* Handles responses to an ajax request: <ide> function ajaxHandleResponses( s, jqXHR, responses ) { <ide> while( dataTypes[ 0 ] === "*" ) { <ide> dataTypes.shift(); <ide> if ( ct === undefined ) { <del> ct = s.mimeType || jqXHR.getResponseHeader( "content-type" ); <add> ct = s.mimeType || jqXHR.getResponseHeader("Content-Type"); <ide> } <ide> } <ide> <ide> function ajaxHandleResponses( s, jqXHR, responses ) { <ide> function ajaxConvert( s, response ) { <ide> <ide> var conv, conv2, current, tmp, <add> converters = {}, <add> i = 0, <ide> // Work with a copy of dataTypes in case we need to modify it for conversion <ide> dataTypes = s.dataTypes.slice(), <del> prev = dataTypes[ 0 ], <del> converters = {}, <del> i = 0; <add> prev = dataTypes[ 0 ]; <ide> <ide> // Apply the dataFilter if provided <ide> if ( s.dataFilter ) { <ide><path>src/ajax/jsonp.js <ide> var oldCallbacks = [], <del> rquestion = /\?/, <del> rjsonp = /(=)\?(?=&|$)|\?\?/, <del> nonce = jQuery.now(); <add> rjsonp = /(=)\?(?=&|$)|\?\?/; <ide> <ide> // Default jsonp settings <ide> jQuery.ajaxSetup({ <ide> jsonp: "callback", <ide> jsonpCallback: function() { <del> var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) ); <add> var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( ajax_nonce++ ) ); <ide> this[ callback ] = true; <ide> return callback; <ide> } <ide> jQuery.ajaxSetup({ <ide> jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { <ide> <ide> var callbackName, overwritten, responseContainer, <del> data = s.data, <del> url = s.url, <del> hasCallback = s.jsonp !== false, <del> replaceInUrl = hasCallback && rjsonp.test( url ), <del> replaceInData = hasCallback && !replaceInUrl && typeof data === "string" && <del> !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") && <del> rjsonp.test( data ); <add> jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ? <add> "url" : <add> typeof s.data === "string" && !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") && rjsonp.test( s.data ) && "data" <add> ); <ide> <ide> // Handle iff the expected data type is "jsonp" or we have a parameter to set <del> if ( s.dataTypes[ 0 ] === "jsonp" || replaceInUrl || replaceInData ) { <add> if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) { <ide> <ide> // Get callback name, remembering preexisting value associated with it <ide> callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ? <ide> s.jsonpCallback() : <ide> s.jsonpCallback; <del> overwritten = window[ callbackName ]; <ide> <ide> // Insert callback into url or form data <del> if ( replaceInUrl ) { <del> s.url = url.replace( rjsonp, "$1" + callbackName ); <del> } else if ( replaceInData ) { <del> s.data = data.replace( rjsonp, "$1" + callbackName ); <del> } else if ( hasCallback ) { <del> s.url += ( rquestion.test( url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName; <add> if ( jsonProp ) { <add> s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName ); <add> } else if ( s.jsonp !== false ) { <add> s.url += ( ajax_rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName; <ide> } <ide> <ide> // Use data converter to retrieve json after script execution <ide> jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { <ide> s.dataTypes[ 0 ] = "json"; <ide> <ide> // Install callback <add> overwritten = window[ callbackName ]; <ide> window[ callbackName ] = function() { <ide> responseContainer = arguments; <ide> }; <ide><path>src/ajax/script.js <ide> jQuery.ajaxSetup({ <ide> script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript" <ide> }, <ide> contents: { <del> script: /javascript|ecmascript/ <add> script: /(?:java|ecma)script/ <ide> }, <ide> converters: { <ide> "text script": function( text ) { <ide> jQuery.ajaxTransport( "script", function(s) { <ide> if ( s.crossDomain ) { <ide> <ide> var script, <del> head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement; <add> head = document.head || jQuery("head")[0] || document.documentElement; <ide> <ide> return { <ide> <ide> send: function( _, callback ) { <ide> <del> script = document.createElement( "script" ); <add> script = document.createElement("script"); <ide> <ide> script.async = true; <ide> <ide> jQuery.ajaxTransport( "script", function(s) { <ide> script.onload = script.onreadystatechange = null; <ide> <ide> // Remove the script <del> if ( head && script.parentNode ) { <del> head.removeChild( script ); <add> if ( script.parentNode ) { <add> script.parentNode.removeChild( script ); <ide> } <ide> <ide> // Dereference the script <del> script = undefined; <add> script = null; <ide> <ide> // Callback if not abort <ide> if ( !isAbort ) { <ide> callback( 200, "success" ); <ide> } <ide> } <ide> }; <del> // Use insertBefore instead of appendChild to circumvent an IE6 bug. <del> // This arises when a base node is used (#2709 and #4378). <add> <add> // Circumvent IE6 bugs with base elements (#2709 and #4378) by prepending <add> // Use native DOM manipulation to avoid our domManip AJAX trickery <ide> head.insertBefore( script, head.firstChild ); <ide> }, <ide> <ide> abort: function() { <ide> if ( script ) { <del> script.onload( 0, 1 ); <add> script.onload( undefined, true ); <ide> } <ide> } <ide> }; <ide><path>src/ajax/xhr.js <del>var xhrCallbacks, <add>var xhrCallbacks, xhrSupported, <add> xhrId = 0, <ide> // #5280: Internet Explorer will keep connections alive if we don't abort on unload <del> xhrOnUnloadAbort = window.ActiveXObject ? function() { <add> xhrOnUnloadAbort = window.ActiveXObject && function() { <ide> // Abort all pending requests <del> for ( var key in xhrCallbacks ) { <del> xhrCallbacks[ key ]( 0, 1 ); <add> var key; <add> for ( key in xhrCallbacks ) { <add> xhrCallbacks[ key ]( undefined, true ); <ide> } <del> } : false, <del> xhrId = 0; <add> }; <ide> <ide> // Functions to create xhrs <ide> function createStandardXHR() { <ide> function createStandardXHR() { <ide> <ide> function createActiveXHR() { <ide> try { <del> return new window.ActiveXObject( "Microsoft.XMLHTTP" ); <add> return new window.ActiveXObject("Microsoft.XMLHTTP"); <ide> } catch( e ) {} <ide> } <ide> <ide> jQuery.ajaxSettings.xhr = window.ActiveXObject ? <ide> createStandardXHR; <ide> <ide> // Determine support properties <del>(function( xhr ) { <del> jQuery.extend( jQuery.support, { <del> ajax: !!xhr, <del> cors: !!xhr && ( "withCredentials" in xhr ) <del> }); <del>})( jQuery.ajaxSettings.xhr() ); <add>xhrSupported = jQuery.ajaxSettings.xhr(); <add>jQuery.support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported ); <add>xhrSupported = jQuery.support.ajax = !!xhrSupported; <ide> <ide> // Create transport if the browser can provide an xhr <del>if ( jQuery.support.ajax ) { <add>if ( xhrSupported ) { <ide> <ide> jQuery.ajaxTransport(function( s ) { <ide> // Cross domain only allowed if supported through XMLHttpRequest <ide> if ( jQuery.support.ajax ) { <ide> // (it can always be set on a per-request basis or even using ajaxSetup) <ide> // For same-domain requests, won't change header if already provided. <ide> if ( !s.crossDomain && !headers["X-Requested-With"] ) { <del> headers[ "X-Requested-With" ] = "XMLHttpRequest"; <add> headers["X-Requested-With"] = "XMLHttpRequest"; <ide> } <ide> <ide> // Need an extra try/catch for cross domain requests in Firefox 3 <ide> if ( jQuery.support.ajax ) { <ide> xhr.abort(); <ide> } <ide> } else { <del> status = xhr.status; <del> responseHeaders = xhr.getAllResponseHeaders(); <ide> responses = {}; <add> status = xhr.status; <ide> xml = xhr.responseXML; <add> responseHeaders = xhr.getAllResponseHeaders(); <ide> <ide> // Construct response list <ide> if ( xml && xml.documentElement /* #4958 */ ) { <ide> if ( jQuery.support.ajax ) { <ide> <ide> abort: function() { <ide> if ( callback ) { <del> callback(0,1); <add> callback( undefined, true ); <ide> } <ide> } <ide> };
4
Java
Java
delete unused code in dataclassrowmapper
0556fdecaa3b228880e7322529a385c5ebbfe5c1
<ide><path>spring-jdbc/src/main/java/org/springframework/jdbc/core/DataClassRowMapper.java <ide> <ide> import org.springframework.beans.BeanUtils; <ide> import org.springframework.beans.TypeConverter; <del>import org.springframework.core.DefaultParameterNameDiscoverer; <del>import org.springframework.core.ParameterNameDiscoverer; <ide> import org.springframework.core.convert.ConversionService; <ide> import org.springframework.lang.Nullable; <ide> import org.springframework.util.Assert; <ide> */ <ide> public class DataClassRowMapper<T> extends BeanPropertyRowMapper<T> { <ide> <del> private static final ParameterNameDiscoverer parameterNameDiscoverer = new DefaultParameterNameDiscoverer(); <del> <ide> @Nullable <ide> private Constructor<T> mappedConstructor; <ide>
1
Java
Java
fix javadoc warnings
2b0d8609231deaf1a3790334f6ffd7dae326aa0e
<ide><path>spring-beans/src/main/java/org/springframework/beans/ExtendedBeanInfo.java <ide> /* <del> * Copyright 2002-2012 the original author or authors. <add> * Copyright 2002-2013 the original author or authors. <ide> * <ide> * Licensed under the Apache License, Version 2.0 (the "License"); <ide> * you may not use this file except in compliance with the License. <ide> * this.foo = foo; <ide> * return this; <ide> * } <del> * }</pre> <add> * }}</pre> <ide> * The standard JavaBeans {@code Introspector} will discover the {@code getFoo} read <ide> * method, but will bypass the {@code #setFoo(Foo)} write method, because its non-void <ide> * returning signature does not comply with the JavaBeans specification. <ide><path>spring-core/src/main/java/org/springframework/util/ObjectUtils.java <ide> /* <del> * Copyright 2002-2012 the original author or authors. <add> * Copyright 2002-2013 the original author or authors. <ide> * <ide> * Licensed under the Apache License, Version 2.0 (the "License"); <ide> * you may not use this file except in compliance with the License. <ide> public static int nullSafeHashCode(short[] array) { <ide> } <ide> <ide> /** <del> * Return the same value as {@code {@link Boolean#hashCode()}}. <add> * Return the same value as {@link Boolean#hashCode()}}. <ide> * @see Boolean#hashCode() <ide> */ <ide> public static int hashCode(boolean bool) { <ide> return bool ? 1231 : 1237; <ide> } <ide> <ide> /** <del> * Return the same value as {@code {@link Double#hashCode()}}. <add> * Return the same value as {@link Double#hashCode()}}. <ide> * @see Double#hashCode() <ide> */ <ide> public static int hashCode(double dbl) { <ide> public static int hashCode(double dbl) { <ide> } <ide> <ide> /** <del> * Return the same value as {@code {@link Float#hashCode()}}. <add> * Return the same value as {@link Float#hashCode()}}. <ide> * @see Float#hashCode() <ide> */ <ide> public static int hashCode(float flt) { <ide> return Float.floatToIntBits(flt); <ide> } <ide> <ide> /** <del> * Return the same value as {@code {@link Long#hashCode()}}. <add> * Return the same value as {@link Long#hashCode()}}. <ide> * @see Long#hashCode() <ide> */ <ide> public static int hashCode(long lng) { <ide><path>spring-core/src/test/java/org/springframework/core/type/CachingMetadataReaderLeakTest.java <ide> import org.springframework.tests.TestGroup; <ide> <ide> /** <del> * Unit test checking the behaviour of {@link CachingMetadataReaderFactory under load. <add> * Unit test checking the behaviour of {@link CachingMetadataReaderFactory} under load. <ide> * If the cache is not controller, this test should fail with an out of memory exception around entry <ide> * 5k. <ide> * <ide><path>spring-web/src/main/java/org/springframework/web/util/UriTemplate.java <ide> /* <del> * Copyright 2002-2012 the original author or authors. <add> * Copyright 2002-2013 the original author or authors. <ide> * <ide> * Licensed under the Apache License, Version 2.0 (the "License"); <ide> * you may not use this file except in compliance with the License. <ide> <ide> /** <ide> * Represents a URI template. A URI template is a URI-like String that contains variables enclosed <del> * by braces ({@code {}, {@code }}), which can be expanded to produce an actual URI. <add> * by braces ({@code {}}), which can be expanded to produce an actual URI. <ide> * <ide> * <p>See {@link #expand(Map)}, {@link #expand(Object[])}, and {@link #match(String)} for example usages. <ide> * <ide><path>src/test/java/org/springframework/aop/config/AopNamespaceHandlerScopeIntegrationTests.java <ide> * Integration tests for scoped proxy use in conjunction with aop: namespace. <ide> * Deemed an integration test because .web mocks and application contexts are required. <ide> * <del> * @see org.springframework.aop.config.AopNamespaceHandlerTests; <add> * @see org.springframework.aop.config.AopNamespaceHandlerTests <ide> * <ide> * @author Rob Harrop <ide> * @author Juergen Hoeller <ide><path>src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorIntegrationTests.java <ide> * Integration tests for auto proxy creation by advisor recognition working in <ide> * conjunction with transaction managment resources. <ide> * <del> * @see org.springframework.aop.framework.autoproxy.AdvisorAutoProxyCreatorTests; <add> * @see org.springframework.aop.framework.autoproxy.AdvisorAutoProxyCreatorTests <ide> * <ide> * @author Rod Johnson <ide> * @author Chris Beams
6
Text
Text
add changelog entry for [ci skip]
e5e3ec20851bb336d0efb7956d115a4b4a4bd9b1
<ide><path>activerecord/CHANGELOG.md <add>* Do not set `sql_mode` if `strict: :default` is specified. <add> <add> ``` <add> # database.yml <add> production: <add> adapter: mysql2 <add> database: foo_prod <add> user: foo <add> strict: :default <add> ``` <add> <add> *Ryuta Kamizono* <add> <ide> * SQLite: `:collation` support for string and text columns. <ide> <ide> Example:
1
Go
Go
use mount package to unmount container stuff
d6558ad6a4552fc745e893f93ae190710d1a36bc
<ide><path>container/container_linux.go <del>package container // import "github.com/docker/docker/container" <del> <del>import ( <del> "golang.org/x/sys/unix" <del>) <del> <del>func detachMounted(path string) error { <del> return unix.Unmount(path, unix.MNT_DETACH) <del>} <ide><path>container/container_notlinux.go <del>// +build freebsd <del> <del>package container // import "github.com/docker/docker/container" <del> <del>import ( <del> "golang.org/x/sys/unix" <del>) <del> <del>func detachMounted(path string) error { <del> // FreeBSD do not support the lazy unmount or MNT_DETACH feature. <del> // Therefore there are separate definitions for this. <del> return unix.Unmount(path, 0) <del>} <del> <del>// SecretMounts returns the mounts for the secret path <del>func (container *Container) SecretMounts() []Mount { <del> return nil <del>} <del> <del>// UnmountSecrets unmounts the fs for secrets <del>func (container *Container) UnmountSecrets() error { <del> return nil <del>} <ide><path>container/container_unix.go <del>// +build linux freebsd <add>// +build !windows <ide> <ide> package container // import "github.com/docker/docker/container" <ide> <ide> func (container *Container) DetachAndUnmount(volumeEventLog func(name, action st <ide> } <ide> <ide> for _, mountPath := range mountPaths { <del> if err := detachMounted(mountPath); err != nil { <add> if err := mount.Unmount(mountPath); err != nil { <ide> logrus.Warnf("%s unmountVolumes: Failed to do lazy umount fo volume '%s': %v", container.ID, mountPath, err) <ide> } <ide> }
3
Text
Text
add cgroups freezer info
3957d72f9cd613fa8a0eeb03517e4f78f9cc58f1
<ide><path>docs/sources/reference/commandline/cli.md <ide> log entry. <ide> <ide> Usage: docker pause CONTAINER <ide> <del> Pause all processes within a container <add> Pause uses the cgroups freezer to suspend all processes in a container. <add> Traditionally when suspending a process the SIGSTOP signal is used, <add> which is observable by the process being suspended. With the cgroups freezer <add> the process is unaware, and unable to capture, that it is being suspended, <add> and subsequently resumed. <add> <add> For for information on the cgroups freezer see: <add> https://www.kernel.org/doc/Documentation/cgroups/freezer-subsystem.txt <ide> <ide> ## ps <ide> <ide> them to [*Share Images via Repositories*]( <ide> <ide> Usage: docker unpause CONTAINER <ide> <del> Pause all processes within a container <add> Resumes a paused container. <ide> <ide> ## version <ide>
1
PHP
PHP
apply fixes from styleci
015ea8fd59e7a1bd38d08a3036ce08c045fe9075
<ide><path>tests/Queue/QueueDatabaseQueueUnitTest.php <ide> public function testBulkBatchPushesOntoDatabase() <ide> public function testBuildDatabaseRecordWithPayloadAtTheEnd() <ide> { <ide> $queue = m::mock('Illuminate\Queue\DatabaseQueue'); <del> $record = $queue->buildDatabaseRecord('queue','any_payload',0); <add> $record = $queue->buildDatabaseRecord('queue', 'any_payload', 0); <ide> $this->assertArrayHasKey('payload', $record); <del> $this->assertArrayHasKey('payload', array_slice($record, -1, 1, TRUE)); <add> $this->assertArrayHasKey('payload', array_slice($record, -1, 1, true)); <ide> } <ide> }
1
PHP
PHP
create a test that a chain can be added
77676a28826edb3a748ee8981ea9cf8499d4fd75
<ide><path>tests/Bus/BusBatchTest.php <ide> use Illuminate\Bus\BatchFactory; <ide> use Illuminate\Bus\DatabaseBatchRepository; <ide> use Illuminate\Bus\PendingBatch; <add>use Illuminate\Bus\Queueable; <ide> use Illuminate\Container\Container; <ide> use Illuminate\Contracts\Queue\Factory; <add>use Illuminate\Contracts\Queue\ShouldQueue; <ide> use Illuminate\Database\Capsule\Manager as DB; <ide> use Illuminate\Database\Eloquent\Model; <add>use Illuminate\Foundation\Bus\Dispatchable; <ide> use Illuminate\Queue\CallQueuedClosure; <add>use Illuminate\Queue\InteractsWithQueue; <add>use Illuminate\Queue\SerializesModels; <ide> use Mockery as m; <ide> use PHPUnit\Framework\TestCase; <ide> use RuntimeException; <ide> public function test_batch_state_can_be_inspected() <ide> $this->assertTrue(is_string(json_encode($batch))); <ide> } <ide> <add> public function test_chain_can_be_added_to_batch() <add> { <add> $queue = m::mock(Factory::class); <add> <add> $batch = $this->createTestBatch($queue); <add> <add> $chainHeadJob = new class implements ShouldQueue { <add> use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, Batchable; <add> }; <add> <add> $secondJob = new class implements ShouldQueue { <add> use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, Batchable; <add> }; <add> <add> $thirdJob = new class implements ShouldQueue { <add> use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, Batchable; <add> }; <add> <add> $queue->shouldReceive('connection')->once() <add> ->with('test-connection') <add> ->andReturn($connection = m::mock(stdClass::class)); <add> <add> $connection->shouldReceive('bulk')->once()->with(\Mockery::on(function ($args) use ($chainHeadJob, $secondJob, $thirdJob) { <add> return <add> $args[0] == $chainHeadJob <add> && serialize($secondJob) == $args[0]->chained[0] <add> && serialize($thirdJob) == $args[0]->chained[1]; <add> }), '', 'test-queue'); <add> <add> $batch = $batch->add([ <add> [$chainHeadJob, $secondJob, $thirdJob] <add> ]); <add> <add> $this->assertEquals(3, $batch->totalJobs); <add> $this->assertEquals(3, $batch->pendingJobs); <add> $this->assertTrue(is_string($chainHeadJob->batchId)); <add> $this->assertTrue(is_string($secondJob->batchId)); <add> $this->assertTrue(is_string($thirdJob->batchId)); <add> $this->assertInstanceOf(CarbonImmutable::class, $batch->createdAt); <add> } <add> <ide> protected function createTestBatch($queue, $allowFailures = false) <ide> { <ide> $repository = new DatabaseBatchRepository(new BatchFactory($queue), DB::connection(), 'job_batches');
1
PHP
PHP
add tests for plugin() method
3a595147fd1744e19b2ca94316c77aad3737f66a
<ide><path>src/Routing/ScopedRouteCollection.php <ide> public function prefix($name, callable $callback) { <ide> * @param callable $callback The callback to invoke that builds the plugin routes. <ide> * Only required when $options is defined. <ide> * @return void <del>* @throws \Cake\Error\Exception When an invalid callback is provided <ide> */ <ide> public function plugin($name, $options = [], $callback = null) { <ide> if ($callback === null) { <ide> $callback = $options; <ide> $options = []; <ide> } <del> $params = ['plugin' => $name]; <del> if (empty($optons['path'])) { <add> $params = ['plugin' => $name] + $this->_params; <add> if (empty($options['path'])) { <ide> $options['path'] = '/' . Inflector::underscore($name); <ide> } <del> return Router::scope($options['path'], $params, $callback); <add> $options['path'] = $this->_path . $options['path']; <add> Router::scope($options['path'], $params, $callback); <ide> } <ide> <ide> /** <ide><path>tests/TestCase/Routing/ScopedRouteCollectionTest.php <ide> public function testNestedPrefix() { <ide> $this->assertNull($res); <ide> } <ide> <add>/** <add> * Test creating sub-scopes with plugin() <add> * <add> * @return void <add> */ <add> public function testNestedPlugin() { <add> $routes = new ScopedRouteCollection('/b', ['key' => 'value']); <add> $res = $routes->plugin('Contacts', function($r) { <add> $this->assertEquals('/b/contacts', $r->path()); <add> $this->assertEquals(['plugin' => 'Contacts', 'key' => 'value'], $r->params()); <add> }); <add> $this->assertNull($res); <add> } <add> <add>/** <add> * Test creating sub-scopes with plugin() + path option <add> * <add> * @return void <add> */ <add> public function testNestedPluginPathOption() { <add> $routes = new ScopedRouteCollection('/b', ['key' => 'value']); <add> $routes->plugin('Contacts', ['path' => '/people'], function($r) { <add> $this->assertEquals('/b/people', $r->path()); <add> $this->assertEquals(['plugin' => 'Contacts', 'key' => 'value'], $r->params()); <add> }); <add> } <add> <ide> }
2
Text
Text
improve vm.md copy
baeed8b3d93efb337a09c902e259c0695d179a15
<ide><path>doc/api/vm.md <ide> <ide> <!--name=vm--> <ide> <del>You can access this module with: <add>The `vm` module provides APIs for compiling and running code within V8 Virtual <add>Machine contexts. It can be accessed using: <ide> <ide> ```js <ide> const vm = require('vm'); <ide> const vm = require('vm'); <ide> JavaScript code can be compiled and run immediately or compiled, saved, and run <ide> later. <ide> <del>## Class: Script <add>## Class: vm.Script <ide> <del>A class for holding precompiled scripts, and running them in specific sandboxes. <add>Instances of the `vm.Script` class contain precompiled scripts that can be <add>executed in specific sandboxes (or "contexts"). <ide> <ide> ### new vm.Script(code, options) <ide> <del>Creating a new `Script` compiles `code` but does not run it. Instead, the <del>created `vm.Script` object represents this compiled code. This script can be run <del>later many times using methods below. The returned script is not bound to any <del>global object. It is bound before each run, just for that run. <del> <del>The options when creating a script are: <del> <del>- `filename`: allows you to control the filename that shows up in any stack <del> traces produced from this script. <del>- `lineOffset`: allows you to add an offset to the line number that is <del> displayed in stack traces <del>- `columnOffset`: allows you to add an offset to the column number that is <del> displayed in stack traces <del>- `displayErrors`: if `true`, on error, attach the line of code that caused <del> the error to the stack trace. Applies only to syntax errors compiling the <del> code; errors while running the code are controlled by the options to the <del> script's methods. <del>- `timeout`: a number of milliseconds to execute `code` before terminating <del> execution. If execution is terminated, an [`Error`][] will be thrown. <del>- `cachedData`: an optional `Buffer` with V8's code cache data for the supplied <del> source. When supplied `cachedDataRejected` value will be set to either <del> `true` or `false` depending on acceptance of the data by V8. <del>- `produceCachedData`: if `true` and no `cachedData` is present - V8 tries to <del> produce code cache data for `code`. Upon success, a `Buffer` with V8's code <del> cache data will be produced and stored in `cachedData` property of the <del> returned `vm.Script` instance. `cachedDataProduced` value will be set to <del> either `true` or `false` depending on whether code cache data is produced <del> successfully. <add>* `code` {string} The JavaScript code to compile. <add>* `options` <add> * `filename` {string} Specifies the filename used in stack traces produced <add> by this script. <add> * `lineOffset` {number} Specifies the line number offset that is displayed <add> in stack traces produced by this script. <add> * `columnOffset` {number} Specifies the column number offset that is displayed <add> in stack traces produced by this script. <add> * `displayErrors` {boolean} When `true`, if an [`Error`][] error occurs <add> while compiling the `code`, the line of code causing the error is attached <add> to the stack trace. <add> * `timeout` {number} Specifies the number of milliseconds to execute `code` <add> before terminating execution. If execution is terminated, an [`Error`][] <add> will be thrown. <add> * `cachedData` {Buffer} Provides an optional `Buffer` with V8's code cache <add> data for the supplied source. When supplied, the `cachedDataRejected` value <add> will be set to either `true` or `false` depending on acceptance of the data <add> by V8. <add> * `produceCachedData` {boolean} When `true` and no `cachedData` is present, V8 <add> will attempt to produce code cache data for `code`. Upon success, a <add> `Buffer` with V8's code cache data will be produced and stored in the <add> `cachedData` property of the returned `vm.Script` instance. <add> The `cachedDataProduced` value will be set to either `true` or `false` <add> depending on whether code cache data is produced successfully. <add> <add>Creating a new `vm.Script` object compiles `code` but does not run it. The <add>compiled `vm.Script` can be run later multiple times. It is important to note <add>that the `code` is not bound to any global object; rather, it is bound before <add>each run, just for that run. <ide> <ide> ### script.runInContext(contextifiedSandbox[, options]) <ide> <del>Similar to [`vm.runInContext()`][] but a method of a precompiled `Script` <del>object. `script.runInContext()` runs `script`'s compiled code in <add>* `contextifiedSandbox` {Object} A [contextified][] object as returned by the <add> `vm.createContext()` method. <add>* `options` {Object} <add> * `filename` {string} Specifies the filename used in stack traces produced <add> by this script. <add> * `lineOffset` {number} Specifies the line number offset that is displayed <add> in stack traces produced by this script. <add> * `columnOffset` {number} Specifies the column number offset that is displayed <add> in stack traces produced by this script. <add> * `displayErrors` {boolean} When `true`, if an [`Error`][] error occurs <add> while compiling the `code`, the line of code causing the error is attached <add> to the stack trace. <add> * `timeout` {number} Specifies the number of milliseconds to execute `code` <add> before terminating execution. If execution is terminated, an [`Error`][] <add> will be thrown. <add> <add>Runs the compiled code contained by the `vm.Script` object within the given <ide> `contextifiedSandbox` and returns the result. Running code does not have access <ide> to local scope. <ide> <del>`script.runInContext()` takes the same options as <del>[`script.runInThisContext()`][]. <del> <del>Example: compile code that increments a global variable and sets one, then <del>execute the code multiple times. These globals are contained in the sandbox. <add>The following example compiles code that increments a global variable, sets <add>the value of another global variable, then execute the code multiple times. <add>The globals are contained in the `sandbox` object. <ide> <ide> ```js <ide> const util = require('util'); <ide> const vm = require('vm'); <ide> <del>var sandbox = { <add>const sandbox = { <ide> animal: 'cat', <ide> count: 2 <ide> }; <ide> <del>var context = new vm.createContext(sandbox); <del>var script = new vm.Script('count += 1; name = "kitty"'); <add>const script = new vm.Script('count += 1; name = "kitty";'); <ide> <add>const context = new vm.createContext(sandbox); <ide> for (var i = 0; i < 10; ++i) { <ide> script.runInContext(context); <ide> } <ide> console.log(util.inspect(sandbox)); <ide> // { animal: 'cat', count: 12, name: 'kitty' } <ide> ``` <ide> <del>Note that running untrusted code is a tricky business requiring great care. <del>`script.runInContext()` is quite useful, but safely running untrusted code <del>requires a separate process. <del> <ide> ### script.runInNewContext([sandbox][, options]) <ide> <del>Similar to [`vm.runInNewContext()`][] but a method of a precompiled `Script` <del>object. `script.runInNewContext()` contextifies `sandbox` if passed or creates a <del>new contextified sandbox if it's omitted, and then runs `script`'s compiled code <del>with the sandbox as the global object and returns the result. Running code does <del>not have access to local scope. <del> <del>`script.runInNewContext()` takes the same options as <del>[`script.runInThisContext()`][]. <del> <del>Example: compile code that sets a global variable, then execute the code <del>multiple times in different contexts. These globals are set on and contained in <del>the sandboxes. <add>* `sandbox` {Object} An object that will be [contextified][]. If `undefined`, a <add> new object will be created. <add>* `options` {Object} <add> * `filename` {string} Specifies the filename used in stack traces produced <add> by this script. <add> * `lineOffset` {number} Specifies the line number offset that is displayed <add> in stack traces produced by this script. <add> * `columnOffset` {number} Specifies the column number offset that is displayed <add> in stack traces produced by this script. <add> * `displayErrors` {boolean} When `true`, if an [`Error`][] error occurs <add> while compiling the `code`, the line of code causing the error is attached <add> to the stack trace. <add> * `timeout` {number} Specifies the number of milliseconds to execute `code` <add> before terminating execution. If execution is terminated, an [`Error`][] <add> will be thrown. <add> <add>First contextifies the given `sandbox`, runs the compiled code contained by <add>the `vm.Script` object within the created sandbox, and returns the result. <add>Running code does not have access to local scope. <add> <add>The following example compiles code that sets a global variable, then executes <add>the code multiple times in different contexts. The globals are set on and <add>contained within each individual `sandbox`. <ide> <ide> ```js <ide> const util = require('util'); <ide> const vm = require('vm'); <ide> <del>const sandboxes = [{}, {}, {}]; <del> <ide> const script = new vm.Script('globalVar = "set"'); <ide> <add>const sandboxes = [{}, {}, {}]; <ide> sandboxes.forEach((sandbox) => { <ide> script.runInNewContext(sandbox); <ide> }); <ide> console.log(util.inspect(sandboxes)); <ide> // [{ globalVar: 'set' }, { globalVar: 'set' }, { globalVar: 'set' }] <ide> ``` <ide> <del>Note that running untrusted code is a tricky business requiring great care. <del>`script.runInNewContext()` is quite useful, but safely running untrusted code <del>requires a separate process. <del> <ide> ### script.runInThisContext([options]) <ide> <del>Similar to [`vm.runInThisContext()`][] but a method of a precompiled `Script` <del>object. `script.runInThisContext()` runs `script`'s compiled code and returns <del>the result. Running code does not have access to local scope, but does have <del>access to the current `global` object. <del> <del>Example of using `script.runInThisContext()` to compile code once and run it <del>multiple times: <add>* `options` {Object} <add> * `filename` {string} Specifies the filename used in stack traces produced <add> by this script. <add> * `lineOffset` {number} Specifies the line number offset that is displayed <add> in stack traces produced by this script. <add> * `columnOffset` {number} Specifies the column number offset that is displayed <add> in stack traces produced by this script. <add> * `displayErrors` {boolean} When `true`, if an [`Error`][] error occurs <add> while compiling the `code`, the line of code causing the error is attached <add> to the stack trace. <add> * `timeout` {number} Specifies the number of milliseconds to execute `code` <add> before terminating execution. If execution is terminated, an [`Error`][] <add> will be thrown. <add> <add>Runs the compiled code contained by the `vm.Script` within the context of the <add>current `global` object. Running code does not have access to local scope, but <add>*does* have access to the current `global` object. <add> <add>The following example compiles code that increments a `global` variable then <add>executes that code multiple times: <ide> <ide> ```js <ide> const vm = require('vm'); <ide> console.log(globalVar); <ide> // 1000 <ide> ``` <ide> <del>The options for running a script are: <del> <del>- `filename`: allows you to control the filename that shows up in any stack <del> traces produced. <del>- `lineOffset`: allows you to add an offset to the line number that is <del> displayed in stack traces <del>- `columnOffset`: allows you to add an offset to the column number that is <del> displayed in stack traces <del>- `displayErrors`: if `true`, on error, attach the line of code that caused <del> the error to the stack trace. Applies only to runtime errors executing the <del> code; it is impossible to create a `Script` instance with syntax errors, as <del> the constructor will throw. <del>- `timeout`: a number of milliseconds to execute the script before terminating <del> execution. If execution is terminated, an [`Error`][] will be thrown. <del> <ide> ## vm.createContext([sandbox]) <ide> <del>If given a `sandbox` object, will "contextify" that sandbox so that it can be <add>* `sandbox` {Object} <add> <add>If given a `sandbox` object, the `vm.createContext()` method will [prepare <add>that sandbox][#vm_what_does_it_mean_to_contextify_an_object] so that it can be <ide> used in calls to [`vm.runInContext()`][] or [`script.runInContext()`][]. Inside <del>scripts run as such, `sandbox` will be the global object, retaining all its <del>existing properties but also having the built-in objects and functions any <add>such scripts, the `sandbox` object will be the global object, retaining all of <add>its existing properties but also having the built-in objects and functions any <ide> standard [global object][] has. Outside of scripts run by the vm module, <del>`sandbox` will be unchanged. <add>`sandbox` will remain unchanged. <ide> <del>If not given a sandbox object, returns a new, empty contextified sandbox object <del>you can use. <add>If `sandbox` is omitted (or passed explicitly as `undefined`), a new, empty <add>[contextified][] sandbox object will be returned. <ide> <del>This function is useful for creating a sandbox that can be used to run multiple <del>scripts, e.g. if you were emulating a web browser it could be used to create a <del>single sandbox representing a window's global object, then run all `<script>` <del>tags together inside that sandbox. <add>The `vm.createContext()` method is primarily useful for creating a single <add>sandbox that can be used to run multiple scripts. For instance, if emulating a <add>web browser, the method can be used to create a single sandbox representing a <add>window's global object, then run all `<script>` tags together within the context <add>of that sandbox. <ide> <ide> ## vm.isContext(sandbox) <ide> <del>Returns whether or not a sandbox object has been contextified by calling <del>[`vm.createContext()`][] on it. <del> <del>## vm.runInContext(code, contextifiedSandbox[, options]) <add>* `sandbox` {Object} <ide> <del>`vm.runInContext()` compiles `code`, then runs it in `contextifiedSandbox` and <del>returns the result. Running code does not have access to local scope. The <del>`contextifiedSandbox` object must have been previously contextified via <del>[`vm.createContext()`][]; it will be used as the global object for `code`. <add>Returns `true` if the given `sandbox` object has been [contextified][] using <add>[`vm.createContext()`][]. <ide> <del>`vm.runInContext()` takes the same options as [`vm.runInThisContext()`][]. <add>## vm.runInContext(code, contextifiedSandbox[, options]) <ide> <del>Example: compile and execute different scripts in a single existing context. <add>* `code` {string} The JavaScript code to compile and run. <add>* `contextifiedSandbox` {Object} The [contextified][] object that will be used <add> as the `global` when the `code` is compiled and run. <add>* `options` <add> * `filename` {string} Specifies the filename used in stack traces produced <add> by this script. <add> * `lineOffset` {number} Specifies the line number offset that is displayed <add> in stack traces produced by this script. <add> * `columnOffset` {number} Specifies the column number offset that is displayed <add> in stack traces produced by this script. <add> * `displayErrors` {boolean} When `true`, if an [`Error`][] error occurs <add> while compiling the `code`, the line of code causing the error is attached <add> to the stack trace. <add> * `timeout` {number} Specifies the number of milliseconds to execute `code` <add> before terminating execution. If execution is terminated, an [`Error`][] <add> will be thrown. <add> <add>The `vm.runInContext()` method compiles `code`, runs it within the context of <add>the `contextifiedSandbox`, then returns the result. Running code does not have <add>access to the local scope. The `contextifiedSandbox` object *must* have been <add>previously [contextified][] using the [`vm.createContext()`][] method. <add> <add>The following example compiles and executes different scripts using a single <add>[contextified][] object: <ide> <ide> ```js <ide> const util = require('util'); <ide> const sandbox = { globalVar: 1 }; <ide> vm.createContext(sandbox); <ide> <ide> for (var i = 0; i < 10; ++i) { <del> vm.runInContext('globalVar *= 2;', sandbox); <add> vm.runInContext('globalVar *= 2;', sandbox); <ide> } <ide> console.log(util.inspect(sandbox)); <ide> <ide> // { globalVar: 1024 } <ide> ``` <ide> <del>Note that running untrusted code is a tricky business requiring great care. <del>`vm.runInContext()` is quite useful, but safely running untrusted code requires <del>a separate process. <del> <ide> ## vm.runInDebugContext(code) <ide> <del>`vm.runInDebugContext()` compiles and executes `code` inside the V8 debug <del>context. The primary use case is to get access to the V8 debug object: <add>* `code` {string} The JavaScript code to compile and run. <add> <add>The `vm.runInDebugContext()` method compiles and executes `code` inside the V8 <add>debug context. The primary use case is to gain access to the V8 `Debug` object: <ide> <ide> ```js <ide> const vm = require('vm'); <ide> console.log(Debug.findScript(process.emit).name); // 'events.js' <ide> console.log(Debug.findScript(process.exit).name); // 'internal/process.js' <ide> ``` <ide> <del>Note that the debug context and object are intrinsically tied to V8's debugger <del>implementation and may change (or even get removed) without prior warning. <add>*Note*: The debug context and object are intrinsically tied to V8's debugger <add>implementation and may change (or even be removed) without prior warning. <ide> <del>The debug object can also be exposed with the `--expose_debug_as=` switch. <add>The `Debug` object can also be made available using the V8-specific <add>`--expose_debug_as=` [command line option][cli.md]. <ide> <ide> ## vm.runInNewContext(code[, sandbox][, options]) <ide> <del>`vm.runInNewContext()` compiles `code`, contextifies `sandbox` if passed or <del>creates a new contextified sandbox if it's omitted, and then runs the code with <del>the sandbox as the global object and returns the result. <del> <del>`vm.runInNewContext()` takes the same options as [`vm.runInThisContext()`][]. <del> <del>Example: compile and execute code that increments a global variable and sets a <del>new one. These globals are contained in the sandbox. <add>* `code` {string} The JavaScript code to compile and run. <add>* `sandbox` {Object} An object that will be [contextified][]. If `undefined`, a <add> new object will be created. <add>* `options` <add> * `filename` {string} Specifies the filename used in stack traces produced <add> by this script. <add> * `lineOffset` {number} Specifies the line number offset that is displayed <add> in stack traces produced by this script. <add> * `columnOffset` {number} Specifies the column number offset that is displayed <add> in stack traces produced by this script. <add> * `displayErrors` {boolean} When `true`, if an [`Error`][] error occurs <add> while compiling the `code`, the line of code causing the error is attached <add> to the stack trace. <add> * `timeout` {number} Specifies the number of milliseconds to execute `code` <add> before terminating execution. If execution is terminated, an [`Error`][] <add> will be thrown. <add> <add>The `vm.runInContext()` first contextifies the given `sandbox` object (or <add>creates a new `sandbox` if passed as `undefined`), compiles the `code`, runs it <add>within the context of the created context, then returns the result. Running code <add>does not have access to the local scope. <add> <add>The following example compiles and executes code that increments a global <add>variable and sets a new one. These globals are contained in the `sandbox`. <ide> <ide> ```js <ide> const util = require('util'); <ide> console.log(util.inspect(sandbox)); <ide> // { animal: 'cat', count: 3, name: 'kitty' } <ide> ``` <ide> <del>Note that running untrusted code is a tricky business requiring great care. <del>`vm.runInNewContext()` is quite useful, but safely running untrusted code requires <del>a separate process. <del> <ide> ## vm.runInThisContext(code[, options]) <ide> <del>`vm.runInThisContext()` compiles `code`, runs it and returns the result. Running <del>code does not have access to local scope, but does have access to the current <del>`global` object. <del> <del>Example of using `vm.runInThisContext()` and [`eval()`][] to run the same code: <add>* `code` {string} The JavaScript code to compile and run. <add>* `options` <add> * `filename` {string} Specifies the filename used in stack traces produced <add> by this script. <add> * `lineOffset` {number} Specifies the line number offset that is displayed <add> in stack traces produced by this script. <add> * `columnOffset` {number} Specifies the column number offset that is displayed <add> in stack traces produced by this script. <add> * `displayErrors` {boolean} When `true`, if an [`Error`][] error occurs <add> while compiling the `code`, the line of code causing the error is attached <add> to the stack trace. <add> * `timeout` {number} Specifies the number of milliseconds to execute `code` <add> before terminating execution. If execution is terminated, an [`Error`][] <add> will be thrown. <add> <add>`vm.runInThisContext()` compiles `code`, runs it within the context of the <add>current `global` and returns the result. Running code does not have access to <add>local scope, but does have access to the current `global` object. <add> <add>The following example illustrates using both `vm.runInThisContext()` and <add>the JavaScript [`eval()`][] function to run the same code: <ide> <ide> ```js <ide> const vm = require('vm'); <ide> console.log('localVar: ', localVar); <ide> // evalResult: 'eval', localVar: 'eval' <ide> ``` <ide> <del>`vm.runInThisContext()` does not have access to the local scope, so `localVar` <del>is unchanged. [`eval()`][] does have access to the local scope, so `localVar` is <del>changed. <del> <del>In this way `vm.runInThisContext()` is much like an [indirect `eval()` call][], <del>e.g. `(0,eval)('code')`. However, it also has the following additional options: <del> <del>- `filename`: allows you to control the filename that shows up in any stack <del> traces produced. <del>- `lineOffset`: allows you to add an offset to the line number that is <del> displayed in stack traces <del>- `columnOffset`: allows you to add an offset to the column number that is <del> displayed in stack traces <del>- `displayErrors`: if `true`, on error, attach the line of code that caused <del> the error to the stack trace. Will capture both syntax errors from compiling <del> `code` and runtime errors thrown by executing the compiled code. Defaults to <del> `true`. <del>- `timeout`: a number of milliseconds to execute `code` before terminating <del> execution. If execution is terminated, an [`Error`][] will be thrown. <del> <del>## Example: Run a Server within a VM <del> <del>The context of `.runInThisContext()` refers to the V8 context. The code passed <del>to this VM context will have it's own isolated scope. To run a simple web server <del>using the `http` module, for instance, the code passed to the context must either <del>call `require('http')` on its own, or have a reference to the `http` module passed <del>to it. For instance: <add>Because `vm.runInThisContext()` does not have access to the local scope, <add>`localVar` is unchanged. In contrast, [`eval()`][] *does* have access to the <add>local scope, so the value `localVar` is changed. In this way <add>`vm.runInThisContext()` is much like an [indirect `eval()` call][], e.g. <add>`(0,eval)('code')`. <add> <add>## Example: Running an HTTP Server within a VM <add> <add>When using either `script.runInThisContext()` or `vm.runInThisContext()`, the <add>code is executed within the current V8 global context. The code passed <add>to this VM context will have its own isolated scope. <add> <add>In order to run a simple web server using the `http` module the code passed to <add>the context must either call `require('http')` on its own, or have a reference <add>to the `http` module passed to it. For instance: <ide> <ide> ```js <ide> 'use strict'; <ide> let code = <ide> vm.runInThisContext(code)(require); <ide> ``` <ide> <del>_Note: `require()` in the above case shares the state with context it is passed <del>from. This might introduce risks when unknown code is executed, e.g. altering <del>objects from the calling thread's context in unwanted ways. It is advisable to <del>run `vm` code in a separate process._ <add>*Note*: The `require()` in the above case shares the state with context it is <add>passed from. This may introduce risks when untrusted code is executed, e.g. <add>altering objects from the calling thread's context in unwanted ways. <add> <add>## What does it mean to "contextify" an object? <add> <add>All JavaScript executed within Node.js runs within the scope of a "context". <add>According to the [V8 Embedder's Guide][]: <add> <add>> In V8, a context is an execution environment that allows separate, unrelated, <add>> JavaScript applications to run in a single instance of V8. You must explicitly <add>> specify the context in which you want any JavaScript code to be run. <add> <add>When the method `vm.createContext()` is called, the `sandbox` object that is <add>passed in (or a newly created object if `sandbox` is `undefined`) is associated <add>internally with a new instance of a V8 Context. This V8 Context provides the <add>`code` run using the `vm` modules methods with an isolated global environment <add>within which it can operate. The process of creating the V8 Context and <add>associating it with the `sandbox` object is what this document refers to as <add>"contextifying" the `sandbox`. <ide> <ide> [indirect `eval()` call]: https://es5.github.io/#x10.4.2 <ide> [global object]: https://es5.github.io/#x15.1 <ide> run `vm` code in a separate process._ <ide> [`vm.runInNewContext()`]: #vm_vm_runinnewcontext_code_sandbox_options <ide> [`vm.runInThisContext()`]: #vm_vm_runinthiscontext_code_options <ide> [`eval()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval <add>[V8 Embedder's Guide]: https://developers.google.com/v8/embed#contexts <add>[contextified]: #vm_what_does_it_mean_to_contextify_an_object
1
Text
Text
add description of multidimensional arrays
b92b49efb6fc4462010a2e321aafa41ac81a8d66
<ide><path>guide/english/csharp/array/index.md <ide> Console.Write(array[1][2]); // Displays 3 (third element of second subarray) <ide> Console.Write(array[1][0]); // Displays 1 (first element of second subarray) <ide> ``` <ide> <add>## Multidimensional array <add>Arrays can have more than one dimension (every element will be represented by more than one index). Example of declaration and initialization of two dimensional array: <add> <add>```csharp <add>string[,] weekDays = new string[2, 3]; <add>``` <add> <add>Having two dimensional array we need to use two indexes to represent the position of element: <add> <add>```csharp <add>weekDays[0,0] = "monday"; <add>weekDays[0,1] = "montag"; <add>weekDays[0,2] = "lundi"; <add>weekDays[1,0] = "tuesday"; <add>weekDays[1,1] = "dienstag"; <add>weekDays[1,2] = "mardi"; <add>``` <add> <add>To check number of dimensions we can use Rank property: <add> <add>```csharp <add>int[,,,] array = new int[6, 4, 2, 8]; <add>Console.WriteLine(array.Rank); // 4 <add>``` <add> <ide> ## Advantages <ide> <ide> * Can be easily accessed in a random manner
1
Text
Text
add changelog entry for
684a040437197f421f31587681301ef6ddd0c4bc
<ide><path>actionpack/CHANGELOG.md <ide> ## Rails 4.0.0 (unreleased) ## <ide> <add>* Fix select_tag when option_tags is nil. <add> Fixes #7404. <add> <add> *Sandeep Ravichandran* <add> <ide> * Add Request#formats=(extensions) that lets you set multiple formats directly in a prioritized order *DHH* <ide> <ide> Example of using this for custom iphone views with an HTML fallback:
1
Javascript
Javascript
use plain objects for write/corked reqs
a3539ae3be51c54f0b2f1619e18980fc1a2cb8d2
<ide><path>lib/_stream_writable.js <ide> util.inherits(Writable, Stream); <ide> <ide> function nop() {} <ide> <del>function WriteReq(chunk, encoding, cb) { <del> this.chunk = chunk; <del> this.encoding = encoding; <del> this.callback = cb; <del> this.next = null; <del>} <del> <ide> function WritableState(options, stream) { <ide> options = options || {}; <ide> <ide> function WritableState(options, stream) { <ide> <ide> // allocate the first CorkedRequest, there is always <ide> // one allocated and free to use, and we maintain at most two <del> this.corkedRequestsFree = new CorkedRequest(this); <add> var corkReq = { next: null, entry: null, finish: undefined }; <add> corkReq.finish = onCorkedFinish.bind(undefined, corkReq, this); <add> this.corkedRequestsFree = corkReq; <ide> } <ide> <ide> WritableState.prototype.getBuffer = function getBuffer() { <ide> function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) { <ide> <ide> if (state.writing || state.corked) { <ide> var last = state.lastBufferedRequest; <del> state.lastBufferedRequest = new WriteReq(chunk, encoding, cb); <add> state.lastBufferedRequest = { chunk, encoding, callback: cb, next: null }; <ide> if (last) { <ide> last.next = state.lastBufferedRequest; <ide> } else { <ide> function clearBuffer(stream, state) { <ide> state.corkedRequestsFree = holder.next; <ide> holder.next = null; <ide> } else { <del> state.corkedRequestsFree = new CorkedRequest(state); <add> var corkReq = { next: null, entry: null, finish: undefined }; <add> corkReq.finish = onCorkedFinish.bind(undefined, corkReq, state); <add> state.corkedRequestsFree = corkReq; <ide> } <ide> } else { <ide> // Slow case, write chunks one-by-one <ide> function endWritable(stream, state, cb) { <ide> stream.writable = false; <ide> } <ide> <del>// It seems a linked list but it is not <del>// there will be only 2 of these for each stream <del>function CorkedRequest(state) { <del> this.next = null; <del> this.entry = null; <del> this.finish = onCorkedFinish.bind(undefined, this, state); <del>} <del> <ide> function onCorkedFinish(corkReq, state, err) { <ide> var entry = corkReq.entry; <ide> corkReq.entry = null;
1
Python
Python
fix loading bertjapanesetokenizer
57b5cb3eaa850a212235fccbd4e5d002aede72b6
<ide><path>transformers/tokenization_auto.py <ide> def from_pretrained(cls, pretrained_model_name_or_path, *inputs, **kwargs): <ide> - contains `albert`: AlbertTokenizer (ALBERT model) <ide> - contains `camembert`: CamembertTokenizer (CamemBERT model) <ide> - contains `roberta`: RobertaTokenizer (RoBERTa model) <add> - contains `bert-base-japanese`: BertJapaneseTokenizer (Bert model) <ide> - contains `bert`: BertTokenizer (Bert model) <ide> - contains `openai-gpt`: OpenAIGPTTokenizer (OpenAI GPT model) <ide> - contains `gpt2`: GPT2Tokenizer (OpenAI GPT-2 model) <ide> def from_pretrained(cls, pretrained_model_name_or_path, *inputs, **kwargs): <ide> return CamembertTokenizer.from_pretrained(pretrained_model_name_or_path, *inputs, **kwargs) <ide> elif 'roberta' in pretrained_model_name_or_path: <ide> return RobertaTokenizer.from_pretrained(pretrained_model_name_or_path, *inputs, **kwargs) <del> elif 'bert-japanese' in pretrained_model_name_or_path: <add> elif 'bert-base-japanese' in pretrained_model_name_or_path: <ide> return BertJapaneseTokenizer.from_pretrained(pretrained_model_name_or_path, *inputs, **kwargs) <ide> elif 'bert' in pretrained_model_name_or_path: <ide> return BertTokenizer.from_pretrained(pretrained_model_name_or_path, *inputs, **kwargs)
1
Go
Go
fix typo in comment
76122f95e9173c1182b8dd44e1aa236a045d4e6a
<ide><path>pkg/plugins/plugins.go <ide> type Plugin struct { <ide> <ide> // error produced by activation <ide> activateErr error <del> // specifies if the activation sequence is completed (not if it is sucessful or not) <add> // specifies if the activation sequence is completed (not if it is successful or not) <ide> activated bool <ide> // wait for activation to finish <ide> activateWait *sync.Cond
1
Javascript
Javascript
fix three_to_webgl conversion
95114947175b47a843d6072c3dc149bcc4eceae6
<ide><path>examples/js/exporters/GLTFExporter.js <ide> //------------------------------------------------------------------------------ <ide> var WEBGL_CONSTANTS = { <ide> POINTS: 0x0000, <del> LINES: 0x0001, <del> LINE_LOOP: 0x0002, <del> LINE_STRIP: 0x0003, <del> TRIANGLES: 0x0004, <del> TRIANGLE_STRIP: 0x0005, <del> TRIANGLE_FAN: 0x0006, <add> LINES: 0x0001, <add> LINE_LOOP: 0x0002, <add> LINE_STRIP: 0x0003, <add> TRIANGLES: 0x0004, <add> TRIANGLE_STRIP: 0x0005, <add> TRIANGLE_FAN: 0x0006, <ide> <ide> UNSIGNED_BYTE: 0x1401, <ide> UNSIGNED_SHORT: 0x1403, <ide> var WEBGL_CONSTANTS = { <ide> ELEMENT_ARRAY_BUFFER: 0x8893, <ide> <ide> NEAREST: 0x2600, <del> LINEAR: 0x2601, <del> NEAREST_MIPMAP_NEAREST: 0x2700, <del> LINEAR_MIPMAP_NEAREST: 0x2701, <del> NEAREST_MIPMAP_LINEAR: 0x2702, <del> LINEAR_MIPMAP_LINEAR: 0x2703 <add> LINEAR: 0x2601, <add> NEAREST_MIPMAP_NEAREST: 0x2700, <add> LINEAR_MIPMAP_NEAREST: 0x2701, <add> NEAREST_MIPMAP_LINEAR: 0x2702, <add> LINEAR_MIPMAP_LINEAR: 0x2703 <ide> }; <ide> <ide> var THREE_TO_WEBGL = { <ide> // @TODO Replace with computed property name [THREE.*] when available on es6 <del> 0x2600: THREE.NearestFilter, <del> 0x2601: THREE.LinearFilter, <del> 0x2700: THREE.NearestMipMapNearestFilter, <del> 0x2701: THREE.LinearMipMapNearestFilter, <del> 0x2702: THREE.NearestMipMapLinearFilter, <del> 0x2703: THREE.LinearMipMapLinearFilter <add> 1003: WEBGL_CONSTANTS.NEAREST, <add> 1004: WEBGL_CONSTANTS.LINEAR, <add> 1005: WEBGL_CONSTANTS.NEAREST_MIPMAP_NEAREST, <add> 1006: WEBGL_CONSTANTS.LINEAR_MIPMAP_NEAREST, <add> 1007: WEBGL_CONSTANTS.NEAREST_MIPMAP_LINEAR, <add> 1008: WEBGL_CONSTANTS.LINEAR_MIPMAP_LINEAR <ide> }; <ide> <ide> //------------------------------------------------------------------------------
1
PHP
PHP
update warning messages
a7443625e240110ceae763e5e2aea30069eb2c3c
<ide><path>src/View/Helper.php <ide> public function __get($name) <ide> if (isset($removed[$name])) { <ide> $method = $removed[$name]; <ide> deprecationWarning(sprintf( <del> 'Helper::$%s is deprecated. Use $view->%s() instead.', <add> 'Helper::$%s is removed. Use $view->%s() instead.', <ide> $name, <ide> $method <ide> )); <ide> public function __get($name) <ide> <ide> if ($name === 'helpers') { <ide> deprecationWarning( <del> 'Helper::$helpers is now deprecated and should be accessed from outside a helper class.' <add> 'Helper::$helpers is now protected and should not be accessed from outside a helper class.' <ide> ); <ide> <ide> return $this->helpers; <ide> public function __set($name, $value) <ide> if (isset($removed[$name])) { <ide> $method = $removed[$name]; <ide> deprecationWarning(sprintf( <del> 'Helper::$%s is deprecated. Use $view->%s() instead.', <add> 'Helper::$%s is removed. Use $view->%s() instead.', <ide> $name, <ide> $method <ide> )); <ide> public function __set($name, $value) <ide> <ide> if ($name === 'helpers') { <ide> deprecationWarning( <del> 'Helper::$helpers is now deprecated and should be accessed from outside a helper class.' <add> 'Helper::$helpers is now protected and should not be accessed from outside a helper class.' <ide> ); <ide> } <ide>
1
PHP
PHP
allow afterresponse chain
4123c8d18807a0b31c8d82a446a46b611875ba28
<ide><path>src/Illuminate/Foundation/Bus/PendingDispatch.php <ide> class PendingDispatch <ide> */ <ide> protected $job; <ide> <add> /** <add> * Indicates if the job should be dispatched immediately after sending the response. <add> * <add> * @var bool <add> */ <add> protected $afterResponse = false; <add> <ide> /** <ide> * Create a new pending job dispatch. <ide> * <ide> public function chain($chain) <ide> return $this; <ide> } <ide> <add> /** <add> * Indicate that the job should be dispatched after the response is sent to the browser. <add> * <add> * @return $this <add> */ <add> public function afterResponse() <add> { <add> $this->afterResponse = true; <add> <add> return $this; <add> } <add> <ide> /** <ide> * Handle the object's destruction. <ide> * <ide> * @return void <ide> */ <ide> public function __destruct() <ide> { <del> app(Dispatcher::class)->dispatch($this->job); <add> if ($this->afterResponse) { <add> app(Dispatcher::class)->dispatchAfterResponse($this->job); <add> } else { <add> app(Dispatcher::class)->dispatch($this->job); <add> } <ide> } <ide> }
1
PHP
PHP
prevent error on flushing empty cache
d29eec6576a47566fc907e7b0adc7052ef1f3ccf
<ide><path>src/Illuminate/Cache/Section.php <ide> public function forget($key) <ide> */ <ide> public function flush() <ide> { <del> $this->store->increment($this->sectionKey()); <add> $this->reset(); <ide> } <ide> <ide> /** <ide> public function sectionItemKey($key) <ide> return $this->name.':'.$this->sectionId().':'.$key; <ide> } <ide> <add> /** <add> * Reset the section, returning a new section identifier <add> * <add> * @return string <add> */ <add> protected function reset() <add> { <add> $this->store->forever($this->sectionKey(), $id = uniqid()); <add> return $id; <add> } <add> <ide> /** <ide> * Get the unique section identifier. <ide> * <ide> protected function sectionId() <ide> <ide> if (is_null($id)) <ide> { <del> $this->store->forever($this->sectionKey(), $id = rand(1, 10000)); <add> $id = $this->reset(); <ide> } <ide> <ide> return $id;
1
Text
Text
adjust tty wording & add inter-doc links
606ff7c6f2cb8ab36bdbbe782eaef66f83a42f08
<ide><path>doc/api/tty.md <ide> However, it can be accessed using: <ide> const tty = require('tty'); <ide> ``` <ide> <del>When Node.js detects that it is being run inside a text terminal ("TTY") <del>context, the `process.stdin` will, by default, be initialized as an instance of <del>`tty.ReadStream` and both `process.stdout` and `process.stderr` will, by <add>When Node.js detects that it is being run with a text terminal ("TTY") <add>attached, [`process.stdin`][] will, by default, be initialized as an instance of <add>`tty.ReadStream` and both [`process.stdout`][] and [`process.stderr`][] will, by <ide> default be instances of `tty.WriteStream`. The preferred method of determining <ide> whether Node.js is being run within a TTY context is to check that the value of <ide> the `process.stdout.isTTY` property is `true`: <ide> false <ide> ``` <ide> <ide> In most cases, there should be little to no reason for an application to <del>create instances of the `tty.ReadStream` and `tty.WriteStream` classes. <add>manually create instances of the `tty.ReadStream` and `tty.WriteStream` <add>classes. <ide> <ide> ## Class: tty.ReadStream <ide> <!-- YAML <ide> added: v0.5.8 <ide> --> <ide> <del>The `tty.ReadStream` class is a subclass of `net.Socket` that represents the <del>readable side of a TTY. In normal circumstances `process.stdin` will be the <add>The `tty.ReadStream` class is a subclass of [`net.Socket`][] that represents the <add>readable side of a TTY. In normal circumstances [`process.stdin`][] will be the <ide> only `tty.ReadStream` instance in a Node.js process and there should be no <ide> reason to create additional instances. <ide> <ide> raw device. Defaults to `false`. <ide> added: v0.5.8 <ide> --> <ide> <del>A `boolean` that is always `true`. <add>A `boolean` that is always `true` for `tty.ReadStream` instances. <ide> <ide> ### readStream.setRawMode(mode) <ide> <!-- YAML <ide> added: v0.5.8 <ide> --> <ide> <ide> The `tty.WriteStream` class is a subclass of `net.Socket` that represents the <del>writable side of a TTY. In normal circumstances, `process.stdout` and <del>`process.stderr` will be the only `tty.WriteStream` instances created for a <add>writable side of a TTY. In normal circumstances, [`process.stdout`][] and <add>[`process.stderr`][] will be the only `tty.WriteStream` instances created for a <ide> Node.js process and there should be no reason to create additional instances. <ide> <ide> ### Event: 'resize' <ide> added: v0.5.8 <ide> The `tty.isatty()` method returns `true` if the given `fd` is associated with <ide> a TTY and `false` if it is not, including whenever `fd` is not a non-negative <ide> integer. <add> <add>[`net.Socket`]: net.html#net_class_net_socket <add>[`process.stdin`]: process.html#process_process_stdin <add>[`process.stdout`]: process.html#process_process_stdout <add>[`process.stderr`]: process.html#process_process_stderr
1
Javascript
Javascript
remove unused variables
4dc6ae2181715157f91372c26d11c3d3ff2742ba
<ide><path>lib/_stream_writable.js <ide> Writable.prototype.pipe = function() { <ide> }; <ide> <ide> <del>function writeAfterEnd(stream, state, cb) { <add>function writeAfterEnd(stream, cb) { <ide> var er = new Error('write after end'); <ide> // TODO: defer error events consistently everywhere, not just the cb <ide> stream.emit('error', er); <ide> Writable.prototype.write = function(chunk, encoding, cb) { <ide> cb = nop; <ide> <ide> if (state.ended) <del> writeAfterEnd(this, state, cb); <add> writeAfterEnd(this, cb); <ide> else if (validChunk(this, state, chunk, cb)) { <ide> state.pendingcb++; <ide> ret = writeOrBuffer(this, state, chunk, encoding, cb); <ide> function onwrite(stream, er) { <ide> onwriteError(stream, state, sync, er, cb); <ide> else { <ide> // Check if we're actually ready to finish, but don't emit yet <del> var finished = needFinish(stream, state); <add> var finished = needFinish(state); <ide> <ide> if (!finished && <ide> !state.corked && <ide> Writable.prototype.end = function(chunk, encoding, cb) { <ide> }; <ide> <ide> <del>function needFinish(stream, state) { <add>function needFinish(state) { <ide> return (state.ending && <ide> state.length === 0 && <ide> state.bufferedRequest === null && <ide> function prefinish(stream, state) { <ide> } <ide> <ide> function finishMaybe(stream, state) { <del> var need = needFinish(stream, state); <add> var need = needFinish(state); <ide> if (need) { <ide> if (state.pendingcb === 0) { <ide> prefinish(stream, state); <ide><path>lib/util.js <ide> function reduceToSingleString(output, base, braces) { <ide> <ide> // NOTE: These type checking functions intentionally don't use `instanceof` <ide> // because it is fragile and can be easily faked with `Object.create()`. <del>const isArray = exports.isArray = Array.isArray; <add>exports.isArray = Array.isArray; <ide> <ide> function isBoolean(arg) { <ide> return typeof arg === 'boolean';
2
PHP
PHP
fix inconsistent types
d82aeb340cc6451182f37e032b326741fedd9444
<ide><path>src/Database/Driver.php <ide> public function supportsQuoting(): bool <ide> /** <ide> * {@inheritDoc} <ide> */ <del> abstract public function queryTranslator($type); <add> abstract public function queryTranslator(string $type); <ide> <ide> /** <ide> * {@inheritDoc} <ide><path>src/Database/SqlDialectTrait.php <ide> public function quoteIdentifier(string $identifier): string <ide> * (select, insert, update, delete) <ide> * @return callable <ide> */ <del> public function queryTranslator($type) <add> public function queryTranslator(string $type) <ide> { <ide> return function ($query) use ($type) { <ide> if ($this->isAutoQuotingEnabled()) {
2
Text
Text
add faq entry on form state
fe4069e101f5bec84423b5bf0f501d19d7e197f9
<ide><path>docs/FAQ.md <ide> - [Do I have to put all my state into Redux? Should I ever use React's setState()?](/docs/faq/OrganizingState.md#do-i-have-to-put-all-my-state-into-redux-should-i-ever-use-reacts-setstate) <ide> - [Can I put functions, promises, or other non-serializable items in my store state?](/docs/faq/OrganizingState.md#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state) <ide> - [How do I organize nested or duplicate data in my state?](/docs/faq/OrganizingState.md#how-do-i-organize-nested-or-duplicate-data-in-my-state) <add> - [Should I put form state or other UI state in my store?](/docs/faq/OrganizingState.md#should-i-put-form-state-or-other-ui-state-in-my-store) <ide> - **Store Setup** <ide> - [Can or should I create multiple stores? Can I import my store directly, and use it in components myself?](/docs/faq/StoreSetup.md#can-or-should-i-create-multiple-stores-can-i-import-my-store-directly-and-use-it-in-components-myself) <ide> - [Is it OK to have more than one middleware chain in my store enhancer? What is the difference between next and dispatch in a middleware function?](/docs/faq/StoreSetup.md#is-it-ok-to-have-more-than-one-middleware-chain-in-my-store-enhancer-what-is-the-difference-between-next-and-dispatch-in-a-middleware-function) <ide> - [What are the benefits of immutability?](/docs/faq/ImmutableData.md#what-are-the-benefits-of-immutability) <ide> - [Why is immutability required by Redux?](/docs/faq/ImmutableData.md#why-is-immutability-required-by-redux) <ide> - [What approaches are there for handling data immutability? Do I have to use Immutable.JS?](/docs/faq/ImmutableData.md#what-approaches-are-there-for-handling-data-immutability-do-i-have-to-use-immutable-js) <del> - [What are the issues with using JavaScript for immutable operations?](/docs/faq/ImmutableData.md#what-are-the-issues-with-using-plain-javascript-for-immutable-operations) <add> - [What are the issues with using JavaScript for immutable operations?](/docs/faq/ImmutableData.md#what-are-the-issues-with-using-plain-javascript-for-immutable-operations) <ide> - **Using Immutable.JS with Redux** <del> <ide> - [Why should I use an immutable-focused library such as Immutable.JS?](/docs/recipes/UsingImmutableJS.md#why-should-i-use-an-immutable-focused-library-such-as-immutable-js) <ide> - [Why should I choose Immutable.JS as an immutable library?](/docs/recipes/UsingImmutableJS.md#why-should-i-choose-immutable-js-as-an-immutable-library) <ide> - [What are the issues with using Immutable.JS?](/docs/recipes/UsingImmutableJS.md#what-are-the-issues-with-using-immutable-js) <ide><path>docs/faq/OrganizingState.md <ide> - [Do I have to put all my state into Redux? Should I ever use React's setState()?](#do-i-have-to-put-all-my-state-into-redux-should-i-ever-use-reacts-setstate) <ide> - [Can I put functions, promises, or other non-serializable items in my store state?](#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state) <ide> - [How do I organize nested or duplicate data in my state?](#how-do-i-organize-nested-or-duplicate-data-in-my-state) <add>- [Should I put form state or other UI state in my store?](#should-i-put-form-state-or-other-ui-state-in-my-store) <ide> <ide> ## Organizing State <ide> <ide> Some common rules of thumb for determining what kind of data should be put into <ide> - Is the same data being used to drive multiple components? <ide> - Is there value to you in being able to restore this state to a given point in time (ie, time travel debugging)? <ide> - Do you want to cache the data (ie, use what's in state if it's already there instead of re-requesting it)? <add>- Do you want to keep this data consistent while hot-reloading UI components (which may lose their internal state when swapped)? <ide> <ide> There are a number of community packages that implement various approaches for storing per-component state in a Redux store instead, such as [redux-ui](https://github.com/tonyhb/redux-ui), [redux-component](https://github.com/tomchentw/redux-component), [redux-react-local](https://github.com/threepointone/redux-react-local), and more. It's also possible to apply Redux's principles and concept of reducers to the task of updating local component state as well, along the lines of `this.setState( (previousState) => reducer(previousState, someAction))`. <ide> <ide> Data with IDs, nesting, or relationships should generally be stored in a “norm <ide> - [Twitter: state shape should be normalized](https://twitter.com/dan_abramov/status/715507260244496384) <ide> - [Stack Overflow: How to handle tree-shaped entities in Redux reducers?](http://stackoverflow.com/questions/32798193/how-to-handle-tree-shaped-entities-in-redux-reducers) <ide> - [Stack Overflow: How to optimize small updates to props of nested components in React + Redux?](http://stackoverflow.com/questions/37264415/how-to-optimize-small-updates-to-props-of-nested-component-in-react-redux) <add> <add> <add>### Should I put form state or other UI state in my store? <add> <add>The [same rules of thumb for deciding what should go in the Redux store](#do-i-have-to-put-all-my-state-into-redux-should-i-ever-use-reacts-setstate) apply for this question as well. <add> <add>**Based on those rules of thumb, most form state doesn't need to go into Redux**, as it's probably not being shared between components. However, that decision is always going to be specific to you and your application. You might choose to keep some form state in Redux because you are editing data that came from the store originally, or because you do need to see the work-in-progress values reflected in other components elsewhere in the application. On the other hand, it may be a lot simpler to keep the form state local to the component, and only dispatch an action to put the data in the store once the user is done with the form. <add> <add>Based on this, in most cases you probably don't need a Redux-based form management library either. We suggest trying these approaches, in this order: <add> <add>- Even if the data is coming from the Redux store, start by writing your form logic by hand. It's likely this is all you'll need. (See [**Gosha Arinich's posts on working with forms in React**](https://goshakkk.name/on-forms-react/) for some excellent guidance on this.) <add>- If you decide that writing forms "manually" is too difficult, try a React-based form library like [Formik](https://github.com/jaredpalmer/formik) or [React-Final-Form](https://github.com/final-form/react-final-form). <add>- If you are absolutely sure you _must_ use a Redux-based form library because the other approaches aren't sufficient, then you may finally want to look at [Redux-Form](https://github.com/erikras/redux-form) and [React-Redux-Form](https://github.com/davidkpiano/react-redux-form). <add> <add>If you are keeping form state in Redux, you should take some time to consider performance characteristics. Dispatching an action on every keystroke of a text input probably isn't worthwhile, and you may want to look into [ways to buffer keystrokes to keep changes local before dispatching](https://blog.isquaredsoftware.com/2017/01/practical-redux-part-7-forms-editing-reducers/). As always, take some time to analyze the overall performance needs of your own application. <add> <add>Other kinds of UI state follow these rules of thumb as well. The classic example is tracking an `isDropdownOpen` flag. In most situations, the rest of the app doesn't care about this, so in most cases it should stay in component state. However, depending on your application, it may make sense to use Redux to [manage dialogs and other popups](https://blog.isquaredsoftware.com/2017/07/practical-redux-part-10-managing-modals/), tabs, expanding panels, and so on. <add> <add> <add>#### Further Information <add> <add>**Articles** <add> <add>- [Gosha Arinich: Writings on Forms in React](https://goshakkk.name/on-forms-react/) <add>- [Practical Redux, Part 6: Connected Lists and Forms](https://blog.isquaredsoftware.com/2017/01/practical-redux-part-6-connected-lists-forms-and-performance/) <add>- [Practical Redux, Part 7: Form Change Handling](https://blog.isquaredsoftware.com/2017/01/practical-redux-part-7-forms-editing-reducers/) <add>- [Practical Redux, Part 10: Managing Modals and Context Menus](https://blog.isquaredsoftware.com/2017/07/practical-redux-part-10-managing-modals/) <add>- [React/Redux Links: Redux UI Management](https://github.com/markerikson/react-redux-links/blob/master/redux-ui-management.md)
2
PHP
PHP
fix docblocks around bool false
49a9b37e81624530582769e369ffd69b7750e5a6
<ide><path>src/Controller/Component/AuthComponent.php <ide> public function redirectUrl($url = null): string <ide> * Triggers `Auth.afterIdentify` event which the authenticate classes can listen <ide> * to. <ide> * <del> * @return array|bool User record data, or false, if the user could not be identified. <add> * @return array|false User record data, or false, if the user could not be identified. <ide> */ <ide> public function identify() <ide> { <ide> public function getAuthenticate(string $alias): ?BaseAuthenticate <ide> /** <ide> * Set a flash message. Uses the Flash component with values from `flash` config. <ide> * <del> * @param string|bool $message The message to set. <add> * @param string|false $message The message to set. False to skip. <ide> * @return void <ide> */ <ide> public function flash($message): void <ide><path>src/Filesystem/File.php <ide> public function open(string $mode = 'r', bool $force = false): bool <ide> /** <ide> * Return the contents of this file as a string. <ide> * <del> * @param string|bool $bytes where to start <add> * @param string|false $bytes where to start <ide> * @param string $mode A `fread` compatible mode. <ide> * @param bool $force If true then the file will be re-opened even if its already opened, otherwise it won't <del> * @return string|bool string on success, false on failure <add> * @return string|false String on success, false on failure <ide> */ <ide> public function read($bytes = false, string $mode = 'rb', bool $force = false) <ide> { <ide><path>src/Mailer/Transport/SmtpTransport.php <ide> protected function _generateSocket(): void <ide> * Protected method for sending data to SMTP connection <ide> * <ide> * @param string|null $data Data to be sent to SMTP server <del> * @param string|bool $checkCode Code to check for in server response, false to skip <add> * @param string|false $checkCode Code to check for in server response, false to skip <ide> * @return string|null The matched code, or null if nothing matched <ide> * @throws \Cake\Network\Exception\SocketException <ide> */ <ide><path>src/ORM/Table.php <ide> public function delete(EntityInterface $entity, $options = []): bool <ide> * <ide> * @param \Cake\Datasource\EntityInterface[]|\Cake\Datasource\ResultSetInterface $entities Entities to delete. <ide> * @param array|\ArrayAccess $options Options used when calling Table::save() for each entity. <del> * @return bool|\Cake\Datasource\EntityInterface[]|\Cake\Datasource\ResultSetInterface <del> * False on failure, entities list on success. <add> * @return \Cake\Datasource\EntityInterface[]|\Cake\Datasource\ResultSetInterface|false Entities list <add> * on success, false on failure. <ide> * @throws \Exception <ide> * @see \Cake\ORM\Table::delete() for options and events related to this method. <ide> */ <ide><path>src/View/Helper/PaginatorHelper.php <ide> public function sortDir(?string $model = null, array $options = []): string <ide> /** <ide> * Generate an active/inactive link for next/prev methods. <ide> * <del> * @param string|bool $text The enabled text for the link. <add> * @param string|false $text The enabled text for the link. <ide> * @param bool $enabled Whether or not the enabled/disabled version should be created. <ide> * @param array $options An array of options from the calling method. <ide> * @param array $templates An array of templates with the 'active' and 'disabled' keys.
5
Javascript
Javascript
update documentation for expect methods
61cb4085d421060edfb98d7eae0a43b615542843
<ide><path>src/ngMock/angular-mocks.js <ide> function createHttpBackendMock($rootScope, $delegate, $browser) { <ide> * <ide> * @param {string} method HTTP method. <ide> * @param {string|RegExp} url HTTP url. <del> * @param {(string|RegExp|function(string))=} data HTTP request body or function that receives <del> * data string and returns true if the data is as expected. <add> * @param {(string|RegExp|function(string)|Object)=} data HTTP request body or function that <add> * receives data string and returns true if the data is as expected, or Object if request body <add> * is in JSON format. <ide> * @param {(Object|function(Object))=} headers HTTP headers or function that receives http header <ide> * object and returns true if the headers match the current expectation. <ide> * @returns {requestHandler} Returns an object with `respond` method that control how a matched <ide> function createHttpBackendMock($rootScope, $delegate, $browser) { <ide> * Creates a new request expectation for POST requests. For more info see `expect()`. <ide> * <ide> * @param {string|RegExp} url HTTP url. <del> * @param {(string|RegExp|function(string))=} data HTTP request body or function that receives <del> * data string and returns true if the data is as expected. <add> * @param {(string|RegExp|function(string)|Object)=} data HTTP request body or function that <add> * receives data string and returns true if the data is as expected, or Object if request body <add> * is in JSON format. <ide> * @param {Object=} headers HTTP headers. <ide> * @returns {requestHandler} Returns an object with `respond` method that control how a matched <ide> * request is handled. <ide> function createHttpBackendMock($rootScope, $delegate, $browser) { <ide> * Creates a new request expectation for PUT requests. For more info see `expect()`. <ide> * <ide> * @param {string|RegExp} url HTTP url. <del> * @param {(string|RegExp|function(string))=} data HTTP request body or function that receives <del> * data string and returns true if the data is as expected. <add> * @param {(string|RegExp|function(string)|Object)=} data HTTP request body or function that <add> * receives data string and returns true if the data is as expected, or Object if request body <add> * is in JSON format. <ide> * @param {Object=} headers HTTP headers. <ide> * @returns {requestHandler} Returns an object with `respond` method that control how a matched <ide> * request is handled. <ide> function createHttpBackendMock($rootScope, $delegate, $browser) { <ide> * Creates a new request expectation for PATCH requests. For more info see `expect()`. <ide> * <ide> * @param {string|RegExp} url HTTP url. <del> * @param {(string|RegExp|function(string))=} data HTTP request body or function that receives <del> * data string and returns true if the data is as expected. <add> * @param {(string|RegExp|function(string)|Object)=} data HTTP request body or function that <add> * receives data string and returns true if the data is as expected, or Object if request body <add> * is in JSON format. <ide> * @param {Object=} headers HTTP headers. <ide> * @returns {requestHandler} Returns an object with `respond` method that control how a matched <ide> * request is handled.
1
Text
Text
add 1.5.3 release notes
3cd00fa3dded965a72fba29f0004618122b9da14
<ide><path>CHANGELOG.md <add><a name="1.5.3"></a> <add># 1.5.3 diplohaplontic-meiosis (2016-03-25) <add> <add>## Bug Fixes <add> <add>- **$compile:** workaround a GC bug in Chrome < 50 <add> ([513199ee](https://github.com/angular/angular.js/commit/513199ee9f1c8eef1240983d6e52c824404adb98), <add> [#14041](https://github.com/angular/angular.js/issues/14041), [#14286](https://github.com/angular/angular.js/issues/14286)) <add>- **$sniffer:** fix history sniffing in Chrome Packaged Apps <add> ([457fd21a](https://github.com/angular/angular.js/commit/457fd21a1a0c10c66245c32a73602f3a09038bda), <add> [#11932](https://github.com/angular/angular.js/issues/11932), [#13945](https://github.com/angular/angular.js/issues/13945)) <add>- **formatNumber:** handle small numbers correctly when `gSize` !== `lgSize` <add> ([3277b885](https://github.com/angular/angular.js/commit/3277b885c4dec3edd51b8e8c3d1776057d6d4d1d), <add> [#14289](https://github.com/angular/angular.js/issues/14289), [#14290](https://github.com/angular/angular.js/issues/14290)) <add>- **ngAnimate:** run structural animations with cancelled out class changes <add> ([c7813e9e](https://github.com/angular/angular.js/commit/c7813e9ebf793fe89380dcad54e8e002fafdd985), <add> [#14249](https://github.com/angular/angular.js/issues/14249)) <add>- **ngMessages:** don't crash when nested messages are removed <add> ([ef91b04c](https://github.com/angular/angular.js/commit/ef91b04cdd794f308617bca7ebd0b1b747e4f7de), <add> [#14183](https://github.com/angular/angular.js/issues/14183), [#14242](https://github.com/angular/angular.js/issues/14242)) <add> <add> <add>## Features <add> <add>- **$compile:** add more lifecycle hooks to directive controllers <add> ([9cd9956d](https://github.com/angular/angular.js/commit/9cd9956dcbc8382e8e8757a805398bd251bbc67e), <add> [#14127](https://github.com/angular/angular.js/issues/14127), [#14030](https://github.com/angular/angular.js/issues/14030), [#14020](https://github.com/angular/angular.js/issues/14020), [#13991](https://github.com/angular/angular.js/issues/13991), [#14302](https://github.com/angular/angular.js/issues/14302)) <add> <add> <add> <ide> <a name="1.5.2"></a> <ide> # 1.5.2 differential-recovery (2016-03-18) <ide>
1
Javascript
Javascript
fix merge bug
1637c4b1594115dcdab974b8e76fe03c0517914d
<ide><path>d3.js <ide> d3.behavior.zoom = function() { <ide> function start() { <ide> d3_behavior_zoomXyz = xyz; <ide> d3_behavior_zoomExtent = extent; <del> d3_behavior_zoomDispatch = event.zoom.dispatch; <add> d3_behavior_zoomDispatch = event.zoom; <ide> d3_behavior_zoomEventTarget = d3.event.target; <ide> d3_behavior_zoomTarget = this; <ide> d3_behavior_zoomArguments = arguments; <ide><path>d3.min.js <ide> (function(){function e(a){var b=-1,c=a.length,d=[];while(++b<c)d.push(a[b]);return d}function f(a){return Array.prototype.slice.call(a)}function i(){return this}function j(a){return a!=null&&!isNaN(a)}function k(a){return a.length}function l(a){return a==null}function m(a){return a.replace(/(^\s+)|(\s+$)/g,"").replace(/\s+/g," ")}function o(){}function p(){function c(){var b=a,c=-1,d=b.length,e;while(++c<d)(e=b[c])._on&&e.apply(this,arguments)}var a=[],b={};return c.on=function(d,e){var f,g;if(f=b[d])f._on=!1,a=a.slice(0,g=a.indexOf(f)).concat(a.slice(g+1)),delete b[d];return e&&(e._on=!0,a.push(e),b[d]=e),c},c}function s(a,b){return b-(a?1+Math.floor(Math.log(a+Math.pow(10,1+Math.floor(Math.log(a)/Math.LN10)-b))/Math.LN10):1)}function t(a){return a+""}function u(a){var b=a.lastIndexOf("."),c=b>=0?a.substring(b):(b=a.length,""),d=[];while(b>0)d.push(a.substring(b-=3,b+3));return d.reverse().join(",")+c}function w(a,b){return{scale:Math.pow(10,(8-b)*3),symbol:a}}function B(a){return function(b){return b<=0?0:b>=1?1:a(b)}}function C(a){return function(b){return 1-a(1-b)}}function D(a){return function(b){return.5*(b<.5?a(2*b):2-a(2-2*b))}}function E(a){return a}function F(a){return function(b){return Math.pow(b,a)}}function G(a){return 1-Math.cos(a*Math.PI/2)}function H(a){return Math.pow(2,10*(a-1))}function I(a){return 1-Math.sqrt(1-a*a)}function J(a,b){var c;return arguments.length<2&&(b=.45),arguments.length<1?(a=1,c=b/4):c=b/(2*Math.PI)*Math.asin(1/a),function(d){return 1+a*Math.pow(2,10*-d)*Math.sin((d-c)*2*Math.PI/b)}}function K(a){return a||(a=1.70158),function(b){return b*b*((a+1)*b-a)}}function L(a){return a<1/2.75?7.5625*a*a:a<2/2.75?7.5625*(a-=1.5/2.75)*a+.75:a<2.5/2.75?7.5625*(a-=2.25/2.75)*a+.9375:7.5625*(a-=2.625/2.75)*a+.984375}function M(){d3.event.stopPropagation(),d3.event.preventDefault()}function P(a){return a in O||/\bcolor\b/.test(a)?d3.interpolateRgb:d3.interpolate}function Q(a,b){return b=b-(a=+a)?1/(b-a):0,function(c){return(c-a)*b}}function R(a,b){return b=b-(a=+a)?1/(b-a):0,function(c){return Math.max(0,Math.min(1,(c-a)*b))}}function S(a,b,c){return new T(a,b,c)}function T(a,b,c){this.r=a,this.g=b,this.b=c}function U(a){return a<16?"0"+Math.max(0,a).toString(16):Math.min(255,a).toString(16)}function V(a,b,c){var d=0,e=0,f=0,g,h,i;g=/([a-z]+)\((.*)\)/i.exec(a);if(g){h=g[2].split(",");switch(g[1]){case"hsl":return c(parseFloat(h[0]),parseFloat(h[1])/100,parseFloat(h[2])/100);case"rgb":return b(X(h[0]),X(h[1]),X(h[2]))}}return(i=Y[a])?b(i.r,i.g,i.b):(a!=null&&a.charAt(0)==="#"&&(a.length===4?(d=a.charAt(1),d+=d,e=a.charAt(2),e+=e,f=a.charAt(3),f+=f):a.length===7&&(d=a.substring(1,3),e=a.substring(3,5),f=a.substring(5,7)),d=parseInt(d,16),e=parseInt(e,16),f=parseInt(f,16)),b(d,e,f))}function W(a,b,c){var d=Math.min(a/=255,b/=255,c/=255),e=Math.max(a,b,c),f=e-d,g,h,i=(e+d)/2;return f?(h=i<.5?f/(e+d):f/(2-e-d),a==e?g=(b-c)/f+(b<c?6:0):b==e?g=(c-a)/f+2:g=(a-b)/f+4,g*=60):h=g=0,$(g,h,i)}function X(a){var b=parseFloat(a);return a.charAt(a.length-1)==="%"?Math.round(b*2.55):b}function $(a,b,c){return new _(a,b,c)}function _(a,b,c){this.h=a,this.s=b,this.l=c}function ba(a,b,c){function f(a){return a>360?a-=360:a<0&&(a+=360),a<60?d+(e-d)*a/60:a<180?e:a<240?d+(e-d)*(240-a)/60:d}function g(a){return Math.round(f(a)*255)}var d,e;return a%=360,a<0&&(a+=360),b=b<0?0:b>1?1:b,c=c<0?0:c>1?1:c,e=c<=.5?c*(1+b):c+b-c*b,d=2*c-e,S(g(a+120),g(a),g(a-120))}function bb(a){return h(a,be),a}function bf(a){return function(){return bc(a,this)}}function bg(a){return function(){return bd(a,this)}}function bi(a,b){function f(){if(b=this.classList)return b.add(a);var b=this.className,d=b.baseVal!=null,e=d?b.baseVal:b;c.lastIndex=0,c.test(e)||(e=m(e+" "+a),d?b.baseVal=e:this.className=e)}function g(){if(b=this.classList)return b.remove(a);var b=this.className,d=b.baseVal!=null,e=d?b.baseVal:b;e=m(e.replace(c," ")),d?b.baseVal=e:this.className=e}function h(){(b.apply(this,arguments)?f:g).call(this)}var c=new RegExp("(^|\\s+)"+d3.requote(a)+"(\\s+|$)","g");if(arguments.length<2){var d=this.node();if(e=d.classList)return e.contains(a);var e=d.className;return c.lastIndex=0,c.test(e.baseVal!=null?e.baseVal:e)}return this.each(typeof b=="function"?h:b?f:g)}function bj(a){return{__data__:a}}function bk(a){return arguments.length||(a=d3.ascending),function(b,c){return a(b&&b.__data__,c&&c.__data__)}}function bm(a){return h(a,bn),a}function bo(a,b,c){h(a,bs);var d={},e=d3.dispatch("start","end"),f=bv;return a.id=b,a.time=c,a.tween=function(b,c){return arguments.length<2?d[b]:(c==null?delete d[b]:d[b]=c,a)},a.ease=function(b){return arguments.length?(f=typeof b=="function"?b:d3.ease.apply(d3,arguments),a):f},a.each=function(b,c){return arguments.length<2?bw.call(a,b):(e.on(b,c),a)},d3.timer(function(g){return a.each(function(h,i,j){function p(a){if(o.active>b)return r();o.active=b;for(var f in d)(f=d[f].call(l,h,i))&&k.push(f);return e.start.call(l,h,i),q(a)||d3.timer(q,0,c),1}function q(a){if(o.active!==b)return r();var c=(a-m)/n,d=f(c),g=k.length;while(g>0)k[--g].call(l,d);if(c>=1)return r(),bu=b,e.end.call(l,h,i),bu=0,1}function r(){return--o.count||delete l.__transition__,1}var k=[],l=this,m=a[j][i].delay,n=a[j][i].duration,o=l.__transition__||(l.__transition__={active:0,count:0});++o.count,m<=g?p(g):d3.timer(p,m,c)}),1},0,c),a}function bq(a,b,c){return c!=""&&bp}function br(a){function b(b,c,d){var e=a.call(this,b,c);return e==null?d!=""&&bp:d!=e&&d3.interpolate(d,e)}function c(b,c,d){return d!=a&&d3.interpolate(d,a)}return typeof a=="function"?b:a==null?bq:(a+="",c)}function bw(a){for(var b=0,c=this.length;b<c;b++)for(var d=this[b],e=0,f=d.length;e<f;e++){var g=d[e];g&&a.call(g=g.node,g.__data__,e,b)}return this}function bA(){var a,b=Date.now(),c=bx;while(c)a=b-c.then,a>=c.delay&&(c.flush=c.callback(a)),c=c.next;var d=bB()-b;d>24?(isFinite(d)&&(clearTimeout(bz),bz=setTimeout(bA,d)),by=0):(by=1,bC(bA))}function bB(){var a=null,b=bx,c=Infinity;while(b)b.flush?b=a?a.next=b.next:bx=b.next:(c=Math.min(c,b.then+b.delay),b=(a=b).next);return c}function bD(){}function bE(a){var b=a[0],c=a[a.length-1];return b<c?[b,c]:[c,b]}function bF(a,b){var c=0,d=a.length-1,e=a[c],f=a[d],g;f<e&&(g=c,c=d,d=g,g=e,e=f,f=g);if(g=f-e)b=b(g),a[c]=b.floor(e),a[d]=b.ceil(f);return a}function bG(){return Math}function bH(a,b,c,d){function g(){var g=a.length==2?bN:bO,i=d?R:Q;return e=g(a,b,i,c),f=g(b,a,i,d3.interpolate),h}function h(a){return e(a)}var e,f;return h.invert=function(a){return f(a)},h.domain=function(b){return arguments.length?(a=b.map(Number),g()):a},h.range=function(a){return arguments.length?(b=a,g()):b},h.rangeRound=function(a){return h.range(a).interpolate(d3.interpolateRound)},h.clamp=function(a){return arguments.length?(d=a,g()):d},h.interpolate=function(a){return arguments.length?(c=a,g()):c},h.ticks=function(b){return bL(a,b)},h.tickFormat=function(b){return bM(a,b)},h.nice=function(){return bF(a,bJ),g()},h.copy=function(){return bH(a,b,c,d)},g()}function bI(a,b){return a.range=d3.rebind(a,b.range),a.rangeRound=d3.rebind(a,b.rangeRound),a.interpolate=d3.rebind(a,b.interpolate),a.clamp=d3.rebind(a,b.clamp),a}function bJ(a){return a=Math.pow(10,Math.round(Math.log(a)/Math.LN10)-1),{floor:function(b){return Math.floor(b/a)*a},ceil:function(b){return Math.ceil(b/a)*a}}}function bK(a,b){var c=bE(a),d=c[1]-c[0],e=Math.pow(10,Math.floor(Math.log(d/b)/Math.LN10)),f=b/d*e;return f<=.15?e*=10:f<=.35?e*=5:f<=.75&&(e*=2),c[0]=Math.ceil(c[0]/e)*e,c[1]=Math.floor(c[1]/e)*e+e*.5,c[2]=e,c}function bL(a,b){return d3.range.apply(d3,bK(a,b))}function bM(a,b){return d3.format(",."+Math.max(0,-Math.floor(Math.log(bK(a,b)[2])/Math.LN10+.01))+"f")}function bN(a,b,c,d){var e=c(a[0],a[1]),f=d(b[0],b[1]);return function(a){return f(e(a))}}function bO(a,b,c,d){var e=[],f=[],g=0,h=a.length;while(++g<h)e.push(c(a[g-1],a[g])),f.push(d(b[g-1],b[g]));return function(b){var c=d3.bisect(a,b,1,a.length-1)-1;return f[c](e[c](b))}}function bP(a,b){function d(c){return a(b(c))}var c=b.pow;return d.invert=function(b){return c(a.invert(b))},d.domain=function(e){return arguments.length?(b=e[0]<0?bS:bR,c=b.pow,a.domain(e.map(b)),d):a.domain().map(c)},d.nice=function(){return a.domain(bF(a.domain(),bG)),d},d.ticks=function(){var d=bE(a.domain()),e=[];if(d.every(isFinite)){var f=Math.floor(d[0]),g=Math.ceil(d[1]),h=Math.round(c(d[0])),i=Math.round(c(d[1]));if(b===bS){e.push(c(f));for(;f++<g;)for(var j=9;j>0;j--)e.push(c(f)*j)}else{for(;f<g;f++)for(var j=1;j<10;j++)e.push(c(f)*j);e.push(c(f))}for(f=0;e[f]<h;f++);for(g=e.length;e[g-1]>i;g--);e=e.slice(f,g)}return e},d.tickFormat=function(a,e){arguments.length<2&&(e=bQ);if(arguments.length<1)return e;var f=a/d.ticks().length,g=b===bS?(h=-1e-15,Math.floor):(h=1e-15,Math.ceil),h;return function(a){return a/c(g(b(a)+h))<f?e(a):""}},d.copy=function(){return bP(a.copy(),b)},bI(d,a)}function bR(a){return Math.log(a)/Math.LN10}function bS(a){return-Math.log(-a)/Math.LN10}function bT(a,b){function e(b){return a(c(b))}var c=bU(b),d=bU(1/b);return e.invert=function(b){return d(a.invert(b))},e.domain=function(b){return arguments.length?(a.domain(b.map(c)),e):a.domain().map(d)},e.ticks=function(a){return bL(e.domain(),a)},e.tickFormat=function(a){return bM(e.domain(),a)},e.nice=function(){return e.domain(bF(e.domain(),bJ))},e.exponent=function(a){if(!arguments.length)return b;var f=e.domain();return c=bU(b=a),d=bU(1/b),e.domain(f)},e.copy=function(){return bT(a.copy(),b)},bI(e,a)}function bU(a){return function(b){return b<0?-Math.pow(-b,a):Math.pow(b,a)}}function bV(a,b){function f(b){return d[((c[b]||(c[b]=a.push(b)))-1)%d.length]}function g(b,c){return d3.range(a.length).map(function(a){return b+c*a})}var c,d,e;return f.domain=function(d){if(!arguments.length)return a;a=[],c={};var e=-1,g=d.length,h;while(++e<g)c[h=d[e]]||(c[h]=a.push(h));return f[b.t](b.x,b.p)},f.range=function(a){return arguments.length?(d=a,e=0,b={t:"range",x:a},f):d},f.rangePoints=function(c,h){arguments.length<2&&(h=0);var i=c[0],j=c[1],k=(j-i)/(a.length-1+h);return d=g(a.length<2?(i+j)/2:i+k*h/2,k),e=0,b={t:"rangePoints",x:c,p:h},f},f.rangeBands=function(c,h){arguments.length<2&&(h=0);var i=c[0],j=c[1],k=(j-i)/(a.length+h);return d=g(i+k*h,k),e=k*(1-h),b={t:"rangeBands",x:c,p:h},f},f.rangeRoundBands=function(c,h){arguments.length<2&&(h=0);var i=c[0],j=c[1],k=Math.floor((j-i)/(a.length+h));return d=g(i+Math.round((j-i-(a.length-h)*k)/2),k),e=Math.round(k*(1-h)),b={t:"rangeRoundBands",x:c,p:h},f},f.rangeBand=function(){return e},f.copy=function(){return bV(a,b)},f.domain(a)}function b$(a,b){function d(){var d=0,f=a.length,g=b.length;c=[];while(++d<g)c[d-1]=d3.quantile(a,d/g);return e}function e(a){return isNaN(a=+a)?NaN:b[d3.bisect(c,a)]}var c;return e.domain=function(b){return arguments.length?(a=b.filter(function(a){return!isNaN(a)}).sort(d3.ascending),d()):a},e.range=function(a){return arguments.length?(b=a,d()):b},e.quantiles=function(){return c},e.copy=function(){return b$(a,b)},d()}function b_(a,b,c){function f(b){return c[Math.max(0,Math.min(e,Math.floor(d*(b-a))))]}function g(){return d=c.length/(b-a),e=c.length-1,f}var d,e;return f.domain=function(c){return arguments.length?(a=+c[0],b=+c[c.length-1],g()):[a,b]},f.range=function(a){return arguments.length?(c=a,g()):c},f.copy=function(){return b_(a,b,c)},g()}function cc(a){return a.innerRadius}function cd(a){return a.outerRadius}function ce(a){return a.startAngle}function cf(a){return a.endAngle}function cg(a){function g(d){return d.length<1?null:"M"+e(a(ch(this,d,b,c)),f)}var b=ci,c=cj,d="linear",e=ck[d],f=.7;return g.x=function(a){return arguments.length?(b=a,g):b},g.y=function(a){return arguments.length?(c=a,g):c},g.interpolate=function(a){return arguments.length?(e=ck[d=a],g):d},g.tension=function(a){return arguments.length?(f=a,g):f},g}function ch(a,b,c,d){var e=[],f=-1,g=b.length,h=typeof c=="function",i=typeof d=="function",j;if(h&&i)while(++f<g)e.push([c.call(a,j=b[f],f),d.call(a,j,f)]);else if(h)while(++f<g)e.push([c.call(a,b[f],f),d]);else if(i)while(++f<g)e.push([c,d.call(a,b[f],f)]);else while(++f<g)e.push([c,d]);return e}function ci(a){return a[0]}function cj(a){return a[1]}function cl(a){var b=0,c=a.length,d=a[0],e=[d[0],",",d[1]];while(++b<c)e.push("L",(d=a[b])[0],",",d[1]);return e.join("")}function cm(a){var b=0,c=a.length,d=a[0],e=[d[0],",",d[1]];while(++b<c)e.push("V",(d=a[b])[1],"H",d[0]);return e.join("")}function cn(a){var b=0,c=a.length,d=a[0],e=[d[0],",",d[1]];while(++b<c)e.push("H",(d=a[b])[0],"V",d[1]);return e.join("")}function co(a,b){return a.length<4?cl(a):a[1]+cr(a.slice(1,a.length-1),cs(a,b))}function cp(a,b){return a.length<3?cl(a):a[0]+cr((a.push(a[0]),a),cs([a[a.length-2]].concat(a,[a[1]]),b))}function cq(a,b,c){return a.length<3?cl(a):a[0]+cr(a,cs(a,b))}function cr(a,b){if(b.length<1||a.length!=b.length&&a.length!=b.length+2)return cl(a);var c=a.length!=b.length,d="",e=a[0],f=a[1],g=b[0],h=g,i=1;c&&(d+="Q"+(f[0]-g[0]*2/3)+","+(f[1]-g[1]*2/3)+","+f[0]+","+f[1],e=a[1],i=2);if(b.length>1){h=b[1],f=a[i],i++,d+="C"+(e[0]+g[0])+","+(e[1]+g[1])+","+(f[0]-h[0])+","+(f[1]-h[1])+","+f[0]+","+f[1];for(var j=2;j<b.length;j++,i++)f=a[i],h=b[j],d+="S"+(f[0]-h[0])+","+(f[1]-h[1])+","+f[0]+","+f[1]}if(c){var k=a[i];d+="Q"+(f[0]+h[0]*2/3)+","+(f[1]+h[1]*2/3)+","+k[0]+","+k[1]}return d}function cs(a,b){var c=[],d=(1-b)/2,e,f=a[0],g=a[1],h=1,i=a.length;while(++h<i)e=f,f=g,g=a[h],c.push([d*(g[0]-e[0]),d*(g[1]-e[1])]);return c}function ct(a){if(a.length<3)return cl(a);var b=1,c=a.length,d=a[0],e=d[0],f=d[1],g=[e,e,e,(d=a[1])[0]],h=[f,f,f,d[1]],i=[e,",",f];cB(i,g,h);while(++b<c)d=a[b],g.shift(),g.push(d[0]),h.shift(),h.push(d[1]),cB(i,g,h);b=-1;while(++b<2)g.shift(),g.push(d[0]),h.shift(),h.push(d[1]),cB(i,g,h);return i.join("")}function cu(a){if(a.length<4)return cl(a);var b=[],c=-1,d=a.length,e,f=[0],g=[0];while(++c<3)e=a[c],f.push(e[0]),g.push(e[1]);b.push(cx(cA,f)+","+cx(cA,g)),--c;while(++c<d)e=a[c],f.shift(),f.push(e[0]),g.shift(),g.push(e[1]),cB(b,f,g);return b.join("")}function cv(a){var b,c=-1,d=a.length,e=d+4,f,g=[],h=[];while(++c<4)f=a[c%d],g.push(f[0]),h.push(f[1]);b=[cx(cA,g),",",cx(cA,h)],--c;while(++c<e)f=a[c%d],g.shift(),g.push(f[0]),h.shift(),h.push(f[1]),cB(b,g,h);return b.join("")}function cw(a,b){var c=a.length-1,d=a[0][0],e=a[0][1],f=a[c][0]-d,g=a[c][1]-e,h=-1,i,j;while(++h<=c)i=a[h],j=h/c,i[0]=b*i[0]+(1-b)*(d+j*f),i[1]=b*i[1]+(1-b)*(e+j*g);return ct(a)}function cx(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]+a[3]*b[3]}function cB(a,b,c){a.push("C",cx(cy,b),",",cx(cy,c),",",cx(cz,b),",",cx(cz,c),",",cx(cA,b),",",cx(cA,c))}function cC(a,b){return(b[1]-a[1])/(b[0]-a[0])}function cD(a){var b=0,c=a.length-1,d=[],e=a[0],f=a[1],g=d[0]=cC(e,f);while(++b<c)d[b]=g+(g=cC(e=f,f=a[b+1]));return d[b]=g,d}function cE(a){var b=[],c,d,e,f,g=cD(a),h=-1,i=a.length-1;while(++h<i)c=cC(a[h],a[h+1]),Math.abs(c)<1e-6?g[h]=g[h+1]=0:(d=g[h]/c,e=g[h+1]/c,f=d*d+e*e,f>9&&(f=c*3/Math.sqrt(f),g[h]=f*d,g[h+1]=f*e));h=-1;while(++h<=i)f=(a[Math.min(i,h+1)][0]-a[Math.max(0,h-1)][0])/(6*(1+g[h]*g[h])),b.push([f||0,g[h]*f||0]);return b}function cF(a){return a.length<3?cl(a):a[0]+cr(a,cE(a))}function cG(a){var b,c=-1,d=a.length,e,f;while(++c<d)b=a[c],e=b[0],f=b[1]+ca,b[0]=e*Math.cos(f),b[1]=e*Math.sin(f);return a}function cH(a){function j(f){if(f.length<1)return null;var j=ch(this,f,b,d),k=ch(this,f,b===c?cI(j):c,d===e?cJ(j):e);return"M"+g(a(k),i)+"L"+h(a(j.reverse()),i)+"Z"}var b=ci,c=ci,d=0,e=cj,f,g,h,i=.7;return j.x=function(a){return arguments.length?(b=c=a,j):c},j.x0=function(a){return arguments.length?(b=a,j):b},j.x1=function(a){return arguments.length?(c=a,j):c},j.y=function(a){return arguments.length?(d=e=a,j):e},j.y0=function(a){return arguments.length?(d=a,j):d},j.y1=function(a){return arguments.length?(e=a,j):e},j.interpolate=function(a){return arguments.length?(g=ck[f=a],h=g.reverse||g,j):f},j.tension=function(a){return arguments.length?(i=a,j):i},j.interpolate("linear")}function cI(a){return function(b,c){return a[c][0]}}function cJ(a){return function(b,c){return a[c][1]}}function cK(a){return a.source}function cL(a){return a.target}function cM(a){return a.radius}function cN(a){return a.startAngle}function cO(a){return a.endAngle}function cP(a){return[a.x,a.y]}function cQ(a){return function(){var b=a.apply(this,arguments),c=b[0],d=b[1]+ca;return[c*Math.cos(d),c*Math.sin(d)]}}function cS(a,b){var c=(a.ownerSVGElement||a).createSVGPoint();if(cR<0&&(window.scrollX||window.scrollY)){var d=d3.select(document.body).append("svg:svg").style("position","absolute").style("top",0).style("left",0),e=d[0][0].getScreenCTM();cR=!e.f&&!e.e,d.remove()}return cR?(c.x=b.pageX,c.y=b.pageY):(c.x=b.clientX,c.y=b.clientY),c=c.matrixTransform(a.getScreenCTM().inverse()),[c.x,c.y]}function cT(){return 64}function cU(){return"circle"}function cY(a,b){a.attr("transform",function(a){return"translate("+b(a)+",0)"})}function cZ(a,b){a.attr("transform",function(a){return"translate(0,"+b(a)+")"})}function c$(a,b,c){e=[];if(c&&b.length>1){var d=bE(a.domain()),e,f=-1,g=b.length,h=(b[1]-b[0])/++c,i,j;while(++f<g)for(i=c;--i>0;)(j=+b[f]-i*h)>=d[0]&&e.push(j);for(--f,i=0;++i<c&&(j=+b[f]+i*h)<d[1];)e.push(j)}return e}function dj(a,b){a.select(".extent").attr("x",b[0][0]),a.selectAll(".n,.s,.w,.nw,.sw").attr("x",b[0][0]-2),a.selectAll(".e,.ne,.se").attr("x",b[1][0]-3),a.selectAll(".extent,.n,.s").attr("width",b[1][0]-b[0][0])}function dk(a,b){a.select(".extent").attr("y",b[0][1]),a.selectAll(".n,.e,.w,.nw,.ne").attr("y",b[0][1]-3),a.selectAll(".s,.se,.sw").attr("y",b[1][1]-4),a.selectAll(".extent,.e,.w").attr("height",b[1][1]-b[0][1])}function dl(){d3.event.keyCode==32&&db&&!df&&(dh=null,di[0]-=de[1][0],di[1]-=de[1][1],df=2,M())}function dm(){d3.event.keyCode==32&&df==2&&(di[0]+=de[1][0],di[1]+=de[1][1],df=0,M())}function dn(){if(di){var a=d3.svg.mouse(db),b=d3.select(db);df||(d3.event.altKey?(dh||(dh=[(de[0][0]+de[1][0])/2,(de[0][1]+de[1][1])/2]),di[0]=de[+(a[0]<dh[0])][0],di[1]=de[+(a[1]<dh[1])][1]):dh=null),dc&&(dp(a,dc,0),dj(b,de)),dd&&(dp(a,dd,1),dk(b,de)),da("brush")}}function dp(a,b,c){var d=bE(b.range()),e=di[c],f=de[1][c]-de[0][c],g,h;df&&(d[0]-=e,d[1]-=f+e),g=Math.max(d[0],Math.min(d[1],a[c])),df?h=(g+=e)+f:(dh&&(e=Math.max(d[0],Math.min(d[1],2*dh[c]-g))),e<g?(h=g,g=e):h=e),de[0][c]=g,de[1][c]=h}function dq(){di&&(dn(),d3.select(db).selectAll(".resize").style("pointer-events",c_.empty()?"none":"all"),da("brushend"),c_=da=db=dc=dd=de=df=dg=dh=di=null,M())}function dz(a){var b=d3.event,c=du.parentNode,d=0,e=0;c&&(c=dA(c),d=c[0]-dw[0],e=c[1]-dw[1],dw=c,dx|=d|e);try{d3.event={dx:d,dy:e},ds[a].apply(du,dv)}finally{d3.event=b}b.preventDefault()}function dA(a,b){var c=d3.event.changedTouches;return c?d3.svg.touches(a,c)[0]:d3.svg.mouse(a)}function dB(){if(!du)return;var a=du.parentNode;if(!a)return dC();dz("drag"),M()}function dC(){if(!du)return;dz("dragend"),du=null,dx&&dt===d3.event.target&&(dy=!0,M())}function dD(){dy&&dt===d3.event.target&&(M(),dy=!1,dt=null)}function dR(a){return[a[0]-dJ[0],a[1]-dJ[1],dJ[2]]}function dS(){dE||(dE=d3.select("body").append("div").style("visibility","hidden").style("top",0).style("height",0).style("width",0).style("overflow-y","scroll").append("div").style("height","2000px").node().parentNode);var a=d3.event,b;try{dE.scrollTop=1e3,dE.dispatchEvent(a),b=1e3-dE.scrollTop}catch(c){b=a.wheelDelta||-a.detail*5}return b*.005}function dT(){var a=d3.svg.touches(dN),b=-1,c=a.length,d;while(++b<c)dH[(d=a[b]).identifier]=dR(d);return a}function dU(){var a=d3.svg.touches(dN);switch(a.length){case 1:var b=a[0];dY(dJ[2],b,dH[b.identifier]);break;case 2:var c=a[0],d=a[1],e=[(c[0]+d[0])/2,(c[1]+d[1])/2],f=dH[c.identifier],g=dH[d.identifier],h=[(f[0]+g[0])/2,(f[1]+g[1])/2,f[2]];dY(Math.log(d3.event.scale)/Math.LN2+f[2],e,h)}}function dV(){dG=null,dF&&(dP=!0,dY(dJ[2],d3.svg.mouse(dN),dF))}function dW(){dF&&(dP&&dM===d3.event.target&&(dQ=!0),dV(),dF=null)}function dX(){dQ&&dM===d3.event.target&&(d3.event.stopPropagation(),d3.event.preventDefault(),dQ=!1,dM=null)}function dY(a,b,c){function l(a,b,c){a.domain(a.range().map(function(f){return a.invert((f-c)*d/e+b)}))}a=dZ(a,2);var d=Math.pow(2,dJ[2]),e=Math.pow(2,a),f=Math.pow(2,(dJ[2]=a)-c[2]),g=dZ(b[0]-c[0]*f,0,e),h=dZ(b[1]-c[1]*f,1,e),i=dJ[0],j=dJ[1],k=d3.event;dJ[0]=g,dJ[1]=h,d3.event={scale:e,translate:[g,h],transform:function(a,b){a&&l(a,i,g),b&&l(b,j,h)}};try{dL.apply(dN,dO)}finally{d3.event=k}k.preventDefault()}function dZ(a,b,c){var d=dK[b],e=d[0],f=d[1];return arguments.length===3?Math.max(f*(f===Infinity?-Infinity:1/c-1),Math.min(e===-Infinity?Infinity:e,a/c))*c:Math.max(e,Math.min(f,a))}Date.now||(Date.now=function(){return+(new Date)});try{document.createElement("div").style.setProperty("opacity",0,"")}catch(a){var b=CSSStyleDeclaration.prototype,c=b.setProperty;b.setProperty=function(a,b,d){c.call(this,a,b+"",d)}}d3={version:"2.4.6"};var d=f;try{d(document.documentElement.childNodes)[0].nodeType}catch(g){d=e}var h=[].__proto__?function(a,b){a.__proto__=b}:function(a,b){for(var c in b)a[c]=b[c]};d3.functor=function(a){return typeof a=="function"?a:function(){return a}},d3.rebind=function(a,b){return function(){var c=b.apply(a,arguments);return arguments.length?a:c}},d3.ascending=function(a,b){return a<b?-1:a>b?1:a>=b?0:NaN},d3.descending=function(a,b){return b<a?-1:b>a?1:b>=a?0:NaN},d3.mean=function(a,b){var c=a.length,d,e=0,f=-1,g=0;if(arguments.length===1)while(++f<c)j(d=a[f])&&(e+=(d-e)/++g);else while(++f<c)j(d=b.call(a,a[f],f))&&(e+=(d-e)/++g);return g?e:undefined},d3.median=function(a,b){return arguments.length>1&&(a=a.map(b)),a=a.filter(j),a.length?d3.quantile(a.sort(d3.ascending),.5):undefined},d3.min=function(a,b){var c=-1,d=a.length,e,f;if(arguments.length===1){while(++c<d&&((e=a[c])==null||e!=e))e=undefined;while(++c<d)(f=a[c])!=null&&e>f&&(e=f)}else{while(++c<d&&((e=b.call(a,a[c],c))==null||e!=e))e=undefined;while(++c<d)(f=b.call(a,a[c],c))!=null&&e>f&&(e=f)}return e},d3.max=function(a,b){var c=-1,d=a.length,e,f;if(arguments.length===1){while(++c<d&&((e=a[c])==null||e!=e))e=undefined;while(++c<d)(f=a[c])!=null&&f>e&&(e=f)}else{while(++c<d&&((e=b.call(a,a[c],c))==null||e!=e))e=undefined;while(++c<d)(f=b.call(a,a[c],c))!=null&&f>e&&(e=f)}return e},d3.extent=function(a,b){var c=-1,d=a.length,e,f,g;if(arguments.length===1){while(++c<d&&((e=g=a[c])==null||e!=e))e=g=undefined;while(++c<d)(f=a[c])!=null&&(e>f&&(e=f),g<f&&(g=f))}else{while(++c<d&&((e=g=b.call(a,a[c],c))==null||e!=e))e=undefined;while(++c<d)(f=b.call(a,a[c],c))!=null&&(e>f&&(e=f),g<f&&(g=f))}return[e,g]},d3.random={normal:function(a,b){return arguments.length<2&&(b=1),arguments.length<1&&(a=0),function(){var c,d,e;do c=Math.random()*2-1,d=Math.random()*2-1,e=c*c+d*d;while(!e||e>1);return a+b*c*Math.sqrt(-2*Math.log(e)/e)}}},d3.sum=function(a,b){var c=0,d=a.length,e,f=-1;if(arguments.length===1)while(++f<d)isNaN(e=+a[f])||(c+=e);else while(++f<d)isNaN(e=+b.call(a,a[f],f))||(c+=e);return c},d3.quantile=function(a,b){var c=(a.length-1)*b+1,d=Math.floor(c),e=a[d-1],f=c-d;return f?e+f*(a[d]-e):e},d3.zip=function(){if(!(e=arguments.length))return[];for(var a=-1,b=d3.min(arguments,k),c=new Array(b);++a<b;)for(var d=-1,e,f=c[a]=new Array(e);++d<e;)f[d]=arguments[d][a];return c},d3.bisectLeft=function(a,b,c,d){arguments.length<3&&(c=0),arguments.length<4&&(d=a.length);while(c<d){var e=c+d>>1;a[e]<b?c=e+1:d=e}return c},d3.bisect=d3.bisectRight=function(a,b,c,d){arguments.length<3&&(c=0),arguments.length<4&&(d=a.length);while(c<d){var e=c+d>>1;b<a[e]?d=e:c=e+1}return c},d3.first=function(a,b){var c=0,d=a.length,e=a[0],f;arguments.length===1&&(b=d3.ascending);while(++c<d)b.call(a,e,f=a[c])>0&&(e=f);return e},d3.last=function(a,b){var c=0,d=a.length,e=a[0],f;arguments.length===1&&(b=d3.ascending);while(++c<d)b.call(a,e,f=a[c])<=0&&(e=f);return e},d3.nest=function(){function f(c,g){if(g>=b.length)return e?e.call(a,c):d?c.sort(d):c;var h=-1,i=c.length,j=b[g++],k,l,m={};while(++h<i)(k=j(l=c[h]))in m?m[k].push(l):m[k]=[l];for(k in m)m[k]=f(m[k],g);return m}function g(a,d){if(d>=b.length)return a;var e=[],f=c[d++],h;for(h in a)e.push({key:h,values:g(a[h],d)});return f&&e.sort(function(a,b){return f(a.key,b.key)}),e}var a={},b=[],c=[],d,e;return a.map=function(a){return f(a,0)},a.entries=function(a){return g(f(a,0),0)},a.key=function(c){return b.push(c),a},a.sortKeys=function(d){return c[b.length-1]=d,a},a.sortValues=function(b){return d=b,a},a.rollup=function(b){return e=b,a},a},d3.keys=function(a){var b=[];for(var c in a)b.push(c);return b},d3.values=function(a){var b=[];for(var c in a)b.push(a[c]);return b},d3.entries=function(a){var b=[];for(var c in a)b.push({key:c,value:a[c]});return b},d3.permute=function(a,b){var c=[],d=-1,e=b.length;while(++d<e)c[d]=a[b[d]];return c},d3.merge=function(a){return Array.prototype.concat.apply([],a)},d3.split=function(a,b){var c=[],d=[],e,f=-1,g=a.length;arguments.length<2&&(b=l);while(++f<g)b.call(d,e=a[f],f)?d=[]:(d.length||c.push(d),d.push(e));return c},d3.range=function(a,b,c){arguments.length<3&&(c=1,arguments.length<2&&(b=a,a=0));if((b-a)/c==Infinity)throw new Error("infinite range");var d=[],e=-1,f;if(c<0)while((f=a+c*++e)>b)d.push(f);else while((f=a+c*++e)<b)d.push(f);return d},d3.requote=function(a){return a.replace(n,"\\$&")};var n=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g;d3.round=function(a,b){return b?Math.round(a*Math.pow(10,b))*Math.pow(10,-b):Math.round(a)},d3.xhr=function(a,b,c){var d=new XMLHttpRequest;arguments.length<3?c=b:b&&d.overrideMimeType&&d.overrideMimeType(b),d.open("GET",a,!0),d.onreadystatechange=function(){d.readyState===4&&c(d.status<300?d:null)},d.send(null)},d3.text=function(a,b,c){function d(a){c(a&&a.responseText)}arguments.length<3&&(c=b,b=null),d3.xhr(a,b,d)},d3.json=function(a,b){d3.text(a,"application/json",function(a){b(a?JSON.parse(a):null)})},d3.html=function(a,b){d3.text(a,"text/html",function(a){if(a!=null){var c=document.createRange();c.selectNode(document.body),a=c.createContextualFragment(a)}b(a)})},d3.xml=function(a,b,c){function d(a){c(a&&a.responseXML)}arguments.length<3&&(c=b,b=null),d3.xhr(a,b,d)},d3.ns={prefix:{svg:"http://www.w3.org/2000/svg",xhtml:"http://www.w3.org/1999/xhtml",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"},qualify:function(a){var b=a.indexOf(":");return b<0?a:{space:d3.ns.prefix[a.substring(0,b)],local:a.substring(b+1)}}},d3.dispatch=function(){var a=new o,b=-1,c=arguments.length;while(++b<c)a[arguments[b]]=p();return a},o.prototype.on=function(a,b){var c=a.indexOf("."),d="";c>0&&(d=a.substring(c+1),a=a.substring(0,c)),this[a].on(d,b)},d3.format=function(a){var b=q.exec(a),c=b[1]||" ",d=b[3]||"",e=b[5],f=+b[6],g=b[7],h=b[8],i=b[9],j=1,k="",l=!1;h&&(h=+h.substring(1)),e&&(c="0",g&&(f-=Math.floor((f-1)/4)));switch(i){case"n":g=!0,i="g";break;case"%":j=100,k="%",i="f";break;case"p":j=100,k="%",i="r";break;case"d":l=!0,h=0;break;case"s":j=-1,i="r"}return i=="r"&&!h&&(i="g"),i=r[i]||t,function(a){if(l&&a%1)return"";var b=a<0&&(a=-a)?"−":d;if(j<0){var m=d3.formatPrefix(a,h);a*=m.scale,k=m.symbol}else a*=j;a=i(a,h);if(e){var n=a.length+b.length;n<f&&(a=(new Array(f-n+1)).join(c)+a),g&&(a=u(a)),a=b+a}else{g&&(a=u(a)),a=b+a;var n=a.length;n<f&&(a=(new Array(f-n+1)).join(c)+a)}return a+k}};var q=/(?:([^{])?([<>=^]))?([+\- ])?(#)?(0)?([0-9]+)?(,)?(\.[0-9]+)?([a-zA-Z%])?/,r={g:function(a,b){return a.toPrecision(b)},e:function(a,b){return a.toExponential(b)},f:function(a,b){return a.toFixed(b)},r:function(a,b){return d3.round(a,b=s(a,b)).toFixed(Math.max(0,Math.min(20,b)))}},v=["y","z","a","f","p","n","μ","m","","k","M","G","T","P","E","Z","Y"].map(w);d3.formatPrefix=function(a,b){var c=0;return a&&(a<0&&(a*=-1),b&&(a=d3.round(a,s(a,b))),c=1+Math.floor(1e-12+Math.log(a)/Math.LN10),c=Math.max(-24,Math.min(24,Math.floor((c<=0?c+1:c-1)/3)*3))),v[8+c/3]};var x=F(2),y=F(3),z={linear:function(){return E},poly:F,quad:function(){return x},cubic:function(){return y},sin:function(){return G},exp:function(){return H},circle:function(){return I},elastic:J,back:K,bounce:function(){return L}},A={"in":function(a){return a},out:C,"in-out":D,"out-in":function(a){return D(C(a))}};d3.ease=function(a){var b=a.indexOf("-"),c=b>=0?a.substring(0,b):a,d=b>=0?a.substring(b+1):"in";return B(A[d](z[c].apply(null,Array.prototype.slice.call(arguments,1))))},d3.event=null,d3.interpolate=function(a,b){var c=d3.interpolators.length,d;while(--c>=0&&!(d=d3.interpolators[c](a,b)));return d},d3.interpolateNumber=function(a,b){return b-=a,function(c){return a+b*c}},d3.interpolateRound=function(a,b){return b-=a,function(c){return Math.round(a+b*c)}},d3.interpolateString=function(a,b){var c,d,e,f=0,g=0,h=[],i=[],j,k;N.lastIndex=0;for(d=0;c=N.exec(b);++d)c.index&&h.push(b.substring(f,g=c.index)),i.push({i:h.length,x:c[0]}),h.push(null),f=N.lastIndex;f<b.length&&h.push(b.substring(f));for(d=0,j=i.length;(c=N.exec(a))&&d<j;++d){k=i[d];if(k.x==c[0]){if(k.i)if(h[k.i+1]==null){h[k.i-1]+=k.x,h.splice(k.i,1);for(e=d+1;e<j;++e)i[e].i--}else{h[k.i-1]+=k.x+h[k.i+1],h.splice(k.i,2);for(e=d+1;e<j;++e)i[e].i-=2}else if(h[k.i+1]==null)h[k.i]=k.x;else{h[k.i]=k.x+h[k.i+1],h.splice(k.i+1,1);for(e=d+1;e<j;++e)i[e].i--}i.splice(d,1),j--,d--}else k.x=d3.interpolateNumber(parseFloat(c[0]),parseFloat(k.x))}while(d<j)k=i.pop(),h[k.i+1]==null?h[k.i]=k.x:(h[k.i]=k.x+h[k.i+1],h.splice(k.i+1,1)),j--;return h.length===1?h[0]==null?i[0].x:function(){return b}:function(a){for(d=0;d<j;++d)h[(k=i[d]).i]=k.x(a);return h.join("")}},d3.interpolateRgb=function(a,b){a=d3.rgb(a),b=d3.rgb(b);var c=a.r,d=a.g,e=a.b,f=b.r-c,g=b.g-d,h=b.b-e;return function(a){return"#"+U(Math.round(c+f*a))+U(Math.round(d+g*a))+U(Math.round(e+h*a))}},d3.interpolateHsl=function(a,b){a=d3.hsl(a),b=d3.hsl(b);var c=a.h,d=a.s,e=a.l,f=b.h-c,g=b.s-d,h=b.l-e;return function(a){return ba(c+f*a,d+g*a,e+h*a).toString()}},d3.interpolateArray=function(a,b){var c=[],d=[],e=a.length,f=b.length,g=Math.min(a.length,b.length),h;for(h=0;h<g;++h)c.push(d3.interpolate(a[h],b[h]));for(;h<e;++h)d[h]=a[h];for(;h<f;++h)d[h]=b[h];return function(a){for(h=0;h<g;++h)d[h]=c[h](a);return d}},d3.interpolateObject=function(a,b){var c={},d={},e;for(e in a)e in b?c[e]=P(e)(a[e],b[e]):d[e]=a[e];for(e in b)e in a||(d[e]=b[e]);return function(a){for(e in c)d[e]=c[e](a);return d}};var N=/[-+]?(?:\d+\.\d+|\d+\.|\.\d+|\d+)(?:[eE][-]?\d+)?/g,O={background:1,fill:1,stroke:1};d3.interpolators=[d3.interpolateObject,function(a,b){return b instanceof Array&&d3.interpolateArray(a,b)},function(a,b){return typeof b=="string"&&d3.interpolateString(String(a),b)},function(a,b){return(typeof b=="string"?b in Y||/^(#|rgb\(|hsl\()/.test(b):b instanceof T||b instanceof _)&&d3.interpolateRgb(String(a),b)},function(a,b){return typeof b=="number"&&d3.interpolateNumber(+a,b)}],d3.rgb=function(a,b,c){return arguments.length===1?a instanceof T?S(a.r,a.g,a.b):V(""+a,S,ba):S(~~a,~~b,~~c)},T.prototype.brighter=function(a){a=Math.pow(.7,arguments.length?a:1);var b=this.r,c=this.g,d=this.b,e=30;return!b&&!c&&!d?S(e,e,e):(b&&b<e&&(b=e),c&&c<e&&(c=e),d&&d<e&&(d=e),S(Math.min(255,Math.floor(b/a)),Math.min(255,Math.floor(c/a)),Math.min(255,Math.floor(d/a))))},T.prototype.darker=function(a){return a=Math.pow(.7,arguments.length?a:1),S(Math.floor(a*this.r),Math.floor(a*this.g),Math.floor(a*this.b))},T.prototype.hsl=function(){return W(this.r,this.g,this.b)},T.prototype.toString=function(){return"#"+U(this.r)+U(this.g)+U(this.b)};var Y={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen <del>:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"};for(var Z in Y)Y[Z]=V(Y[Z],S,ba);d3.hsl=function(a,b,c){return arguments.length===1?a instanceof _?$(a.h,a.s,a.l):V(""+a,W,$):$(+a,+b,+c)},_.prototype.brighter=function(a){return a=Math.pow(.7,arguments.length?a:1),$(this.h,this.s,this.l/a)},_.prototype.darker=function(a){return a=Math.pow(.7,arguments.length?a:1),$(this.h,this.s,a*this.l)},_.prototype.rgb=function(){return ba(this.h,this.s,this.l)},_.prototype.toString=function(){return this.rgb().toString()};var bc=function(a,b){return b.querySelector(a)},bd=function(a,b){return b.querySelectorAll(a)};typeof Sizzle=="function"&&(bc=function(a,b){return Sizzle(a,b)[0]},bd=function(a,b){return Sizzle.uniqueSort(Sizzle(a,b))});var be=[];d3.selection=function(){return bl},d3.selection.prototype=be,be.select=function(a){var b=[],c,d,e,f;typeof a!="function"&&(a=bf(a));for(var g=-1,h=this.length;++g<h;){b.push(c=[]),c.parentNode=(e=this[g]).parentNode;for(var i=-1,j=e.length;++i<j;)(f=e[i])?(c.push(d=a.call(f,f.__data__,i)),d&&"__data__"in f&&(d.__data__=f.__data__)):c.push(null)}return bb(b)},be.selectAll=function(a){var b=[],c,e;typeof a!="function"&&(a=bg(a));for(var f=-1,g=this.length;++f<g;)for(var h=this[f],i=-1,j=h.length;++i<j;)if(e=h[i])b.push(c=d(a.call(e,e.__data__,i))),c.parentNode=e;return bb(b)},be.attr=function(a,b){function d(){this.removeAttribute(a)}function e(){this.removeAttributeNS(a.space,a.local)}function f(){this.setAttribute(a,b)}function g(){this.setAttributeNS(a.space,a.local,b)}function h(){var c=b.apply(this,arguments);c==null?this.removeAttribute(a):this.setAttribute(a,c)}function i(){var c=b.apply(this,arguments);c==null?this.removeAttributeNS(a.space,a.local):this.setAttributeNS(a.space,a.local,c)}a=d3.ns.qualify(a);if(arguments.length<2){var c=this.node();return a.local?c.getAttributeNS(a.space,a.local):c.getAttribute(a)}return this.each(b==null?a.local?e:d:typeof b=="function"?a.local?i:h:a.local?g:f)},be.classed=function(a,b){var c=a.split(bh),d=c.length,e=-1;if(arguments.length>1){while(++e<d)bi.call(this,c[e],b);return this}while(++e<d)if(!bi.call(this,c[e]))return!1;return!0};var bh=/\s+/g;be.style=function(a,b,c){function d(){this.style.removeProperty(a)}function e(){this.style.setProperty(a,b,c)}function f(){var d=b.apply(this,arguments);d==null?this.style.removeProperty(a):this.style.setProperty(a,d,c)}return arguments.length<3&&(c=""),arguments.length<2?window.getComputedStyle(this.node(),null).getPropertyValue(a):this.each(b==null?d:typeof b=="function"?f:e)},be.property=function(a,b){function c(){delete this[a]}function d(){this[a]=b}function e(){var c=b.apply(this,arguments);c==null?delete this[a]:this[a]=c}return arguments.length<2?this.node()[a]:this.each(b==null?c:typeof b=="function"?e:d)},be.text=function(a){return arguments.length<1?this.node().textContent:this.each(typeof a=="function"?function(){this.textContent=a.apply(this,arguments)}:function(){this.textContent=a})},be.html=function(a){return arguments.length<1?this.node().innerHTML:this.each(typeof a=="function"?function(){this.innerHTML=a.apply(this,arguments)}:function(){this.innerHTML=a})},be.append=function(a){function b(){return this.appendChild(document.createElement(a))}function c(){return this.appendChild(document.createElementNS(a.space,a.local))}return a=d3.ns.qualify(a),this.select(a.local?c:b)},be.insert=function(a,b){function c(){return this.insertBefore(document.createElement(a),bc(b,this))}function d(){return this.insertBefore(document.createElementNS(a.space,a.local),bc(b,this))}return a=d3.ns.qualify(a),this.select(a.local?d:c)},be.remove=function(){return this.each(function(){var a=this.parentNode;a&&a.removeChild(this)})},be.data=function(a,b){function f(a,f){var g,h=a.length,i=f.length,j=Math.min(h,i),k=Math.max(h,i),l=[],m=[],n=[],o,p;if(b){var q={},r=[],s,t=f.length;for(g=-1;++g<h;)s=b.call(o=a[g],o.__data__,g),s in q?n[t++]=o:q[s]=o,r.push(s);for(g=-1;++g<i;)o=q[s=b.call(f,p=f[g],g)],o?(o.__data__=p,l[g]=o,m[g]=n[g]=null):(m[g]=bj(p),l[g]=n[g]=null),delete q[s];for(g=-1;++g<h;)r[g]in q&&(n[g]=a[g])}else{for(g=-1;++g<j;)o=a[g],p=f[g],o?(o.__data__=p,l[g]=o,m[g]=n[g]=null):(m[g]=bj(p),l[g]=n[g]=null);for(;g<i;++g)m[g]=bj(f[g]),l[g]=n[g]=null;for(;g<k;++g)n[g]=a[g],m[g]=l[g]=null}m.update=l,m.parentNode=l.parentNode=n.parentNode=a.parentNode,c.push(m),d.push(l),e.push(n)}var c=[],d=[],e=[],g=-1,h=this.length,i;if(typeof a=="function")while(++g<h)f(i=this[g],a.call(i,i.parentNode.__data__,g));else while(++g<h)f(i=this[g],a);var j=bb(d);return j.enter=function(){return bm(c)},j.exit=function(){return bb(e)},j},be.filter=function(a){var b=[],c,d,e;for(var f=0,g=this.length;f<g;f++){b.push(c=[]),c.parentNode=(d=this[f]).parentNode;for(var h=0,i=d.length;h<i;h++)(e=d[h])&&a.call(e,e.__data__,h)&&c.push(e)}return bb(b)},be.map=function(a){return this.each(function(){this.__data__=a.apply(this,arguments)})},be.sort=function(a){a=bk.apply(this,arguments);for(var b=0,c=this.length;b<c;b++)for(var d=this[b].sort(a),e=1,f=d.length,g=d[0];e<f;e++){var h=d[e];h&&(g&&g.parentNode.insertBefore(h,g.nextSibling),g=h)}return this},be.on=function(a,b,c){arguments.length<3&&(c=!1);var d="__on"+a,e=a.indexOf(".");return e>0&&(a=a.substring(0,e)),arguments.length<2?(e=this.node()[d])&&e._:this.each(function(e,f){function h(a){var c=d3.event;d3.event=a;try{b.call(g,g.__data__,f)}finally{d3.event=c}}var g=this;g[d]&&g.removeEventListener(a,g[d],c),b&&g.addEventListener(a,g[d]=h,c),h._=b})},be.each=function(a){for(var b=-1,c=this.length;++b<c;)for(var d=this[b],e=-1,f=d.length;++e<f;){var g=d[e];g&&a.call(g,g.__data__,e,b)}return this},be.call=function(a){return a.apply(this,(arguments[0]=this,arguments)),this},be.empty=function(){return!this.node()},be.node=function(a){for(var b=0,c=this.length;b<c;b++)for(var d=this[b],e=0,f=d.length;e<f;e++){var g=d[e];if(g)return g}return null},be.transition=function(){var a=[],b,c;for(var d=-1,e=this.length;++d<e;){a.push(b=[]);for(var f=this[d],g=-1,h=f.length;++g<h;)b.push((c=f[g])?{node:c,delay:0,duration:250}:null)}return bo(a,bu||++bt,Date.now())};var bl=bb([[document]]);bl[0].parentNode=document.documentElement,d3.select=function(a){return typeof a=="string"?bl.select(a):bb([[a]])},d3.selectAll=function(a){return typeof a=="string"?bl.selectAll(a):bb([d(a)])};var bn=[];bn.append=be.append,bn.insert=be.insert,bn.empty=be.empty,bn.node=be.node,bn.select=function(a){var b=[],c,d,e,f,g;for(var h=-1,i=this.length;++h<i;){e=(f=this[h]).update,b.push(c=[]),c.parentNode=f.parentNode;for(var j=-1,k=f.length;++j<k;)(g=f[j])?(c.push(e[j]=d=a.call(f.parentNode,g.__data__,j)),d.__data__=g.__data__):c.push(null)}return bb(b)};var bp={},bs=[],bt=0,bu=0,bv=d3.ease("cubic-in-out");bs.call=be.call,d3.transition=function(){return bl.transition()},d3.transition.prototype=bs,bs.select=function(a){var b=[],c,d,e;typeof a!="function"&&(a=bf(a));for(var f=-1,g=this.length;++f<g;){b.push(c=[]);for(var h=this[f],i=-1,j=h.length;++i<j;)(e=h[i])&&(d=a.call(e.node,e.node.__data__,i))?("__data__"in e.node&&(d.__data__=e.node.__data__),c.push({node:d,delay:e.delay,duration:e.duration})):c.push(null)}return bo(b,this.id,this.time).ease(this.ease())},bs.selectAll=function(a){var b=[],c,d,e;typeof a!="function"&&(a=bg(a));for(var f=-1,g=this.length;++f<g;)for(var h=this[f],i=-1,j=h.length;++i<j;)if(e=h[i]){d=a.call(e.node,e.node.__data__,i),b.push(c=[]);for(var k=-1,l=d.length;++k<l;)c.push({node:d[k],delay:e.delay,duration:e.duration})}return bo(b,this.id,this.time).ease(this.ease())},bs.attr=function(a,b){return this.attrTween(a,br(b))},bs.attrTween=function(a,b){function d(a,d){var e=b.call(this,a,d,this.getAttribute(c));return e===bp?(this.removeAttribute(c),null):e&&function(a){this.setAttribute(c,e(a))}}function e(a,d){var e=b.call(this,a,d,this.getAttributeNS(c.space,c.local));return e===bp?(this.removeAttributeNS(c.space,c.local),null):e&&function(a){this.setAttributeNS(c.space,c.local,e(a))}}var c=d3.ns.qualify(a);return this.tween("attr."+a,c.local?e:d)},bs.style=function(a,b,c){return arguments.length<3&&(c=""),this.styleTween(a,br(b),c)},bs.styleTween=function(a,b,c){return arguments.length<3&&(c=""),this.tween("style."+a,function(d,e){var f=b.call(this,d,e,window.getComputedStyle(this,null).getPropertyValue(a));return f===bp?(this.style.removeProperty(a),null):f&&function(b){this.style.setProperty(a,f(b),c)}})},bs.text=function(a){return this.tween("text",function(b,c){this.textContent=typeof a=="function"?a.call(this,b,c):a})},bs.remove=function(){return this.each("end",function(){var a;!this.__transition__&&(a=this.parentNode)&&a.removeChild(this)})},bs.delay=function(a){var b=this;return b.each(typeof a=="function"?function(c,d,e){b[e][d].delay=+a.apply(this,arguments)}:(a=+a,function(c,d,e){b[e][d].delay=a}))},bs.duration=function(a){var b=this;return b.each(typeof a=="function"?function(c,d,e){b[e][d].duration=+a.apply(this,arguments)}:(a=+a,function(c,d,e){b[e][d].duration=a}))},bs.transition=function(){return this.select(i)};var bx=null,by,bz;d3.timer=function(a,b,c){var d=!1,e,f=bx;if(arguments.length<3){if(arguments.length<2)b=0;else if(!isFinite(b))return;c=Date.now()}while(f){if(f.callback===a){f.then=c,f.delay=b,d=!0;break}e=f,f=f.next}d||(bx={callback:a,then:c,delay:b,next:bx}),by||(bz=clearTimeout(bz),by=1,bC(bA))},d3.timer.flush=function(){var a,b=Date.now(),c=bx;while(c)a=b-c.then,c.delay||(c.flush=c.callback(a)),c=c.next;bB()};var bC=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(a){setTimeout(a,17)};d3.scale={},d3.scale.linear=function(){return bH([0,1],[0,1],d3.interpolate,!1)},d3.scale.log=function(){return bP(d3.scale.linear(),bR)};var bQ=d3.format("e");bR.pow=function(a){return Math.pow(10,a)},bS.pow=function(a){return-Math.pow(10,-a)},d3.scale.pow=function(){return bT(d3.scale.linear(),1)},d3.scale.sqrt=function(){return d3.scale.pow().exponent(.5)},d3.scale.ordinal=function(){return bV([],{t:"range",x:[]})},d3.scale.category10=function(){return d3.scale.ordinal().range(bW)},d3.scale.category20=function(){return d3.scale.ordinal().range(bX)},d3.scale.category20b=function(){return d3.scale.ordinal().range(bY)},d3.scale.category20c=function(){return d3.scale.ordinal().range(bZ)};var bW=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],bX=["#1f77b4","#aec7e8","#ff7f0e","#ffbb78","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5","#8c564b","#c49c94","#e377c2","#f7b6d2","#7f7f7f","#c7c7c7","#bcbd22","#dbdb8d","#17becf","#9edae5"],bY=["#393b79","#5254a3","#6b6ecf","#9c9ede","#637939","#8ca252","#b5cf6b","#cedb9c","#8c6d31","#bd9e39","#e7ba52","#e7cb94","#843c39","#ad494a","#d6616b","#e7969c","#7b4173","#a55194","#ce6dbd","#de9ed6"],bZ=["#3182bd","#6baed6","#9ecae1","#c6dbef","#e6550d","#fd8d3c","#fdae6b","#fdd0a2","#31a354","#74c476","#a1d99b","#c7e9c0","#756bb1","#9e9ac8","#bcbddc","#dadaeb","#636363","#969696","#bdbdbd","#d9d9d9"];d3.scale.quantile=function(){return b$([],[])},d3.scale.quantize=function(){return b_(0,1,[0,1])},d3.svg={},d3.svg.arc=function(){function e(){var e=a.apply(this,arguments),f=b.apply(this,arguments),g=c.apply(this,arguments)+ca,h=d.apply(this,arguments)+ca,i=(h<g&&(i=g,g=h,h=i),h-g),j=i<Math.PI?"0":"1",k=Math.cos(g),l=Math.sin(g),m=Math.cos(h),n=Math.sin(h);return i>=cb?e?"M0,"+f+"A"+f+","+f+" 0 1,1 0,"+ -f+"A"+f+","+f+" 0 1,1 0,"+f+"M0,"+e+"A"+e+","+e+" 0 1,0 0,"+ -e+"A"+e+","+e+" 0 1,0 0,"+e+"Z":"M0,"+f+"A"+f+","+f+" 0 1,1 0,"+ -f+"A"+f+","+f+" 0 1,1 0,"+f+"Z":e?"M"+f*k+","+f*l+"A"+f+","+f+" 0 "+j+",1 "+f*m+","+f*n+"L"+e*m+","+e*n+"A"+e+","+e+" 0 "+j+",0 "+e*k+","+e*l+"Z":"M"+f*k+","+f*l+"A"+f+","+f+" 0 "+j+",1 "+f*m+","+f*n+"L0,0"+"Z"}var a=cc,b=cd,c=ce,d=cf;return e.innerRadius=function(b){return arguments.length?(a=d3.functor(b),e):a},e.outerRadius=function(a){return arguments.length?(b=d3.functor(a),e):b},e.startAngle=function(a){return arguments.length?(c=d3.functor(a),e):c},e.endAngle=function(a){return arguments.length?(d=d3.functor(a),e):d},e.centroid=function(){var e=(a.apply(this,arguments)+b.apply(this,arguments))/2,f=(c.apply(this,arguments)+d.apply(this,arguments))/2+ca;return[Math.cos(f)*e,Math.sin(f)*e]},e};var ca=-Math.PI/2,cb=2*Math.PI-1e-6;d3.svg.line=function(){return cg(Object)};var ck={linear:cl,"step-before":cm,"step-after":cn,basis:ct,"basis-open":cu,"basis-closed":cv,bundle:cw,cardinal:cq,"cardinal-open":co,"cardinal-closed":cp,monotone:cF},cy=[0,2/3,1/3,0],cz=[0,1/3,2/3,0],cA=[0,1/6,2/3,1/6];d3.svg.line.radial=function(){var a=cg(cG);return a.radius=a.x,delete a.x,a.angle=a.y,delete a.y,a},cm.reverse=cn,cn.reverse=cm,d3.svg.area=function(){return cH(Object)},d3.svg.area.radial=function(){var a=cH(cG);return a.radius=a.x,delete a.x,a.innerRadius=a.x0,delete a.x0,a.outerRadius=a.x1,delete a.x1,a.angle=a.y,delete a.y,a.startAngle=a.y0,delete a.y0,a.endAngle=a.y1,delete a.y1,a},d3.svg.chord=function(){function f(c,d){var e=g(this,a,c,d),f=g(this,b,c,d);return"M"+e.p0+i(e.r,e.p1)+(h(e,f)?j(e.r,e.p1,e.r,e.p0):j(e.r,e.p1,f.r,f.p0)+i(f.r,f.p1)+j(f.r,f.p1,e.r,e.p0))+"Z"}function g(a,b,f,g){var h=b.call(a,f,g),i=c.call(a,h,g),j=d.call(a,h,g)+ca,k=e.call(a,h,g)+ca;return{r:i,a0:j,a1:k,p0:[i*Math.cos(j),i*Math.sin(j)],p1:[i*Math.cos(k),i*Math.sin(k)]}}function h(a,b){return a.a0==b.a0&&a.a1==b.a1}function i(a,b){return"A"+a+","+a+" 0 0,1 "+b}function j(a,b,c,d){return"Q 0,0 "+d}var a=cK,b=cL,c=cM,d=ce,e=cf;return f.radius=function(a){return arguments.length?(c=d3.functor(a),f):c},f.source=function(b){return arguments.length?(a=d3.functor(b),f):a},f.target=function(a){return arguments.length?(b=d3.functor(a),f):b},f.startAngle=function(a){return arguments.length?(d=d3.functor(a),f):d},f.endAngle=function(a){return arguments.length?(e=d3.functor(a),f):e},f},d3.svg.diagonal=function(){function d(d,e){var f=a.call(this,d,e),g=b.call(this,d,e),h=(f.y+g.y)/2,i=[f,{x:f.x,y:h},{x:g.x,y:h},g];return i=i.map(c),"M"+i[0]+"C"+i[1]+" "+i[2]+" "+i[3]}var a=cK,b=cL,c=cP;return d.source=function(b){return arguments.length?(a=d3.functor(b),d):a},d.target=function(a){return arguments.length?(b=d3.functor(a),d):b},d.projection=function(a){return arguments.length?(c=a,d):c},d},d3.svg.diagonal.radial=function(){var a=d3.svg.diagonal(),b=cP,c=a.projection;return a.projection=function(a){return arguments.length?c(cQ(b=a)):b},a},d3.svg.mouse=function(a){return cS(a,d3.event)};var cR=/WebKit/.test(navigator.userAgent)?-1:0;d3.svg.touches=function(a,b){return arguments.length<2&&(b=d3.event.touches),b?d(b).map(function(b){var c=cS(a,b);return c.identifier=b.identifier,c}):[]},d3.svg.symbol=function(){function c(c,d){return(cV[a.call(this,c,d)]||cV.circle)(b.call(this,c,d))}var a=cU,b=cT;return c.type=function(b){return arguments.length?(a=d3.functor(b),c):a},c.size=function(a){return arguments.length?(b=d3.functor(a),c):b},c};var cV={circle:function(a){var b=Math.sqrt(a/Math.PI);return"M0,"+b+"A"+b+","+b+" 0 1,1 0,"+ -b+"A"+b+","+b+" 0 1,1 0,"+b+"Z"},cross:function(a){var b=Math.sqrt(a/5)/2;return"M"+ -3*b+","+ -b+"H"+ -b+"V"+ -3*b+"H"+b+"V"+ -b+"H"+3*b+"V"+b+"H"+b+"V"+3*b+"H"+ -b+"V"+b+"H"+ -3*b+"Z"},diamond:function(a){var b=Math.sqrt(a/(2*cX)),c=b*cX;return"M0,"+ -b+"L"+c+",0"+" 0,"+b+" "+ -c+",0"+"Z"},square:function(a){var b=Math.sqrt(a)/2;return"M"+ -b+","+ -b+"L"+b+","+ -b+" "+b+","+b+" "+ -b+","+b+"Z"},"triangle-down":function(a){var b=Math.sqrt(a/cW),c=b*cW/2;return"M0,"+c+"L"+b+","+ -c+" "+ -b+","+ -c+"Z"},"triangle-up":function(a){var b=Math.sqrt(a/cW),c=b*cW/2;return"M0,"+ -c+"L"+b+","+c+" "+ -b+","+c+"Z"}};d3.svg.symbolTypes=d3.keys(cV);var cW=Math.sqrt(3),cX=Math.tan(30*Math.PI/180);d3.svg.axis=function(){function j(j){j.each(function(k,l,m){var n=d3.select(this),o=j.delay?function(a){var b=bu;try{return bu=j.id,a.transition().delay(j[m][l].delay).duration(j[m][l].duration).ease(j.ease())}finally{bu=b}}:Object,p=a.ticks.apply(a,g),q=h==null?a.tickFormat.apply(a,g):h,r=c$(a,p,i),s=n.selectAll(".minor").data(r,String),t=s.enter().insert("svg:line","g").attr("class","tick minor").style("opacity",1e-6),u=o(s.exit()).style("opacity",1e-6).remove(),v=o(s).style("opacity",1),w=n.selectAll("g").data(p,String),x=w.enter().insert("svg:g","path").style("opacity",1e-6),y=o(w.exit()).style("opacity",1e-6).remove(),z=o(w).style("opacity",1),A,B=bE(a.range()),C=n.selectAll(".domain").data([0]),D=C.enter().append("svg:path").attr("class","domain"),E=o(C),F=this.__chart__||a;this.__chart__=a.copy(),x.append("svg:line").attr("class","tick"),x.append("svg:text"),z.select("text").text(q);switch(b){case"bottom":A=cY,v.attr("x2",0).attr("y2",d),z.select("line").attr("x2",0).attr("y2",c),z.select("text").attr("x",0).attr("y",Math.max(c,0)+f).attr("dy",".71em").attr("text-anchor","middle"),E.attr("d","M"+B[0]+","+e+"V0H"+B[1]+"V"+e);break;case"top":A=cY,v.attr("x2",0).attr("y2",-d),z.select("line").attr("x2",0).attr("y2",-c),z.select("text").attr("x",0).attr("y",-(Math.max(c,0)+f)).attr("dy","0em").attr("text-anchor","middle"),E.attr("d","M"+B[0]+","+ -e+"V0H"+B[1]+"V"+ -e);break;case"left":A=cZ,v.attr("x2",-d).attr("y2",0),z.select("line").attr("x2",-c).attr("y2",0),z.select("text").attr("x",-(Math.max(c,0)+f)).attr("y",0).attr("dy",".32em").attr("text-anchor","end"),E.attr("d","M"+ -e+","+B[0]+"H0V"+B[1]+"H"+ -e);break;case"right":A=cZ,v.attr("x2",d).attr("y2",0),z.select("line").attr("x2",c).attr("y2",0),z.select("text").attr("x",Math.max(c,0)+f).attr("y",0).attr("dy",".32em").attr("text-anchor","start"),E.attr("d","M"+e+","+B[0]+"H0V"+B[1]+"H"+e)}x.call(A,F),z.call(A,a),y.call(A,a),t.call(A,F),v.call(A,a),u.call(A,a)})}var a=d3.scale.linear(),b="bottom",c=6,d=6,e=6,f=3,g=[10],h,i=0;return j.scale=function(b){return arguments.length?(a=b,j):a},j.orient=function(a){return arguments.length?(b=a,j):b},j.ticks=function(){return arguments.length?(g=arguments,j):g},j.tickFormat=function(a){return arguments.length?(h=a,j):h},j.tickSize=function(a,b,f){if(!arguments.length)return c;var g=arguments.length-1;return c=+a,d=g>1?+b:c,e=g>0?+arguments[g]:c,j},j.tickPadding=function(a){return arguments.length?(f=+a,j):f},j.tickSubdivide=function(a){return arguments.length?(i=+a,j):i},j},d3.svg.brush=function(){function e(a){var g=b&&c?["n","e","s","w","nw","ne","se","sw"]:b?["e","w"]:c?["n","s"]:[];a.each(function(){var a=d3.select(this).on("mousedown.brush",f),h=a.selectAll(".background").data([,]),i=a.selectAll(".extent").data([,]),j=a.selectAll(".resize").data(g,String),k;h.enter().append("svg:rect").attr("class","background").style("visibility","hidden").style("pointer-events","all").style("cursor","crosshair"),i.enter().append("svg:rect").attr("class","extent").style("cursor","move"),j.enter().append("svg:rect").attr("class",function(a){return"resize "+a}).attr("width",6).attr("height",6).style("visibility","hidden").style("pointer-events",e.empty()?"none":"all").style("cursor",function(a){return dr[a]}),j.exit().remove(),b&&(k=bE(b.range()),h.attr("x",k[0]).attr("width",k[1]-k[0]),dj(a,d)),c&&(k=bE(c.range()),h.attr("y",k[0]).attr("height",k[1]-k[0]),dk(a,d))})}function f(){var a=d3.select(d3.event.target);c_=e,db=this,de=d,di=d3.svg.mouse(db),(df=a.classed("extent"))?(di[0]=d[0][0]-di[0],di[1]=d[0][1]-di[1]):a.classed("resize")?(dg=d3.event.target.__data__,di[0]=d[+/w$/.test(dg)][0],di[1]=d[+/^n/.test(dg)][1]):d3.event.altKey&&(dh=di.slice()),dc=!/^(n|s)$/.test(dg)&&b,dd=!/^(e|w)$/.test(dg)&&c,da=g(this,arguments),da("brushstart"),dn(),M()}function g(b,c){return function(d){var f=d3.event;try{d3.event={type:d,target:e},a[d].apply(b,c)}finally{d3.event=f}}}var a=d3.dispatch("brushstart","brush","brushend"),b,c,d=[[0,0],[0,0]];return e.x=function(a){return arguments.length?(b=a,e):b},e.y=function(a){return arguments.length?(c=a,e):c},e.extent=function(a){var f,g,h,i,j;return arguments.length?(b&&(f=a[0],g=a[1],c&&(f=f[0],g=g[0]),f=b(f),g=b(g),g<f&&(j=f,f=g,g=j),d[0][0]=f,d[1][0]=g),c&&(h=a[0],i=a[1],b&&(h=h[1],i=i[1]),h=c(h),i=c(i),i<h&&(j=h,h=i,i=j),d[0][1]=h,d[1][1]=i),e):(b&&(f=b.invert(d[0][0]),g=b.invert(d[1][0]),g<f&&(j=f,f=g,g=j)),c&&(h=c.invert(d[0][1]),i=c.invert(d[1][1]),i<h&&(j=h,h=i,i=j)),b&&c?[[f,h],[g,i]]:b?[f,g]:c&&[h,i])},e.clear=function(){return d[0][0]=d[0][1]=d[1][0]=d[1][1]=0,e},e.empty=function(){return b&&d[0][0]===d[1][0]||c&&d[0][1]===d[1][1]},e.on=function(b,c){return a.on(b,c),e},d3.select(window).on("mousemove.brush",dn).on("mouseup.brush",dq).on("keydown.brush",dl).on("keyup.brush",dm),e};var c_,da,db,dc,dd,de,df,dg,dh,di,dr={n:"ns-resize",e:"ew-resize",s:"ns-resize",w:"ew-resize",nw:"nwse-resize",ne:"nesw-resize",se:"nwse-resize",sw:"nesw-resize"};d3.behavior={},d3.behavior.drag=function(){function b(){this.on("mousedown.drag",d).on("touchstart.drag",d),d3.select(window).on("mousemove.drag",dB).on("touchmove.drag",dB).on("mouseup.drag",dC,!0).on("touchend.drag",dC,!0).on("click.drag",dD,!0)}function c(){ds=a,dt=d3.event.target,dw=dA((du=this).parentNode),dx=0,dv=arguments}function d(){c.apply(this,arguments),dz("dragstart")}var a=d3.dispatch("drag","dragstart","dragend");return b.on=function(c,d){return a.on(c,d),b},b};var ds,dt,du,dv,dw,dx,dy;d3.behavior.zoom=function(){function d(){this.on("mousedown.zoom",f).on("mousewheel.zoom",g).on("DOMMouseScroll.zoom",g).on("dblclick.zoom",h).on("touchstart.zoom",i),d3.select(window).on("mousemove.zoom",dV).on("mouseup.zoom",dW).on("touchmove.zoom",dU).on("touchend.zoom",dT).on("click.zoom",dX,!0)}function e(){dJ=a,dK=c,dL=b.zoom.dispatch,dM=d3.event.target,dN=this,dO=arguments}function f(){e.apply(this,arguments),dF=dR(d3.svg.mouse(dN)),dP=!1,d3.event.preventDefault(),window.focus()}function g(){e.apply(this,arguments),dG||(dG=dR(d3.svg.mouse(dN))),dY(dS()+a[2],d3.svg.mouse(dN),dG)}function h(){e.apply(this,arguments);var b=d3.svg.mouse(dN);dY(d3.event.shiftKey?Math.ceil(a[2]-1):Math.floor(a[2]+1),b,dR(b))}function i(){e.apply(this,arguments);var b=dT(),c,d=Date.now();b.length===1&&d-dI<300&&dY(1+Math.floor(a[2]),c=b[0],dH[c.identifier]),dI=d}var a=[0,0,0],b=d3.dispatch("zoom"),c=[[-Infinity,Infinity],[-Infinity,Infinity],[-Infinity,Infinity]];return d.extent=function(a){return arguments.length?(c=a==null?(a=[-Infinity,Infinity],[a,a,a]):a,d):c},d.on=function(a,c){return b.on(a,c),d},d};var dE,dF,dG,dH={},dI=0,dJ,dK,dL,dM,dN,dO,dP,dQ})(); <ide>\ No newline at end of file <add>:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"};for(var Z in Y)Y[Z]=V(Y[Z],S,ba);d3.hsl=function(a,b,c){return arguments.length===1?a instanceof _?$(a.h,a.s,a.l):V(""+a,W,$):$(+a,+b,+c)},_.prototype.brighter=function(a){return a=Math.pow(.7,arguments.length?a:1),$(this.h,this.s,this.l/a)},_.prototype.darker=function(a){return a=Math.pow(.7,arguments.length?a:1),$(this.h,this.s,a*this.l)},_.prototype.rgb=function(){return ba(this.h,this.s,this.l)},_.prototype.toString=function(){return this.rgb().toString()};var bc=function(a,b){return b.querySelector(a)},bd=function(a,b){return b.querySelectorAll(a)};typeof Sizzle=="function"&&(bc=function(a,b){return Sizzle(a,b)[0]},bd=function(a,b){return Sizzle.uniqueSort(Sizzle(a,b))});var be=[];d3.selection=function(){return bl},d3.selection.prototype=be,be.select=function(a){var b=[],c,d,e,f;typeof a!="function"&&(a=bf(a));for(var g=-1,h=this.length;++g<h;){b.push(c=[]),c.parentNode=(e=this[g]).parentNode;for(var i=-1,j=e.length;++i<j;)(f=e[i])?(c.push(d=a.call(f,f.__data__,i)),d&&"__data__"in f&&(d.__data__=f.__data__)):c.push(null)}return bb(b)},be.selectAll=function(a){var b=[],c,e;typeof a!="function"&&(a=bg(a));for(var f=-1,g=this.length;++f<g;)for(var h=this[f],i=-1,j=h.length;++i<j;)if(e=h[i])b.push(c=d(a.call(e,e.__data__,i))),c.parentNode=e;return bb(b)},be.attr=function(a,b){function d(){this.removeAttribute(a)}function e(){this.removeAttributeNS(a.space,a.local)}function f(){this.setAttribute(a,b)}function g(){this.setAttributeNS(a.space,a.local,b)}function h(){var c=b.apply(this,arguments);c==null?this.removeAttribute(a):this.setAttribute(a,c)}function i(){var c=b.apply(this,arguments);c==null?this.removeAttributeNS(a.space,a.local):this.setAttributeNS(a.space,a.local,c)}a=d3.ns.qualify(a);if(arguments.length<2){var c=this.node();return a.local?c.getAttributeNS(a.space,a.local):c.getAttribute(a)}return this.each(b==null?a.local?e:d:typeof b=="function"?a.local?i:h:a.local?g:f)},be.classed=function(a,b){var c=a.split(bh),d=c.length,e=-1;if(arguments.length>1){while(++e<d)bi.call(this,c[e],b);return this}while(++e<d)if(!bi.call(this,c[e]))return!1;return!0};var bh=/\s+/g;be.style=function(a,b,c){function d(){this.style.removeProperty(a)}function e(){this.style.setProperty(a,b,c)}function f(){var d=b.apply(this,arguments);d==null?this.style.removeProperty(a):this.style.setProperty(a,d,c)}return arguments.length<3&&(c=""),arguments.length<2?window.getComputedStyle(this.node(),null).getPropertyValue(a):this.each(b==null?d:typeof b=="function"?f:e)},be.property=function(a,b){function c(){delete this[a]}function d(){this[a]=b}function e(){var c=b.apply(this,arguments);c==null?delete this[a]:this[a]=c}return arguments.length<2?this.node()[a]:this.each(b==null?c:typeof b=="function"?e:d)},be.text=function(a){return arguments.length<1?this.node().textContent:this.each(typeof a=="function"?function(){this.textContent=a.apply(this,arguments)}:function(){this.textContent=a})},be.html=function(a){return arguments.length<1?this.node().innerHTML:this.each(typeof a=="function"?function(){this.innerHTML=a.apply(this,arguments)}:function(){this.innerHTML=a})},be.append=function(a){function b(){return this.appendChild(document.createElement(a))}function c(){return this.appendChild(document.createElementNS(a.space,a.local))}return a=d3.ns.qualify(a),this.select(a.local?c:b)},be.insert=function(a,b){function c(){return this.insertBefore(document.createElement(a),bc(b,this))}function d(){return this.insertBefore(document.createElementNS(a.space,a.local),bc(b,this))}return a=d3.ns.qualify(a),this.select(a.local?d:c)},be.remove=function(){return this.each(function(){var a=this.parentNode;a&&a.removeChild(this)})},be.data=function(a,b){function f(a,f){var g,h=a.length,i=f.length,j=Math.min(h,i),k=Math.max(h,i),l=[],m=[],n=[],o,p;if(b){var q={},r=[],s,t=f.length;for(g=-1;++g<h;)s=b.call(o=a[g],o.__data__,g),s in q?n[t++]=o:q[s]=o,r.push(s);for(g=-1;++g<i;)o=q[s=b.call(f,p=f[g],g)],o?(o.__data__=p,l[g]=o,m[g]=n[g]=null):(m[g]=bj(p),l[g]=n[g]=null),delete q[s];for(g=-1;++g<h;)r[g]in q&&(n[g]=a[g])}else{for(g=-1;++g<j;)o=a[g],p=f[g],o?(o.__data__=p,l[g]=o,m[g]=n[g]=null):(m[g]=bj(p),l[g]=n[g]=null);for(;g<i;++g)m[g]=bj(f[g]),l[g]=n[g]=null;for(;g<k;++g)n[g]=a[g],m[g]=l[g]=null}m.update=l,m.parentNode=l.parentNode=n.parentNode=a.parentNode,c.push(m),d.push(l),e.push(n)}var c=[],d=[],e=[],g=-1,h=this.length,i;if(typeof a=="function")while(++g<h)f(i=this[g],a.call(i,i.parentNode.__data__,g));else while(++g<h)f(i=this[g],a);var j=bb(d);return j.enter=function(){return bm(c)},j.exit=function(){return bb(e)},j},be.filter=function(a){var b=[],c,d,e;for(var f=0,g=this.length;f<g;f++){b.push(c=[]),c.parentNode=(d=this[f]).parentNode;for(var h=0,i=d.length;h<i;h++)(e=d[h])&&a.call(e,e.__data__,h)&&c.push(e)}return bb(b)},be.map=function(a){return this.each(function(){this.__data__=a.apply(this,arguments)})},be.sort=function(a){a=bk.apply(this,arguments);for(var b=0,c=this.length;b<c;b++)for(var d=this[b].sort(a),e=1,f=d.length,g=d[0];e<f;e++){var h=d[e];h&&(g&&g.parentNode.insertBefore(h,g.nextSibling),g=h)}return this},be.on=function(a,b,c){arguments.length<3&&(c=!1);var d="__on"+a,e=a.indexOf(".");return e>0&&(a=a.substring(0,e)),arguments.length<2?(e=this.node()[d])&&e._:this.each(function(e,f){function h(a){var c=d3.event;d3.event=a;try{b.call(g,g.__data__,f)}finally{d3.event=c}}var g=this;g[d]&&g.removeEventListener(a,g[d],c),b&&g.addEventListener(a,g[d]=h,c),h._=b})},be.each=function(a){for(var b=-1,c=this.length;++b<c;)for(var d=this[b],e=-1,f=d.length;++e<f;){var g=d[e];g&&a.call(g,g.__data__,e,b)}return this},be.call=function(a){return a.apply(this,(arguments[0]=this,arguments)),this},be.empty=function(){return!this.node()},be.node=function(a){for(var b=0,c=this.length;b<c;b++)for(var d=this[b],e=0,f=d.length;e<f;e++){var g=d[e];if(g)return g}return null},be.transition=function(){var a=[],b,c;for(var d=-1,e=this.length;++d<e;){a.push(b=[]);for(var f=this[d],g=-1,h=f.length;++g<h;)b.push((c=f[g])?{node:c,delay:0,duration:250}:null)}return bo(a,bu||++bt,Date.now())};var bl=bb([[document]]);bl[0].parentNode=document.documentElement,d3.select=function(a){return typeof a=="string"?bl.select(a):bb([[a]])},d3.selectAll=function(a){return typeof a=="string"?bl.selectAll(a):bb([d(a)])};var bn=[];bn.append=be.append,bn.insert=be.insert,bn.empty=be.empty,bn.node=be.node,bn.select=function(a){var b=[],c,d,e,f,g;for(var h=-1,i=this.length;++h<i;){e=(f=this[h]).update,b.push(c=[]),c.parentNode=f.parentNode;for(var j=-1,k=f.length;++j<k;)(g=f[j])?(c.push(e[j]=d=a.call(f.parentNode,g.__data__,j)),d.__data__=g.__data__):c.push(null)}return bb(b)};var bp={},bs=[],bt=0,bu=0,bv=d3.ease("cubic-in-out");bs.call=be.call,d3.transition=function(){return bl.transition()},d3.transition.prototype=bs,bs.select=function(a){var b=[],c,d,e;typeof a!="function"&&(a=bf(a));for(var f=-1,g=this.length;++f<g;){b.push(c=[]);for(var h=this[f],i=-1,j=h.length;++i<j;)(e=h[i])&&(d=a.call(e.node,e.node.__data__,i))?("__data__"in e.node&&(d.__data__=e.node.__data__),c.push({node:d,delay:e.delay,duration:e.duration})):c.push(null)}return bo(b,this.id,this.time).ease(this.ease())},bs.selectAll=function(a){var b=[],c,d,e;typeof a!="function"&&(a=bg(a));for(var f=-1,g=this.length;++f<g;)for(var h=this[f],i=-1,j=h.length;++i<j;)if(e=h[i]){d=a.call(e.node,e.node.__data__,i),b.push(c=[]);for(var k=-1,l=d.length;++k<l;)c.push({node:d[k],delay:e.delay,duration:e.duration})}return bo(b,this.id,this.time).ease(this.ease())},bs.attr=function(a,b){return this.attrTween(a,br(b))},bs.attrTween=function(a,b){function d(a,d){var e=b.call(this,a,d,this.getAttribute(c));return e===bp?(this.removeAttribute(c),null):e&&function(a){this.setAttribute(c,e(a))}}function e(a,d){var e=b.call(this,a,d,this.getAttributeNS(c.space,c.local));return e===bp?(this.removeAttributeNS(c.space,c.local),null):e&&function(a){this.setAttributeNS(c.space,c.local,e(a))}}var c=d3.ns.qualify(a);return this.tween("attr."+a,c.local?e:d)},bs.style=function(a,b,c){return arguments.length<3&&(c=""),this.styleTween(a,br(b),c)},bs.styleTween=function(a,b,c){return arguments.length<3&&(c=""),this.tween("style."+a,function(d,e){var f=b.call(this,d,e,window.getComputedStyle(this,null).getPropertyValue(a));return f===bp?(this.style.removeProperty(a),null):f&&function(b){this.style.setProperty(a,f(b),c)}})},bs.text=function(a){return this.tween("text",function(b,c){this.textContent=typeof a=="function"?a.call(this,b,c):a})},bs.remove=function(){return this.each("end",function(){var a;!this.__transition__&&(a=this.parentNode)&&a.removeChild(this)})},bs.delay=function(a){var b=this;return b.each(typeof a=="function"?function(c,d,e){b[e][d].delay=+a.apply(this,arguments)}:(a=+a,function(c,d,e){b[e][d].delay=a}))},bs.duration=function(a){var b=this;return b.each(typeof a=="function"?function(c,d,e){b[e][d].duration=+a.apply(this,arguments)}:(a=+a,function(c,d,e){b[e][d].duration=a}))},bs.transition=function(){return this.select(i)};var bx=null,by,bz;d3.timer=function(a,b,c){var d=!1,e,f=bx;if(arguments.length<3){if(arguments.length<2)b=0;else if(!isFinite(b))return;c=Date.now()}while(f){if(f.callback===a){f.then=c,f.delay=b,d=!0;break}e=f,f=f.next}d||(bx={callback:a,then:c,delay:b,next:bx}),by||(bz=clearTimeout(bz),by=1,bC(bA))},d3.timer.flush=function(){var a,b=Date.now(),c=bx;while(c)a=b-c.then,c.delay||(c.flush=c.callback(a)),c=c.next;bB()};var bC=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(a){setTimeout(a,17)};d3.scale={},d3.scale.linear=function(){return bH([0,1],[0,1],d3.interpolate,!1)},d3.scale.log=function(){return bP(d3.scale.linear(),bR)};var bQ=d3.format("e");bR.pow=function(a){return Math.pow(10,a)},bS.pow=function(a){return-Math.pow(10,-a)},d3.scale.pow=function(){return bT(d3.scale.linear(),1)},d3.scale.sqrt=function(){return d3.scale.pow().exponent(.5)},d3.scale.ordinal=function(){return bV([],{t:"range",x:[]})},d3.scale.category10=function(){return d3.scale.ordinal().range(bW)},d3.scale.category20=function(){return d3.scale.ordinal().range(bX)},d3.scale.category20b=function(){return d3.scale.ordinal().range(bY)},d3.scale.category20c=function(){return d3.scale.ordinal().range(bZ)};var bW=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],bX=["#1f77b4","#aec7e8","#ff7f0e","#ffbb78","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5","#8c564b","#c49c94","#e377c2","#f7b6d2","#7f7f7f","#c7c7c7","#bcbd22","#dbdb8d","#17becf","#9edae5"],bY=["#393b79","#5254a3","#6b6ecf","#9c9ede","#637939","#8ca252","#b5cf6b","#cedb9c","#8c6d31","#bd9e39","#e7ba52","#e7cb94","#843c39","#ad494a","#d6616b","#e7969c","#7b4173","#a55194","#ce6dbd","#de9ed6"],bZ=["#3182bd","#6baed6","#9ecae1","#c6dbef","#e6550d","#fd8d3c","#fdae6b","#fdd0a2","#31a354","#74c476","#a1d99b","#c7e9c0","#756bb1","#9e9ac8","#bcbddc","#dadaeb","#636363","#969696","#bdbdbd","#d9d9d9"];d3.scale.quantile=function(){return b$([],[])},d3.scale.quantize=function(){return b_(0,1,[0,1])},d3.svg={},d3.svg.arc=function(){function e(){var e=a.apply(this,arguments),f=b.apply(this,arguments),g=c.apply(this,arguments)+ca,h=d.apply(this,arguments)+ca,i=(h<g&&(i=g,g=h,h=i),h-g),j=i<Math.PI?"0":"1",k=Math.cos(g),l=Math.sin(g),m=Math.cos(h),n=Math.sin(h);return i>=cb?e?"M0,"+f+"A"+f+","+f+" 0 1,1 0,"+ -f+"A"+f+","+f+" 0 1,1 0,"+f+"M0,"+e+"A"+e+","+e+" 0 1,0 0,"+ -e+"A"+e+","+e+" 0 1,0 0,"+e+"Z":"M0,"+f+"A"+f+","+f+" 0 1,1 0,"+ -f+"A"+f+","+f+" 0 1,1 0,"+f+"Z":e?"M"+f*k+","+f*l+"A"+f+","+f+" 0 "+j+",1 "+f*m+","+f*n+"L"+e*m+","+e*n+"A"+e+","+e+" 0 "+j+",0 "+e*k+","+e*l+"Z":"M"+f*k+","+f*l+"A"+f+","+f+" 0 "+j+",1 "+f*m+","+f*n+"L0,0"+"Z"}var a=cc,b=cd,c=ce,d=cf;return e.innerRadius=function(b){return arguments.length?(a=d3.functor(b),e):a},e.outerRadius=function(a){return arguments.length?(b=d3.functor(a),e):b},e.startAngle=function(a){return arguments.length?(c=d3.functor(a),e):c},e.endAngle=function(a){return arguments.length?(d=d3.functor(a),e):d},e.centroid=function(){var e=(a.apply(this,arguments)+b.apply(this,arguments))/2,f=(c.apply(this,arguments)+d.apply(this,arguments))/2+ca;return[Math.cos(f)*e,Math.sin(f)*e]},e};var ca=-Math.PI/2,cb=2*Math.PI-1e-6;d3.svg.line=function(){return cg(Object)};var ck={linear:cl,"step-before":cm,"step-after":cn,basis:ct,"basis-open":cu,"basis-closed":cv,bundle:cw,cardinal:cq,"cardinal-open":co,"cardinal-closed":cp,monotone:cF},cy=[0,2/3,1/3,0],cz=[0,1/3,2/3,0],cA=[0,1/6,2/3,1/6];d3.svg.line.radial=function(){var a=cg(cG);return a.radius=a.x,delete a.x,a.angle=a.y,delete a.y,a},cm.reverse=cn,cn.reverse=cm,d3.svg.area=function(){return cH(Object)},d3.svg.area.radial=function(){var a=cH(cG);return a.radius=a.x,delete a.x,a.innerRadius=a.x0,delete a.x0,a.outerRadius=a.x1,delete a.x1,a.angle=a.y,delete a.y,a.startAngle=a.y0,delete a.y0,a.endAngle=a.y1,delete a.y1,a},d3.svg.chord=function(){function f(c,d){var e=g(this,a,c,d),f=g(this,b,c,d);return"M"+e.p0+i(e.r,e.p1)+(h(e,f)?j(e.r,e.p1,e.r,e.p0):j(e.r,e.p1,f.r,f.p0)+i(f.r,f.p1)+j(f.r,f.p1,e.r,e.p0))+"Z"}function g(a,b,f,g){var h=b.call(a,f,g),i=c.call(a,h,g),j=d.call(a,h,g)+ca,k=e.call(a,h,g)+ca;return{r:i,a0:j,a1:k,p0:[i*Math.cos(j),i*Math.sin(j)],p1:[i*Math.cos(k),i*Math.sin(k)]}}function h(a,b){return a.a0==b.a0&&a.a1==b.a1}function i(a,b){return"A"+a+","+a+" 0 0,1 "+b}function j(a,b,c,d){return"Q 0,0 "+d}var a=cK,b=cL,c=cM,d=ce,e=cf;return f.radius=function(a){return arguments.length?(c=d3.functor(a),f):c},f.source=function(b){return arguments.length?(a=d3.functor(b),f):a},f.target=function(a){return arguments.length?(b=d3.functor(a),f):b},f.startAngle=function(a){return arguments.length?(d=d3.functor(a),f):d},f.endAngle=function(a){return arguments.length?(e=d3.functor(a),f):e},f},d3.svg.diagonal=function(){function d(d,e){var f=a.call(this,d,e),g=b.call(this,d,e),h=(f.y+g.y)/2,i=[f,{x:f.x,y:h},{x:g.x,y:h},g];return i=i.map(c),"M"+i[0]+"C"+i[1]+" "+i[2]+" "+i[3]}var a=cK,b=cL,c=cP;return d.source=function(b){return arguments.length?(a=d3.functor(b),d):a},d.target=function(a){return arguments.length?(b=d3.functor(a),d):b},d.projection=function(a){return arguments.length?(c=a,d):c},d},d3.svg.diagonal.radial=function(){var a=d3.svg.diagonal(),b=cP,c=a.projection;return a.projection=function(a){return arguments.length?c(cQ(b=a)):b},a},d3.svg.mouse=function(a){return cS(a,d3.event)};var cR=/WebKit/.test(navigator.userAgent)?-1:0;d3.svg.touches=function(a,b){return arguments.length<2&&(b=d3.event.touches),b?d(b).map(function(b){var c=cS(a,b);return c.identifier=b.identifier,c}):[]},d3.svg.symbol=function(){function c(c,d){return(cV[a.call(this,c,d)]||cV.circle)(b.call(this,c,d))}var a=cU,b=cT;return c.type=function(b){return arguments.length?(a=d3.functor(b),c):a},c.size=function(a){return arguments.length?(b=d3.functor(a),c):b},c};var cV={circle:function(a){var b=Math.sqrt(a/Math.PI);return"M0,"+b+"A"+b+","+b+" 0 1,1 0,"+ -b+"A"+b+","+b+" 0 1,1 0,"+b+"Z"},cross:function(a){var b=Math.sqrt(a/5)/2;return"M"+ -3*b+","+ -b+"H"+ -b+"V"+ -3*b+"H"+b+"V"+ -b+"H"+3*b+"V"+b+"H"+b+"V"+3*b+"H"+ -b+"V"+b+"H"+ -3*b+"Z"},diamond:function(a){var b=Math.sqrt(a/(2*cX)),c=b*cX;return"M0,"+ -b+"L"+c+",0"+" 0,"+b+" "+ -c+",0"+"Z"},square:function(a){var b=Math.sqrt(a)/2;return"M"+ -b+","+ -b+"L"+b+","+ -b+" "+b+","+b+" "+ -b+","+b+"Z"},"triangle-down":function(a){var b=Math.sqrt(a/cW),c=b*cW/2;return"M0,"+c+"L"+b+","+ -c+" "+ -b+","+ -c+"Z"},"triangle-up":function(a){var b=Math.sqrt(a/cW),c=b*cW/2;return"M0,"+ -c+"L"+b+","+c+" "+ -b+","+c+"Z"}};d3.svg.symbolTypes=d3.keys(cV);var cW=Math.sqrt(3),cX=Math.tan(30*Math.PI/180);d3.svg.axis=function(){function j(j){j.each(function(k,l,m){var n=d3.select(this),o=j.delay?function(a){var b=bu;try{return bu=j.id,a.transition().delay(j[m][l].delay).duration(j[m][l].duration).ease(j.ease())}finally{bu=b}}:Object,p=a.ticks.apply(a,g),q=h==null?a.tickFormat.apply(a,g):h,r=c$(a,p,i),s=n.selectAll(".minor").data(r,String),t=s.enter().insert("svg:line","g").attr("class","tick minor").style("opacity",1e-6),u=o(s.exit()).style("opacity",1e-6).remove(),v=o(s).style("opacity",1),w=n.selectAll("g").data(p,String),x=w.enter().insert("svg:g","path").style("opacity",1e-6),y=o(w.exit()).style("opacity",1e-6).remove(),z=o(w).style("opacity",1),A,B=bE(a.range()),C=n.selectAll(".domain").data([0]),D=C.enter().append("svg:path").attr("class","domain"),E=o(C),F=this.__chart__||a;this.__chart__=a.copy(),x.append("svg:line").attr("class","tick"),x.append("svg:text"),z.select("text").text(q);switch(b){case"bottom":A=cY,v.attr("x2",0).attr("y2",d),z.select("line").attr("x2",0).attr("y2",c),z.select("text").attr("x",0).attr("y",Math.max(c,0)+f).attr("dy",".71em").attr("text-anchor","middle"),E.attr("d","M"+B[0]+","+e+"V0H"+B[1]+"V"+e);break;case"top":A=cY,v.attr("x2",0).attr("y2",-d),z.select("line").attr("x2",0).attr("y2",-c),z.select("text").attr("x",0).attr("y",-(Math.max(c,0)+f)).attr("dy","0em").attr("text-anchor","middle"),E.attr("d","M"+B[0]+","+ -e+"V0H"+B[1]+"V"+ -e);break;case"left":A=cZ,v.attr("x2",-d).attr("y2",0),z.select("line").attr("x2",-c).attr("y2",0),z.select("text").attr("x",-(Math.max(c,0)+f)).attr("y",0).attr("dy",".32em").attr("text-anchor","end"),E.attr("d","M"+ -e+","+B[0]+"H0V"+B[1]+"H"+ -e);break;case"right":A=cZ,v.attr("x2",d).attr("y2",0),z.select("line").attr("x2",c).attr("y2",0),z.select("text").attr("x",Math.max(c,0)+f).attr("y",0).attr("dy",".32em").attr("text-anchor","start"),E.attr("d","M"+e+","+B[0]+"H0V"+B[1]+"H"+e)}x.call(A,F),z.call(A,a),y.call(A,a),t.call(A,F),v.call(A,a),u.call(A,a)})}var a=d3.scale.linear(),b="bottom",c=6,d=6,e=6,f=3,g=[10],h,i=0;return j.scale=function(b){return arguments.length?(a=b,j):a},j.orient=function(a){return arguments.length?(b=a,j):b},j.ticks=function(){return arguments.length?(g=arguments,j):g},j.tickFormat=function(a){return arguments.length?(h=a,j):h},j.tickSize=function(a,b,f){if(!arguments.length)return c;var g=arguments.length-1;return c=+a,d=g>1?+b:c,e=g>0?+arguments[g]:c,j},j.tickPadding=function(a){return arguments.length?(f=+a,j):f},j.tickSubdivide=function(a){return arguments.length?(i=+a,j):i},j},d3.svg.brush=function(){function e(a){var g=b&&c?["n","e","s","w","nw","ne","se","sw"]:b?["e","w"]:c?["n","s"]:[];a.each(function(){var a=d3.select(this).on("mousedown.brush",f),h=a.selectAll(".background").data([,]),i=a.selectAll(".extent").data([,]),j=a.selectAll(".resize").data(g,String),k;h.enter().append("svg:rect").attr("class","background").style("visibility","hidden").style("pointer-events","all").style("cursor","crosshair"),i.enter().append("svg:rect").attr("class","extent").style("cursor","move"),j.enter().append("svg:rect").attr("class",function(a){return"resize "+a}).attr("width",6).attr("height",6).style("visibility","hidden").style("pointer-events",e.empty()?"none":"all").style("cursor",function(a){return dr[a]}),j.exit().remove(),b&&(k=bE(b.range()),h.attr("x",k[0]).attr("width",k[1]-k[0]),dj(a,d)),c&&(k=bE(c.range()),h.attr("y",k[0]).attr("height",k[1]-k[0]),dk(a,d))})}function f(){var a=d3.select(d3.event.target);c_=e,db=this,de=d,di=d3.svg.mouse(db),(df=a.classed("extent"))?(di[0]=d[0][0]-di[0],di[1]=d[0][1]-di[1]):a.classed("resize")?(dg=d3.event.target.__data__,di[0]=d[+/w$/.test(dg)][0],di[1]=d[+/^n/.test(dg)][1]):d3.event.altKey&&(dh=di.slice()),dc=!/^(n|s)$/.test(dg)&&b,dd=!/^(e|w)$/.test(dg)&&c,da=g(this,arguments),da("brushstart"),dn(),M()}function g(b,c){return function(d){var f=d3.event;try{d3.event={type:d,target:e},a[d].apply(b,c)}finally{d3.event=f}}}var a=d3.dispatch("brushstart","brush","brushend"),b,c,d=[[0,0],[0,0]];return e.x=function(a){return arguments.length?(b=a,e):b},e.y=function(a){return arguments.length?(c=a,e):c},e.extent=function(a){var f,g,h,i,j;return arguments.length?(b&&(f=a[0],g=a[1],c&&(f=f[0],g=g[0]),f=b(f),g=b(g),g<f&&(j=f,f=g,g=j),d[0][0]=f,d[1][0]=g),c&&(h=a[0],i=a[1],b&&(h=h[1],i=i[1]),h=c(h),i=c(i),i<h&&(j=h,h=i,i=j),d[0][1]=h,d[1][1]=i),e):(b&&(f=b.invert(d[0][0]),g=b.invert(d[1][0]),g<f&&(j=f,f=g,g=j)),c&&(h=c.invert(d[0][1]),i=c.invert(d[1][1]),i<h&&(j=h,h=i,i=j)),b&&c?[[f,h],[g,i]]:b?[f,g]:c&&[h,i])},e.clear=function(){return d[0][0]=d[0][1]=d[1][0]=d[1][1]=0,e},e.empty=function(){return b&&d[0][0]===d[1][0]||c&&d[0][1]===d[1][1]},e.on=function(b,c){return a.on(b,c),e},d3.select(window).on("mousemove.brush",dn).on("mouseup.brush",dq).on("keydown.brush",dl).on("keyup.brush",dm),e};var c_,da,db,dc,dd,de,df,dg,dh,di,dr={n:"ns-resize",e:"ew-resize",s:"ns-resize",w:"ew-resize",nw:"nwse-resize",ne:"nesw-resize",se:"nwse-resize",sw:"nesw-resize"};d3.behavior={},d3.behavior.drag=function(){function b(){this.on("mousedown.drag",d).on("touchstart.drag",d),d3.select(window).on("mousemove.drag",dB).on("touchmove.drag",dB).on("mouseup.drag",dC,!0).on("touchend.drag",dC,!0).on("click.drag",dD,!0)}function c(){ds=a,dt=d3.event.target,dw=dA((du=this).parentNode),dx=0,dv=arguments}function d(){c.apply(this,arguments),dz("dragstart")}var a=d3.dispatch("drag","dragstart","dragend");return b.on=function(c,d){return a.on(c,d),b},b};var ds,dt,du,dv,dw,dx,dy;d3.behavior.zoom=function(){function d(){this.on("mousedown.zoom",f).on("mousewheel.zoom",g).on("DOMMouseScroll.zoom",g).on("dblclick.zoom",h).on("touchstart.zoom",i),d3.select(window).on("mousemove.zoom",dV).on("mouseup.zoom",dW).on("touchmove.zoom",dU).on("touchend.zoom",dT).on("click.zoom",dX,!0)}function e(){dJ=a,dK=c,dL=b.zoom,dM=d3.event.target,dN=this,dO=arguments}function f(){e.apply(this,arguments),dF=dR(d3.svg.mouse(dN)),dP=!1,d3.event.preventDefault(),window.focus()}function g(){e.apply(this,arguments),dG||(dG=dR(d3.svg.mouse(dN))),dY(dS()+a[2],d3.svg.mouse(dN),dG)}function h(){e.apply(this,arguments);var b=d3.svg.mouse(dN);dY(d3.event.shiftKey?Math.ceil(a[2]-1):Math.floor(a[2]+1),b,dR(b))}function i(){e.apply(this,arguments);var b=dT(),c,d=Date.now();b.length===1&&d-dI<300&&dY(1+Math.floor(a[2]),c=b[0],dH[c.identifier]),dI=d}var a=[0,0,0],b=d3.dispatch("zoom"),c=[[-Infinity,Infinity],[-Infinity,Infinity],[-Infinity,Infinity]];return d.extent=function(a){return arguments.length?(c=a==null?(a=[-Infinity,Infinity],[a,a,a]):a,d):c},d.on=function(a,c){return b.on(a,c),d},d};var dE,dF,dG,dH={},dI=0,dJ,dK,dL,dM,dN,dO,dP,dQ})(); <ide>\ No newline at end of file <ide><path>src/behavior/zoom.js <ide> d3.behavior.zoom = function() { <ide> function start() { <ide> d3_behavior_zoomXyz = xyz; <ide> d3_behavior_zoomExtent = extent; <del> d3_behavior_zoomDispatch = event.zoom.dispatch; <add> d3_behavior_zoomDispatch = event.zoom; <ide> d3_behavior_zoomEventTarget = d3.event.target; <ide> d3_behavior_zoomTarget = this; <ide> d3_behavior_zoomArguments = arguments;
3
Python
Python
reduce logs from imported/vendored fab class
c6414b8f4e7505c7c59da1045691cbf7eeee8ee0
<ide><path>airflow/www/extensions/init_appbuilder.py <ide> from airflow import settings <ide> from airflow.configuration import conf <ide> <del>log = logging.getLogger(__name__) <add># This module contains code imported from FlaskAppbuilder, so lets use _its_ logger name <add>log = logging.getLogger("flask_appbuilder.base") <ide> <ide> <ide> def dynamic_class_import(class_path):
1
PHP
PHP
handle case when $this->events is null
ceab3cc25cb7257c273b81dbf06f0c4e00fade90
<ide><path>src/Illuminate/Mail/Mailer.php <ide> public function send($view, array $data = [], $callback = null) <ide> <ide> $this->sendSwiftMessage($message->getSwiftMessage()); <ide> <del> $this->events->dispatch(new Events\MessageSent($message->getSwiftMessage())); <add> if ($this->events) { <add> $this->events->dispatch(new Events\MessageSent($message->getSwiftMessage())); <add> } <ide> } <ide> <ide> /**
1
PHP
PHP
fix failing test
f331866b855eac286edc81cdd86390fb865d5f17
<ide><path>src/View/Helper/FormHelper.php <ide> public function input($fieldName, array $options = []) { <ide> protected function _getInput($fieldName, $options) { <ide> switch ($options['type']) { <ide> case 'select': <del> $opts = $options['options']; <add> $opts = (array)$options['options']; <ide> unset($options['options']); <ide> return $this->select($fieldName, $opts, $options); <ide> case 'url':
1
Javascript
Javascript
add chain removal to ember.destroy
901b0f64cbd03d4dcf75bb616ef2b500b2dab449
<ide><path>packages/ember-metal/lib/properties.js <ide> Ember.createPrototype = function(obj, props) { <ide> if (META_KEY in ret) Ember.rewatch(ret); // setup watch chains if needed. <ide> return ret; <ide> }; <del> <del> <del>/** <del> Tears down the meta on an object so that it can be garbage collected. <del> Multiple calls will have no effect. <del> <del> @param {Object} obj the object to destroy <del> @returns {void} <del>*/ <del>Ember.destroy = function(obj) { <del> if (obj[META_KEY]) obj[META_KEY] = null; <del>}; <del> <ide><path>packages/ember-metal/lib/watching.js <ide> var normalizeTuple = Ember.normalizeTuple.primitive; <ide> var normalizePath = Ember.normalizePath; <ide> var SIMPLE_PROPERTY = Ember.SIMPLE_PROPERTY; <ide> var GUID_KEY = Ember.GUID_KEY; <add>var META_KEY = Ember.META_KEY; <ide> var notifyObservers = Ember.notifyObservers; <ide> <ide> var FIRST_KEY = /^([^\.\*]+)/; <ide> var propertyDidChange = Ember.propertyDidChange = function(obj, keyName) { <ide> chainsDidChange(obj, keyName); <ide> Ember.notifyObservers(obj, keyName); <ide> }; <add> <add>/** <add> Tears down the meta on an object so that it can be garbage collected. <add> Multiple calls will have no effect. <add> <add> @param {Object} obj the object to destroy <add> @returns {void} <add>*/ <add>Ember.destroy = function (obj) { <add> var meta = obj[META_KEY], chains, watching, paths, path; <add> if (meta) { <add> obj[META_KEY] = null; <add> // remove chains to remove circular references that would prevent GC <add> chains = meta.chains; <add> if (chains) { <add> watching = meta.watching; <add> paths = chains._paths; <add> for(path in paths) { <add> if (!(paths[path] > 0)) continue; // this check will also catch non-number vals. <add> chains.remove(path); <add> watching[path] = 0; <add> } <add> } <add> } <add>}; <ide><path>packages/ember-metal/tests/watching/watch_test.js <ide> testBoth('watching a global object that does not yet exist should queue', functi <ide> Global = null; // reset <ide> }); <ide> <add>testBoth('destroy should tear down chainWatchers', function(get, set) { <add> <add> Global = { foo: 'bar' }; <add> var obj = {}; <add> <add> Ember.watch(obj, 'Global.foo'); <add> <add> var metaGlobal = Ember.meta(Global); <add> equals(metaGlobal.watching.foo, 1, 'should be watching Global.foo'); <add> <add> Ember.destroy(obj); <add> <add> equals(metaGlobal.watching.foo, 0, 'should not be watching Global.foo'); <add> <add> Global = null; // reset <add>}); <ide><path>packages/ember-runtime/lib/system/core_object.js <ide> CoreObject.PrototypeMixin = Ember.Mixin.create( <ide> @private <ide> */ <ide> _scheduledDestroy: function() { <del> this[Ember.META_KEY] = null; <add> Ember.destroy(this); <ide> }, <ide> <ide> bind: function(to, from) {
4
Text
Text
fix lint error in modules.md
361632dab1eb57c55fae17d2fcb11b3000036661
<ide><path>doc/api/modules.md <ide> native modules and if a name matching a native module is added to the cache, <ide> only `node:`-prefixed require calls are going to receive the native module. <ide> Use with care! <ide> <add><!-- eslint-disable node-core/no-duplicate-requires --> <ide> ```js <ide> const assert = require('assert'); <ide> const realFs = require('fs');
1
Text
Text
improve ajax example [ci skip]
6dbd73d8264a12de329c4525c6e2a03a8533ee8d
<ide><path>guides/source/working_with_javascript_in_rails.md <ide> fetch("/test") <ide> .then((data) => data.text()) <ide> .then((html) => { <ide> const results = document.querySelector("#results"); <del> results.insertAdjacentHTML("beforeend", data); <add> results.insertAdjacentHTML("beforeend", html); <ide> }); <ide> ``` <ide>
1
Python
Python
add control if server did not return uptime stat
0e5b73c12bacb800fb95034ba4b393d5a56ffcc5
<ide><path>glances/glances.py <ide> def displaySystem(self, host, system, uptime): <ide> center = ((screen_x - len(uptime_msg)) // 2) - len(system_msg) // 2 <ide> self.term_window.addnstr(self.system_y, self.system_x + center, <ide> system_msg, 80, curses.A_UNDERLINE) <del> self.term_window.addnstr(self.uptime_y, screen_x - len(uptime_msg), <del> uptime_msg, 80) <del> return len(system_msg) + len(uptime_msg) <add> try: <add> self.term_window.addnstr(self.uptime_y, screen_x - len(uptime_msg), <add> uptime_msg, 80) <add> except: <add> return len(system_msg) <add> else: <add> return len(system_msg) + len(uptime_msg) <ide> elif (screen_x > self.system_x + len(system_msg)): <ide> center = (screen_x // 2) - len(system_msg) // 2 <ide> self.term_window.addnstr(self.system_y, self.system_x + center,
1
Javascript
Javascript
change the applicationtest to testresolver
0296f161b6e976719c11255dafaa055cbca3e9ec
<ide><path>packages/ember-application/lib/system/application.js <ide> Application.reopenClass({ <ide> }); <ide> <ide> function commonSetupRegistry(registry) { <add> registry.register('router:main', Router); <ide> registry.register('-view-registry:main', { create() { return dictionary(null); } }); <ide> <ide> registry.register('route:basic', Route); <ide><path>packages/ember-glimmer/tests/integration/application/actions-test.js <ide> moduleFor('Application test: actions', class extends ApplicationTest { <ide> ['@test actions in top level template application template target application controller'](assert) { <ide> assert.expect(1); <ide> <del> this.registerController('application', Controller.extend({ <add> this.add('controller:application', Controller.extend({ <ide> actions: { <ide> handleIt(arg) { <ide> assert.ok(true, 'controller received action properly'); <ide> } <ide> } <ide> })); <ide> <del> this.registerTemplate('application', '<button id="handle-it" {{action "handleIt"}}>Click!</button>'); <add> this.addTemplate('application', '<button id="handle-it" {{action "handleIt"}}>Click!</button>'); <ide> <ide> return this.visit('/') <ide> .then(() => { <ide> moduleFor('Application test: actions', class extends ApplicationTest { <ide> ['@test actions in nested outlet template target their controller'](assert) { <ide> assert.expect(1); <ide> <del> this.registerController('application', Controller.extend({ <add> this.add('controller:application', Controller.extend({ <ide> actions: { <ide> handleIt(arg) { <ide> assert.ok(false, 'application controller should not have received action!'); <ide> } <ide> } <ide> })); <ide> <del> this.registerController('index', Controller.extend({ <add> this.add('controller:index', Controller.extend({ <ide> actions: { <ide> handleIt(arg) { <ide> assert.ok(true, 'controller received action properly'); <ide> } <ide> } <ide> })); <ide> <del> this.registerTemplate('index', '<button id="handle-it" {{action "handleIt"}}>Click!</button>'); <add> this.addTemplate('index', '<button id="handle-it" {{action "handleIt"}}>Click!</button>'); <ide> <ide> return this.visit('/') <ide> .then(() => { <ide><path>packages/ember-glimmer/tests/integration/application/engine-test.js <ide> moduleFor('Application test: engine rendering', class extends ApplicationTest { <ide> setupAppAndRoutableEngine(hooks = []) { <ide> let self = this; <ide> <del> this.application.register('template:application', compile('Application{{outlet}}')); <add> this.addTemplate('application', 'Application{{outlet}}'); <ide> <ide> this.router.map(function() { <ide> this.mount('blog'); <ide> }); <del> this.application.register('route-map:blog', function() { <add> this.add('route-map:blog', function() { <ide> this.route('post', function() { <ide> this.route('comments'); <ide> this.route('likes'); <ide> }); <ide> this.route('category', {path: 'category/:id'}); <ide> this.route('author', {path: 'author/:id'}); <ide> }); <del> this.registerRoute('application', Route.extend({ <add> this.add('route:application', Route.extend({ <ide> model() { <ide> hooks.push('application - application'); <ide> } <ide> })); <ide> <del> this.registerEngine('blog', Engine.extend({ <add> this.add('engine:blog', Engine.extend({ <ide> init() { <ide> this._super(...arguments); <ide> this.register('controller:application', Controller.extend({ <ide> moduleFor('Application test: engine rendering', class extends ApplicationTest { <ide> setupAppAndRoutelessEngine(hooks) { <ide> this.setupRoutelessEngine(hooks); <ide> <del> this.registerEngine('chat-engine', Engine.extend({ <add> this.add('engine:chat-engine', Engine.extend({ <ide> init() { <ide> this._super(...arguments); <ide> this.register('template:application', compile('Engine')); <ide> moduleFor('Application test: engine rendering', class extends ApplicationTest { <ide> } <ide> <ide> setupAppAndRoutableEngineWithPartial(hooks) { <del> this.application.register('template:application', compile('Application{{outlet}}')); <add> this.addTemplate('application', 'Application{{outlet}}'); <ide> <ide> this.router.map(function() { <ide> this.mount('blog'); <ide> }); <del> this.application.register('route-map:blog', function() { }); <del> this.registerRoute('application', Route.extend({ <add> this.add('route-map:blog', function() { }); <add> this.add('route:application', Route.extend({ <ide> model() { <ide> hooks.push('application - application'); <ide> } <ide> })); <ide> <del> this.registerEngine('blog', Engine.extend({ <add> this.add('engine:blog', Engine.extend({ <ide> init() { <ide> this._super(...arguments); <ide> this.register('template:foo', compile('foo partial')); <ide> moduleFor('Application test: engine rendering', class extends ApplicationTest { <ide> } <ide> <ide> setupRoutelessEngine(hooks) { <del> this.application.register('template:application', compile('Application{{mount "chat-engine"}}')); <del> this.registerRoute('application', Route.extend({ <add> this.addTemplate('application', 'Application{{mount "chat-engine"}}'); <add> this.add('route:application', Route.extend({ <ide> model() { <ide> hooks.push('application - application'); <ide> } <ide> moduleFor('Application test: engine rendering', class extends ApplicationTest { <ide> setupAppAndRoutlessEngineWithPartial(hooks) { <ide> this.setupRoutelessEngine(hooks); <ide> <del> this.registerEngine('chat-engine', Engine.extend({ <add> this.add('engine:chat-engine', Engine.extend({ <ide> init() { <ide> this._super(...arguments); <ide> this.register('template:foo', compile('foo partial')); <ide> moduleFor('Application test: engine rendering', class extends ApplicationTest { <ide> } <ide> <ide> setupEngineWithAttrs(hooks) { <del> this.application.register('template:application', compile('Application{{mount "chat-engine"}}')); <add> this.addTemplate('application', 'Application{{mount "chat-engine"}}'); <ide> <del> this.registerEngine('chat-engine', Engine.extend({ <add> this.add('engine:chat-engine', Engine.extend({ <ide> init() { <ide> this._super(...arguments); <ide> this.register('template:components/foo-bar', compile(`{{partial "troll"}}`)); <ide> moduleFor('Application test: engine rendering', class extends ApplicationTest { <ide> {{outlet}} <ide> `); <ide> <del> this.application.register('template:application', sharedTemplate); <del> this.registerController('application', Controller.extend({ <add> this.add('template:application', sharedTemplate); <add> this.add('controller:application', Controller.extend({ <ide> contextType: 'Application', <ide> 'ambiguous-curlies': 'Controller Data!' <ide> })); <ide> <ide> this.router.map(function() { <ide> this.mount('blog'); <ide> }); <del> this.application.register('route-map:blog', function() { }); <add> this.add('route-map:blog', function() { }); <ide> <del> this.registerEngine('blog', Engine.extend({ <add> this.add('engine:blog', Engine.extend({ <ide> init() { <ide> this._super(...arguments); <ide> <ide> moduleFor('Application test: engine rendering', class extends ApplicationTest { <ide> layout: sharedLayout <ide> }); <ide> <del> this.application.register('template:application', compile(strip` <add> this.addTemplate('application', strip` <ide> <h1>Application</h1> <ide> {{my-component ambiguous-curlies="Local Data!"}} <ide> {{outlet}} <del> `)); <add> `); <ide> <del> this.application.register('component:my-component', sharedComponent); <add> this.add('component:my-component', sharedComponent); <ide> <ide> this.router.map(function() { <ide> this.mount('blog'); <ide> }); <del> this.application.register('route-map:blog', function() { }); <add> this.add('route-map:blog', function() { }); <ide> <del> this.registerEngine('blog', Engine.extend({ <add> this.add('engine:blog', Engine.extend({ <ide> init() { <ide> this._super(...arguments); <ide> this.register('template:application', compile(strip` <ide> moduleFor('Application test: engine rendering', class extends ApplicationTest { <ide> <ide> this.setupAppAndRoutableEngine(); <ide> <del> this.registerEngine('blog', Engine.extend({ <add> this.add('engine:blog', Engine.extend({ <ide> init() { <ide> this._super(...arguments); <ide> this.register('template:application', compile('Engine{{outlet}}')); <ide> moduleFor('Application test: engine rendering', class extends ApplicationTest { <ide> assert.expect(2); <ide> <ide> this.setupAppAndRoutableEngine(); <del> this.application.__registry__.resolver.moduleBasedResolver = true; <ide> this.additionalEngineRegistrations(function() { <ide> this.register('template:application_error', compile('Error! {{model.message}}')); <ide> this.register('route:post', Route.extend({ <ide> moduleFor('Application test: engine rendering', class extends ApplicationTest { <ide> assert.expect(2); <ide> <ide> this.setupAppAndRoutableEngine(); <del> this.application.__registry__.resolver.moduleBasedResolver = true; <ide> this.additionalEngineRegistrations(function() { <ide> this.register('template:error', compile('Error! {{model.message}}')); <ide> this.register('route:post', Route.extend({ <ide> moduleFor('Application test: engine rendering', class extends ApplicationTest { <ide> assert.expect(2); <ide> <ide> this.setupAppAndRoutableEngine(); <del> this.application.__registry__.resolver.moduleBasedResolver = true; <ide> this.additionalEngineRegistrations(function() { <ide> this.register('template:post_error', compile('Error! {{model.message}}')); <ide> this.register('route:post', Route.extend({ <ide> moduleFor('Application test: engine rendering', class extends ApplicationTest { <ide> assert.expect(2); <ide> <ide> this.setupAppAndRoutableEngine(); <del> this.application.__registry__.resolver.moduleBasedResolver = true; <ide> this.additionalEngineRegistrations(function() { <ide> this.register('template:post.error', compile('Error! {{model.message}}')); <ide> this.register('route:post.comments', Route.extend({ <ide> moduleFor('Application test: engine rendering', class extends ApplicationTest { <ide> let resolveLoading; <ide> <ide> this.setupAppAndRoutableEngine(); <del> this.application.__registry__.resolver.moduleBasedResolver = true; <ide> this.additionalEngineRegistrations(function() { <ide> this.register('template:application_loading', compile('Loading')); <ide> this.register('template:post', compile('Post')); <ide> moduleFor('Application test: engine rendering', class extends ApplicationTest { <ide> let resolveLoading; <ide> <ide> this.setupAppAndRoutableEngine(); <del> this.application.__registry__.resolver.moduleBasedResolver = true; <ide> this.additionalEngineRegistrations(function() { <ide> this.register('template:post', compile('{{outlet}}')); <ide> this.register('template:post.comments', compile('Comments')); <ide><path>packages/ember-glimmer/tests/integration/application/rendering-test.js <ide> import { Component } from 'ember-glimmer'; <ide> moduleFor('Application test: rendering', class extends ApplicationTest { <ide> <ide> ['@test it can render the application template'](assert) { <del> this.registerTemplate('application', 'Hello world!'); <add> this.addTemplate('application', 'Hello world!'); <ide> <ide> return this.visit('/').then(() => { <ide> this.assertText('Hello world!'); <ide> }); <ide> } <ide> <ide> ['@test it can access the model provided by the route'](assert) { <del> this.registerRoute('application', Route.extend({ <add> this.add('route:application', Route.extend({ <ide> model() { <ide> return ['red', 'yellow', 'blue']; <ide> } <ide> })); <ide> <del> this.registerTemplate('application', strip` <add> this.addTemplate('application', strip` <ide> <ul> <ide> {{#each model as |item|}} <ide> <li>{{item}}</li> <ide> moduleFor('Application test: rendering', class extends ApplicationTest { <ide> }); <ide> <ide> // The "favorite" route will inherit the model <del> this.registerRoute('lists.colors', Route.extend({ <add> this.add('route:lists.colors', Route.extend({ <ide> model() { <ide> return ['red', 'yellow', 'blue']; <ide> } <ide> })); <ide> <del> this.registerTemplate('lists.colors.favorite', strip` <add> this.addTemplate('lists.colors.favorite', strip` <ide> <ul> <ide> {{#each model as |item|}} <ide> <li>{{item}}</li> <ide> moduleFor('Application test: rendering', class extends ApplicationTest { <ide> this.route('colors'); <ide> }); <ide> <del> this.registerTemplate('application', strip` <add> this.addTemplate('application', strip` <ide> <nav>{{outlet "nav"}}</nav> <ide> <main>{{outlet}}</main> <ide> `); <ide> <del> this.registerTemplate('nav', strip` <add> this.addTemplate('nav', strip` <ide> <a href="http://emberjs.com/">Ember</a> <ide> `); <ide> <del> this.registerRoute('application', Route.extend({ <add> this.add('route:application', Route.extend({ <ide> renderTemplate() { <ide> this.render(); <ide> this.render('nav', { <ide> moduleFor('Application test: rendering', class extends ApplicationTest { <ide> } <ide> })); <ide> <del> this.registerRoute('colors', Route.extend({ <add> this.add('route:colors', Route.extend({ <ide> model() { <ide> return ['red', 'yellow', 'blue']; <ide> } <ide> })); <ide> <del> this.registerTemplate('colors', strip` <add> this.addTemplate('colors', strip` <ide> <ul> <ide> {{#each model as |item|}} <ide> <li>{{item}}</li> <ide> moduleFor('Application test: rendering', class extends ApplicationTest { <ide> this.route('colors'); <ide> }); <ide> <del> this.registerTemplate('application', strip` <add> this.addTemplate('application', strip` <ide> <nav>{{outlet "nav"}}</nav> <ide> <main>{{outlet}}</main> <ide> `); <ide> <del> this.registerTemplate('nav', strip` <add> this.addTemplate('nav', strip` <ide> <a href="http://emberjs.com/">Ember</a> <ide> `); <ide> <del> this.registerRoute('application', Route.extend({ <add> this.add('route:application', Route.extend({ <ide> renderTemplate() { <ide> this.render(); <ide> this.render('nav', { <ide> moduleFor('Application test: rendering', class extends ApplicationTest { <ide> } <ide> })); <ide> <del> this.registerRoute('colors', Route.extend({ <add> this.add('route:colors', Route.extend({ <ide> model() { <ide> return ['red', 'yellow', 'blue']; <ide> } <ide> })); <ide> <del> this.registerTemplate('colors', strip` <add> this.addTemplate('colors', strip` <ide> <ul> <ide> {{#each model as |item|}} <ide> <li>{{item}}</li> <ide> moduleFor('Application test: rendering', class extends ApplicationTest { <ide> }); <ide> }); <ide> <del> this.registerTemplate('a', 'A{{outlet}}'); <del> this.registerTemplate('b', 'B{{outlet}}'); <del> this.registerTemplate('b.c', 'C'); <del> this.registerTemplate('b.d', 'D'); <add> this.addTemplate('a', 'A{{outlet}}'); <add> this.addTemplate('b', 'B{{outlet}}'); <add> this.addTemplate('b.c', 'C'); <add> this.addTemplate('b.d', 'D'); <ide> <ide> return this.visit('/b/c').then(() => { <ide> // this.assertComponentElement(this.firstChild, { content: 'BC' }); <ide> moduleFor('Application test: rendering', class extends ApplicationTest { <ide> this.route('color', { path: '/colors/:color' }); <ide> }); <ide> <del> this.registerRoute('color', Route.extend({ <add> this.add('route:color', Route.extend({ <ide> model(params) { <ide> return params.color; <ide> } <ide> })); <ide> <del> this.registerTemplate('color', 'color: {{model}}'); <add> this.addTemplate('color', 'color: {{model}}'); <ide> <ide> return this.visit('/colors/red').then(() => { <ide> this.assertComponentElement(this.firstChild, { content: 'color: red' }); <ide> moduleFor('Application test: rendering', class extends ApplicationTest { <ide> this.route('b'); <ide> }); <ide> <del> this.registerController('a', Controller.extend({ <add> this.add('controller:a', Controller.extend({ <ide> value: 'a' <ide> })); <ide> <del> this.registerController('b', Controller.extend({ <add> this.add('controller:b', Controller.extend({ <ide> value: 'b' <ide> })); <ide> <del> this.registerTemplate('a', '{{value}}'); <del> this.registerTemplate('b', '{{value}}'); <add> this.addTemplate('a', '{{value}}'); <add> this.addTemplate('b', '{{value}}'); <ide> <ide> return this.visit('/a').then(() => { <ide> this.assertText('a'); <ide> moduleFor('Application test: rendering', class extends ApplicationTest { <ide> this.route('color', { path: '/colors/:color' }); <ide> }); <ide> <del> this.registerRoute('color', Route.extend({ <add> this.add('route:color', Route.extend({ <ide> model(params) { <ide> return { color: params.color }; <ide> }, <ide> moduleFor('Application test: rendering', class extends ApplicationTest { <ide> } <ide> })); <ide> <del> this.registerController('red', Controller.extend({ <add> this.add('controller:red', Controller.extend({ <ide> color: 'red' <ide> })); <ide> <del> this.registerController('green', Controller.extend({ <add> this.add('controller:green', Controller.extend({ <ide> color: 'green' <ide> })); <ide> <del> this.registerTemplate('color', 'model color: {{model.color}}, controller color: {{color}}'); <add> this.addTemplate('color', 'model color: {{model.color}}, controller color: {{color}}'); <ide> <ide> return this.visit('/colors/red').then(() => { <ide> this.assertComponentElement(this.firstChild, { content: 'model color: red, controller color: red' }); <ide> moduleFor('Application test: rendering', class extends ApplicationTest { <ide> this.route('b'); <ide> }); <ide> <del> this.registerRoute('a', Route.extend({ <add> this.add('route:a', Route.extend({ <ide> model() { <ide> return 'A'; <ide> }, <ide> moduleFor('Application test: rendering', class extends ApplicationTest { <ide> } <ide> })); <ide> <del> this.registerRoute('b', Route.extend({ <add> this.add('route:b', Route.extend({ <ide> model() { <ide> return 'B'; <ide> }, <ide> moduleFor('Application test: rendering', class extends ApplicationTest { <ide> } <ide> })); <ide> <del> this.registerController('common', Controller.extend({ <add> this.add('controller:common', Controller.extend({ <ide> prefix: 'common' <ide> })); <ide> <del> this.registerTemplate('common', '{{prefix}} {{model}}'); <add> this.addTemplate('common', '{{prefix}} {{model}}'); <ide> <ide> return this.visit('/a').then(() => { <ide> this.assertComponentElement(this.firstChild, { content: 'common A' }); <ide> moduleFor('Application test: rendering', class extends ApplicationTest { <ide> // I wish there was a way to assert that the OutletComponentManager did not <ide> // receive a didCreateElement. <ide> ['@test a child outlet is always a fragment']() { <del> this.registerTemplate('application', '{{outlet}}'); <del> this.registerTemplate('index', '{{#if true}}1{{/if}}<div>2</div>'); <add> this.addTemplate('application', '{{outlet}}'); <add> this.addTemplate('index', '{{#if true}}1{{/if}}<div>2</div>'); <ide> return this.visit('/').then(() => { <ide> this.assertComponentElement(this.firstChild, { content: '1<div>2</div>' }); <ide> }); <ide> moduleFor('Application test: rendering', class extends ApplicationTest { <ide> this.route('a'); <ide> }); <ide> <del> this.registerRoute('index', Route.extend({ <add> this.add('route:index', Route.extend({ <ide> activate() { <ide> this.transitionTo('a'); <ide> } <ide> })); <ide> <del> this.registerTemplate('a', 'Hello from A!'); <add> this.addTemplate('a', 'Hello from A!'); <ide> <ide> return this.visit('/').then(() => { <ide> this.assertComponentElement(this.firstChild, { <ide> moduleFor('Application test: rendering', class extends ApplicationTest { <ide> this.route('routeWithError'); <ide> }); <ide> <del> this.registerRoute('routeWithError', Route.extend({ <add> this.add('route:routeWithError', Route.extend({ <ide> model() { <ide> return { name: 'Alex' }; <ide> } <ide> })); <ide> <del> this.registerTemplate('routeWithError', 'Hi {{model.name}} {{x-foo person=model}}'); <add> this.addTemplate('routeWithError', 'Hi {{model.name}} {{x-foo person=model}}'); <ide> <del> this.registerComponent('x-foo', { <add> this.addComponent('x-foo', { <ide> ComponentClass: Component.extend({ <ide> init() { <ide> this._super(...arguments); <ide><path>packages/ember-glimmer/tests/integration/components/link-to-test.js <ide> moduleFor('Link-to component', class extends ApplicationTest { <ide> <ide> ['@test accessing `currentWhen` triggers a deprecation'](assert) { <ide> let component; <del> this.registerComponent('link-to', { <add> this.addComponent('link-to', { <ide> ComponentClass: LinkComponent.extend({ <ide> init() { <ide> this._super(...arguments); <ide> moduleFor('Link-to component', class extends ApplicationTest { <ide> }) <ide> }); <ide> <del> this.registerTemplate('application', `{{link-to 'Index' 'index'}}`); <add> this.addTemplate('application', `{{link-to 'Index' 'index'}}`); <ide> <ide> return this.visit('/').then(() => { <ide> expectDeprecation(() => { <ide> moduleFor('Link-to component', class extends ApplicationTest { <ide> } <ide> <ide> ['@test should be able to be inserted in DOM when the router is not present']() { <del> this.registerTemplate('application', `{{#link-to 'index'}}Go to Index{{/link-to}}`); <add> this.addTemplate('application', `{{#link-to 'index'}}Go to Index{{/link-to}}`); <ide> <ide> return this.visit('/').then(() => { <ide> this.assertText('Go to Index'); <ide> moduleFor('Link-to component', class extends ApplicationTest { <ide> ['@test re-renders when title changes']() { <ide> let controller; <ide> <del> this.registerTemplate('application', '{{link-to title routeName}}'); <del> this.registerController('application', Controller.extend({ <add> this.addTemplate('application', '{{link-to title routeName}}'); <add> this.add('controller:application', Controller.extend({ <ide> init() { <ide> this._super(...arguments); <ide> controller = this; <ide> moduleFor('Link-to component', class extends ApplicationTest { <ide> } <ide> <ide> ['@test escaped inline form (double curlies) escapes link title']() { <del> this.registerTemplate('application', `{{link-to title 'index'}}`); <del> this.registerController('application', Controller.extend({ <add> this.addTemplate('application', `{{link-to title 'index'}}`); <add> this.add('controller:application', Controller.extend({ <ide> title: '<b>blah</b>' <ide> })); <ide> <ide> moduleFor('Link-to component', class extends ApplicationTest { <ide> } <ide> <ide> ['@test escaped inline form with (-html-safe) does not escape link title'](assert) { <del> this.registerTemplate('application', `{{link-to (-html-safe title) 'index'}}`); <del> this.registerController('application', Controller.extend({ <add> this.addTemplate('application', `{{link-to (-html-safe title) 'index'}}`); <add> this.add('controller:application', Controller.extend({ <ide> title: '<b>blah</b>' <ide> })); <ide> <ide> moduleFor('Link-to component', class extends ApplicationTest { <ide> } <ide> <ide> ['@test unescaped inline form (triple curlies) does not escape link title'](assert) { <del> this.registerTemplate('application', `{{{link-to title 'index'}}}`); <del> this.registerController('application', Controller.extend({ <add> this.addTemplate('application', `{{{link-to title 'index'}}}`); <add> this.add('controller:application', Controller.extend({ <ide> title: '<b>blah</b>' <ide> })); <ide> <ide> moduleFor('Link-to component', class extends ApplicationTest { <ide> this.router.map(function() { <ide> this.route('profile', { path: '/profile/:id' }); <ide> }); <del> this.registerTemplate('application', `{{#link-to 'profile' otherController}}Text{{/link-to}}`); <del> this.registerController('application', Controller.extend({ <add> this.addTemplate('application', `{{#link-to 'profile' otherController}}Text{{/link-to}}`); <add> this.add('controller:application', Controller.extend({ <ide> otherController: Controller.create({ <ide> model: 'foo' <ide> }) <ide> moduleFor('Link-to component', class extends ApplicationTest { <ide> } <ide> <ide> ['@test able to safely extend the built-in component and use the normal path']() { <del> this.registerComponent('custom-link-to', { ComponentClass: LinkComponent.extend() }); <del> this.registerTemplate('application', `{{#custom-link-to 'index'}}{{title}}{{/custom-link-to}}`); <del> this.registerController('application', Controller.extend({ <add> this.addComponent('custom-link-to', { ComponentClass: LinkComponent.extend() }); <add> this.addTemplate('application', `{{#custom-link-to 'index'}}{{title}}{{/custom-link-to}}`); <add> this.add('controller:application', Controller.extend({ <ide> title: 'Hello' <ide> })); <ide> <ide> moduleFor('Link-to component', class extends ApplicationTest { <ide> } <ide> <ide> ['@test [GH#13432] able to safely extend the built-in component and invoke it inline']() { <del> this.registerComponent('custom-link-to', { ComponentClass: LinkComponent.extend() }); <del> this.registerTemplate('application', `{{custom-link-to title 'index'}}`); <del> this.registerController('application', Controller.extend({ <add> this.addComponent('custom-link-to', { ComponentClass: LinkComponent.extend() }); <add> this.addTemplate('application', `{{custom-link-to title 'index'}}`); <add> this.add('controller:application', Controller.extend({ <ide> title: 'Hello' <ide> })); <ide> <ide> moduleFor('Link-to component with query-params', class extends ApplicationTest { <ide> constructor() { <ide> super(...arguments); <ide> <del> this.registerController('index', Controller.extend({ <add> this.add('controller:index', Controller.extend({ <ide> queryParams: ['foo'], <ide> foo: '123', <ide> bar: 'yes' <ide> })); <ide> } <ide> <ide> ['@test populates href with fully supplied query param values'](assert) { <del> this.registerTemplate('index', `{{#link-to 'index' (query-params foo='456' bar='NAW')}}Index{{/link-to}}`); <add> this.addTemplate('index', `{{#link-to 'index' (query-params foo='456' bar='NAW')}}Index{{/link-to}}`); <ide> <ide> return this.visit('/').then(() => { <ide> this.assertComponentElement(this.firstChild.firstElementChild, { <ide> moduleFor('Link-to component with query-params', class extends ApplicationTest { <ide> } <ide> <ide> ['@test populates href with partially supplied query param values, but omits if value is default value']() { <del> this.registerTemplate('index', `{{#link-to 'index' (query-params foo='123')}}Index{{/link-to}}`); <add> this.addTemplate('index', `{{#link-to 'index' (query-params foo='123')}}Index{{/link-to}}`); <ide> <ide> return this.visit('/').then(() => { <ide> this.assertComponentElement(this.firstChild.firstElementChild, { <ide><path>packages/ember-glimmer/tests/integration/components/target-action-test.js <ide> moduleFor('Components test: sendAction to a controller', class extends Applicati <ide> }); <ide> }); <ide> <del> this.registerComponent('foo-bar', { <add> this.addComponent('foo-bar', { <ide> ComponentClass: Component.extend({ <ide> init() { <ide> this._super(...arguments); <ide> moduleFor('Components test: sendAction to a controller', class extends Applicati <ide> template: `{{val}}` <ide> }); <ide> <del> this.registerController('a', Controller.extend({ <add> this.add('controller:a', Controller.extend({ <ide> send(actionName, actionContext) { <ide> assert.equal(actionName, 'poke', 'send() method was invoked from a top level controller'); <ide> assert.equal(actionContext, 'top', 'action arguments were passed into the top level controller'); <ide> } <ide> })); <del> this.registerTemplate('a', '{{foo-bar val="a" poke="poke"}}'); <add> this.addTemplate('a', '{{foo-bar val="a" poke="poke"}}'); <ide> <del> this.registerRoute('b', Route.extend({ <add> this.add('route:b', Route.extend({ <ide> actions: { <ide> poke(actionContext) { <ide> assert.ok(true, 'Unhandled action sent to route'); <ide> assert.equal(actionContext, 'top no controller'); <ide> } <ide> } <ide> })); <del> this.registerTemplate('b', '{{foo-bar val="b" poke="poke"}}'); <add> this.addTemplate('b', '{{foo-bar val="b" poke="poke"}}'); <ide> <del> this.registerRoute('c', Route.extend({ <add> this.add('route:c', Route.extend({ <ide> actions: { <ide> poke(actionContext) { <ide> assert.ok(true, 'Unhandled action sent to route'); <ide> assert.equal(actionContext, 'top with nested no controller'); <ide> } <ide> } <ide> })); <del> this.registerTemplate('c', '{{foo-bar val="c" poke="poke"}}{{outlet}}'); <add> this.addTemplate('c', '{{foo-bar val="c" poke="poke"}}{{outlet}}'); <ide> <del> this.registerRoute('c.d', Route.extend({})); <add> this.add('route:c.d', Route.extend({})); <ide> <del> this.registerController('c.d', Controller.extend({ <add> this.add('controller:c.d', Controller.extend({ <ide> send(actionName, actionContext) { <ide> assert.equal(actionName, 'poke', 'send() method was invoked from a nested controller'); <ide> assert.equal(actionContext, 'nested', 'action arguments were passed into the nested controller'); <ide> } <ide> })); <del> this.registerTemplate('c.d', '{{foo-bar val=".d" poke="poke"}}'); <add> this.addTemplate('c.d', '{{foo-bar val=".d" poke="poke"}}'); <ide> <del> this.registerRoute('c.e', Route.extend({ <add> this.add('route:c.e', Route.extend({ <ide> actions: { <ide> poke(actionContext) { <ide> assert.ok(true, 'Unhandled action sent to route'); <ide> assert.equal(actionContext, 'nested no controller'); <ide> } <ide> } <ide> })); <del> this.registerTemplate('c.e', '{{foo-bar val=".e" poke="poke"}}'); <add> this.addTemplate('c.e', '{{foo-bar val=".e" poke="poke"}}'); <ide> <ide> return this.visit('/a') <ide> .then(() => component.sendAction('poke', 'top')) <ide> moduleFor('Components test: sendAction to a controller', class extends Applicati <ide> <ide> let component; <ide> <del> this.registerComponent('x-parent', { <add> this.addComponent('x-parent', { <ide> ComponentClass: Component.extend({ <ide> actions: { <ide> poke() { <ide> moduleFor('Components test: sendAction to a controller', class extends Applicati <ide> template: '{{x-child poke="poke"}}' <ide> }); <ide> <del> this.registerComponent('x-child', { <add> this.addComponent('x-child', { <ide> ComponentClass: Component.extend({ <ide> init() { <ide> this._super(...arguments); <ide> moduleFor('Components test: sendAction to a controller', class extends Applicati <ide> }) <ide> }); <ide> <del> this.registerTemplate('application', '{{x-parent}}'); <del> this.registerController('application', Controller.extend({ <add> this.addTemplate('application', '{{x-parent}}'); <add> this.add('controller:application', Controller.extend({ <ide> send(actionName) { <ide> throw new Error('controller action should not be called'); <ide> } <ide><path>packages/ember-glimmer/tests/integration/components/utils-test.js <ide> moduleFor('View tree tests', class extends ApplicationTest { <ide> constructor() { <ide> super(); <ide> <del> this.registerComponent('x-tagless', { <add> this.addComponent('x-tagless', { <ide> ComponentClass: Component.extend({ <ide> tagName: '' <ide> }), <ide> <ide> template: '<div id="{{id}}">[{{id}}] {{#if isShowing}}{{yield}}{{/if}}</div>' <ide> }); <ide> <del> this.registerComponent('x-toggle', { <add> this.addComponent('x-toggle', { <ide> ComponentClass: Component.extend({ <ide> isExpanded: true, <ide> <ide> moduleFor('View tree tests', class extends ApplicationTest { <ide> } <ide> }); <ide> <del> this.registerController('application', ToggleController); <add> this.add('controller:application', ToggleController); <ide> <del> this.registerTemplate('application', ` <add> this.addTemplate('application', ` <ide> {{x-tagless id="root-1"}} <ide> <ide> {{#x-toggle id="root-2"}} <ide> moduleFor('View tree tests', class extends ApplicationTest { <ide> {{outlet}} <ide> `); <ide> <del> this.registerController('index', ToggleController.extend({ <add> this.add('controller:index', ToggleController.extend({ <ide> isExpanded: false <ide> })); <ide> <del> this.registerTemplate('index', ` <add> this.addTemplate('index', ` <ide> {{x-tagless id="root-4"}} <ide> <ide> {{#x-toggle id="root-5" isExpanded=false}} <ide> moduleFor('View tree tests', class extends ApplicationTest { <ide> {{/if}} <ide> `); <ide> <del> this.registerTemplate('zomg', ` <add> this.addTemplate('zomg', ` <ide> {{x-tagless id="root-7"}} <ide> <ide> {{#x-toggle id="root-8"}} <ide> moduleFor('View tree tests', class extends ApplicationTest { <ide> {{/x-toggle}} <ide> `); <ide> <del> this.registerTemplate('zomg.lol', ` <add> this.addTemplate('zomg.lol', ` <ide> {{x-toggle id="inner-10"}} <ide> `); <ide> <ide><path>packages/ember-glimmer/tests/integration/mount-test.js <ide> moduleFor('{{mount}} test', class extends ApplicationTest { <ide> <ide> let engineRegistrations = this.engineRegistrations = {}; <ide> <del> this.registerEngine('chat', Engine.extend({ <add> this.add('engine:chat', Engine.extend({ <ide> router: null, <ide> <ide> init() { <ide> moduleFor('{{mount}} test', class extends ApplicationTest { <ide> } <ide> })); <ide> <del> this.registerTemplate('index', '{{mount "chat"}}'); <add> this.addTemplate('index', '{{mount "chat"}}'); <ide> } <ide> <ide> ['@test it boots an engine, instantiates its application controller, and renders its application template'](assert) { <ide> moduleFor('{{mount}} test', class extends ApplicationTest { <ide> this.route('route-with-mount'); <ide> }); <ide> <del> this.registerTemplate('index', ''); <del> this.registerTemplate('route-with-mount', '{{mount "chat"}}'); <add> this.addTemplate('index', ''); <add> this.addTemplate('route-with-mount', '{{mount "chat"}}'); <ide> <ide> this.engineRegistrations['template:application'] = compile('hi {{person.name}} [{{component-with-backtracking-set person=person}}]', { moduleName: 'application' }); <ide> this.engineRegistrations['controller:application'] = Controller.extend({ <ide> moduleFor('{{mount}} test', class extends ApplicationTest { <ide> this.route('bound-engine-name'); <ide> }); <ide> let controller; <del> this.registerController('bound-engine-name', Controller.extend({ <add> this.add('controller:bound-engine-name', Controller.extend({ <ide> engineName: null, <ide> init() { <ide> this._super(); <ide> controller = this; <ide> } <ide> })); <del> this.registerTemplate('bound-engine-name', '{{mount engineName}}'); <add> this.addTemplate('bound-engine-name', '{{mount engineName}}'); <ide> <del> this.registerEngine('foo', Engine.extend({ <add> this.add('engine:foo', Engine.extend({ <ide> router: null, <ide> init() { <ide> this._super(...arguments); <ide> this.register('template:application', compile('<h2>Foo Engine</h2>', { moduleName: 'application' })); <ide> } <ide> })); <del> this.registerEngine('bar', Engine.extend({ <add> this.add('engine:bar', Engine.extend({ <ide> router: null, <ide> init() { <ide> this._super(...arguments); <ide><path>packages/ember/tests/routing/query_params_test.js <ide> moduleFor('Query Params - main', class extends QueryParamTestCase { <ide> let appModelCount = 0; <ide> let promiseResolve; <ide> <del> this.registerRoute('application', Route.extend({ <add> this.add('route:application', Route.extend({ <ide> queryParams: { <ide> appomg: { <ide> defaultValue: 'applol' <ide> moduleFor('Query Params - main', class extends QueryParamTestCase { <ide> <ide> let actionName = typeof loadingReturn !== 'undefined' ? 'loading' : 'ignore'; <ide> let indexModelCount = 0; <del> this.registerRoute('index', Route.extend({ <add> this.add('route:index', Route.extend({ <ide> queryParams: { <ide> omg: { <ide> refreshModel: true <ide> moduleFor('Query Params - main', class extends QueryParamTestCase { <ide> }); <ide> }); <ide> <del> this.registerRoute('parent.child', Route.extend({ <add> this.add('route:parent.child', Route.extend({ <ide> afterModel() { <ide> this.transitionTo('parent.sibling'); <ide> } <ide> moduleFor('Query Params - main', class extends QueryParamTestCase { <ide> ['@test Query params can map to different url keys configured on the controller'](assert) { <ide> assert.expect(6); <ide> <del> this.registerController('index', Controller.extend({ <add> this.add('controller:index', Controller.extend({ <ide> queryParams: [{ foo: 'other_foo', bar: { as: 'other_bar' } }], <ide> foo: 'FOO', <ide> bar: 'BAR' <ide> moduleFor('Query Params - main', class extends QueryParamTestCase { <ide> ['@test Routes have a private overridable serializeQueryParamKey hook'](assert) { <ide> assert.expect(2); <ide> <del> this.registerRoute('index', Route.extend({ <add> this.add('route:index', Route.extend({ <ide> serializeQueryParamKey: StringUtils.dasherize <ide> })); <ide> <ide> moduleFor('Query Params - main', class extends QueryParamTestCase { <ide> <ide> this.setSingleQPController('index'); <ide> <del> this.registerRoute('index', Route.extend({ <add> this.add('route:index', Route.extend({ <ide> model(params) { <ide> assert.deepEqual(params, { foo: 'bar' }); <ide> } <ide> moduleFor('Query Params - main', class extends QueryParamTestCase { <ide> <ide> this.setSingleQPController('index'); <ide> <del> this.registerRoute('index', Route.extend({ <add> this.add('route:index', Route.extend({ <ide> model(params) { <ide> assert.deepEqual(params, { foo: 'bar', id: 'baz' }); <ide> } <ide> moduleFor('Query Params - main', class extends QueryParamTestCase { <ide> <ide> this.setSingleQPController('index'); <ide> <del> this.registerRoute('index', Route.extend({ <add> this.add('route:index', Route.extend({ <ide> model(params) { <ide> assert.deepEqual(params, { foo: 'baz', id: 'boo' }); <ide> } <ide> moduleFor('Query Params - main', class extends QueryParamTestCase { <ide> this.route('about'); <ide> }); <ide> <del> this.registerTemplate('home', `<h3>{{link-to 'About' 'about' (query-params lol='wat') id='link-to-about'}}</h3>`); <del> this.registerTemplate('about', `<h3>{{link-to 'Home' 'home' (query-params foo='naw')}}</h3>`); <del> this.registerTemplate('cats.index', `<h3>{{link-to 'Cats' 'cats' (query-params name='domino') id='cats-link'}}</h3>`); <add> this.addTemplate('home', `<h3>{{link-to 'About' 'about' (query-params lol='wat') id='link-to-about'}}</h3>`); <add> this.addTemplate('about', `<h3>{{link-to 'Home' 'home' (query-params foo='naw')}}</h3>`); <add> this.addTemplate('cats.index', `<h3>{{link-to 'Cats' 'cats' (query-params name='domino') id='cats-link'}}</h3>`); <ide> <ide> let homeShouldBeCreated = false; <ide> let aboutShouldBeCreated = false; <ide> let catsIndexShouldBeCreated = false; <ide> <del> this.registerRoute('home', Route.extend({ <add> this.add('route:home', Route.extend({ <ide> setup() { <ide> homeShouldBeCreated = true; <ide> this._super(...arguments); <ide> moduleFor('Query Params - main', class extends QueryParamTestCase { <ide> } <ide> }); <ide> <del> this.registerRoute('about', Route.extend({ <add> this.add('route:about', Route.extend({ <ide> setup() { <ide> aboutShouldBeCreated = true; <ide> this._super(...arguments); <ide> moduleFor('Query Params - main', class extends QueryParamTestCase { <ide> } <ide> }); <ide> <del> this.registerRoute('cats.index', Route.extend({ <add> this.add('route:cats.index', Route.extend({ <ide> model() { <ide> return []; <ide> }, <ide> moduleFor('Query Params - main', class extends QueryParamTestCase { <ide> } <ide> })); <ide> <del> this.registerController('cats.index', Controller.extend({ <add> this.add('controller:cats.index', Controller.extend({ <ide> queryParams: ['breed', 'name'], <ide> breed: 'Golden', <ide> name: null, <ide> moduleFor('Query Params - main', class extends QueryParamTestCase { <ide> <ide> this.setSingleQPController('application'); <ide> <del> this.registerRoute('application', Route.extend({ <add> this.add('route:application', Route.extend({ <ide> setupController(controller) { <ide> assert.equal(controller.get('foo'), 'YEAH', 'controller\'s foo QP property set before setupController called'); <ide> } <ide> moduleFor('Query Params - main', class extends QueryParamTestCase { <ide> <ide> this.setSingleQPController('application', { faz: 'foo' }); <ide> <del> this.registerRoute('application', Route.extend({ <add> this.add('route:application', Route.extend({ <ide> setupController(controller) { <ide> assert.equal(controller.get('faz'), 'YEAH', 'controller\'s foo QP property set before setupController called'); <ide> } <ide> moduleFor('Query Params - main', class extends QueryParamTestCase { <ide> <ide> this.setSingleQPController('index'); <ide> <del> this.registerRoute('index', Route.extend({ <add> this.add('route:index', Route.extend({ <ide> model(params, transition) { <ide> assert.deepEqual(this.paramsFor('index'), { something: 'baz', foo: 'bar' }, 'could retrieve params for index'); <ide> } <ide> moduleFor('Query Params - main', class extends QueryParamTestCase { <ide> <ide> this.setSingleQPController('index'); <ide> <del> this.registerRoute('index', Route.extend({ <add> this.add('route:index', Route.extend({ <ide> model(params, transition) { <ide> assert.deepEqual(this.paramsFor('index'), { something: 'baz', foo: 'boo' }, 'could retrieve params for index'); <ide> } <ide> moduleFor('Query Params - main', class extends QueryParamTestCase { <ide> <ide> this.setSingleQPController('index', 'foo', false); <ide> <del> this.registerRoute('index', Route.extend({ <add> this.add('route:index', Route.extend({ <ide> model(params, transition) { <ide> assert.deepEqual(this.paramsFor('index'), { something: 'baz', foo: false }, 'could retrieve params for index'); <ide> } <ide> moduleFor('Query Params - main', class extends QueryParamTestCase { <ide> <ide> this.setSingleQPController('index', 'foo', true); <ide> <del> this.registerRoute('index', Route.extend({ <add> this.add('route:index', Route.extend({ <ide> model(params, transition) { <ide> assert.deepEqual(this.paramsFor('index'), { something: 'baz', foo: false }, 'could retrieve params for index'); <ide> } <ide> moduleFor('Query Params - main', class extends QueryParamTestCase { <ide> this.setSingleQPController('application', 'appomg', 'applol'); <ide> this.setSingleQPController('index', 'omg', 'lol'); <ide> <del> this.registerRoute('application', Route.extend({ <add> this.add('route:application', Route.extend({ <ide> model(params) { <ide> assert.deepEqual(params, { appomg: 'applol' }); <ide> } <ide> })); <ide> <del> this.registerRoute('index', Route.extend({ <add> this.add('route:index', Route.extend({ <ide> model(params) { <ide> assert.deepEqual(params, { omg: 'lol' }); <ide> assert.deepEqual(this.paramsFor('application'), { appomg: 'applol' }); <ide> moduleFor('Query Params - main', class extends QueryParamTestCase { <ide> this.setSingleQPController('application', 'appomg', 'applol'); <ide> this.setSingleQPController('index', 'omg', 'lol'); <ide> <del> this.registerRoute('application', Route.extend({ <add> this.add('route:application', Route.extend({ <ide> model(params) { <ide> assert.deepEqual(params, { appomg: 'appyes' }); <ide> } <ide> })); <ide> <del> this.registerRoute('index', Route.extend({ <add> this.add('route:index', Route.extend({ <ide> model(params) { <ide> assert.deepEqual(params, { omg: 'yes' }); <ide> assert.deepEqual(this.paramsFor('application'), { appomg: 'appyes' }); <ide> moduleFor('Query Params - main', class extends QueryParamTestCase { <ide> this.setSingleQPController('index', 'omg', 'lol'); <ide> <ide> let appModelCount = 0; <del> this.registerRoute('application', Route.extend({ <add> this.add('route:application', Route.extend({ <ide> model(params) { <ide> appModelCount++; <ide> } <ide> })); <ide> <ide> let indexModelCount = 0; <del> this.registerRoute('index', Route.extend({ <add> this.add('route:index', Route.extend({ <ide> queryParams: { <ide> omg: { <ide> refreshModel: true <ide> moduleFor('Query Params - main', class extends QueryParamTestCase { <ide> this.setSingleQPController('index', 'steely', 'lel'); <ide> <ide> let refreshCount = 0; <del> this.registerRoute('index', Route.extend({ <add> this.add('route:index', Route.extend({ <ide> queryParams: { <ide> alex: { <ide> refreshModel: true <ide> moduleFor('Query Params - main', class extends QueryParamTestCase { <ide> this.setSingleQPController('application', 'appomg', 'applol'); <ide> this.setSingleQPController('index', 'omg', 'lol'); <ide> <del> this.registerRoute('index', Route.extend({ <add> this.add('route:index', Route.extend({ <ide> queryParams: { <ide> omg: { <ide> refreshModel: true <ide> moduleFor('Query Params - main', class extends QueryParamTestCase { <ide> } <ide> <ide> ['@test queryParams are updated when a controller property is set and the route is refreshed. Issue #13263 '](assert) { <del> this.registerTemplate('application', '<button id="test-button" {{action \'increment\'}}>Increment</button><span id="test-value">{{foo}}</span>{{outlet}}'); <add> this.addTemplate('application', '<button id="test-button" {{action \'increment\'}}>Increment</button><span id="test-value">{{foo}}</span>{{outlet}}'); <ide> <ide> this.setSingleQPController('application', 'foo', 1, { <ide> actions: { <ide> moduleFor('Query Params - main', class extends QueryParamTestCase { <ide> } <ide> }); <ide> <del> this.registerRoute('application', Route.extend({ <add> this.add('route:application', Route.extend({ <ide> actions: { <ide> refreshRoute() { <ide> this.refresh(); <ide> moduleFor('Query Params - main', class extends QueryParamTestCase { <ide> this.setSingleQPController('index', 'omg', 'lol'); <ide> <ide> let appModelCount = 0; <del> this.registerRoute('application', Route.extend({ <add> this.add('route:application', Route.extend({ <ide> model(params) { <ide> appModelCount++; <ide> } <ide> })); <ide> <ide> let indexModelCount = 0; <del> this.registerRoute('index', Route.extend({ <add> this.add('route:index', Route.extend({ <ide> queryParams: EmberObject.create({ <ide> unknownProperty(keyName) { <ide> return { refreshModel: true }; <ide> moduleFor('Query Params - main', class extends QueryParamTestCase { <ide> this.setSingleQPController('index', 'omg', 'lol'); <ide> <ide> let indexModelCount = 0; <del> this.registerRoute('index', Route.extend({ <add> this.add('route:index', Route.extend({ <ide> queryParams: { <ide> omg: { <ide> refreshModel: true <ide> moduleFor('Query Params - main', class extends QueryParamTestCase { <ide> <ide> this.setSingleQPController('application', 'alex', 'matchneer'); <ide> <del> this.registerRoute('application', Route.extend({ <add> this.add('route:application', Route.extend({ <ide> queryParams: { <ide> alex: { <ide> replace: true <ide> moduleFor('Query Params - main', class extends QueryParamTestCase { <ide> ['@test Route query params config can be configured using property name instead of URL key'](assert) { <ide> assert.expect(2); <ide> <del> this.registerController('application', Controller.extend({ <add> this.add('controller:application', Controller.extend({ <ide> queryParams: [{ commitBy: 'commit_by' }] <ide> })); <ide> <del> this.registerRoute('application', Route.extend({ <add> this.add('route:application', Route.extend({ <ide> queryParams: { <ide> commitBy: { <ide> replace: true <ide> moduleFor('Query Params - main', class extends QueryParamTestCase { <ide> ['@test An explicit replace:false on a changed QP always wins and causes a pushState'](assert) { <ide> assert.expect(3); <ide> <del> this.registerController('application', Controller.extend({ <add> this.add('controller:application', Controller.extend({ <ide> queryParams: ['alex', 'steely'], <ide> alex: 'matchneer', <ide> steely: 'dan' <ide> })); <ide> <del> this.registerRoute('application', Route.extend({ <add> this.add('route:application', Route.extend({ <ide> queryParams: { <ide> alex: { <ide> replace: true <ide> moduleFor('Query Params - main', class extends QueryParamTestCase { <ide> } <ide> <ide> ['@test can opt into full transition by setting refreshModel in route queryParams when transitioning from child to parent'](assert) { <del> this.registerTemplate('parent', '{{outlet}}'); <del> this.registerTemplate('parent.child', '{{link-to \'Parent\' \'parent\' (query-params foo=\'change\') id=\'parent-link\'}}'); <add> this.addTemplate('parent', '{{outlet}}'); <add> this.addTemplate('parent.child', '{{link-to \'Parent\' \'parent\' (query-params foo=\'change\') id=\'parent-link\'}}'); <ide> <ide> this.router.map(function() { <ide> this.route('parent', function() { <ide> moduleFor('Query Params - main', class extends QueryParamTestCase { <ide> }); <ide> <ide> let parentModelCount = 0; <del> this.registerRoute('parent', Route.extend({ <add> this.add('route:parent', Route.extend({ <ide> model() { <ide> parentModelCount++; <ide> }, <ide> moduleFor('Query Params - main', class extends QueryParamTestCase { <ide> <ide> this.setSingleQPController('application', 'alex', 'matchneer'); <ide> <del> this.registerRoute('application', Route.extend({ <add> this.add('route:application', Route.extend({ <ide> queryParams: EmberObject.create({ <ide> unknownProperty(keyName) { <ide> // We are simulating all qps requiring refresh <ide> moduleFor('Query Params - main', class extends QueryParamTestCase { <ide> <ide> this.setSingleQPController('index', 'omg', 'lol'); <ide> <del> this.registerRoute('index', Route.extend({ <add> this.add('route:index', Route.extend({ <ide> setupController(controller) { <ide> assert.ok(true, 'setupController called'); <ide> controller.set('omg', 'OVERRIDE'); <ide> moduleFor('Query Params - main', class extends QueryParamTestCase { <ide> <ide> this.setSingleQPController('index', 'omg', ['lol']); <ide> <del> this.registerRoute('index', Route.extend({ <add> this.add('route:index', Route.extend({ <ide> setupController(controller) { <ide> assert.ok(true, 'setupController called'); <ide> controller.set('omg', ['OVERRIDE']); <ide> moduleFor('Query Params - main', class extends QueryParamTestCase { <ide> }); <ide> }); <ide> <del> this.registerTemplate('application', '{{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> this.addTemplate('application', '{{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}}'); <ide> <ide> this.setSingleQPController('abc.def', 'foo', 'lol'); <ide> this.setSingleQPController('abc.def.zoo', 'bar', 'haha'); <ide> moduleFor('Query Params - main', class extends QueryParamTestCase { <ide> } <ide> <ide> ['@test transitionTo supports query params (multiple)'](assert) { <del> this.registerController('index', Controller.extend({ <add> this.add('controller:index', Controller.extend({ <ide> queryParams: ['foo', 'bar'], <ide> foo: 'lol', <ide> bar: 'wat' <ide> moduleFor('Query Params - main', class extends QueryParamTestCase { <ide> ['@test setting QP to empty string doesn\'t generate null in URL'](assert) { <ide> assert.expect(1); <ide> <del> this.registerRoute('index', Route.extend({ <add> this.add('route:index', Route.extend({ <ide> queryParams: { <ide> foo: { <ide> defaultValue: '123' <ide> moduleFor('Query Params - main', class extends QueryParamTestCase { <ide> <ide> this.setSingleQPController('index', 'foo', false); <ide> <del> this.registerRoute('index', Route.extend({ <add> this.add('route:index', Route.extend({ <ide> model(params) { <ide> assert.equal(params.foo, true, 'model hook received foo as boolean true'); <ide> } <ide> moduleFor('Query Params - main', class extends QueryParamTestCase { <ide> ['@test Query param without value are empty string'](assert) { <ide> assert.expect(1); <ide> <del> this.registerController('index', Controller.extend({ <add> this.add('controller:index', Controller.extend({ <ide> queryParams: ['foo'], <ide> foo: '' <ide> })); <ide> moduleFor('Query Params - main', class extends QueryParamTestCase { <ide> }); <ide> <ide> let modelCount = 0; <del> this.registerRoute('home', Route.extend({ <add> this.add('route:home', Route.extend({ <ide> model() { <ide> modelCount++; <ide> } <ide> moduleFor('Query Params - main', class extends QueryParamTestCase { <ide> // unless we return a copy of the params hash. <ide> this.setSingleQPController('application', 'woot', 'wat'); <ide> <del> this.registerRoute('other', Route.extend({ <add> this.add('route:other', Route.extend({ <ide> model(p, trans) { <ide> let m = meta(trans.params.application); <ide> assert.ok(!m.peekWatching('woot'), 'A meta object isn\'t constructed for this params POJO'); <ide> moduleFor('Query Params - main', class extends QueryParamTestCase { <ide> woot: undefined <ide> }); <ide> <del> this.registerRoute('application', Route.extend({ <add> this.add('route:application', Route.extend({ <ide> model(p, trans) { <ide> return { woot: true }; <ide> } <ide> })); <ide> <del> this.registerRoute('index', Route.extend({ <add> this.add('route:index', Route.extend({ <ide> setupController(controller, model) { <ide> assert.deepEqual(model, { woot: true }, 'index route inherited model route from parent route'); <ide> } <ide> moduleFor('Query Params - main', class extends QueryParamTestCase { <ide> ['@test opting into replace does not affect transitions between routes'](assert) { <ide> assert.expect(5); <ide> <del> this.registerTemplate('application', '{{link-to \'Foo\' \'foo\' id=\'foo-link\'}}{{link-to \'Bar\' \'bar\' id=\'bar-no-qp-link\'}}{{link-to \'Bar\' \'bar\' (query-params raytiley=\'isthebest\') id=\'bar-link\'}}{{outlet}}'); <add> this.addTemplate('application', '{{link-to \'Foo\' \'foo\' id=\'foo-link\'}}{{link-to \'Bar\' \'bar\' id=\'bar-no-qp-link\'}}{{link-to \'Bar\' \'bar\' (query-params raytiley=\'isthebest\') id=\'bar-link\'}}{{outlet}}'); <ide> <ide> this.router.map(function() { <ide> this.route('foo'); <ide> moduleFor('Query Params - main', class extends QueryParamTestCase { <ide> <ide> this.setSingleQPController('bar', 'raytiley', 'israd'); <ide> <del> this.registerRoute('bar', Route.extend({ <add> this.add('route:bar', Route.extend({ <ide> queryParams: { <ide> raytiley: { <ide> replace: true <ide> moduleFor('Query Params - main', class extends QueryParamTestCase { <ide> this.route('example'); <ide> }); <ide> <del> this.registerTemplate('application', '{{link-to \'Example\' \'example\' (query-params foo=undefined) id=\'the-link\'}}'); <add> this.addTemplate('application', '{{link-to \'Example\' \'example\' (query-params foo=undefined) id=\'the-link\'}}'); <ide> <ide> this.setSingleQPController('example', 'foo', undefined, { <ide> foo: undefined <ide> }); <ide> <del> this.registerRoute('example', Route.extend({ <add> this.add('route:example', Route.extend({ <ide> model(params) { <ide> assert.deepEqual(params, { foo: undefined }); <ide> } <ide> moduleFor('Query Params - main', class extends QueryParamTestCase { <ide> ['@test warn user that Route\'s queryParams configuration must be an Object, not an Array'](assert) { <ide> assert.expect(1); <ide> <del> this.registerRoute('application', Route.extend({ <add> this.add('route:application', Route.extend({ <ide> queryParams: [ <ide> { commitBy: { replace: true } } <ide> ] <ide> moduleFor('Query Params - main', class extends QueryParamTestCase { <ide> this.route('constructor'); <ide> }); <ide> <del> this.registerRoute('constructor', Route.extend({ <add> this.add('route:constructor', Route.extend({ <ide> queryParams: { <ide> foo: { <ide> defaultValue: '123' <ide><path>packages/ember/tests/routing/query_params_test/model_dependent_state_with_query_params_test.js <ide> class ModelDependentQPTestCase extends QueryParamTestCase { <ide> <ide> assert.expect(32); <ide> <del> this.registerTemplate('application', `{{#each articles as |a|}} {{link-to 'Article' '${articleLookup}' a.id id=a.id}} {{/each}}`); <add> this.addTemplate('application', `{{#each articles as |a|}} {{link-to 'Article' '${articleLookup}' a.id id=a.id}} {{/each}}`); <ide> <ide> return this.boot().then(() => { <ide> this.expectedModelHookParams = { id: 'a-1', q: 'wat', z: 0 }; <ide> class ModelDependentQPTestCase extends QueryParamTestCase { <ide> } <ide> }); <ide> <del> this.registerTemplate('about', `{{link-to 'A' '${commentsLookup}' 'a-1' id='one'}} {{link-to 'B' '${commentsLookup}' 'a-2' id='two'}}`); <add> this.addTemplate('about', `{{link-to 'A' '${commentsLookup}' 'a-1' id='one'}} {{link-to 'B' '${commentsLookup}' 'a-2' id='two'}}`); <ide> <ide> return this.visitApplication().then(() => { <ide> this.transitionTo(commentsLookup, 'a-1'); <ide> moduleFor('Query Params - model-dependent state', class extends ModelDependentQP <ide> <ide> let articles = emberA([{ id: 'a-1' }, { id: 'a-2' }, { id: 'a-3' }]); <ide> <del> this.registerController('application', Controller.extend({ <add> this.add('controller:application', Controller.extend({ <ide> articles <ide> })); <ide> <ide> let self = this; <ide> let assert = this.assert; <del> this.registerRoute('article', Route.extend({ <add> this.add('route:article', Route.extend({ <ide> model(params) { <ide> if (self.expectedModelHookParams) { <ide> assert.deepEqual(params, self.expectedModelHookParams, 'the ArticleRoute model hook received the expected merged dynamic segment + query params hash'); <ide> moduleFor('Query Params - model-dependent state', class extends ModelDependentQP <ide> } <ide> })); <ide> <del> this.registerController('article', Controller.extend({ <add> this.add('controller:article', Controller.extend({ <ide> queryParams: ['q', 'z'], <ide> q: 'wat', <ide> z: 0 <ide> })); <ide> <del> this.registerController('comments', Controller.extend({ <add> this.add('controller:comments', Controller.extend({ <ide> queryParams: 'page', <ide> page: 1 <ide> })); <ide> <del> this.registerTemplate('application', '{{#each articles as |a|}} 1{{link-to \'Article\' \'article\' a id=a.id}} {{/each}} {{outlet}}'); <add> this.addTemplate('application', '{{#each articles as |a|}} 1{{link-to \'Article\' \'article\' a id=a.id}} {{/each}} {{outlet}}'); <ide> } <ide> <ide> visitApplication() { <ide> moduleFor('Query Params - model-dependent state (nested)', class extends ModelDe <ide> <ide> let site_articles = emberA([{ id: 'a-1' }, { id: 'a-2' }, { id: 'a-3' }]); <ide> <del> this.registerController('application', Controller.extend({ <add> this.add('controller:application', Controller.extend({ <ide> articles: site_articles <ide> })); <ide> <ide> let self = this; <ide> let assert = this.assert; <del> this.registerRoute('site.article', Route.extend({ <add> this.add('route:site.article', Route.extend({ <ide> model(params) { <ide> if (self.expectedModelHookParams) { <ide> assert.deepEqual(params, self.expectedModelHookParams, 'the ArticleRoute model hook received the expected merged dynamic segment + query params hash'); <ide> moduleFor('Query Params - model-dependent state (nested)', class extends ModelDe <ide> } <ide> })); <ide> <del> this.registerController('site.article', Controller.extend({ <add> this.add('controller:site.article', Controller.extend({ <ide> queryParams: ['q', 'z'], <ide> q: 'wat', <ide> z: 0 <ide> })); <ide> <del> this.registerController('site.article.comments', Controller.extend({ <add> this.add('controller:site.article.comments', Controller.extend({ <ide> queryParams: 'page', <ide> page: 1 <ide> })); <ide> <del> this.registerTemplate('application', '{{#each articles as |a|}} {{link-to \'Article\' \'site.article\' a id=a.id}} {{/each}} {{outlet}}'); <add> this.addTemplate('application', '{{#each articles as |a|}} {{link-to \'Article\' \'site.article\' a id=a.id}} {{/each}} {{outlet}}'); <ide> } <ide> <ide> visitApplication() { <ide> moduleFor('Query Params - model-dependent state (nested & more than 1 dynamic se <ide> let sites = emberA([{ id: 's-1' }, { id: 's-2' }, { id: 's-3' }]); <ide> let site_articles = emberA([{ id: 'a-1' }, { id: 'a-2' }, { id: 'a-3' }]); <ide> <del> this.registerController('application', Controller.extend({ <add> this.add('controller:application', Controller.extend({ <ide> siteArticles: site_articles, <ide> sites, <ide> allSitesAllArticles: computed({ <ide> moduleFor('Query Params - model-dependent state (nested & more than 1 dynamic se <ide> <ide> let self = this; <ide> let assert = this.assert; <del> this.registerRoute('site', Route.extend({ <add> this.add('route:site', Route.extend({ <ide> model(params) { <ide> if (self.expectedSiteModelHookParams) { <ide> assert.deepEqual(params, self.expectedSiteModelHookParams, 'the SiteRoute model hook received the expected merged dynamic segment + query params hash'); <ide> moduleFor('Query Params - model-dependent state (nested & more than 1 dynamic se <ide> } <ide> })); <ide> <del> this.registerRoute('site.article', Route.extend({ <add> this.add('route:site.article', Route.extend({ <ide> model(params) { <ide> if (self.expectedArticleModelHookParams) { <ide> assert.deepEqual(params, self.expectedArticleModelHookParams, 'the SiteArticleRoute model hook received the expected merged dynamic segment + query params hash'); <ide> moduleFor('Query Params - model-dependent state (nested & more than 1 dynamic se <ide> } <ide> })); <ide> <del> this.registerController('site', Controller.extend({ <add> this.add('controller:site', Controller.extend({ <ide> queryParams: ['country'], <ide> country: 'au' <ide> })); <ide> <del> this.registerController('site.article', Controller.extend({ <add> this.add('controller:site.article', Controller.extend({ <ide> queryParams: ['q', 'z'], <ide> q: 'wat', <ide> z: 0 <ide> })); <ide> <del> this.registerController('site.article.comments', Controller.extend({ <add> this.add('controller:site.article.comments', Controller.extend({ <ide> queryParams: ['page'], <ide> page: 1 <ide> })); <ide> <del> this.registerTemplate('application', '{{#each allSitesAllArticles as |a|}} {{#link-to \'site.article\' a.site_id a.article_id id=a.id}}Article [{{a.site_id}}] [{{a.article_id}}]{{/link-to}} {{/each}} {{outlet}}'); <add> this.addTemplate('application', '{{#each allSitesAllArticles as |a|}} {{#link-to \'site.article\' a.site_id a.article_id id=a.id}}Article [{{a.site_id}}] [{{a.article_id}}]{{/link-to}} {{/each}} {{outlet}}'); <ide> } <ide> <ide> visitApplication() { <ide><path>packages/ember/tests/routing/query_params_test/overlapping_query_params_test.js <ide> moduleFor('Query Params - overlapping query param property names', class extends <ide> let parentController = Controller.extend({ <ide> queryParams: { page: 'page' } <ide> }); <del> this.registerController('parent', parentController); <del> this.registerRoute('parent.child', Route.extend({controllerName: 'parent'})); <add> this.add('controller:parent', parentController); <add> this.add('route:parent.child', Route.extend({controllerName: 'parent'})); <ide> <ide> return this.setupBase('/parent').then(() => { <ide> this.transitionTo('parent.child', { queryParams: { page: 2 } }); <ide> moduleFor('Query Params - overlapping query param property names', class extends <ide> page: 1 <ide> }); <ide> <del> this.registerController('parent', Controller.extend(HasPage, { <add> this.add('controller:parent', Controller.extend(HasPage, { <ide> queryParams: { page: 'yespage' } <ide> })); <ide> <del> this.registerController('parent.child', Controller.extend(HasPage)); <add> this.add('controller:parent.child', Controller.extend(HasPage)); <ide> <ide> return this.setupBase().then(() => { <ide> this.assertCurrentPath('/parent/child'); <ide><path>packages/ember/tests/routing/query_params_test/query_param_async_get_handler_test.js <ide> moduleFor('Query Params - async get handler', class extends QueryParamTestCase { <ide> this.setSingleQPController('post'); <ide> <ide> let setupAppTemplate = () => { <del> this.registerTemplate('application', ` <add> this.addTemplate('application', ` <ide> {{link-to 'Post' 'post' 1337 (query-params foo='bar') class='post-link'}} <ide> {{link-to 'Post' 'post' 7331 (query-params foo='boo') class='post-link'}} <ide> {{outlet}} <ide> moduleFor('Query Params - async get handler', class extends QueryParamTestCase { <ide> this.route('example'); <ide> }); <ide> <del> this.registerTemplate('application', '{{link-to \'Example\' \'example\' (query-params foo=undefined) id=\'the-link\'}}'); <add> this.addTemplate('application', '{{link-to \'Example\' \'example\' (query-params foo=undefined) id=\'the-link\'}}'); <ide> <ide> this.setSingleQPController('example', 'foo', undefined, { <ide> foo: undefined <ide> }); <ide> <del> this.registerRoute('example', Route.extend({ <add> this.add('route:example', Route.extend({ <ide> model(params) { <ide> assert.deepEqual(params, { foo: undefined }); <ide> } <ide><path>packages/ember/tests/routing/query_params_test/query_params_paramless_link_to_test.js <ide> moduleFor('Query Params - paramless link-to', class extends QueryParamTestCase { <ide> testParamlessLinks(assert, routeName) { <ide> assert.expect(1); <ide> <del> this.registerTemplate(routeName, '{{link-to \'index\' \'index\' id=\'index-link\'}}'); <add> this.addTemplate(routeName, '{{link-to \'index\' \'index\' id=\'index-link\'}}'); <ide> <del> this.registerController(routeName, Controller.extend({ <add> this.add(`controller:${routeName}`, Controller.extend({ <ide> queryParams: ['foo'], <ide> foo: 'wat' <ide> })); <ide><path>packages/ember/tests/routing/query_params_test/shared_state_test.js <ide> moduleFor('Query Params - shared service state', class extends QueryParamTestCas <ide> this.route('dashboard'); <ide> }); <ide> <del> this.application.register('service:filters', Service.extend({ <add> this.add('service:filters', Service.extend({ <ide> shared: true <ide> })); <ide> <del> this.registerController('home', Controller.extend({ <add> this.add('controller:home', Controller.extend({ <ide> filters: Ember.inject.service() <ide> })); <ide> <del> this.registerController('dashboard', Controller.extend({ <add> this.add('controller:dashboard', Controller.extend({ <ide> filters: Ember.inject.service(), <ide> queryParams: [ <ide> { 'filters.shared': 'shared' } <ide> ] <ide> })); <ide> <del> this.registerTemplate('application', `{{link-to 'Home' 'home' }} <div> {{outlet}} </div>`); <del> this.registerTemplate('home', `{{link-to 'Dashboard' 'dashboard' }}{{input type="checkbox" id='filters-checkbox' checked=(mut filters.shared) }}`); <del> this.registerTemplate('dashboard', `{{link-to 'Home' 'home' }}`); <add> this.addTemplate('application', `{{link-to 'Home' 'home' }} <div> {{outlet}} </div>`); <add> this.addTemplate('home', `{{link-to 'Dashboard' 'dashboard' }}{{input type="checkbox" id='filters-checkbox' checked=(mut filters.shared) }}`); <add> this.addTemplate('dashboard', `{{link-to 'Home' 'home' }}`); <ide> } <ide> visitApplication() { <ide> return this.visit('/'); <ide><path>packages/ember/tests/routing/router_service_test/basic_test.js <ide> if (isFeatureEnabled('ember-routing-router-service')) { <ide> ['@test RouterService#rootURL is correctly set to a custom value'](assert) { <ide> assert.expect(1); <ide> <del> this.registerRoute('parent.index', Route.extend({ <add> this.add('route:parent.index', Route.extend({ <ide> init() { <ide> this._super(); <ide> set(this.router, 'rootURL', '/homepage'); <ide><path>packages/ember/tests/routing/router_service_test/currenturl_lifecycle_test.js <ide> if (isFeatureEnabled('ember-routing-router-service')) { <ide> <ide> ROUTE_NAMES.forEach((name) => { <ide> let routeName = `parent.${name}`; <del> this.registerRoute(routeName, InstrumentedRoute.extend()); <del> this.registerTemplate(routeName, '{{current-url}}'); <add> this.add(`route:${routeName}`, InstrumentedRoute.extend()); <add> this.addTemplate(routeName, '{{current-url}}'); <ide> }); <ide> <del> this.registerComponent('current-url', { <add> this.addComponent('current-url', { <ide> ComponentClass: Component.extend({ <ide> routerService: inject.service('router'), <ide> currentURL: readOnly('routerService.currentURL') <ide><path>packages/ember/tests/routing/router_service_test/replaceWith_test.js <ide> if (isFeatureEnabled('ember-routing-router-service')) { <ide> let testCase = this; <ide> testCase.state = []; <ide> <del> this.application.register('location:test', NoneLocation.extend({ <add> this.add('location:test', NoneLocation.extend({ <ide> setURL(path) { <ide> testCase.state.push(path); <ide> this.set('path', path); <ide><path>packages/ember/tests/routing/router_service_test/transitionTo_test.js <ide> if (isFeatureEnabled('ember-routing-router-service')) { <ide> let testCase = this; <ide> testCase.state = []; <ide> <del> this.application.register('location:test', NoneLocation.extend({ <add> this.add('location:test', NoneLocation.extend({ <ide> setURL(path) { <ide> testCase.state.push(path); <ide> this.set('path', path); <ide> if (isFeatureEnabled('ember-routing-router-service')) { <ide> <ide> let componentInstance; <ide> <del> this.registerTemplate('parent.index', '{{foo-bar}}'); <add> this.addTemplate('parent.index', '{{foo-bar}}'); <ide> <del> this.registerComponent('foo-bar', { <add> this.addComponent('foo-bar', { <ide> ComponentClass: Component.extend({ <ide> routerService: inject.service('router'), <ide> init() { <ide> if (isFeatureEnabled('ember-routing-router-service')) { <ide> <ide> let componentInstance; <ide> <del> this.registerTemplate('parent.index', '{{foo-bar}}'); <add> this.addTemplate('parent.index', '{{foo-bar}}'); <ide> <del> this.registerComponent('foo-bar', { <add> this.addComponent('foo-bar', { <ide> ComponentClass: Component.extend({ <ide> routerService: inject.service('router'), <ide> init() { <ide> if (isFeatureEnabled('ember-routing-router-service')) { <ide> let componentInstance; <ide> let dynamicModel = { id: 1, contents: 'much dynamicism' }; <ide> <del> this.registerTemplate('parent.index', '{{foo-bar}}'); <del> this.registerTemplate('dynamic', '{{model.contents}}'); <add> this.addTemplate('parent.index', '{{foo-bar}}'); <add> this.addTemplate('dynamic', '{{model.contents}}'); <ide> <del> this.registerComponent('foo-bar', { <add> this.addComponent('foo-bar', { <ide> ComponentClass: Component.extend({ <ide> routerService: inject.service('router'), <ide> init() { <ide> if (isFeatureEnabled('ember-routing-router-service')) { <ide> let componentInstance; <ide> let dynamicModel = { id: 1, contents: 'much dynamicism' }; <ide> <del> this.registerRoute('dynamic', Route.extend({ <add> this.add('route:dynamic', Route.extend({ <ide> model() { <ide> return dynamicModel; <ide> } <ide> })); <ide> <del> this.registerTemplate('parent.index', '{{foo-bar}}'); <del> this.registerTemplate('dynamic', '{{model.contents}}'); <add> this.addTemplate('parent.index', '{{foo-bar}}'); <add> this.addTemplate('dynamic', '{{model.contents}}'); <ide> <del> this.registerComponent('foo-bar', { <add> this.addComponent('foo-bar', { <ide> ComponentClass: Component.extend({ <ide> routerService: inject.service('router'), <ide> init() { <ide><path>packages/ember/tests/routing/router_service_test/urlFor_test.js <ide> if (isFeatureEnabled('ember-routing-router-service')) { <ide> let expectedURL; <ide> let dynamicModel = { id: 1 }; <ide> <del> this.registerRoute('dynamic', Route.extend({ <add> this.add('route:dynamic', Route.extend({ <ide> model() { <ide> return dynamicModel; <ide> } <ide> if (isFeatureEnabled('ember-routing-router-service')) { <ide> let queryParams = buildQueryParams({ foo: 'bar' }); <ide> let dynamicModel = { id: 1 }; <ide> <del> this.registerRoute('dynamic', Route.extend({ <add> this.add('route:dynamic', Route.extend({ <ide> model() { <ide> return dynamicModel; <ide> } <ide><path>packages/internal-test-helpers/lib/test-cases/abstract-application.js <ide> import { Router } from 'ember-routing'; <ide> import { compile } from 'ember-template-compiler'; <ide> <ide> import AbstractTestCase from './abstract'; <add>import { ModuleBasedResolver } from '../test-resolver'; <ide> import { runDestroy } from '../run'; <ide> <ide> export default class AbstractApplicationTestCase extends AbstractTestCase { <ide> export default class AbstractApplicationTestCase extends AbstractTestCase { <ide> <ide> this.element = jQuery('#qunit-fixture')[0]; <ide> <del> this.application = run(Application, 'create', this.applicationOptions); <add> let { applicationOptions } = this; <add> this.application = run(Application, 'create', applicationOptions); <ide> <del> this.router = this.application.Router = Router.extend(this.routerOptions); <add> this.resolver = applicationOptions.Resolver.lastInstance; <add> <add> this.add('router:main', Router.extend(this.routerOptions)); <ide> <ide> this.applicationInstance = null; <ide> } <ide> <ide> get applicationOptions() { <ide> return { <ide> rootElement: '#qunit-fixture', <del> autoboot: false <add> autoboot: false, <add> Resolver: ModuleBasedResolver <ide> }; <ide> } <ide> <ide> export default class AbstractApplicationTestCase extends AbstractTestCase { <ide> }; <ide> } <ide> <add> get router() { <add> return this.application.resolveRegistration('router:main'); <add> } <add> <ide> get appRouter() { <ide> return this.applicationInstance.lookup('router:main'); <ide> } <ide> <ide> teardown() { <del> if (this.applicationInstance) { <del> runDestroy(this.applicationInstance); <del> } <del> <add> runDestroy(this.applicationInstance); <ide> runDestroy(this.application); <ide> } <ide> <ide> export default class AbstractApplicationTestCase extends AbstractTestCase { <ide> return compile(...arguments); <ide> } <ide> <del> registerRoute(name, route) { <del> this.application.register(`route:${name}`, route); <add> add(specifier, factory) { <add> this.resolver.add(specifier, factory); <ide> } <ide> <del> registerTemplate(name, template) { <del> this.application.register(`template:${name}`, this.compile(template, { <del> moduleName: name <add> addTemplate(templateName, templateString) { <add> this.resolver.add(`template:${templateName}`, this.compile(templateString, { <add> moduleName: templateName <ide> })); <ide> } <ide> <del> registerComponent(name, { ComponentClass = null, template = null }) { <add> addComponent(name, { ComponentClass = null, template = null }) { <ide> if (ComponentClass) { <del> this.application.register(`component:${name}`, ComponentClass); <add> this.resolver.add(`component:${name}`, ComponentClass); <ide> } <ide> <ide> if (typeof template === 'string') { <del> this.application.register(`template:components/${name}`, this.compile(template, { <add> this.resolver.add(`template:components/${name}`, this.compile(template, { <ide> moduleName: `components/${name}` <ide> })); <ide> } <ide> } <ide> <del> registerController(name, controller) { <del> this.application.register(`controller:${name}`, controller); <del> } <del> <del> registerEngine(name, engine) { <del> this.application.register(`engine:${name}`, engine); <del> } <ide> } <ide><path>packages/internal-test-helpers/lib/test-cases/query-param.js <ide> export default class QueryParamTestCase extends ApplicationTestCase { <ide> let testCase = this; <ide> testCase.expectedPushURL = null; <ide> testCase.expectedReplaceURL = null; <del> this.application.register('location:test', NoneLocation.extend({ <add> this.add('location:test', NoneLocation.extend({ <ide> setURL(path) { <ide> if (testCase.expectedReplaceURL) { <ide> testCase.assert.ok(false, 'pushState occurred but a replaceState was expected'); <ide> export default class QueryParamTestCase extends ApplicationTestCase { <ide> @method setSingleQPController <ide> */ <ide> setSingleQPController(routeName, param = 'foo', defaultValue = 'bar', options = {}) { <del> this.registerController(routeName, Controller.extend({ <add> this.add(`controller:${routeName}`, Controller.extend({ <ide> queryParams: [param], <ide> [param]: defaultValue <ide> }, options)); <ide> export default class QueryParamTestCase extends ApplicationTestCase { <ide> @method setMappedQPController <ide> */ <ide> setMappedQPController(routeName, prop = 'page', urlKey = 'parentPage', defaultValue = 1, options = {}) { <del> this.registerController(routeName, Controller.extend({ <add> this.add(`controller:${routeName}`, Controller.extend({ <ide> queryParams: { <ide> [prop]: urlKey <ide> }, <ide><path>packages/internal-test-helpers/lib/test-resolver.js <ide> class Resolver { <ide> return this._registered[specifier]; <ide> } <ide> add(specifier, factory) { <add> if (specifier.indexOf(':') === -1) { <add> throw new Error('Specifiers added to the resolver must be in the format of type:name'); <add> } <ide> return this._registered[specifier] = factory; <ide> } <ide> addTemplate(templateName, template) {
22
Text
Text
fix relative links in website readme.md
838284c254948e599ec750a434805db288a2aedd
<ide><path>website/README.md <ide> The docs can always use another example or more detail, and they should always b <ide> <ide> While all page content lives in the `.jade` files, article meta (page titles, sidebars etc.) is stored as JSON. Each folder contains a `_data.json` with all required meta for its files. <ide> <del>For simplicity, all sites linked in the [tutorials](https://spacy.io/docs/usage/tutorials) and [showcase](https://spacy.io/docs/usage/showcase) are also stored as JSON. So in order to edit those pages, there's no need to dig into the Jade files – simply edit the [`_data.json`](website/docs/usage/_data.json). <add>For simplicity, all sites linked in the [tutorials](https://spacy.io/docs/usage/tutorials) and [showcase](https://spacy.io/docs/usage/showcase) are also stored as JSON. So in order to edit those pages, there's no need to dig into the Jade files – simply edit the [`_data.json`](docs/usage/_data.json). <ide> <ide> ### Markup language and conventions <ide> <ide> Note that for external links, `+a("...")` is used instead of `a(href="...")` – <ide> <ide> ### Mixins <ide> <del>Each file includes a collection of [custom mixins](website/_includes/_mixins.jade) that make it easier to add content components – no HTML or class names required. <add>Each file includes a collection of [custom mixins](_includes/_mixins.jade) that make it easier to add content components – no HTML or class names required. <ide> <ide> For example: <ide> ```pug <ide> Code blocks are implemented using the `+code` or `+aside-code` (to display them <ide> en_doc = en_nlp(u'Hello, world. Here are two sentences.') <ide> ``` <ide> <del>You can find the documentation for the available mixins in [`_includes/_mixins.jade`](website/_includes/_mixins.jade). <add>You can find the documentation for the available mixins in [`_includes/_mixins.jade`](_includes/_mixins.jade). <ide> <ide> ### Linking to the Github repo <ide>
1
Javascript
Javascript
remove unused focusedopacity prop and function
85247f99864b890fb96b8356947abd2feb6c42ff
<ide><path>Libraries/Components/Touchable/TouchableOpacity.js <ide> var TouchableOpacity = createReactClass({ <ide> * active. Defaults to 0.2. <ide> */ <ide> activeOpacity: PropTypes.number, <del> focusedOpacity: PropTypes.number, <ide> /** <ide> * Apple TV parallax effects <ide> */ <ide> var TouchableOpacity = createReactClass({ <ide> getDefaultProps: function() { <ide> return { <ide> activeOpacity: 0.2, <del> focusedOpacity: 0.7, <ide> }; <ide> }, <ide> <ide> var TouchableOpacity = createReactClass({ <ide> ); <ide> }, <ide> <del> _opacityFocused: function() { <del> this.setOpacityTo(this.props.focusedOpacity); <del> }, <del> <ide> _getChildStyleOpacityWithDefault: function() { <ide> var childStyle = flattenStyle(this.props.style) || {}; <ide> return childStyle.opacity == undefined ? 1 : childStyle.opacity;
1
Ruby
Ruby
simplify the block and add a comment
329e357d9acdd7989cb3ba6394f3b4839bb1e83f
<ide><path>Library/Homebrew/caveats.rb <ide> def plist_caveats <ide> else <ide> s << " launchctl load #{plist_link}" <ide> end <del> else <del> if f.plist_startup <add> # For startup plists, we cannot tell whether it's running on launchd, <add> # as it requires for `sudo launchctl list` to get real result. <add> elsif f.plist_startup <ide> s << "To reload #{f.name} after an upgrade:" <ide> s << " sudo launchctl unload #{plist_link}" <ide> s << " sudo cp -fv #{f.opt_prefix}/*.plist #{destination}" <ide> s << " sudo launchctl load #{plist_link}" <del> else <del> if Kernel.system "/bin/launchctl list #{plist_domain} &>/dev/null" <del> s << "To reload #{f.name} after an upgrade:" <del> s << " launchctl unload #{plist_link}" <del> s << " launchctl load #{plist_link}" <del> else <del> s << "To load #{f.name}:" <del> s << " launchctl load #{plist_link}" <del> end <del> end <add> elsif Kernel.system "/bin/launchctl list #{plist_domain} &>/dev/null" <add> s << "To reload #{f.name} after an upgrade:" <add> s << " launchctl unload #{plist_link}" <add> s << " launchctl load #{plist_link}" <add> else <add> s << "To load #{f.name}:" <add> s << " launchctl load #{plist_link}" <ide> end <ide> <ide> if f.plist_manual
1
Javascript
Javascript
pass cli flags in pummel/test-regress-gh-892
32ac8c0b69d87ff635c3827f1891907dec9ee381
<ide><path>test/pummel/test-regress-GH-892.js <ide> function makeRequest() { <ide> <ide> var stderrBuffer = ''; <ide> <del> var child = spawn(process.execPath, <del> [childScript, common.PORT, bytesExpected]); <add> // Pass along --trace-deprecation/--throw-deprecation in <add> // process.execArgv to track down nextTick recursion errors <add> // more easily. Also, this is handy when using this test to <add> // view V8 opt/deopt behavior. <add> var args = process.execArgv.concat([ childScript, <add> common.PORT, <add> bytesExpected ]); <add> <add> var child = spawn(process.execPath, args); <ide> <ide> child.on('exit', function(code) { <ide> assert.ok(/DONE/.test(stderrBuffer));
1
Go
Go
move "containers" to daemon/list.go
d0370076585f506d2f81af3fb3dab56119bdc0e9
<ide><path>daemon/daemon.go <ide> func (daemon *Daemon) Install(eng *engine.Engine) error { <ide> if err := eng.Register("top", daemon.ContainerTop); err != nil { <ide> return err <ide> } <add> if err := eng.Register("containers", daemon.Containers); err != nil { <add> return err <add> } <ide> return nil <ide> } <ide> <del>// List returns an array of all containers registered in the daemon. <del>func (daemon *Daemon) List() []*Container { <del> return daemon.containers.List() <del>} <del> <ide> // Get looks for a container by the specified ID or name, and returns it. <ide> // If the container is not found, or if an error occurs, nil is returned. <ide> func (daemon *Daemon) Get(name string) *Container { <add><path>daemon/list.go <del><path>server/container.go <del>// DEPRECATION NOTICE. PLEASE DO NOT ADD ANYTHING TO THIS FILE. <del>// <del>// For additional commments see server/server.go <del>// <del>package server <add>package daemon <ide> <ide> import ( <ide> "errors" <ide> "fmt" <ide> "strings" <ide> <del> "github.com/docker/docker/daemon" <del> "github.com/docker/docker/engine" <ide> "github.com/docker/docker/pkg/graphdb" <add> <add> "github.com/docker/docker/engine" <ide> ) <ide> <del>func (srv *Server) Containers(job *engine.Job) engine.Status { <add>// List returns an array of all containers registered in the daemon. <add>func (daemon *Daemon) List() []*Container { <add> return daemon.containers.List() <add>} <add> <add>func (daemon *Daemon) Containers(job *engine.Job) engine.Status { <ide> var ( <ide> foundBefore bool <ide> displayed int <ide> func (srv *Server) Containers(job *engine.Job) engine.Status { <ide> outs := engine.NewTable("Created", 0) <ide> <ide> names := map[string][]string{} <del> srv.daemon.ContainerGraph().Walk("/", func(p string, e *graphdb.Entity) error { <add> daemon.ContainerGraph().Walk("/", func(p string, e *graphdb.Entity) error { <ide> names[e.ID()] = append(names[e.ID()], p) <ide> return nil <ide> }, -1) <ide> <del> var beforeCont, sinceCont *daemon.Container <add> var beforeCont, sinceCont *Container <ide> if before != "" { <del> beforeCont = srv.daemon.Get(before) <add> beforeCont = daemon.Get(before) <ide> if beforeCont == nil { <ide> return job.Error(fmt.Errorf("Could not find container with name or id %s", before)) <ide> } <ide> } <ide> <ide> if since != "" { <del> sinceCont = srv.daemon.Get(since) <add> sinceCont = daemon.Get(since) <ide> if sinceCont == nil { <ide> return job.Error(fmt.Errorf("Could not find container with name or id %s", since)) <ide> } <ide> } <ide> <ide> errLast := errors.New("last container") <del> writeCont := func(container *daemon.Container) error { <add> writeCont := func(container *Container) error { <ide> container.Lock() <ide> defer container.Unlock() <ide> if !container.State.IsRunning() && !all && n <= 0 && since == "" && before == "" { <ide> func (srv *Server) Containers(job *engine.Job) engine.Status { <ide> out := &engine.Env{} <ide> out.Set("Id", container.ID) <ide> out.SetList("Names", names[container.ID]) <del> out.Set("Image", srv.daemon.Repositories().ImageName(container.Image)) <add> out.Set("Image", daemon.Repositories().ImageName(container.Image)) <ide> if len(container.Args) > 0 { <ide> args := []string{} <ide> for _, arg := range container.Args { <ide> func (srv *Server) Containers(job *engine.Job) engine.Status { <ide> return nil <ide> } <ide> <del> for _, container := range srv.daemon.List() { <add> for _, container := range daemon.List() { <ide> if err := writeCont(container); err != nil { <ide> if err != errLast { <ide> return job.Error(err) <ide><path>server/init.go <ide> func InitServer(job *engine.Job) engine.Status { <ide> "image_delete": srv.ImageDelete, <ide> "events": srv.Events, <ide> "push": srv.ImagePush, <del> "containers": srv.Containers, <ide> } { <ide> if err := job.Eng.Register(name, srv.handlerWrap(handler)); err != nil { <ide> return job.Error(err)
3
Python
Python
fix openstackexception issue
85b6f4a29c91dca6631dbff7cc25225f60cb70ba
<ide><path>libcloud/compute/drivers/openstack.py <ide> def __init__(self, id, parent_group_id, ip_protocol, from_port, to_port, <ide> self.direction = direction <ide> else: <ide> raise OpenStackException("Security group direction incorrect " <del> "value: ingress or egress.") <add> "value: ingress or egress.", 500, <add> driver) <ide> <ide> self.tenant_id = tenant_id <ide> self.extra = extra or {}
1
Javascript
Javascript
add test case
6592956d357a7a47dad716d5bb57ba8f1c62a8d7
<ide><path>test/configCases/parsing/issue-14720/index.js <add>it("should generate a chunk for a full require dependencies in require.ensure", done => { <add> require.ensure([], () => { <add> expect(require("./module").property).toBe(42); <add> expect(__STATS__.chunks.length).toBe(2); <add> done(); <add> }); <add>}); <ide><path>test/configCases/parsing/issue-14720/module.js <add>exports.property = 42; <ide><path>test/configCases/parsing/issue-14720/webpack.config.js <add>/** @type {import("../../../../").Configuration} */ <add>module.exports = { <add> mode: "production" <add>};
3
Text
Text
add a section about platform.version on ios
390c8cf96ee0b139aafc99bb23f8a49236f05309
<ide><path>docs/PlatformSpecificInformation.md <ide> if (Platform.Version === 25) { <ide> } <ide> ``` <ide> <add>### Detecting the iOS version <add> <add>On iOS, the `Version` is a result of `-[UIDevice systemVersion]`, which is a string with the current version of the operating system. An example of the system version is "10.3". For example, to detect the major version number on iOS: <add> <add>```javascript <add>import { Platform } from 'react-native'; <add> <add>const majorVersionIOS = parseInt(Platform.Version, 10); <add>if (majorVersionIOS <= 9) { <add> console.log('Work around a change in behavior'); <add>} <add>``` <add> <ide> ## Platform-specific extensions <ide> <ide> When your platform-specific code is more complex, you should consider splitting the code out into separate files. React Native will detect when a file has a `.ios.` or `.android.` extension and load the relevant platform file when required from other components.
1
Python
Python
remove references to python 2 / is_python2
296b5d633b94ca51ed038b31d207edb5f53e0acb
<ide><path>spacy/tests/regression/test_issue5230.py <ide> from spacy.vectors import Vectors <ide> from spacy.language import Language <ide> from spacy.pipeline import Pipe <del>from spacy.compat import is_python2 <ide> <ide> <ide> from ..util import make_tempdir <ide> def write_obj_and_catch_warnings(obj): <ide> return list(filter(lambda x: isinstance(x, ResourceWarning), warnings_list)) <ide> <ide> <del>@pytest.mark.skipif(is_python2, reason="ResourceWarning needs Python 3.x") <ide> @pytest.mark.parametrize("obj", objects_to_test[0], ids=objects_to_test[1]) <ide> def test_to_disk_resource_warning(obj): <ide> warnings_list = write_obj_and_catch_warnings(obj) <ide> assert len(warnings_list) == 0 <ide> <ide> <del>@pytest.mark.skipif(is_python2, reason="ResourceWarning needs Python 3.x") <ide> def test_writer_with_path_py35(): <ide> writer = None <ide> with make_tempdir() as d: <ide> def test_save_and_load_knowledge_base(): <ide> pytest.fail(str(e)) <ide> <ide> <del>if not is_python2: <add>class TestToDiskResourceWarningUnittest(TestCase): <add> def test_resource_warning(self): <add> scenarios = zip(*objects_to_test) <ide> <del> class TestToDiskResourceWarningUnittest(TestCase): <del> def test_resource_warning(self): <del> scenarios = zip(*objects_to_test) <del> <del> for scenario in scenarios: <del> with self.subTest(msg=scenario[1]): <del> warnings_list = write_obj_and_catch_warnings(scenario[0]) <del> self.assertEqual(len(warnings_list), 0) <add> for scenario in scenarios: <add> with self.subTest(msg=scenario[1]): <add> warnings_list = write_obj_and_catch_warnings(scenario[0]) <add> self.assertEqual(len(warnings_list), 0) <ide><path>spacy/tests/serialize/test_serialize_vocab_strings.py <ide> import pickle <ide> from spacy.vocab import Vocab <ide> from spacy.strings import StringStore <del>from spacy.compat import is_python2 <ide> <ide> from ..util import make_tempdir <ide> <ide> def test_serialize_stringstore_roundtrip_disk(strings1, strings2): <ide> assert list(sstore1_d) != list(sstore2_d) <ide> <ide> <del>@pytest.mark.skipif(is_python2, reason="Dict order? Not sure if worth investigating") <ide> @pytest.mark.parametrize("strings,lex_attr", test_strings_attrs) <ide> def test_pickle_vocab(strings, lex_attr): <ide> vocab = Vocab(strings=strings) <ide><path>spacy/tests/vocab_vectors/test_vectors.py <ide> from spacy.tokenizer import Tokenizer <ide> from spacy.strings import hash_string <ide> from spacy.tokens import Doc <del>from spacy.compat import is_python2 <ide> <ide> from ..util import add_vecs_to_vocab, get_cosine, make_tempdir <ide> <ide> def test_vocab_prune_vectors(): <ide> assert_allclose(similarity, get_cosine(data[0], data[2]), atol=1e-4, rtol=1e-3) <ide> <ide> <del>@pytest.mark.skipif(is_python2, reason="Dict order? Not sure if worth investigating") <ide> def test_vectors_serialize(): <ide> data = numpy.asarray([[4, 2, 2, 2], [4, 2, 2, 2], [1, 1, 1, 1]], dtype="f") <ide> v = Vectors(data=data, keys=["A", "B", "C"])
3
Java
Java
add tests to spring-messaging
e1a46bb57a88628305534ddab85591dbc8dcc8e9
<ide><path>spring-messaging/src/main/java/org/springframework/messaging/simp/annotation/support/SubscriptionMethodReturnValueHandler.java <ide> <ide> /** <ide> * A {@link HandlerMethodReturnValueHandler} for replying directly to a subscription. It <del> * supports methods annotated with {@link SubscribeEvent} that do not also annotated with <del> * neither {@link ReplyTo} nor {@link ReplyToUser}. <del> * <del> * <p>The value returned from the method is converted, and turned to a {@link Message} and <add> * supports methods annotated with {@link SubscribeEvent} unless they're also annotated <add> * with {@link ReplyTo} or {@link ReplyToUser}. <add> * <p> <add> * The value returned from the method is converted, and turned to a {@link Message} and <ide> * then enriched with the sessionId, subscriptionId, and destination of the input message. <ide> * The message is then sent directly back to the connected client. <ide> * <ide> public void handleReturnValue(Object returnValue, MethodParameter returnType, Me <ide> String destination = inputHeaders.getDestination(); <ide> <ide> Assert.state(inputHeaders.getSubscriptionId() != null, <del> "No subsriptiondId in input message. Add @ReplyTo or @ReplyToUser to method: " <del> + returnType.getMethod()); <add> "No subsriptiondId in input message to method " + returnType.getMethod()); <ide> <ide> MessagePostProcessor postProcessor = new SubscriptionHeaderPostProcessor(sessionId, subscriptionId); <ide> this.messagingTemplate.convertAndSend(destination, returnValue, postProcessor); <ide><path>spring-messaging/src/main/java/org/springframework/messaging/simp/config/AbstractStompEndpointRegistration.java <ide> <ide> <ide> /** <del> * A helper class for configuring STOMP protocol handling over WebSocket <del> * with optional SockJS fallback options. <add> * An abstract base class class for configuring STOMP over WebSocket/SockJS endpoints. <ide> * <ide> * @author Rossen Stoyanchev <ide> * @since 4.0 <ide> <ide> private StompSockJsServiceRegistration sockJsServiceRegistration; <ide> <del> private final TaskScheduler defaultSockJsTaskScheduler; <add> private final TaskScheduler sockJsTaskScheduler; <ide> <ide> <ide> public AbstractStompEndpointRegistration(String[] paths, SubProtocolWebSocketHandler webSocketHandler, <del> TaskScheduler defaultSockJsTaskScheduler) { <add> TaskScheduler sockJsTaskScheduler) { <ide> <ide> Assert.notEmpty(paths, "No paths specified"); <ide> this.paths = paths; <ide> this.wsHandler = webSocketHandler; <del> this.defaultSockJsTaskScheduler = defaultSockJsTaskScheduler; <add> this.sockJsTaskScheduler = sockJsTaskScheduler; <ide> } <ide> <ide> <del> protected SubProtocolWebSocketHandler getWsHandler() { <del> return this.wsHandler; <del> } <del> <add> /** <add> * Provide a custom or pre-configured {@link HandshakeHandler}. This property is <add> * optional. <add> */ <ide> @Override <ide> public StompEndpointRegistration setHandshakeHandler(HandshakeHandler handshakeHandler) { <ide> this.handshakeHandler = handshakeHandler; <ide> return this; <ide> } <ide> <add> /** <add> * Enable SockJS fallback options. <add> */ <ide> @Override <ide> public SockJsServiceRegistration withSockJS() { <ide> <del> this.sockJsServiceRegistration = new StompSockJsServiceRegistration(this.defaultSockJsTaskScheduler); <add> this.sockJsServiceRegistration = new StompSockJsServiceRegistration(this.sockJsTaskScheduler); <ide> <ide> if (this.handshakeHandler != null) { <ide> WebSocketTransportHandler transportHandler = new WebSocketTransportHandler(this.handshakeHandler); <ide> public SockJsServiceRegistration withSockJS() { <ide> return this.sockJsServiceRegistration; <ide> } <ide> <del> protected M getMappings() { <add> protected final M getMappings() { <ide> <ide> M mappings = createMappings(); <ide> <ide><path>spring-messaging/src/main/java/org/springframework/messaging/simp/config/MessageBrokerConfigurer.java <ide> */ <ide> public class MessageBrokerConfigurer { <ide> <del> private final MessageChannel webSocketReplyChannel; <add> private final MessageChannel webSocketResponseChannel; <ide> <ide> private SimpleBrokerRegistration simpleBroker; <ide> <ide> public class MessageBrokerConfigurer { <ide> private String[] annotationMethodDestinationPrefixes; <ide> <ide> <del> public MessageBrokerConfigurer(MessageChannel webSocketReplyChannel) { <del> Assert.notNull(webSocketReplyChannel); <del> this.webSocketReplyChannel = webSocketReplyChannel; <add> public MessageBrokerConfigurer(MessageChannel webSocketResponseChannel) { <add> Assert.notNull(webSocketResponseChannel); <add> this.webSocketResponseChannel = webSocketResponseChannel; <ide> } <ide> <ide> public SimpleBrokerRegistration enableSimpleBroker(String... destinationPrefixes) { <del> this.simpleBroker = new SimpleBrokerRegistration(this.webSocketReplyChannel, destinationPrefixes); <add> this.simpleBroker = new SimpleBrokerRegistration(this.webSocketResponseChannel, destinationPrefixes); <ide> return this.simpleBroker; <ide> } <ide> <ide> public StompBrokerRelayRegistration enableStompBrokerRelay(String... destinationPrefixes) { <del> this.stompRelay = new StompBrokerRelayRegistration(this.webSocketReplyChannel, destinationPrefixes); <add> this.stompRelay = new StompBrokerRelayRegistration(this.webSocketResponseChannel, destinationPrefixes); <ide> return this.stompRelay; <ide> } <ide> <ide> protected AbstractBrokerMessageHandler getSimpleBroker() { <ide> <ide> protected void initSimpleBrokerIfNecessary() { <ide> if ((this.simpleBroker == null) && (this.stompRelay == null)) { <del> this.simpleBroker = new SimpleBrokerRegistration(this.webSocketReplyChannel, null); <add> this.simpleBroker = new SimpleBrokerRegistration(this.webSocketResponseChannel, null); <ide> } <ide> } <ide> <ide><path>spring-messaging/src/main/java/org/springframework/messaging/simp/config/StompBrokerRelayRegistration.java <ide> public class StompBrokerRelayRegistration extends AbstractBrokerRegistration { <ide> <ide> private String applicationPasscode = "guest"; <ide> <add> private boolean autoStartup = true; <add> <ide> <ide> public StompBrokerRelayRegistration(MessageChannel webSocketReplyChannel, String[] destinationPrefixes) { <ide> super(webSocketReplyChannel, destinationPrefixes); <ide> public StompBrokerRelayRegistration setRelayHost(String relayHost) { <ide> return this; <ide> } <ide> <del> /** <del> * @return the STOMP message broker host. <del> */ <del> protected String getRelayHost() { <del> return this.relayHost; <del> } <del> <ide> /** <ide> * Set the STOMP message broker port. <ide> */ <ide> public StompBrokerRelayRegistration setRelayPort(int relayPort) { <ide> return this; <ide> } <ide> <del> /** <del> * @return the STOMP message broker port. <del> */ <del> protected int getRelayPort() { <del> return this.relayPort; <del> } <del> <ide> /** <ide> * Set the login for a "system" TCP connection used to send messages to the STOMP <ide> * broker without having a client session (e.g. REST/HTTP request handling method). <ide> public StompBrokerRelayRegistration setApplicationLogin(String login) { <ide> return this; <ide> } <ide> <del> /** <del> * @return the login for a shared, "system" connection to the STOMP message broker. <del> */ <del> protected String getApplicationLogin() { <del> return this.applicationLogin; <del> } <del> <ide> /** <ide> * Set the passcode for a "system" TCP connection used to send messages to the STOMP <ide> * broker without having a client session (e.g. REST/HTTP request handling method). <ide> public StompBrokerRelayRegistration setApplicationPasscode(String passcode) { <ide> } <ide> <ide> /** <del> * @return the passcode for a shared, "system" connection to the STOMP message broker. <add> * Configure whether the {@link StompBrokerRelayMessageHandler} should start <add> * automatically when the Spring ApplicationContext is refreshed. <add> * <p> <add> * The default setting is {@code true}. <ide> */ <del> protected String getApplicationPasscode() { <del> return this.applicationPasscode; <add> public StompBrokerRelayRegistration setAutoStartup(boolean autoStartup) { <add> this.autoStartup = autoStartup; <add> return this; <ide> } <ide> <ide> <ide> protected StompBrokerRelayMessageHandler getMessageHandler() { <ide> handler.setRelayPort(this.relayPort); <ide> handler.setSystemLogin(this.applicationLogin); <ide> handler.setSystemPasscode(this.applicationPasscode); <add> handler.setAutoStartup(this.autoStartup); <ide> return handler; <ide> } <ide> <ide><path>spring-messaging/src/main/java/org/springframework/messaging/simp/config/WebSocketMessageBrokerConfigurationSupport.java <ide> public HandlerMapping brokerWebSocketHandlerMapping() { <ide> @Bean <ide> public SubProtocolWebSocketHandler subProtocolWebSocketHandler() { <ide> SubProtocolWebSocketHandler wsHandler = new SubProtocolWebSocketHandler(webSocketRequestChannel()); <del> webSocketReplyChannel().subscribe(wsHandler); <add> webSocketResponseChannel().subscribe(wsHandler); <ide> return wsHandler; <ide> } <ide> <ide> public SubscribableChannel webSocketRequestChannel() { <ide> } <ide> <ide> @Bean <del> public SubscribableChannel webSocketReplyChannel() { <add> public SubscribableChannel webSocketResponseChannel() { <ide> return new ExecutorSubscribableChannel(webSocketChannelExecutor()); <ide> } <ide> <ide> public ThreadPoolTaskExecutor webSocketChannelExecutor() { <ide> @Bean <ide> public AnnotationMethodMessageHandler annotationMethodMessageHandler() { <ide> AnnotationMethodMessageHandler handler = <del> new AnnotationMethodMessageHandler(brokerMessagingTemplate(), webSocketReplyChannel()); <add> new AnnotationMethodMessageHandler(brokerMessagingTemplate(), webSocketResponseChannel()); <ide> handler.setDestinationPrefixes(getMessageBrokerConfigurer().getAnnotationMethodDestinationPrefixes()); <ide> handler.setMessageConverter(brokerMessageConverter()); <ide> webSocketRequestChannel().subscribe(handler); <ide> public AbstractBrokerMessageHandler simpleBrokerMessageHandler() { <ide> } <ide> else { <ide> webSocketRequestChannel().subscribe(handler); <del> brokerMessageChannel().subscribe(handler); <add> brokerChannel().subscribe(handler); <ide> return handler; <ide> } <ide> } <ide> public AbstractBrokerMessageHandler stompBrokerRelayMessageHandler() { <ide> } <ide> else { <ide> webSocketRequestChannel().subscribe(handler); <del> brokerMessageChannel().subscribe(handler); <add> brokerChannel().subscribe(handler); <ide> return handler; <ide> } <ide> } <ide> <ide> protected final MessageBrokerConfigurer getMessageBrokerConfigurer() { <ide> if (this.messageBrokerConfigurer == null) { <del> MessageBrokerConfigurer configurer = new MessageBrokerConfigurer(webSocketReplyChannel()); <add> MessageBrokerConfigurer configurer = new MessageBrokerConfigurer(webSocketResponseChannel()); <ide> configureMessageBroker(configurer); <ide> this.messageBrokerConfigurer = configurer; <ide> } <ide> public UserDestinationMessageHandler userDestinationMessageHandler() { <ide> UserDestinationMessageHandler handler = new UserDestinationMessageHandler( <ide> brokerMessagingTemplate(), userQueueSuffixResolver()); <ide> webSocketRequestChannel().subscribe(handler); <del> brokerMessageChannel().subscribe(handler); <add> brokerChannel().subscribe(handler); <ide> return handler; <ide> } <ide> <ide> @Bean <ide> public SimpMessageSendingOperations brokerMessagingTemplate() { <del> SimpMessagingTemplate template = new SimpMessagingTemplate(webSocketRequestChannel()); <add> SimpMessagingTemplate template = new SimpMessagingTemplate(brokerChannel()); <ide> template.setMessageConverter(brokerMessageConverter()); <ide> return template; <ide> } <ide> <ide> @Bean <del> public SubscribableChannel brokerMessageChannel() { <add> public SubscribableChannel brokerChannel() { <ide> return new ExecutorSubscribableChannel(); // synchronous <ide> } <ide> <ide><path>spring-messaging/src/main/java/org/springframework/messaging/simp/handler/AbstractBrokerMessageHandler.java <ide> <ide> private AtomicBoolean brokerAvailable = new AtomicBoolean(false); <ide> <add> private boolean autoStartup = true; <add> <ide> private Object lifecycleMonitor = new Object(); <ide> <ide> private volatile boolean running = false; <ide> public ApplicationEventPublisher getApplicationEventPublisher() { <ide> return this.eventPublisher; <ide> } <ide> <add> public void setAutoStartup(boolean autoStartup) { <add> this.autoStartup = autoStartup; <add> } <add> <ide> @Override <ide> public boolean isAutoStartup() { <del> return true; <add> return this.autoStartup; <ide> } <ide> <ide> @Override <ide><path>spring-messaging/src/main/java/org/springframework/messaging/simp/handler/AnnotationMethodMessageHandler.java <ide> public class AnnotationMethodMessageHandler implements MessageHandler, Applicati <ide> <ide> private final SimpMessageSendingOperations brokerTemplate; <ide> <del> private final SimpMessageSendingOperations webSocketReplyTemplate; <add> private final SimpMessageSendingOperations webSocketResponseTemplate; <ide> <ide> private Collection<String> destinationPrefixes; <ide> <ide> public class AnnotationMethodMessageHandler implements MessageHandler, Applicati <ide> <ide> /** <ide> * @param brokerTemplate a messaging template to sending messages to the broker <del> * @param webSocketReplyChannel the channel for messages to WebSocket clients <add> * @param webSocketResponseChannel the channel for messages to WebSocket clients <ide> */ <ide> public AnnotationMethodMessageHandler(SimpMessageSendingOperations brokerTemplate, <del> MessageChannel webSocketReplyChannel) { <add> MessageChannel webSocketResponseChannel) { <ide> <ide> Assert.notNull(brokerTemplate, "brokerTemplate is required"); <del> Assert.notNull(webSocketReplyChannel, "webSocketReplyChannel is required"); <add> Assert.notNull(webSocketResponseChannel, "webSocketReplyChannel is required"); <ide> this.brokerTemplate = brokerTemplate; <del> this.webSocketReplyTemplate = new SimpMessagingTemplate(webSocketReplyChannel); <add> this.webSocketResponseTemplate = new SimpMessagingTemplate(webSocketResponseChannel); <ide> } <ide> <ide> <ide> public Collection<String> getDestinationPrefixes() { <ide> public void setMessageConverter(MessageConverter<?> converter) { <ide> this.messageConverter = converter; <ide> if (converter != null) { <del> ((AbstractMessageSendingTemplate<?>) this.webSocketReplyTemplate).setMessageConverter(converter); <add> ((AbstractMessageSendingTemplate<?>) this.webSocketResponseTemplate).setMessageConverter(converter); <ide> } <ide> } <ide> <ide> public void afterPropertiesSet() { <ide> <ide> // Annotation-based return value types <ide> this.returnValueHandlers.addHandler(new ReplyToMethodReturnValueHandler(this.brokerTemplate)); <del> this.returnValueHandlers.addHandler(new SubscriptionMethodReturnValueHandler(this.webSocketReplyTemplate)); <add> this.returnValueHandlers.addHandler(new SubscriptionMethodReturnValueHandler(this.webSocketResponseTemplate)); <ide> <ide> // custom return value types <ide> this.returnValueHandlers.addHandlers(this.customReturnValueHandlers); <ide> private <A extends Annotation> void initHandlerMethods(Object handler, Class<?> <ide> final Class<A> annotationType, MappingInfoCreator<A> mappingInfoCreator, <ide> Map<MappingInfo, HandlerMethod> handlerMethods) { <ide> <del> Set<Method> messageMethods = HandlerMethodSelector.selectMethods(handlerType, new MethodFilter() { <add> Set<Method> methods = HandlerMethodSelector.selectMethods(handlerType, new MethodFilter() { <ide> @Override <ide> public boolean matches(Method method) { <ide> return AnnotationUtils.findAnnotation(method, annotationType) != null; <ide> } <ide> }); <ide> <del> for (Method method : messageMethods) { <add> for (Method method : methods) { <ide> A annotation = AnnotationUtils.findAnnotation(method, annotationType); <ide> HandlerMethod hm = createHandlerMethod(handler, method); <ide> handlerMethods.put(mappingInfoCreator.create(annotation), hm); <ide><path>spring-messaging/src/main/java/org/springframework/messaging/support/channel/AbstractMessageChannel.java <ide> public final boolean send(Message<?> message, long timeout) { <ide> <ide> protected abstract boolean sendInternal(Message<?> message, long timeout); <ide> <add> <add> @Override <add> public String toString() { <add> return "MessageChannel [name=" + this.beanName + "]"; <add> } <add> <ide> } <ide><path>spring-messaging/src/test/java/org/springframework/messaging/simp/config/AbstractStompEndpointRegistrationTests.java <ide> public void setup() { <ide> } <ide> <ide> @Test <del> public void minimal() { <add> public void minimalRegistration() { <ide> <ide> TestStompEndpointRegistration registration = <ide> new TestStompEndpointRegistration(new String[] {"/foo"}, this.wsHandler, this.scheduler); <ide> public void minimal() { <ide> } <ide> <ide> @Test <del> public void handshakeHandler() { <add> public void customHandshakeHandler() { <ide> <ide> DefaultHandshakeHandler handshakeHandler = new DefaultHandshakeHandler(); <ide> <ide> public void handshakeHandler() { <ide> } <ide> <ide> @Test <del> public void handshakeHandlerPassedToSockJsService() { <add> public void customHandshakeHandlerPassedToSockJsService() { <ide> <ide> DefaultHandshakeHandler handshakeHandler = new DefaultHandshakeHandler(); <ide> <ide><path>spring-messaging/src/test/java/org/springframework/messaging/simp/config/ServletStompEndpointRegistryTests.java <add>/* <add> * Copyright 2002-2013 the original author or authors. <add> * <add> * Licensed under the Apache License, Version 2.0 (the "License"); <add> * you may not use this file except in compliance with the License. <add> * You may obtain a copy of the License at <add> * <add> * http://www.apache.org/licenses/LICENSE-2.0 <add> * <add> * Unless required by applicable law or agreed to in writing, software <add> * distributed under the License is distributed on an "AS IS" BASIS, <add> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <add> * See the License for the specific language governing permissions and <add> * limitations under the License. <add> */ <add> <add>package org.springframework.messaging.simp.config; <add> <add>import java.util.Map; <add> <add>import org.junit.Before; <add>import org.junit.Test; <add>import org.mockito.Mockito; <add>import org.springframework.messaging.MessageChannel; <add>import org.springframework.messaging.handler.websocket.SubProtocolHandler; <add>import org.springframework.messaging.handler.websocket.SubProtocolWebSocketHandler; <add>import org.springframework.messaging.simp.handler.MutableUserQueueSuffixResolver; <add>import org.springframework.messaging.simp.handler.SimpleUserQueueSuffixResolver; <add>import org.springframework.messaging.simp.stomp.StompProtocolHandler; <add>import org.springframework.scheduling.TaskScheduler; <add>import org.springframework.web.servlet.handler.SimpleUrlHandlerMapping; <add> <add>import static org.junit.Assert.*; <add> <add> <add>/** <add> * Test fixture for {@link ServletStompEndpointRegistry}. <add> * <add> * @author Rossen Stoyanchev <add> */ <add>public class ServletStompEndpointRegistryTests { <add> <add> private ServletStompEndpointRegistry registry; <add> <add> private SubProtocolWebSocketHandler webSocketHandler; <add> <add> private MutableUserQueueSuffixResolver queueSuffixResolver; <add> <add> <add> @Before <add> public void setup() { <add> MessageChannel channel = Mockito.mock(MessageChannel.class); <add> this.webSocketHandler = new SubProtocolWebSocketHandler(channel); <add> this.queueSuffixResolver = new SimpleUserQueueSuffixResolver(); <add> TaskScheduler taskScheduler = Mockito.mock(TaskScheduler.class); <add> this.registry = new ServletStompEndpointRegistry(webSocketHandler, queueSuffixResolver, taskScheduler); <add> } <add> <add> <add> @Test <add> public void stompProtocolHandler() { <add> <add> this.registry.addEndpoint("/stomp"); <add> <add> Map<String, SubProtocolHandler> protocolHandlers = webSocketHandler.getProtocolHandlers(); <add> assertEquals(3, protocolHandlers.size()); <add> assertNotNull(protocolHandlers.get("v10.stomp")); <add> assertNotNull(protocolHandlers.get("v11.stomp")); <add> assertNotNull(protocolHandlers.get("v12.stomp")); <add> <add> StompProtocolHandler stompHandler = (StompProtocolHandler) protocolHandlers.get("v10.stomp"); <add> assertSame(this.queueSuffixResolver, stompHandler.getUserQueueSuffixResolver()); <add> } <add> <add> @Test <add> public void handlerMapping() { <add> <add> SimpleUrlHandlerMapping hm = (SimpleUrlHandlerMapping) this.registry.getHandlerMapping(); <add> assertEquals(0, hm.getUrlMap().size()); <add> <add> this.registry.addEndpoint("/stompOverWebSocket"); <add> this.registry.addEndpoint("/stompOverSockJS").withSockJS(); <add> <add> hm = (SimpleUrlHandlerMapping) this.registry.getHandlerMapping(); <add> assertEquals(2, hm.getUrlMap().size()); <add> assertNotNull(hm.getUrlMap().get("/stompOverWebSocket")); <add> assertNotNull(hm.getUrlMap().get("/stompOverSockJS/**")); <add> } <add> <add>} <ide><path>spring-messaging/src/test/java/org/springframework/messaging/simp/config/WebSocketMessageBrokerConfigurationSupportTests.java <add>/* <add> * Copyright 2002-2013 the original author or authors. <add> * <add> * Licensed under the Apache License, Version 2.0 (the "License"); <add> * you may not use this file except in compliance with the License. <add> * You may obtain a copy of the License at <add> * <add> * http://www.apache.org/licenses/LICENSE-2.0 <add> * <add> * Unless required by applicable law or agreed to in writing, software <add> * distributed under the License is distributed on an "AS IS" BASIS, <add> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <add> * See the License for the specific language governing permissions and <add> * limitations under the License. <add> */ <add> <add>package org.springframework.messaging.simp.config; <add> <add>import java.util.List; <add>import java.util.Map; <add> <add>import org.junit.Before; <add>import org.junit.Test; <add>import org.mockito.ArgumentCaptor; <add>import org.mockito.Mockito; <add>import org.springframework.context.annotation.AnnotationConfigApplicationContext; <add>import org.springframework.context.annotation.Bean; <add>import org.springframework.context.annotation.Configuration; <add>import org.springframework.messaging.Message; <add>import org.springframework.messaging.MessageHandler; <add>import org.springframework.messaging.SubscribableChannel; <add>import org.springframework.messaging.handler.annotation.MessageMapping; <add>import org.springframework.messaging.handler.annotation.ReplyTo; <add>import org.springframework.messaging.handler.websocket.SubProtocolWebSocketHandler; <add>import org.springframework.messaging.simp.SimpMessageType; <add>import org.springframework.messaging.simp.annotation.SubscribeEvent; <add>import org.springframework.messaging.simp.handler.AnnotationMethodMessageHandler; <add>import org.springframework.messaging.simp.handler.MutableUserQueueSuffixResolver; <add>import org.springframework.messaging.simp.handler.SimpleBrokerMessageHandler; <add>import org.springframework.messaging.simp.handler.UserDestinationMessageHandler; <add>import org.springframework.messaging.simp.stomp.StompBrokerRelayMessageHandler; <add>import org.springframework.messaging.simp.stomp.StompCommand; <add>import org.springframework.messaging.simp.stomp.StompHeaderAccessor; <add>import org.springframework.messaging.simp.stomp.StompTextMessageBuilder; <add>import org.springframework.messaging.support.MessageBuilder; <add>import org.springframework.stereotype.Controller; <add>import org.springframework.web.servlet.HandlerMapping; <add>import org.springframework.web.servlet.handler.SimpleUrlHandlerMapping; <add>import org.springframework.web.socket.TextMessage; <add>import org.springframework.web.socket.support.TestWebSocketSession; <add> <add>import static org.junit.Assert.*; <add>import static org.mockito.Matchers.*; <add>import static org.mockito.Mockito.*; <add> <add> <add>/** <add> * Test fixture for {@link WebSocketMessageBrokerConfigurationSupport}. <add> * <add> * @author Rossen Stoyanchev <add> */ <add>public class WebSocketMessageBrokerConfigurationSupportTests { <add> <add> private AnnotationConfigApplicationContext cxtSimpleBroker; <add> <add> private AnnotationConfigApplicationContext cxtStompBroker; <add> <add> <add> @Before <add> public void setupOnce() { <add> <add> this.cxtSimpleBroker = new AnnotationConfigApplicationContext(); <add> this.cxtSimpleBroker.register(TestWebSocketMessageBrokerConfiguration.class, TestSimpleMessageBrokerConfig.class); <add> this.cxtSimpleBroker.refresh(); <add> <add> this.cxtStompBroker = new AnnotationConfigApplicationContext(); <add> this.cxtStompBroker.register(TestWebSocketMessageBrokerConfiguration.class, TestStompMessageBrokerConfig.class); <add> this.cxtStompBroker.refresh(); <add> } <add> <add> @Test <add> public void handlerMapping() { <add> <add> SimpleUrlHandlerMapping hm = (SimpleUrlHandlerMapping) this.cxtSimpleBroker.getBean(HandlerMapping.class); <add> assertEquals(1, hm.getOrder()); <add> <add> Map<String, Object> handlerMap = hm.getHandlerMap(); <add> assertEquals(1, handlerMap.size()); <add> assertNotNull(handlerMap.get("/simpleBroker")); <add> } <add> <add> @Test <add> public void webSocketRequestChannel() { <add> <add> SubscribableChannel channel = this.cxtSimpleBroker.getBean("webSocketRequestChannel", SubscribableChannel.class); <add> <add> ArgumentCaptor<MessageHandler> captor = ArgumentCaptor.forClass(MessageHandler.class); <add> verify(channel, times(3)).subscribe(captor.capture()); <add> <add> List<MessageHandler> values = captor.getAllValues(); <add> assertEquals(3, values.size()); <add> <add> assertTrue(values.contains(cxtSimpleBroker.getBean(AnnotationMethodMessageHandler.class))); <add> assertTrue(values.contains(cxtSimpleBroker.getBean(UserDestinationMessageHandler.class))); <add> assertTrue(values.contains(cxtSimpleBroker.getBean(SimpleBrokerMessageHandler.class))); <add> } <add> <add> @Test <add> public void webSocketRequestChannelWithStompBroker() { <add> SubscribableChannel channel = this.cxtStompBroker.getBean("webSocketRequestChannel", SubscribableChannel.class); <add> <add> ArgumentCaptor<MessageHandler> captor = ArgumentCaptor.forClass(MessageHandler.class); <add> verify(channel, times(3)).subscribe(captor.capture()); <add> <add> List<MessageHandler> values = captor.getAllValues(); <add> assertEquals(3, values.size()); <add> assertTrue(values.contains(cxtStompBroker.getBean(AnnotationMethodMessageHandler.class))); <add> assertTrue(values.contains(cxtStompBroker.getBean(UserDestinationMessageHandler.class))); <add> assertTrue(values.contains(cxtStompBroker.getBean(StompBrokerRelayMessageHandler.class))); <add> } <add> <add> @Test <add> public void webSocketRequestChannelSendMessage() throws Exception { <add> <add> SubscribableChannel channel = this.cxtSimpleBroker.getBean("webSocketRequestChannel", SubscribableChannel.class); <add> SubProtocolWebSocketHandler webSocketHandler = this.cxtSimpleBroker.getBean(SubProtocolWebSocketHandler.class); <add> <add> TextMessage textMessage = StompTextMessageBuilder.create(StompCommand.SEND).headers("destination:/foo").build(); <add> webSocketHandler.handleMessage(new TestWebSocketSession(), textMessage); <add> <add> ArgumentCaptor<Message> captor = ArgumentCaptor.forClass(Message.class); <add> verify(channel).send(captor.capture()); <add> <add> Message message = captor.getValue(); <add> StompHeaderAccessor headers = StompHeaderAccessor.wrap(message); <add> <add> assertEquals(SimpMessageType.MESSAGE, headers.getMessageType()); <add> assertEquals("/foo", headers.getDestination()); <add> } <add> <add> @Test <add> public void webSocketResponseChannel() { <add> SubscribableChannel channel = this.cxtSimpleBroker.getBean("webSocketResponseChannel", SubscribableChannel.class); <add> verify(channel).subscribe(any(SubProtocolWebSocketHandler.class)); <add> verifyNoMoreInteractions(channel); <add> } <add> <add> @Test <add> public void webSocketResponseChannelUsedByAnnotatedMethod() { <add> <add> SubscribableChannel channel = this.cxtSimpleBroker.getBean("webSocketResponseChannel", SubscribableChannel.class); <add> AnnotationMethodMessageHandler messageHandler = this.cxtSimpleBroker.getBean(AnnotationMethodMessageHandler.class); <add> <add> StompHeaderAccessor headers = StompHeaderAccessor.create(StompCommand.SUBSCRIBE); <add> headers.setSessionId("sess1"); <add> headers.setSubscriptionId("subs1"); <add> headers.setDestination("/foo"); <add> Message<?> message = MessageBuilder.withPayloadAndHeaders(new byte[0], headers).build(); <add> <add> when(channel.send(any(Message.class))).thenReturn(true); <add> messageHandler.handleMessage(message); <add> <add> ArgumentCaptor<Message> captor = ArgumentCaptor.forClass(Message.class); <add> verify(channel).send(captor.capture()); <add> message = captor.getValue(); <add> headers = StompHeaderAccessor.wrap(message); <add> <add> assertEquals(SimpMessageType.MESSAGE, headers.getMessageType()); <add> assertEquals("/foo", headers.getDestination()); <add> assertEquals("\"bar\"", new String((byte[]) message.getPayload())); <add> } <add> <add> @Test <add> public void webSocketResponseChannelUsedBySimpleBroker() { <add> SubscribableChannel channel = this.cxtSimpleBroker.getBean("webSocketResponseChannel", SubscribableChannel.class); <add> SimpleBrokerMessageHandler broker = this.cxtSimpleBroker.getBean(SimpleBrokerMessageHandler.class); <add> <add> StompHeaderAccessor headers = StompHeaderAccessor.create(StompCommand.SUBSCRIBE); <add> headers.setSessionId("sess1"); <add> headers.setSubscriptionId("subs1"); <add> headers.setDestination("/foo"); <add> Message<?> message = MessageBuilder.withPayloadAndHeaders(new byte[0], headers).build(); <add> <add> // subscribe <add> broker.handleMessage(message); <add> <add> headers = StompHeaderAccessor.create(StompCommand.SEND); <add> headers.setSessionId("sess1"); <add> headers.setDestination("/foo"); <add> message = MessageBuilder.withPayloadAndHeaders("bar".getBytes(), headers).build(); <add> <add> // message <add> when(channel.send(any(Message.class))).thenReturn(true); <add> broker.handleMessage(message); <add> <add> ArgumentCaptor<Message> captor = ArgumentCaptor.forClass(Message.class); <add> verify(channel).send(captor.capture()); <add> message = captor.getValue(); <add> headers = StompHeaderAccessor.wrap(message); <add> <add> assertEquals(SimpMessageType.MESSAGE, headers.getMessageType()); <add> assertEquals("/foo", headers.getDestination()); <add> assertEquals("bar", new String((byte[]) message.getPayload())); <add> } <add> <add> @Test <add> public void brokerChannel() { <add> SubscribableChannel channel = this.cxtSimpleBroker.getBean("brokerChannel", SubscribableChannel.class); <add> <add> ArgumentCaptor<MessageHandler> captor = ArgumentCaptor.forClass(MessageHandler.class); <add> verify(channel, times(2)).subscribe(captor.capture()); <add> <add> List<MessageHandler> values = captor.getAllValues(); <add> assertEquals(2, values.size()); <add> assertTrue(values.contains(cxtSimpleBroker.getBean(UserDestinationMessageHandler.class))); <add> assertTrue(values.contains(cxtSimpleBroker.getBean(SimpleBrokerMessageHandler.class))); <add> } <add> <add> @Test <add> public void brokerChannelWithStompBroker() { <add> SubscribableChannel channel = this.cxtStompBroker.getBean("brokerChannel", SubscribableChannel.class); <add> <add> ArgumentCaptor<MessageHandler> captor = ArgumentCaptor.forClass(MessageHandler.class); <add> verify(channel, times(2)).subscribe(captor.capture()); <add> <add> List<MessageHandler> values = captor.getAllValues(); <add> assertEquals(2, values.size()); <add> assertTrue(values.contains(cxtStompBroker.getBean(UserDestinationMessageHandler.class))); <add> assertTrue(values.contains(cxtStompBroker.getBean(StompBrokerRelayMessageHandler.class))); <add> } <add> <add> @Test <add> public void brokerChannelUsedByAnnotatedMethod() { <add> SubscribableChannel channel = this.cxtSimpleBroker.getBean("brokerChannel", SubscribableChannel.class); <add> AnnotationMethodMessageHandler messageHandler = this.cxtSimpleBroker.getBean(AnnotationMethodMessageHandler.class); <add> <add> StompHeaderAccessor headers = StompHeaderAccessor.create(StompCommand.SEND); <add> headers.setDestination("/foo"); <add> Message<?> message = MessageBuilder.withPayloadAndHeaders(new byte[0], headers).build(); <add> <add> when(channel.send(any(Message.class))).thenReturn(true); <add> messageHandler.handleMessage(message); <add> <add> ArgumentCaptor<Message> captor = ArgumentCaptor.forClass(Message.class); <add> verify(channel).send(captor.capture()); <add> message = captor.getValue(); <add> headers = StompHeaderAccessor.wrap(message); <add> <add> assertEquals(SimpMessageType.MESSAGE, headers.getMessageType()); <add> assertEquals("/bar", headers.getDestination()); <add> assertEquals("\"bar\"", new String((byte[]) message.getPayload())); <add> } <add> <add> @Test <add> public void brokerChannelUsedByUserDestinationMessageHandler() { <add> SubscribableChannel channel = this.cxtSimpleBroker.getBean("brokerChannel", SubscribableChannel.class); <add> UserDestinationMessageHandler messageHandler = this.cxtSimpleBroker.getBean(UserDestinationMessageHandler.class); <add> <add> this.cxtSimpleBroker.getBean(MutableUserQueueSuffixResolver.class).addQueueSuffix("joe", "s1", "s1"); <add> <add> StompHeaderAccessor headers = StompHeaderAccessor.create(StompCommand.SEND); <add> headers.setDestination("/user/joe/foo"); <add> Message<?> message = MessageBuilder.withPayloadAndHeaders(new byte[0], headers).build(); <add> <add> when(channel.send(any(Message.class))).thenReturn(true); <add> messageHandler.handleMessage(message); <add> <add> ArgumentCaptor<Message> captor = ArgumentCaptor.forClass(Message.class); <add> verify(channel).send(captor.capture()); <add> message = captor.getValue(); <add> headers = StompHeaderAccessor.wrap(message); <add> <add> assertEquals(SimpMessageType.MESSAGE, headers.getMessageType()); <add> assertEquals("/foos1", headers.getDestination()); <add> } <add> <add> <add> @Controller <add> static class TestController { <add> <add> @SubscribeEvent("/foo") <add> public String handleSubscribe() { <add> return "bar"; <add> } <add> <add> @MessageMapping("/foo") <add> @ReplyTo("/bar") <add> public String handleMessage() { <add> return "bar"; <add> } <add> } <add> <add> @Configuration <add> static class TestSimpleMessageBrokerConfig implements WebSocketMessageBrokerConfigurer { <add> <add> @Override <add> public void registerStompEndpoints(StompEndpointRegistry registry) { <add> registry.addEndpoint("/simpleBroker"); <add> } <add> <add> @Override <add> public void configureMessageBroker(MessageBrokerConfigurer configurer) { <add> // SimpleBroker used by default <add> } <add> <add> @Bean <add> public TestController subscriptionController() { <add> return new TestController(); <add> } <add> } <add> <add> @Configuration <add> static class TestStompMessageBrokerConfig implements WebSocketMessageBrokerConfigurer { <add> <add> @Override <add> public void registerStompEndpoints(StompEndpointRegistry registry) { <add> registry.addEndpoint("/stompBrokerRelay"); <add> } <add> <add> @Override <add> public void configureMessageBroker(MessageBrokerConfigurer configurer) { <add> configurer.enableStompBrokerRelay("/topic", "/queue").setAutoStartup(false); <add> } <add> } <add> <add> @Configuration <add> static class TestWebSocketMessageBrokerConfiguration extends DelegatingWebSocketMessageBrokerConfiguration { <add> <add> @Override <add> @Bean <add> public SubscribableChannel webSocketRequestChannel() { <add> return Mockito.mock(SubscribableChannel.class); <add> } <add> <add> @Override <add> @Bean <add> public SubscribableChannel webSocketResponseChannel() { <add> return Mockito.mock(SubscribableChannel.class); <add> } <add> <add> @Override <add> public SubscribableChannel brokerChannel() { <add> return Mockito.mock(SubscribableChannel.class); <add> } <add> } <add> <add>} <add><path>spring-messaging/src/test/java/org/springframework/messaging/simp/handler/AnnotationMethodIntegrationTests.java <del><path>spring-messaging/src/test/java/org/springframework/messaging/simp/config/WebSocketMessageBrokerConfigurationTests.java <ide> * limitations under the License. <ide> */ <ide> <del>package org.springframework.messaging.simp.config; <add>package org.springframework.messaging.simp.handler; <ide> <add>import java.lang.annotation.ElementType; <add>import java.lang.annotation.Retention; <add>import java.lang.annotation.RetentionPolicy; <add>import java.lang.annotation.Target; <ide> import java.util.Arrays; <add>import java.util.List; <add>import java.util.concurrent.CopyOnWriteArrayList; <ide> import java.util.concurrent.CountDownLatch; <ide> import java.util.concurrent.TimeUnit; <ide> <ide> import org.junit.runners.Parameterized.Parameters; <ide> import org.springframework.beans.factory.annotation.Autowired; <ide> import org.springframework.context.annotation.Bean; <add>import org.springframework.context.annotation.ComponentScan; <ide> import org.springframework.context.annotation.Configuration; <ide> import org.springframework.messaging.SubscribableChannel; <ide> import org.springframework.messaging.handler.annotation.MessageMapping; <add>import org.springframework.messaging.simp.config.DelegatingWebSocketMessageBrokerConfiguration; <add>import org.springframework.messaging.simp.config.MessageBrokerConfigurer; <add>import org.springframework.messaging.simp.config.StompEndpointRegistry; <add>import org.springframework.messaging.simp.config.WebSocketMessageBrokerConfigurer; <ide> import org.springframework.messaging.simp.stomp.StompCommand; <del>import org.springframework.messaging.simp.stomp.StompTextMessageBuilder; <ide> import org.springframework.messaging.support.channel.ExecutorSubscribableChannel; <ide> import org.springframework.stereotype.Controller; <ide> import org.springframework.web.socket.AbstractWebSocketIntegrationTests; <ide> import org.springframework.web.socket.JettyWebSocketTestServer; <ide> import org.springframework.web.socket.TextMessage; <ide> import org.springframework.web.socket.TomcatWebSocketTestServer; <del>import org.springframework.web.socket.WebSocketHandler; <ide> import org.springframework.web.socket.WebSocketSession; <ide> import org.springframework.web.socket.adapter.TextWebSocketHandlerAdapter; <ide> import org.springframework.web.socket.client.endpoint.StandardWebSocketClient; <ide> import org.springframework.web.socket.client.jetty.JettyWebSocketClient; <ide> import org.springframework.web.socket.server.HandshakeHandler; <del>import org.springframework.web.socket.server.config.WebSocketConfigurationSupport; <del>import org.springframework.web.socket.sockjs.transport.handler.WebSocketTransportHandler; <ide> <ide> import static org.junit.Assert.*; <add>import static org.springframework.messaging.simp.stomp.StompTextMessageBuilder.*; <ide> <ide> <ide> /** <del> * Test fixture for {@link WebSocketConfigurationSupport}. <del> * <add> * Integration tests with annotated message-handling methods. <ide> * @author Rossen Stoyanchev <ide> */ <ide> @RunWith(Parameterized.class) <del>public class WebSocketMessageBrokerConfigurationTests extends AbstractWebSocketIntegrationTests { <add>public class AnnotationMethodIntegrationTests extends AbstractWebSocketIntegrationTests { <ide> <ide> @Parameters <ide> public static Iterable<Object[]> arguments() { <ide> public static Iterable<Object[]> arguments() { <ide> <ide> @Override <ide> protected Class<?>[] getAnnotatedConfigClasses() { <del> return new Class<?>[] { TestWebSocketMessageBrokerConfiguration.class, SimpleBrokerConfigurer.class }; <add> return new Class<?>[] { TestMessageBrokerConfiguration.class, TestMessageBrokerConfigurer.class }; <ide> } <ide> <del> @Test <del> public void sendMessage() throws Exception { <ide> <del> final TextMessage textMessage = StompTextMessageBuilder.create(StompCommand.SEND) <del> .headers("destination:/app/foo").build(); <add> @Test <add> public void simpleController() throws Exception { <ide> <del> WebSocketHandler clientHandler = new TextWebSocketHandlerAdapter() { <del> @Override <del> public void afterConnectionEstablished(WebSocketSession session) throws Exception { <del> session.sendMessage(textMessage); <del> } <del> }; <add> TextMessage message = create(StompCommand.SEND).headers("destination:/app/simple").build(); <add> WebSocketSession session = doHandshake(new TestClientWebSocketHandler(message, 0), "/ws"); <ide> <del> TestController testController = this.wac.getBean(TestController.class); <add> SimpleController controller = this.wac.getBean(SimpleController.class); <add> assertTrue(controller.latch.await(2, TimeUnit.SECONDS)); <ide> <del> WebSocketSession session = this.webSocketClient.doHandshake(clientHandler, getWsBaseUrl() + "/ws"); <del> assertTrue(testController.latch.await(2, TimeUnit.SECONDS)); <ide> session.close(); <add> } <ide> <del> testController.latch = new CountDownLatch(1); <del> session = this.webSocketClient.doHandshake(clientHandler, getWsBaseUrl() + "/sockjs/websocket"); <del> assertTrue(testController.latch.await(2, TimeUnit.SECONDS)); <del> session.close(); <add> <add> @IntegrationTestController <add> static class SimpleController { <add> <add> private CountDownLatch latch = new CountDownLatch(1); <add> <add> @MessageMapping(value="/app/simple") <add> public void handle() { <add> this.latch.countDown(); <add> } <ide> } <ide> <add> private static class TestClientWebSocketHandler extends TextWebSocketHandlerAdapter { <ide> <del> @Configuration <del> static class TestWebSocketMessageBrokerConfiguration extends DelegatingWebSocketMessageBrokerConfiguration { <add> private final TextMessage messageToSend; <ide> <del> @Override <del> @Bean <del> public SubscribableChannel webSocketRequestChannel() { <del> return new ExecutorSubscribableChannel(); // synchronous <add> private final int expected; <add> <add> private final List<TextMessage> actual = new CopyOnWriteArrayList<TextMessage>(); <add> <add> private final CountDownLatch latch; <add> <add> <add> public TestClientWebSocketHandler(TextMessage messageToSend, int expectedNumberOfMessages) { <add> this.messageToSend = messageToSend; <add> this.expected = expectedNumberOfMessages; <add> this.latch = new CountDownLatch(this.expected); <ide> } <ide> <ide> @Override <del> @Bean <del> public SubscribableChannel webSocketReplyChannel() { <del> return new ExecutorSubscribableChannel(); // synchronous <add> public void afterConnectionEstablished(WebSocketSession session) throws Exception { <add> session.sendMessage(this.messageToSend); <ide> } <ide> <del> @Bean <del> public TestController testController() { <del> return new TestController(); <add> @Override <add> protected void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception { <add> this.actual.add(message); <add> this.latch.countDown(); <ide> } <ide> } <ide> <ide> @Configuration <del> static class SimpleBrokerConfigurer implements WebSocketMessageBrokerConfigurer { <add> @ComponentScan(basePackageClasses=AnnotationMethodIntegrationTests.class, <add> [email protected](IntegrationTestController.class)) <add> static class TestMessageBrokerConfigurer implements WebSocketMessageBrokerConfigurer { <ide> <ide> @Autowired <ide> private HandshakeHandler handshakeHandler; // can't rely on classpath for server detection <ide> <del> <ide> @Override <ide> public void registerStompEndpoints(StompEndpointRegistry registry) { <del> <del> registry.addEndpoint("/ws") <del> .setHandshakeHandler(this.handshakeHandler); <del> <del> registry.addEndpoint("/sockjs").withSockJS() <del> .setTransportHandlerOverrides(new WebSocketTransportHandler(this.handshakeHandler));; <add> registry.addEndpoint("/ws").setHandshakeHandler(this.handshakeHandler); <ide> } <ide> <ide> @Override <ide> public void configureMessageBroker(MessageBrokerConfigurer configurer) { <ide> configurer.setAnnotationMethodDestinationPrefixes("/app/"); <del> configurer.enableSimpleBroker("/topic"); <add> configurer.enableSimpleBroker("/topic", "/queue"); <ide> } <ide> } <ide> <del> @Controller <del> private static class TestController { <add> @Configuration <add> static class TestMessageBrokerConfiguration extends DelegatingWebSocketMessageBrokerConfiguration { <ide> <del> private CountDownLatch latch = new CountDownLatch(1); <add> @Override <add> @Bean <add> public SubscribableChannel webSocketRequestChannel() { <add> return new ExecutorSubscribableChannel(); // synchronous <add> } <ide> <del> @MessageMapping(value="/app/foo") <del> public void handleFoo() { <del> this.latch.countDown(); <add> @Override <add> @Bean <add> public SubscribableChannel webSocketResponseChannel() { <add> return new ExecutorSubscribableChannel(); // synchronous <ide> } <ide> } <ide> <add> @Target({ElementType.TYPE}) <add> @Retention(RetentionPolicy.RUNTIME) <add> @Controller <add> private @interface IntegrationTestController { <add> } <add> <ide> } <ide><path>spring-websocket/src/test/java/org/springframework/web/socket/AbstractWebSocketIntegrationTests.java <ide> protected String getWsBaseUrl() { <ide> return "ws://localhost:" + this.server.getPort(); <ide> } <ide> <add> protected WebSocketSession doHandshake(WebSocketHandler clientHandler, String endpointPath) { <add> return this.webSocketClient.doHandshake(clientHandler, getWsBaseUrl() + endpointPath); <add> } <add> <ide> <ide> static abstract class AbstractRequestUpgradeStrategyConfig { <ide>
13
Python
Python
add cinder support libcloud-874
c8d253f7c8e566aa29589b78236264946a3cade3
<ide><path>libcloud/compute/drivers/openstack.py <ide> def create_volume(self, size, name, location=None, snapshot=None, <ide> volume['snapshot_id'] = snapshot.id <ide> <ide> resp = self.volumev2_connection.request('/volumes', <del> method='POST', <del> data={'volume': volume}) <add> method='POST', <add> data={'volume': volume}) <ide> return self._to_volume(resp.object) <ide> <ide> def destroy_volume(self, volume): <ide> return self.volumev2_connection.request('/volumes/%s' % volume.id, <del> method='DELETE').success() <add> method='DELETE').success() <ide> <ide> def ex_list_snapshots(self): <ide> return self._to_snapshots( <ide> def create_volume_snapshot(self, volume, name=None, ex_description=None, <ide> if ex_description is not None: <ide> data['snapshot']['description'] = ex_description <ide> <del> return self._to_snapshot(self.volumev2_connection.request('/snapshots', <del> method='POST', <del> data=data).object) <add> return self._to_snapshot( <add> self.volumev2_connection.request('/snapshots', method='POST', <add> data=data).object) <ide> <ide> def destroy_volume_snapshot(self, snapshot): <ide> resp = self.volumev2_connection.request('/snapshots/%s' % snapshot.id, <del> method='DELETE') <add> method='DELETE') <ide> return resp.status == httplib.ACCEPTED <ide> <ide>
1
Javascript
Javascript
move register/unregister to core.controller
572b1c737ee20ad9e144976e60b2bb33444d74d0
<ide><path>src/core/core.controller.js <ide> Chart.instances = {}; <ide> <ide> Chart.registry = registry; <ide> <add>// @ts-ignore <add>const invalidatePlugins = () => each(Chart.instances, (chart) => chart._plugins.invalidate()); <add> <add>Chart.register = (...items) => { <add> registry.add(...items); <add> invalidatePlugins(); <add>}; <add>Chart.unregister = (...items) => { <add> registry.remove(...items); <add> invalidatePlugins(); <add>}; <add> <ide> export default Chart; <ide><path>src/index.js <ide> import registry from './core/core.registry'; <ide> import Scale from './core/core.scale'; <ide> import * as scales from './scales'; <ide> import Ticks from './core/core.ticks'; <del>import {each} from './helpers/helpers.core'; <del> <del>// @ts-ignore <del>const invalidatePlugins = () => each(Chart.instances, (chart) => chart._plugins.invalidate()); <del> <del>Chart.register = (...items) => { <del> registry.add(...items); <del> invalidatePlugins(); <del>}; <del>Chart.unregister = (...items) => { <del> registry.remove(...items); <del> invalidatePlugins(); <del>}; <ide> <ide> // Register built-ins <add>// @ts-ignore <ide> Chart.register(controllers, scales, elements, plugins); <ide> <ide> Chart.helpers = helpers;
2
Python
Python
invalidate _urls cache on register
822b85ac36818f0d8cb4b05f47ea5532b12a8d57
<ide><path>rest_framework/routers.py <ide> def register(self, prefix, viewset, basename=None, base_name=None): <ide> basename = self.get_default_basename(viewset) <ide> self.registry.append((prefix, viewset, basename)) <ide> <add> # invalidate the urls cache <add> if hasattr(self, '_urls'): <add> del self._urls <add> <ide> def get_default_basename(self, viewset): <ide> """ <ide> If `basename` is not specified, attempt to automatically determine <ide><path>tests/test_routers.py <ide> def test_multiple_action_handlers(self): <ide> response = self.client.delete(reverse('basic-action3', args=[1])) <ide> assert response.data == {'delete': '1'} <ide> <add> def test_register_after_accessing_urls(self): <add> self.router.register(r'notes', NoteViewSet) <add> assert len(self.router.urls) == 2 # list and detail <add> self.router.register(r'notes_bis', NoteViewSet) <add> assert len(self.router.urls) == 4 <add> <ide> <ide> class TestRootView(URLPatternsTestCase, TestCase): <ide> urlpatterns = [
2
Javascript
Javascript
fix calls to dns bindings in dns.js
3847add9436ce2eb080b9a91dd6955603ac6a714
<ide><path>lib/dns.js <del>process.binding('dns'); <add>var dns = process.binding('dns'); <ide> <ide> exports.resolve = function (domain, type_, callback_) { <ide> var type, callback; <ide> exports.resolve = function (domain, type_, callback_) { <ide> } <ide> } <ide> <del>exports.resolve4 = process.dns.resolve4; <del>exports.resolve6 = process.dns.resolve6; <del>exports.resolveMx = process.dns.resolveMx; <del>exports.resolveTxt = process.dns.resolveTxt; <del>exports.resolveSrv = process.dns.resolveSrv; <del>exports.reverse = process.dns.reverse; <add>exports.resolve4 = dns.resolve4; <add>exports.resolve6 = dns.resolve6; <add>exports.resolveMx = dns.resolveMx; <add>exports.resolveTxt = dns.resolveTxt; <add>exports.resolveSrv = dns.resolveSrv; <add>exports.reverse = dns.reverse; <ide> <ide> // ERROR CODES <ide> <ide> // timeout, SERVFAIL or similar. <del>exports.TEMPFAIL = process.dns.TEMPFAIL; <add>exports.TEMPFAIL = dns.TEMPFAIL; <ide> <ide> // got garbled reply. <del>exports.PROTOCOL = process.dns.PROTOCOL; <add>exports.PROTOCOL = dns.PROTOCOL; <ide> <ide> // domain does not exists. <del>exports.NXDOMAIN = process.dns.NXDOMAIN; <add>exports.NXDOMAIN = dns.NXDOMAIN; <ide> <ide> // domain exists but no data of reqd type. <del>exports.NODATA = process.dns.NODATA; <add>exports.NODATA = dns.NODATA; <ide> <ide> // out of memory while processing. <del>exports.NOMEM = process.dns.NOMEM; <add>exports.NOMEM = dns.NOMEM; <ide> <ide> // the query is malformed. <del>exports.BADQUERY = process.dns.BADQUERY; <add>exports.BADQUERY = dns.BADQUERY; <ide> <ide> var resolveMap = { <ide> 'A': exports.resolve4,
1
Java
Java
introduce entitymanager initialization callbacks
9bf7ff23c02f68e492f377a0781eb607e7515440
<ide><path>spring-orm/src/main/java/org/springframework/orm/hibernate5/HibernateTransactionManager.java <ide> /* <del> * Copyright 2002-2019 the original author or authors. <add> * Copyright 2002-2020 the original author or authors. <ide> * <ide> * Licensed under the Apache License, Version 2.0 (the "License"); <ide> * you may not use this file except in compliance with the License. <ide> <ide> import java.sql.Connection; <ide> import java.sql.ResultSet; <add>import java.util.function.Consumer; <ide> <ide> import javax.persistence.PersistenceException; <ide> import javax.sql.DataSource; <ide> public class HibernateTransactionManager extends AbstractPlatformTransactionMana <ide> <ide> private boolean hibernateManagedSession = false; <ide> <add> @Nullable <add> private Consumer<Session> sessionInitializer; <add> <ide> @Nullable <ide> private Object entityInterceptor; <ide> <ide> public void setHibernateManagedSession(boolean hibernateManagedSession) { <ide> this.hibernateManagedSession = hibernateManagedSession; <ide> } <ide> <add> /** <add> * Specify a callback for customizing every Hibernate {@code Session} resource <add> * created for a new transaction managed by this {@code HibernateTransactionManager}. <add> * <p>This enables convenient customizations for application purposes, e.g. <add> * setting Hibernate filters. <add> * @since 5.3 <add> */ <add> public void setSessionInitializer(Consumer<Session> sessionInitializer) { <add> this.sessionInitializer = sessionInitializer; <add> } <add> <ide> /** <ide> * Set the bean name of a Hibernate entity interceptor that allows to inspect <ide> * and change property values before writing to and reading from the database. <ide> protected void doBegin(Object transaction, TransactionDefinition definition) { <ide> Session newSession = (entityInterceptor != null ? <ide> obtainSessionFactory().withOptions().interceptor(entityInterceptor).openSession() : <ide> obtainSessionFactory().openSession()); <add> if (this.sessionInitializer != null) { <add> this.sessionInitializer.accept(session); <add> } <ide> if (logger.isDebugEnabled()) { <ide> logger.debug("Opened new Session [" + newSession + "] for Hibernate transaction"); <ide> } <ide><path>spring-orm/src/main/java/org/springframework/orm/jpa/AbstractEntityManagerFactoryBean.java <ide> /* <del> * Copyright 2002-2018 the original author or authors. <add> * Copyright 2002-2020 the original author or authors. <ide> * <ide> * Licensed under the Apache License, Version 2.0 (the "License"); <ide> * you may not use this file except in compliance with the License. <ide> import java.util.Set; <ide> import java.util.concurrent.ExecutionException; <ide> import java.util.concurrent.Future; <add>import java.util.function.Consumer; <ide> <ide> import javax.persistence.EntityManager; <ide> import javax.persistence.EntityManagerFactory; <ide> public abstract class AbstractEntityManagerFactoryBean implements <ide> @Nullable <ide> private JpaVendorAdapter jpaVendorAdapter; <ide> <add> @Nullable <add> private Consumer<EntityManager> entityManagerInitializer; <add> <ide> @Nullable <ide> private AsyncTaskExecutor bootstrapExecutor; <ide> <ide> public String getPersistenceUnitName() { <ide> * {@code Persistence.createEntityManagerFactory} (if any). <ide> * <p>Can be populated with a String "value" (parsed via PropertiesEditor) or a <ide> * "props" element in XML bean definitions. <del> * @see javax.persistence.Persistence#createEntityManagerFactory(String, java.util.Map) <del> * @see javax.persistence.spi.PersistenceProvider#createContainerEntityManagerFactory(javax.persistence.spi.PersistenceUnitInfo, java.util.Map) <add> * @see javax.persistence.Persistence#createEntityManagerFactory(String, Map) <add> * @see javax.persistence.spi.PersistenceProvider#createContainerEntityManagerFactory(PersistenceUnitInfo, Map) <ide> */ <ide> public void setJpaProperties(Properties jpaProperties) { <ide> CollectionUtils.mergePropertiesIntoMap(jpaProperties, this.jpaPropertyMap); <ide> public void setJpaProperties(Properties jpaProperties) { <ide> * Specify JPA properties as a Map, to be passed into <ide> * {@code Persistence.createEntityManagerFactory} (if any). <ide> * <p>Can be populated with a "map" or "props" element in XML bean definitions. <del> * @see javax.persistence.Persistence#createEntityManagerFactory(String, java.util.Map) <del> * @see javax.persistence.spi.PersistenceProvider#createContainerEntityManagerFactory(javax.persistence.spi.PersistenceUnitInfo, java.util.Map) <add> * @see javax.persistence.Persistence#createEntityManagerFactory(String, Map) <add> * @see javax.persistence.spi.PersistenceProvider#createContainerEntityManagerFactory(PersistenceUnitInfo, Map) <ide> */ <ide> public void setJpaPropertyMap(@Nullable Map<String, ?> jpaProperties) { <ide> if (jpaProperties != null) { <ide> public JpaVendorAdapter getJpaVendorAdapter() { <ide> return this.jpaVendorAdapter; <ide> } <ide> <add> /** <add> * Specify a callback for customizing every {@code EntityManager} created <add> * by the exposed {@code EntityManagerFactory}. <add> * <p>This is an alternative to a {@code JpaVendorAdapter}-level <add> * {@code postProcessEntityManager} implementation, enabling convenient <add> * customizations for application purposes, e.g. setting Hibernate filters. <add> * @since 5.3 <add> * @see JpaVendorAdapter#postProcessEntityManager <add> * @see JpaTransactionManager#setEntityManagerInitializer <add> */ <add> public void setEntityManagerInitializer(Consumer<EntityManager> entityManagerInitializer) { <add> this.entityManagerInitializer = entityManagerInitializer; <add> } <add> <ide> /** <ide> * Specify an asynchronous executor for background bootstrapping, <ide> * e.g. a {@link org.springframework.core.task.SimpleAsyncTaskExecutor}. <ide> else if (method.getName().equals("createEntityManager") && args != null && args. <ide> EntityManager rawEntityManager = (args.length > 1 ? <ide> getNativeEntityManagerFactory().createEntityManager((Map<?, ?>) args[1]) : <ide> getNativeEntityManagerFactory().createEntityManager()); <add> postProcessEntityManager(rawEntityManager); <ide> return ExtendedEntityManagerCreator.createApplicationManagedEntityManager(rawEntityManager, this, true); <ide> } <ide> <ide> else if (method.getName().equals("createEntityManager") && args != null && args. <ide> if (retVal instanceof EntityManager) { <ide> // Any other createEntityManager variant - expecting non-synchronized semantics <ide> EntityManager rawEntityManager = (EntityManager) retVal; <add> postProcessEntityManager(rawEntityManager); <ide> retVal = ExtendedEntityManagerCreator.createApplicationManagedEntityManager(rawEntityManager, this, false); <ide> } <ide> return retVal; <ide> public EntityManagerFactory getNativeEntityManagerFactory() { <ide> } <ide> } <ide> <add> @Override <add> public EntityManager createNativeEntityManager(@Nullable Map<?, ?> properties) { <add> EntityManager rawEntityManager = (!CollectionUtils.isEmpty(properties) ? <add> getNativeEntityManagerFactory().createEntityManager(properties) : <add> getNativeEntityManagerFactory().createEntityManager()); <add> postProcessEntityManager(rawEntityManager); <add> return rawEntityManager; <add> } <add> <add> /** <add> * Optional callback for post-processing the native EntityManager <add> * before active use. <add> * <p>The default implementation delegates to <add> * {@link JpaVendorAdapter#postProcessEntityManager}, if available. <add> * @param rawEntityManager the EntityManager to post-process <add> * @since 5.3 <add> * @see #createNativeEntityManager <add> * @see JpaVendorAdapter#postProcessEntityManager <add> */ <add> protected void postProcessEntityManager(EntityManager rawEntityManager) { <add> JpaVendorAdapter jpaVendorAdapter = getJpaVendorAdapter(); <add> if (jpaVendorAdapter != null) { <add> jpaVendorAdapter.postProcessEntityManager(rawEntityManager); <add> } <add> Consumer<EntityManager> customizer = this.entityManagerInitializer; <add> if (customizer != null) { <add> customizer.accept(rawEntityManager); <add> } <add> } <add> <ide> @Override <ide> @Nullable <ide> public PersistenceUnitInfo getPersistenceUnitInfo() { <ide><path>spring-orm/src/main/java/org/springframework/orm/jpa/EntityManagerFactoryInfo.java <ide> /* <del> * Copyright 2002-2012 the original author or authors. <add> * Copyright 2002-2020 the original author or authors. <ide> * <ide> * Licensed under the Apache License, Version 2.0 (the "License"); <ide> * you may not use this file except in compliance with the License. <ide> <ide> package org.springframework.orm.jpa; <ide> <add>import java.util.Map; <add> <ide> import javax.persistence.EntityManager; <ide> import javax.persistence.EntityManagerFactory; <ide> import javax.persistence.spi.PersistenceProvider; <ide> */ <ide> public interface EntityManagerFactoryInfo { <ide> <del> /** <del> * Return the raw underlying EntityManagerFactory. <del> * @return the unadorned EntityManagerFactory (never {@code null}) <del> */ <del> EntityManagerFactory getNativeEntityManagerFactory(); <del> <ide> /** <ide> * Return the underlying PersistenceProvider that the underlying <ide> * EntityManagerFactory was created with. <ide> public interface EntityManagerFactoryInfo { <ide> */ <ide> ClassLoader getBeanClassLoader(); <ide> <add> /** <add> * Return the raw underlying EntityManagerFactory. <add> * @return the unadorned EntityManagerFactory (never {@code null}) <add> */ <add> EntityManagerFactory getNativeEntityManagerFactory(); <add> <add> /** <add> * Create a native JPA EntityManager to be used as the framework-managed <add> * resource behind an application-level EntityManager handle. <add> * <p>This exposes a native {@code EntityManager} from the underlying <add> * {@link #getNativeEntityManagerFactory() native EntityManagerFactory}, <add> * taking {@link JpaVendorAdapter#postProcessEntityManager(EntityManager)} <add> * into account. <add> * @since 5.3 <add> * @see #getNativeEntityManagerFactory() <add> * @see EntityManagerFactory#createEntityManager() <add> */ <add> EntityManager createNativeEntityManager(@Nullable Map<?, ?> properties); <add> <ide> } <ide><path>spring-orm/src/main/java/org/springframework/orm/jpa/ExtendedEntityManagerCreator.java <ide> public static EntityManager createContainerManagedEntityManager( <ide> Assert.notNull(emf, "EntityManagerFactory must not be null"); <ide> if (emf instanceof EntityManagerFactoryInfo) { <ide> EntityManagerFactoryInfo emfInfo = (EntityManagerFactoryInfo) emf; <del> EntityManagerFactory nativeEmf = emfInfo.getNativeEntityManagerFactory(); <del> EntityManager rawEntityManager = (!CollectionUtils.isEmpty(properties) ? <del> nativeEmf.createEntityManager(properties) : nativeEmf.createEntityManager()); <add> EntityManager rawEntityManager = emfInfo.createNativeEntityManager(properties); <ide> return createProxy(rawEntityManager, emfInfo, true, synchronizedWithTransaction); <ide> } <ide> else { <ide><path>spring-orm/src/main/java/org/springframework/orm/jpa/JpaTransactionManager.java <ide> import java.util.HashMap; <ide> import java.util.Map; <ide> import java.util.Properties; <add>import java.util.function.Consumer; <ide> <ide> import javax.persistence.EntityManager; <ide> import javax.persistence.EntityManagerFactory; <ide> public class JpaTransactionManager extends AbstractPlatformTransactionManager <ide> <ide> private JpaDialect jpaDialect = new DefaultJpaDialect(); <ide> <add> @Nullable <add> private Consumer<EntityManager> entityManagerInitializer; <add> <ide> <ide> /** <ide> * Create a new JpaTransactionManager instance. <ide> public JpaDialect getJpaDialect() { <ide> return this.jpaDialect; <ide> } <ide> <add> /** <add> * Specify a callback for customizing every {@code EntityManager} resource <add> * created for a new transaction managed by this {@code JpaTransactionManager}. <add> * <p>This is an alternative to a factory-level {@code EntityManager} customizer <add> * and to a {@code JpaVendorAdapter}-level {@code postProcessEntityManager} <add> * callback, enabling specific customizations of transactional resources. <add> * @since 5.3 <add> * @see #createEntityManagerForTransaction() <add> * @see AbstractEntityManagerFactoryBean#setEntityManagerInitializer <add> * @see JpaVendorAdapter#postProcessEntityManager <add> */ <add> public void setEntityManagerInitializer(Consumer<EntityManager> entityManagerInitializer) { <add> this.entityManagerInitializer = entityManagerInitializer; <add> } <add> <ide> /** <ide> * Retrieves an EntityManagerFactory by persistence unit name, if none set explicitly. <ide> * Falls back to a default EntityManagerFactory bean if no persistence unit specified. <ide> protected void doBegin(Object transaction, TransactionDefinition definition) { <ide> EntityManager em = txObject.getEntityManagerHolder().getEntityManager(); <ide> <ide> // Delegate to JpaDialect for actual transaction begin. <del> final int timeoutToUse = determineTimeout(definition); <add> int timeoutToUse = determineTimeout(definition); <ide> Object transactionData = getJpaDialect().beginTransaction(em, <ide> new JpaTransactionDefinition(definition, timeoutToUse, txObject.isNewEntityManagerHolder())); <ide> txObject.setTransactionData(transactionData); <ide> protected void doBegin(Object transaction, TransactionDefinition definition) { <ide> /** <ide> * Create a JPA EntityManager to be used for a transaction. <ide> * <p>The default implementation checks whether the EntityManagerFactory <del> * is a Spring proxy and unwraps it first. <add> * is a Spring proxy and delegates to <add> * {@link EntityManagerFactoryInfo#createNativeEntityManager} <add> * if possible which in turns applies <add> * {@link JpaVendorAdapter#postProcessEntityManager(EntityManager)}. <ide> * @see javax.persistence.EntityManagerFactory#createEntityManager() <del> * @see EntityManagerFactoryInfo#getNativeEntityManagerFactory() <ide> */ <ide> protected EntityManager createEntityManagerForTransaction() { <ide> EntityManagerFactory emf = obtainEntityManagerFactory(); <add> Map<String, Object> properties = getJpaPropertyMap(); <add> EntityManager em; <ide> if (emf instanceof EntityManagerFactoryInfo) { <del> emf = ((EntityManagerFactoryInfo) emf).getNativeEntityManagerFactory(); <add> em = ((EntityManagerFactoryInfo) emf).createNativeEntityManager(properties); <ide> } <del> Map<String, Object> properties = getJpaPropertyMap(); <del> return (!CollectionUtils.isEmpty(properties) ? <del> emf.createEntityManager(properties) : emf.createEntityManager()); <add> else { <add> em = (!CollectionUtils.isEmpty(properties) ? <add> emf.createEntityManager(properties) : emf.createEntityManager()); <add> } <add> if (this.entityManagerInitializer != null) { <add> this.entityManagerInitializer.accept(em); <add> } <add> return em; <ide> } <ide> <ide> /** <ide><path>spring-orm/src/main/java/org/springframework/orm/jpa/JpaVendorAdapter.java <ide> /* <del> * Copyright 2002-2017 the original author or authors. <add> * Copyright 2002-2020 the original author or authors. <ide> * <ide> * Licensed under the Apache License, Version 2.0 (the "License"); <ide> * you may not use this file except in compliance with the License. <ide> default Class<? extends EntityManager> getEntityManagerInterface() { <ide> default void postProcessEntityManagerFactory(EntityManagerFactory emf) { <ide> } <ide> <add> /** <add> * Optional callback for post-processing the native EntityManager <add> * before active use. <add> * <p>This can be used for setting vendor-specific parameters, e.g. <add> * Hibernate filters, on every new EntityManager. <add> * @since 5.3 <add> */ <add> default void postProcessEntityManager(EntityManager em) { <add> } <add> <ide> } <ide><path>spring-orm/src/main/java/org/springframework/orm/jpa/vendor/AbstractJpaVendorAdapter.java <ide> /* <del> * Copyright 2002-2018 the original author or authors. <add> * Copyright 2002-2020 the original author or authors. <ide> * <ide> * Licensed under the Apache License, Version 2.0 (the "License"); <ide> * you may not use this file except in compliance with the License. <ide> public Class<? extends EntityManager> getEntityManagerInterface() { <ide> public void postProcessEntityManagerFactory(EntityManagerFactory emf) { <ide> } <ide> <add> @Override <add> public void postProcessEntityManager(EntityManager em) { <add> } <add> <ide> } <ide><path>spring-orm/src/test/java/org/springframework/orm/jpa/support/PersistenceInjectionTests.java <ide> /* <del> * Copyright 2002-2019 the original author or authors. <add> * Copyright 2002-2020 the original author or authors. <ide> * <ide> * Licensed under the Apache License, Version 2.0 (the "License"); <ide> * you may not use this file except in compliance with the License. <ide> public void testPrivateVendorSpecificPersistenceContextField() { <ide> } <ide> <ide> @Test <del> public void testPublicExtendedPersistenceContextSetter() throws Exception { <add> public void testPublicExtendedPersistenceContextSetter() { <ide> EntityManager mockEm = mock(EntityManager.class); <ide> given(mockEmf.createEntityManager()).willReturn(mockEm); <ide> <ide> public void testPublicExtendedPersistenceContextSetter() throws Exception { <ide> } <ide> <ide> @Test <del> public void testPublicSpecificExtendedPersistenceContextSetter() throws Exception { <add> public void testPublicSpecificExtendedPersistenceContextSetter() { <ide> EntityManagerFactory mockEmf2 = mock(EntityManagerFactory.class); <ide> EntityManager mockEm2 = mock(EntityManager.class); <ide> given(mockEmf2.createEntityManager()).willReturn(mockEm2); <ide> public void testPublicExtendedPersistenceContextSetterWithSerialization() throws <ide> } <ide> <ide> @Test <del> @SuppressWarnings({ "unchecked", "rawtypes" }) <add> @SuppressWarnings({"unchecked", "rawtypes"}) <ide> public void testPublicExtendedPersistenceContextSetterWithEntityManagerInfoAndSerialization() throws Exception { <ide> EntityManager mockEm = mock(EntityManager.class, withSettings().serializable()); <ide> given(mockEm.isOpen()).willReturn(true); <ide> EntityManagerFactoryWithInfo mockEmf = mock(EntityManagerFactoryWithInfo.class); <del> given(mockEmf.getNativeEntityManagerFactory()).willReturn(mockEmf); <ide> given(mockEmf.getJpaDialect()).willReturn(new DefaultJpaDialect()); <del> given(mockEmf.getEntityManagerInterface()).willReturn((Class)EntityManager.class); <add> given(mockEmf.getEntityManagerInterface()).willReturn((Class) EntityManager.class); <ide> given(mockEmf.getBeanClassLoader()).willReturn(getClass().getClassLoader()); <del> given(mockEmf.createEntityManager()).willReturn(mockEm); <add> given(mockEmf.createNativeEntityManager(null)).willReturn(mockEm); <ide> <ide> GenericApplicationContext gac = new GenericApplicationContext(); <ide> gac.getDefaultListableBeanFactory().registerSingleton("entityManagerFactory", mockEmf);
8
PHP
PHP
add support for themes + cells
d1300885f0705376ee600d4d1a786fb10bdae155
<ide><path>src/View/Cell.php <ide> abstract class Cell { <ide> */ <ide> public $viewClass = 'Cake\View\View'; <ide> <add>/** <add> * The theme name that will be used to render. <add> * <add> * @var string <add> */ <add> public $theme; <add> <ide> /** <ide> * Instance of the Cake\Event\EventManager this cell is using <ide> * to dispatch inner events. <ide> abstract class Cell { <ide> * @see \Cake\View\View <ide> */ <ide> protected $_validViewOptions = [ <del> 'viewVars', 'helpers', 'viewPath', 'plugin', <add> 'viewVars', 'helpers', 'viewPath', 'plugin', 'theme' <ide> ]; <ide> <ide> /** <ide><path>src/View/CellTrait.php <ide> public function cell($cell, $data = [], $options = []) { <ide> $cellInstance = new $className($this->request, $this->response, $this->getEventManager(), $options); <ide> $cellInstance->action = Inflector::underscore($action); <ide> $cellInstance->plugin = !empty($plugin) ? $plugin : null; <add> $cellInstance->theme = !empty($this->theme) ? $this->theme : null; <ide> $length = count($data); <ide> <ide> if ($length) { <ide><path>tests/TestCase/View/CellTest.php <ide> public function testCellManualRender() { <ide> $this->assertContains('<h2>Lorem ipsum</h2>', $cell->render('teaser_list')); <ide> } <ide> <add>/** <add> * Test rendering a cell with a theme. <add> * <add> * @return void <add> */ <add> public function testCellRenderThemed() { <add> $this->View->theme = 'TestTheme'; <add> $cell = $this->View->cell('Articles', ['msg' => 'hello world!']); <add> <add> $this->assertEquals($this->View->theme, $cell->theme); <add> $this->assertContains('Themed cell content.', $cell->render()); <add> $this->assertEquals($cell->View->theme, $cell->theme); <add> } <add> <ide> /** <ide> * Tests that using plugin's cells works. <ide> *
3
PHP
PHP
add missing import
49d2bb196d1e217c9332df11d33df31965f66563
<ide><path>tests/TestCase/Cache/Engine/WincacheEngineTest.php <ide> <ide> use Cake\Cache\Cache; <ide> use Cake\TestSuite\TestCase; <add>use DateInterval; <ide> <ide> /** <ide> * WincacheEngineTest class
1
Text
Text
fix syntac error
82637eae4528f97967870c3cd510b778d692b446
<ide><path>docs/docs/10.1-animation.md <ide> It is also possible to use custom class names for each of the steps in your tran <ide> ```javascript <ide> ... <ide> <ReactCSSTransitionGroup <del> transitionName={{ <add> transitionName={ { <ide> enter: 'enter', <ide> enterActive: 'enterActive', <ide> leave: 'leave', <ide> leaveActive: 'leaveActive', <ide> appear: 'appear', <ide> appearActive: 'appearActive' <del> }}> <add> } }> <ide> {item} <ide> </ReactCSSTransitionGroup> <ide> <ide> <ReactCSSTransitionGroup <del> transitionName={{ <add> transitionName={ { <ide> enter: 'enter', <ide> leave: 'leave', <ide> appear: 'appear' <del> }}> <add> } }> <ide> {item2} <ide> </ReactCSSTransitionGroup> <ide> ...
1
Go
Go
use tag service for pulling tagged reference
e4cf1c733677ff77e51101e2de542373b449b471
<ide><path>distribution/pull_v2.go <ide> func (p *v2Puller) pullV2Tag(ctx context.Context, ref reference.Named, platform <ide> } <ide> tagOrDigest = digested.Digest().String() <ide> } else if tagged, isTagged := ref.(reference.NamedTagged); isTagged { <del> manifest, err = manSvc.Get(ctx, "", distribution.WithTag(tagged.Tag())) <add> tagService := p.repo.Tags(ctx) <add> desc, err := tagService.Get(ctx, tagged.Tag()) <ide> if err != nil { <ide> return false, allowV1Fallback(err) <ide> } <add> <add> manifest, err = manSvc.Get(ctx, desc.Digest) <add> if err != nil { <add> return false, err <add> } <ide> tagOrDigest = tagged.Tag() <ide> } else { <ide> return false, fmt.Errorf("internal error: reference has neither a tag nor a digest: %s", reference.FamiliarString(ref))
1
PHP
PHP
replace foreach with in_array
80f51e7e15082abeb34ff147fad8f87896754652
<ide><path>src/Illuminate/Validation/Validator.php <ide> protected function validateMimes($attribute, $value, $parameters) <ide> // The Symfony File class should do a decent job of guessing the extension <ide> // based on the true MIME type so we'll just loop through the array of <ide> // extensions and compare it to the guessed extension of the files. <del> foreach ($parameters as $extension) <del> { <del> if ($value->guessExtension() == $extension) <del> { <del> return true; <del> } <del> } <del> <del> return false; <add> return in_array($value->guessExtension(), $parameters); <ide> } <ide> <ide> /**
1
PHP
PHP
apply fixes from styleci
f3a556927621bd745a6ca90e3a22063971c3d8c1
<ide><path>src/Illuminate/Routing/ImplicitRouteBinding.php <ide> namespace Illuminate\Routing; <ide> <ide> use Illuminate\Support\Str; <del>use Illuminate\Database\Eloquent\Model; <ide> use Illuminate\Contracts\Routing\UrlRoutable; <ide> use Illuminate\Database\Eloquent\ModelNotFoundException; <ide>
1
PHP
PHP
apply suggestions from code review
6f7a8eb65c39c30de59f58f9eab63159a72f2dc7
<ide><path>tests/TestCase/Database/Schema/MysqlSchemaTest.php <ide> public function testDescribeTable() <ide> if (ConnectionManager::get('test')->getDriver()->isMariadb()) { <ide> $expected['created_with_precision']['default'] = 'current_timestamp(3)'; <ide> $expected['created_with_precision']['comment'] = ''; <del> if (!empty($expected['collate'])) { <del> $expected['collate'] = 'utf8mb3_general_ci'; <del> } <add> $expected['title']['collate'] = 'utf8mb3_general_ci'; <add> $expected['body']['collate'] = 'utf8mb3_general_ci'; <ide> } <ide> <ide> $this->assertEquals(['id'], $result->getPrimaryKey());
1
PHP
PHP
add asserttimessent method to notificationfake
c0afae9c56a0caabb03ac8e6d222c2b32a58a8bf
<ide><path>src/Illuminate/Support/Testing/Fakes/NotificationFake.php <ide> public function assertNothingSent() <ide> PHPUnit::assertEmpty($this->notifications, 'Notifications were sent unexpectedly.'); <ide> } <ide> <add> /** <add> * Assert the total amount of times a notification was sent. <add> * <add> * @param int $expectedCount <add> * @param string $notification <add> * <add> * @return void <add> */ <add> public function assertTimesSent(int $expectedCount, string $notification) <add> { <add> $actualCount = collect($this->notifications) <add> ->flatten(1) <add> ->reduce(function ($count, $sent) use ($notification) { <add> return $count + count($sent[$notification] ?? []); <add> }, 0); <add> <add> PHPUnit::assertSame( <add> $expectedCount, <add> $actualCount, <add> "[{$notification}] was not sent as many times as expected." <add> ); <add> } <add> <ide> /** <ide> * Get all of the notifications matching a truth-test callback. <ide> * <ide><path>tests/Support/SupportTestingNotificationFakeTest.php <ide> public function testResettingNotificationId() <ide> $this->assertNotNull($notification->id); <ide> $this->assertNotSame($id, $notification->id); <ide> } <add> <add> public function testAssertTimesSent() <add> { <add> $this->fake->assertTimesSent(0, NotificationStub::class); <add> <add> $this->fake->send($this->user, new NotificationStub); <add> <add> $this->fake->send($this->user, new NotificationStub); <add> <add> $this->fake->send(new UserStub, new NotificationStub); <add> <add> $this->fake->assertTimesSent(3, NotificationStub::class); <add> } <ide> } <ide> <ide> class NotificationStub extends Notification
2
Ruby
Ruby
add method to define a root requirement
d477d1663acaee53ec73acf7e4c3a1b2fd256878
<ide><path>Library/Homebrew/formula.rb <ide> def with_logging(log_type) <ide> # </plist> <ide> # EOS <ide> # end</pre> <add> # <add> # @deprecated Please use {#service} instead <ide> def plist <ide> nil <ide> end <ide> def service_name <ide> # The generated launchd {.plist} file path. <ide> sig { returns(Pathname) } <ide> def plist_path <add> odeprecated "formula.plist_path", "formula.launchd_service_path" <add> launchd_service_path <add> end <add> <add> # The generated systemd {.service} file path. <add> sig { returns(Pathname) } <add> def launchd_service_path <ide> opt_prefix/"#{plist_name}.plist" <ide> end <ide> <ide> def patch(strip = :p1, src = nil, &block) <ide> # <ide> # Or perhaps you'd like to give the user a choice? Ooh fancy. <ide> # <pre>plist_options startup: true, manual: "foo start"</pre> <add> # <add> # @deprecated Please use {#service.require_root} instead <ide> def plist_options(options) <add> odeprecated "plist_options", "service.require_root" <ide> @plist_startup = options[:startup] <ide> @plist_manual = options[:manual] <ide> end <ide> def livecheck(&block) <ide> # Service can be used to define services. <ide> # This method evaluates the DSL specified in the service block of the <ide> # {Formula} (if it exists) and sets the instance variables of a Service <del> # object accordingly. This is used by `brew install` to generate a plist. <add> # object accordingly. This is used by `brew install` to generate a service file. <ide> # <ide> # <pre>service do <ide> # run [opt_bin/"foo"] <ide><path>Library/Homebrew/service.rb <ide> def keep_alive(value = nil) <ide> end <ide> end <ide> <add> sig { params(value: T.nilable(T::Boolean)).returns(T.nilable(T::Boolean)) } <add> def require_root(value = nil) <add> case T.unsafe(value) <add> when nil <add> @require_root <add> when true, false <add> @require_root = value <add> else <add> raise TypeError, "Service#require_root expects a Boolean" <add> end <add> end <add> <add> # Returns a `Boolean` describing if a service requires root access. <add> # @return [Boolean] <add> sig { returns(T::Boolean) } <add> def requires_root? <add> instance_eval(&@service_block) <add> @require_root.present? && @require_root == true <add> end <add> <ide> sig { params(value: T.nilable(String)).returns(T.nilable(T::Hash[Symbol, String])) } <ide> def sockets(value = nil) <ide> case T.unsafe(value) <ide><path>Library/Homebrew/test/formula_spec.rb <ide> <ide> expect(f.plist_name).to eq("homebrew.mxcl.formula_name") <ide> expect(f.service_name).to eq("homebrew.formula_name") <del> expect(f.plist_path).to eq(HOMEBREW_PREFIX/"opt/formula_name/homebrew.mxcl.formula_name.plist") <add> expect(f.launchd_service_path).to eq(HOMEBREW_PREFIX/"opt/formula_name/homebrew.mxcl.formula_name.plist") <ide> expect(f.systemd_service_path).to eq(HOMEBREW_PREFIX/"opt/formula_name/homebrew.formula_name.service") <ide> expect(f.systemd_timer_path).to eq(HOMEBREW_PREFIX/"opt/formula_name/homebrew.formula_name.timer") <ide> end <ide><path>Library/Homebrew/test/service_spec.rb <ide> def stub_formula(&block) <ide> end <ide> end <ide> <add> describe "#requires_root?" do <add> it "returns status when set" do <add> f = stub_formula do <add> service do <add> run opt_bin/"beanstalkd" <add> require_root true <add> end <add> end <add> <add> expect(f.service.requires_root?).to be(true) <add> end <add> <add> it "returns status when not set" do <add> f = stub_formula do <add> service do <add> run opt_bin/"beanstalkd" <add> end <add> end <add> <add> expect(f.service.requires_root?).to be(false) <add> end <add> end <add> <ide> describe "#run_type" do <ide> it "throws for unexpected type" do <ide> f = stub_formula do <ide> def stub_formula(&block) <ide> error_log_path var/"log/beanstalkd.error.log" <ide> log_path var/"log/beanstalkd.log" <ide> input_path var/"in/beanstalkd" <add> require_root true <ide> root_dir var <ide> working_dir var <ide> keep_alive true <ide> def stub_formula(&block) <ide> error_log_path var/"log/beanstalkd.error.log" <ide> log_path var/"log/beanstalkd.log" <ide> input_path var/"in/beanstalkd" <add> require_root true <ide> root_dir var <ide> working_dir var <ide> keep_alive true
4
Go
Go
implement the cmdadd instruction
6ae3800151025ff73a97c40af578ee714164003b
<ide><path>buildfile.go <ide> type buildFile struct { <ide> image string <ide> maintainer string <ide> config *Config <add> context string <ide> <ide> tmpContainers map[string]struct{} <ide> tmpImages map[string]struct{} <ide> func (b *buildFile) CmdInsert(args string) error { <ide> } <ide> defer file.Body.Close() <ide> <add> b.config.Cmd = []string{"echo", "INSERT", sourceUrl, "in", destPath} <ide> cid, err := b.run() <ide> if err != nil { <ide> return err <ide> func (b *buildFile) CmdInsert(args string) error { <ide> return b.commit(cid) <ide> } <ide> <add>func (b *buildFile) CmdAdd(args string) error { <add> tmp := strings.SplitN(args, " ", 2) <add> if len(tmp) != 2 { <add> return fmt.Errorf("Invalid INSERT format") <add> } <add> orig := strings.Trim(tmp[0], " ") <add> dest := strings.Trim(tmp[1], " ") <add> <add> b.config.Cmd = []string{"echo", "PUSH", orig, "in", dest} <add> cid, err := b.run() <add> if err != nil { <add> return err <add> } <add> <add> container := b.runtime.Get(cid) <add> if container == nil { <add> return fmt.Errorf("Error while creating the container (CmdAdd)") <add> } <add> <add> if err := os.MkdirAll(path.Join(container.rwPath(), dest), 0700); err != nil { <add> return err <add> } <add> <add> if err := utils.CopyDirectory(path.Join(b.context, orig), path.Join(container.rwPath(), dest)); err != nil { <add> return err <add> } <add> <add> return b.commit(cid) <add>} <add> <ide> func (b *buildFile) run() (string, error) { <ide> if b.image == "" { <ide> return "", fmt.Errorf("Please provide a source image with `from` prior to run") <ide> func (b *buildFile) commit(id string) error { <ide> return fmt.Errorf("Please provide a source image with `from` prior to commit") <ide> } <ide> b.config.Image = b.image <del> <ide> if id == "" { <ide> cmd := b.config.Cmd <ide> b.config.Cmd = []string{"true"} <ide> func (b *buildFile) commit(id string) error { <ide> } <ide> <ide> func (b *buildFile) Build(dockerfile, context io.Reader) (string, error) { <del> b.out = os.Stdout <del> <ide> defer b.clearTmp(b.tmpContainers, b.tmpImages) <add> <add> if context != nil { <add> name, err := ioutil.TempDir("/tmp", "docker-build") <add> if err != nil { <add> return "", err <add> } <add> if err := Untar(context, name); err != nil { <add> return "", err <add> } <add> defer os.RemoveAll(name) <add> b.context = name <add> } <ide> file := bufio.NewReader(dockerfile) <ide> for { <ide> line, err := file.ReadString('\n') <ide> func NewBuildFile(srv *Server, out io.Writer) BuildFile { <ide> runtime: srv.runtime, <ide> srv: srv, <ide> config: &Config{}, <add> out: out, <ide> tmpContainers: make(map[string]struct{}), <ide> tmpImages: make(map[string]struct{}), <ide> } <ide><path>commands.go <ide> func (cli *DockerCli) CmdBuild(args ...string) error { <ide> return nil <ide> } <ide> <del>func (cli *DockerCli) CmdBuildClient(args ...string) error { <del> cmd := Subcmd("build", "-|Dockerfile", "Build an image from Dockerfile or via stdin") <del> if err := cmd.Parse(args); err != nil { <del> return nil <del> } <del> var ( <del> file io.ReadCloser <del> err error <del> ) <del> <del> if cmd.NArg() == 0 { <del> file, err = os.Open("Dockerfile") <del> if err != nil { <del> return err <del> } <del> } else if cmd.Arg(0) == "-" { <del> file = os.Stdin <del> } else { <del> file, err = os.Open(cmd.Arg(0)) <del> if err != nil { <del> return err <del> } <del> } <del> if _, err := NewBuilderClient("0.0.0.0", 4243).Build(file, nil); err != nil { <del> return err <del> } <del> return nil <del>} <del> <ide> // 'docker login': login / register a user to registry service. <ide> func (cli *DockerCli) CmdLogin(args ...string) error { <ide> var readStringOnRawTerminal = func(stdin io.Reader, stdout io.Writer, echo bool) string { <ide><path>runtime_test.go <ide> func nuke(runtime *Runtime) error { <ide> return os.RemoveAll(runtime.root) <ide> } <ide> <del>func CopyDirectory(source, dest string) error { <del> if _, err := exec.Command("cp", "-ra", source, dest).Output(); err != nil { <del> return err <del> } <del> return nil <del>} <del> <ide> func layerArchive(tarfile string) (io.Reader, error) { <ide> // FIXME: need to close f somewhere <ide> f, err := os.Open(tarfile) <ide> func newTestRuntime() (*Runtime, error) { <ide> if err := os.Remove(root); err != nil { <ide> return nil, err <ide> } <del> if err := CopyDirectory(unitTestStoreBase, root); err != nil { <add> if err := utils.CopyDirectory(unitTestStoreBase, root); err != nil { <ide> return nil, err <ide> } <ide> <ide> func TestRestore(t *testing.T) { <ide> if err := os.Remove(root); err != nil { <ide> t.Fatal(err) <ide> } <del> if err := CopyDirectory(unitTestStoreBase, root); err != nil { <add> if err := utils.CopyDirectory(unitTestStoreBase, root); err != nil { <ide> t.Fatal(err) <ide> } <ide> <ide><path>utils/utils.go <ide> func GetKernelVersion() (*KernelVersionInfo, error) { <ide> }, nil <ide> } <ide> <add>func CopyDirectory(source, dest string) error { <add> if _, err := exec.Command("cp", "-ra", source, dest).Output(); err != nil { <add> return err <add> } <add> return nil <add>} <add> <ide> type NopFlusher struct{} <ide> <ide> func (f *NopFlusher) Flush() {}
4
Text
Text
remove duplicate test from catphotoapp step 23
3470ca57a304c8d0ac3792035db5b283f292b473
<ide><path>curriculum/challenges/english/14-responsive-web-design-22/learn-html-by-building-a-cat-photo-app/5dfb6a35eacea3f48c6300b4.md <ide> After the image nested in the `figure` element, add a `figcaption` element with <ide> <ide> # --hints-- <ide> <del>The Lasagna `img` element should be nested in the `figure` element. <del> <del>```js <del>assert( <del> document.querySelector('figure > img') && <del> document.querySelector('figure > img').getAttribute('src').toLowerCase() === <del> 'https://cdn.freecodecamp.org/curriculum/cat-photo-app/lasagna.jpg' <del>); <del>``` <del> <ide> Your `figcaption` element should have an opening tag. Opening tags have the following syntax: `<elementName>`. <ide> <ide> ```js
1
PHP
PHP
add strict_types to filesystem classes
7de2b92e1a7942e332a492d405bc0a321527a902
<ide><path>src/Filesystem/File.php <ide> <?php <add>declare(strict_types=1); <ide> /** <ide> * CakePHP(tm) : Rapid Development Framework (https://cakephp.org) <ide> * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org) <ide> public function info() <ide> /** <ide> * Returns the file extension. <ide> * <del> * @return string|false The file extension, false if extension cannot be extracted. <add> * @return string|null The file extension, false if extension cannot be extracted. <ide> */ <ide> public function ext() <ide> { <ide> public function ext() <ide> return $this->info['extension']; <ide> } <ide> <del> return false; <add> return null; <ide> } <ide> <ide> /** <ide> public function name() <ide> * @param string|null $ext The name of the extension <ide> * @return string the file basename. <ide> */ <del> protected static function _basename($path, $ext = null) <add> protected static function _basename(string $path, ?string $ext = null) <ide> { <ide> // check for multibyte string and use basename() if not found <ide> if (mb_strlen($path) === strlen($path)) { <ide> protected static function _basename($path, $ext = null) <ide> * @param string|null $ext The name of the extension to make safe if different from $this->ext <ide> * @return string The extension of the file <ide> */ <del> public function safe($name = null, $ext = null) <add> public function safe(?string $name = null, ?string $ext = null): string <ide> { <ide> if (!$name) { <ide> $name = $this->name; <ide> public function pwd() <ide> { <ide> if ($this->path === null) { <ide> $dir = $this->Folder->pwd(); <del> if (is_dir($dir)) { <add> if ($dir && is_dir($dir)) { <ide> $this->path = $this->Folder->slashTerm($dir) . $this->name; <ide> } <ide> } <ide> public function exists() <ide> { <ide> $this->clearStatCache(); <ide> <del> return (file_exists($this->path) && is_file($this->path)); <add> return ($this->path && file_exists($this->path) && is_file($this->path)); <ide> } <ide> <ide> /** <ide> public function mime() <ide> */ <ide> public function clearStatCache($all = false) <ide> { <del> if ($all === false) { <add> if ($all === false && $this->path) { <ide> clearstatcache(true, $this->path); <ide> } <ide> <ide><path>src/Filesystem/Folder.php <ide> <?php <add>declare(strict_types=1); <ide> /** <ide> * CakePHP(tm) : Rapid Development Framework (https://cakephp.org) <ide> * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org) <ide><path>tests/TestCase/Filesystem/FileTest.php <ide> <?php <add>declare(strict_types=1); <ide> /** <ide> * CakePHP(tm) : Rapid Development Framework (https://cakephp.org) <ide> * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org) <ide> public function testBasename($path, $suffix, $isRoot) <ide> // Check name() <ide> $splInfo = new SplFileInfo($path); <ide> $File->name = ltrim($splInfo->getFilename(), '/\\'); <add> $File->path = $path; <add> <ide> if ($suffix === null) { <del> $File->info();//to set and unset 'extension' in bellow <add> $File->info(); // to set and unset 'extension' in bellow <ide> unset($File->info['extension']); <ide> <ide> $this->assertEquals(basename($path), $File->name()); <ide><path>tests/TestCase/Filesystem/FolderTest.php <ide> <?php <add>declare(strict_types=1); <ide> /** <ide> * FolderTest file <ide> * <ide> public function testRecursiveCreateFailure() <ide> <ide> $path = TMP . 'tests/one'; <ide> mkdir($path, 0777, true); <del> chmod($path, '0444'); <add> chmod($path, 0444); <ide> <ide> try { <ide> $Folder = new Folder($path); <ide> public function testRecursiveCreateFailure() <ide> $this->assertInstanceOf('PHPUnit\Framework\Error\Error', $e); <ide> } <ide> <del> chmod($path, '0777'); <add> chmod($path, 0777); <ide> rmdir($path); <ide> } <ide>
4
Javascript
Javascript
change hotkeys to work across platforms
ab3a9076d90f17ee4d063495fd9f8df8b273cffd
<ide><path>client/src/templates/Challenges/classic/Editor.js <ide> class Editor extends Component { <ide> keybindings: [ <ide> /* eslint-disable no-bitwise */ <ide> monaco.KeyMod.chord( <del> monaco.KeyMod.CtrlCmd | monaco.KeyMod.Shift | monaco.KeyCode.PageDown <add> monaco.KeyMod.CtrlCmd | monaco.KeyMod.Shift | monaco.KeyCode.US_COMMA <ide> ) <ide> ], <ide> run: () => navigate(this.props.prevChallengePath) <ide> class Editor extends Component { <ide> keybindings: [ <ide> /* eslint-disable no-bitwise */ <ide> monaco.KeyMod.chord( <del> monaco.KeyMod.CtrlCmd | monaco.KeyMod.Shift | monaco.KeyCode.PageUp <add> monaco.KeyMod.CtrlCmd | monaco.KeyMod.Shift | monaco.KeyCode.US_DOT <ide> ) <ide> ], <ide> run: () => navigate(this.props.nextChallengePath) <ide><path>client/src/templates/Challenges/components/Challenge-Title.js <ide> import './challenge-title.css'; <ide> import GreenPass from '../../../assets/icons/GreenPass'; <ide> <ide> const keyMap = { <del> NAVIGATE_PREV: 'ctrl+shift+pagedown', <del> NAVIGATE_NEXT: 'ctrl+shift+pageup' <add> NAVIGATE_PREV: ['ctrl+shift+<', 'cmd+shift+<'], <add> NAVIGATE_NEXT: ['ctrl+shift+>', 'cmd+shift+>'] <ide> }; <ide> <ide> const propTypes = { <ide> function ChallengeTitle({ <ide> NAVIGATE_PREV: () => navigate(prevChallengePath), <ide> NAVIGATE_NEXT: () => navigate(nextChallengePath) <ide> }; <del> <ide> return ( <ide> <div className='challenge-title-wrap'> <ide> <GlobalHotKeys handlers={handlers} keyMap={keyMap} />
2
Text
Text
change key terms to their correct translation
1059098ac8c934bdd0f0f4a4ba55750da64ea469
<ide><path>guide/russian/machine-learning/supervised-learning/index.md <ide> --- <ide> title: Supervised Learning <del>localeTitle: Обучаемое обучение <add>localeTitle: Обучение с учителем <ide> --- <del>## Обучаемое обучение <add>## Обучение с учителем <ide> <del>В контролируемом обучении мы знаем, какой должен быть правильный результат. Контролируемые проблемы обучения могут быть отнесены к регрессии и классификации. Регрессионная проблема заключается в том, где вы сопоставляете ввод с непрерывным выходом. Напротив, проблема классификации - это то, где вы сопоставляете (группируете) входы с дискретными категориями. <add>В данном типе обучения мы знаем правильный результат. Основные два вида обучения с учителем - классификация и регрессия. При регрессии модель предсказывает число, при классификации - приписывает данным определенный лейбл. <ide> <ide> ### регрессия <ide> <ide> localeTitle: Обучаемое обучение <ide> <ide> > Учитывая данные о размерах домов на рынке недвижимости, попробуйте предсказать их цену. <ide> <del>Цена как функция размера - это непрерывный выход, поэтому это проблема регрессии. <add>Цена как функция размера - это число, поэтому в данном случае мы говорим о регрессии. <ide> <ide> #### Пример 2: <ide> <ide> localeTitle: Обучаемое обучение <ide> #### Предлагаемое чтение: <ide> <ide> * https://en.wikipedia.org/wiki/Supervised\_learning <del>* https://stackoverflow.com/a/1854449/6873133 <ide>\ No newline at end of file <add>* https://stackoverflow.com/a/1854449/6873133
1
Python
Python
add camembert for question answering for examples
47591763137f17021928e686ef171f25c240f076
<ide><path>src/transformers/__init__.py <ide> CamembertForSequenceClassification, <ide> CamembertForMultipleChoice, <ide> CamembertForTokenClassification, <add> CamembertForQuestionAnswering, <ide> CAMEMBERT_PRETRAINED_MODEL_ARCHIVE_MAP, <ide> ) <ide> from .modeling_encoder_decoder import PreTrainedEncoderDecoder
1
Javascript
Javascript
add test to dynamic enablement of trace-events
8e9121530711414586075186879ce3f7bada4125
<ide><path>test/parallel/test-trace-events-dynamic-enable.js <add>'use strict'; <add> <add>const common = require('../common'); <add> <add>common.skipIfInspectorDisabled(); <add> <add>const assert = require('assert'); <add>const { performance } = require('perf_hooks'); <add>const { Session } = require('inspector'); <add> <add>const session = new Session(); <add> <add>function post(message, data) { <add> return new Promise((resolve, reject) => { <add> session.post(message, data, (err, result) => { <add> if (err) <add> reject(new Error(JSON.stringify(err))); <add> else <add> resolve(result); <add> }); <add> }); <add>} <add> <add>async function test() { <add> session.connect(); <add> <add> let traceNotification = null; <add> let tracingComplete = false; <add> session.on('NodeTracing.dataCollected', (n) => traceNotification = n); <add> session.on('NodeTracing.tracingComplete', () => tracingComplete = true); <add> <add> // Generate a node.perf event before tracing is enabled. <add> performance.mark('mark1'); <add> <add> const traceConfig = { includedCategories: ['node.perf'] }; <add> await post('NodeTracing.start', { traceConfig }); <add> <add> // Generate a node.perf event after tracing is enabled. This should be the <add> // mark event captured. <add> performance.mark('mark2'); <add> <add> await post('NodeTracing.stop', { traceConfig }); <add> <add> performance.mark('mark3'); <add> <add> session.disconnect(); <add> <add> assert.ok(tracingComplete); <add> assert.ok(traceNotification); <add> assert.ok(traceNotification.data && traceNotification.data.value); <add> <add> const events = traceNotification.data.value; <add> const marks = events.filter((t) => null !== /node\.perf\.usertim/.exec(t.cat)); <add> assert.strictEqual(marks.length, 1); <add> assert.strictEqual(marks[0].name, 'mark2'); <add>} <add> <add>test();
1
PHP
PHP
fix failing test suite
a701e912e87d921429c3b9d605e8c4b9f0488d74
<ide><path>tests/TestCase/ORM/Behavior/TimestampBehaviorTest.php <ide> public function testUseImmutable() <ide> $entity = new Entity(); <ide> $event = new Event('Model.beforeSave'); <ide> <del> TypeFactory::build('timestamp')->useImmutable(); <ide> $entity->clean(); <ide> $this->Behavior->handleEvent($event, $entity); <ide> $this->assertInstanceOf('Cake\I18n\FrozenTime', $entity->modified); <ide> public function testUseImmutable() <ide> $entity->clean(); <ide> $this->Behavior->handleEvent($event, $entity); <ide> $this->assertInstanceOf('Cake\I18n\Time', $entity->modified); <add> // Revert back to using immutable class to avoid causing problems in <add> // other test cases when running full test suite. <add> TypeFactory::build('timestamp')->useImmutable(); <ide> } <ide> <ide> /**
1
Javascript
Javascript
remove misleading comment
04c1fbb0fa8cfa18c8b89985b777f37801660811
<ide><path>lib/net.js <ide> Socket.prototype._unrefTimer = function _unrefTimer() { <ide> <ide> // the user has called .end(), and all the bytes have been <ide> // sent out to the other side. <del>// If allowHalfOpen is false, or if the readable side has <del>// ended already, then destroy. <del>// If allowHalfOpen is true, then we need to do a shutdown, <del>// so that only the writable side will be cleaned up. <ide> function onSocketFinish() { <ide> // If still connecting - defer handling 'finish' until 'connect' will happen <ide> if (this.connecting) {
1
Ruby
Ruby
fix tests depending too deep
9e4c8b88584ba09c46abcd484969da6244416946
<ide><path>actionpack/lib/action_controller/response.rb <ide> def prepare! <ide> set_content_length! <ide> end <ide> <add> <ide> private <ide> def handle_conditional_get! <del> if body.is_a?(String) && headers['Status'][0..2] == '200' && !body.empty? <add> if body.is_a?(String) && (headers['Status'] ? headers['Status'][0..2] == '200' : true) && !body.empty? <ide> self.headers['ETag'] ||= %("#{Digest::MD5.hexdigest(body)}") <ide> self.headers['Cache-Control'] = 'private' if headers['Cache-Control'] == DEFAULT_HEADERS['Cache-Control'] <ide> <ide><path>actionpack/test/controller/action_pack_assertions_test.rb <ide> def setup <ide> <ide> def test_rendering_xml_sets_content_type <ide> assert_deprecated(/render/) { process :hello_xml_world } <del> assert_equal('application/xml; charset=utf-8', @controller.headers['Content-Type']) <add> assert_equal('application/xml; charset=utf-8', @response.headers['type']) <ide> end <ide> <ide> def test_rendering_xml_respects_content_type <del> @response.headers['Content-Type'] = 'application/pdf' <add> @response.headers['type'] = 'application/pdf' <ide> assert_deprecated(/render/) { process :hello_xml_world } <del> assert_equal('application/pdf; charset=utf-8', @controller.headers['Content-Type']) <add> assert_equal('application/pdf; charset=utf-8', @response.headers['type']) <ide> end <ide> <ide> <ide> def test_render_text_with_custom_content_type <ide> get :render_text_with_custom_content_type <del> assert_equal 'application/rss+xml; charset=utf-8', @response.headers['Content-Type'] <add> assert_equal 'application/rss+xml; charset=utf-8', @response.headers['type'] <ide> end <ide> end <ide><path>actionpack/test/controller/new_render_test.rb <ide> def test_render_text_with_assigns <ide> def test_update_page <ide> get :update_page <ide> assert_template nil <del> assert_equal 'text/javascript; charset=utf-8', @response.headers['Content-Type'] <add> assert_equal 'text/javascript; charset=utf-8', @response.headers['type'] <ide> assert_equal 2, @response.body.split($/).length <ide> end <ide> <ide> def test_update_page_with_instance_variables <ide> get :update_page_with_instance_variables <ide> assert_template nil <del> assert_equal 'text/javascript; charset=utf-8', @response.headers['Content-Type'] <add> assert_equal 'text/javascript; charset=utf-8', @response.headers['type'] <ide> assert_match /balance/, @response.body <ide> assert_match /\$37/, @response.body <ide> end <ide><path>actionpack/test/controller/send_file_test.rb <ide> def test_data <ide> <ide> def test_headers_after_send_shouldnt_include_charset <ide> response = process('data') <del> assert_equal "application/octet-stream", response.headers["Content-Type"] <add> assert_equal "application/octet-stream", response.content_type <ide> <ide> response = process('file') <del> assert_equal "application/octet-stream", response.headers["Content-Type"] <add> assert_equal "application/octet-stream", response.content_type <ide> end <ide> <ide> # Test that send_file_headers! is setting the correct HTTP headers. <ide> def test_send_file_headers! <ide> define_method "test_send_#{method}_status" do <ide> @controller.options = { :stream => false, :status => 500 } <ide> assert_nothing_raised { assert_not_nil process(method) } <del> assert_equal '500 Internal Server Error', @controller.headers['Status'] <add> assert_equal '500 Internal Server Error', @response.headers['Status'] <ide> end <ide> <ide> define_method "test_default_send_#{method}_status" do <ide> @controller.options = { :stream => false } <ide> assert_nothing_raised { assert_not_nil process(method) } <del> assert_equal ActionController::Base::DEFAULT_RENDER_STATUS_CODE, @controller.headers['Status'] <add> assert_equal ActionController::Base::DEFAULT_RENDER_STATUS_CODE, @response.headers['Status'] <ide> end <ide> end <ide> end
4
PHP
PHP
remove extra cast
46a7edb57fd35533d8465b6f865f60cf8d958ca7
<ide><path>src/Illuminate/Encryption/Encrypter.php <ide> public function __construct($key, $cipher = 'AES-128-CBC') <ide> */ <ide> protected function hasValidCipherAndKeyCombination($key, $cipher) <ide> { <del> $length = mb_strlen($key = (string) $key, '8bit'); <add> $length = mb_strlen($key, '8bit'); <ide> <ide> return ($cipher === 'AES-128-CBC' && ($length === 16 || $length === 32)) || <ide> ($cipher === 'AES-256-CBC' && $length === 32);
1
Javascript
Javascript
fix ie8 disabled input throwing on focus
6203e53d16be80db5661f5bd51947fec0dc083fb
<ide><path>src/browser/ReactInputSelection.js <ide> var ReactDOMSelection = require('ReactDOMSelection'); <ide> <ide> var containsNode = require('containsNode'); <add>var focusNode = require('focusNode'); <ide> var getActiveElement = require('getActiveElement'); <ide> <ide> function isInDocument(node) { <ide> var ReactInputSelection = { <ide> priorSelectionRange <ide> ); <ide> } <del> priorFocusedElem.focus(); <add> focusNode(priorFocusedElem); <ide> } <ide> }, <ide> <ide><path>src/browser/dom/components/AutoFocusMixin.js <ide> <ide> "use strict"; <ide> <add>var focusNode = require('focusNode'); <add> <ide> var AutoFocusMixin = { <ide> componentDidMount: function() { <ide> if (this.props.autoFocus) { <del> this.getDOMNode().focus(); <add> focusNode(this.getDOMNode()); <ide> } <ide> } <ide> };
2
Javascript
Javascript
fix variable typo. (i think.)
a9c64beaf3b745de8cb4f3bb961b95e6e4cabb25
<ide><path>examples/js/effects/VREffect.js <ide> THREE.VREffect = function ( renderer, onError ) { <ide> <ide> this.setSize = function ( width, height ) { <ide> <del> renderSize = { width: width, height: height }; <add> rendererSize = { width: width, height: height }; <ide> <ide> if ( isPresenting ) { <ide>
1
Javascript
Javascript
fix small typo
b45c91d3e760791f0307ddd74a76de4e7691f49f
<ide><path>Libraries/Lists/FlatList.js <ide> type DefaultProps = typeof defaultProps; <ide> * - By default, the list looks for a `key` prop on each item and uses that for the React key. <ide> * Alternatively, you can provide a custom `keyExtractor` prop. <ide> * <del> * Also inherets [ScrollView Props](docs/scrollview.html#props), unless it is nested in another FlatList of same orientation. <add> * Also inherits [ScrollView Props](docs/scrollview.html#props), unless it is nested in another FlatList of same orientation. <ide> */ <ide> class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> { <ide> static defaultProps: DefaultProps = defaultProps;
1
Text
Text
update export docs for selectlistview
0730c7902dd697637d4ec4a4e60ee5a5f54fa020
<ide><path>docs/README.md <ide> The classes available from `require 'atom'` are: <ide> * [Point][Point] <ide> * [Range][Range] <ide> * [ScrollView][ScrollView] <del> * [SelectList][SelectList] <add> * [SelectListView][SelectListView] <ide> * [View][View] <ide> * [WorkspaceView][WorkspaceView] <ide> <ide> Atom ships with node 0.11.10 and the comprehensive node API docs are available <ide> [Point]: ../classes/Point.html <ide> [Range]: ../classes/Range.html <ide> [ScrollView]: ../classes/ScrollView.html <del>[SelectList]: ../classes/SelectList.html <add>[SelectListView]: ../classes/SelectListView.html <ide> [View]: ../classes/View.html <ide> [WorkspaceView]: ../classes/WorkspaceView.html <ide> [creating-a-package]: https://www.atom.io/docs/latest/creating-a-package
1
Python
Python
use tensorflow ops for keras learningrateschedule
9d38e894ab525ffde639cd09e13a2a96550af753
<ide><path>official/resnet/keras/keras_common.py <ide> def on_batch_begin(self, batch, logs=None): <ide> 'change learning rate to %s.', self.epochs, batch, lr) <ide> <ide> <add>class PiecewiseConstantDecayWithWarmup( <add> tf.keras.optimizers.schedules.LearningRateSchedule): <add> """Piecewise constant decay with warmup schedule.""" <add> <add> def __init__(self, batch_size, epoch_size, warmup_epochs, boundaries, <add> multipliers, compute_lr_on_cpu=True, name=None): <add> super(PiecewiseConstantDecayWithWarmup, self).__init__() <add> if len(boundaries) != len(multipliers) - 1: <add> raise ValueError('The length of boundaries must be 1 less than the ' <add> 'length of multipliers') <add> <add> base_lr_batch_size = 256 <add> num_batches_per_epoch = epoch_size // batch_size <add> <add> self.rescaled_lr = BASE_LEARNING_RATE * batch_size / base_lr_batch_size <add> self.step_boundaries = [float(num_batches_per_epoch) * x <add> for x in boundaries] <add> self.lr_values = [self.rescaled_lr * m for m in multipliers] <add> self.warmup_steps = warmup_epochs * num_batches_per_epoch <add> self.compute_lr_on_cpu = compute_lr_on_cpu <add> self.name = name <add> <add> self.cached_learning_rate_op = None <add> <add> def __call__(self, step): <add> if tf.executing_eagerly(): <add> return self._get_learning_rate(step) <add> <add> # In an eager function or graph, the current implementation of optimizer <add> # repeatedly call and thus create ops for the learning rate schedule. To <add> # avoid this, we cache the ops if not executing eagerly. <add> if self.cached_learning_rate_op is None: <add> if self.compute_lr_on_cpu: <add> with tf.device('/device:CPU:0'): <add> self.cached_learning_rate_op = self._get_learning_rate(step) <add> else: <add> self.cached_learning_rate_op = self._get_learning_rate(step) <add> return self.cached_learning_rate_op <add> <add> def _get_learning_rate(self, step): <add> """Compute learning rate at given step.""" <add> with tf.name_scope(self.name, 'PiecewiseConstantDecayWithWarmup', [ <add> self.rescaled_lr, self.step_boundaries, self.lr_values, <add> self.warmup_steps, self.compute_lr_on_cpu]): <add> def warmup_lr(step): <add> return self.rescaled_lr * ( <add> tf.cast(step, tf.float32) / tf.cast(self.warmup_steps, tf.float32)) <add> def piecewise_lr(step): <add> return tf.compat.v1.train.piecewise_constant( <add> step, self.step_boundaries, self.lr_values) <add> return tf.cond(step < self.warmup_steps, <add> lambda: warmup_lr(step), <add> lambda: piecewise_lr(step)) <add> <add> def get_config(self): <add> return { <add> 'rescaled_lr': self.rescaled_lr, <add> 'step_boundaries': self.step_boundaries, <add> 'lr_values': self.lr_values, <add> 'warmup_steps': self.warmup_steps, <add> 'compute_lr_on_cpu': self.compute_lr_on_cpu, <add> 'name': self.name <add> } <add> <add> <ide> class ProfilerCallback(tf.keras.callbacks.Callback): <ide> """Save profiles in specified step range to log directory.""" <ide> <ide> def set_gpu_thread_mode_and_count(flags_obj): <ide> flags_obj.datasets_num_private_threads) <ide> <ide> <del>def get_optimizer(): <add>def get_optimizer(learning_rate=0.1): <ide> """Returns optimizer to use.""" <ide> # The learning_rate is overwritten at the beginning of each step by callback. <del> return gradient_descent_v2.SGD(learning_rate=0.1, momentum=0.9) <add> return gradient_descent_v2.SGD(learning_rate=learning_rate, momentum=0.9) <ide> <ide> <ide> def get_callbacks(learning_rate_schedule_fn, num_images): <ide> """Returns common callbacks.""" <ide> time_callback = keras_utils.TimeHistory(FLAGS.batch_size, FLAGS.log_steps) <del> lr_callback = LearningRateBatchScheduler( <del> learning_rate_schedule_fn, <del> batch_size=FLAGS.batch_size, <del> num_images=num_images) <del> callbacks = [time_callback, lr_callback] <add> callbacks = [time_callback] <add> <add> if not FLAGS.use_tensor_lr: <add> lr_callback = LearningRateBatchScheduler( <add> learning_rate_schedule_fn, <add> batch_size=FLAGS.batch_size, <add> num_images=num_images) <add> callbacks.append(lr_callback) <ide> <ide> if FLAGS.enable_tensorboard: <ide> tensorboard_callback = tf.keras.callbacks.TensorBoard( <ide> def define_keras_flags(): <ide> flags.DEFINE_boolean(name='skip_eval', default=False, help='Skip evaluation?') <ide> flags.DEFINE_boolean(name='use_trivial_model', default=False, <ide> help='Whether to use a trivial Keras model.') <add> flags.DEFINE_boolean(name='use_tensor_lr', default=False, <add> help='Use learning rate tensor instead of a callback.') <ide> flags.DEFINE_boolean( <ide> name='enable_xla', default=False, <ide> help='Whether to enable XLA auto jit compilation. This is still an ' <ide><path>official/resnet/keras/keras_imagenet_main.py <ide> def run(flags_obj): <ide> dtype=dtype, <ide> drop_remainder=drop_remainder) <ide> <add> lr_schedule = 0.1 <add> if flags_obj.use_tensor_lr: <add> lr_schedule = keras_common.PiecewiseConstantDecayWithWarmup( <add> batch_size=flags_obj.batch_size, <add> epoch_size=imagenet_main.NUM_IMAGES['train'], <add> warmup_epochs=LR_SCHEDULE[0][1], <add> boundaries=list(p[1] for p in LR_SCHEDULE[1:]), <add> multipliers=list(p[0] for p in LR_SCHEDULE), <add> compute_lr_on_cpu=True) <add> <ide> with strategy_scope: <del> optimizer = keras_common.get_optimizer() <add> optimizer = keras_common.get_optimizer(lr_schedule) <ide> if dtype == 'float16': <ide> # TODO(reedwm): Remove manually wrapping optimizer once mixed precision <ide> # can be enabled with a single line of code.
2
Javascript
Javascript
remove vestiges of previous _transform api
ea4f0b4a6b4c1785b1d112504a79ebf7d7f46e49
<ide><path>lib/_stream_transform.js <ide> Transform.prototype.push = function(chunk) { <ide> // Call `cb(err)` when you are done with this chunk. If you pass <ide> // an error, then that'll put the hurt on the whole operation. If you <ide> // never call cb(), then you'll never get another chunk. <del>Transform.prototype._transform = function(chunk, output, cb) { <add>Transform.prototype._transform = function(chunk, encoding, cb) { <ide> throw new Error('not implemented'); <ide> }; <ide> <ide> Transform.prototype._write = function(chunk, encoding, cb) { <ide> }; <ide> <ide> // Doesn't matter what the args are here. <del>// the output and callback functions passed to _transform do all the work. <add>// _transform does all the work. <ide> // That we got here means that the readable side wants more data. <ide> Transform.prototype._read = function(n) { <ide> var ts = this._transformState;
1
Text
Text
add the preferred name for @himself65
721fd012c04caeac304ae8094412e96df910645c
<ide><path>README.md <ide> For information about the governance of the Node.js project, see <ide> * [HarshithaKP](https://github.com/HarshithaKP) - <ide> **Harshitha K P** <<[email protected]>> (she/her) <ide> * [himself65](https://github.com/himself65) - <del> **Zeyu Yang** <<[email protected]>> (he/him) <add> **Zeyu "Alex" Yang** <<[email protected]>> (he/him) <ide> * [hiroppy](https://github.com/hiroppy) - <ide> **Yuta Hiroto** <<[email protected]>> (he/him) <ide> * [iansu](https://github.com/iansu) -
1
Javascript
Javascript
use compositetype in warning invariant for refs
06ea71d3fdd614e12c659c2f08f371c6b01fe880
<ide><path>src/renderers/shared/stack/reconciler/ReactCompositeComponent.js <ide> var ReactCompositeComponent = { <ide> if (__DEV__) { <ide> var componentName = component && component.getName ? <ide> component.getName() : 'a component'; <del> warning(publicComponentInstance != null, <add> warning( <add> publicComponentInstance != null || <add> component._compositeType !== CompositeTypes.StatelessFunctional, <ide> 'Stateless function components cannot be given refs ' + <ide> '(See ref "%s" in %s created by %s). ' + <ide> 'Attempts to access this ref will fail.', <ide><path>src/renderers/testing/__tests__/ReactTestRenderer-test.js <ide> describe('ReactTestRenderer', function() { <ide> expect(log).toEqual([null]); <ide> }); <ide> <add> it('warns correctly for refs on SFCs', function() { <add> spyOn(console, 'error'); <add> function Bar() { <add> return <div>Hello, world</div> <add> } <add> class Foo extends React.Component { <add> render() { <add> return <Bar ref="foo" /> <add> } <add> } <add> class Baz extends React.Component { <add> render() { <add> return <div ref="baz" /> <add> } <add> } <add> ReactTestRenderer.create(<Baz />); <add> ReactTestRenderer.create(<Foo />); <add> expect(console.error.calls.count()).toBe(1); <add> expect(console.error.calls.argsFor(0)[0]).toContain( <add> 'Stateless function components cannot be given refs ' + <add> '(See ref "foo" in Bar created by Foo). ' + <add> 'Attempts to access this ref will fail.' <add> ); <add> }); <add> <ide> it('supports error boundaries', function() { <ide> var log = []; <ide> class Angry extends React.Component {
2
Go
Go
use a map[string]struct{} for validopts
342f7a357ad00164c5f8130127ab54a1d823b1de
<ide><path>volume/local/local.go <ide> func validateOpts(opts map[string]string) error { <ide> return nil <ide> } <ide> for opt := range opts { <del> if !validOpts[opt] { <add> if _, ok := validOpts[opt]; !ok { <ide> return validationError(fmt.Sprintf("invalid option key: %q", opt)) <ide> } <ide> } <ide><path>volume/local/local_unix.go <ide> import ( <ide> var ( <ide> oldVfsDir = filepath.Join("vfs", "dir") <ide> <del> validOpts = map[string]bool{ <del> "type": true, // specify the filesystem type for mount, e.g. nfs <del> "o": true, // generic mount options <del> "device": true, // device to mount from <add> validOpts = map[string]struct{}{ <add> "type": {}, // specify the filesystem type for mount, e.g. nfs <add> "o": {}, // generic mount options <add> "device": {}, // device to mount from <ide> } <ide> mandatoryOpts = map[string]struct{}{ <ide> "device": {}, <ide><path>volume/local/local_windows.go <ide> import ( <ide> type optsConfig struct{} <ide> <ide> var ( <del> validOpts map[string]bool <add> validOpts map[string]struct{} <ide> mandatoryOpts map[string]struct{} <ide> ) <ide>
3
Text
Text
improve translation of spanish
5c59201546e5eec4e922d63d09dcfc75351d36f6
<ide><path>curriculum/challenges/spanish/02-javascript-algorithms-and-data-structures/javascript-algorithms-and-data-structures-projects/cash-register.spanish.md <ide> localeTitle: Caja registradora <ide> --- <ide> <ide> ## Description <del><section id="description"> Diseñe una función de cajón de la caja registradora <code>checkCashRegister()</code> que acepte el precio de compra como primer argumento ( <code>price</code> ), el pago como segundo argumento ( <code>cash</code> ) y el cajón de efectivo ( <code>cid</code> ) como tercer argumento. <code>cid</code> es una matriz 2D que muestra la moneda disponible. La función <code>checkCashRegister()</code> siempre debe devolver un objeto con una clave de <code>status</code> y una clave de <code>change</code> . Devuelva <code>{status: &quot;INSUFFICIENT_FUNDS&quot;, change: []}</code> si el cajón de efectivo es inferior al cambio debido, o si no puede devolver el cambio exacto. Devuelva <code>{status: &quot;CLOSED&quot;, change: [...]}</code> con cash-in-drawer como el valor para el <code>change</code> clave si es igual al cambio debido. De lo contrario, devuelva <code>{status: &quot;OPEN&quot;, change: [...]}</code> , con el cambio en monedas y billetes, ordenados de mayor a menor, como el valor de la clave de <code>change</code> . Recuerda usar <a href="http://forum.freecodecamp.org/t/how-to-get-help-when-you-are-stuck/19514" target="_blank">Read-Search-Ask</a> si te atascas. Trate de emparejar el programa. Escribe tu propio código. <table class="table table-striped"><tbody><tr><th> Unidad monetaria </th><th> Cantidad </th></tr><tr><td> Centavo </td><td> $ 0.01 (PENNY) </td></tr><tr><td> Níquel </td><td> $ 0.05 (níquel) </td></tr><tr><td> Moneda de diez centavos </td><td> $ 0.1 (DIME) </td></tr><tr><td> Trimestre </td><td> $ 0.25 (TRIMESTRE) </td></tr><tr><td> Dólar </td><td> $ 1 (DÓLAR) </td></tr><tr><td> Cinco dólares </td><td> $ 5 (CINCO) </td></tr><tr><td> Diez dólares </td><td> $ 10 (DIEZ) </td></tr><tr><td> Veinte dólares </td><td> $ 20 (VEINTE) </td></tr><tr><td> Cien dolares </td><td> $ 100 (100) </td></tr></tbody></table></section> <add><section id="description"> Diseñe una función de caja registradora <code>checkCashRegister()</code> que acepte el precio de compra como primer argumento ( <code>price</code> ), el pago como segundo argumento ( <code>cash</code> ) y el efectivo en caja ( <code>cid</code> ) como tercer argumento. <code>cid</code> es una matriz 2D que muestra el dinero disponible. La función <code>checkCashRegister()</code> siempre debe devolver un objeto con una clave de <code>status</code> y una clave de <code>change</code> . Devuelva <code>{status: &quot;INSUFFICIENT_FUNDS&quot;, change: []}</code> si el efectivo en caja es inferior al cambio debido, o si no puede devolver el cambio exacto. Devuelva <code>{status: &quot;CLOSED&quot;, change: [...]}</code> con <code>cid</code> como el valor para la clave <code>change</code> si este es igual al cambio debido. De lo contrario, devuelva <code>{status: &quot;OPEN&quot;, change: [...]}</code> , con el cambio en monedas y billetes, ordenados de mayor a menor, como el valor de la clave <code>change</code> . Recuerda usar <a href="http://forum.freecodecamp.org/t/how-to-get-help-when-you-are-stuck/19514" target="_blank">Read-Search-Ask</a> si te atascas. Trate de emparejar el programa. Escribe tu propio código. <table class="table table-striped"><tbody><tr><th> Unidad monetaria </th><th> Cantidad </th></tr><tr><td> Centavo </td><td> $ 0.01 (PENNY) </td></tr><tr><td> Níquel </td><td> $ 0.05 (níquel) </td></tr><tr><td> Moneda de diez centavos </td><td> $ 0.1 (DIME) </td></tr><tr><td> Trimestre </td><td> $ 0.25 (TRIMESTRE) </td></tr><tr><td> Dólar </td><td> $ 1 (DÓLAR) </td></tr><tr><td> Cinco dólares </td><td> $ 5 (CINCO) </td></tr><tr><td> Diez dólares </td><td> $ 10 (DIEZ) </td></tr><tr><td> Veinte dólares </td><td> $ 20 (VEINTE) </td></tr><tr><td> Cien dolares </td><td> $ 100 (100) </td></tr></tbody></table></section> <ide> <ide> ## Instructions <ide> <section id="instructions">
1
Text
Text
fix external links with 404 status
ee46c7302335ff495fb8acb632aa0b0a1a16e986
<ide><path>doc/api/crypto.md <ide> the `crypto`, `tls`, and `https` modules and are generally specific to OpenSSL. <ide> [Crypto Constants]: #crypto_crypto_constants_1 <ide> [HTML5's `keygen` element]: http://www.w3.org/TR/html5/forms.html#the-keygen-element <ide> [NIST SP 800-131A]: http://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-131Ar1.pdf <del>[NIST SP 800-132]: http://csrc.nist.gov/publications/nistpubs/800-132/nist-sp800-132.pdf <add>[NIST SP 800-132]: http://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf <ide> [Nonce-Disrespecting Adversaries]: https://github.com/nonce-disrespect/nonce-disrespect <ide> [OpenSSL's SPKAC implementation]: https://www.openssl.org/docs/man1.0.2/apps/spkac.html <ide> [RFC 2412]: https://www.rfc-editor.org/rfc/rfc2412.txt <ide><path>doc/api/os.md <ide> The `os.release()` method returns a string identifying the operating system <ide> release. <ide> <ide> *Note*: On POSIX systems, the operating system release is determined by <del>calling uname(3). On Windows, `GetVersionExW()` is used. Please see <add>calling [uname(3)][]. On Windows, `GetVersionExW()` is used. Please see <ide> https://en.wikipedia.org/wiki/Uname#Examples for more information. <ide> <ide> ## os.tmpdir() <ide> added: v0.3.3 <ide> * Returns: {string} <ide> <ide> The `os.type()` method returns a string identifying the operating system name <del>as returned by uname(3). For example `'Linux'` on Linux, `'Darwin'` on macOS and <del>`'Windows_NT'` on Windows. <add>as returned by [uname(3)][]. For example `'Linux'` on Linux, `'Darwin'` on macOS <add>and `'Windows_NT'` on Windows. <ide> <ide> Please see https://en.wikipedia.org/wiki/Uname#Examples for additional <del>information about the output of running uname(3) on various operating systems. <add>information about the output of running [uname(3)][] on various operating <add>systems. <ide> <ide> ## os.uptime() <ide> <!-- YAML <ide> information. <ide> [`process.arch`]: process.html#process_process_arch <ide> [`process.platform`]: process.html#process_process_platform <ide> [OS Constants]: #os_os_constants <add>[uname(3)]: https://linux.die.net/man/3/uname
2
Javascript
Javascript
remove disabled test
999d25b5ecfd947f7a4262c75de94ec6bc633c06
<ide><path>test/disabled/GH-670.js <del>'use strict'; <del>var common = require('../common'); <del>var assert = require('assert'); <del>var https = require('https'); <del>var tls = require('tls'); <del> <del>var options = { <del> host: 'github.com', <del> path: '/kriskowal/tigerblood/', <del> port: 443 <del>}; <del> <del>var req = https.get(options, function(response) { <del> var recved = 0; <del> <del> response.on('data', function(chunk) { <del> recved += chunk.length; <del> console.log('Response data.'); <del> }); <del> <del> response.on('end', function() { <del> console.log('Response end.'); <del> // Does not work <del> loadDom(); <del> }); <del> <del>}); <del> <del>req.on('error', function(e) { <del> console.log('Error on get.'); <del>}); <del> <del>function loadDom() { <del> // Do a lot of computation to stall the process. <del> // In the meantime the socket will be disconnected. <del> for (var i = 0; i < 1e8; i++); <del> <del> console.log('Dom loaded.'); <del>}
1
Text
Text
update asset fingerprinting information
8e311940ef8974606a57467c24f08072946bc03d
<ide><path>guides/source/asset_pipeline.md <ide> requests can mean faster loading for your application. <ide> Sprockets concatenates all JavaScript files into one master `.js` file and all <ide> CSS files into one master `.css` file. As you'll learn later in this guide, you <ide> can customize this strategy to group files any way you like. In production, <del>Rails inserts an MD5 fingerprint into each filename so that the file is cached <del>by the web browser. You can invalidate the cache by altering this fingerprint, <del>which happens automatically whenever you change the file contents. <add>Rails inserts an SHA256 fingerprint into each filename so that the file is <add>cached by the web browser. You can invalidate the cache by altering this <add>fingerprint, which happens automatically whenever you change the file contents. <ide> <ide> The second feature of the asset pipeline is asset minification or compression. <ide> For CSS files, this is done by removing whitespace and comments. For JavaScript, <ide> Provided that the pipeline is enabled within your application (and not disabled <ide> in the current environment context), this file is served by Sprockets. If a file <ide> exists at `public/assets/rails.png` it is served by the web server. <ide> <del>Alternatively, a request for a file with an MD5 hash such as <del>`public/assets/rails-af27b6a414e6da00003503148be9b409.png` is treated the same <del>way. How these hashes are generated is covered in the [In <add>Alternatively, a request for a file with an SHA256 hash such as <add>`public/assets/rails-f90d8a84c707a8dc923fca1ca1895ae8ed0a09237f6992015fef1e11be77c023.png` <add>is treated the same way. How these hashes are generated is covered in the [In <ide> Production](#in-production) section later on in this guide. <ide> <ide> Sprockets will also look through the paths specified in `config.assets.paths`, <ide> In the production environment Sprockets uses the fingerprinting scheme outlined <ide> above. By default Rails assumes assets have been precompiled and will be <ide> served as static assets by your web server. <ide> <del>During the precompilation phase an MD5 is generated from the contents of the <add>During the precompilation phase an SHA256 is generated from the contents of the <ide> compiled files, and inserted into the filenames as they are written to disk. <ide> These fingerprinted names are used by the Rails helpers in place of the manifest <ide> name. <ide> Rails.application.config.assets.precompile += %w( admin.js admin.css ) <ide> NOTE. Always specify an expected compiled filename that ends with .js or .css, <ide> even if you want to add Sass or CoffeeScript files to the precompile array. <ide> <del>The task also generates a `manifest-md5hash.json` that contains a list with <del>all your assets and their respective fingerprints. This is used by the Rails <del>helper methods to avoid handing the mapping requests back to Sprockets. A <del>typical manifest file looks like: <add>The task also generates a `.sprockets-manifest-md5hash.json` (where `md5hash` is <add>a MD5 hash) that contains a list with all your assets and their respective <add>fingerprints. This is used by the Rails helper methods to avoid handing the <add>mapping requests back to Sprockets. A typical manifest file looks like: <ide> <ide> ```ruby <del>{"files":{"application-723d1be6cc741a3aabb1cec24276d681.js":{"logical_path":"application.js","mtime":"2013-07-26T22:55:03-07:00","size":302506, <del>"digest":"723d1be6cc741a3aabb1cec24276d681"},"application-12b3c7dd74d2e9df37e7cbb1efa76a6d.css":{"logical_path":"application.css","mtime":"2013-07-26T22:54:54-07:00","size":1560, <del>"digest":"12b3c7dd74d2e9df37e7cbb1efa76a6d"},"application-1c5752789588ac18d7e1a50b1f0fd4c2.css":{"logical_path":"application.css","mtime":"2013-07-26T22:56:17-07:00","size":1591, <del>"digest":"1c5752789588ac18d7e1a50b1f0fd4c2"},"favicon-a9c641bf2b81f0476e876f7c5e375969.ico":{"logical_path":"favicon.ico","mtime":"2013-07-26T23:00:10-07:00","size":1406, <del>"digest":"a9c641bf2b81f0476e876f7c5e375969"},"my_image-231a680f23887d9dd70710ea5efd3c62.png":{"logical_path":"my_image.png","mtime":"2013-07-26T23:00:27-07:00","size":6646, <del>"digest":"231a680f23887d9dd70710ea5efd3c62"}},"assets":{"application.js": <del>"application-723d1be6cc741a3aabb1cec24276d681.js","application.css": <del>"application-1c5752789588ac18d7e1a50b1f0fd4c2.css", <del>"favicon.ico":"favicona9c641bf2b81f0476e876f7c5e375969.ico","my_image.png": <del>"my_image-231a680f23887d9dd70710ea5efd3c62.png"}} <add>{"files":{"application-aee4be71f1288037ae78b997df388332edfd246471b533dcedaa8f9fe156442b.js":{"logical_path":"application.js","mtime":"2016-12-23T20:12:03-05:00","size":412383, <add>"digest":"aee4be71f1288037ae78b997df388332edfd246471b533dcedaa8f9fe156442b","integrity":"sha256-ruS+cfEogDeueLmX3ziDMu39JGRxtTPc7aqPn+FWRCs="}, <add>"application-86a292b5070793c37e2c0e5f39f73bb387644eaeada7f96e6fc040a028b16c18.css":{"logical_path":"application.css","mtime":"2016-12-23T19:12:20-05:00","size":2994, <add>"digest":"86a292b5070793c37e2c0e5f39f73bb387644eaeada7f96e6fc040a028b16c18","integrity":"sha256-hqKStQcHk8N+LA5fOfc7s4dkTq6tp/lub8BAoCixbBg="}, <add>"favicon-8d2387b8d4d32cecd93fa3900df0e9ff89d01aacd84f50e780c17c9f6b3d0eda.ico":{"logical_path":"favicon.ico","mtime":"2016-12-23T20:11:00-05:00","size":8629, <add>"digest":"8d2387b8d4d32cecd93fa3900df0e9ff89d01aacd84f50e780c17c9f6b3d0eda","integrity":"sha256-jSOHuNTTLOzZP6OQDfDp/4nQGqzYT1DngMF8n2s9Dto="}, <add>"my_image-f4028156fd7eca03584d5f2fc0470df1e0dbc7369eaae638b2ff033f988ec493.png":{"logical_path":"my_image.png","mtime":"2016-12-23T20:10:54-05:00","size":23414, <add>"digest":"f4028156fd7eca03584d5f2fc0470df1e0dbc7369eaae638b2ff033f988ec493","integrity":"sha256-9AKBVv1+ygNYTV8vwEcN8eDbxzaequY4sv8DP5iOxJM="}}, <add>"assets":{"application.js":"application-aee4be71f1288037ae78b997df388332edfd246471b533dcedaa8f9fe156442b.js", <add>"application.css":"application-86a292b5070793c37e2c0e5f39f73bb387644eaeada7f96e6fc040a028b16c18.css", <add>"favicon.ico":"favicon-8d2387b8d4d32cecd93fa3900df0e9ff89d01aacd84f50e780c17c9f6b3d0eda.ico", <add>"my_image.png":"my_image-f4028156fd7eca03584d5f2fc0470df1e0dbc7369eaae638b2ff033f988ec493.png"}} <ide> ``` <ide> <ide> The default location for the manifest is the root of the location specified in <ide> config.assets.compile = true <ide> <ide> On the first request the assets are compiled and cached as outlined in <ide> development above, and the manifest names used in the helpers are altered to <del>include the MD5 hash. <add>include the SHA256 hash. <ide> <ide> Sprockets also sets the `Cache-Control` HTTP header to `max-age=31536000`. This <ide> signals all caches between your server and the client browser that this content
1
PHP
PHP
allow modifiers in createfromformat()
9c6653e43d374ca301e68c77a760cb9f62377b59
<ide><path>src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php <ide> namespace Illuminate\Database\Eloquent\Concerns; <ide> <ide> use Carbon\CarbonInterface; <add>use Carbon\Exceptions\InvalidFormatException; <ide> use DateTimeInterface; <ide> use Illuminate\Contracts\Database\Eloquent\Castable; <ide> use Illuminate\Contracts\Database\Eloquent\CastsInboundAttributes; <ide> protected function asDateTime($value) <ide> // Finally, we will just assume this date is in the format used by default on <ide> // the database connection and use that format to create the Carbon object <ide> // that is returned back out to the developers after we convert it here. <del> if (Date::hasFormat($value, $format)) { <del> return Date::createFromFormat($format, $value); <add> try { <add> $date = Date::createFromFormat($format, $value); <add> } catch (InvalidFormatException $_) { <add> $date = false; <ide> } <ide> <del> return Date::parse($value); <add> return $date ?: Date::parse($value); <ide> } <ide> <ide> /**
1
Python
Python
fix issue with undefined vocab size
40074aec8ecf6a81cf91dc7fa2f837928a40840f
<ide><path>keras/layers/preprocessing/index_lookup.py <ide> def finalize_state(self): <ide> # compute a new vocabulary. <ide> if self.output_mode == TF_IDF: <ide> self.idf_weights_const = self.idf_weights.value() <add> self._record_vocabulary_size() <ide> return <ide> <ide> # Remove special tokens from our counts.
1
Javascript
Javascript
fix the closure in ajax.js too
ab74d8e6a0810717419abb696154d034ad145f2b
<ide><path>src/ajax.js <ide> jQuery.support.ajax = !!testXHR; <ide> // Does this browser support crossDomain XHR requests <ide> jQuery.support.cors = testXHR && "withCredentials" in testXHR; <ide> <del>})(jQuery); <ide>\ No newline at end of file <add>})( jQuery );
1
Java
Java
improve performance of observable.flatmapiterable
ab21265ef0cb25f7149c699fc147597c13403221
<ide><path>src/main/java/io/reactivex/Observable.java <ide> public final <R> Observable<R> concatMapEagerDelayError(Function<? super T, ? ex <ide> @SchedulerSupport(SchedulerSupport.NONE) <ide> public final <U> Observable<U> concatMapIterable(final Function<? super T, ? extends Iterable<? extends U>> mapper) { <ide> ObjectHelper.requireNonNull(mapper, "mapper is null"); <del> return concatMap(ObservableInternalHelper.flatMapIntoIterable(mapper)); <add> return RxJavaPlugins.onAssembly(new ObservableFlattenIterable<T, U>(this, mapper)); <ide> } <ide> <ide> /** <ide> public final <U, R> Observable<R> flatMap(Function<? super T, ? extends Observab <ide> @SchedulerSupport(SchedulerSupport.NONE) <ide> public final <U> Observable<U> flatMapIterable(final Function<? super T, ? extends Iterable<? extends U>> mapper) { <ide> ObjectHelper.requireNonNull(mapper, "mapper is null"); <del> return flatMap(ObservableInternalHelper.flatMapIntoIterable(mapper)); <add> return RxJavaPlugins.onAssembly(new ObservableFlattenIterable<T, U>(this, mapper)); <ide> } <ide> <ide> /** <ide><path>src/main/java/io/reactivex/internal/operators/observable/ObservableFlattenIterable.java <add>/** <add> * Copyright 2016 Netflix, Inc. <add> * <add> * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in <add> * compliance with the License. You may obtain a copy of the License at <add> * <add> * http://www.apache.org/licenses/LICENSE-2.0 <add> * <add> * Unless required by applicable law or agreed to in writing, software distributed under the License is <add> * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See <add> * the License for the specific language governing permissions and limitations under the License. <add> */ <add> <add>package io.reactivex.internal.operators.observable; <add> <add>import java.util.Iterator; <add> <add>import io.reactivex.*; <add>import io.reactivex.disposables.Disposable; <add>import io.reactivex.exceptions.Exceptions; <add>import io.reactivex.functions.Function; <add>import io.reactivex.internal.disposables.DisposableHelper; <add>import io.reactivex.internal.functions.ObjectHelper; <add>import io.reactivex.plugins.RxJavaPlugins; <add> <add>/** <add> * Maps a sequence into an Iterable and emits its values. <add> * <add> * @param <T> the input value type to map to Iterable <add> * @param <R> the element type of the Iterable and the output <add> */ <add>public final class ObservableFlattenIterable<T, R> extends AbstractObservableWithUpstream<T, R> { <add> <add> final Function<? super T, ? extends Iterable<? extends R>> mapper; <add> <add> public ObservableFlattenIterable(ObservableSource<T> source, <add> Function<? super T, ? extends Iterable<? extends R>> mapper) { <add> super(source); <add> this.mapper = mapper; <add> } <add> <add> @Override <add> protected void subscribeActual(Observer<? super R> observer) { <add> source.subscribe(new FlattenIterableObserver<T, R>(observer, mapper)); <add> } <add> <add> static final class FlattenIterableObserver<T, R> implements Observer<T>, Disposable { <add> final Observer<? super R> actual; <add> <add> final Function<? super T, ? extends Iterable<? extends R>> mapper; <add> <add> Disposable d; <add> <add> FlattenIterableObserver(Observer<? super R> actual, Function<? super T, ? extends Iterable<? extends R>> mapper) { <add> this.actual = actual; <add> this.mapper = mapper; <add> } <add> <add> @Override <add> public void onSubscribe(Disposable d) { <add> if (DisposableHelper.validate(this.d, d)) { <add> this.d = d; <add> <add> actual.onSubscribe(this); <add> } <add> } <add> <add> @Override <add> public void onNext(T value) { <add> if (d == DisposableHelper.DISPOSED) { <add> return; <add> } <add> <add> Iterator<? extends R> it; <add> <add> try { <add> it = mapper.apply(value).iterator(); <add> } catch (Throwable ex) { <add> Exceptions.throwIfFatal(ex); <add> d.dispose(); <add> onError(ex); <add> return; <add> } <add> <add> Observer<? super R> a = actual; <add> <add> for (;;) { <add> boolean b; <add> <add> try { <add> b = it.hasNext(); <add> } catch (Throwable ex) { <add> Exceptions.throwIfFatal(ex); <add> d.dispose(); <add> onError(ex); <add> return; <add> } <add> <add> if (b) { <add> R v; <add> <add> try { <add> v = ObjectHelper.requireNonNull(it.next(), "The iterator returned a null value"); <add> } catch (Throwable ex) { <add> Exceptions.throwIfFatal(ex); <add> d.dispose(); <add> onError(ex); <add> return; <add> } <add> <add> a.onNext(v); <add> } else { <add> break; <add> } <add> } <add> } <add> <add> @Override <add> public void onError(Throwable e) { <add> if (d == DisposableHelper.DISPOSED) { <add> RxJavaPlugins.onError(e); <add> return; <add> } <add> actual.onError(e); <add> } <add> <add> @Override <add> public void onComplete() { <add> if (d == DisposableHelper.DISPOSED) { <add> return; <add> } <add> actual.onComplete(); <add> } <add> <add> @Override <add> public boolean isDisposed() { <add> return d.isDisposed(); <add> } <add> <add> @Override <add> public void dispose() { <add> d.dispose(); <add> d = DisposableHelper.DISPOSED; <add> } <add> } <add>} <ide><path>src/perf/java/io/reactivex/FlatMapJustPerf.java <add>/** <add> * Copyright 2016 Netflix, Inc. <add> * <add> * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in <add> * compliance with the License. You may obtain a copy of the License at <add> * <add> * http://www.apache.org/licenses/LICENSE-2.0 <add> * <add> * Unless required by applicable law or agreed to in writing, software distributed under the License is <add> * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See <add> * the License for the specific language governing permissions and limitations under the License. <add> */ <add> <add>package io.reactivex; <add> <add>import java.util.concurrent.TimeUnit; <add> <add>import org.openjdk.jmh.annotations.*; <add>import org.openjdk.jmh.infra.Blackhole; <add>import org.reactivestreams.Publisher; <add> <add>import io.reactivex.functions.Function; <add> <add>@BenchmarkMode(Mode.Throughput) <add>@Warmup(iterations = 5) <add>@Measurement(iterations = 5, time = 5, timeUnit = TimeUnit.SECONDS) <add>@OutputTimeUnit(TimeUnit.SECONDS) <add>@Fork(value = 1) <add>@State(Scope.Thread) <add>public class FlatMapJustPerf { <add> @Param({ "1", "10", "100", "1000", "10000", "100000", "1000000" }) <add> public int times; <add> <add> Flowable<Integer> flowable; <add> <add> Observable<Integer> observable; <add> <add> @Setup <add> public void setup() { <add> Integer[] array = new Integer[times]; <add> <add> flowable = Flowable.fromArray(array).flatMap(new Function<Integer, Publisher<Integer>>() { <add> @Override <add> public Publisher<Integer> apply(Integer v) throws Exception { <add> return Flowable.just(v); <add> } <add> }); <add> <add> observable = Observable.fromArray(array).flatMap(new Function<Integer, Observable<Integer>>() { <add> @Override <add> public Observable<Integer> apply(Integer v) throws Exception { <add> return Observable.just(v); <add> } <add> }); <add> } <add> <add> @Benchmark <add> public void flowable(Blackhole bh) { <add> flowable.subscribe(new PerfConsumer(bh)); <add> } <add> <add> @Benchmark <add> public void observable(Blackhole bh) { <add> observable.subscribe(new PerfConsumer(bh)); <add> } <add>} <ide>\ No newline at end of file <ide><path>src/perf/java/io/reactivex/FlattenCrossMapPerf.java <add>/** <add> * Copyright 2016 Netflix, Inc. <add> * <add> * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in <add> * compliance with the License. You may obtain a copy of the License at <add> * <add> * http://www.apache.org/licenses/LICENSE-2.0 <add> * <add> * Unless required by applicable law or agreed to in writing, software distributed under the License is <add> * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See <add> * the License for the specific language governing permissions and limitations under the License. <add> */ <add> <add>package io.reactivex; <add> <add>import java.util.*; <add>import java.util.concurrent.TimeUnit; <add> <add>import org.openjdk.jmh.annotations.*; <add>import org.openjdk.jmh.infra.Blackhole; <add> <add>import io.reactivex.functions.Function; <add> <add>@BenchmarkMode(Mode.Throughput) <add>@Warmup(iterations = 5) <add>@Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) <add>@OutputTimeUnit(TimeUnit.SECONDS) <add>@Fork(value = 1) <add>@State(Scope.Thread) <add>public class FlattenCrossMapPerf { <add> @Param({ "1", "10", "100", "1000", "10000", "100000", "1000000" }) <add> public int times; <add> <add> Flowable<Integer> flowable; <add> <add> Observable<Integer> observable; <add> <add> @Setup <add> public void setup() { <add> Integer[] array = new Integer[times]; <add> Arrays.fill(array, 777); <add> <add> Integer[] arrayInner = new Integer[1000000 / times]; <add> Arrays.fill(arrayInner, 888); <add> <add> final Iterable<Integer> list = Arrays.asList(arrayInner); <add> <add> flowable = Flowable.fromArray(array).flatMapIterable(new Function<Integer, Iterable<Integer>>() { <add> @Override <add> public Iterable<Integer> apply(Integer v) throws Exception { <add> return list; <add> } <add> }); <add> <add> observable = Observable.fromArray(array).flatMapIterable(new Function<Integer, Iterable<Integer>>() { <add> @Override <add> public Iterable<Integer> apply(Integer v) throws Exception { <add> return list; <add> } <add> }); <add> } <add> <add> @Benchmark <add> public void flowable(Blackhole bh) { <add> flowable.subscribe(new PerfConsumer(bh)); <add> } <add> <add> @Benchmark <add> public void observable(Blackhole bh) { <add> observable.subscribe(new PerfConsumer(bh)); <add> } <add>} <ide>\ No newline at end of file <ide><path>src/perf/java/io/reactivex/FlattenJustPerf.java <add>/** <add> * Copyright 2016 Netflix, Inc. <add> * <add> * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in <add> * compliance with the License. You may obtain a copy of the License at <add> * <add> * http://www.apache.org/licenses/LICENSE-2.0 <add> * <add> * Unless required by applicable law or agreed to in writing, software distributed under the License is <add> * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See <add> * the License for the specific language governing permissions and limitations under the License. <add> */ <add> <add>package io.reactivex; <add> <add>import java.util.*; <add>import java.util.concurrent.TimeUnit; <add> <add>import org.openjdk.jmh.annotations.*; <add>import org.openjdk.jmh.infra.Blackhole; <add> <add>import io.reactivex.functions.Function; <add> <add>@BenchmarkMode(Mode.Throughput) <add>@Warmup(iterations = 5) <add>@Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) <add>@OutputTimeUnit(TimeUnit.SECONDS) <add>@Fork(value = 1) <add>@State(Scope.Thread) <add>public class FlattenJustPerf { <add> @Param({ "1", "10", "100", "1000", "10000", "100000", "1000000" }) <add> public int times; <add> <add> Flowable<Integer> flowable; <add> <add> Observable<Integer> observable; <add> <add> @Setup <add> public void setup() { <add> Integer[] array = new Integer[times]; <add> Arrays.fill(array, 777); <add> <add> final Iterable<Integer> singletonList = Collections.singletonList(1); <add> <add> flowable = Flowable.fromArray(array).flatMapIterable(new Function<Integer, Iterable<Integer>>() { <add> @Override <add> public Iterable<Integer> apply(Integer v) throws Exception { <add> return singletonList; <add> } <add> }); <add> <add> observable = Observable.fromArray(array).flatMapIterable(new Function<Integer, Iterable<Integer>>() { <add> @Override <add> public Iterable<Integer> apply(Integer v) throws Exception { <add> return singletonList; <add> } <add> }); <add> } <add> <add> @Benchmark <add> public void flowable(Blackhole bh) { <add> flowable.subscribe(new PerfConsumer(bh)); <add> } <add> <add> @Benchmark <add> public void observable(Blackhole bh) { <add> observable.subscribe(new PerfConsumer(bh)); <add> } <add>} <ide>\ No newline at end of file <ide><path>src/perf/java/io/reactivex/PerfConsumer.java <add>/** <add> * Copyright 2016 Netflix, Inc. <add> * <add> * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in <add> * compliance with the License. You may obtain a copy of the License at <add> * <add> * http://www.apache.org/licenses/LICENSE-2.0 <add> * <add> * Unless required by applicable law or agreed to in writing, software distributed under the License is <add> * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See <add> * the License for the specific language governing permissions and limitations under the License. <add> */ <add> <add>package io.reactivex; <add> <add>import org.openjdk.jmh.infra.Blackhole; <add>import org.reactivestreams.*; <add> <add>import io.reactivex.disposables.Disposable; <add> <add>/** <add> * A multi-type synchronous consumer. <add> */ <add>public final class PerfConsumer implements Subscriber<Object>, Observer<Object>, <add>SingleObserver<Object>, CompletableObserver, MaybeObserver<Object> { <add> <add> final Blackhole bh; <add> <add> public PerfConsumer(Blackhole bh) { <add> this.bh = bh; <add> } <add> <add> @Override <add> public void onSuccess(Object value) { <add> bh.consume(value); <add> } <add> <add> @Override <add> public void onSubscribe(Disposable d) { <add> } <add> <add> @Override <add> public void onSubscribe(Subscription s) { <add> s.request(Long.MAX_VALUE); <add> } <add> <add> @Override <add> public void onNext(Object t) { <add> bh.consume(t); <add> } <add> <add> @Override <add> public void onError(Throwable t) { <add> t.printStackTrace(); <add> } <add> <add> @Override <add> public void onComplete() { <add> bh.consume(true); <add> } <add>} <add><path>src/test/java/io/reactivex/internal/operators/observable/ObservableFlattenIterableTest.java <del><path>src/test/java/io/reactivex/internal/operators/observable/ObservableFlattenIterable.java <ide> import io.reactivex.Observable; <ide> import io.reactivex.functions.Function; <ide> <del>public class ObservableFlattenIterable { <add>public class ObservableFlattenIterableTest { <ide> <ide> @Test <ide> public void flatMapIterablePrefetch() { <ide><path>src/test/java/io/reactivex/internal/operators/observable/ObservableMergeTest.java <ide> public void onNext(String v) { <ide> // to make sure after o1.onNextBeingSent and o2.onNextBeingSent are hit that the following <ide> // onNext is invoked. <ide> <del> int timeout = 10; <add> int timeout = 20; <ide> <ide> while (timeout-- > 0 && concurrentCounter.get() != 1) { <ide> Thread.sleep(100);
8
Ruby
Ruby
convert search test to spec
82e6070ca045001eab7aec0ba9b85dbca48615f8
<ide><path>Library/Homebrew/cask/spec/cask/cli/search_spec.rb <add>require "spec_helper" <add> <add>describe Hbc::CLI::Search do <add> it "lists the available Casks that match the search term" do <add> expect { <add> Hbc::CLI::Search.run("photoshop") <add> }.to output(<<-EOS.undent).to_stdout <add> ==> Partial matches <add> adobe-photoshop-cc <add> adobe-photoshop-lightroom <add> EOS <add> end <add> <add> it "shows that there are no Casks matching a search term that did not result in anything" do <add> expect { <add> Hbc::CLI::Search.run("foo-bar-baz") <add> }.to output("No Cask found for \"foo-bar-baz\".\n").to_stdout <add> end <add> <add> it "lists all available Casks with no search term" do <add> expect { <add> Hbc::CLI::Search.run <add> }.to output(/google-chrome/).to_stdout <add> end <add> <add> it "ignores hyphens in search terms" do <add> expect { <add> Hbc::CLI::Search.run("goo-gle-chrome") <add> }.to output(/google-chrome/).to_stdout <add> end <add> <add> it "ignores hyphens in Cask tokens" do <add> expect { <add> Hbc::CLI::Search.run("googlechrome") <add> }.to output(/google-chrome/).to_stdout <add> end <add> <add> it "accepts multiple arguments" do <add> expect { <add> Hbc::CLI::Search.run("google chrome") <add> }.to output(/google-chrome/).to_stdout <add> end <add> <add> it "accepts a regexp argument" do <add> expect { <add> Hbc::CLI::Search.run("/^google-c[a-z]rome$/") <add> }.to output("==> Regexp matches\ngoogle-chrome\n").to_stdout <add> end <add> <add> it "Returns both exact and partial matches" do <add> expect { <add> Hbc::CLI::Search.run("mnemosyne") <add> }.to output(/^==> Exact match\nmnemosyne\n==> Partial matches\nsubclassed-mnemosyne/).to_stdout <add> end <add> <add> it "does not search the Tap name" do <add> expect { <add> Hbc::CLI::Search.run("caskroom") <add> }.to output(/^No Cask found for "caskroom"\.\n/).to_stdout <add> end <add>end <ide><path>Library/Homebrew/cask/test/cask/cli/search_test.rb <del>require "test_helper" <del> <del>describe Hbc::CLI::Search do <del> it "lists the available Casks that match the search term" do <del> lambda { <del> Hbc::CLI::Search.run("photoshop") <del> }.must_output <<-EOS.undent <del> ==> Partial matches <del> adobe-photoshop-cc <del> adobe-photoshop-lightroom <del> EOS <del> end <del> <del> it "shows that there are no Casks matching a search term that did not result in anything" do <del> lambda { <del> Hbc::CLI::Search.run("foo-bar-baz") <del> }.must_output("No Cask found for \"foo-bar-baz\".\n") <del> end <del> <del> it "lists all available Casks with no search term" do <del> out = capture_io { Hbc::CLI::Search.run }[0] <del> out.must_match(/google-chrome/) <del> out.length.must_be :>, 1000 <del> end <del> <del> it "ignores hyphens in search terms" do <del> out = capture_io { Hbc::CLI::Search.run("goo-gle-chrome") }[0] <del> out.must_match(/google-chrome/) <del> out.length.must_be :<, 100 <del> end <del> <del> it "ignores hyphens in Cask tokens" do <del> out = capture_io { Hbc::CLI::Search.run("googlechrome") }[0] <del> out.must_match(/google-chrome/) <del> out.length.must_be :<, 100 <del> end <del> <del> it "accepts multiple arguments" do <del> out = capture_io { Hbc::CLI::Search.run("google chrome") }[0] <del> out.must_match(/google-chrome/) <del> out.length.must_be :<, 100 <del> end <del> <del> it "accepts a regexp argument" do <del> lambda { <del> Hbc::CLI::Search.run("/^google-c[a-z]rome$/") <del> }.must_output "==> Regexp matches\ngoogle-chrome\n" <del> end <del> <del> it "Returns both exact and partial matches" do <del> out = capture_io { Hbc::CLI::Search.run("mnemosyne") }[0] <del> out.must_match(/^==> Exact match\nmnemosyne\n==> Partial matches\nsubclassed-mnemosyne/) <del> end <del> <del> it "does not search the Tap name" do <del> out = capture_io { Hbc::CLI::Search.run("caskroom") }[0] <del> out.must_match(/^No Cask found for "caskroom"\.\n/) <del> end <del>end
2
PHP
PHP
add a comment
78148251944be9a3da065954baa52691f5263ed0
<ide><path>src/Illuminate/Foundation/Console/Kernel.php <ide> public function call($command, array $parameters = array()) <ide> { <ide> $this->bootstrap(); <ide> <add> // If we are calling a arbitary command from within the application, we will load <add> // all of the available deferred providers which will make all of the commands <add> // available to an application. Otherwise the command will not be available. <ide> $this->app->loadDeferredProviders(); <ide> <ide> return $this->getArtisan()->call($command, $parameters);
1
Go
Go
apply the new walkhistory prototype to merge
f246cc9cdd9091baa5f956f7c8119a49e8379f91
<ide><path>commands.go <ide> func (srv *Server) CmdHistory(stdin io.ReadCloser, stdout io.Writer, args ...str <ide> return err <ide> } <ide> var child *Image <del> return image.WalkHistory(func(img *Image) { <add> return image.WalkHistory(func(img *Image) error { <ide> if child == nil { <ide> fmt.Fprintf(stdout, " %s\n", img.Id) <ide> } else { <ide> fmt.Fprintf(stdout, " = %s + %s\n", img.Id, strings.Join(child.ParentCommand, " ")) <ide> } <ide> child = img <add> return nil <ide> }) <ide> } <ide>
1
Go
Go
move t from arg to env
6ba456ff87cfe2687db7df896e2983636ca9fe1e
<ide><path>api.go <ide> func postContainersStop(srv *Server, version float64, w http.ResponseWriter, r * <ide> return fmt.Errorf("Missing parameter") <ide> } <ide> job := srv.Eng.Job("stop", vars["name"]) <del> if t := r.Form.Get("t"); t != "" { <del> job.Args = append(job.Args, t) <del> } <add> job.Setenv("t", r.Form.Get("t")) <ide> if err := job.Run(); err != nil { <ide> return err <ide> } <ide><path>integration/server_test.go <ide> func TestCreateRmVolumes(t *testing.T) { <ide> t.Fatal(err) <ide> } <ide> <del> if err := eng.Job("stop", id, "1").Run(); err != nil { <add> job = eng.Job("stop", id) <add> job.SetenvInt("t", 1) <add> if err := job.Run(); err != nil { <ide> t.Fatal(err) <ide> } <ide> <ide> func TestCreateStartRestartStopStartKillRm(t *testing.T) { <ide> t.Fatal(err) <ide> } <ide> <del> if err := eng.Job("stop", id, "15").Run(); err != nil { <add> job = eng.Job("stop", id) <add> job.SetenvInt("t", 15) <add> if err := job.Run(); err != nil { <ide> t.Fatal(err) <ide> } <ide> <ide><path>server.go <ide> func (srv *Server) ContainerStart(job *engine.Job) engine.Status { <ide> } <ide> <ide> func (srv *Server) ContainerStop(job *engine.Job) engine.Status { <del> if len(job.Args) < 1 { <del> job.Errorf("Not enough arguments. Usage: %s CONTAINER TIMEOUT\n", job.Name) <add> if len(job.Args) != 1 { <add> job.Errorf("Usage: %s CONTAINER\n", job.Name) <ide> return engine.StatusErr <ide> } <ide> name := job.Args[0] <del> var t uint64 <del> if len(job.Args) == 2 { <del> var err error <del> t, err = strconv.ParseUint(job.Args[1], 10, 32) <del> if err != nil { <del> job.Errorf("Invalid delay format: %s. Please provide an integer number of seconds.\n", job.Args[1]) <del> return engine.StatusErr <del> } <del> } else { <add> t := job.GetenvInt("t") <add> if t == -1 { <ide> t = 10 <ide> } <ide> if container := srv.runtime.Get(name); container != nil {
3
Javascript
Javascript
classify stl file prefix using matchdataviewat
303a954121734963c1376b6dbff79bf523fb6276
<ide><path>examples/js/loaders/STLLoader.js <ide> THREE.STLLoader.prototype = { <ide> <ide> for ( var off = 0; off < 5; off ++ ) { <ide> <del> // Check if solid[ i ] matches the i-th byte at the current offset <add> // If "solid" text is matched to the current offset, declare it to be an ASCII STL. <ide> <del> var found = true; <del> for ( var i = 0; found && i < 5; i ++ ) { <add> if ( matchDataViewAt ( solid, reader, off ) ) return false; <ide> <del> found = found && ( solid[ i ] == reader.getUint8( off + i, false ) ); <add> } <ide> <del> } <add> // Couldn't find "solid" text at the beginning; it is binary STL. <ide> <del> // Found "solid" text at the beginning; declare it to be an ASCII STL. <add> return true; <ide> <del> if ( found ) { <del> return false; <del> } <add> } <ide> <del> } <add> function matchDataViewAt( query, reader, offset ) { <ide> <del> // Couldn't find "solid" text at the beginning; it is binary STL. <add> // Check if each byte in query matches the corresponding byte from the current offset <add> <add> for ( var i = 0, il = query.length; i < il; i ++ ) { <add> <add> if ( query[ i ] !== reader.getUint8( offset + i, false ) ) return false; <add> <add> } <ide> <ide> return true; <ide>
1
Ruby
Ruby
fix typo in serialized_attribute_test. [ci skip]
c3b46d63b96729fb6b77f10de453171d7af39295
<ide><path>activerecord/test/cases/serialized_attribute_test.rb <ide> def test_regression_serialized_default_on_text_column_with_null_false <ide> assert_equal [], light.long_state <ide> end <ide> <del> def test_serialized_columh_should_not_be_wrapped_twice <add> def test_serialized_column_should_not_be_wrapped_twice <ide> Topic.serialize(:content, MyObject) <ide> <ide> myobj = MyObject.new('value1', 'value2')
1
Javascript
Javascript
add dns.onlookupall() to increase coverage
a58f37720d389fe921b35daf45afb1c4e2c02274
<ide><path>test/internet/test-dns-lookup.js <ide> 'use strict'; <ide> <ide> require('../common'); <del>const dnsPromises = require('dns').promises; <add>const common = require('../common'); <add>const dns = require('dns'); <add>const dnsPromises = dns.promises; <ide> const { addresses } = require('../common/internet'); <ide> const assert = require('assert'); <ide> <ide> assert.rejects( <ide> message: `getaddrinfo ENOTFOUND ${addresses.INVALID_HOST}` <ide> } <ide> ); <add> <add>dns.lookup(addresses.INVALID_HOST, { <add> hints: 0, <add> family: 0, <add> all: true <add>}, common.mustCall((error) => { <add> assert.strictEqual(error.code, 'ENOTFOUND'); <add> assert.strictEqual( <add> error.message, <add> `getaddrinfo ENOTFOUND ${addresses.INVALID_HOST}` <add> ); <add> assert.strictEqual(error.syscall, 'getaddrinfo'); <add> assert.strictEqual(error.hostname, addresses.INVALID_HOST); <add>}));
1
Javascript
Javascript
fix process.nexttick() error case regression
362b5a6c401d08eafad701f4b6023e357a82f910
<ide><path>src/node.js <ide> for (var i = 0; i < l; i++) q[i](); <ide> } <ide> catch (e) { <add> if (i + 1 < l) { <add> nextTickQueue = q.slice(i + 1).concat(nextTickQueue); <add> } <ide> if (nextTickQueue.length) { <ide> process._needTickCallback(); <ide> } <ide><path>test/simple/test-process-next-tick.js <add>var assert = require('assert'); <add>var N = 2; <add>var tickCount = 0; <add>var exceptionCount = 0; <add> <add>function cb() { <add> ++tickCount; <add> throw new Error(); <add>} <add> <add>for (var i = 0; i < N; ++i) { <add> process.nextTick(cb); <add>} <add> <add>process.on('uncaughtException', function() { <add> ++exceptionCount; <add>}); <add> <add>process.on('exit', function() { <add> process.removeAllListeners('uncaughtException'); <add> assert.equal(tickCount, N); <add> assert.equal(exceptionCount, N); <add>});
2
Python
Python
fix serialization of optional elements
924c58bde38c0b97f35e746b3d1367aa7f6c907b
<ide><path>spacy/util.py <ide> def to_bytes(getters, exclude): <ide> def from_bytes(bytes_data, setters, exclude): <ide> msg = msgpack.loads(bytes_data, encoding='utf8') <ide> for key, setter in setters.items(): <del> if key not in exclude: <add> if key not in exclude and key in msg: <ide> setter(msg[key]) <ide> return msg <ide>
1
Javascript
Javascript
use strict equalities in src/core/jpg.js
2796d1bf10b6a012835ebc131c28c860b5beb3d3
<ide><path>src/core/jpg.js <ide> var JpegImage = (function jpegImage() { <ide> return (bitsData >> bitsCount) & 1; <ide> } <ide> bitsData = data[offset++]; <del> if (bitsData == 0xFF) { <add> if (bitsData === 0xFF) { <ide> var nextByte = data[offset++]; <ide> if (nextByte) { <ide> throw 'unexpected marker: ' + <ide> var JpegImage = (function jpegImage() { <ide> } else { <ide> r--; <ide> if (r === 0) { <del> successiveACState = successiveACState == 2 ? 3 : 0; <add> successiveACState = successiveACState === 2 ? 3 : 0; <ide> } <ide> } <ide> break; <ide> var JpegImage = (function jpegImage() { <ide> <ide> var mcu = 0, marker; <ide> var mcuExpected; <del> if (componentsLength == 1) { <add> if (componentsLength === 1) { <ide> mcuExpected = components[0].blocksPerLine * components[0].blocksPerColumn; <ide> } else { <ide> mcuExpected = mcusPerLine * frame.mcusPerColumn; <ide> var JpegImage = (function jpegImage() { <ide> } <ide> eobrun = 0; <ide> <del> if (componentsLength == 1) { <add> if (componentsLength === 1) { <ide> component = components[0]; <ide> for (n = 0; n < resetInterval; n++) { <ide> decodeBlock(component, decodeFn, mcu); <ide> var JpegImage = (function jpegImage() { <ide> var quantizationTables = []; <ide> var huffmanTablesAC = [], huffmanTablesDC = []; <ide> var fileMarker = readUint16(); <del> if (fileMarker != 0xFFD8) { // SOI (Start of Image) <add> if (fileMarker !== 0xFFD8) { // SOI (Start of Image) <ide> throw 'SOI not found'; <ide> } <ide> <ide> fileMarker = readUint16(); <del> while (fileMarker != 0xFFD9) { // EOI (End of image) <add> while (fileMarker !== 0xFFD9) { // EOI (End of image) <ide> var i, j, l; <ide> switch(fileMarker) { <ide> case 0xFFE0: // APP0 (Application Specific) <ide> var JpegImage = (function jpegImage() { <ide> offset += processed; <ide> break; <ide> default: <del> if (data[offset - 3] == 0xFF && <add> if (data[offset - 3] === 0xFF && <ide> data[offset - 2] >= 0xC0 && data[offset - 2] <= 0xFE) { <ide> // could be incorrect encoding -- last 0xFF byte of the previous <ide> // block was eaten by the encoder <ide> var JpegImage = (function jpegImage() { <ide> if (this.adobe && this.adobe.transformCode) { <ide> // The adobe transform marker overrides any previous setting <ide> return true; <del> } else if (this.numComponents == 3) { <add> } else if (this.numComponents === 3) { <ide> return true; <ide> } else { <ide> return false;
1
Python
Python
disallow verbose=1 with parameterserverstrategy
1dd712893462e9d656531f769a39556c7d0a1c02
<ide><path>keras/distribute/dataset_creator_model_fit_ps_only_test.py <ide> def testModelFitTensorBoardEpochLevel(self, strategy, use_dataset_creator): <ide> files = tf.compat.v1.gfile.ListDirectory(log_dir) <ide> self.assertGreaterEqual(len(files), 1) <ide> <add> def testModelFitVerbose1(self, strategy, use_dataset_creator): <add> with self.assertRaisesRegex(ValueError, <add> "`verbose=1` is not allowed with " <add> "`ParameterServerStrategy` for performance " <add> "reasons. Received: `verbose`=1"): <add> self._model_fit( <add> strategy, use_dataset_creator=use_dataset_creator, <add> verbose=1) <add> <ide> def testModelEvaluateErrorOnBatchLevelCallbacks(self, strategy, <ide> use_dataset_creator): <ide> <ide><path>keras/distribute/dataset_creator_model_fit_test_base.py <ide> def _model_fit(self, <ide> with_normalization_layer=False, <ide> callbacks=None, <ide> use_lookup_layer=False, <del> use_dataset_creator=True): <add> use_dataset_creator=True, <add> verbose="auto"): <ide> if callbacks is None: <ide> callbacks = [] <ide> <ide> def _model_fit(self, <ide> steps_per_epoch=steps_per_epoch, <ide> callbacks=callbacks, <ide> validation_data=validation_data, <del> validation_steps=steps_per_epoch) <add> validation_steps=steps_per_epoch, <add> verbose=verbose) <ide> return model <ide> <ide> def _model_evaluate(self, <ide><path>keras/engine/training.py <ide> def fit(self, <ide> verbose = 2 # Default to epoch-level logging for PSStrategy. <ide> else: <ide> verbose = 1 # Default to batch-level logging otherwise. <add> elif verbose == 1 and self.distribute_strategy._should_use_with_coordinator: # pylint: disable=protected-access <add> raise ValueError( <add> '`verbose=1` is not allowed with `ParameterServerStrategy` for ' <add> f'performance reasons. Received: `verbose`={verbose}') <ide> <ide> if validation_split: <ide> # Create the validation data using the training data. Only supported for
3
Python
Python
fix the tests for python 3.7
5c7074f90ee7093f231816cb356cb787e0f22802
<ide><path>numpy/_pytesttester.py <ide> def __call__(self, label='fast', verbose=1, extra_argv=None, <ide> # so fetch module for suppression here. <ide> from numpy.distutils import cpuinfo <ide> <del> # Ignore the warning from importing the array_api submodule. This <del> # warning is done on import, so it would break pytest collection, <del> # but importing it early here prevents the warning from being <del> # issued when it imported again. <del> warnings.simplefilter("ignore") <del> import numpy.array_api <add> if sys.version_info >= (3, 8): <add> # Ignore the warning from importing the array_api submodule. This <add> # warning is done on import, so it would break pytest collection, <add> # but importing it early here prevents the warning from being <add> # issued when it imported again. <add> warnings.simplefilter("ignore") <add> import numpy.array_api <add> else: <add> # The array_api submodule is Python 3.8+ only due to the use <add> # of positional-only argument syntax. We have to ignore it <add> # completely or the tests will fail at the collection stage. <add> pytest_args += ['--ignore-glob=numpy/array_api/*'] <ide> <ide> # Filter out annoying import messages. Want these in both develop and <ide> # release mode.
1
PHP
PHP
fix more risky tests
63b8d021864ae0eed4106efba0a0ea76958c7627
<ide><path>tests/TestCase/TestSuite/TestCaseTest.php <ide> class TestCaseTest extends TestCase { <ide> public function testAssertHtmlBasic() { <ide> $test = new AssertHtmlTestCase('testAssertHtmlQuotes'); <ide> $result = $test->run(); <add> ob_start(); <ide> $this->assertEquals(0, $result->errorCount()); <ide> $this->assertTrue($result->wasSuccessful()); <ide> $this->assertEquals(0, $result->failureCount()); <ide> public function testAssertHtmlRuntimeComplexity() { <ide> public function testNumericValuesInExpectationForAssertHtml() { <ide> $test = new AssertHtmlTestCase('testNumericValuesInExpectationForAssertHtml'); <ide> $result = $test->run(); <add> ob_start(); <ide> $this->assertEquals(0, $result->errorCount()); <ide> $this->assertTrue($result->wasSuccessful()); <ide> $this->assertEquals(0, $result->failureCount()); <ide> public function testNumericValuesInExpectationForAssertHtml() { <ide> public function testBadAssertHtml() { <ide> $test = new AssertHtmlTestCase('testBadAssertHtml'); <ide> $result = $test->run(); <add> ob_start(); <ide> $this->assertEquals(0, $result->errorCount()); <ide> $this->assertFalse($result->wasSuccessful()); <ide> $this->assertEquals(1, $result->failureCount()); <ide> <ide> $test = new AssertHtmlTestCase('testBadAssertHtml2'); <ide> $result = $test->run(); <add> ob_start(); <ide> $this->assertEquals(0, $result->errorCount()); <ide> $this->assertFalse($result->wasSuccessful()); <ide> $this->assertEquals(1, $result->failureCount()); <ide> public function testLoadFixturesOnDemand() { <ide> $test->fixtureManager = $manager; <ide> $manager->expects($this->once())->method('loadSingle'); <ide> $result = $test->run(); <add> ob_start(); <add> <ide> $this->assertEquals(0, $result->errorCount()); <ide> } <ide> <ide> public function testLoadFixturesOnDemand() { <ide> public function testSkipIf() { <ide> $test = new FixturizedTestCase('testSkipIfTrue'); <ide> $result = $test->run(); <add> ob_start(); <ide> $this->assertEquals(1, $result->skippedCount()); <ide> <ide> $test = new FixturizedTestCase('testSkipIfFalse'); <ide> $result = $test->run(); <add> ob_start(); <ide> $this->assertEquals(0, $result->skippedCount()); <ide> } <ide>
1