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
Text
Text
add translations to titles and fix typo
7f25b2c7e3a3940c8e0711fb8de571353a126cef
<ide><path>curriculum/challenges/portuguese/03-front-end-libraries/bootstrap/add-elements-within-your-bootstrap-wells.portuguese.md <ide> videoUrl: '' <ide> localeTitle: Adicionar elementos dentro dos seus poços de bootstrap <ide> --- <ide> <del>## Description <del><section id="description"> Agora temos vários elementos <code>div</code> em cada coluna da nossa linha. Isso é tão profundo quanto precisaremos ir. Agora podemos adicionar nossos elementos de <code>button</code> . Aninhe três elementos de <code>button</code> dentro de cada um dos elementos do seu <code>well</code> <code>div</code> . </section> <add>## Descrição <add><section id="description"> Agora temos vários elementos <code>div</code> em cada coluna da nossa linha. Isso é tão profundo quanto precisaremos ir. Agora podemos adicionar nossos elementos de <code>button</code> . Alinhe três elementos de <code>button</code> dentro de cada um dos elementos do seu <code>well</code> <code>div</code> . </section> <ide> <del>## Instructions <add>## Instruções <ide> <section id="instructions"> <ide> </section> <ide> <del>## Tests <add>## Testes <ide> <section id='tests'> <ide> <ide> ```yml <ide> tests: <del> - text: Aninhe três elementos de <code>button</code> dentro de cada um dos seus elementos <code>div</code> com classe <code>well</code> . <add> - text: Alinhe três elementos de <code>button</code> dentro de cada um dos seus elementos <code>div</code> com classe <code>well</code> . <ide> testString: 'assert($("div.well:eq(0)").children("button").length === 3 && $("div.well:eq(1)").children("button").length === 3, "Nest three <code>button</code> elements within each of your <code>div</code> elements with class <code>well</code>.");' <ide> - text: Você deve ter um total de 6 elementos de <code>button</code> . <ide> testString: 'assert($("button") && $("button").length > 5, "You should have a total of 6 <code>button</code> elements.");' <ide> tests: <ide> <ide> </section> <ide> <del>## Solution <add>## Solução <ide> <section id='solution'> <ide> <ide> ```js
1
Ruby
Ruby
avoid extra recursive call in sprockets helpers
381904d26b601c89e2a8496612a7c76db8ae9359
<ide><path>actionpack/lib/sprockets/helpers/rails_helper.rb <ide> def javascript_include_tag(*sources) <ide> sources.collect do |source| <ide> if debug && asset = asset_paths.asset_for(source, 'js') <ide> asset.to_a.map { |dep| <del> javascript_include_tag(dep, options.merge({ :debug => false, :body => true })) <add> super(dep.to_s, { :src => asset_path(dep, 'js', true) }.merge!(options)) <ide> } <ide> else <ide> super(source.to_s, { :src => asset_path(source, 'js', body) }.merge!(options)) <ide> def stylesheet_link_tag(*sources) <ide> sources.collect do |source| <ide> if debug && asset = asset_paths.asset_for(source, 'css') <ide> asset.to_a.map { |dep| <del> stylesheet_link_tag(dep, options.merge({ :debug => false, :body => true })) <add> super(dep.to_s, { :href => asset_path(dep, 'css', true, :request) }.merge!(options)) <ide> } <ide> else <ide> super(source.to_s, { :href => asset_path(source, 'css', body, :request) }.merge!(options))
1
PHP
PHP
hasmiddleware
1c2f33316ac8e2ff0d7ff765ef086cd52b04a8fd
<ide><path>src/Illuminate/Foundation/Http/Kernel.php <ide> protected function dispatchToRouter() <ide> */ <ide> public function hasMiddleware($middleware) <ide> { <del> return array_key_exists($middleware, array_flip($this->middleware)); <add> return in_array($middleware, $this->middleware); <ide> } <ide> <ide> /**
1
Ruby
Ruby
move argument validation into match
fe12497e4d8ad292ffbcb4486a26b8802c19d65d
<ide><path>activerecord/lib/active_record/dynamic_finder_match.rb <ide> def instantiator? <ide> def bang? <ide> false <ide> end <add> <add> def valid_arguments?(arguments) <add> arguments.size >= @attribute_names.size <add> end <ide> end <ide> <ide> class FindBy < DynamicFinderMatch <ide> def self.match(method) <ide> new(:first, $2, $1 == 'initialize' ? :new : :create) <ide> end <ide> end <add> <add> def valid_arguments?(arguments) <add> arguments.size == 1 && arguments.first.is_a?(Hash) || super <add> end <ide> end <ide> end <ide><path>activerecord/lib/active_record/dynamic_matchers.rb <ide> def method_missing(method_id, *arguments, &block) <ide> if match = (DynamicFinderMatch.match(method_id) || DynamicScopeMatch.match(method_id)) <ide> attribute_names = match.attribute_names <ide> super unless all_attributes_exists?(attribute_names) <del> if !(match.is_a?(DynamicFinderMatch) && match.instantiator? && arguments.first.is_a?(Hash)) && arguments.size < attribute_names.size <add> unless match.valid_arguments?(arguments) <ide> method_trace = "#{__FILE__}:#{__LINE__}:in `#{method_id}'" <ide> backtrace = [method_trace] + caller <ide> raise ArgumentError, "wrong number of arguments (#{arguments.size} for #{attribute_names.size})", backtrace <ide><path>activerecord/lib/active_record/dynamic_scope_match.rb <ide> def initialize(scope, attribute_names) <ide> <ide> attr_reader :scope, :attribute_names <ide> alias :scope? :scope <add> <add> def valid_arguments?(arguments) <add> arguments.size >= @attribute_names.size <add> end <ide> end <ide> end
3
Go
Go
remove backward compat hack for go < 1.9
cddaa8477786011227677a8a220de0a380387d02
<ide><path>builder/remotecontext/tarsum_test.go <ide> func TestHashFile(t *testing.T) { <ide> t.Fatalf("Hash returned empty sum") <ide> } <ide> <del> expected := "1149ab94af7be6cc1da1335e398f24ee1cf4926b720044d229969dfc248ae7ec" <add> expected := "55dfeb344351ab27f59aa60ebb0ed12025a2f2f4677bf77d26ea7a671274a9ca" <ide> <ide> if actual := sum; expected != actual { <ide> t.Fatalf("invalid checksum. expected %s, got %s", expected, actual) <ide> func TestHashSubdir(t *testing.T) { <ide> t.Fatalf("Hash returned empty sum") <ide> } <ide> <del> expected := "d7f8d6353dee4816f9134f4156bf6a9d470fdadfb5d89213721f7e86744a4e69" <add> expected := "74a3326b8e766ce63a8e5232f22e9dd895be647fb3ca7d337e5e0a9b3da8ef28" <ide> <ide> if actual := sum; expected != actual { <ide> t.Fatalf("invalid checksum. expected %s, got %s", expected, actual) <ide><path>pkg/archive/archive.go <ide> const ( <ide> OverlayWhiteoutFormat <ide> ) <ide> <del>const ( <del> modeISDIR = 040000 // Directory <del> modeISFIFO = 010000 // FIFO <del> modeISREG = 0100000 // Regular file <del> modeISLNK = 0120000 // Symbolic link <del> modeISBLK = 060000 // Block special file <del> modeISCHR = 020000 // Character special file <del> modeISSOCK = 0140000 // Socket <del>) <del> <ide> // IsArchivePath checks if the (possibly compressed) file at the given path <ide> // starts with a tar file header. <ide> func IsArchivePath(path string) bool { <ide> func FileInfoHeaderNoLookups(fi os.FileInfo, link string) (*tar.Header, error) { <ide> // but is safe to call from a chrooted process. The AccessTime and ChangeTime <ide> // fields are not set in the returned header, ModTime is truncated to one-second <ide> // precision, and the Uname and Gname fields are only set when fi is a FileInfo <del>// value returned from tar.Header.FileInfo(). Also, regardless of Go version, <del>// this function fills file type bits (e.g. hdr.Mode |= modeISDIR), which have <del>// been deleted since Go 1.9 archive/tar. <add>// value returned from tar.Header.FileInfo(). <ide> func FileInfoHeader(name string, fi os.FileInfo, link string) (*tar.Header, error) { <ide> hdr, err := FileInfoHeaderNoLookups(fi, link) <ide> if err != nil { <ide> func FileInfoHeader(name string, fi os.FileInfo, link string) (*tar.Header, erro <ide> hdr.ModTime = hdr.ModTime.Truncate(time.Second) <ide> hdr.AccessTime = time.Time{} <ide> hdr.ChangeTime = time.Time{} <del> hdr.Mode = fillGo18FileTypeBits(int64(chmodTarEntry(os.FileMode(hdr.Mode))), fi) <add> hdr.Mode = int64(chmodTarEntry(os.FileMode(hdr.Mode))) <ide> hdr.Name = canonicalTarName(name, fi.IsDir()) <ide> return hdr, nil <ide> } <ide> <del>// fillGo18FileTypeBits fills type bits which have been removed on Go 1.9 archive/tar <del>// https://github.com/golang/go/commit/66b5a2f <del>func fillGo18FileTypeBits(mode int64, fi os.FileInfo) int64 { <del> fm := fi.Mode() <del> switch { <del> case fm.IsRegular(): <del> mode |= modeISREG <del> case fi.IsDir(): <del> mode |= modeISDIR <del> case fm&os.ModeSymlink != 0: <del> mode |= modeISLNK <del> case fm&os.ModeDevice != 0: <del> if fm&os.ModeCharDevice != 0 { <del> mode |= modeISCHR <del> } else { <del> mode |= modeISBLK <del> } <del> case fm&os.ModeNamedPipe != 0: <del> mode |= modeISFIFO <del> case fm&os.ModeSocket != 0: <del> mode |= modeISSOCK <del> } <del> return mode <del>} <del> <ide> // ReadSecurityXattrToTarHeader reads security.capability xattr from filesystem <ide> // to a tar header <ide> func ReadSecurityXattrToTarHeader(path string, hdr *tar.Header) error { <ide><path>pkg/archive/archive_windows.go <ide> func CanonicalTarNameForPath(p string) string { <ide> // chmodTarEntry is used to adjust the file permissions used in tar header based <ide> // on the platform the archival is done. <ide> func chmodTarEntry(perm os.FileMode) os.FileMode { <del> // perm &= 0755 // this 0-ed out tar flags (like link, regular file, directory marker etc.) <del> permPart := perm & os.ModePerm <del> noPermPart := perm &^ os.ModePerm <del> // Add the x bit: make everything +x from windows <del> permPart |= 0111 <del> permPart &= 0755 <del> <del> return noPermPart | permPart <add> // Add the x bit: make everything +x on Windows <add> return perm | 0111 <ide> } <ide> <ide> func setHeaderForSpecialDevice(hdr *tar.Header, name string, stat interface{}) (err error) { <ide><path>pkg/archive/archive_windows_test.go <ide> func TestChmodTarEntry(t *testing.T) { <ide> in, expected os.FileMode <ide> }{ <ide> {0000, 0111}, <del> {0777, 0755}, <add> {0777, 0777}, <ide> {0644, 0755}, <ide> {0755, 0755}, <ide> {0444, 0555}, <del> {0755 | os.ModeDir, 0755 | os.ModeDir}, <del> {0755 | os.ModeSymlink, 0755 | os.ModeSymlink}, <ide> } <ide> for _, v := range cases { <ide> if out := chmodTarEntry(v.in); out != v.expected {
4
PHP
PHP
improve deprecation error
cc269286767a875bc781fe4497764c08614f3586
<ide><path>src/Database/Type.php <ide> public function toPHP($value, Driver $driver) <ide> */ <ide> protected function _basicTypeCast($value) <ide> { <del> deprecationWarning('Type::_basicTypeCast() is deprecated.'); <add> deprecationWarning( <add> 'Using Type::_basicTypeCast() is deprecated. ' . <add> "The '{$this->_name}' type needs to be updated to implement `TypeInterface`." <add> ); <ide> if ($value === null) { <ide> return null; <ide> }
1
Javascript
Javascript
add regression test for 13557
871e4d0280178ce1ec2955f9b3f71b528077f6fd
<ide><path>test/parallel/test-readline-reopen.js <add>'use strict'; <add> <add>// Regression test for https://github.com/nodejs/node/issues/13557 <add>// Tests that multiple subsequent readline instances can re-use an input stream. <add> <add>const common = require('../common'); <add>const assert = require('assert'); <add>const readline = require('readline'); <add>const { PassThrough } = require('stream'); <add> <add>const input = new PassThrough(); <add>const output = new PassThrough(); <add> <add>const rl1 = readline.createInterface({ <add> input, <add> output, <add> terminal: true <add>}); <add> <add>rl1.on('line', common.mustCall(rl1OnLine)); <add> <add>// Write a line plus the first byte of a UTF-8 multibyte character to make sure <add>// that it doesn’t get lost when closing the readline instance. <add>input.write(Buffer.concat([ <add> Buffer.from('foo\n'), <add> Buffer.from([ 0xe2 ]) // Exactly one third of a ☃ snowman. <add>])); <add> <add>function rl1OnLine(line) { <add> assert.strictEqual(line, 'foo'); <add> rl1.close(); <add> const rl2 = readline.createInterface({ <add> input, <add> output, <add> terminal: true <add> }); <add> <add> rl2.on('line', common.mustCall((line) => { <add> assert.strictEqual(line, '☃bar'); <add> rl2.close(); <add> })); <add> input.write(Buffer.from([0x98, 0x83])); // The rest of the ☃ snowman. <add> input.write('bar\n'); <add>}
1
Ruby
Ruby
add cairomm@1.14 to allowlist
5d0a4d58c28420864aa248114a54572c694e474d
<ide><path>Library/Homebrew/formula_auditor.rb <ide> def audit_postgresql <ide> openssl@1.1 <ide> python@3.8 <ide> python@3.9 <add> cairomm@1.14 <ide> ].freeze <ide> <ide> def audit_versioned_keg_only
1
Java
Java
fix typos in javadoc comments
db76ba2b792f14ab2a18fb5d226d5ebb2f55a4cb
<ide><path>rxjava-core/src/main/java/rx/Observable.java <ide> public final Observable<T> repeat(final long count, Scheduler scheduler) { <ide> * </dl> <ide> * <ide> * @param notificationHandler <del> * recieves an Observable of notifications with which a user can complete or error, aborting the repeat. <add> * receives an Observable of notifications with which a user can complete or error, aborting the repeat. <ide> * @param scheduler <ide> * the {@link Scheduler} to emit the items on <ide> * @return the source Observable modified with repeat logic <ide> public final Observable<T> repeatWhen(Func1<? super Observable<? extends Notific <ide> * </dl> <ide> * <ide> * @param notificationHandler <del> * recieves an Observable of notifications with which a user can complete or error, aborting the repeat. <add> * receives an Observable of notifications with which a user can complete or error, aborting the repeat. <ide> * @return the source Observable modified with repeat logic <ide> * @see <a href="https://github.com/Netflix/RxJava/wiki/Creating-Observables#repeatwhen">RxJava Wiki: repeatWhen()</a> <ide> * @see <a href="http://msdn.microsoft.com/en-us/library/hh229428.aspx">MSDN: Observable.Repeat</a> <ide> public final Observable<T> retry(Func2<Integer, Throwable, Boolean> predicate) { <ide> * </dl> <ide> * <ide> * @param notificationHandler <del> * recieves an Observable of notifications with which a user can complete or error, aborting the <add> * receives an Observable of notifications with which a user can complete or error, aborting the <ide> * retry <ide> * @return the source Observable modified with retry logic <ide> * @see <a href="https://github.com/Netflix/RxJava/wiki/Error-Handling-Operators#retrywhen">RxJava Wiki: retryWhen()</a> <ide> public final Observable<T> retryWhen(Func1<? super Observable<? extends Notifica <ide> * </dl> <ide> * <ide> * @param notificationHandler <del> * recieves an Observable of notifications with which a user can complete or error, aborting the <add> * receives an Observable of notifications with which a user can complete or error, aborting the <ide> * retry <ide> * @param scheduler <ide> * the {@link Scheduler} on which to subscribe to the source Observable
1
Go
Go
fix bug in getrootresourcepath in previous commit
48907d57ede696c68e210cb93cb405124a49cbd3
<ide><path>daemon/container.go <ide> func (container *Container) WriteHostConfig() error { <ide> <ide> func (container *Container) getResourcePath(path string) (string, error) { <ide> cleanPath := filepath.Join("/", path) <del> fullPath := filepath.Join(container.basefs, cleanPath) <del> <del> result, err := symlink.FollowSymlinkInScope(fullPath, container.basefs) <del> if err != nil { <del> return "", err <del> } <del> <del> return result, nil <add> return symlink.FollowSymlinkInScope(filepath.Join(container.basefs, cleanPath), container.basefs) <ide> } <ide> <ide> func (container *Container) getRootResourcePath(path string) (string, error) { <ide> cleanPath := filepath.Join("/", path) <del> fullPath := filepath.Join(container.root, cleanPath) <del> <del> result, err := symlink.FollowSymlinkInScope(fullPath, container.basefs) <del> if err != nil { <del> return "", err <del> } <del> <del> return result, nil <add> return symlink.FollowSymlinkInScope(filepath.Join(container.root, cleanPath), container.root) <ide> } <ide> <ide> func populateCommand(c *Container, env []string) error {
1
Text
Text
fix equality expression in ternary operator
9900699d0bf7650914d7f98c953415ffc59c9b01
<ide><path>guide/english/certifications/javascript-algorithms-and-data-structures/basic-javascript/use-the-conditional-ternary-operator/index.md <ide> Use ternary operator to check for equality. <ide> <ide> ```javascript <ide> function checkEqual(a, b) { <del> return (a = b ? true : false ); <add> return (a == b ? true : false ); <ide> } <ide> <ide> checkEqual(1, 2);
1
Java
Java
ensure undertow 1.1 compatibility
73267d75230dfb90097133017f203ca15ef813db
<ide><path>spring-websocket/src/main/java/org/springframework/web/socket/server/standard/UndertowRequestUpgradeStrategy.java <ide> <ide> package org.springframework.web.socket.server.standard; <ide> <add>import java.lang.reflect.Constructor; <ide> import java.util.Arrays; <ide> import java.util.Collections; <ide> import java.util.List; <add>import java.util.Set; <add>import java.util.concurrent.ConcurrentHashMap; <ide> import javax.servlet.http.HttpServletRequest; <ide> import javax.servlet.http.HttpServletResponse; <ide> import javax.websocket.Decoder; <ide> import io.undertow.websockets.core.WebSocketChannel; <ide> import io.undertow.websockets.core.WebSocketVersion; <ide> import io.undertow.websockets.core.protocol.Handshake; <del>import io.undertow.websockets.core.protocol.version07.Hybi07Handshake; <del>import io.undertow.websockets.core.protocol.version08.Hybi08Handshake; <del>import io.undertow.websockets.core.protocol.version13.Hybi13Handshake; <ide> import io.undertow.websockets.jsr.ConfiguredServerEndpoint; <ide> import io.undertow.websockets.jsr.EncodingFactory; <ide> import io.undertow.websockets.jsr.EndpointSessionHandler; <ide> import io.undertow.websockets.jsr.handshake.JsrHybi07Handshake; <ide> import io.undertow.websockets.jsr.handshake.JsrHybi08Handshake; <ide> import io.undertow.websockets.jsr.handshake.JsrHybi13Handshake; <add>import org.springframework.util.ClassUtils; <ide> import org.xnio.StreamConnection; <ide> <ide> import org.springframework.http.server.ServerHttpRequest; <ide> */ <ide> public class UndertowRequestUpgradeStrategy extends AbstractStandardUpgradeStrategy { <ide> <del> private final String[] supportedVersions = new String[] { <add> private static final Constructor<ServletWebSocketHttpExchange> exchangeConstructor; <add> <add> private static final boolean undertow10Present; <add> <add> static { <add> Class<ServletWebSocketHttpExchange> type = ServletWebSocketHttpExchange.class; <add> Class<?>[] paramTypes = new Class<?>[] {HttpServletRequest.class, HttpServletResponse.class, Set.class}; <add> if (ClassUtils.hasConstructor(type, paramTypes)) { <add> exchangeConstructor = ClassUtils.getConstructorIfAvailable(type, paramTypes); <add> undertow10Present = false; <add> } <add> else { <add> paramTypes = new Class<?>[] {HttpServletRequest.class, HttpServletResponse.class}; <add> exchangeConstructor = ClassUtils.getConstructorIfAvailable(type, paramTypes); <add> undertow10Present = true; <add> } <add> } <add> <add> private static final String[] supportedVersions = new String[] { <ide> WebSocketVersion.V13.toHttpHeaderValue(), <ide> WebSocketVersion.V08.toHttpHeaderValue(), <ide> WebSocketVersion.V07.toHttpHeaderValue() <ide> }; <ide> <ide> <add> private Set<WebSocketChannel> peerConnections; <add> <add> <add> public UndertowRequestUpgradeStrategy() { <add> if (undertow10Present) { <add> this.peerConnections = null; <add> } <add> else { <add> this.peerConnections = Collections.newSetFromMap(new ConcurrentHashMap<WebSocketChannel, Boolean>()); <add> } <add> } <add> <add> <ide> @Override <ide> public String[] getSupportedVersions() { <del> return this.supportedVersions; <add> return supportedVersions; <ide> } <ide> <ide> @Override <ide> protected void upgradeInternal(ServerHttpRequest request, ServerHttpResponse res <ide> HttpServletRequest servletRequest = getHttpServletRequest(request); <ide> HttpServletResponse servletResponse = getHttpServletResponse(response); <ide> <del> final ServletWebSocketHttpExchange exchange = new ServletWebSocketHttpExchange(servletRequest, servletResponse); <add> final ServletWebSocketHttpExchange exchange = createHttpExchange(servletRequest, servletResponse); <ide> exchange.putAttachment(HandshakeUtil.PATH_PARAMS, Collections.<String, String>emptyMap()); <ide> <ide> ServerWebSocketContainer wsContainer = (ServerWebSocketContainer) getContainer(servletRequest); <ide> protected void upgradeInternal(ServerHttpRequest request, ServerHttpResponse res <ide> @Override <ide> public void handleUpgrade(StreamConnection connection, HttpServerExchange serverExchange) { <ide> WebSocketChannel channel = handshake.createChannel(exchange, connection, exchange.getBufferPool()); <add> if (peerConnections != null) { <add> peerConnections.add(channel); <add> } <ide> endpointSessionHandler.onConnect(exchange, channel); <ide> } <ide> }); <ide> <ide> handshake.handshake(exchange); <ide> } <ide> <add> private ServletWebSocketHttpExchange createHttpExchange(HttpServletRequest request, HttpServletResponse response) { <add> try { <add> return (this.peerConnections != null ? <add> exchangeConstructor.newInstance(request, response, this.peerConnections) : <add> exchangeConstructor.newInstance(request, response)); <add> } <add> catch (Exception ex) { <add> throw new HandshakeFailureException("Failed to instantiate ServletWebSocketHttpExchange", ex); <add> } <add> } <add> <ide> private Handshake getHandshakeToUse(ServletWebSocketHttpExchange exchange, ConfiguredServerEndpoint endpoint) { <ide> Handshake handshake = new JsrHybi13Handshake(endpoint); <ide> if (handshake.matches(exchange)) {
1
Text
Text
use more consistent formatting for deprecations
975bbbc443c47df777d460fadaada3c6d265b321
<ide><path>doc/api/deprecations.md <ide> Assigning properties to the top-level `this` as an alternative <ide> to `module.exports` is deprecated. Developers should use `exports` <ide> or `module.exports` instead. <ide> <del>### DEP0093: `crypto.fips` is deprecated and replaced. <add>### DEP0093: `crypto.fips` is deprecated and replaced <ide> <!-- YAML <ide> changes: <ide> - version: v10.0.0 <ide> Type: Documentation-only <ide> The [`crypto.fips`][] property is deprecated. Please use `crypto.setFips()` <ide> and `crypto.getFips()` instead. <ide> <del>### DEP0094: Using `assert.fail()` with more than one argument. <add>### DEP0094: Using `assert.fail()` with more than one argument <ide> <!-- YAML <ide> changes: <ide> - version: v10.0.0 <ide> Type: End-of-Life <ide> <ide> The `--with-lttng` compile-time option has been removed. <ide> <del>### DEP0102: Using `noAssert` in `Buffer#(read|write)` operations. <add>### DEP0102: Using `noAssert` in `Buffer#(read|write)` operations <ide> <!-- YAML <ide> changes: <ide> - version: v10.0.0
1
Ruby
Ruby
add comment about content-disposition handling
d330e915d13c11a4701c7e9e159a93140cfac7cd
<ide><path>Library/Homebrew/download_strategy.rb <ide> def resolve_url_basename_time_file_size(url) <ide> filename = URI.decode_www_form_component(encoded_filename).encode(encoding) if encoding && encoded_filename <ide> end <ide> <add> # Servers may include '/' in their Content-Disposition filename header. Take only the basename of this, because: <add> # - Unpacking code assumes this is a single file - not something living in a subdirectory. <add> # - Directory traversal attacks are possible without limiting this to just the basename. <ide> (filename || content_disposition.filename).rpartition("/")[-1] <ide> end <ide>
1
Text
Text
add action cable to readme.md of rails
98087a604c988e2fd906cc7c63b30ea495679a5f
<ide><path>README.md <ide> Active Record, Active Model, Action Pack, and Action View can each be used indep <ide> In addition to them, Rails also comes with Action Mailer ([README](actionmailer/README.rdoc)), a library <ide> to generate and send emails; Active Job ([README](activejob/README.md)), a <ide> framework for declaring jobs and making them run on a variety of queueing <del>backends; and Active Support ([README](activesupport/README.rdoc)), a collection <add>backends; Action Cable ([README](actioncable/README.md)), a framework to <add>integrate WebSockets with a Rails application; <add>and Active Support ([README](activesupport/README.rdoc)), a collection <ide> of utility classes and standard library extensions that are useful for Rails, <ide> and may also be used independently outside Rails. <ide>
1
Javascript
Javascript
flow type and codegen for androidtextinput
ba56fa43f0a89a7f2654d6ba9655356bb975f56d
<ide><path>Libraries/Components/TextInput/AndroidTextInputNativeComponent.js <ide> <ide> 'use strict'; <ide> <add>import type {ViewProps} from '../View/ViewPropTypes'; <add>import type { <add> BubblingEventHandler, <add> DirectEventHandler, <add> Double, <add> Float, <add> Int32, <add>} from 'react-native/Libraries/Types/CodegenTypes'; <add>import type {NativeComponent} from '../../Renderer/shims/ReactNative'; <add>import type {TextStyleProp, ViewStyleProp} from '../../StyleSheet/StyleSheet'; <add>import type {ColorValue} from '../../StyleSheet/StyleSheetTypes'; <ide> import {requireNativeComponent} from 'react-native'; <ide> <del>const AndroidTextInputNativeComponent: string = requireNativeComponent( <del> 'AndroidTextInput', <del>); <add>/*export type KeyboardType = <add> // Cross Platform <add> | 'default' <add> | 'email-address' <add> | 'numeric' <add> | 'phone-pad' <add> | 'number-pad' <add> | 'decimal-pad' <add> // iOS-only <add> | 'ascii-capable' <add> | 'numbers-and-punctuation' <add> | 'url' <add> | 'name-phone-pad' <add> | 'twitter' <add> | 'web-search' <add> // Android-only <add> | 'visible-password';*/ <add> <add>/*export type ReturnKeyType = <add> // Cross Platform <add> | 'done' <add> | 'go' <add> | 'next' <add> | 'search' <add> | 'send' <add> // Android-only <add> | 'none' <add> | 'previous' <add> // iOS-only <add> | 'default' <add> | 'emergency-call' <add> | 'google' <add> | 'join' <add> | 'route' <add> | 'yahoo';*/ <add> <add>export type NativeProps = $ReadOnly<{| <add> // This allows us to inherit everything from ViewProps except for style (see below) <add> // This must be commented for Fabric codegen to work. <add> ...$Diff<ViewProps, $ReadOnly<{|style: ?ViewStyleProp|}>>, <add> <add> /** <add> * Android props after this <add> */ <add> /** <add> * Determines which content to suggest on auto complete, e.g.`username`. <add> * To disable auto complete, use `off`. <add> * <add> * *Android Only* <add> * <add> * The following values work on Android only: <add> * <add> * - `username` <add> * - `password` <add> * - `email` <add> * - `name` <add> * - `tel` <add> * - `street-address` <add> * - `postal-code` <add> * - `cc-number` <add> * - `cc-csc` <add> * - `cc-exp` <add> * - `cc-exp-month` <add> * - `cc-exp-year` <add> * - `off` <add> * <add> * @platform android <add> */ <add> // TODO T53321474: define as flow enum <add> autoCompleteType?: ?string /*WithDefault< <add> ?( <add> | 'cc-csc' <add> | 'cc-exp' <add> | 'cc-exp-month' <add> | 'cc-exp-year' <add> | 'cc-number' <add> | 'email' <add> | 'name' <add> | 'password' <add> | 'postal-code' <add> | 'street-address' <add> | 'tel' <add> | 'username' <add> | 'off' <add> ), <add> 'off', <add> >*/, <add> <add> /** <add> * Sets the return key to the label. Use it instead of `returnKeyType`. <add> * @platform android <add> */ <add> returnKeyLabel?: ?string, <add> <add> /** <add> * Sets the number of lines for a `TextInput`. Use it with multiline set to <add> * `true` to be able to fill the lines. <add> * @platform android <add> */ <add> numberOfLines?: ?Int32, <add> <add> /** <add> * When `false`, if there is a small amount of space available around a text input <add> * (e.g. landscape orientation on a phone), the OS may choose to have the user edit <add> * the text inside of a full screen text input mode. When `true`, this feature is <add> * disabled and users will always edit the text directly inside of the text input. <add> * Defaults to `false`. <add> * @platform android <add> */ <add> disableFullscreenUI?: ?boolean, <add> <add> /** <add> * Set text break strategy on Android API Level 23+, possible values are `simple`, `highQuality`, `balanced` <add> * The default value is `simple`. <add> * @platform android <add> */ <add> // TODO T53321474: enable enum types in codegen <add> textBreakStrategy?: string, // ?('simple' | 'highQuality' | 'balanced'), <add> <add> /** <add> * The color of the `TextInput` underline. <add> * @platform android <add> */ <add> underlineColorAndroid?: ?ColorValue, <add> <add> /** <add> * If defined, the provided image resource will be rendered on the left. <add> * The image resource must be inside `/android/app/src/main/res/drawable` and referenced <add> * like <add> * ``` <add> * <TextInput <add> * inlineImageLeft='search_icon' <add> * /> <add> * ``` <add> * @platform android <add> */ <add> inlineImageLeft?: ?string, <add> <add> /** <add> * Padding between the inline image, if any, and the text input itself. <add> * @platform android <add> */ <add> inlineImagePadding?: ?Int32, <add> <add> importantForAutofill?: string /*?( <add> | 'auto' <add> | 'no' <add> | 'noExcludeDescendants' <add> | 'yes' <add> | 'yesExcludeDescendants' <add> ),*/, <add> <add> /** <add> * When `false`, it will prevent the soft keyboard from showing when the field is focused. <add> * Defaults to `true`. <add> * @platform android <add> */ <add> showSoftInputOnFocus?: ?boolean, <add> <add> /** <add> * TextInput props after this <add> */ <add> /** <add> * Can tell `TextInput` to automatically capitalize certain characters. <add> * <add> * - `characters`: all characters. <add> * - `words`: first letter of each word. <add> * - `sentences`: first letter of each sentence (*default*). <add> * - `none`: don't auto capitalize anything. <add> */ <add> autoCapitalize?: ?string, // TODO T53321474: define as enum: AutoCapitalize 'none' | 'sentences' | 'words' | 'characters' , <add> <add> /** <add> * If `false`, disables auto-correct. The default value is `true`. <add> */ <add> autoCorrect?: ?boolean, <add> <add> /** <add> * If `true`, focuses the input on `componentDidMount`. <add> * The default value is `false`. <add> */ <add> autoFocus?: ?boolean, <add> <add> /** <add> * Specifies whether fonts should scale to respect Text Size accessibility settings. The <add> * default is `true`. <add> */ <add> allowFontScaling?: ?boolean, <add> <add> /** <add> * Specifies largest possible scale a font can reach when `allowFontScaling` is enabled. <add> * Possible values: <add> * `null/undefined` (default): inherit from the parent node or the global default (0) <add> * `0`: no max, ignore parent/global default <add> * `>= 1`: sets the maxFontSizeMultiplier of this node to this value <add> */ <add> maxFontSizeMultiplier?: ?Float, <add> <add> /** <add> * If `false`, text is not editable. The default value is `true`. <add> */ <add> editable?: ?boolean, <add> <add> /** <add> * Determines which keyboard to open, e.g.`numeric`. <add> * <add> * The following values work across platforms: <add> * <add> * - `default` <add> * - `numeric` <add> * - `number-pad` <add> * - `decimal-pad` <add> * - `email-address` <add> * - `phone-pad` <add> * <add> * *iOS Only* <add> * <add> * The following values work on iOS only: <add> * <add> * - `ascii-capable` <add> * - `numbers-and-punctuation` <add> * - `url` <add> * - `name-phone-pad` <add> * - `twitter` <add> * - `web-search` <add> * <add> * *Android Only* <add> * <add> * The following values work on Android only: <add> * <add> * - `visible-password` <add> */ <add> // TODO T53321474: enable enum codegen <add> keyboardType?: ?string, // ?KeyboardType, <add> <add> /** <add> * Determines how the return key should look. On Android you can also use <add> * `returnKeyLabel`. <add> * <add> * *Cross platform* <add> * <add> * The following values work across platforms: <add> * <add> * - `done` <add> * - `go` <add> * - `next` <add> * - `search` <add> * - `send` <add> * <add> * *Android Only* <add> * <add> * The following values work on Android only: <add> * <add> * - `none` <add> * - `previous` <add> * <add> * *iOS Only* <add> * <add> * The following values work on iOS only: <add> * <add> * - `default` <add> * - `emergency-call` <add> * - `google` <add> * - `join` <add> * - `route` <add> * - `yahoo` <add> */ <add> // TODO T53321474: enable enum codegen <add> returnKeyType?: ?string, // ?ReturnKeyType, <add> <add> /** <add> * Limits the maximum number of characters that can be entered. Use this <add> * instead of implementing the logic in JS to avoid flicker. <add> */ <add> maxLength?: ?Int32, <add> <add> /** <add> * If `true`, the text input can be multiple lines. <add> * The default value is `false`. <add> */ <add> multiline?: ?boolean, <add> <add> /** <add> * Callback that is called when the text input is blurred. <add> * `target` is the reactTag of the element <add> */ <add> onBlur?: ?BubblingEventHandler<$ReadOnly<{|target: Int32|}>>, <add> <add> /** <add> * Callback that is called when the text input is focused. <add> * `target` is the reactTag of the element <add> */ <add> onFocus?: ?BubblingEventHandler<$ReadOnly<{|target: Int32|}>>, <add> <add> /** <add> * Callback that is called when the text input's text changes. <add> * `target` is the reactTag of the element <add> * TODO: differentiate between onChange and onChangeText <add> */ <add> onChange?: ?BubblingEventHandler< <add> $ReadOnly<{|target: Int32, eventCount: Int32, text: string|}>, <add> >, <ide> <del>export default AndroidTextInputNativeComponent; <add> /** <add> * Callback that is called when the text input's text changes. <add> * Changed text is passed as an argument to the callback handler. <add> * TODO: differentiate between onChange and onChangeText <add> */ <add> onChangeText?: ?BubblingEventHandler< <add> $ReadOnly<{|target: Int32, eventCount: Int32, text: string|}>, <add> >, <add> <add> /** <add> * Callback that is called when the text input's content size changes. <add> * This will be called with <add> * `{ nativeEvent: { contentSize: { width, height } } }`. <add> * <add> * Only called for multiline text inputs. <add> */ <add> onContentSizeChange?: ?DirectEventHandler< <add> $ReadOnly<{| <add> target: Int32, <add> // contentSize: $ReadOnly<{|width: Double, height: Double|}>, <add> contentSize: {|width: Double, height: Double|}, <add> |}>, <add> >, <add> <add> onTextInput?: ?BubblingEventHandler< <add> $ReadOnly<{| <add> target: Int32, <add> text: string, <add> previousText: string, <add> // range: $ReadOnly<{|start: Double, end: Double|}>, <add> range: {|start: Double, end: Double|}, <add> |}>, <add> >, <add> <add> /** <add> * Callback that is called when text input ends. <add> */ <add> onEndEditing?: ?BubblingEventHandler< <add> $ReadOnly<{|target: Int32, text: string|}>, <add> >, <add> <add> /** <add> * Callback that is called when the text input selection is changed. <add> * This will be called with <add> * `{ nativeEvent: { selection: { start, end } } }`. <add> */ <add> onSelectionChange?: ?DirectEventHandler< <add> $ReadOnly<{| <add> target: Int32, <add> //selection: $ReadOnly<{|start: Double, end: Double|}>, <add> selection: {|start: Double, end: Double|}, <add> |}>, <add> >, <add> <add> /** <add> * Callback that is called when the text input's submit button is pressed. <add> * Invalid if `multiline={true}` is specified. <add> */ <add> onSubmitEditing?: ?BubblingEventHandler< <add> $ReadOnly<{|target: Int32, text: string|}>, <add> >, <add> <add> /** <add> * Callback that is called when a key is pressed. <add> * This will be called with `{ nativeEvent: { key: keyValue } }` <add> * where `keyValue` is `'Enter'` or `'Backspace'` for respective keys and <add> * the typed-in character otherwise including `' '` for space. <add> * Fires before `onChange` callbacks. <add> */ <add> onKeyPress?: ?BubblingEventHandler<$ReadOnly<{|target: Int32, key: string|}>>, <add> <add> /** <add> * Invoked on content scroll with `{ nativeEvent: { contentOffset: { x, y } } }`. <add> * May also contain other properties from ScrollEvent but on Android contentSize <add> * is not provided for performance reasons. <add> */ <add> onScroll?: ?DirectEventHandler< <add> $ReadOnly<{| <add> target: Int32, <add> responderIgnoreScroll: boolean, <add> contentInset: {| <add> //$ReadOnly<{| <add> top: Double, // always 0 on Android <add> bottom: Double, // always 0 on Android <add> left: Double, // always 0 on Android <add> right: Double, // always 0 on Android <add> |}, <add> contentOffset: {| <add> //$ReadOnly<{| <add> x: Double, <add> y: Double, <add> |}, <add> contentSize: {| <add> // $ReadOnly<{| <add> width: Double, // always 0 on Android <add> height: Double, // always 0 on Android <add> |}, <add> layoutMeasurement: {| <add> // $ReadOnly<{| <add> width: Double, <add> height: Double, <add> |}, <add> velocity: {| <add> // $ReadOnly<{| <add> x: Double, // always 0 on Android <add> y: Double, // always 0 on Android <add> |}, <add> |}>, <add> >, <add> <add> /** <add> * The string that will be rendered before text input has been entered. <add> */ <add> placeholder?: ?string, <add> <add> /** <add> * The text color of the placeholder string. <add> */ <add> placeholderTextColor?: ?ColorValue, <add> <add> /** <add> * If `true`, the text input obscures the text entered so that sensitive text <add> * like passwords stay secure. The default value is `false`. Does not work with 'multiline={true}'. <add> */ <add> secureTextEntry?: ?boolean, <add> <add> /** <add> * The highlight and cursor color of the text input. <add> */ <add> selectionColor?: ?ColorValue, <add> <add> /** <add> * The start and end of the text input's selection. Set start and end to <add> * the same value to position the cursor. <add> */ <add> selection?: ?$ReadOnly<{| <add> start: Int32, <add> end?: ?Int32, <add> |}>, <add> <add> /** <add> * The value to show for the text input. `TextInput` is a controlled <add> * component, which means the native value will be forced to match this <add> * value prop if provided. For most uses, this works great, but in some <add> * cases this may cause flickering - one common cause is preventing edits <add> * by keeping value the same. In addition to simply setting the same value, <add> * either set `editable={false}`, or set/update `maxLength` to prevent <add> * unwanted edits without flicker. <add> */ <add> value?: ?string, <add> <add> /** <add> * Provides an initial value that will change when the user starts typing. <add> * Useful for simple use-cases where you do not want to deal with listening <add> * to events and updating the value prop to keep the controlled state in sync. <add> */ <add> defaultValue?: ?string, <add> <add> /** <add> * If `true`, all text will automatically be selected on focus. <add> */ <add> selectTextOnFocus?: ?boolean, <add> <add> /** <add> * If `true`, the text field will blur when submitted. <add> * The default value is true for single-line fields and false for <add> * multiline fields. Note that for multiline fields, setting `blurOnSubmit` <add> * to `true` means that pressing return will blur the field and trigger the <add> * `onSubmitEditing` event instead of inserting a newline into the field. <add> */ <add> blurOnSubmit?: ?boolean, <add> <add> /** <add> * Note that not all Text styles are supported, an incomplete list of what is not supported includes: <add> * <add> * - `borderLeftWidth` <add> * - `borderTopWidth` <add> * - `borderRightWidth` <add> * - `borderBottomWidth` <add> * - `borderTopLeftRadius` <add> * - `borderTopRightRadius` <add> * - `borderBottomRightRadius` <add> * - `borderBottomLeftRadius` <add> * <add> * see [Issue#7070](https://github.com/facebook/react-native/issues/7070) <add> * for more detail. <add> * <add> * [Styles](docs/style.html) <add> */ <add> // TODO: figure out what to do with this style prop for codegen/Fabric purposes <add> // This must be commented for Fabric codegen to work; it's currently not possible <add> // to override the default View style prop in codegen. <add> style?: ?TextStyleProp, <add> <add> /** <add> * If `true`, caret is hidden. The default value is `false`. <add> * This property is supported only for single-line TextInput component on iOS. <add> */ <add> caretHidden?: ?boolean, <add> <add> /* <add> * If `true`, contextMenuHidden is hidden. The default value is `false`. <add> */ <add> contextMenuHidden?: ?boolean, <add> <add> /** <add> * The following are props that `BaseTextShadowNode` takes. It is unclear if they <add> * are used by TextInput. <add> */ <add> textShadowColor?: ?ColorValue, <add> textShadowRadius?: ?Float, <add> textDecorationLine?: ?string, <add> fontStyle?: ?string, <add> textShadowOffset?: ?$ReadOnly<{|width?: ?Double, height?: ?Double|}>, <add> lineHeight?: ?Float, <add> textTransform?: ?string, <add> color?: ?Int32, <add> letterSpacing?: ?Float, <add> fontSize?: ?Float, <add> textAlign?: ?string, <add> includeFontPadding?: ?boolean, <add> fontWeight?: ?string, <add> fontFamily?: ?string, <add> <add> /** <add> * I cannot find where these are defined but JS complains without them. <add> */ <add> textAlignVertical?: ?string, <add> cursorColor?: ?ColorValue, <add> <add> /** <add> * "Private" fields used by TextInput.js and not users of this component directly <add> */ <add> mostRecentEventCount: Int32, <add> text?: ?string, <add>|}>; <add> <add>type AndroidTextInputComponentType = Class<NativeComponent<NativeProps>>; <add> <add>export default ((requireNativeComponent( <add> 'AndroidTextInput', <add>): any): AndroidTextInputComponentType);
1
Python
Python
add option to use custom template with js2c.py
fa2d0a117e0882c5f5d9e0e9b596b8628b6b533f
<ide><path>tools/js2c.py <ide> def JS2C(source, target): <ide> def main(): <ide> natives = sys.argv[1] <ide> source_files = sys.argv[2:] <add> if source_files[-2] == '-t': <add> global TEMPLATE <add> TEMPLATE = source_files[-1] <add> source_files = source_files[:-2] <ide> JS2C(source_files, [natives]) <ide> <ide> if __name__ == "__main__":
1
Go
Go
move getexitcode() to pkg/idtools, and un-export
07b1aa822cc7b371ef5925940d8ea8cfb54de57e
<ide><path>pkg/idtools/idtools_unix.go <ide> import ( <ide> "fmt" <ide> "io" <ide> "os" <add> "os/exec" <ide> "path/filepath" <ide> "strconv" <ide> "sync" <ide> func callGetent(database, key string) (io.Reader, error) { <ide> } <ide> out, err := execCmd(getentCmd, database, key) <ide> if err != nil { <del> exitCode, errC := system.GetExitCode(err) <add> exitCode, errC := getExitCode(err) <ide> if errC != nil { <ide> return nil, err <ide> } <ide> func callGetent(database, key string) (io.Reader, error) { <ide> return bytes.NewReader(out), nil <ide> } <ide> <add>// getExitCode returns the ExitStatus of the specified error if its type is <add>// exec.ExitError, returns 0 and an error otherwise. <add>func getExitCode(err error) (int, error) { <add> exitCode := 0 <add> if exiterr, ok := err.(*exec.ExitError); ok { <add> if procExit, ok := exiterr.Sys().(syscall.WaitStatus); ok { <add> return procExit.ExitStatus(), nil <add> } <add> } <add> return exitCode, fmt.Errorf("failed to get exit code") <add>} <add> <ide> // setPermissions performs a chown/chmod only if the uid/gid don't match what's requested <ide> // Normally a Chown is a no-op if uid/gid match, but in some cases this can still cause an error, e.g. if the <ide> // dir is on an NFS share, so don't call chown unless we absolutely must. <ide><path>pkg/system/exitcode.go <del>package system // import "github.com/docker/docker/pkg/system" <del> <del>import ( <del> "fmt" <del> "os/exec" <del> "syscall" <del>) <del> <del>// GetExitCode returns the ExitStatus of the specified error if its type is <del>// exec.ExitError, returns 0 and an error otherwise. <del>func GetExitCode(err error) (int, error) { <del> exitCode := 0 <del> if exiterr, ok := err.(*exec.ExitError); ok { <del> if procExit, ok := exiterr.Sys().(syscall.WaitStatus); ok { <del> return procExit.ExitStatus(), nil <del> } <del> } <del> return exitCode, fmt.Errorf("failed to get exit code") <del>}
2
Javascript
Javascript
fix jsdocs for multi-line es6-style methods
97aad167a6cfe897469e98f5f0f8e2ea38785bd0
<ide><path>website/jsdocs/jsdocs.js <ide> function sanitizeTypehint(string) { <ide> <ide> /** <ide> * @param {object} node <add> * @param {object} docNode Node used for location/docblock purposes <ide> * @param {object} state <ide> * @param {string} source <ide> * @param {array<object>} commentsForFile <ide> * @param {array<string>} linesForFile <ide> * @return {object} <ide> */ <del>function getFunctionData(node, state, source, commentsForFile, linesForFile) { <add>function getFunctionData( <add> node, <add> docNode, <add> state, <add> source, <add> commentsForFile, <add> linesForFile <add>) { <ide> var params = []; <ide> var typechecks = commentsForFile.typechecks; <ide> var typehintsFromBlock = null; <ide> function getFunctionData(node, state, source, commentsForFile, linesForFile) { <ide> }); <ide> } <ide> return { <del> line: node.loc.start.line, <add> line: docNode.loc.start.line, <ide> source: source.substring.apply(source, node.range), <del> docblock: getDocBlock(node, commentsForFile, linesForFile), <add> docblock: getDocBlock(docNode, commentsForFile, linesForFile), <ide> modifiers: [], <ide> params: params, <ide> tparams: tparams, <ide> function getObjectData(node, state, source, scopeChain, <ide> <ide> switch (property.value.type) { <ide> case Syntax.FunctionExpression: <del> var methodData = getFunctionData(property.value, state, source, <add> var methodData = getFunctionData(property.value, property, state, source, <ide> commentsForFile, linesForFile); <ide> methodData.name = property.key.name || property.key.value; <ide> methodData.source = source.substring.apply(source, property.range); <ide> function getObjectData(node, state, source, scopeChain, <ide> if (expr) { <ide> if (expr.type === Syntax.FunctionDeclaration) { <ide> var functionData = <del> getFunctionData(expr, state, source, commentsForFile, linesForFile); <add> getFunctionData(expr, property, state, source, commentsForFile, <add> linesForFile); <ide> functionData.name = property.key.name || property.key.value; <ide> functionData.modifiers.push('static'); <ide> methods.push(functionData); <ide> function getClassData(node, state, source, commentsForFile, linesForFile) { <ide> if (bodyItem.type === Syntax.MethodDefinition) { <ide> if (bodyItem.value.type === Syntax.FunctionExpression) { <ide> var methodData = <del> getFunctionData(bodyItem.value, state, source, <add> getFunctionData(bodyItem.value, bodyItem, state, source, <ide> commentsForFile, linesForFile); <ide> methodData.name = bodyItem.key.name; <ide> methodData.source = source.substring.apply(source, bodyItem.range); <ide> function parseSource(source) { <ide> break; <ide> case Syntax.FunctionDeclaration: <ide> case Syntax.FunctionExpression: <del> data = getFunctionData(definition, _state, source, ast.comments, lines); <add> data = getFunctionData(definition, definition, _state, source, <add> ast.comments, lines); <ide> data.type = 'function'; <ide> break; <ide> default:
1
PHP
PHP
remove unneeded unset() call
7e61df8b85f6e0885f9d9708a371692cf3a81eb4
<ide><path>src/Controller/Component/SecurityComponent.php <ide> protected function _validatePost(Controller $controller) { <ide> if (strpos($token, ':')) { <ide> list($token, $locked) = explode(':', $token, 2); <ide> } <del> unset($check['_Token'], $check['_csrfToken']); <add> unset($check['_Token']); <ide> <ide> $locked = explode('|', $locked); <ide> $unlocked = explode('|', $unlocked);
1
Javascript
Javascript
fix a typo
c894470d4122913168dd75f829f1d19c4af696ed
<ide><path>src/ng/compile.js <ide> function directiveNormalize(name) { <ide> * <ide> * <ide> * @param {string} name Normalized element attribute name of the property to modify. The name is <del> * revers translated using the {@link ng.$compile.directive.Attributes#$attr $attr} <add> * reverse-translated using the {@link ng.$compile.directive.Attributes#$attr $attr} <ide> * property to the original name. <ide> * @param {string} value Value to set the attribute to. The value can be an interpolated string. <ide> */
1
Java
Java
avoid java.util.stream.stream usage in hot paths
862fa557bde6698252c3fbb6f295dbf12461a630
<ide><path>spring-core/src/main/java/org/springframework/core/ReactiveAdapterRegistry.java <ide> /* <del> * Copyright 2002-2018 the original author or authors. <add> * Copyright 2002-2019 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 ReactiveAdapter getAdapter(@Nullable Class<?> reactiveType, @Nullable Obj <ide> if (clazz == null) { <ide> return null; <ide> } <del> <del> return this.adapters.stream() <del> .filter(adapter -> adapter.getReactiveType() == clazz) <del> .findFirst() <del> .orElseGet(() -> <del> this.adapters.stream() <del> .filter(adapter -> adapter.getReactiveType().isAssignableFrom(clazz)) <del> .findFirst() <del> .orElse(null)); <add> for(ReactiveAdapter adapter : this.adapters) { <add> if (adapter.getReactiveType() == clazz) { <add> return adapter; <add> } <add> } <add> for(ReactiveAdapter adapter : this.adapters) { <add> if (adapter.getReactiveType().isAssignableFrom(clazz)) { <add> return adapter; <add> } <add> } <add> return null; <ide> } <ide> <ide> <ide><path>spring-core/src/main/java/org/springframework/core/codec/AbstractEncoder.java <ide> /* <del> * Copyright 2002-2018 the original author or authors. <add> * Copyright 2002-2019 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 boolean canEncode(ResolvableType elementType, @Nullable MimeType mimeType <ide> if (mimeType == null) { <ide> return true; <ide> } <del> return this.encodableMimeTypes.stream().anyMatch(candidate -> candidate.isCompatibleWith(mimeType)); <add> for(MimeType candidate : this.encodableMimeTypes) { <add> if (candidate.isCompatibleWith(mimeType)) { <add> return true; <add> } <add> } <add> return false; <ide> } <ide> <ide> } <ide><path>spring-core/src/main/java/org/springframework/core/log/CompositeLog.java <ide> /* <del> * Copyright 2002-2018 the original author or authors. <add> * Copyright 2002-2019 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 CompositeLog(List<Log> loggers) { <ide> } <ide> <ide> private static Log initLogger(List<Log> loggers, Predicate<Log> predicate) { <del> return loggers.stream().filter(predicate).findFirst().orElse(NO_OP_LOG); <add> for (Log logger : loggers) { <add> if (predicate.test(logger)) { <add> return logger; <add> } <add> } <add> return NO_OP_LOG; <ide> } <ide> <ide> <ide><path>spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/AbstractMessageWriterResultHandler.java <ide> /* <del> * Copyright 2002-2018 the original author or authors. <add> * Copyright 2002-2019 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.web.reactive.result.method.annotation; <ide> <add>import java.util.ArrayList; <ide> import java.util.List; <del>import java.util.stream.Collectors; <ide> <ide> import org.reactivestreams.Publisher; <ide> import reactor.core.publisher.Mono; <ide> protected Mono<Void> writeBody(@Nullable Object body, MethodParameter bodyParame <ide> <ide> ServerHttpRequest request = exchange.getRequest(); <ide> ServerHttpResponse response = exchange.getResponse(); <del> MediaType bestMediaType = selectMediaType(exchange, () -> getMediaTypesFor(elementType)); <add> List<MediaType> writableMediaTypes = getMediaTypesFor(elementType); <add> MediaType bestMediaType = selectMediaType(exchange, () -> writableMediaTypes); <ide> if (bestMediaType != null) { <ide> String logPrefix = exchange.getLogPrefix(); <ide> if (logger.isDebugEnabled()) { <ide> protected Mono<Void> writeBody(@Nullable Object body, MethodParameter bodyParame <ide> } <ide> } <ide> else { <del> if (getMediaTypesFor(elementType).isEmpty()) { <add> if (writableMediaTypes.isEmpty()) { <ide> return Mono.error(new IllegalStateException("No writer for : " + elementType)); <ide> } <ide> } <ide> <del> return Mono.error(new NotAcceptableStatusException(getMediaTypesFor(elementType))); <add> return Mono.error(new NotAcceptableStatusException(writableMediaTypes)); <ide> } <ide> <ide> private ResolvableType getElementType(ReactiveAdapter adapter, ResolvableType genericType) { <ide> else if (genericType != ResolvableType.NONE) { <ide> } <ide> <ide> private List<MediaType> getMediaTypesFor(ResolvableType elementType) { <del> return getMessageWriters().stream() <del> .filter(converter -> converter.canWrite(elementType, null)) <del> .flatMap(converter -> converter.getWritableMediaTypes().stream()) <del> .collect(Collectors.toList()); <add> List<MediaType> writableMediaTypes = new ArrayList<>(); <add> for (HttpMessageWriter<?> converter : getMessageWriters()) { <add> if (converter.canWrite(elementType, null)) { <add> writableMediaTypes.addAll(converter.getWritableMediaTypes()); <add> } <add> } <add> return writableMediaTypes; <ide> } <ide> <ide> }
4
Javascript
Javascript
replace common.fixturesdir with fixture
3f5f847ed131799da2e8424bf39acf3be55ad683
<ide><path>test/parallel/test-http2-respond-file-compat.js <ide> const common = require('../common'); <ide> if (!common.hasCrypto) <ide> common.skip('missing crypto'); <ide> const http2 = require('http2'); <del>const path = require('path'); <add>const fixtures = require('../common/fixtures'); <ide> <del>const fname = path.resolve(common.fixturesDir, 'elipses.txt'); <add>const fname = fixtures.path('elipses.txt'); <ide> <ide> const server = http2.createServer(common.mustCall((request, response) => { <ide> response.stream.respondWithFile(fname);
1
PHP
PHP
fix typo in core alias for event dispatcher
f1eb309438f7d19e8a71dcecc0eced5f8b33a7c3
<ide><path>src/Illuminate/Foundation/Application.php <ide> public function registerCoreContainerAliases() <ide> 'cookie' => 'Illuminate\Cookie\CookieJar', <ide> 'encrypter' => 'Illuminate\Encryption\Encrypter', <ide> 'db' => 'Illuminate\Database\DatabaseManager', <del> 'events' => 'Illuminate\Events\Dispatacher', <add> 'events' => 'Illuminate\Events\Dispatcher', <ide> 'files' => 'Illuminate\Filesystem\Filesystem', <ide> 'form' => 'Illuminate\Html\FormBuilder', <ide> 'hash' => 'Illuminate\Hashing\HasherInterface',
1
Ruby
Ruby
extract clusterfuck method for surgery
3b863366947c063e19bac1504274ef22831e37d9
<ide><path>activerecord/lib/active_record/relation/merger.rb <add>module ActiveRecord <add> class Relation <add> class Merger <add> attr_reader :relation, :other <add> <add> def initialize(relation, other) <add> @relation = relation <add> <add> if other.default_scoped? && other.klass != relation.klass <add> @other = other.with_default_scope <add> else <add> @other = other <add> end <add> end <add> <add> def merge <add> Relation::ASSOCIATION_METHODS.each do |method| <add> value = other.send(:"#{method}_values") <add> <add> unless value.empty? <add> relation.send("#{method}!", value) <add> end <add> end <add> <add> (Relation::MULTI_VALUE_METHODS - [:joins, :where, :order, :binds]).each do |method| <add> value = other.send(:"#{method}_values") <add> next if value.empty? <add> <add> value += relation.send(:"#{method}_values") <add> relation.send :"#{method}_values=", value <add> end <add> <add> relation.joins_values += other.joins_values <add> <add> merged_wheres = relation.where_values + other.where_values <add> <add> merged_binds = (relation.bind_values + other.bind_values).uniq(&:first) <add> <add> unless relation.where_values.empty? <add> # Remove duplicates, last one wins. <add> seen = Hash.new { |h,table| h[table] = {} } <add> merged_wheres = merged_wheres.reverse.reject { |w| <add> nuke = false <add> if w.respond_to?(:operator) && w.operator == :== <add> name = w.left.name <add> table = w.left.relation.name <add> nuke = seen[table][name] <add> seen[table][name] = true <add> end <add> nuke <add> }.reverse <add> end <add> <add> relation.where_values = merged_wheres <add> relation.bind_values = merged_binds <add> <add> (Relation::SINGLE_VALUE_METHODS - [:lock, :create_with, :reordering]).each do |method| <add> value = other.send(:"#{method}_value") <add> relation.send(:"#{method}_value=", value) unless value.nil? <add> end <add> <add> relation.lock_value = other.lock_value unless relation.lock_value <add> <add> unless other.create_with_value.empty? <add> relation.create_with_value = (relation.create_with_value || {}).merge(other.create_with_value) <add> end <add> <add> if other.reordering_value <add> # override any order specified in the original relation <add> relation.reordering_value = true <add> relation.order_values = other.order_values <add> else <add> # merge in order_values from r <add> relation.order_values += other.order_values <add> end <add> <add> # Apply scope extension modules <add> relation.send :apply_modules, other.extensions <add> <add> relation <add> end <add> end <add> end <add>end <ide><path>activerecord/lib/active_record/relation/spawn_methods.rb <ide> require 'active_support/core_ext/object/blank' <add>require 'active_record/relation/merger' <ide> <ide> module ActiveRecord <ide> module SpawnMethods <del> def merge(r) <del> return self unless r <del> return to_a & r if r.is_a?(Array) <del> <del> merged_relation = clone <del> <del> r = r.with_default_scope if r.default_scoped? && r.klass != klass <del> <del> Relation::ASSOCIATION_METHODS.each do |method| <del> value = r.send(:"#{method}_values") <del> <del> unless value.empty? <del> if method == :includes <del> merged_relation = merged_relation.includes(value) <del> else <del> merged_relation.send(:"#{method}_values=", value) <del> end <add> def merge(other) <add> if other <add> if other.is_a?(Array) <add> to_a & other <add> else <add> ActiveRecord::Relation::Merger.new(clone, other).merge <ide> end <del> end <del> <del> (Relation::MULTI_VALUE_METHODS - [:joins, :where, :order, :binds]).each do |method| <del> value = r.send(:"#{method}_values") <del> next if value.empty? <del> <del> value += merged_relation.send(:"#{method}_values") <del> merged_relation.send :"#{method}_values=", value <del> end <del> <del> merged_relation.joins_values += r.joins_values <del> <del> merged_wheres = @where_values + r.where_values <del> <del> merged_binds = (@bind_values + r.bind_values).uniq(&:first) <del> <del> unless @where_values.empty? <del> # Remove duplicates, last one wins. <del> seen = Hash.new { |h,table| h[table] = {} } <del> merged_wheres = merged_wheres.reverse.reject { |w| <del> nuke = false <del> if w.respond_to?(:operator) && w.operator == :== <del> name = w.left.name <del> table = w.left.relation.name <del> nuke = seen[table][name] <del> seen[table][name] = true <del> end <del> nuke <del> }.reverse <del> end <del> <del> merged_relation.where_values = merged_wheres <del> merged_relation.bind_values = merged_binds <del> <del> (Relation::SINGLE_VALUE_METHODS - [:lock, :create_with, :reordering]).each do |method| <del> value = r.send(:"#{method}_value") <del> merged_relation.send(:"#{method}_value=", value) unless value.nil? <del> end <del> <del> merged_relation.lock_value = r.lock_value unless merged_relation.lock_value <del> <del> merged_relation = merged_relation.create_with(r.create_with_value) unless r.create_with_value.empty? <del> <del> if (r.reordering_value) <del> # override any order specified in the original relation <del> merged_relation.reordering_value = true <del> merged_relation.order_values = r.order_values <ide> else <del> # merge in order_values from r <del> merged_relation.order_values += r.order_values <add> self <ide> end <del> <del> # Apply scope extension modules <del> merged_relation.send :apply_modules, r.extensions <del> <del> merged_relation <ide> end <ide> <ide> # Removes from the query the condition(s) specified in +skips+.
2
Go
Go
remove unintentional dependency for /tmp/data
d610d3f61cd7483dcab5897c8d4edb54248b45be
<ide><path>integration-cli/docker_cli_volume_test.go <ide> func (s *DockerSuite) TestDuplicateMountpointsForVolumesFromAndBind(c *check.C) <ide> c.Assert(strings.TrimSpace(out), checker.Contains, data1) <ide> c.Assert(strings.TrimSpace(out), checker.Contains, data2) <ide> <add> // /tmp/data is automatically created, because we are not using the modern mount API here <ide> out, _, err := dockerCmdWithError("run", "--name=app", "--volumes-from=data1", "--volumes-from=data2", "-v", "/tmp/data:/tmp/data", "-d", "busybox", "top") <ide> c.Assert(err, checker.IsNil, check.Commentf("Out: %s", out)) <ide> <ide> func (s *DockerSuite) TestDuplicateMountpointsForVolumesFromAndBind(c *check.C) <ide> <ide> // Test case (3) for 21845: duplicate targets for --volumes-from and `Mounts` (API only) <ide> func (s *DockerSuite) TestDuplicateMountpointsForVolumesFromAndMounts(c *check.C) { <del> testRequires(c, DaemonIsLinux) <add> testRequires(c, SameHostDaemon, DaemonIsLinux) <ide> <ide> image := "vimage" <ide> buildImageSuccessfully(c, image, withDockerfile(` <ide> func (s *DockerSuite) TestDuplicateMountpointsForVolumesFromAndMounts(c *check.C <ide> c.Assert(strings.TrimSpace(out), checker.Contains, data1) <ide> c.Assert(strings.TrimSpace(out), checker.Contains, data2) <ide> <add> err := os.MkdirAll("/tmp/data", 0755) <add> c.Assert(err, checker.IsNil) <ide> // Mounts is available in API <ide> status, body, err := request.SockRequest("POST", "/containers/create?name=app", map[string]interface{}{ <ide> "Image": "busybox",
1
Javascript
Javascript
fix emotion labelformat and sourcemap options
4da09da1a2fa0c7b2d9c558b8072dfdd00a4b369
<ide><path>packages/next/build/swc/options.js <ide> function getEmotionOptions(nextConfig, development) { <ide> return { <ide> enabled: true, <ide> autoLabel, <del> labelFormat: nextConfig?.experimental?.emotion?.labelFormat, <add> labelFormat: nextConfig?.compiler?.emotion?.labelFormat, <ide> sourcemap: development <del> ? nextConfig?.experimental?.emotion?.sourceMap ?? true <add> ? nextConfig?.compiler?.emotion?.sourceMap ?? true <ide> : false, <ide> } <ide> }
1
Javascript
Javascript
honor the islinenumberguttervisible option
36f5262f407f3070becef34d28c884433c1ab354
<ide><path>spec/text-editor-component-spec.js <ide> describe('TextEditorComponent', () => { <ide> expect(element.offsetHeight).toBeGreaterThan(initialHeight) <ide> }) <ide> <add> it('supports the isLineNumberGutterVisible parameter', () => { <add> const {component, element, editor} = buildComponent({lineNumberGutterVisible: false}) <add> expect(element.querySelector('.line-number')).toBe(null) <add> }) <add> <ide> describe('mini editors', () => { <ide> it('adds the mini attribute', () => { <ide> const {element, editor} = buildComponent({mini: true}) <ide> function buildComponent (params = {}) { <ide> if (params.mini != null) editorParams.mini = params.mini <ide> if (params.autoHeight != null) editorParams.autoHeight = params.autoHeight <ide> if (params.autoWidth != null) editorParams.autoWidth = params.autoWidth <add> if (params.lineNumberGutterVisible != null) editorParams.lineNumberGutterVisible = params.lineNumberGutterVisible <ide> const editor = new TextEditor(editorParams) <ide> const component = new TextEditorComponent({ <ide> model: editor, <ide><path>src/text-editor-component.js <ide> class TextEditorComponent { <ide> } <ide> <ide> renderLineNumberGutter () { <add> const model = this.getModel() <add> <add> if (!model.isLineNumberGutterVisible()) return null <add> <ide> if (this.currentFrameLineNumberGutterProps) { <ide> return $(LineNumberGutterComponent, this.currentFrameLineNumberGutterProps) <ide> } <ide> <del> const model = this.getModel() <ide> const maxLineNumberDigits = Math.max(2, model.getLineCount().toString().length) <ide> <ide> if (this.measurements) {
2
Ruby
Ruby
liberalize picky test
8087d518425597ab1a667878702dd3aaa9def488
<ide><path>actionmailer/test/mail_service_test.rb <ide> def test_return_path_with_create <ide> def test_return_path_with_deliver <ide> ActionMailer::Base.delivery_method = :smtp <ide> TestMailer.deliver_return_path <del> assert_match %r{^Return-Path: another@somewhere.test}, MockSMTP.deliveries[0][0] <add> assert_match %r{^Return-Path:.*another@somewhere.test}, MockSMTP.deliveries[0][0] <ide> assert_equal "another@somewhere.test", MockSMTP.deliveries[0][1].to_s <ide> end <ide>
1
Python
Python
fix sort order in connection list on query page
b61dc2fde9f1bb1cad05826a590736d305765a8e
<ide><path>airflow/bin/cli.py <ide> def run(args): <ide> format=settings.LOG_FORMAT) <ide> if not args.pickle: <ide> dagbag = DagBag(subdir) <add> print subdir <add> print dagbag.dags <ide> if args.dag_id not in dagbag.dags: <ide> msg = 'DAG [{0}] could not be found'.format(args.dag_id) <ide> logging.error(msg) <ide><path>airflow/www/app.py <ide> def query(self): <ide> models.Connection.conn_id).all() <ide> session.expunge_all() <ide> db_choices = list( <del> {(db.conn_id, db.conn_id) for db in dbs if db.get_hook()}) <add> ((db.conn_id, db.conn_id) for db in dbs if db.get_hook())) <ide> conn_id_str = request.args.get('conn_id') <ide> csv = request.args.get('csv') == "true" <ide> sql = request.args.get('sql')
2
PHP
PHP
return a lazy collection from query@cursor()
2fea43d024fa0f0faf10059113781942cc03a5ff
<ide><path>src/Illuminate/Database/Eloquent/Builder.php <ide> protected function isNestedUnder($relation, $name) <ide> } <ide> <ide> /** <del> * Get a generator for the given query. <add> * Get a lazy collection for the given query. <ide> * <del> * @return \Generator <add> * @return \Illuminate\Support\LazyCollection <ide> */ <ide> public function cursor() <ide> { <del> foreach ($this->applyScopes()->query->cursor() as $record) { <del> yield $this->newModelInstance()->newFromBuilder($record); <del> } <add> return $this->applyScopes()->query->cursor()->map(function ($record) { <add> return $this->newModelInstance()->newFromBuilder($record); <add> }); <ide> } <ide> <ide> /** <ide><path>src/Illuminate/Database/Query/Builder.php <ide> use InvalidArgumentException; <ide> use Illuminate\Support\Collection; <ide> use Illuminate\Pagination\Paginator; <add>use Illuminate\Support\LazyCollection; <ide> use Illuminate\Support\Traits\Macroable; <ide> use Illuminate\Contracts\Support\Arrayable; <ide> use Illuminate\Database\ConnectionInterface; <ide> protected function withoutSelectAliases(array $columns) <ide> } <ide> <ide> /** <del> * Get a generator for the given query. <add> * Get a lazy collection for the given query. <ide> * <del> * @return \Generator <add> * @return \Illuminate\Support\LazyCollection <ide> */ <ide> public function cursor() <ide> { <ide> if (is_null($this->columns)) { <ide> $this->columns = ['*']; <ide> } <ide> <del> return $this->connection->cursor( <del> $this->toSql(), $this->getBindings(), ! $this->useWritePdo <del> ); <add> return new LazyCollection(function () { <add> yield from $this->connection->cursor( <add> $this->toSql(), $this->getBindings(), ! $this->useWritePdo <add> ); <add> }); <ide> } <ide> <ide> /** <ide><path>tests/Database/DatabaseEloquentHasManyThroughIntegrationTest.php <ide> namespace Illuminate\Tests\Database; <ide> <ide> use PHPUnit\Framework\TestCase; <add>use Illuminate\Support\LazyCollection; <ide> use Illuminate\Database\Eloquent\SoftDeletes; <ide> use Illuminate\Database\Capsule\Manager as DB; <ide> use Illuminate\Database\Eloquent\Model as Eloquent; <ide> public function testCursorReturnsCorrectModels() <ide> <ide> $posts = $country->posts()->cursor(); <ide> <add> $this->assertInstanceOf(LazyCollection::class, $posts); <add> <ide> foreach ($posts as $post) { <ide> $this->assertEquals([ <ide> 'id',
3
Javascript
Javascript
remove timer from test-http-1.0
6a3d38f00f116cbe51cd006ee558ca773522e6f5
<ide><path>test/parallel/test-http-1.0.js <ide> function test(handler, request_generator, response_validator) { <ide> var client_got_eof = false; <ide> var server_response = ''; <ide> <del> function cleanup() { <del> server.close(); <del> response_validator(server_response, client_got_eof, true); <del> } <del> var timer = setTimeout(cleanup, common.platformTimeout(1000)); <del> process.on('exit', cleanup); <del> <ide> server.listen(port); <ide> server.on('listening', function() { <ide> var c = net.createConnection(port); <ide> function test(handler, request_generator, response_validator) { <ide> server_response += chunk; <ide> }); <ide> <del> c.on('end', function() { <add> c.on('end', common.mustCall(function() { <ide> client_got_eof = true; <ide> c.end(); <ide> server.close(); <del> clearTimeout(timer); <del> process.removeListener('exit', cleanup); <ide> response_validator(server_response, client_got_eof, false); <del> }); <add> })); <ide> }); <ide> } <ide>
1
Go
Go
skip some test on remote daemon for e2e run(s)
ef2c2040c22eba8ab6ea1033ad64ba9b0095db9b
<ide><path>integration/build/build_session_test.go <ide> import ( <ide> "testing" <ide> <ide> dclient "github.com/docker/docker/client" <del> "github.com/docker/docker/internal/test/daemon" <ide> "github.com/docker/docker/internal/test/fakecontext" <ide> "github.com/docker/docker/internal/test/request" <ide> "github.com/gotestyourself/gotestyourself/assert" <ide> is "github.com/gotestyourself/gotestyourself/assert/cmp" <add> "github.com/gotestyourself/gotestyourself/skip" <ide> "github.com/moby/buildkit/session" <ide> "github.com/moby/buildkit/session/filesync" <ide> "golang.org/x/sync/errgroup" <ide> ) <ide> <ide> func TestBuildWithSession(t *testing.T) { <del> d := daemon.New(t, daemon.WithExperimental) <del> d.StartWithBusybox(t) <del> defer d.Stop(t) <add> skip.If(t, !testEnv.DaemonInfo.ExperimentalBuild) <ide> <del> client, err := d.NewClient() <del> assert.NilError(t, err) <add> client := testEnv.APIClient() <ide> <ide> dockerfile := ` <ide> FROM busybox <ide> func TestBuildWithSession(t *testing.T) { <ide> ) <ide> defer fctx.Close() <ide> <del> out := testBuildWithSession(t, client, d.Sock(), fctx.Dir, dockerfile) <add> out := testBuildWithSession(t, client, client.DaemonHost(), fctx.Dir, dockerfile) <ide> assert.Check(t, is.Contains(out, "some content")) <ide> <ide> fctx.Add("second", "contentcontent") <ide> func TestBuildWithSession(t *testing.T) { <ide> RUN cat /second <ide> ` <ide> <del> out = testBuildWithSession(t, client, d.Sock(), fctx.Dir, dockerfile) <add> out = testBuildWithSession(t, client, client.DaemonHost(), fctx.Dir, dockerfile) <ide> assert.Check(t, is.Equal(strings.Count(out, "Using cache"), 2)) <ide> assert.Check(t, is.Contains(out, "contentcontent")) <ide> <ide> du, err := client.DiskUsage(context.TODO()) <ide> assert.Check(t, err) <ide> assert.Check(t, du.BuilderSize > 10) <ide> <del> out = testBuildWithSession(t, client, d.Sock(), fctx.Dir, dockerfile) <add> out = testBuildWithSession(t, client, client.DaemonHost(), fctx.Dir, dockerfile) <ide> assert.Check(t, is.Equal(strings.Count(out, "Using cache"), 4)) <ide> <ide> du2, err := client.DiskUsage(context.TODO()) <ide> func TestBuildWithSession(t *testing.T) { <ide> // FIXME(vdemeester) use sock here <ide> res, body, err := request.Do( <ide> "/build", <del> request.Host(d.Sock()), <add> request.Host(client.DaemonHost()), <ide> request.Method(http.MethodPost), <ide> request.RawContent(fctx.AsTarReader(t)), <ide> request.ContentType("application/x-tar")) <ide> func TestBuildWithSession(t *testing.T) { <ide> assert.Check(t, is.Equal(du.BuilderSize, int64(0))) <ide> } <ide> <del>func testBuildWithSession(t *testing.T, client dclient.APIClient, daemonSock string, dir, dockerfile string) (outStr string) { <add>func testBuildWithSession(t *testing.T, client dclient.APIClient, daemonHost string, dir, dockerfile string) (outStr string) { <ide> sess, err := session.NewSession("foo1", "foo") <ide> assert.Check(t, err) <ide> <ide> func testBuildWithSession(t *testing.T, client dclient.APIClient, daemonSock str <ide> // FIXME use sock here <ide> res, body, err := request.Do( <ide> "/build?remote=client-session&session="+sess.ID(), <del> request.Host(daemonSock), <add> request.Host(daemonHost), <ide> request.Method(http.MethodPost), <ide> request.With(func(req *http.Request) error { <ide> req.Body = ioutil.NopCloser(strings.NewReader(dockerfile)) <ide><path>integration/build/build_squash_test.go <ide> import ( <ide> <ide> "github.com/docker/docker/api/types" <ide> "github.com/docker/docker/integration/internal/container" <del> "github.com/docker/docker/internal/test/daemon" <ide> "github.com/docker/docker/internal/test/fakecontext" <ide> "github.com/docker/docker/pkg/stdcopy" <ide> "github.com/gotestyourself/gotestyourself/assert" <ide> is "github.com/gotestyourself/gotestyourself/assert/cmp" <add> "github.com/gotestyourself/gotestyourself/skip" <ide> ) <ide> <ide> func TestBuildSquashParent(t *testing.T) { <del> d := daemon.New(t, daemon.WithExperimental) <del> d.StartWithBusybox(t) <del> defer d.Stop(t) <add> skip.If(t, !testEnv.DaemonInfo.ExperimentalBuild) <ide> <del> client, err := d.NewClient() <del> assert.NilError(t, err) <add> client := testEnv.APIClient() <ide> <ide> dockerfile := ` <ide> FROM busybox <ide><path>integration/container/daemon_linux_test.go <ide> import ( <ide> // the container process, then start dockerd back up and attempt to start the <ide> // container again. <ide> func TestContainerStartOnDaemonRestart(t *testing.T) { <del> skip.If(t, testEnv.IsRemoteDaemon(), "cannot start daemon on remote test run") <add> skip.If(t, testEnv.IsRemoteDaemon, "cannot start daemon on remote test run") <ide> t.Parallel() <ide> <ide> d := daemon.New(t) <ide><path>integration/container/restart_test.go <ide> import ( <ide> ) <ide> <ide> func TestDaemonRestartKillContainers(t *testing.T) { <del> skip.If(t, testEnv.IsRemoteDaemon(), "cannot start daemon on remote test run") <add> skip.If(t, testEnv.IsRemoteDaemon, "cannot start daemon on remote test run") <ide> type testCase struct { <ide> desc string <ide> config *container.Config <ide><path>integration/internal/swarm/service.go <ide> func ContainerPoll(config *poll.Settings) { <ide> // NewSwarm creates a swarm daemon for testing <ide> func NewSwarm(t *testing.T, testEnv *environment.Execution, ops ...func(*daemon.Daemon)) *daemon.Daemon { <ide> t.Helper() <del> skip.IfCondition(t, testEnv.IsRemoteDaemon()) <add> skip.If(t, testEnv.IsRemoteDaemon) <ide> if testEnv.DaemonInfo.ExperimentalBuild { <ide> ops = append(ops, daemon.WithExperimental) <ide> } <ide><path>integration/plugin/authz/main_test.go <ide> func TestMain(m *testing.M) { <ide> } <ide> <ide> func setupTest(t *testing.T) func() { <del> skip.IfCondition(t, testEnv.IsRemoteDaemon(), "cannot run daemon when remote daemon") <add> skip.If(t, testEnv.IsRemoteDaemon, "cannot run daemon when remote daemon") <ide> environment.ProtectAll(t, testEnv) <ide> <ide> d = daemon.New(t, daemon.WithExperimental) <ide><path>integration/plugin/graphdriver/external_test.go <ide> type graphEventsCounter struct { <ide> <ide> func TestExternalGraphDriver(t *testing.T) { <ide> skip.If(t, runtime.GOOS == "windows") <del> skip.If(t, testEnv.IsRemoteDaemon(), "cannot run daemon when remote daemon") <add> skip.If(t, testEnv.IsRemoteDaemon, "cannot run daemon when remote daemon") <ide> skip.If(t, !requirement.HasHubConnectivity(t)) <ide> <ide> // Setup plugin(s) <ide> func testGraphDriverPull(c client.APIClient, d *daemon.Daemon) func(*testing.T) <ide> <ide> func TestGraphdriverPluginV2(t *testing.T) { <ide> skip.If(t, runtime.GOOS == "windows") <del> skip.If(t, testEnv.IsRemoteDaemon(), "cannot run daemon when remote daemon") <add> skip.If(t, testEnv.IsRemoteDaemon, "cannot run daemon when remote daemon") <ide> skip.If(t, !requirement.HasHubConnectivity(t)) <ide> skip.If(t, os.Getenv("DOCKER_ENGINE_GOARCH") != "amd64") <ide> skip.If(t, !requirement.Overlay2Supported(testEnv.DaemonInfo.KernelVersion)) <ide><path>integration/plugin/logging/validation_test.go <ide> import ( <ide> // Ensure that a daemon with a log plugin set as the default logger for containers <ide> // does not keep the daemon from starting. <ide> func TestDaemonStartWithLogOpt(t *testing.T) { <del> skip.IfCondition(t, testEnv.IsRemoteDaemon(), "cannot run daemon when remote daemon") <add> skip.If(t, testEnv.IsRemoteDaemon, "cannot run daemon when remote daemon") <ide> t.Parallel() <ide> <ide> d := daemon.New(t) <ide><path>integration/plugin/volumes/mounts_test.go <ide> import ( <ide> "github.com/docker/docker/internal/test/daemon" <ide> "github.com/docker/docker/internal/test/fixtures/plugin" <ide> "github.com/gotestyourself/gotestyourself/assert" <add> "github.com/gotestyourself/gotestyourself/skip" <ide> ) <ide> <ide> // TestPluginWithDevMounts tests very specific regression caused by mounts ordering <ide> // (sorted in the daemon). See #36698 <ide> func TestPluginWithDevMounts(t *testing.T) { <add> skip.If(t, testEnv.IsRemoteDaemon, "cannot run daemon when remote daemon") <ide> t.Parallel() <ide> <ide> d := daemon.New(t) <ide><path>integration/service/plugin_test.go <ide> import ( <ide> ) <ide> <ide> func TestServicePlugin(t *testing.T) { <add> skip.If(t, testEnv.IsRemoteDaemon, "cannot run daemon when remote daemon") <ide> skip.If(t, testEnv.DaemonInfo.OSType == "windows") <ide> skip.If(t, os.Getenv("DOCKER_ENGINE_GOARCH") != "amd64") <ide> defer setupTest(t)() <ide><path>integration/volume/volume_test.go <ide> import ( <ide> "github.com/google/go-cmp/cmp/cmpopts" <ide> "github.com/gotestyourself/gotestyourself/assert" <ide> is "github.com/gotestyourself/gotestyourself/assert/cmp" <add> "github.com/gotestyourself/gotestyourself/skip" <ide> ) <ide> <ide> func TestVolumesCreateAndList(t *testing.T) { <add> skip.If(t, testEnv.IsRemoteDaemon, "cannot run daemon when remote daemon") <ide> defer setupTest(t)() <ide> client := request.NewAPIClient(t) <ide> ctx := context.Background()
11
Python
Python
support host_name on datadog provider
df84c4ad42b1bbaf352d14973f1f867c89dc0a3b
<ide><path>airflow/providers/datadog/hooks/datadog.py <ide> def __init__(self, datadog_conn_id: str = 'datadog_default') -> None: <ide> conn = self.get_connection(datadog_conn_id) <ide> self.api_key = conn.extra_dejson.get('api_key', None) <ide> self.app_key = conn.extra_dejson.get('app_key', None) <add> self.api_host = conn.extra_dejson.get('api_host', None) <ide> self.source_type_name = conn.extra_dejson.get('source_type_name', None) <ide> <ide> # If the host is populated, it will use that hostname instead. <ide> def __init__(self, datadog_conn_id: str = 'datadog_default') -> None: <ide> raise AirflowException("api_key must be specified in the Datadog connection details") <ide> <ide> self.log.info("Setting up api keys for Datadog") <del> initialize(api_key=self.api_key, app_key=self.app_key) <add> initialize(api_key=self.api_key, app_key=self.app_key, api_host=self.api_host) <ide> <ide> def validate_response(self, response: Dict[str, Any]) -> None: <ide> """Validate Datadog response""" <ide><path>tests/providers/datadog/hooks/test_datadog.py <ide> <ide> APP_KEY = 'app_key' <ide> API_KEY = 'api_key' <add>API_HOST = 'api_host' <ide> METRIC_NAME = 'metric' <ide> DATAPOINT = 7 <ide> TAGS = ['tag'] <ide> def setUp(self, mock_get_connection, mock_initialize): <ide> { <ide> 'app_key': APP_KEY, <ide> 'api_key': API_KEY, <add> 'api_host': API_HOST, <ide> } <ide> ) <ide> )
2
Javascript
Javascript
fix bug when transitioning namespaced attributes
037493c2509f8c7b78badef97b410b313a5fe069
<ide><path>d3.js <ide> function d3_transition(groups, id) { <ide> var d3_transitionRemove = {}; <ide> <ide> function d3_transitionNull(d, i, a) { <del> if (a != "") return d3_transitionRemove; <add> return a != "" && d3_transitionRemove; <ide> } <ide> <ide> function d3_transitionTween(b) { <del> return typeof b === "function" <del> ? function(d, i, a) { <del> var v = b.call(this, d, i); <del> if (v == null) { <del> if (a != "") return d3_transitionRemove; <del> } else return a != v && d3.interpolate(a, v); <del> } <add> function transitionFunction(d, i, a) { <add> var v = b.call(this, d, i); <add> return v == null <add> ? a != "" && d3_transitionRemove <add> : a != v && d3.interpolate(a, v); <add> } <add> function transitionString(d, i, a) { <add> return a != b && d3.interpolate(a, b); <add> } <add> return typeof b === "function" ? transitionFunction <ide> : b == null ? d3_transitionNull <del> : (b = b + "", function(d, i, a) { return a != b && d3.interpolate(a, b); }); <add> : (b += "", transitionString); <ide> } <ide> <ide> var d3_transitionPrototype = [], <ide> d3_transitionPrototype.attr = function(name, value) { <ide> return this.attrTween(name, d3_transitionTween(value)); <ide> }; <ide> <del>d3_transitionPrototype.attrTween = function(name, tween) { <del> name = d3.ns.qualify(name); <add>d3_transitionPrototype.attrTween = function(nameNS, tween) { <add> var name = d3.ns.qualify(nameNS); <ide> <ide> function attrTween(d, i) { <ide> var f = tween.call(this, d, i, this.getAttribute(name)); <del> if (f === d3_transitionRemove) this.removeAttribute(name); <del> else return f && function(t) { <del> this.setAttribute(name, f(t)); <del> }; <add> return f === d3_transitionRemove ? this.removeAttribute(name) <add> : f && function(t) { this.setAttribute(name, f(t)); }; <ide> } <ide> <ide> function attrTweenNS(d, i) { <ide> var f = tween.call(this, d, i, this.getAttributeNS(name.space, name.local)); <del> return f && function(t) { <del> this.setAttributeNS(name.space, name.local, f(t)); <del> }; <add> return f === d3_transitionRemove <add> ? (this.removeAttributeNS(name.space, name.local), null) // TODO remove workaround for JSDOM <add> : f && function(t) { this.setAttributeNS(name.space, name.local, f(t)); }; <ide> } <ide> <del> return this.tween("attr." + name, name.local ? attrTweenNS : attrTween); <add> return this.tween("attr." + nameNS, name.local ? attrTweenNS : attrTween); <ide> }; <ide> d3_transitionPrototype.style = function(name, value, priority) { <ide> if (arguments.length < 3) priority = ""; <ide> d3_transitionPrototype.styleTween = function(name, tween, priority) { <ide> if (arguments.length < 3) priority = ""; <ide> return this.tween("style." + name, function(d, i) { <ide> var f = tween.call(this, d, i, window.getComputedStyle(this, null).getPropertyValue(name)); <del> if (f === d3_transitionRemove) this.style.removeProperty(name); <del> else return f && function(t) { <del> this.style.setProperty(name, f(t), priority); <del> }; <add> if (f !== d3_transitionRemove) { <add> return f && function(t) { this.style.setProperty(name, f(t), priority); }; <add> } <add> this.style.removeProperty(name); <ide> }); <ide> }; <ide> d3_transitionPrototype.text = function(value) { <ide><path>d3.min.js <del>(function(){function dy(a,b,c){function i(a,b){var c=a.__domain||(a.__domain=a.domain()),d=a.range().map(function(a){return(a-b)/h});a.domain(c).domain(d.map(a.invert))}var d=Math.pow(2,(dj[2]=a)-c[2]),e=dj[0]=b[0]-d*c[0],f=dj[1]=b[1]-d*c[1],g=d3.event,h=Math.pow(2,a);d3.event={scale:h,translate:[e,f],transform:function(a,b){a&&i(a,e),b&&i(b,f)}};try{dk.apply(dm,dn)}finally{d3.event=g}g.preventDefault()}function dx(){dq&&dl===d3.event.target&&(d3.event.stopPropagation(),d3.event.preventDefault(),dq=!1,dl=null)}function dw(){df&&(dp&&dl===d3.event.target&&(dq=!0),dv(),df=null)}function dv(){dg=null,df&&(dp=!0,dy(dj[2],d3.svg.mouse(dm),df))}function du(){var a=d3.svg.touches(dm);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 dt(){var a=d3.svg.touches(dm),b=-1,c=a.length,d;while(++b<c)dh[(d=a[b]).identifier]=dr(d);return a}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 dr(a){return[a[0]-dj[0],a[1]-dj[1],dj[2]]}function dd(){d3.event.stopPropagation(),d3.event.preventDefault()}function dc(){cZ&&cU===d3.event.target&&(dd(),cZ=!1,cU=null)}function db(){!cV||(c$("dragend"),cV=null,cY&&cU===d3.event.target&&(cZ=!0,dd()))}function da(){if(!!cV){var a=cV.parentNode;if(!a)return db();c$("drag"),dd()}}function c_(a){return d3.event.touches?d3.svg.touches(a)[0]:d3.svg.mouse(a)}function c$(a){var b=d3.event,c=cV.parentNode,d=0,e=0;c&&(c=c_(c),d=c[0]-cX[0],e=c[1]-cX[1],cX=c,cY|=d|e);try{d3.event={dx:d,dy:e},cT[a].dispatch.apply(cV,cW)}finally{d3.event=b}b.preventDefault()}function cS(a,b,c){e=[];if(c&&b.length>1){var d=bw(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 cR(a,b){a.attr("transform",function(a){return"translate(0,"+b(a)+")"})}function cQ(a,b){a.attr("transform",function(a){return"translate("+b(a)+",0)"})}function cM(){return"circle"}function cL(){return 64}function cK(a,b){var c=(a.ownerSVGElement||a).createSVGPoint();if(cJ<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();cJ=!e.f&&!e.e,d.remove()}cJ?(c.x=b.pageX,c.y=b.pageY):(c.x=b.clientX,c.y=b.clientY),c=c.matrixTransform(a.getScreenCTM().inverse());return[c.x,c.y]}function cI(a){return function(){var b=a.apply(this,arguments),c=b[0],d=b[1]+bU;return[c*Math.cos(d),c*Math.sin(d)]}}function cH(a){return[a.x,a.y]}function cG(a){return a.endAngle}function cF(a){return a.startAngle}function cE(a){return a.radius}function cD(a){return a.target}function cC(a){return a.source}function cB(a){return function(b,c){return a[c][1]}}function cA(a){return function(b,c){return a[c][0]}}function cz(a){function i(f){if(f.length<1)return null;var i=b_(this,f,b,d),j=b_(this,f,b===c?cA(i):c,d===e?cB(i):e);return"M"+g(a(j),h)+"L"+g(a(i.reverse()),h)+"Z"}var b=ca,c=ca,d=0,e=cb,f="linear",g=cc[f],h=.7;i.x=function(a){if(!arguments.length)return c;b=c=a;return i},i.x0=function(a){if(!arguments.length)return b;b=a;return i},i.x1=function(a){if(!arguments.length)return c;c=a;return i},i.y=function(a){if(!arguments.length)return e;d=e=a;return i},i.y0=function(a){if(!arguments.length)return d;d=a;return i},i.y1=function(a){if(!arguments.length)return e;e=a;return i},i.interpolate=function(a){if(!arguments.length)return f;g=cc[f=a];return i},i.tension=function(a){if(!arguments.length)return h;h=a;return i};return i}function cy(a){var b,c=-1,d=a.length,e,f;while(++c<d)b=a[c],e=b[0],f=b[1]+bU,b[0]=e*Math.cos(f),b[1]=e*Math.sin(f);return a}function cx(a){return a.length<3?cd(a):a[0]+cj(a,cw(a))}function cw(a){var b=[],c,d,e,f,g=cv(a),h=-1,i=a.length-1;while(++h<i)c=cu(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 cv(a){var b=0,c=a.length-1,d=[],e=a[0],f=a[1],g=d[0]=cu(e,f);while(++b<c)d[b]=g+(g=cu(e=f,f=a[b+1]));d[b]=g;return d}function cu(a,b){return(b[1]-a[1])/(b[0]-a[0])}function ct(a,b,c){a.push("C",cp(cq,b),",",cp(cq,c),",",cp(cr,b),",",cp(cr,c),",",cp(cs,b),",",cp(cs,c))}function cp(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]+a[3]*b[3]}function co(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 cl(a)}function cn(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=[cp(cs,g),",",cp(cs,h)],--c;while(++c<e)f=a[c%d],g.shift(),g.push(f[0]),h.shift(),h.push(f[1]),ct(b,g,h);return b.join("")}function cm(a){if(a.length<4)return cd(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(cp(cs,f)+","+cp(cs,g)),--c;while(++c<d)e=a[c],f.shift(),f.push(e[0]),g.shift(),g.push(e[1]),ct(b,f,g);return b.join("")}function cl(a){if(a.length<3)return cd(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];ct(i,g,h);while(++b<c)d=a[b],g.shift(),g.push(d[0]),h.shift(),h.push(d[1]),ct(i,g,h);b=-1;while(++b<2)g.shift(),g.push(d[0]),h.shift(),h.push(d[1]),ct(i,g,h);return i.join("")}function ck(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 cj(a,b){if(b.length<1||a.length!=b.length&&a.length!=b.length+2)return cd(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 ci(a,b,c){return a.length<3?cd(a):a[0]+cj(a,ck(a,b))}function ch(a,b){return a.length<3?cd(a):a[0]+cj((a.push(a[0]),a),ck([a[a.length-2]].concat(a,[a[1]]),b))}function cg(a,b){return a.length<4?cd(a):a[1]+cj(a.slice(1,a.length-1),ck(a,b))}function cf(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 ce(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 cd(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 cb(a){return a[1]}function ca(a){return a[0]}function b_(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 b$(a){function g(d){return d.length<1?null:"M"+e(a(b_(this,d,b,c)),f)}var b=ca,c=cb,d="linear",e=cc[d],f=.7;g.x=function(a){if(!arguments.length)return b;b=a;return g},g.y=function(a){if(!arguments.length)return c;c=a;return g},g.interpolate=function(a){if(!arguments.length)return d;e=cc[d=a];return g},g.tension=function(a){if(!arguments.length)return f;f=a;return g};return g}function bZ(a){return a.endAngle}function bY(a){return a.startAngle}function bX(a){return a.outerRadius}function bW(a){return a.innerRadius}function bT(a,b,c){function g(){d=c.length/(b-a),e=c.length-1;return f}function f(b){return c[Math.max(0,Math.min(e,Math.floor(d*(b-a))))]}var d,e;f.domain=function(c){if(!arguments.length)return[a,b];a=+c[0],b=+c[c.length-1];return g()},f.range=function(a){if(!arguments.length)return c;c=a;return g()},f.copy=function(){return bT(a,b,c)};return g()}function bS(a,b){function e(a){return isNaN(a=+a)?NaN:b[d3.bisect(c,a)]}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}var c;e.domain=function(b){if(!arguments.length)return a;a=b.filter(function(a){return!isNaN(a)}).sort(d3.ascending);return d()},e.range=function(a){if(!arguments.length)return b;b=a;return d()},e.quantiles=function(){return c},e.copy=function(){return bS(a,b)};return d()}function bN(a,b){function f(b){return d[((c[b]||(c[b]=a.push(b)))-1)%d.length]}var c,d,e;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){if(!arguments.length)return d;d=a,e=0,b={t:"range",x:a};return f},f.rangePoints=function(c,g){arguments.length<2&&(g=0);var h=c[0],i=c[1],j=(i-h)/(a.length-1+g);d=a.length<2?[(h+i)/2]:d3.range(h+j*g/2,i+j/2,j),e=0,b={t:"rangePoints",x:c,p:g};return f},f.rangeBands=function(c,g){arguments.length<2&&(g=0);var h=c[0],i=c[1],j=(i-h)/(a.length+g);d=d3.range(h+j*g,i,j),e=j*(1-g),b={t:"rangeBands",x:c,p:g};return f},f.rangeRoundBands=function(c,g){arguments.length<2&&(g=0);var h=c[0],i=c[1],j=Math.floor((i-h)/(a.length+g)),k=i-h-(a.length-g)*j;d=d3.range(h+Math.round(k/2),i,j),e=Math.round(j*(1-g)),b={t:"rangeRoundBands",x:c,p:g};return f},f.rangeBand=function(){return e},f.copy=function(){return bN(a,b)};return f.domain(a)}function bM(a){return function(b){return b<0?-Math.pow(-b,a):Math.pow(b,a)}}function bL(a,b){function e(b){return a(c(b))}var c=bM(b),d=bM(1/b);e.invert=function(b){return d(a.invert(b))},e.domain=function(b){if(!arguments.length)return a.domain().map(d);a.domain(b.map(c));return e},e.ticks=function(a){return bD(e.domain(),a)},e.tickFormat=function(a){return bE(e.domain(),a)},e.nice=function(){return e.domain(bx(e.domain(),bB))},e.exponent=function(a){if(!arguments.length)return b;var f=e.domain();c=bM(b=a),d=bM(1/b);return e.domain(f)},e.copy=function(){return bL(a.copy(),b)};return bA(e,a)}function bK(a){return-Math.log(-a)/Math.LN10}function bJ(a){return Math.log(a)/Math.LN10}function bH(a,b){function d(c){return a(b(c))}var c=b.pow;d.invert=function(b){return c(a.invert(b))},d.domain=function(e){if(!arguments.length)return a.domain().map(c);b=e[0]<0?bK:bJ,c=b.pow,a.domain(e.map(b));return d},d.nice=function(){a.domain(bx(a.domain(),by));return d},d.ticks=function(){var d=bw(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===bK){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=bI);if(arguments.length<1)return e;var f=a/d.ticks().length,g=b===bK?(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 bH(a.copy(),b)};return bA(d,a)}function bG(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 bF(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 bE(a,b){return d3.format(",."+Math.max(0,-Math.floor(Math.log(bC(a,b)[2])/Math.LN10+.01))+"f")}function bD(a,b){return d3.range.apply(d3,bC(a,b))}function bC(a,b){var c=bw(a),d=c[1]-c[0],e=Math.pow(10,Math.floor(Math.log(d/b)/Math.LN10)),f=b/d*e;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;return c}function bB(a){a=Math.pow(10,Math.round(Math.log(a)/Math.LN10)-1);return{floor:function(b){return Math.floor(b/a)*a},ceil:function(b){return Math.ceil(b/a)*a}}}function bA(a,b){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);return a}function bz(a,b,c,d){function h(a){return e(a)}function g(){var g=a.length==2?bF:bG,i=d?L:K;e=g(a,b,i,c),f=g(b,a,i,d3.interpolate);return h}var e,f;h.invert=function(a){return f(a)},h.domain=function(b){if(!arguments.length)return a;a=b.map(Number);return g()},h.range=function(a){if(!arguments.length)return b;b=a;return g()},h.rangeRound=function(a){return h.range(a).interpolate(d3.interpolateRound)},h.clamp=function(a){if(!arguments.length)return d;d=a;return g()},h.interpolate=function(a){if(!arguments.length)return c;c=a;return g()},h.ticks=function(b){return bD(a,b)},h.tickFormat=function(b){return bE(a,b)},h.nice=function(){bx(a,bB);return g()},h.copy=function(){return bz(a,b,c,d)};return g()}function by(){return Math}function bx(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),b=b(f-e),a[c]=b.floor(e),a[d]=b.ceil(f);return a}function bw(a){var b=a[0],c=a[a.length-1];return b<c?[b,c]:[c,b]}function bv(){}function bt(){var a=null,b=bp,c=Infinity;while(b)b.flush?b=a?a.next=b.next:bp=b.next:(c=Math.min(c,b.then+b.delay),b=(a=b).next);return c}function bs(){var a,b=Date.now(),c=bp;while(c)a=b-c.then,a>=c.delay&&(c.flush=c.callback(a)),c=c.next;var d=bt()-b;d>24?(isFinite(d)&&(clearTimeout(br),br=setTimeout(bs,d)),bq=0):(bq=1,bu(bs))}function bo(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 bj(a){return typeof a=="function"?function(b,c,d){var e=a.call(this,b,c);if(e!=null)return d!=e&&d3.interpolate(d,e);if(d!="")return bh}:a==null?bi:(a=a+"",function(b,c,d){return d!=a&&d3.interpolate(d,a)})}function bi(a,b,c){if(c!="")return bh}function bg(a,b){h(a,bk);var c={},d=d3.dispatch("start","end"),e=bn,f=Date.now();a.id=b,a.tween=function(b,d){if(arguments.length<2)return c[b];d==null?delete c[b]:c[b]=d;return a},a.ease=function(b){if(!arguments.length)return e;e=typeof b=="function"?b:d3.ease.apply(d3,arguments);return a},a.each=function(b,c){if(arguments.length<2)return bo.call(a,b);d[b].add(c);return a},d3.timer(function(g){a.each(function(h,i,j){function r(){--o.count||delete l.__transition__;return 1}function q(a){if(o.active!==b)return r();var c=(a-m)/n,f=e(c),g=k.length;while(g>0)k[--g].call(l,f);if(c>=1){r(),bm=b,d.end.dispatch.call(l,h,i),bm=0;return 1}}function p(a){if(o.active>b)return r();o.active=b;for(var e in c)(e=c[e].call(l,h,i))&&k.push(e);d.start.dispatch.call(l,h,i),q(a)||d3.timer(q,0,f);return 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,f)});return 1},0,f);return a}function be(a){arguments.length||(a=d3.ascending);return function(b,c){return a(b&&b.__data__,c&&c.__data__)}}function bc(a){h(a,bd);return a}function bb(a){return{__data__:a}}function ba(a){return function(){return Z(a,this)}}function _(a){return function(){return Y(a,this)}}function X(a){h(a,$);return a}function W(a,b,c){function g(a){return Math.round(f(a)*255)}function f(a){a>360?a-=360:a<0&&(a+=360);return a<60?d+(e-d)*a/60:a<180?e:a<240?d+(e-d)*(240-a)/60:d}var d,e;a=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;return M(g(a+120),g(a),g(a-120))}function V(a,b,c){this.h=a,this.s=b,this.l=c}function U(a,b,c){return new V(a,b,c)}function R(a){var b=parseFloat(a);return a.charAt(a.length-1)==="%"?Math.round(b*2.55):b}function Q(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;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;return U(g,h,i)}function P(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(R(h[0]),R(h[1]),R(h[2]))}}if(i=S[a])return 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));return b(d,e,f)}function O(a){return a<16?"0"+a.toString(16):a.toString(16)}function N(a,b,c){this.r=a,this.g=b,this.b=c}function M(a,b,c){return new N(a,b,c)}function L(a,b){b=b-(a=+a)?1/(b-a):0;return function(c){return Math.max(0,Math.min(1,(c-a)*b))}}function K(a,b){b=b-(a=+a)?1/(b-a):0;return function(c){return(c-a)*b}}function J(a){return a in I||/\bcolor\b/.test(a)?d3.interpolateRgb:d3.interpolate}function G(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 F(a){a||(a=1.70158);return function(b){return b*b*((a+1)*b-a)}}function E(a,b){var c;arguments.length<2&&(b=.45),arguments.length<1?(a=1,c=b/4):c=b/(2*Math.PI)*Math.asin(1/a);return function(d){return 1+a*Math.pow(2,10*-d)*Math.sin((d-c)*2*Math.PI/b)}}function D(a){return 1-Math.sqrt(1-a*a)}function C(a){return Math.pow(2,10*(a-1))}function B(a){return 1-Math.cos(a*Math.PI/2)}function A(a){return function(b){return Math.pow(b,a)}}function z(a){return a}function y(a){return function(b){return.5*(b<.5?a(2*b):2-a(2-2*b))}}function x(a){return function(b){return 1-a(1-b)}}function w(a){return function(b){return b<=0?0:b>=1?1:a(b)}}function r(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 q(a){return a+""}function n(a){var b={},c=[];b.add=function(a){for(var d=0;d<c.length;d++)if(c[d].listener==a)return b;c.push({listener:a,on:!0});return b},b.remove=function(a){for(var d=0;d<c.length;d++){var e=c[d];if(e.listener==a){e.on=!1,c=c.slice(0,d).concat(c.slice(d+1));break}}return b},b.dispatch=function(){var a=c;for(var b=0,d=a.length;b<d;b++){var e=a[b];e.on&&e.listener.apply(this,arguments)}};return b}function l(a){return a.replace(/(^\s+)|(\s+$)/g,"").replace(/\s+/g," ")}function k(a){return a==null}function j(a){return a.length}function i(){return this}function f(a){return Array.prototype.slice.call(a)}function e(a){var b=-1,c=a.length,d=[];while(++b<c)d.push(a[b]);return d}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.3.2"};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.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.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,j),c=Array(b);++a<b;)for(var d=-1,e,f=c[a]=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 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)});f&&e.sort(function(a,b){return f(a.key,b.key)});return e}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}var a={},b=[],c=[],d,e;a.map=function(a){return f(a,0)},a.entries=function(a){return g(f(a,0),0)},a.key=function(c){b.push(c);return a},a.sortKeys=function(d){c[b.length-1]=d;return a},a.sortValues=function(b){d=b;return a},a.rollup=function(b){e=b;return a};return 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=k);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(m,"\\$&")};var m=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/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(a){var b={},c;for(var d=0,e=arguments.length;d<e;d++)c=arguments[d],b[c]=n(c);return b},d3.format=function(a){var b=o.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=!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=!0,i="f";break;case"p":j=!0,i="r";break;case"d":k=!0,h="0"}i=p[i]||q;return function(a){var b=j?a*100:+a,l=b<0&&(b=-b)?"−":d;if(k&&b%1)return"";a=i(b,h);if(e){var m=a.length+l.length;m<f&&(a=Array(f-m+1).join(c)+a),g&&(a=r(a)),a=l+a}else{g&&(a=r(a)),a=l+a;var m=a.length;m<f&&(a=Array(f-m+1).join(c)+a)}j&&(a+="%");return a}};var o=/(?:([^{])?([<>=^]))?([+\- ])?(#)?(0)?([0-9]+)?(,)?(\.[0-9]+)?([a-zA-Z%])?/,p={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){var c=a?1+Math.floor(1e-15+Math.log(a)/Math.LN10):1;return d3.round(a,b-c).toFixed(Math.max(0,Math.min(20,b-c)))}},s=A(2),t=A(3),u={linear:function(){return z},poly:A,quad:function(){return s},cubic:function(){return t},sin:function(){return B},exp:function(){return C},circle:function(){return D},elastic:E,back:F,bounce:function(){return G}},v={"in":function(a){return a},out:x,"in-out":y,"out-in":function(a){return y(x(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 w(v[d](u[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){b-=a;return function(c){return a+b*c}},d3.interpolateRound=function(a,b){b-=a;return 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;H.lastIndex=0;for(d=0;c=H.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=H.lastIndex;f<b.length&&h.push(b.substring(f));for(d=0,j=i.length;(c=H.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"rgb("+Math.round(c+f*a)+","+Math.round(d+g*a)+","+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 W(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]=J(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 H=/[-+]?(?:\d+\.\d+|\d+\.|\.\d+|\d+)(?:[eE][-]?\d+)?/g,I={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 S||/^(#|rgb\(|hsl\()/.test(b):b instanceof N||b instanceof V)&&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?P(""+a,M,W):M(~~a,~~b,~~c)},N.prototype.brighter=function(a){a=Math.pow(.7,arguments.length?a:1);var b=this.r,c=this.g,d=this.b,e=30;if(!b&&!c&&!d)return M(e,e,e);b&&b<e&&(b=e),c&&c<e&&(c=e),d&&d<e&&(d=e);return M(Math.min(255,Math.floor(b/a)),Math.min(255,Math.floor(c/a)),Math.min(255,Math.floor(d/a)))},N.prototype.darker=function(a){a=Math.pow(.7,arguments.length?a:1);return M(Math.max(0,Math.floor(a*this.r)),Math.max(0,Math.floor(a*this.g)),Math.max(0,Math.floor(a*this.b)))},N.prototype.hsl=function(){return Q(this.r,this.g,this.b)},N.prototype.toString=function(){return"#"+O(this.r)+O(this.g)+O(this.b)};var S={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:"#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 T in S)S[T]=P(S[T],M,W);d3.hsl=function(a,b,c){return arguments.length===1?P(""+a,Q,U):U(+a,+b,+c)},V.prototype.brighter=function(a){a=Math.pow(.7,arguments.length?a:1);return U(this.h,this.s,this.l/a)},V.prototype.darker=function(a){a=Math.pow(.7,arguments.length?a:1);return U(this.h,this.s,a*this.l)},V.prototype.rgb=function(){return W(this.h,this.s,this.l)},V.prototype.toString=function(){return"hsl("+this.h+","+this.s*100+"%,"+this.l*100+"%)"};var Y=function(a,b){return b.querySelector(a)},Z=function(a,b){return b.querySelectorAll(a)};typeof Sizzle=="function"&&(Y=function(a,b){return Sizzle(a,b)[0]},Z=function(a,b){return Sizzle.uniqueSort(Sizzle(a,b))});var $=[];d3.selection=function(){return bf},d3.selection.prototype=$,$.select=function(a){var b=[],c,d,e,f;typeof a!="function"&&(a=_(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 X(b)},$.selectAll=function(a){var b=[],c,e;typeof a!="function"&&(a=ba(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 X(b)},$.attr=function(a,b){function i(){var c=b.apply(this,arguments);c==null?this.removeAttributeNS(a.space,a.local):this.setAttributeNS(a.space,a.local,c)}function h(){var c=b.apply(this,arguments);c==null?this.removeAttribute(a):this.setAttribute(a,c)}function g(){this.setAttributeNS(a.space,a.local,b)}function f(){this.setAttribute(a,b)}function e(){this.removeAttributeNS(a.space,a.local)}function d(){this.removeAttribute(a)}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)},$.classed=function(a,b) <del>{function h(){(b.apply(this,arguments)?f:g).call(this)}function g(){if(b=this.classList)return b.remove(a);var b=this.className,d=b.baseVal!=null,e=d?b.baseVal:b;e=l(e.replace(c," ")),d?b.baseVal=e:this.className=e}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=l(e+" "+a),d?b.baseVal=e:this.className=e)}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;c.lastIndex=0;return c.test(e.baseVal!=null?e.baseVal:e)}return this.each(typeof b=="function"?h:b?f:g)},$.style=function(a,b,c){function f(){var d=b.apply(this,arguments);d==null?this.style.removeProperty(a):this.style.setProperty(a,d,c)}function e(){this.style.setProperty(a,b,c)}function d(){this.style.removeProperty(a)}arguments.length<3&&(c="");return arguments.length<2?window.getComputedStyle(this.node(),null).getPropertyValue(a):this.each(b==null?d:typeof b=="function"?f:e)},$.property=function(a,b){function e(){var c=b.apply(this,arguments);c==null?delete this[a]:this[a]=c}function d(){this[a]=b}function c(){delete this[a]}return arguments.length<2?this.node()[a]:this.each(b==null?c:typeof b=="function"?e:d)},$.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})},$.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})},$.append=function(a){function c(){return this.appendChild(document.createElementNS(a.space,a.local))}function b(){return this.appendChild(document.createElement(a))}a=d3.ns.qualify(a);return this.select(a.local?c:b)},$.insert=function(a,b){function d(){return this.insertBefore(document.createElementNS(a.space,a.local),Y(b,this))}function c(){return this.insertBefore(document.createElement(a),Y(b,this))}a=d3.ns.qualify(a);return this.select(a.local?d:c)},$.remove=function(){return this.each(function(){var a=this.parentNode;a&&a.removeChild(this)})},$.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]=bb(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]=bb(p),l[g]=n[g]=null);for(;g<i;++g)m[g]=bb(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=X(d);j.enter=function(){return bc(c)},j.exit=function(){return X(e)};return j};var bd=[];bd.append=$.append,bd.insert=$.insert,bd.empty=$.empty,bd.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 X(b)},$.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 X(b)},$.map=function(a){return this.each(function(){this.__data__=a.apply(this,arguments)})},$.sort=function(a){a=be.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},$.on=function(a,b,c){arguments.length<3&&(c=!1);var d="__on"+a,e=a.indexOf(".");e>0&&(a=a.substring(0,e));return 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})},$.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},$.call=function(a){a.apply(this,(arguments[0]=this,arguments));return this},$.empty=function(){return!this.node()},$.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},$.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 bg(a,bm||++bl)};var bf=X([[document]]);bf[0].parentNode=document.documentElement,d3.select=function(a){return typeof a=="string"?bf.select(a):X([[a]])},d3.selectAll=function(a){return typeof a=="string"?bf.selectAll(a):X([d(a)])};var bh={},bk=[],bl=0,bm=0,bn=d3.ease("cubic-in-out");bk.call=$.call,d3.transition=function(){return bf.transition()},d3.transition.prototype=bk,bk.select=function(a){var b=[],c,d,e;typeof a!="function"&&(a=_(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 bg(b,this.id).ease(this.ease())},bk.selectAll=function(a){var b=[],c,d,e;typeof a!="function"&&(a=ba(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 bg(b,this.id).ease(this.ease())},bk.attr=function(a,b){return this.attrTween(a,bj(b))},bk.attrTween=function(a,b){function d(c,d){var e=b.call(this,c,d,this.getAttributeNS(a.space,a.local));return e&&function(b){this.setAttributeNS(a.space,a.local,e(b))}}function c(c,d){var e=b.call(this,c,d,this.getAttribute(a));if(e===bh)this.removeAttribute(a);else return e&&function(b){this.setAttribute(a,e(b))}}a=d3.ns.qualify(a);return this.tween("attr."+a,a.local?d:c)},bk.style=function(a,b,c){arguments.length<3&&(c="");return this.styleTween(a,bj(b),c)},bk.styleTween=function(a,b,c){arguments.length<3&&(c="");return this.tween("style."+a,function(d,e){var f=b.call(this,d,e,window.getComputedStyle(this,null).getPropertyValue(a));if(f===bh)this.style.removeProperty(a);else return f&&function(b){this.style.setProperty(a,f(b),c)}})},bk.text=function(a){return this.tween("text",function(b,c){this.textContent=typeof a=="function"?a.call(this,b,c):a})},bk.remove=function(){return this.each("end",function(){var a;!this.__transition__&&(a=this.parentNode)&&a.removeChild(this)})},bk.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}))},bk.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}))},bk.transition=function(){return this.select(i)};var bp=null,bq,br;d3.timer=function(a,b,c){var d=!1,e,f=bp;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||(bp={callback:a,then:c,delay:b,next:bp}),bq||(br=clearTimeout(br),bq=1,bu(bs))},d3.timer.flush=function(){var a,b=Date.now(),c=bp;while(c)a=b-c.then,c.delay||(c.flush=c.callback(a)),c=c.next;bt()};var bu=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(a){setTimeout(a,17)};d3.scale={},d3.scale.linear=function(){return bz([0,1],[0,1],d3.interpolate,!1)},d3.scale.log=function(){return bH(d3.scale.linear(),bJ)};var bI=d3.format("e");bJ.pow=function(a){return Math.pow(10,a)},bK.pow=function(a){return-Math.pow(10,-a)},d3.scale.pow=function(){return bL(d3.scale.linear(),1)},d3.scale.sqrt=function(){return d3.scale.pow().exponent(.5)},d3.scale.ordinal=function(){return bN([],{t:"range",x:[]})},d3.scale.category10=function(){return d3.scale.ordinal().range(bO)},d3.scale.category20=function(){return d3.scale.ordinal().range(bP)},d3.scale.category20b=function(){return d3.scale.ordinal().range(bQ)},d3.scale.category20c=function(){return d3.scale.ordinal().range(bR)};var bO=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],bP=["#1f77b4","#aec7e8","#ff7f0e","#ffbb78","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5","#8c564b","#c49c94","#e377c2","#f7b6d2","#7f7f7f","#c7c7c7","#bcbd22","#dbdb8d","#17becf","#9edae5"],bQ=["#393b79","#5254a3","#6b6ecf","#9c9ede","#637939","#8ca252","#b5cf6b","#cedb9c","#8c6d31","#bd9e39","#e7ba52","#e7cb94","#843c39","#ad494a","#d6616b","#e7969c","#7b4173","#a55194","#ce6dbd","#de9ed6"],bR=["#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 bS([],[])},d3.scale.quantize=function(){return bT(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)+bU,h=d.apply(this,arguments)+bU,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>=bV?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=bW,b=bX,c=bY,d=bZ;e.innerRadius=function(b){if(!arguments.length)return a;a=d3.functor(b);return e},e.outerRadius=function(a){if(!arguments.length)return b;b=d3.functor(a);return e},e.startAngle=function(a){if(!arguments.length)return c;c=d3.functor(a);return e},e.endAngle=function(a){if(!arguments.length)return d;d=d3.functor(a);return e},e.centroid=function(){var e=(a.apply(this,arguments)+b.apply(this,arguments))/2,f=(c.apply(this,arguments)+d.apply(this,arguments))/2+bU;return[Math.cos(f)*e,Math.sin(f)*e]};return e};var bU=-Math.PI/2,bV=2*Math.PI-1e-6;d3.svg.line=function(){return b$(Object)};var cc={linear:cd,"step-before":ce,"step-after":cf,basis:cl,"basis-open":cm,"basis-closed":cn,bundle:co,cardinal:ci,"cardinal-open":cg,"cardinal-closed":ch,monotone:cx},cq=[0,2/3,1/3,0],cr=[0,1/3,2/3,0],cs=[0,1/6,2/3,1/6];d3.svg.line.radial=function(){var a=b$(cy);a.radius=a.x,delete a.x,a.angle=a.y,delete a.y;return a},d3.svg.area=function(){return cz(Object)},d3.svg.area.radial=function(){var a=cz(cy);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;return a},d3.svg.chord=function(){function j(a,b,c,d){return"Q 0,0 "+d}function i(a,b){return"A"+a+","+a+" 0 0,1 "+b}function h(a,b){return a.a0==b.a0&&a.a1==b.a1}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)+bU,k=e.call(a,h,g)+bU;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 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"}var a=cC,b=cD,c=cE,d=bY,e=bZ;f.radius=function(a){if(!arguments.length)return c;c=d3.functor(a);return f},f.source=function(b){if(!arguments.length)return a;a=d3.functor(b);return f},f.target=function(a){if(!arguments.length)return b;b=d3.functor(a);return f},f.startAngle=function(a){if(!arguments.length)return d;d=d3.functor(a);return f},f.endAngle=function(a){if(!arguments.length)return e;e=d3.functor(a);return f};return 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];i=i.map(c);return"M"+i[0]+"C"+i[1]+" "+i[2]+" "+i[3]}var a=cC,b=cD,c=cH;d.source=function(b){if(!arguments.length)return a;a=d3.functor(b);return d},d.target=function(a){if(!arguments.length)return b;b=d3.functor(a);return d},d.projection=function(a){if(!arguments.length)return c;c=a;return d};return d},d3.svg.diagonal.radial=function(){var a=d3.svg.diagonal(),b=cH,c=a.projection;a.projection=function(a){return arguments.length?c(cI(b=a)):b};return a},d3.svg.mouse=function(a){return cK(a,d3.event)};var cJ=/WebKit/.test(navigator.userAgent)?-1:0;d3.svg.touches=function(a){var b=d3.event.touches;return b?d(b).map(function(b){var c=cK(a,b);c.identifier=b.identifier;return c}):[]},d3.svg.symbol=function(){function c(c,d){return(cN[a.call(this,c,d)]||cN.circle)(b.call(this,c,d))}var a=cM,b=cL;c.type=function(b){if(!arguments.length)return a;a=d3.functor(b);return c},c.size=function(a){if(!arguments.length)return b;b=d3.functor(a);return c};return c};var cN={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*cP)),c=b*cP;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/cO),c=b*cO/2;return"M0,"+c+"L"+b+","+ -c+" "+ -b+","+ -c+"Z"},"triangle-up":function(a){var b=Math.sqrt(a/cO),c=b*cO/2;return"M0,"+ -c+"L"+b+","+c+" "+ -b+","+c+"Z"}};d3.svg.symbolTypes=d3.keys(cN);var cO=Math.sqrt(3),cP=Math.tan(30*Math.PI/180);d3.svg.axis=function(){function j(j){j.each(function(k,l,m){function F(a){return j.delay?a.transition().delay(j[m][l].delay).duration(j[m][l].duration).ease(j.ease()):a}var n=d3.select(this),o=a.ticks.apply(a,g),p=h==null?a.tickFormat.apply(a,g):h,q=cS(a,o,i),r=n.selectAll(".minor").data(q,String),s=r.enter().insert("svg:line","g").attr("class","tick minor").style("opacity",1e-6),t=F(r.exit()).style("opacity",1e-6).remove(),u=F(r).style("opacity",1),v=n.selectAll("g").data(o,String),w=v.enter().insert("svg:g","path").style("opacity",1e-6),x=F(v.exit()).style("opacity",1e-6).remove(),y=F(v).style("opacity",1),z,A=bw(a.range()),B=n.selectAll(".domain").data([0]),C=B.enter().append("svg:path").attr("class","domain"),D=F(B),E=this.__chart__||a;this.__chart__=a.copy(),w.append("svg:line").attr("class","tick"),w.append("svg:text"),y.select("text").text(p);switch(b){case"bottom":z=cQ,u.attr("y2",d),w.select("text").attr("dy",".71em").attr("text-anchor","middle"),y.select("line").attr("y2",c),y.select("text").attr("y",Math.max(c,0)+f),D.attr("d","M"+A[0]+","+e+"V0H"+A[1]+"V"+e);break;case"top":z=cQ,u.attr("y2",-d),w.select("text").attr("text-anchor","middle"),y.select("line").attr("y2",-c),y.select("text").attr("y",-(Math.max(c,0)+f)),D.attr("d","M"+A[0]+","+ -e+"V0H"+A[1]+"V"+ -e);break;case"left":z=cR,u.attr("x2",-d),w.select("text").attr("dy",".32em").attr("text-anchor","end"),y.select("line").attr("x2",-c),y.select("text").attr("x",-(Math.max(c,0)+f)),D.attr("d","M"+ -e+","+A[0]+"H0V"+A[1]+"H"+ -e);break;case"right":z=cR,u.attr("x2",d),w.select("text").attr("dy",".32em"),y.select("line").attr("x2",c),y.select("text").attr("x",Math.max(c,0)+f),D.attr("d","M"+e+","+A[0]+"H0V"+A[1]+"H"+e)}w.call(z,E),y.call(z,a),x.call(z,a),s.call(z,E),u.call(z,a),t.call(z,a)})}var a=d3.scale.linear(),b="bottom",c=6,d=6,e=6,f=3,g=[10],h,i=0;j.scale=function(b){if(!arguments.length)return a;a=b;return j},j.orient=function(a){if(!arguments.length)return b;b=a;return j},j.ticks=function(){if(!arguments.length)return g;g=arguments;return j},j.tickFormat=function(a){if(!arguments.length)return h;h=a;return j},j.tickSize=function(a,b,f){if(!arguments.length)return c;var g=arguments.length-1;c=+a,d=g>1?+b:c,e=g>0?+arguments[g]:c;return j},j.tickPadding=function(a){if(!arguments.length)return f;f=+a;return j},j.tickSubdivide=function(a){if(!arguments.length)return i;i=+a;return j};return j},d3.behavior={},d3.behavior.drag=function(){function d(){c.apply(this,arguments),c$("dragstart")}function c(){cT=a,cU=d3.event.target,cX=c_((cV=this).parentNode),cY=0,cW=arguments}function b(){this.on("mousedown.drag",d).on("touchstart.drag",d),d3.select(window).on("mousemove.drag",da).on("touchmove.drag",da).on("mouseup.drag",db,!0).on("touchend.drag",db,!0).on("click.drag",dc,!0)}var a=d3.dispatch("drag","dragstart","dragend");b.on=function(c,d){a[c].add(d);return b};return b};var cT,cU,cV,cW,cX,cY,cZ;d3.behavior.zoom=function(){function h(){d.apply(this,arguments);var b=dt(),c,e=Date.now();b.length===1&&e-di<300&&dy(1+Math.floor(a[2]),c=b[0],dh[c.identifier]),di=e}function g(){d.apply(this,arguments);var b=d3.svg.mouse(dm);dy(d3.event.shiftKey?Math.ceil(a[2]-1):Math.floor(a[2]+1),b,dr(b))}function f(){d.apply(this,arguments),dg||(dg=dr(d3.svg.mouse(dm))),dy(ds()+a[2],d3.svg.mouse(dm),dg)}function e(){d.apply(this,arguments),df=dr(d3.svg.mouse(dm)),dp=!1,d3.event.preventDefault(),window.focus()}function d(){dj=a,dk=b.zoom.dispatch,dl=d3.event.target,dm=this,dn=arguments}function c(){this.on("mousedown.zoom",e).on("mousewheel.zoom",f).on("DOMMouseScroll.zoom",f).on("dblclick.zoom",g).on("touchstart.zoom",h),d3.select(window).on("mousemove.zoom",dv).on("mouseup.zoom",dw).on("touchmove.zoom",du).on("touchend.zoom",dt).on("click.zoom",dx,!0)}var a=[0,0,0],b=d3.dispatch("zoom");c.on=function(a,d){b[a].add(d);return c};return c};var de,df,dg,dh={},di=0,dj,dk,dl,dm,dn,dp,dq})() <ide>\ No newline at end of file <add>(function(){function dy(a,b,c){function i(a,b){var c=a.__domain||(a.__domain=a.domain()),d=a.range().map(function(a){return(a-b)/h});a.domain(c).domain(d.map(a.invert))}var d=Math.pow(2,(dj[2]=a)-c[2]),e=dj[0]=b[0]-d*c[0],f=dj[1]=b[1]-d*c[1],g=d3.event,h=Math.pow(2,a);d3.event={scale:h,translate:[e,f],transform:function(a,b){a&&i(a,e),b&&i(b,f)}};try{dk.apply(dm,dn)}finally{d3.event=g}g.preventDefault()}function dx(){dq&&dl===d3.event.target&&(d3.event.stopPropagation(),d3.event.preventDefault(),dq=!1,dl=null)}function dw(){df&&(dp&&dl===d3.event.target&&(dq=!0),dv(),df=null)}function dv(){dg=null,df&&(dp=!0,dy(dj[2],d3.svg.mouse(dm),df))}function du(){var a=d3.svg.touches(dm);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 dt(){var a=d3.svg.touches(dm),b=-1,c=a.length,d;while(++b<c)dh[(d=a[b]).identifier]=dr(d);return a}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 dr(a){return[a[0]-dj[0],a[1]-dj[1],dj[2]]}function dd(){d3.event.stopPropagation(),d3.event.preventDefault()}function dc(){cZ&&cU===d3.event.target&&(dd(),cZ=!1,cU=null)}function db(){!cV||(c$("dragend"),cV=null,cY&&cU===d3.event.target&&(cZ=!0,dd()))}function da(){if(!!cV){var a=cV.parentNode;if(!a)return db();c$("drag"),dd()}}function c_(a){return d3.event.touches?d3.svg.touches(a)[0]:d3.svg.mouse(a)}function c$(a){var b=d3.event,c=cV.parentNode,d=0,e=0;c&&(c=c_(c),d=c[0]-cX[0],e=c[1]-cX[1],cX=c,cY|=d|e);try{d3.event={dx:d,dy:e},cT[a].dispatch.apply(cV,cW)}finally{d3.event=b}b.preventDefault()}function cS(a,b,c){e=[];if(c&&b.length>1){var d=bw(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 cR(a,b){a.attr("transform",function(a){return"translate(0,"+b(a)+")"})}function cQ(a,b){a.attr("transform",function(a){return"translate("+b(a)+",0)"})}function cM(){return"circle"}function cL(){return 64}function cK(a,b){var c=(a.ownerSVGElement||a).createSVGPoint();if(cJ<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();cJ=!e.f&&!e.e,d.remove()}cJ?(c.x=b.pageX,c.y=b.pageY):(c.x=b.clientX,c.y=b.clientY),c=c.matrixTransform(a.getScreenCTM().inverse());return[c.x,c.y]}function cI(a){return function(){var b=a.apply(this,arguments),c=b[0],d=b[1]+bU;return[c*Math.cos(d),c*Math.sin(d)]}}function cH(a){return[a.x,a.y]}function cG(a){return a.endAngle}function cF(a){return a.startAngle}function cE(a){return a.radius}function cD(a){return a.target}function cC(a){return a.source}function cB(a){return function(b,c){return a[c][1]}}function cA(a){return function(b,c){return a[c][0]}}function cz(a){function i(f){if(f.length<1)return null;var i=b_(this,f,b,d),j=b_(this,f,b===c?cA(i):c,d===e?cB(i):e);return"M"+g(a(j),h)+"L"+g(a(i.reverse()),h)+"Z"}var b=ca,c=ca,d=0,e=cb,f="linear",g=cc[f],h=.7;i.x=function(a){if(!arguments.length)return c;b=c=a;return i},i.x0=function(a){if(!arguments.length)return b;b=a;return i},i.x1=function(a){if(!arguments.length)return c;c=a;return i},i.y=function(a){if(!arguments.length)return e;d=e=a;return i},i.y0=function(a){if(!arguments.length)return d;d=a;return i},i.y1=function(a){if(!arguments.length)return e;e=a;return i},i.interpolate=function(a){if(!arguments.length)return f;g=cc[f=a];return i},i.tension=function(a){if(!arguments.length)return h;h=a;return i};return i}function cy(a){var b,c=-1,d=a.length,e,f;while(++c<d)b=a[c],e=b[0],f=b[1]+bU,b[0]=e*Math.cos(f),b[1]=e*Math.sin(f);return a}function cx(a){return a.length<3?cd(a):a[0]+cj(a,cw(a))}function cw(a){var b=[],c,d,e,f,g=cv(a),h=-1,i=a.length-1;while(++h<i)c=cu(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 cv(a){var b=0,c=a.length-1,d=[],e=a[0],f=a[1],g=d[0]=cu(e,f);while(++b<c)d[b]=g+(g=cu(e=f,f=a[b+1]));d[b]=g;return d}function cu(a,b){return(b[1]-a[1])/(b[0]-a[0])}function ct(a,b,c){a.push("C",cp(cq,b),",",cp(cq,c),",",cp(cr,b),",",cp(cr,c),",",cp(cs,b),",",cp(cs,c))}function cp(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]+a[3]*b[3]}function co(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 cl(a)}function cn(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=[cp(cs,g),",",cp(cs,h)],--c;while(++c<e)f=a[c%d],g.shift(),g.push(f[0]),h.shift(),h.push(f[1]),ct(b,g,h);return b.join("")}function cm(a){if(a.length<4)return cd(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(cp(cs,f)+","+cp(cs,g)),--c;while(++c<d)e=a[c],f.shift(),f.push(e[0]),g.shift(),g.push(e[1]),ct(b,f,g);return b.join("")}function cl(a){if(a.length<3)return cd(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];ct(i,g,h);while(++b<c)d=a[b],g.shift(),g.push(d[0]),h.shift(),h.push(d[1]),ct(i,g,h);b=-1;while(++b<2)g.shift(),g.push(d[0]),h.shift(),h.push(d[1]),ct(i,g,h);return i.join("")}function ck(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 cj(a,b){if(b.length<1||a.length!=b.length&&a.length!=b.length+2)return cd(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 ci(a,b,c){return a.length<3?cd(a):a[0]+cj(a,ck(a,b))}function ch(a,b){return a.length<3?cd(a):a[0]+cj((a.push(a[0]),a),ck([a[a.length-2]].concat(a,[a[1]]),b))}function cg(a,b){return a.length<4?cd(a):a[1]+cj(a.slice(1,a.length-1),ck(a,b))}function cf(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 ce(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 cd(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 cb(a){return a[1]}function ca(a){return a[0]}function b_(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 b$(a){function g(d){return d.length<1?null:"M"+e(a(b_(this,d,b,c)),f)}var b=ca,c=cb,d="linear",e=cc[d],f=.7;g.x=function(a){if(!arguments.length)return b;b=a;return g},g.y=function(a){if(!arguments.length)return c;c=a;return g},g.interpolate=function(a){if(!arguments.length)return d;e=cc[d=a];return g},g.tension=function(a){if(!arguments.length)return f;f=a;return g};return g}function bZ(a){return a.endAngle}function bY(a){return a.startAngle}function bX(a){return a.outerRadius}function bW(a){return a.innerRadius}function bT(a,b,c){function g(){d=c.length/(b-a),e=c.length-1;return f}function f(b){return c[Math.max(0,Math.min(e,Math.floor(d*(b-a))))]}var d,e;f.domain=function(c){if(!arguments.length)return[a,b];a=+c[0],b=+c[c.length-1];return g()},f.range=function(a){if(!arguments.length)return c;c=a;return g()},f.copy=function(){return bT(a,b,c)};return g()}function bS(a,b){function e(a){return isNaN(a=+a)?NaN:b[d3.bisect(c,a)]}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}var c;e.domain=function(b){if(!arguments.length)return a;a=b.filter(function(a){return!isNaN(a)}).sort(d3.ascending);return d()},e.range=function(a){if(!arguments.length)return b;b=a;return d()},e.quantiles=function(){return c},e.copy=function(){return bS(a,b)};return d()}function bN(a,b){function f(b){return d[((c[b]||(c[b]=a.push(b)))-1)%d.length]}var c,d,e;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){if(!arguments.length)return d;d=a,e=0,b={t:"range",x:a};return f},f.rangePoints=function(c,g){arguments.length<2&&(g=0);var h=c[0],i=c[1],j=(i-h)/(a.length-1+g);d=a.length<2?[(h+i)/2]:d3.range(h+j*g/2,i+j/2,j),e=0,b={t:"rangePoints",x:c,p:g};return f},f.rangeBands=function(c,g){arguments.length<2&&(g=0);var h=c[0],i=c[1],j=(i-h)/(a.length+g);d=d3.range(h+j*g,i,j),e=j*(1-g),b={t:"rangeBands",x:c,p:g};return f},f.rangeRoundBands=function(c,g){arguments.length<2&&(g=0);var h=c[0],i=c[1],j=Math.floor((i-h)/(a.length+g)),k=i-h-(a.length-g)*j;d=d3.range(h+Math.round(k/2),i,j),e=Math.round(j*(1-g)),b={t:"rangeRoundBands",x:c,p:g};return f},f.rangeBand=function(){return e},f.copy=function(){return bN(a,b)};return f.domain(a)}function bM(a){return function(b){return b<0?-Math.pow(-b,a):Math.pow(b,a)}}function bL(a,b){function e(b){return a(c(b))}var c=bM(b),d=bM(1/b);e.invert=function(b){return d(a.invert(b))},e.domain=function(b){if(!arguments.length)return a.domain().map(d);a.domain(b.map(c));return e},e.ticks=function(a){return bD(e.domain(),a)},e.tickFormat=function(a){return bE(e.domain(),a)},e.nice=function(){return e.domain(bx(e.domain(),bB))},e.exponent=function(a){if(!arguments.length)return b;var f=e.domain();c=bM(b=a),d=bM(1/b);return e.domain(f)},e.copy=function(){return bL(a.copy(),b)};return bA(e,a)}function bK(a){return-Math.log(-a)/Math.LN10}function bJ(a){return Math.log(a)/Math.LN10}function bH(a,b){function d(c){return a(b(c))}var c=b.pow;d.invert=function(b){return c(a.invert(b))},d.domain=function(e){if(!arguments.length)return a.domain().map(c);b=e[0]<0?bK:bJ,c=b.pow,a.domain(e.map(b));return d},d.nice=function(){a.domain(bx(a.domain(),by));return d},d.ticks=function(){var d=bw(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===bK){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=bI);if(arguments.length<1)return e;var f=a/d.ticks().length,g=b===bK?(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 bH(a.copy(),b)};return bA(d,a)}function bG(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 bF(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 bE(a,b){return d3.format(",."+Math.max(0,-Math.floor(Math.log(bC(a,b)[2])/Math.LN10+.01))+"f")}function bD(a,b){return d3.range.apply(d3,bC(a,b))}function bC(a,b){var c=bw(a),d=c[1]-c[0],e=Math.pow(10,Math.floor(Math.log(d/b)/Math.LN10)),f=b/d*e;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;return c}function bB(a){a=Math.pow(10,Math.round(Math.log(a)/Math.LN10)-1);return{floor:function(b){return Math.floor(b/a)*a},ceil:function(b){return Math.ceil(b/a)*a}}}function bA(a,b){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);return a}function bz(a,b,c,d){function h(a){return e(a)}function g(){var g=a.length==2?bF:bG,i=d?L:K;e=g(a,b,i,c),f=g(b,a,i,d3.interpolate);return h}var e,f;h.invert=function(a){return f(a)},h.domain=function(b){if(!arguments.length)return a;a=b.map(Number);return g()},h.range=function(a){if(!arguments.length)return b;b=a;return g()},h.rangeRound=function(a){return h.range(a).interpolate(d3.interpolateRound)},h.clamp=function(a){if(!arguments.length)return d;d=a;return g()},h.interpolate=function(a){if(!arguments.length)return c;c=a;return g()},h.ticks=function(b){return bD(a,b)},h.tickFormat=function(b){return bE(a,b)},h.nice=function(){bx(a,bB);return g()},h.copy=function(){return bz(a,b,c,d)};return g()}function by(){return Math}function bx(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),b=b(f-e),a[c]=b.floor(e),a[d]=b.ceil(f);return a}function bw(a){var b=a[0],c=a[a.length-1];return b<c?[b,c]:[c,b]}function bv(){}function bt(){var a=null,b=bp,c=Infinity;while(b)b.flush?b=a?a.next=b.next:bp=b.next:(c=Math.min(c,b.then+b.delay),b=(a=b).next);return c}function bs(){var a,b=Date.now(),c=bp;while(c)a=b-c.then,a>=c.delay&&(c.flush=c.callback(a)),c=c.next;var d=bt()-b;d>24?(isFinite(d)&&(clearTimeout(br),br=setTimeout(bs,d)),bq=0):(bq=1,bu(bs))}function bo(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 bj(a){function c(b,c,d){return d!=a&&d3.interpolate(d,a)}function b(b,c,d){var e=a.call(this,b,c);return e==null?d!=""&&bh:d!=e&&d3.interpolate(d,e)}return typeof a=="function"?b:a==null?bi:(a+="",c)}function bi(a,b,c){return c!=""&&bh}function bg(a,b){h(a,bk);var c={},d=d3.dispatch("start","end"),e=bn,f=Date.now();a.id=b,a.tween=function(b,d){if(arguments.length<2)return c[b];d==null?delete c[b]:c[b]=d;return a},a.ease=function(b){if(!arguments.length)return e;e=typeof b=="function"?b:d3.ease.apply(d3,arguments);return a},a.each=function(b,c){if(arguments.length<2)return bo.call(a,b);d[b].add(c);return a},d3.timer(function(g){a.each(function(h,i,j){function r(){--o.count||delete l.__transition__;return 1}function q(a){if(o.active!==b)return r();var c=(a-m)/n,f=e(c),g=k.length;while(g>0)k[--g].call(l,f);if(c>=1){r(),bm=b,d.end.dispatch.call(l,h,i),bm=0;return 1}}function p(a){if(o.active>b)return r();o.active=b;for(var e in c)(e=c[e].call(l,h,i))&&k.push(e);d.start.dispatch.call(l,h,i),q(a)||d3.timer(q,0,f);return 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,f)});return 1},0,f);return a}function be(a){arguments.length||(a=d3.ascending);return function(b,c){return a(b&&b.__data__,c&&c.__data__)}}function bc(a){h(a,bd);return a}function bb(a){return{__data__:a}}function ba(a){return function(){return Z(a,this)}}function _(a){return function(){return Y(a,this)}}function X(a){h(a,$);return a}function W(a,b,c){function g(a){return Math.round(f(a)*255)}function f(a){a>360?a-=360:a<0&&(a+=360);return a<60?d+(e-d)*a/60:a<180?e:a<240?d+(e-d)*(240-a)/60:d}var d,e;a=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;return M(g(a+120),g(a),g(a-120))}function V(a,b,c){this.h=a,this.s=b,this.l=c}function U(a,b,c){return new V(a,b,c)}function R(a){var b=parseFloat(a);return a.charAt(a.length-1)==="%"?Math.round(b*2.55):b}function Q(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;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;return U(g,h,i)}function P(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(R(h[0]),R(h[1]),R(h[2]))}}if(i=S[a])return 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));return b(d,e,f)}function O(a){return a<16?"0"+a.toString(16):a.toString(16)}function N(a,b,c){this.r=a,this.g=b,this.b=c}function M(a,b,c){return new N(a,b,c)}function L(a,b){b=b-(a=+a)?1/(b-a):0;return function(c){return Math.max(0,Math.min(1,(c-a)*b))}}function K(a,b){b=b-(a=+a)?1/(b-a):0;return function(c){return(c-a)*b}}function J(a){return a in I||/\bcolor\b/.test(a)?d3.interpolateRgb:d3.interpolate}function G(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 F(a){a||(a=1.70158);return function(b){return b*b*((a+1)*b-a)}}function E(a,b){var c;arguments.length<2&&(b=.45),arguments.length<1?(a=1,c=b/4):c=b/(2*Math.PI)*Math.asin(1/a);return function(d){return 1+a*Math.pow(2,10*-d)*Math.sin((d-c)*2*Math.PI/b)}}function D(a){return 1-Math.sqrt(1-a*a)}function C(a){return Math.pow(2,10*(a-1))}function B(a){return 1-Math.cos(a*Math.PI/2)}function A(a){return function(b){return Math.pow(b,a)}}function z(a){return a}function y(a){return function(b){return.5*(b<.5?a(2*b):2-a(2-2*b))}}function x(a){return function(b){return 1-a(1-b)}}function w(a){return function(b){return b<=0?0:b>=1?1:a(b)}}function r(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 q(a){return a+""}function n(a){var b={},c=[];b.add=function(a){for(var d=0;d<c.length;d++)if(c[d].listener==a)return b;c.push({listener:a,on:!0});return b},b.remove=function(a){for(var d=0;d<c.length;d++){var e=c[d];if(e.listener==a){e.on=!1,c=c.slice(0,d).concat(c.slice(d+1));break}}return b},b.dispatch=function(){var a=c;for(var b=0,d=a.length;b<d;b++){var e=a[b];e.on&&e.listener.apply(this,arguments)}};return b}function l(a){return a.replace(/(^\s+)|(\s+$)/g,"").replace(/\s+/g," ")}function k(a){return a==null}function j(a){return a.length}function i(){return this}function f(a){return Array.prototype.slice.call(a)}function e(a){var b=-1,c=a.length,d=[];while(++b<c)d.push(a[b]);return d}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.3.2"};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.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.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,j),c=Array(b);++a<b;)for(var d=-1,e,f=c[a]=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 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)});f&&e.sort(function(a,b){return f(a.key,b.key)});return e}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}var a={},b=[],c=[],d,e;a.map=function(a){return f(a,0)},a.entries=function(a){return g(f(a,0),0)},a.key=function(c){b.push(c);return a},a.sortKeys=function(d){c[b.length-1]=d;return a},a.sortValues=function(b){d=b;return a},a.rollup=function(b){e=b;return a};return 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=k);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(m,"\\$&")};var m=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/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(a){var b={},c;for(var d=0,e=arguments.length;d<e;d++)c=arguments[d],b[c]=n(c);return b},d3.format=function(a){var b=o.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=!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=!0,i="f";break;case"p":j=!0,i="r";break;case"d":k=!0,h="0"}i=p[i]||q;return function(a){var b=j?a*100:+a,l=b<0&&(b=-b)?"−":d;if(k&&b%1)return"";a=i(b,h);if(e){var m=a.length+l.length;m<f&&(a=Array(f-m+1).join(c)+a),g&&(a=r(a)),a=l+a}else{g&&(a=r(a)),a=l+a;var m=a.length;m<f&&(a=Array(f-m+1).join(c)+a)}j&&(a+="%");return a}};var o=/(?:([^{])?([<>=^]))?([+\- ])?(#)?(0)?([0-9]+)?(,)?(\.[0-9]+)?([a-zA-Z%])?/,p={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){var c=a?1+Math.floor(1e-15+Math.log(a)/Math.LN10):1;return d3.round(a,b-c).toFixed(Math.max(0,Math.min(20,b-c)))}},s=A(2),t=A(3),u={linear:function(){return z},poly:A,quad:function(){return s},cubic:function(){return t},sin:function(){return B},exp:function(){return C},circle:function(){return D},elastic:E,back:F,bounce:function(){return G}},v={"in":function(a){return a},out:x,"in-out":y,"out-in":function(a){return y(x(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 w(v[d](u[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){b-=a;return function(c){return a+b*c}},d3.interpolateRound=function(a,b){b-=a;return 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;H.lastIndex=0;for(d=0;c=H.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=H.lastIndex;f<b.length&&h.push(b.substring(f));for(d=0,j=i.length;(c=H.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"rgb("+Math.round(c+f*a)+","+Math.round(d+g*a)+","+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 W(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]=J(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 H=/[-+]?(?:\d+\.\d+|\d+\.|\.\d+|\d+)(?:[eE][-]?\d+)?/g,I={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 S||/^(#|rgb\(|hsl\()/.test(b):b instanceof N||b instanceof V)&&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?P(""+a,M,W):M(~~a,~~b,~~c)},N.prototype.brighter=function(a){a=Math.pow(.7,arguments.length?a:1);var b=this.r,c=this.g,d=this.b,e=30;if(!b&&!c&&!d)return M(e,e,e);b&&b<e&&(b=e),c&&c<e&&(c=e),d&&d<e&&(d=e);return M(Math.min(255,Math.floor(b/a)),Math.min(255,Math.floor(c/a)),Math.min(255,Math.floor(d/a)))},N.prototype.darker=function(a){a=Math.pow(.7,arguments.length?a:1);return M(Math.max(0,Math.floor(a*this.r)),Math.max(0,Math.floor(a*this.g)),Math.max(0,Math.floor(a*this.b)))},N.prototype.hsl=function(){return Q(this.r,this.g,this.b)},N.prototype.toString=function(){return"#"+O(this.r)+O(this.g)+O(this.b)};var S={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:"#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 T in S)S[T]=P(S[T],M,W);d3.hsl=function(a,b,c){return arguments.length===1?P(""+a,Q,U):U(+a,+b,+c)},V.prototype.brighter=function(a){a=Math.pow(.7,arguments.length?a:1);return U(this.h,this.s,this.l/a)},V.prototype.darker=function(a){a=Math.pow(.7,arguments.length?a:1);return U(this.h,this.s,a*this.l)},V.prototype.rgb=function(){return W(this.h,this.s,this.l)},V.prototype.toString=function(){return"hsl("+this.h+","+this.s*100+"%,"+this.l*100+"%)"};var Y=function(a,b){return b.querySelector(a)},Z=function(a,b){return b.querySelectorAll(a)};typeof Sizzle=="function"&&(Y=function(a,b){return Sizzle(a,b)[0]},Z=function(a,b){return Sizzle.uniqueSort(Sizzle(a,b))});var $=[];d3.selection=function(){return bf},d3.selection.prototype=$,$.select=function(a){var b=[],c,d,e,f;typeof a!="function"&&(a=_(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 X(b)},$.selectAll=function(a){var b=[],c,e;typeof a!="function"&&(a=ba(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 X(b)},$.attr=function(a,b){function i(){var c=b.apply(this,arguments);c==null?this.removeAttributeNS(a.space,a.local):this.setAttributeNS(a.space,a.local,c)}function h(){var c=b.apply(this,arguments);c==null?this.removeAttribute(a):this.setAttribute(a,c)}function g(){this.setAttributeNS(a.space,a.local,b)}function f(){this.setAttribute(a,b)}function e(){this.removeAttributeNS(a.space,a.local)}function d(){this.removeAttribute(a)}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)},$.classed=function(a,b){function h <add>(){(b.apply(this,arguments)?f:g).call(this)}function g(){if(b=this.classList)return b.remove(a);var b=this.className,d=b.baseVal!=null,e=d?b.baseVal:b;e=l(e.replace(c," ")),d?b.baseVal=e:this.className=e}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=l(e+" "+a),d?b.baseVal=e:this.className=e)}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;c.lastIndex=0;return c.test(e.baseVal!=null?e.baseVal:e)}return this.each(typeof b=="function"?h:b?f:g)},$.style=function(a,b,c){function f(){var d=b.apply(this,arguments);d==null?this.style.removeProperty(a):this.style.setProperty(a,d,c)}function e(){this.style.setProperty(a,b,c)}function d(){this.style.removeProperty(a)}arguments.length<3&&(c="");return arguments.length<2?window.getComputedStyle(this.node(),null).getPropertyValue(a):this.each(b==null?d:typeof b=="function"?f:e)},$.property=function(a,b){function e(){var c=b.apply(this,arguments);c==null?delete this[a]:this[a]=c}function d(){this[a]=b}function c(){delete this[a]}return arguments.length<2?this.node()[a]:this.each(b==null?c:typeof b=="function"?e:d)},$.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})},$.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})},$.append=function(a){function c(){return this.appendChild(document.createElementNS(a.space,a.local))}function b(){return this.appendChild(document.createElement(a))}a=d3.ns.qualify(a);return this.select(a.local?c:b)},$.insert=function(a,b){function d(){return this.insertBefore(document.createElementNS(a.space,a.local),Y(b,this))}function c(){return this.insertBefore(document.createElement(a),Y(b,this))}a=d3.ns.qualify(a);return this.select(a.local?d:c)},$.remove=function(){return this.each(function(){var a=this.parentNode;a&&a.removeChild(this)})},$.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]=bb(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]=bb(p),l[g]=n[g]=null);for(;g<i;++g)m[g]=bb(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=X(d);j.enter=function(){return bc(c)},j.exit=function(){return X(e)};return j};var bd=[];bd.append=$.append,bd.insert=$.insert,bd.empty=$.empty,bd.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 X(b)},$.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 X(b)},$.map=function(a){return this.each(function(){this.__data__=a.apply(this,arguments)})},$.sort=function(a){a=be.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},$.on=function(a,b,c){arguments.length<3&&(c=!1);var d="__on"+a,e=a.indexOf(".");e>0&&(a=a.substring(0,e));return 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})},$.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},$.call=function(a){a.apply(this,(arguments[0]=this,arguments));return this},$.empty=function(){return!this.node()},$.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},$.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 bg(a,bm||++bl)};var bf=X([[document]]);bf[0].parentNode=document.documentElement,d3.select=function(a){return typeof a=="string"?bf.select(a):X([[a]])},d3.selectAll=function(a){return typeof a=="string"?bf.selectAll(a):X([d(a)])};var bh={},bk=[],bl=0,bm=0,bn=d3.ease("cubic-in-out");bk.call=$.call,d3.transition=function(){return bf.transition()},d3.transition.prototype=bk,bk.select=function(a){var b=[],c,d,e;typeof a!="function"&&(a=_(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 bg(b,this.id).ease(this.ease())},bk.selectAll=function(a){var b=[],c,d,e;typeof a!="function"&&(a=ba(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 bg(b,this.id).ease(this.ease())},bk.attr=function(a,b){return this.attrTween(a,bj(b))},bk.attrTween=function(a,b){function e(a,d){var e=b.call(this,a,d,this.getAttributeNS(c.space,c.local));return e===bh?(this.removeAttributeNS(c.space,c.local),null):e&&function(a){this.setAttributeNS(c.space,c.local,e(a))}}function d(a,d){var e=b.call(this,a,d,this.getAttribute(c));return e===bh?this.removeAttribute(c):e&&function(a){this.setAttribute(c,e(a))}}var c=d3.ns.qualify(a);return this.tween("attr."+a,c.local?e:d)},bk.style=function(a,b,c){arguments.length<3&&(c="");return this.styleTween(a,bj(b),c)},bk.styleTween=function(a,b,c){arguments.length<3&&(c="");return this.tween("style."+a,function(d,e){var f=b.call(this,d,e,window.getComputedStyle(this,null).getPropertyValue(a));if(f!==bh)return f&&function(b){this.style.setProperty(a,f(b),c)};this.style.removeProperty(a)})},bk.text=function(a){return this.tween("text",function(b,c){this.textContent=typeof a=="function"?a.call(this,b,c):a})},bk.remove=function(){return this.each("end",function(){var a;!this.__transition__&&(a=this.parentNode)&&a.removeChild(this)})},bk.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}))},bk.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}))},bk.transition=function(){return this.select(i)};var bp=null,bq,br;d3.timer=function(a,b,c){var d=!1,e,f=bp;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||(bp={callback:a,then:c,delay:b,next:bp}),bq||(br=clearTimeout(br),bq=1,bu(bs))},d3.timer.flush=function(){var a,b=Date.now(),c=bp;while(c)a=b-c.then,c.delay||(c.flush=c.callback(a)),c=c.next;bt()};var bu=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(a){setTimeout(a,17)};d3.scale={},d3.scale.linear=function(){return bz([0,1],[0,1],d3.interpolate,!1)},d3.scale.log=function(){return bH(d3.scale.linear(),bJ)};var bI=d3.format("e");bJ.pow=function(a){return Math.pow(10,a)},bK.pow=function(a){return-Math.pow(10,-a)},d3.scale.pow=function(){return bL(d3.scale.linear(),1)},d3.scale.sqrt=function(){return d3.scale.pow().exponent(.5)},d3.scale.ordinal=function(){return bN([],{t:"range",x:[]})},d3.scale.category10=function(){return d3.scale.ordinal().range(bO)},d3.scale.category20=function(){return d3.scale.ordinal().range(bP)},d3.scale.category20b=function(){return d3.scale.ordinal().range(bQ)},d3.scale.category20c=function(){return d3.scale.ordinal().range(bR)};var bO=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],bP=["#1f77b4","#aec7e8","#ff7f0e","#ffbb78","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5","#8c564b","#c49c94","#e377c2","#f7b6d2","#7f7f7f","#c7c7c7","#bcbd22","#dbdb8d","#17becf","#9edae5"],bQ=["#393b79","#5254a3","#6b6ecf","#9c9ede","#637939","#8ca252","#b5cf6b","#cedb9c","#8c6d31","#bd9e39","#e7ba52","#e7cb94","#843c39","#ad494a","#d6616b","#e7969c","#7b4173","#a55194","#ce6dbd","#de9ed6"],bR=["#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 bS([],[])},d3.scale.quantize=function(){return bT(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)+bU,h=d.apply(this,arguments)+bU,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>=bV?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=bW,b=bX,c=bY,d=bZ;e.innerRadius=function(b){if(!arguments.length)return a;a=d3.functor(b);return e},e.outerRadius=function(a){if(!arguments.length)return b;b=d3.functor(a);return e},e.startAngle=function(a){if(!arguments.length)return c;c=d3.functor(a);return e},e.endAngle=function(a){if(!arguments.length)return d;d=d3.functor(a);return e},e.centroid=function(){var e=(a.apply(this,arguments)+b.apply(this,arguments))/2,f=(c.apply(this,arguments)+d.apply(this,arguments))/2+bU;return[Math.cos(f)*e,Math.sin(f)*e]};return e};var bU=-Math.PI/2,bV=2*Math.PI-1e-6;d3.svg.line=function(){return b$(Object)};var cc={linear:cd,"step-before":ce,"step-after":cf,basis:cl,"basis-open":cm,"basis-closed":cn,bundle:co,cardinal:ci,"cardinal-open":cg,"cardinal-closed":ch,monotone:cx},cq=[0,2/3,1/3,0],cr=[0,1/3,2/3,0],cs=[0,1/6,2/3,1/6];d3.svg.line.radial=function(){var a=b$(cy);a.radius=a.x,delete a.x,a.angle=a.y,delete a.y;return a},d3.svg.area=function(){return cz(Object)},d3.svg.area.radial=function(){var a=cz(cy);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;return a},d3.svg.chord=function(){function j(a,b,c,d){return"Q 0,0 "+d}function i(a,b){return"A"+a+","+a+" 0 0,1 "+b}function h(a,b){return a.a0==b.a0&&a.a1==b.a1}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)+bU,k=e.call(a,h,g)+bU;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 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"}var a=cC,b=cD,c=cE,d=bY,e=bZ;f.radius=function(a){if(!arguments.length)return c;c=d3.functor(a);return f},f.source=function(b){if(!arguments.length)return a;a=d3.functor(b);return f},f.target=function(a){if(!arguments.length)return b;b=d3.functor(a);return f},f.startAngle=function(a){if(!arguments.length)return d;d=d3.functor(a);return f},f.endAngle=function(a){if(!arguments.length)return e;e=d3.functor(a);return f};return 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];i=i.map(c);return"M"+i[0]+"C"+i[1]+" "+i[2]+" "+i[3]}var a=cC,b=cD,c=cH;d.source=function(b){if(!arguments.length)return a;a=d3.functor(b);return d},d.target=function(a){if(!arguments.length)return b;b=d3.functor(a);return d},d.projection=function(a){if(!arguments.length)return c;c=a;return d};return d},d3.svg.diagonal.radial=function(){var a=d3.svg.diagonal(),b=cH,c=a.projection;a.projection=function(a){return arguments.length?c(cI(b=a)):b};return a},d3.svg.mouse=function(a){return cK(a,d3.event)};var cJ=/WebKit/.test(navigator.userAgent)?-1:0;d3.svg.touches=function(a){var b=d3.event.touches;return b?d(b).map(function(b){var c=cK(a,b);c.identifier=b.identifier;return c}):[]},d3.svg.symbol=function(){function c(c,d){return(cN[a.call(this,c,d)]||cN.circle)(b.call(this,c,d))}var a=cM,b=cL;c.type=function(b){if(!arguments.length)return a;a=d3.functor(b);return c},c.size=function(a){if(!arguments.length)return b;b=d3.functor(a);return c};return c};var cN={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*cP)),c=b*cP;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/cO),c=b*cO/2;return"M0,"+c+"L"+b+","+ -c+" "+ -b+","+ -c+"Z"},"triangle-up":function(a){var b=Math.sqrt(a/cO),c=b*cO/2;return"M0,"+ -c+"L"+b+","+c+" "+ -b+","+c+"Z"}};d3.svg.symbolTypes=d3.keys(cN);var cO=Math.sqrt(3),cP=Math.tan(30*Math.PI/180);d3.svg.axis=function(){function j(j){j.each(function(k,l,m){function F(a){return j.delay?a.transition().delay(j[m][l].delay).duration(j[m][l].duration).ease(j.ease()):a}var n=d3.select(this),o=a.ticks.apply(a,g),p=h==null?a.tickFormat.apply(a,g):h,q=cS(a,o,i),r=n.selectAll(".minor").data(q,String),s=r.enter().insert("svg:line","g").attr("class","tick minor").style("opacity",1e-6),t=F(r.exit()).style("opacity",1e-6).remove(),u=F(r).style("opacity",1),v=n.selectAll("g").data(o,String),w=v.enter().insert("svg:g","path").style("opacity",1e-6),x=F(v.exit()).style("opacity",1e-6).remove(),y=F(v).style("opacity",1),z,A=bw(a.range()),B=n.selectAll(".domain").data([0]),C=B.enter().append("svg:path").attr("class","domain"),D=F(B),E=this.__chart__||a;this.__chart__=a.copy(),w.append("svg:line").attr("class","tick"),w.append("svg:text"),y.select("text").text(p);switch(b){case"bottom":z=cQ,u.attr("y2",d),w.select("text").attr("dy",".71em").attr("text-anchor","middle"),y.select("line").attr("y2",c),y.select("text").attr("y",Math.max(c,0)+f),D.attr("d","M"+A[0]+","+e+"V0H"+A[1]+"V"+e);break;case"top":z=cQ,u.attr("y2",-d),w.select("text").attr("text-anchor","middle"),y.select("line").attr("y2",-c),y.select("text").attr("y",-(Math.max(c,0)+f)),D.attr("d","M"+A[0]+","+ -e+"V0H"+A[1]+"V"+ -e);break;case"left":z=cR,u.attr("x2",-d),w.select("text").attr("dy",".32em").attr("text-anchor","end"),y.select("line").attr("x2",-c),y.select("text").attr("x",-(Math.max(c,0)+f)),D.attr("d","M"+ -e+","+A[0]+"H0V"+A[1]+"H"+ -e);break;case"right":z=cR,u.attr("x2",d),w.select("text").attr("dy",".32em"),y.select("line").attr("x2",c),y.select("text").attr("x",Math.max(c,0)+f),D.attr("d","M"+e+","+A[0]+"H0V"+A[1]+"H"+e)}w.call(z,E),y.call(z,a),x.call(z,a),s.call(z,E),u.call(z,a),t.call(z,a)})}var a=d3.scale.linear(),b="bottom",c=6,d=6,e=6,f=3,g=[10],h,i=0;j.scale=function(b){if(!arguments.length)return a;a=b;return j},j.orient=function(a){if(!arguments.length)return b;b=a;return j},j.ticks=function(){if(!arguments.length)return g;g=arguments;return j},j.tickFormat=function(a){if(!arguments.length)return h;h=a;return j},j.tickSize=function(a,b,f){if(!arguments.length)return c;var g=arguments.length-1;c=+a,d=g>1?+b:c,e=g>0?+arguments[g]:c;return j},j.tickPadding=function(a){if(!arguments.length)return f;f=+a;return j},j.tickSubdivide=function(a){if(!arguments.length)return i;i=+a;return j};return j},d3.behavior={},d3.behavior.drag=function(){function d(){c.apply(this,arguments),c$("dragstart")}function c(){cT=a,cU=d3.event.target,cX=c_((cV=this).parentNode),cY=0,cW=arguments}function b(){this.on("mousedown.drag",d).on("touchstart.drag",d),d3.select(window).on("mousemove.drag",da).on("touchmove.drag",da).on("mouseup.drag",db,!0).on("touchend.drag",db,!0).on("click.drag",dc,!0)}var a=d3.dispatch("drag","dragstart","dragend");b.on=function(c,d){a[c].add(d);return b};return b};var cT,cU,cV,cW,cX,cY,cZ;d3.behavior.zoom=function(){function h(){d.apply(this,arguments);var b=dt(),c,e=Date.now();b.length===1&&e-di<300&&dy(1+Math.floor(a[2]),c=b[0],dh[c.identifier]),di=e}function g(){d.apply(this,arguments);var b=d3.svg.mouse(dm);dy(d3.event.shiftKey?Math.ceil(a[2]-1):Math.floor(a[2]+1),b,dr(b))}function f(){d.apply(this,arguments),dg||(dg=dr(d3.svg.mouse(dm))),dy(ds()+a[2],d3.svg.mouse(dm),dg)}function e(){d.apply(this,arguments),df=dr(d3.svg.mouse(dm)),dp=!1,d3.event.preventDefault(),window.focus()}function d(){dj=a,dk=b.zoom.dispatch,dl=d3.event.target,dm=this,dn=arguments}function c(){this.on("mousedown.zoom",e).on("mousewheel.zoom",f).on("DOMMouseScroll.zoom",f).on("dblclick.zoom",g).on("touchstart.zoom",h),d3.select(window).on("mousemove.zoom",dv).on("mouseup.zoom",dw).on("touchmove.zoom",du).on("touchend.zoom",dt).on("click.zoom",dx,!0)}var a=[0,0,0],b=d3.dispatch("zoom");c.on=function(a,d){b[a].add(d);return c};return c};var de,df,dg,dh={},di=0,dj,dk,dl,dm,dn,dp,dq})() <ide>\ No newline at end of file <ide><path>src/core/transition-attr.js <ide> d3_transitionPrototype.attr = function(name, value) { <ide> return this.attrTween(name, d3_transitionTween(value)); <ide> }; <ide> <del>d3_transitionPrototype.attrTween = function(name, tween) { <del> name = d3.ns.qualify(name); <add>d3_transitionPrototype.attrTween = function(nameNS, tween) { <add> var name = d3.ns.qualify(nameNS); <ide> <ide> function attrTween(d, i) { <ide> var f = tween.call(this, d, i, this.getAttribute(name)); <del> if (f === d3_transitionRemove) this.removeAttribute(name); <del> else return f && function(t) { <del> this.setAttribute(name, f(t)); <del> }; <add> return f === d3_transitionRemove ? this.removeAttribute(name) <add> : f && function(t) { this.setAttribute(name, f(t)); }; <ide> } <ide> <ide> function attrTweenNS(d, i) { <ide> var f = tween.call(this, d, i, this.getAttributeNS(name.space, name.local)); <del> return f && function(t) { <del> this.setAttributeNS(name.space, name.local, f(t)); <del> }; <add> return f === d3_transitionRemove <add> ? (this.removeAttributeNS(name.space, name.local), null) // TODO remove workaround for JSDOM <add> : f && function(t) { this.setAttributeNS(name.space, name.local, f(t)); }; <ide> } <ide> <del> return this.tween("attr." + name, name.local ? attrTweenNS : attrTween); <add> return this.tween("attr." + nameNS, name.local ? attrTweenNS : attrTween); <ide> }; <ide><path>src/core/transition-style.js <ide> d3_transitionPrototype.styleTween = function(name, tween, priority) { <ide> if (arguments.length < 3) priority = ""; <ide> return this.tween("style." + name, function(d, i) { <ide> var f = tween.call(this, d, i, window.getComputedStyle(this, null).getPropertyValue(name)); <del> if (f === d3_transitionRemove) this.style.removeProperty(name); <del> else return f && function(t) { <del> this.style.setProperty(name, f(t), priority); <del> }; <add> if (f !== d3_transitionRemove) { <add> return f && function(t) { this.style.setProperty(name, f(t), priority); }; <add> } <add> this.style.removeProperty(name); <ide> }); <ide> }; <ide><path>src/core/transition.js <ide> function d3_transition(groups, id) { <ide> var d3_transitionRemove = {}; <ide> <ide> function d3_transitionNull(d, i, a) { <del> if (a != "") return d3_transitionRemove; <add> return a != "" && d3_transitionRemove; <ide> } <ide> <ide> function d3_transitionTween(b) { <del> return typeof b === "function" <del> ? function(d, i, a) { <del> var v = b.call(this, d, i); <del> if (v == null) { <del> if (a != "") return d3_transitionRemove; <del> } else return a != v && d3.interpolate(a, v); <del> } <add> function transitionFunction(d, i, a) { <add> var v = b.call(this, d, i); <add> return v == null <add> ? a != "" && d3_transitionRemove <add> : a != v && d3.interpolate(a, v); <add> } <add> function transitionString(d, i, a) { <add> return a != b && d3.interpolate(a, b); <add> } <add> return typeof b === "function" ? transitionFunction <ide> : b == null ? d3_transitionNull <del> : (b = b + "", function(d, i, a) { return a != b && d3.interpolate(a, b); }); <add> : (b += "", transitionString); <ide> } <ide> <ide> var d3_transitionPrototype = [], <ide><path>test/core/transition-test-attr.js <ide> module.exports = { <ide> .attr("display", "none") <ide> .attr("font-size", "20px") <ide> .attr("width", 20) <del> .attr("color", "red"); <add> .attr("color", "red") <add> .attr("xlink:type", "simple") <add> .attr("xlink:href", "http://mbostock.github.com/d3/"); <ide> <ide> var t = s.transition() <ide> .attr("display", null) <ide> module.exports = { <ide> .attr("width", 100) <ide> .attr("width", 200) <ide> .attr("color", function() { return "green"; }) <add> .attr("xlink:href", null) <add> .attr("xlink:type", function() { return null; }) <ide> .each("end", function() { cb(null, {selection: s, transition: t}); }); <ide> }, <ide> "defines the corresponding attr tween": function(result) { <ide> module.exports = { <ide> }, <ide> "removes an attribute using a function null": function(result) { <ide> assert.equal(result.selection.attr("font-size"), ""); <add> }, <add> "removes a namespaced attribute using a constant null": function(result) { <add> assert.equal(result.selection.attr("xlink:href"), ""); <add> }, <add> "removes a namespaced attribute using a function null": function(result) { <add> assert.equal(result.selection.attr("xlink:type"), ""); <ide> } <ide> };
6
Ruby
Ruby
remove extraneous whitespace
51df35003c70a093691a3d6d5f29469e7292e19d
<ide><path>actionview/lib/action_view/helpers/form_helper.rb <ide> def apply_form_for_options!(record, object, options) #:nodoc: <ide> # unnecessary unless you support browsers without JavaScript. <ide> # * <tt>:local</tt> - Whether to use standard HTTP form submission. <ide> # When set to <tt>true</tt>, the form is submitted via standard HTTP. <del> # When set to <tt>false</tt>, the form is submitted as a "remote form", which <del> # is handled by Rails UJS as an XHR. When unspecified, the behavior is derived <del> # from <tt>config.action_view.form_with_generates_remote_forms</tt> where the <add> # When set to <tt>false</tt>, the form is submitted as a "remote form", which <add> # is handled by Rails UJS as an XHR. When unspecified, the behavior is derived <add> # from <tt>config.action_view.form_with_generates_remote_forms</tt> where the <ide> # config's value is actually the inverse of what <tt>local</tt>'s value would be. <ide> # As of Rails 6.1, that configuration option defaults to <tt>false</tt> <ide> # (which has the equivalent effect of passing <tt>local: true</tt>).
1
Python
Python
allow subclasses of arrays in testing
925774d3227944e80a7a01699131124dd1abfb44
<ide><path>numpy/testing/utils.py <ide> def assert_approx_equal(actual,desired,significant=7,err_msg='',verbose=True): <ide> <ide> def assert_array_compare(comparison, x, y, err_msg='', verbose=True, <ide> header=''): <del> from numpy.core import asarray, isnan, any <del> x = asarray(x) <del> y = asarray(y) <add> from numpy.core import array, isnan, any <add> x = array(x, copy=False, subok=True) <add> y = array(y, copy=False, subok=True) <ide> <ide> def isnumber(x): <ide> return x.dtype.char in '?bhilqpBHILQPfdgFDG'
1
Python
Python
fix lstm regularizers
d31fe1ac3495ff29251f65d00ab866bbf98893f2
<ide><path>keras/layers/recurrent.py <ide> def build(self, input_shape): <ide> self.W_regularizer.set_param(self.W) <ide> self.regularizers.append(self.W_regularizer) <ide> if self.U_regularizer: <del> self.W_regularizer.set_param(self.U) <add> self.U_regularizer.set_param(self.U) <ide> self.regularizers.append(self.U_regularizer) <ide> if self.b_regularizer: <del> self.W_regularizer.set_param(self.b) <add> self.b_regularizer.set_param(self.b) <ide> self.regularizers.append(self.b_regularizer) <ide> <ide> self.trainable_weights = [self.W, self.U, self.b]
1
Ruby
Ruby
add standard version setup
0e9eb11772ec74cc4b27761d4611c73b66063db5
<ide><path>lib/active_storage/gem_version.rb <add>module ActiveStorage <add> # Returns the version of the currently loaded Active Storage as a <tt>Gem::Version</tt> <add> def self.gem_version <add> Gem::Version.new VERSION::STRING <add> end <add> <add> module VERSION <add> MAJOR = 0 <add> MINOR = 1 <add> TINY = 0 <add> PRE = "alpha" <add> <add> STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".") <add> end <add>end <ide><path>lib/active_storage/version.rb <add>require_relative "gem_version" <add> <add>module ActiveStorage <add> # Returns the version of the currently loaded ActiveStorage as a <tt>Gem::Version</tt> <add> def self.version <add> gem_version <add> end <add>end
2
Ruby
Ruby
fix delivery_method usage
d0f088e7f5668cafa5c9d4090fa1f209ce0e554a
<ide><path>actionmailer/lib/action_mailer/base.rb <ide> module ActionMailer #:nodoc: <ide> # <ide> # * <tt>delivery_method</tt> - Defines a delivery method. Possible values are <tt>:smtp</tt> (default), <ide> # <tt>:sendmail</tt>, <tt>:test</tt>, and <tt>:file</tt>. Or you may provide a custom delivery method <del> # object eg. MyOwnDeliveryMethodClass.new. See the Mail gem documentation on the interface you need to <add> # object e.g. MyOwnDeliveryMethodClass (not MyOwnDeliveryMethodClass.new). See the Mail gem documentation on the interface you need to <ide> # implement for a custom delivery agent. <ide> # <ide> # * <tt>perform_deliveries</tt> - Determines whether emails are actually sent from Action Mailer when you
1
Text
Text
use svg instead of png to get better image quality
34a0d6a561d3e18e1aef8e856064dec33740120f
<ide><path>README.md <del># Ember.js [![Build Status](https://secure.travis-ci.org/emberjs/ember.js.png?branch=master)](http://travis-ci.org/emberjs/ember.js) [![Code Climate](https://codeclimate.com/github/emberjs/ember.js.png)](https://codeclimate.com/github/emberjs/ember.js) <add># Ember.js [![Build Status](https://secure.travis-ci.org/emberjs/ember.js.svg?branch=master)](http://travis-ci.org/emberjs/ember.js) [![Code Climate](https://codeclimate.com/github/emberjs/ember.js.svg)](https://codeclimate.com/github/emberjs/ember.js) <ide> <ide> Ember.js is a JavaScript framework that does all of the heavy lifting <ide> that you'd normally have to do by hand. There are tasks that are common
1
PHP
PHP
add missing type
02642e5c473cfca984956a09ba58fa39ba9b14bf
<ide><path>src/Database/Statement/SqlserverStatement.php <ide> class SqlserverStatement extends PDOStatement <ide> * <ide> * {@inheritDoc} <ide> */ <del> public function bindValue($column, $value, $type = 'string') <add> public function bindValue($column, $value, $type = 'string'): void <ide> { <ide> if ($type === null) { <ide> $type = 'string';
1
Javascript
Javascript
add dynamic injection to reacterrorutils
1c9dcd53d5a5e194afc0d953a3341ad32fe311dc
<ide><path>src/renderers/shared/utils/ReactErrorUtils.js <ide> <ide> 'use strict'; <ide> <add>const invariant = require('invariant'); <add> <ide> let caughtError = null; <ide> <ide> /** <ide> let caughtError = null; <ide> * @param {...*} args Arguments for function <ide> */ <ide> const ReactErrorUtils = { <add> injection: { <add> injectErrorUtils(injectedErrorUtils: Object) { <add> invariant( <add> typeof injectedErrorUtils.invokeGuardedCallback === 'function', <add> 'Injected invokeGuardedCallback() must be a function.', <add> ); <add> invariant( <add> typeof injectedErrorUtils.rethrowCaughtError === 'function', <add> 'Injected rethrowCaughtError() must be a function.', <add> ); <add> ReactErrorUtils.invokeGuardedCallback = injectedErrorUtils.invokeGuardedCallback; <add> ReactErrorUtils.rethrowCaughtError = injectedErrorUtils.rethrowCaughtError; <add> }, <add> }, <add> <ide> invokeGuardedCallback: function<A, B, C, D, E, F, Context>( <ide> name: string | null, <ide> func: (a: A, b: B, c: C, d: D, e: E, f: F) => void,
1
Ruby
Ruby
initialize @_virtual_path path ivar
699fb81def8f0d242962a81d2f492c6a8eed4211
<ide><path>actionpack/test/template/template_test.rb <ide> class TestERBTemplate < ActiveSupport::TestCase <ide> class Context <ide> def initialize <ide> @output_buffer = "original" <add> @_virtual_path = nil <ide> end <ide> <ide> def hello
1
Javascript
Javascript
fix bug 2
3c9c090fedcbf6761df7d940cfd2ba3b0ecd4990
<ide><path>src/math/Box3.js <ide> Object.assign( Box3.prototype, { <ide> <ide> } <ide> <del> return ( min <= -plane.constant && max >= -plane.constant ); <add> return ( min <= - plane.constant && max >= - plane.constant ); <ide> <ide> }, <ide>
1
Ruby
Ruby
explain what initializer/config_serializer does
7e21a7d9d4e89feac0cf896ade9ed13e3a51e810
<ide><path>railties/lib/rails/generators/rails/app/templates/config/initializers/cookies_serializer.rb <ide> # Be sure to restart your server when you modify this file. <ide> <add># Specify a serializer for the signed and encrypted cookie jars. <add># Valid options are :json, :marshal, and :hybrid. <ide> Rails.application.config.action_dispatch.cookies_serializer = :json
1
PHP
PHP
fix deprecation warnings in test suite
044a5628b254e72c33dfe9fdb2e1759fd396b84c
<ide><path>tests/test_app/TestApp/Controller/PostsController.php <ide> class PostsController extends AppController <ide> */ <ide> public $components = [ <ide> 'Flash', <del> 'RequestHandler', <add> 'RequestHandler' => [ <add> 'enableBeforeRedirect' => false <add> ], <ide> 'Security', <ide> ]; <ide> <ide><path>tests/test_app/TestApp/Controller/TestsAppsController.php <ide> <ide> class TestsAppsController extends AppController <ide> { <del> public $components = ['RequestHandler']; <add> public $components = [ <add> 'RequestHandler' => [ <add> 'enableBeforeRedirect' => false <add> ] <add> ]; <ide> <ide> public function index() <ide> {
2
Python
Python
add regression test for
b62739fbfe18c885a0172c8371b89a4010b086fb
<ide><path>spacy/tests/regression/test_issue1654.py <add># coding: utf8 <add>from __future__ import unicode_literals <add> <add>import pytest <add> <add>from ...language import Language <add>from ...vocab import Vocab <add> <add> <add>@pytest.mark.xfail <add>def test_issue1654(): <add> nlp = Language(Vocab()) <add> assert not nlp.pipeline <add> nlp.add_pipe(lambda doc: doc, name='1') <add> nlp.add_pipe(lambda doc: doc, name='2', after='1') <add> nlp.add_pipe(lambda doc: doc, name='3', after='2') <add> assert nlp.pipe_names == ['1', '2', '3']
1
Python
Python
improve modelserializer.create() error message.
2fab7838ef79c2b9c6f67d930ab2e28aa392f516
<ide><path>rest_framework/serializers.py <ide> def create(self, validated_data): <ide> except TypeError: <ide> tb = traceback.format_exc() <ide> msg = ( <del> 'Got a `TypeError` when calling `%s._default_manager.create()`. ' <add> 'Got a `TypeError` when calling `%s.%s.create()`. ' <ide> 'This may be because you have a writable field on the ' <ide> 'serializer class that is not a valid argument to ' <del> '`%s._default_manager.create()`. You may need to make the field ' <add> '`%s.%s.create()`. You may need to make the field ' <ide> 'read-only, or override the %s.create() method to handle ' <ide> 'this correctly.\nOriginal exception was:\n %s' % <ide> ( <ide> ModelClass.__name__, <add> ModelClass._default_manager.name, <ide> ModelClass.__name__, <add> ModelClass._default_manager.name, <ide> self.__class__.__name__, <ide> tb <ide> ) <ide><path>tests/test_model_serializer.py <ide> class Issue3674ChildModel(models.Model): <ide> value = models.CharField(primary_key=True, max_length=64) <ide> <ide> <del>class Issue6110TestModel(models.Model): <del> """Model without .objects manager.""" <del> <del> name = models.CharField(max_length=64) <del> all_objects = models.Manager() <del> <del> <ide> class UniqueChoiceModel(models.Model): <ide> CHOICES = ( <ide> ('choice1', 'choice 1'), <ide> class Meta: <ide> }) <ide> serializer.is_valid() <ide> <del> msginitial = 'Got a `TypeError` when calling `OneFieldModel._default_manager.create()`.' <add> msginitial = 'Got a `TypeError` when calling `OneFieldModel.objects.create()`.' <ide> with self.assertRaisesMessage(TypeError, msginitial): <ide> serializer.save() <ide> <ide> class Meta: <ide> self.assertEqual(unicode_repr(TestSerializer()), expected) <ide> <ide> <del>class Issue6110Test(TestCase): <del> def test_model_serializer_custom_manager(self): <add>class Issue6110TestModel(models.Model): <add> """Model without .objects manager.""" <ide> <del> class TestModelSerializer(serializers.ModelSerializer): <del> class Meta: <del> model = Issue6110TestModel <del> fields = ('name',) <add> name = models.CharField(max_length=64) <add> all_objects = models.Manager() <add> <add> <add>class Issue6110ModelSerializer(serializers.ModelSerializer): <add> class Meta: <add> model = Issue6110TestModel <add> fields = ('name',) <ide> <del> instance = TestModelSerializer().create({'name': 'test_name'}) <add> <add>class Issue6110Test(TestCase): <add> <add> def test_model_serializer_custom_manager(self): <add> instance = Issue6110ModelSerializer().create({'name': 'test_name'}) <ide> self.assertEqual(instance.name, 'test_name') <add> <add> def test_model_serializer_custom_manager_error_message(self): <add> msginitial = ('Got a `TypeError` when calling `Issue6110TestModel.all_objects.create()`.') <add> with self.assertRaisesMessage(TypeError, msginitial): <add> Issue6110ModelSerializer().create({'wrong_param': 'wrong_param'})
2
Mixed
Ruby
add support for postgresql jsonb
99b82fdf03fcf6d6ca8e2d810ba35011723a5267
<ide><path>activerecord/CHANGELOG.md <add>* Add support for Postgresql JSONB <add> <add> Example: <add> <add> create_table :posts do |t| <add> t.jsonb :meta_data <add> end <add> <add> *Philippe Creux*, *Chris Teague* <add> <ide> * `db:purge` with MySQL respects `Rails.env`. <ide> <ide> *Yves Senn* <ide><path>activerecord/lib/active_record/connection_adapters/postgresql/oid.rb <ide> require 'active_record/connection_adapters/postgresql/oid/inet' <ide> require 'active_record/connection_adapters/postgresql/oid/integer' <ide> require 'active_record/connection_adapters/postgresql/oid/json' <add>require 'active_record/connection_adapters/postgresql/oid/jsonb' <ide> require 'active_record/connection_adapters/postgresql/oid/money' <ide> require 'active_record/connection_adapters/postgresql/oid/point' <ide> require 'active_record/connection_adapters/postgresql/oid/range' <ide><path>activerecord/lib/active_record/connection_adapters/postgresql/oid/jsonb.rb <add>module ActiveRecord <add> module ConnectionAdapters <add> module PostgreSQL <add> module OID # :nodoc: <add> class Jsonb < Json # :nodoc: <add> def type <add> :jsonb <add> end <add> <add> def changed_in_place?(raw_old_value, new_value) <add> # Postgres does not preserve insignificant whitespaces when <add> # roundtripping jsonb columns. This causes some false positives for <add> # the comparison here. Therefore, we need to parse and re-dump the <add> # raw value here to ensure the insignificant whitespaces are <add> # consitent with our encoder's output. <add> raw_old_value = type_cast_for_database(type_cast_from_database(raw_old_value)) <add> super(raw_old_value, new_value) <add> end <add> end <add> end <add> end <add> end <add>end <ide><path>activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb <ide> def json(name, options = {}) <ide> column(name, :json, options) <ide> end <ide> <add> def jsonb(name, options = {}) <add> column(name, :jsonb, options) <add> end <add> <ide> def citext(name, options = {}) <ide> column(name, :citext, options) <ide> end <ide><path>activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb <ide> def initialize_type_map(m) # :nodoc: <ide> m.register_type 'point', OID::Point.new <ide> m.register_type 'hstore', OID::Hstore.new <ide> m.register_type 'json', OID::Json.new <add> m.register_type 'jsonb', OID::Jsonb.new <ide> m.register_type 'cidr', OID::Cidr.new <ide> m.register_type 'inet', OID::Inet.new <ide> m.register_type 'uuid', OID::Uuid.new <ide><path>activerecord/test/cases/adapters/postgresql/json_test.rb <ide> require 'active_record/base' <ide> require 'active_record/connection_adapters/postgresql_adapter' <ide> <del>class PostgresqlJSONTest < ActiveRecord::TestCase <add>module PostgresqlJSONSharedTestCases <ide> class JsonDataType < ActiveRecord::Base <ide> self.table_name = 'json_data_type' <ide> <ide> def setup <ide> begin <ide> @connection.transaction do <ide> @connection.create_table('json_data_type') do |t| <del> t.json 'payload', :default => {} <del> t.json 'settings' <add> t.public_send column_type, 'payload', default: {} # t.json 'payload', default: {} <add> t.public_send column_type, 'settings' # t.json 'settings' <ide> end <ide> end <ide> rescue ActiveRecord::StatementInvalid <ide> def setup <ide> @column = JsonDataType.columns_hash['payload'] <ide> end <ide> <del> teardown do <add> def teardown <ide> @connection.execute 'drop table if exists json_data_type' <ide> end <ide> <ide> def test_column <ide> column = JsonDataType.columns_hash["payload"] <del> assert_equal :json, column.type <del> assert_equal "json", column.sql_type <add> assert_equal column_type, column.type <add> assert_equal column_type.to_s, column.sql_type <ide> assert_not column.number? <ide> assert_not column.binary? <ide> assert_not column.array <ide> end <ide> <ide> def test_default <del> @connection.add_column 'json_data_type', 'permissions', :json, default: '{"users": "read", "posts": ["read", "write"]}' <add> @connection.add_column 'json_data_type', 'permissions', column_type, default: '{"users": "read", "posts": ["read", "write"]}' <ide> JsonDataType.reset_column_information <ide> <ide> assert_equal({"users"=>"read", "posts"=>["read", "write"]}, JsonDataType.column_defaults['permissions']) <ide> def test_default <ide> def test_change_table_supports_json <ide> @connection.transaction do <ide> @connection.change_table('json_data_type') do |t| <del> t.json 'users', default: '{}' <add> t.public_send column_type, 'users', default: '{}' # t.json 'users', default: '{}' <ide> end <ide> JsonDataType.reset_column_information <ide> column = JsonDataType.columns_hash['users'] <del> assert_equal :json, column.type <add> assert_equal column_type, column.type <ide> <ide> raise ActiveRecord::Rollback # reset the schema change <ide> end <ide> def test_changes_in_place <ide> assert_not json.changed? <ide> end <ide> end <add> <add>class PostgresqlJSONTest < ActiveRecord::TestCase <add> include PostgresqlJSONSharedTestCases <add> <add> def column_type <add> :json <add> end <add>end <add> <add>class PostgresqlJSONBTest < ActiveRecord::TestCase <add> include PostgresqlJSONSharedTestCases <add> <add> def column_type <add> :jsonb <add> end <add>end
6
Text
Text
add missing meta for createcipheriv
95a35bcf0680367d4d7ae6a8a56f2b0a20f12053
<ide><path>doc/api/crypto.md <ide> vulnerabilities. For the case when IV is reused in GCM, see [Nonce-Disrespecting <ide> Adversaries][] for details. <ide> <ide> ### crypto.createCipheriv(algorithm, key, iv[, options]) <add><!-- YAML <add>added: v0.1.94 <add>--> <ide> - `algorithm` {string} <ide> - `key` {string | Buffer | TypedArray | DataView} <ide> - `iv` {string | Buffer | TypedArray | DataView}
1
Javascript
Javascript
fix typo in destroy-test.js
c4d185ddd778effc3f43f7f20f8ff49eb26bb1a8
<ide><path>packages/ember-glimmer/tests/integration/components/destroy-test.js <ide> moduleFor('Component destroy', class extends RenderingTest { <ide> <ide> this.assertText(''); <ide> <del> assert.equal(this.env.destroyedComponents.length, 0, 'enviroment.destroyedComponents should be empty'); <add> assert.equal(this.env.destroyedComponents.length, 0, 'environment.destroyedComponents should be empty'); <ide> } <ide> });
1
Javascript
Javascript
enable mmdloader to support more various models
086eab8ccd0b0d178a3d0817d92132fe1c4dfd64
<ide><path>examples/js/loaders/MMDLoader.js <ide> THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress <ide> <ide> } <ide> <del> var isSphericalReflectionMapping = params.sphericalReflectionMapping; <ide> var texture = loader.load( fullPath, function ( t ) { <ide> <ide> t.flipY = false; <ide> t.wrapS = THREE.RepeatWrapping; <ide> t.wrapT = THREE.RepeatWrapping; <ide> <del> if ( isSphericalReflectionMapping === true ) { <add> if ( params.sphericalReflectionMapping === true ) { <ide> <ide> t.mapping = THREE.SphericalReflectionMapping; <ide> <ide> } <ide> <add> for ( var i = 0; i < texture.readyCallbacks.length; i++ ) { <add> <add> texture.readyCallbacks[ i ]( texture ); <add> <add> } <add> <ide> } ); <ide> <add> texture.readyCallbacks = []; <add> <ide> var uuid = THREE.Math.generateUUID(); <ide> <ide> textures[ uuid ] = texture; <ide> THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress <ide> <ide> }; <ide> <add> params.faceOffset = offset; <add> params.faceNum = m.faceCount; <add> <ide> for ( var j = 0; j < m.faceCount; j++ ) { <ide> <ide> geometry.faces[ offset ].materialIndex = i; <ide> THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress <ide> params.specular = color.fromArray( [ m.specular[ 0 ], m.specular[ 1 ], m.specular[ 2 ] ] ).getHex(); <ide> params.shininess = m.shininess; <ide> <del> // Note: always transparent so far. <del> //if ( params.opacity < 1 ) { <add> if ( params.opacity === 1.0 ) { <add> <add> params.side = THREE.FrontSide; <add> params.transparent = false; <ide> <add> } else { <add> <add> params.side = THREE.DoubleSide; <ide> params.transparent = true; <ide> <del> //} <add> } <ide> <ide> if ( model.metadata.format === 'pmd' ) { <ide> <ide> THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress <ide> <ide> } <ide> <del> if ( params.map === undefined ) { <add> // TODO: check if this logic is right <add> if ( params.map === undefined /* && params.envMap === undefined */ ) { <ide> <ide> params.emissive = color.fromArray( [ m.emissive[ 0 ], m.emissive[ 1 ], m.emissive[ 2 ] ] ).getHex(); <ide> <ide> THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress <ide> var p2 = model.materials[ i ]; <ide> var m = materialLoader.parse( p ); <ide> <del> m.skinning = true; <del> m.morphTargets = true; <add> m.faceOffset = p.faceOffset; <add> m.faceNum = p.faceNum; <add> <add> m.skinning = geometry.bones.length > 0 ? true : false; <add> m.morphTargets = geometry.morphTargets.length > 0 ? true : false; <ide> m.lights = true; <ide> <ide> m.blending = THREE.CustomBlending; <ide> THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress <ide> m.blendSrcAlpha = THREE.SrcAlphaFactor; <ide> m.blendDstAlpha = THREE.DstAlphaFactor; <ide> <del> if ( p.envMap !== undefined ) { <add> if ( m.map !== null ) { <add> <add> function checkTextureTransparency ( m ) { <add> <add> m.map.readyCallbacks.push( function ( t ) { <add> <add> // Is there any efficient ways? <add> function createImageData ( image ) { <add> <add> var c = document.createElement( 'canvas' ); <add> c.width = image.width; <add> c.height = image.height; <add> <add> var ctx = c.getContext( '2d' ); <add> ctx.drawImage( image, 0, 0 ); <add> <add> return ctx.getImageData( 0, 0, c.width, c.height ); <add> <add> }; <add> <add> function detectTextureTransparency ( image, uvs ) { <add> <add> var width = image.width; <add> var height = image.height; <add> var data = image.data; <add> var threshold = 253; <add> <add> if ( data.length / ( width * height ) !== 4 ) { <add> <add> return false; <add> <add> } <add> <add> for ( var i = 0; i < uvs.length; i++ ) { <add> <add> var centerUV = { x: 0.0, y: 0.0 }; <add> <add> for ( var j = 0; j < 3; j++ ) { <add> <add> var uv = uvs[ i ][ j ]; <add> <add> if ( getAlphaByUv( image, uv ) < threshold ) { <add> <add> return true; <add> <add> } <add> <add> centerUV.x += uv.x; <add> centerUV.y += uv.y; <add> <add> } <add> <add> centerUV.x /= 3; <add> centerUV.y /= 3; <add> <add> <add> if ( getAlphaByUv( image, centerUV ) < threshold ) { <add> <add> return true; <add> <add> } <add> <add> } <add> <add> return false; <add> <add> }; <add> <add> /* <add> * This method expects <add> * t.flipY = false <add> * t.wrapS = THREE.RepeatWrapping <add> * t.wrapT = THREE.RepeatWrapping <add> * TODO: more precise <add> */ <add> function getAlphaByUv ( image, uv ) { <add> <add> var width = image.width; <add> var height = image.height; <add> <add> var x = Math.round( uv.x * width ) % width; <add> var y = Math.round( uv.y * height ) % height; <add> <add> if ( x < 0 ) { <add> <add> x += width; <add> <add> } <add> <add> if ( y < 0 ) { <add> <add> y += height; <add> <add> } <add> <add> var index = y * width + x; <add> <add> return image.data[ index * 4 + 3 ]; <add> <add> }; <add> <add> var imageData = t.image.data !== undefined ? t.image : createImageData( t.image ); <add> var uvs = geometry.faceVertexUvs[ 0 ].slice( m.faceOffset, m.faceOffset + m.faceNum ); <add> <add> m.textureTransparency = detectTextureTransparency( imageData, uvs ); <add> <add> } ); <add> <add> } <add> <add> checkTextureTransparency( m ); <add> <add> } <add> <add> if ( m.envMap !== null ) { <add> <add> // TODO: WebGLRenderer should automatically update? <add> function updateMaterialWhenTextureIsReady ( m ) { <add> <add> m.envMap.readyCallbacks.push( function ( t ) { <add> <add> m.needsUpdate = true; <add> <add> } ); <add> <add> } <ide> <ide> m.combine = p.envMapType; <add> updateMaterialWhenTextureIsReady( m ); <ide> <ide> } <ide> <ide> THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress <ide> m.uniforms.toonMap.value = textures[ p2.toonIndex ]; <ide> m.uniforms.celShading.value = 1; <ide> <del> // temporal workaround <del> // TODO: handle correctly <del> var n = model.toonTextures[ p2.toonIndex === -1 ? 0 : p2.toonIndex ].fileName; <del> var uuid = loadTexture( n, { defaultTexturePath: isDefaultToonTexture( n ) } ); <del> m.uniforms.toonMap.value = textures[ uuid ]; <add> if ( p2.toonIndex === -1 ) { <add> <add> m.uniforms.hasToonTexture.value = 0; <add> <add> } else { <add> <add> var n = model.toonTextures[ p2.toonIndex ].fileName; <add> var uuid = loadTexture( n, { defaultTexturePath: isDefaultToonTexture( n ) } ); <add> m.uniforms.toonMap.value = textures[ uuid ]; <add> m.uniforms.hasToonTexture.value = 1; <add> } <ide> <ide> } else { <ide> <ide> THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress <ide> m.uniforms.outlineAlpha.value = p2.edgeColor[ 3 ]; <ide> m.uniforms.celShading.value = 1; <ide> <del> // temporal workaround <del> // TODO: handle correctly <del> var index = p2.toonIndex === -1 ? -1 : p2.toonIndex; <del> var flag = p2.toonIndex === -1 ? 1 : p2.toonFlag; <add> if ( p2.toonIndex === -1 ) { <ide> <del> if ( flag === 0 ) { <del> <del> var n = model.textures[ index ]; <del> var uuid = loadTexture( n ); <del> m.uniforms.toonMap.value = textures[ uuid ]; <add> m.uniforms.hasToonTexture.value = 0; <ide> <ide> } else { <ide> <del> var num = index + 1; <del> var fileName = 'toon' + ( num < 10 ? '0' + num : num ) + '.bmp'; <del> var uuid = loadTexture( fileName, { defaultTexturePath: true } ); <del> m.uniforms.toonMap.value = textures[ uuid ]; <add> if ( p2.toonFlag === 0 ) { <add> <add> var n = model.textures[ p2.toonIndex ]; <add> var uuid = loadTexture( n ); <add> m.uniforms.toonMap.value = textures[ uuid ]; <add> <add> } else { <add> <add> var num = p2.toonIndex + 1; <add> var fileName = 'toon' + ( num < 10 ? '0' + num : num ) + '.bmp'; <add> var uuid = loadTexture( fileName, { defaultTexturePath: true } ); <add> m.uniforms.toonMap.value = textures[ uuid ]; <add> <add> } <add> <add> m.uniforms.hasToonTexture.value = 1; <ide> <ide> } <ide> <ide> THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress <ide> <ide> } <ide> <add> if ( model.metadata.format === 'pmx' ) { <add> <add> function checkAlphaMorph ( morph, elements ) { <add> <add> if ( morph.type !== 8 ) { <add> <add> return; <add> <add> } <add> <add> for ( var i = 0; i < elements.length; i++ ) { <add> <add> var e = elements[ i ]; <add> <add> if ( e.index === -1 ) { <add> <add> continue; <add> <add> } <add> <add> var m = material.materials[ e.index ]; <add> <add> if ( m.opacity !== e.diffuse[ 3 ] ) { <add> <add> m.morphTransparency = true; <add> <add> } <add> <add> } <add> <add> } <add> <add> for ( var i = 0; i < model.morphs.length; i++ ) { <add> <add> var morph = model.morphs[ i ]; <add> var elements = morph.elements; <add> <add> if ( morph.type === 0 ) { <add> <add> for ( var j = 0; j < elements.length; j++ ) { <add> <add> var morph2 = model.morphs[ elements[ j ].index ]; <add> var elements2 = morph2.elements; <add> <add> checkAlphaMorph( morph2, elements2 ); <add> <add> } <add> <add> } else { <add> <add> checkAlphaMorph( morph, elements ); <add> <add> } <add> <add> } <add> <add> } <add> <ide> }; <ide> <ide> var initPhysics = function () { <ide> THREE.MMDMaterial = function ( parameters ) { <ide> <ide> // this.type = 'MMDMaterial'; <ide> <add> this.faceOffset = null; <add> this.faceNum = null; <add> this.textureTransparency = false; <add> this.morphTransparency = false; <add> <ide> // the followings are copied from MeshPhongMaterial <ide> this.color = new THREE.Color( 0xffffff ); // diffuse <ide> this.emissive = new THREE.Color( 0x000000 ); <ide> THREE.ShaderLib[ 'mmd' ] = { <ide> "outlineColor" : { type: "c", value: new THREE.Color( 0x000000 ) }, <ide> "outlineAlpha" : { type: "f", value: 1.0 }, <ide> "celShading" : { type: "i", value: 0 }, <del> "toonMap" : { type: "t", value: null } <add> "toonMap" : { type: "t", value: null }, <add> "hasToonTexture" : { type: "i", value: 0 } <ide> } <ide> // ---- MMD specific for cel shading(outline drawing and toon mapping) <ide> <ide> THREE.ShaderLib[ 'mmd' ] = { <ide> " uniform float outlineAlpha;", <ide> " uniform bool celShading;", <ide> " uniform sampler2D toonMap;", <add> " uniform bool hasToonTexture;", <ide> <ide> " vec3 toon ( vec3 lightDirection, vec3 norm ) {", <add> " if ( ! hasToonTexture ) {", <add> " return vec3( 1.0 );", <add> " }", <ide> " vec2 coord = vec2( 0.0, 0.5 * ( 1.0 - dot( lightDirection, norm ) ) );", <ide> " return texture2D( toonMap, coord ).rgb;", <ide> " }", <ide> THREE.MMDHelper.prototype = { <ide> <ide> var m = mesh.material.materials[ i ]; <ide> m.uniforms.outlineDrawing.value = 0; <del> m.side = THREE.DoubleSide; <add> m.visible = true; <add> <add> if ( m.opacity === 1.0 ) { <add> <add> m.side = THREE.FrontSide; <add> m.transparent = false; <add> <add> } else { <add> <add> m.side = THREE.DoubleSide; <add> m.transparent = true; <add> <add> } <add> <add> if ( m.textureTransparency === true || m.morphTransparency === true ) { <add> <add> m.transparent = true; <add> <add> } <ide> <ide> } <ide> <ide> THREE.MMDHelper.prototype = { <ide> <ide> } <ide> <del> this.renderer.state.setBlending( THREE.NoBlending ); <del> <ide> }, <ide> <ide> setupOutlineRenderingOneMesh: function ( mesh ) { <ide> THREE.MMDHelper.prototype = { <ide> m.uniforms.outlineDrawing.value = 1; <ide> m.side = THREE.BackSide; <ide> <add> if ( m.uniforms.outlineAlpha.value < 1.0 ) { <add> <add> m.transparent = true; <add> <add> } <add> <add> if ( m.uniforms.outlineThickness.value === 0.0 ) { <add> <add> m.visible = false; <add> <add> } <add> <ide> } <ide> <ide> },
1
Go
Go
skip further checks for quota in user namespaces
7e35df0e0484118740dbf01e7db9b482a1827ef1
<ide><path>daemon/graphdriver/quota/projectquota.go <ide> import ( <ide> "path/filepath" <ide> "unsafe" <ide> <add> rsystem "github.com/opencontainers/runc/libcontainer/system" <ide> "github.com/sirupsen/logrus" <ide> "golang.org/x/sys/unix" <ide> ) <ide> type Control struct { <ide> // project ids. <ide> // <ide> func NewControl(basePath string) (*Control, error) { <add> // <add> // If we are running in a user namespace quota won't be supported for <add> // now since makeBackingFsDev() will try to mknod(). <add> // <add> if rsystem.RunningInUserNS() { <add> return nil, ErrQuotaNotSupported <add> } <add> <ide> // <ide> // create backing filesystem device node <ide> //
1
PHP
PHP
ensure empty body for 304 response
4cf876aba76cae25e68b75fc3e362df17d9fde19
<ide><path>src/Routing/Middleware/AssetMiddleware.php <ide> public function __invoke(ServerRequestInterface $request, Response $response, ca <ide> $modifiedTime = $file->getMTime(); <ide> if ($this->isNotModified($request, $file)) { <ide> return $response <add> ->withStringBody('') <ide> ->withStatus(304) <ide> ->withHeader( <ide> 'Last-Modified',
1
Javascript
Javascript
fix duplicate logic in stream destroy
4d5444981afa7b8579a557be0bf85a79a21a37d5
<ide><path>lib/internal/streams/destroy.js <ide> const { Symbol } = primordials; <ide> const kDestroy = Symbol('kDestroy'); <ide> const kConstruct = Symbol('kConstruct'); <ide> <add>function checkError(err, w, r) { <add> if (err) { <add> // Avoid V8 leak, https://github.com/nodejs/node/pull/34103#issuecomment-652002364 <add> err.stack; <add> <add> if (w && !w.errored) { <add> w.errored = err; <add> } <add> if (r && !r.errored) { <add> r.errored = err; <add> } <add> } <add>} <add> <ide> // Backwards compat. cb() is undocumented and unused in core but <ide> // unfortunately might be used by modules. <ide> function destroy(err, cb) { <ide> function destroy(err, cb) { <ide> return this; <ide> } <ide> <del> if (err) { <del> // Avoid V8 leak, https://github.com/nodejs/node/pull/34103#issuecomment-652002364 <del> err.stack; <del> <del> if (w && !w.errored) { <del> w.errored = err; <del> } <del> if (r && !r.errored) { <del> r.errored = err; <del> } <del> } <ide> <ide> // We set destroyed to true before firing error callbacks in order <ide> // to make it re-entrance safe in case destroy() is called within callbacks <add> checkError(err, w, r); <ide> <ide> if (w) { <ide> w.destroyed = true; <ide> function _destroy(self, err, cb) { <ide> <ide> called = true; <ide> <del> if (err) { <del> // Avoid V8 leak, https://github.com/nodejs/node/pull/34103#issuecomment-652002364 <del> err.stack; <del> <del> if (w && !w.errored) { <del> w.errored = err; <del> } <del> if (r && !r.errored) { <del> r.errored = err; <del> } <del> } <add> checkError(err, w, r); <ide> <ide> if (w) { <ide> w.closed = true;
1
Javascript
Javascript
update example to use a module
d35f50ee11af5d20518a62c750753da9c7c7a8dc
<ide><path>src/ng/interval.js <ide> function $IntervalProvider() { <ide> * @returns {promise} A promise which will be notified on each iteration. <ide> * <ide> * @example <del> * <example module="time"> <del> * <file name="index.html"> <del> * <script> <del> * function Ctrl2($scope,$interval) { <del> * $scope.format = 'M/d/yy h:mm:ss a'; <del> * $scope.blood_1 = 100; <del> * $scope.blood_2 = 120; <del> * <del> * var stop; <del> * $scope.fight = function() { <del> * // Don't start a new fight if we are already fighting <del> * if ( angular.isDefined(stop) ) return; <add> * <example module="intervalExample"> <add> * <file name="index.html"> <add> * <script> <add> * angular.module('intervalExample', []) <add> * .controller('ExampleController', ['$scope', '$interval', <add> * function($scope, $interval) { <add> * $scope.format = 'M/d/yy h:mm:ss a'; <add> * $scope.blood_1 = 100; <add> * $scope.blood_2 = 120; <add> * <add> * var stop; <add> * $scope.fight = function() { <add> * // Don't start a new fight if we are already fighting <add> * if ( angular.isDefined(stop) ) return; <ide> * <ide> * stop = $interval(function() { <ide> * if ($scope.blood_1 > 0 && $scope.blood_2 > 0) { <del> * $scope.blood_1 = $scope.blood_1 - 3; <del> * $scope.blood_2 = $scope.blood_2 - 4; <add> * $scope.blood_1 = $scope.blood_1 - 3; <add> * $scope.blood_2 = $scope.blood_2 - 4; <ide> * } else { <del> * $scope.stopFight(); <add> * $scope.stopFight(); <ide> * } <ide> * }, 100); <ide> * }; <ide> function $IntervalProvider() { <ide> * $scope.resetFight = function() { <ide> * $scope.blood_1 = 100; <ide> * $scope.blood_2 = 120; <del> * } <add> * }; <ide> * <ide> * $scope.$on('$destroy', function() { <del> * // Make sure that the interval is destroyed too <add> * // Make sure that the interval nis destroyed too <ide> * $scope.stopFight(); <ide> * }); <del> * } <del> * <del> * angular.module('time', []) <del> * // Register the 'myCurrentTime' directive factory method. <del> * // We inject $interval and dateFilter service since the factory method is DI. <del> * .directive('myCurrentTime', function($interval, dateFilter) { <add> * }) <add> * // Register the 'myCurrentTime' directive factory method. <add> * // We inject $interval and dateFilter service since the factory method is DI. <add> * .directive('myCurrentTime', ['$interval', 'dateFilter', <add> * function($interval, dateFilter) { <ide> * // return the directive link function. (compile function not needed) <ide> * return function(scope, element, attrs) { <ide> * var format, // date format <del> * stopTime; // so that we can cancel the time updates <add> * stopTime; // so that we can cancel the time updates <ide> * <ide> * // used to update the UI <ide> * function updateTime() { <ide> function $IntervalProvider() { <ide> * stopTime = $interval(updateTime, 1000); <ide> * <ide> * // listen on DOM destroy (removal) event, and cancel the next UI update <del> * // to prevent updating time ofter the DOM element was removed. <add> * // to prevent updating time after the DOM element was removed. <ide> * element.on('$destroy', function() { <ide> * $interval.cancel(stopTime); <ide> * }); <ide> * } <ide> * }); <del> * </script> <del> * <del> * <div> <del> * <div ng-controller="Ctrl2"> <del> * Date format: <input ng-model="format"> <hr/> <del> * Current time is: <span my-current-time="format"></span> <del> * <hr/> <del> * Blood 1 : <font color='red'>{{blood_1}}</font> <del> * Blood 2 : <font color='red'>{{blood_2}}</font> <del> * <button type="button" data-ng-click="fight()">Fight</button> <del> * <button type="button" data-ng-click="stopFight()">StopFight</button> <del> * <button type="button" data-ng-click="resetFight()">resetFight</button> <del> * </div> <add> * </script> <add> * <add> * <div> <add> * <div ng-controller="ExampleController"> <add> * Date format: <input ng-model="format"> <hr/> <add> * Current time is: <span my-current-time="format"></span> <add> * <hr/> <add> * Blood 1 : <font color='red'>{{blood_1}}</font> <add> * Blood 2 : <font color='red'>{{blood_2}}</font> <add> * <button type="button" data-ng-click="fight()">Fight</button> <add> * <button type="button" data-ng-click="stopFight()">StopFight</button> <add> * <button type="button" data-ng-click="resetFight()">resetFight</button> <ide> * </div> <add> * </div> <ide> * <del> * </file> <add> * </file> <ide> * </example> <ide> */ <ide> function interval(fn, delay, count, invokeApply) {
1
Mixed
PHP
fix tests and cons
fb546f8d67a610381ba5ccea6bf873d75d363805
<ide><path>CHANGELOG.md <ide> ## v5.2.33 (2016-05-25) <ide> <ide> ### Added <del>- Allow query results to be traverse their via cursor ([#13030](https://github.com/laravel/framework/pull/13030)) <add>- Allow query results to be traversed using a cursor ([#13030](https://github.com/laravel/framework/pull/13030)) <ide> - Added support for log levels ([#13513](https://github.com/laravel/framework/pull/13513)) <ide> - Added `inRandomOrder()` method to query builder ([#13642](https://github.com/laravel/framework/pull/13642)) <ide> - Added support for custom connection in `PasswordBrokerManager` ([#13646](https://github.com/laravel/framework/pull/13646)) <ide><path>src/Illuminate/Cache/RedisTaggedCache.php <ide> class RedisTaggedCache extends TaggedCache <ide> * <ide> * @var string <ide> */ <del> const REFERENCE_KEY_FOREVER = 'forever'; <add> const REFERENCE_KEY_FOREVER = 'forever_ref'; <ide> /** <ide> * Standard reference key. <ide> * <ide> * @var string <ide> */ <del> const REFERENCE_KEY_STANDARD = 'standard'; <add> const REFERENCE_KEY_STANDARD = 'standard_ref'; <ide> <ide> /** <ide> * Store an item in the cache. <ide><path>src/Illuminate/Database/Eloquent/Builder.php <ide> protected function isNested($name, $relation) <ide> return $dots && Str::startsWith($name, $relation.'.'); <ide> } <ide> <add> /** <add> * Apply the callback's query changes if the given "value" is true. <add> * <add> * @param bool $value <add> * @param \Closure $callback <add> * @return $this <add> */ <add> public function when($value, $callback) <add> { <add> $builder = $this; <add> <add> if ($value) { <add> $builder = call_user_func($callback, $builder); <add> } <add> <add> return $builder; <add> } <add> <ide> /** <ide> * Add a basic where clause to the query. <ide> * <ide><path>src/Illuminate/Database/Eloquent/Relations/MorphTo.php <ide> class MorphTo extends BelongsTo <ide> */ <ide> protected $dictionary = []; <ide> <del> /* <del> * Indicates if soft-deleted model instances should be fetched. <del> * <del> * @var bool <del> */ <del> protected $withTrashed = false; <del> <ide> /** <ide> * Create a new morph to relationship instance. <ide> * <ide> protected function getResultsByType($type) <ide> <ide> $key = $instance->getTable().'.'.$instance->getKeyName(); <ide> <del> $query = $instance->newQuery(); <del> <del> $query = $this->useWithTrashed($query); <add> $query = clone $this->query; <add> $query->setModel($instance); <ide> <ide> return $query->whereIn($key, $this->gatherKeysByType($type)->all())->get(); <ide> } <ide> public function getDictionary() <ide> { <ide> return $this->dictionary; <ide> } <del> <del> /** <del> * Fetch soft-deleted model instances with query. <del> * <del> * @return $this <del> */ <del> public function withTrashed() <del> { <del> $this->withTrashed = true; <del> <del> $this->query = $this->useWithTrashed($this->query); <del> <del> return $this; <del> } <del> <del> /** <del> * Return trashed models with query if told so. <del> * <del> * @param \Illuminate\Database\Eloquent\Builder $query <del> * @return \Illuminate\Database\Eloquent\Builder <del> */ <del> protected function useWithTrashed(Builder $query) <del> { <del> if ($this->withTrashed && $query->getMacro('withTrashed') !== null) { <del> return $query->withTrashed(); <del> } <del> <del> return $query; <del> } <ide> } <ide><path>src/Illuminate/Database/Query/Builder.php <ide> public function where($column, $operator = null, $value = null, $boolean = 'and' <ide> // will be bound to each SQL statements when it is finally executed. <ide> $type = 'Basic'; <ide> <add> if (Str::contains($column, '->') && is_bool($value)) { <add> $value = new Expression($value ? 'true' : 'false'); <add> } <add> <ide> $this->wheres[] = compact('type', 'column', 'operator', 'value', 'boolean'); <ide> <ide> if (! $value instanceof Expression) { <ide><path>src/Illuminate/Database/Query/Grammars/MySqlGrammar.php <ide> <ide> use Illuminate\Support\Str; <ide> use Illuminate\Database\Query\Builder; <add>use Illuminate\Database\Query\JsonExpression; <ide> <ide> class MySqlGrammar extends Grammar <ide> { <ide> protected function compileLock(Builder $query, $value) <ide> */ <ide> public function compileUpdate(Builder $query, $values) <ide> { <del> $sql = parent::compileUpdate($query, $values); <add> $table = $this->wrapTable($query->from); <add> <add> $columns = []; <add> <add> // Each one of the columns in the update statements needs to be wrapped in the <add> // keyword identifiers, also a place-holder needs to be created for each of <add> // the values in the list of bindings so we can make the sets statements. <add> foreach ($values as $key => $value) { <add> if ($this->isJsonSelector($key)) { <add> $columns[] = $this->compileJsonUpdateColumn( <add> $key, new JsonExpression($value) <add> ); <add> } else { <add> $columns[] = $this->wrap($key).' = '.$this->parameter($value); <add> } <add> } <add> <add> $columns = implode(', ', $columns); <add> <add> // If the query has any "join" clauses, we will setup the joins on the builder <add> // and compile them so we can attach them to this update, as update queries <add> // can get join statements to attach to other tables when they're needed. <add> if (isset($query->joins)) { <add> $joins = ' '.$this->compileJoins($query, $query->joins); <add> } else { <add> $joins = ''; <add> } <add> <add> // Of course, update queries may also be constrained by where clauses so we'll <add> // need to compile the where clauses and attach it to the query so only the <add> // intended records are updated by the SQL statements we generate to run. <add> $where = $this->compileWheres($query); <add> <add> $sql = rtrim("update {$table}{$joins} set $columns $where"); <ide> <ide> if (isset($query->orders)) { <ide> $sql .= ' '.$this->compileOrders($query, $query->orders); <ide> public function compileUpdate(Builder $query, $values) <ide> return rtrim($sql); <ide> } <ide> <add> /** <add> * Prepares a JSON column being updated using the JSON_SET function. <add> * <add> * @param string $key <add> * @param \Illuminate\Database\JsonExpression $value <add> * @return string <add> */ <add> protected function compileJsonUpdateColumn($key, JsonExpression $value) <add> { <add> $path = explode('->', $key); <add> <add> $field = $this->wrapValue(array_shift($path)); <add> <add> $accessor = '"$.'.implode('.', $path).'"'; <add> <add> return "{$field} = json_set({$field}, {$accessor}, {$value->getValue()})"; <add> } <add> <ide> /** <ide> * Compile a delete statement into SQL. <ide> * <ide> protected function wrapValue($value) <ide> return $value; <ide> } <ide> <del> if (Str::contains($value, '->')) { <add> if ($this->isJsonSelector($value)) { <ide> return $this->wrapJsonSelector($value); <ide> } <ide> <ide> protected function wrapJsonSelector($value) <ide> <ide> return $field.'->'.'"$.'.implode('.', $path).'"'; <ide> } <add> <add> /** <add> * Determine if the given string is a JSON selector. <add> * <add> * @param string $value <add> * @return bool <add> */ <add> protected function isJsonSelector($value) <add> { <add> return Str::contains($value, '->'); <add> } <ide> } <ide><path>src/Illuminate/Database/Query/JsonExpression.php <add><?php <add> <add>namespace Illuminate\Database\Query; <add> <add>use InvalidArgumentException; <add> <add>class JsonExpression extends Expression <add>{ <add> /** <add> * The value of the expression. <add> * <add> * @var mixed <add> */ <add> protected $value; <add> <add> /** <add> * Create a new raw query expression. <add> * <add> * @param mixed $value <add> * @return void <add> */ <add> public function __construct($value) <add> { <add> $this->value = $this->getJsonBindingParameter($value); <add> } <add> <add> /** <add> * Translate the given value into the appropriate JSON binding parameter. <add> * <add> * @param mixed $value <add> * @return string <add> */ <add> protected function getJsonBindingParameter($value) <add> { <add> switch ($type = gettype($value)) { <add> case 'boolean': <add> return $value ? 'true' : 'false'; <add> case 'integer': <add> case 'double': <add> return $value; <add> case 'string': <add> return '?'; <add> case 'object': <add> case 'array': <add> return '?'; <add> } <add> <add> throw new InvalidArgumentException('JSON value is of illegal type: '.$type); <add> } <add> <add> /** <add> * Get the value of the expression. <add> * <add> * @return mixed <add> */ <add> public function getValue() <add> { <add> return $this->value; <add> } <add> <add> /** <add> * Get the value of the expression. <add> * <add> * @return string <add> */ <add> public function __toString() <add> { <add> return (string) $this->getValue(); <add> } <add>} <ide><path>tests/Cache/CacheTaggedCacheTest.php <ide> public function testRedisCacheTagsPushForeverKeysCorrectly() <ide> $redis = new Illuminate\Cache\RedisTaggedCache($store, $tagSet); <ide> $store->shouldReceive('getPrefix')->andReturn('prefix:'); <ide> $store->shouldReceive('connection')->andReturn($conn = m::mock('StdClass')); <del> $conn->shouldReceive('sadd')->once()->with('prefix:foo:forever', 'prefix:'.sha1('foo|bar').':key1'); <del> $conn->shouldReceive('sadd')->once()->with('prefix:bar:forever', 'prefix:'.sha1('foo|bar').':key1'); <add> $conn->shouldReceive('sadd')->once()->with('prefix:foo:forever_ref', 'prefix:'.sha1('foo|bar').':key1'); <add> $conn->shouldReceive('sadd')->once()->with('prefix:bar:forever_ref', 'prefix:'.sha1('foo|bar').':key1'); <add> <ide> $store->shouldReceive('forever')->with(sha1('foo|bar').':key1', 'key1:value'); <ide> <ide> $redis->forever('key1', 'key1:value'); <ide> public function testRedisCacheTagsPushStandardKeysCorrectly() <ide> $redis = new Illuminate\Cache\RedisTaggedCache($store, $tagSet); <ide> $store->shouldReceive('getPrefix')->andReturn('prefix:'); <ide> $store->shouldReceive('connection')->andReturn($conn = m::mock('StdClass')); <del> $conn->shouldReceive('sadd')->once()->with('prefix:foo:standard', 'prefix:'.sha1('foo|bar').':key1'); <del> $conn->shouldReceive('sadd')->once()->with('prefix:bar:standard', 'prefix:'.sha1('foo|bar').':key1'); <add> $conn->shouldReceive('sadd')->once()->with('prefix:foo:standard_ref', 'prefix:'.sha1('foo|bar').':key1'); <add> $conn->shouldReceive('sadd')->once()->with('prefix:bar:standard_ref', 'prefix:'.sha1('foo|bar').':key1'); <ide> $store->shouldReceive('push')->with(sha1('foo|bar').':key1', 'key1:value'); <ide> <ide> $redis->put('key1', 'key1:value'); <ide> public function testRedisCacheTagsCanBeFlushed() <ide> $store->shouldReceive('connection')->andReturn($conn = m::mock('StdClass')); <ide> <ide> // Forever tag keys <del> $conn->shouldReceive('smembers')->once()->with('prefix:foo:forever')->andReturn(['key1', 'key2']); <del> $conn->shouldReceive('smembers')->once()->with('prefix:bar:forever')->andReturn(['key3']); <add> $conn->shouldReceive('smembers')->once()->with('prefix:foo:forever_ref')->andReturn(['key1', 'key2']); <add> $conn->shouldReceive('smembers')->once()->with('prefix:bar:forever_ref')->andReturn(['key3']); <ide> $conn->shouldReceive('del')->once()->with('key1', 'key2'); <ide> $conn->shouldReceive('del')->once()->with('key3'); <del> $conn->shouldReceive('del')->once()->with('prefix:foo:forever'); <del> $conn->shouldReceive('del')->once()->with('prefix:bar:forever'); <add> $conn->shouldReceive('del')->once()->with('prefix:foo:forever_ref'); <add> $conn->shouldReceive('del')->once()->with('prefix:bar:forever_ref'); <ide> <ide> // Standard tag keys <del> $conn->shouldReceive('smembers')->once()->with('prefix:foo:standard')->andReturn(['key4', 'key5']); <del> $conn->shouldReceive('smembers')->once()->with('prefix:bar:standard')->andReturn(['key6']); <add> $conn->shouldReceive('smembers')->once()->with('prefix:foo:standard_ref')->andReturn(['key4', 'key5']); <add> $conn->shouldReceive('smembers')->once()->with('prefix:bar:standard_ref')->andReturn(['key6']); <ide> $conn->shouldReceive('del')->once()->with('key4', 'key5'); <ide> $conn->shouldReceive('del')->once()->with('key6'); <del> $conn->shouldReceive('del')->once()->with('prefix:foo:standard'); <del> $conn->shouldReceive('del')->once()->with('prefix:bar:standard'); <add> $conn->shouldReceive('del')->once()->with('prefix:foo:standard_ref'); <add> $conn->shouldReceive('del')->once()->with('prefix:bar:standard_ref'); <ide> <ide> $tagSet->shouldReceive('reset')->once(); <ide> <ide><path>tests/Database/DatabaseEloquentBuilderTest.php <ide> public function testWithCountAndContraintsAndHaving() <ide> $builder = $model->where('bar', 'baz'); <ide> $builder->withCount(['foo' => function ($q) { <ide> $q->where('bam', '>', 'qux'); <del> }])->having('fooCount', '>=', 1); <add> }])->having('foo_count', '>=', 1); <ide> <del> $this->assertEquals('select *, (select count(*) from "eloquent_builder_test_model_close_related_stubs" where "eloquent_builder_test_model_parent_stubs"."foo_id" = "eloquent_builder_test_model_close_related_stubs"."id" and "bam" > ?) as "foo_count" from "eloquent_builder_test_model_parent_stubs" where "bar" = ? having "fooCount" >= ?', $builder->toSql()); <add> $this->assertEquals('select *, (select count(*) from "eloquent_builder_test_model_close_related_stubs" where "eloquent_builder_test_model_parent_stubs"."foo_id" = "eloquent_builder_test_model_close_related_stubs"."id" and "bam" > ?) as "foo_count" from "eloquent_builder_test_model_parent_stubs" where "bar" = ? having "foo_count" >= ?', $builder->toSql()); <ide> $this->assertEquals(['qux', 'baz', 1], $builder->getBindings()); <ide> } <ide> <ide><path>tests/Database/DatabaseEloquentMorphToTest.php <ide> <?php <ide> <ide> use Mockery as m; <del>use Illuminate\Database\Eloquent\Collection; <ide> use Illuminate\Database\Eloquent\Relations\MorphTo; <ide> <ide> class DatabaseEloquentMorphToTest extends PHPUnit_Framework_TestCase <ide> public function testLookupDictionaryIsProperlyConstructed() <ide> ], $dictionary); <ide> } <ide> <del> public function testModelsAreProperlyPulledAndMatched() <del> { <del> $relation = $this->getRelation(); <del> <del> $one = m::mock('StdClass'); <del> $one->morph_type = 'morph_type_1'; <del> $one->foreign_key = 'foreign_key_1'; <del> <del> $two = m::mock('StdClass'); <del> $two->morph_type = 'morph_type_1'; <del> $two->foreign_key = 'foreign_key_1'; <del> <del> $three = m::mock('StdClass'); <del> $three->morph_type = 'morph_type_2'; <del> $three->foreign_key = 'foreign_key_2'; <del> <del> $relation->addEagerConstraints([$one, $two, $three]); <del> <del> $relation->shouldReceive('createModelByType')->once()->with('morph_type_1')->andReturn($firstQuery = m::mock('Illuminate\Database\Eloquent\Builder')); <del> $relation->shouldReceive('createModelByType')->once()->with('morph_type_2')->andReturn($secondQuery = m::mock('Illuminate\Database\Eloquent\Builder')); <del> $firstQuery->shouldReceive('getTable')->andReturn('foreign_table_1'); <del> $firstQuery->shouldReceive('getKeyName')->andReturn('id'); <del> $secondQuery->shouldReceive('getTable')->andReturn('foreign_table_2'); <del> $secondQuery->shouldReceive('getKeyName')->andReturn('id'); <del> <del> $firstQuery->shouldReceive('newQuery')->once()->andReturn($firstQuery); <del> $secondQuery->shouldReceive('newQuery')->once()->andReturn($secondQuery); <del> <del> $firstQuery->shouldReceive('whereIn')->once()->with('foreign_table_1.id', ['foreign_key_1'])->andReturn($firstQuery); <del> $firstQuery->shouldReceive('get')->once()->andReturn(Collection::make([$resultOne = m::mock('StdClass')])); <del> $resultOne->shouldReceive('getKey')->andReturn('foreign_key_1'); <del> <del> $secondQuery->shouldReceive('whereIn')->once()->with('foreign_table_2.id', ['foreign_key_2'])->andReturn($secondQuery); <del> $secondQuery->shouldReceive('get')->once()->andReturn(Collection::make([$resultTwo = m::mock('StdClass')])); <del> $resultTwo->shouldReceive('getKey')->andReturn('foreign_key_2'); <del> <del> $one->shouldReceive('setRelation')->once()->with('relation', $resultOne); <del> $two->shouldReceive('setRelation')->once()->with('relation', $resultOne); <del> $three->shouldReceive('setRelation')->once()->with('relation', $resultTwo); <del> <del> $relation->getEager(); <del> } <del> <del> public function testModelsWithSoftDeleteAreProperlyPulled() <del> { <del> $builder = m::mock('Illuminate\Database\Eloquent\Builder'); <del> <del> $relation = $this->getRelation(null, $builder); <del> <del> $builder->shouldReceive('getMacro')->once()->with('withTrashed')->andReturn(function () { return true; }); <del> $builder->shouldReceive('withTrashed')->once(); <del> <del> $relation->withTrashed(); <del> } <del> <ide> public function testAssociateMethodSetsForeignKeyAndTypeOnModel() <ide> { <ide> $parent = m::mock('Illuminate\Database\Eloquent\Model'); <ide> protected function getRelationAssociate($parent) <ide> public function getRelation($parent = null, $builder = null) <ide> { <ide> $builder = $builder ?: m::mock('Illuminate\Database\Eloquent\Builder'); <add> $builder->shouldReceive('toBase')->andReturn($builder); <add> $builder->shouldReceive('removedScopes')->andReturn([]); <add> $builder->shouldReceive('withoutGlobalScopes')->with([])->andReturn($builder); <add> $builder->shouldReceive('getRawBindings')->andReturn([ <add> 'select' => [], <add> 'join' => [], <add> 'where' => [], <add> 'having' => [], <add> 'order' => [], <add> 'union' => [], <add> ]); <ide> $builder->shouldReceive('where')->with('relation.id', '=', 'foreign.value'); <ide> $related = m::mock('Illuminate\Database\Eloquent\Model'); <ide> $related->shouldReceive('getKeyName')->andReturn('id'); <ide><path>tests/Database/DatabaseEloquentSoftDeletesIntegrationTest.php <ide> <ide> use Carbon\Carbon; <ide> use Illuminate\Database\Connection; <add>use Illuminate\Database\Eloquent\SoftDeletingScope; <ide> use Illuminate\Pagination\Paginator; <ide> use Illuminate\Database\Query\Builder; <ide> use Illuminate\Database\Eloquent\SoftDeletes; <ide> public function createSchema() <ide> <ide> $this->schema()->create('comments', function ($table) { <ide> $table->increments('id'); <add> $table->integer('owner_id')->nullable(); <add> $table->string('owner_type')->nullable(); <ide> $table->integer('post_id'); <ide> $table->string('body'); <ide> $table->timestamps(); <ide> public function testOrWhereWithSoftDeleteConstraint() <ide> $this->assertEquals(['abigailotwell@gmail.com'], $users->pluck('email')->all()); <ide> } <ide> <add> public function testMorphToWithTrashed() <add> { <add> $this->createUsers(); <add> <add> $abigail = SoftDeletesTestUser::where('email', 'abigailotwell@gmail.com')->first(); <add> $post1 = $abigail->posts()->create(['title' => 'First Title']); <add> $post1->comments()->create([ <add> 'body' => 'Comment Body', <add> 'owner_type' => SoftDeletesTestUser::class, <add> 'owner_id' => $abigail->id, <add> ]); <add> <add> $abigail->delete(); <add> <add> $comment = SoftDeletesTestCommentWithTrashed::with(['owner' => function ($q) { <add> $q->withoutGlobalScope(SoftDeletingScope::class); <add> }])->first(); <add> <add> $this->assertEquals($abigail->email, $comment->owner->email); <add> <add> $comment = SoftDeletesTestCommentWithTrashed::with(['owner' => function ($q) { <add> $q->withTrashed(); <add> }])->first(); <add> <add> $this->assertEquals($abigail->email, $comment->owner->email); <add> } <add> <add> public function testMorphToWithConstraints() <add> { <add> $this->createUsers(); <add> <add> $abigail = SoftDeletesTestUser::where('email', 'abigailotwell@gmail.com')->first(); <add> $post1 = $abigail->posts()->create(['title' => 'First Title']); <add> $post1->comments()->create([ <add> 'body' => 'Comment Body', <add> 'owner_type' => SoftDeletesTestUser::class, <add> 'owner_id' => $abigail->id, <add> ]); <add> <add> $comment = SoftDeletesTestCommentWithTrashed::with(['owner' => function ($q) { <add> $q->where('email', 'taylorotwell@gmail.com'); <add> }])->first(); <add> <add> $this->assertEquals(null, $comment->owner); <add> } <add> <add> public function testMorphToWithoutConstraints() <add> { <add> $this->createUsers(); <add> <add> $abigail = SoftDeletesTestUser::where('email', 'abigailotwell@gmail.com')->first(); <add> $post1 = $abigail->posts()->create(['title' => 'First Title']); <add> $comment1 = $post1->comments()->create([ <add> 'body' => 'Comment Body', <add> 'owner_type' => SoftDeletesTestUser::class, <add> 'owner_id' => $abigail->id, <add> ]); <add> <add> $comment = SoftDeletesTestCommentWithTrashed::with('owner')->first(); <add> <add> $this->assertEquals($abigail->email, $comment->owner->email); <add> <add> $abigail->delete(); <add> $comment = SoftDeletesTestCommentWithTrashed::with('owner')->first(); <add> <add> $this->assertEquals(null, $comment->owner); <add> } <add> <ide> /** <ide> * Helpers... <ide> */ <ide> class SoftDeletesTestComment extends Eloquent <ide> protected $dates = ['deleted_at']; <ide> protected $table = 'comments'; <ide> protected $guarded = []; <add> <add> public function owner() <add> { <add> return $this->morphTo(); <add> } <add>} <add> <add>class SoftDeletesTestCommentWithTrashed extends Eloquent <add>{ <add> use SoftDeletes; <add> <add> protected $dates = ['deleted_at']; <add> protected $table = 'comments'; <add> protected $guarded = []; <add> <add> public function owner() <add> { <add> return $this->morphTo(); <add> } <ide> } <ide> <ide> /** <ide><path>tests/Database/DatabaseQueryBuilderTest.php <ide> public function testMySqlWrapping() <ide> $this->assertEquals('select * from `users`', $builder->toSql()); <ide> } <ide> <add> public function testMySqlUpdateWrappingJson() <add> { <add> $grammar = new Illuminate\Database\Query\Grammars\MySqlGrammar; <add> $processor = m::mock('Illuminate\Database\Query\Processors\Processor'); <add> <add> // Couldn't get mockery to work <add> $connection = $this->createMock('Illuminate\Database\ConnectionInterface'); <add> $connection->expects($this->once()) <add> ->method('update') <add> ->with( <add> $this->equalTo('update `users` set `name` = json_set(`name`, "$.first_name", ?), `name` = json_set(`name`, "$.last_name", ?) where `active` = ?'), <add> $this->equalTo(['John', 'Doe', 1]) <add> ); <add> <add> $builder = new Builder($connection, $grammar, $processor); <add> <add> $result = $builder->from('users')->where('active', '=', 1)->update(['name->first_name' => 'John', 'name->last_name' => 'Doe']); <add> } <add> <add> public function testMySqlWrappingJsonWithString() <add> { <add> $builder = $this->getMySqlBuilder(); <add> $builder->select('*')->from('users')->where('items->sku', '=', 'foo-bar'); <add> $this->assertEquals('select * from `users` where `items`->"$.sku" = ?', $builder->toSql()); <add> $this->assertCount(1, $builder->getRawBindings()['where']); <add> $this->assertEquals('foo-bar', $builder->getRawBindings()['where'][0]); <add> } <add> <add> public function testMySqlWrappingJsonWithInteger() <add> { <add> $builder = $this->getMySqlBuilder(); <add> $builder->select('*')->from('users')->where('items->price', '=', 1); <add> $this->assertEquals('select * from `users` where `items`->"$.price" = ?', $builder->toSql()); <add> } <add> <add> public function testMySqlWrappingJsonWithDouble() <add> { <add> $builder = $this->getMySqlBuilder(); <add> $builder->select('*')->from('users')->where('items->price', '=', 1.5); <add> $this->assertEquals('select * from `users` where `items`->"$.price" = ?', $builder->toSql()); <add> } <add> <add> public function testMySqlWrappingJsonWithBoolean() <add> { <add> $builder = $this->getMySqlBuilder(); <add> $builder->select('*')->from('users')->where('items->available', '=', true); <add> $this->assertEquals('select * from `users` where `items`->"$.available" = true', $builder->toSql()); <add> } <add> <add> public function testMySqlWrappingJsonWithBooleanAndIntegerThatLooksLikeOne() <add> { <add> $builder = $this->getMySqlBuilder(); <add> $builder->select('*')->from('users')->where('items->available', '=', true)->where('items->active', '=', false)->where('items->number_available', '=', 0); <add> $this->assertEquals('select * from `users` where `items`->"$.available" = true and `items`->"$.active" = false and `items`->"$.number_available" = ?', $builder->toSql()); <add> } <add> <ide> public function testMySqlWrappingJson() <ide> { <ide> $builder = $this->getMySqlBuilder();
12
Go
Go
improve some usages
b622da3cfe211d31df69e72a93ed4fae872aca65
<ide><path>docker/docker.go <ide> func main() { <ide> flDaemon = flag.Bool([]string{"d", "-daemon"}, false, "Enable daemon mode") <ide> flDebug = flag.Bool([]string{"D", "-debug"}, false, "Enable debug mode") <ide> flAutoRestart = flag.Bool([]string{"r", "-restart"}, true, "Restart previously running containers") <del> bridgeName = flag.String([]string{"b", "-bridge"}, "", "Attach containers to a pre-existing network bridge; use 'none' to disable container networking") <add> bridgeName = flag.String([]string{"b", "-bridge"}, "", "Attach containers to a pre-existing network bridge\nuse 'none' to disable container networking") <ide> bridgeIp = flag.String([]string{"#bip", "-bip"}, "", "Use this CIDR notation address for the network bridge's IP, not compatible with -b") <ide> pidfile = flag.String([]string{"p", "-pidfile"}, "/var/run/docker.pid", "Path to use for daemon PID file") <ide> flRoot = flag.String([]string{"g", "-graph"}, "/var/lib/docker", "Path to use as the root of the docker runtime") <del> flSocketGroup = flag.String([]string{"G", "-group"}, "docker", "Group to assign the unix socket specified by -H when running in daemon mode; use '' (the empty string) to disable setting of a group") <add> flSocketGroup = flag.String([]string{"G", "-group"}, "docker", "Group to assign the unix socket specified by -H when running in daemon mode\nuse '' (the empty string) to disable setting of a group") <ide> flEnableCors = flag.Bool([]string{"#api-enable-cors", "-api-enable-cors"}, false, "Enable CORS headers in the remote API") <ide> flDns = opts.NewListOpts(opts.ValidateIp4Address) <ide> flDnsSearch = opts.NewListOpts(opts.ValidateDomain) <ide> func main() { <ide> flGraphDriver = flag.String([]string{"s", "-storage-driver"}, "", "Force the docker runtime to use a specific storage driver") <ide> flExecDriver = flag.String([]string{"e", "-exec-driver"}, "native", "Force the docker runtime to use a specific exec driver") <ide> flHosts = opts.NewListOpts(api.ValidateHost) <del> flMtu = flag.Int([]string{"#mtu", "-mtu"}, 0, "Set the containers network MTU; if no value is provided: default to the default route MTU or 1500 if no default route is available") <add> flMtu = flag.Int([]string{"#mtu", "-mtu"}, 0, "Set the containers network MTU\nif no value is provided: default to the default route MTU or 1500 if no default route is available") <ide> flTls = flag.Bool([]string{"-tls"}, false, "Use TLS; implied by tls-verify flags") <ide> flTlsVerify = flag.Bool([]string{"-tlsverify"}, false, "Use TLS and verify the remote (daemon: verify client, client: verify daemon)") <ide> flCa = flag.String([]string{"-tlscacert"}, dockerConfDir+defaultCaFile, "Trust only remotes providing a certificate signed by the CA given here") <ide> func main() { <ide> ) <ide> flag.Var(&flDns, []string{"#dns", "-dns"}, "Force docker to use specific DNS servers") <ide> flag.Var(&flDnsSearch, []string{"-dns-search"}, "Force Docker to use specific DNS search domains") <del> flag.Var(&flHosts, []string{"H", "-host"}, "The socket(s) to bind to in daemon mode, specified using one or more tcp://host:port, unix:///path/to/socket, fd://* or fd://socketfd.") <add> flag.Var(&flHosts, []string{"H", "-host"}, "The socket(s) to bind to in daemon mode\nspecified using one or more tcp://host:port, unix:///path/to/socket, fd://* or fd://socketfd.") <ide> <ide> flag.Parse() <ide> <ide><path>runconfig/parse.go <ide> func parseRun(cmd *flag.FlagSet, args []string, sysInfo *sysinfo.SysInfo) (*Conf <ide> flUser = cmd.String([]string{"u", "-user"}, "", "Username or UID") <ide> flWorkingDir = cmd.String([]string{"w", "-workdir"}, "", "Working directory inside the container") <ide> flCpuShares = cmd.Int64([]string{"c", "-cpu-shares"}, 0, "CPU shares (relative weight)") <del> flNetMode = cmd.String([]string{"-net"}, "bridge", "Set the Network mode for the container ('bridge': creates a new network stack for the container on the docker bridge, 'none': no networking for this container, 'container:<name|id>': reuses another container network stack), 'host': use the host network stack inside the container") <add> flNetMode = cmd.String([]string{"-net"}, "bridge", "Set the Network mode for the container\n'bridge': creates a new network stack for the container on the docker bridge\n'none': no networking for this container\n'container:<name|id>': reuses another container network stack\n'host': use the host network stack inside the contaner") <ide> // For documentation purpose <ide> _ = cmd.Bool([]string{"#sig-proxy", "-sig-proxy"}, true, "Proxify all received signal to the process (even in non-tty mode)") <ide> _ = cmd.String([]string{"#name", "-name"}, "", "Assign a name to the container") <ide> func parseRun(cmd *flag.FlagSet, args []string, sysInfo *sysinfo.SysInfo) (*Conf <ide> cmd.Var(&flEnv, []string{"e", "-env"}, "Set environment variables") <ide> cmd.Var(&flEnvFile, []string{"-env-file"}, "Read in a line delimited file of ENV variables") <ide> <del> cmd.Var(&flPublish, []string{"p", "-publish"}, fmt.Sprintf("Publish a container's port to the host (format: %s) (use 'docker port' to see the actual mapping)", nat.PortSpecTemplateFormat)) <add> cmd.Var(&flPublish, []string{"p", "-publish"}, fmt.Sprintf("Publish a container's port to the host\nformat: %s\n(use 'docker port' to see the actual mapping)", nat.PortSpecTemplateFormat)) <ide> cmd.Var(&flExpose, []string{"#expose", "-expose"}, "Expose a port from the container without publishing it to your host") <ide> cmd.Var(&flDns, []string{"#dns", "-dns"}, "Set custom dns servers") <ide> cmd.Var(&flDnsSearch, []string{"-dns-search"}, "Set custom dns search domains")
2
Go
Go
add some stdcopy_test (coverage)
2ed4ed50be3a0379d83b9267f62c4c7f665b849f
<ide><path>pkg/stdcopy/stdcopy.go <ide> func (w *StdWriter) Write(buf []byte) (n int, err error) { <ide> // `t` indicates the id of the stream to encapsulate. <ide> // It can be stdcopy.Stdin, stdcopy.Stdout, stdcopy.Stderr. <ide> func NewStdWriter(w io.Writer, t StdType) *StdWriter { <del> if len(t) != StdWriterPrefixLen { <del> return nil <del> } <del> <ide> return &StdWriter{ <ide> Writer: w, <ide> prefix: t, <ide><path>pkg/stdcopy/stdcopy_test.go <ide> package stdcopy <ide> import ( <ide> "bytes" <ide> "io/ioutil" <add> "strings" <ide> "testing" <ide> ) <ide> <add>func TestNewStdWriter(t *testing.T) { <add> writer := NewStdWriter(ioutil.Discard, Stdout) <add> if writer == nil { <add> t.Fatalf("NewStdWriter with an invalid StdType should not return nil.") <add> } <add>} <add> <add>func TestWriteWithUnitializedStdWriter(t *testing.T) { <add> writer := StdWriter{ <add> Writer: nil, <add> prefix: Stdout, <add> sizeBuf: make([]byte, 4), <add> } <add> n, err := writer.Write([]byte("Something here")) <add> if n != 0 || err == nil { <add> t.Fatalf("Should fail when given an uncomplete or uninitialized StdWriter") <add> } <add>} <add> <add>func TestWriteWithNilBytes(t *testing.T) { <add> writer := NewStdWriter(ioutil.Discard, Stdout) <add> n, err := writer.Write(nil) <add> if err != nil { <add> t.Fatalf("Shouldn't have fail when given no data") <add> } <add> if n > 0 { <add> t.Fatalf("Write should have written 0 byte, but has written %d", n) <add> } <add>} <add> <add>func TestWrite(t *testing.T) { <add> writer := NewStdWriter(ioutil.Discard, Stdout) <add> data := []byte("Test StdWrite.Write") <add> n, err := writer.Write(data) <add> if err != nil { <add> t.Fatalf("Error while writing with StdWrite") <add> } <add> if n != len(data) { <add> t.Fatalf("Write should have writen %d byte but wrote %d.", len(data), n) <add> } <add>} <add> <add>func TestStdCopyWithInvalidInputHeader(t *testing.T) { <add> dstOut := NewStdWriter(ioutil.Discard, Stdout) <add> dstErr := NewStdWriter(ioutil.Discard, Stderr) <add> src := strings.NewReader("Invalid input") <add> _, err := StdCopy(dstOut, dstErr, src) <add> if err == nil { <add> t.Fatal("StdCopy with invalid input header should fail.") <add> } <add>} <add> <add>func TestStdCopyWithCorruptedPrefix(t *testing.T) { <add> data := []byte{0x01, 0x02, 0x03} <add> src := bytes.NewReader(data) <add> written, err := StdCopy(nil, nil, src) <add> if err != nil { <add> t.Fatalf("StdCopy should not return an error with corrupted prefix.") <add> } <add> if written != 0 { <add> t.Fatalf("StdCopy should have written 0, but has written %d", written) <add> } <add>} <add> <ide> func BenchmarkWrite(b *testing.B) { <ide> w := NewStdWriter(ioutil.Discard, Stdout) <ide> data := []byte("Test line for testing stdwriter performance\n")
2
Text
Text
add changelog entry for [ci-skip]
d44e786d216f82584c7752ffee91ef4d5bea14ba
<ide><path>activerecord/CHANGELOG.md <add>* Add new `ActiveRecord::Base::generates_token_for` API. <add> <add> Currently, `signed_id` fulfills the role of generating tokens for e.g. <add> resetting a password. However, signed IDs cannot reflect record state, so <add> if a token is intended to be single-use, it must be tracked in a database at <add> least until it expires. <add> <add> With `generates_token_for`, a token can embed data from a record. When <add> using the token to fetch the record, the data from the token and the data <add> from the record will be compared. If the two do not match, the token will <add> be treated as invalid, the same as if it had expired. For example: <add> <add> ```ruby <add> class User < ActiveRecord::Base <add> has_secure_password <add> <add> generates_token_for :password_reset, expires_in: 15.minutes do <add> # A password's BCrypt salt changes when the password is updated. <add> # By embedding (part of) the salt in a token, the token will <add> # expire when the password is updated. <add> BCrypt::Password.new(password_digest).salt[-10..] <add> end <add> end <add> <add> user = User.first <add> token = user.generate_token_for(:password_reset) <add> <add> User.find_by_token_for(:password_reset, token) # => user <add> <add> user.update!(password: "new password") <add> User.find_by_token_for(:password_reset, token) # => nil <add> ``` <add> <ide> * Optimize Active Record batching for whole table iterations. <ide> <ide> Previously, `in_batches` got all the ids and constructed an `IN`-based query for each batch.
1
Javascript
Javascript
add req.connection and res.connection
3546106c43c08aed0f3e45f81f82496c9c51f6b9
<ide><path>lib/http.js <ide> var contentLengthExpression = /Content-Length/i; <ide> function IncomingMessage (socket) { <ide> events.EventEmitter.call(this); <ide> <add> // TODO Remove one of these eventually. <ide> this.socket = socket; <add> this.connection = socket; <add> <ide> this.httpVersion = null; <ide> this.headers = {}; <ide> <ide> IncomingMessage.prototype._addHeaderLine = function (field, value) { <ide> function OutgoingMessage (socket) { <ide> events.EventEmitter.call(this, socket); <ide> <add> // TODO Remove one of these eventually. <ide> this.socket = socket; <add> this.connection = socket; <ide> <ide> this.output = []; <ide> this.outputEncodings = [];
1
Text
Text
fix the case in title
4fd6515e1e2ec22172882964c0bb4b586461589c
<ide><path>guide/english/javascript/html-dom-innerhtml-property/index.md <ide> --- <del>title: HTML Dom Innerhtml Property <add>title: HTML DOM innerHTML Property <ide> --- <del>## HTML Dom Innerhtml Property <del>The `innerHTML` prop return the HTML content inside a selected element and also let you define a new HTML content. <add>## HTML DOM innerHTML Property <add>The `innerHTML` property returns the HTML content inside a selected element and also lets you define a new HTML content. <ide> <ide> ***GET ELEMENT CONTENT*** <ide>
1
Go
Go
fix a minor typo
07d190a61c60cff2f20186e700abca46f18d35ac
<ide><path>graph/push.go <ide> func (s *TagStore) pushImageToEndpoint(endpoint string, out io.Writer, remoteNam <ide> // wait for all the images that require pushes to be collected into a consumable map. <ide> shouldPush := <-pushes <ide> // finish by pushing any images and tags to the endpoint. The order that the images are pushed <del> // is very important that is why we are still itterating over the ordered list of imageIDs. <add> // is very important that is why we are still iterating over the ordered list of imageIDs. <ide> for _, id := range imageIDs { <ide> if _, push := shouldPush[id]; push { <ide> if _, err := s.pushImage(r, out, id, endpoint, repo.Tokens, sf); err != nil {
1
PHP
PHP
fix typos and expand docs
4b7ccf10c3b00328184cfa118c5e248552c0ff3f
<ide><path>src/TestSuite/IntegrationTestCase.php <ide> class IntegrationTestCase extends TestCase { <ide> */ <ide> protected $_response; <ide> <add>/** <add> * Session data to use in the next request. <add> * <add> * @var array <add> */ <ide> protected $_session = []; <add> <add>/** <add> * Cookie data to use in the next request. <add> * <add> * @var array <add> */ <ide> protected $_cookie = []; <ide> <ide> /** <ide> public function tearDown() { <ide> } <ide> <ide> /** <del> * Configure the data for tne *next* request. <add> * Configure the data for the *next* request. <ide> * <ide> * This data is cleared in the tearDown() method. <ide> * <ide> protected function _assertStatus($min, $max, $message) { <ide> * Assert that the Location header is correct. <ide> * <ide> * @param string|array $url The url you expected the client to go to. This <del> * cane either be a string URL or an array compatible with Router::url() <add> * can either be a string URL or an array compatible with Router::url() <ide> * @return void <ide> */ <ide> public function assertRedirect($url, $message = '') { <ide> if (!$this->_response) { <del> $this->fail('Not response set, cannot assert location header. ' . $message); <add> $this->fail('No response set, cannot assert location header. ' . $message); <ide> } <ide> $result = $this->_response->header(); <ide> if (empty($result['Location'])) {
1
Javascript
Javascript
ignore unused materials in fbxloader
87fb3a6477e4d99e6168881e62f9f3586ff70403
<ide><path>examples/js/loaders/FBXLoader.js <ide> for ( var nodeID in materialNodes ) { <ide> <ide> var material = parseMaterial( materialNodes[ nodeID ], textureMap, connections ); <del> materialMap.set( parseInt( nodeID ), material ); <add> if ( material !== null ) materialMap.set( parseInt( nodeID ), material ); <ide> <ide> } <ide> <ide> <ide> } <ide> <add> // Seems like FBX can include unused materials which don't have any connections. <add> // Ignores them so far. <add> if ( ! connections.has( FBX_ID ) ) return null; <add> <ide> var children = connections.get( FBX_ID ).children; <ide> <ide> var parameters = parseParameters( materialNode.properties, textureMap, children );
1
PHP
PHP
prevent block="css" when using inline=false css
22f844c48f3a37948470d0c177d9768fc83a8aaf
<ide><path>lib/Cake/View/Helper/HtmlHelper.php <ide> public function docType($type = 'html5') { <ide> * <ide> * ### Options <ide> * <del> * - `inline` Whether or not the link element should be output inline. Set to false to <add> * - `inline` Whether or not the link element should be output inline. Set to false to <ide> * have the meta tag included in `$scripts_for_layout`, and appended to the 'meta' view block. <ide> * - `block` Choose a custom block to append the meta tag to. Using this option <ide> * will override the inline option. <ide> public function link($title, $url = null, $options = array(), $confirmMessage = <ide> * <ide> * ### Options <ide> * <del> * - `inline` If set to false, the generated tag will be appended to the 'css' block, <add> * - `inline` If set to false, the generated tag will be appended to the 'css' block, <ide> * and included in the `$scripts_for_layout` layout variable. Defaults to true. <ide> * - `block` Set the name of the block link/style tag will be appended to. This overrides the `inline` <ide> * option. <ide> public function css($path, $rel = null, $options = array()) { <ide> } <ide> <ide> if ($rel == 'import') { <del> $out = sprintf($this->_tags['style'], $this->_parseAttributes($options, array('inline'), '', ' '), '@import url(' . $url . ');'); <add> $out = sprintf($this->_tags['style'], $this->_parseAttributes($options, array('inline', 'block'), '', ' '), '@import url(' . $url . ');'); <ide> } else { <ide> if ($rel == null) { <ide> $rel = 'stylesheet'; <ide> } <del> $out = sprintf($this->_tags['css'], $rel, $url, $this->_parseAttributes($options, array('inline'), '', ' ')); <add> $out = sprintf($this->_tags['css'], $rel, $url, $this->_parseAttributes($options, array('inline', 'block'), '', ' ')); <ide> } <ide> <ide> if (empty($options['block'])) {
1
PHP
PHP
implement proper return types
0ac05201b7b06e368c4336ac5760d76d28da3e55
<ide><path>src/Illuminate/Cache/RedisTaggedCache.php <ide> class RedisTaggedCache extends TaggedCache <ide> * @var string <ide> */ <ide> const REFERENCE_KEY_FOREVER = 'forever_ref'; <add> <ide> /** <ide> * Standard reference key. <ide> * <ide> public function put($key, $value, $ttl = null) <ide> * <ide> * @param string $key <ide> * @param mixed $value <del> * @return void <add> * @return int|bool <ide> */ <ide> public function increment($key, $value = 1) <ide> { <ide> $this->pushStandardKeys($this->tags->getNamespace(), $key); <ide> <del> parent::increment($key, $value); <add> return parent::increment($key, $value); <ide> } <ide> <ide> /** <ide> * Decrement the value of an item in the cache. <ide> * <ide> * @param string $key <ide> * @param mixed $value <del> * @return void <add> * @return int|bool <ide> */ <ide> public function decrement($key, $value = 1) <ide> { <ide> $this->pushStandardKeys($this->tags->getNamespace(), $key); <ide> <del> parent::decrement($key, $value); <add> return parent::decrement($key, $value); <ide> } <ide> <ide> /** <ide><path>src/Illuminate/Cache/TaggedCache.php <ide> public function putMany(array $values, $ttl = null) <ide> * <ide> * @param string $key <ide> * @param mixed $value <del> * @return void <add> * @return int|bool <ide> */ <ide> public function increment($key, $value = 1) <ide> { <ide> public function increment($key, $value = 1) <ide> * <ide> * @param string $key <ide> * @param mixed $value <del> * @return void <add> * @return int|bool <ide> */ <ide> public function decrement($key, $value = 1) <ide> {
2
Ruby
Ruby
fix a button_to documentation example
c2cadd2f6de7e573037856379d95e234805c5477
<ide><path>actionview/lib/action_view/helpers/url_helper.rb <ide> def link_to(name = nil, options = nil, html_options = nil, &block) <ide> # <ide> # <ide> # <%= button_to('Destroy', 'http://www.example.com', <del> # method: "delete", remote: true, data: { confirm: 'Are you sure?', disable_with: 'loading...' }) %> <add> # method: :delete, remote: true, data: { confirm: 'Are you sure?', disable_with: 'loading...' }) %> <ide> # # => "<form class='button_to' method='post' action='http://www.example.com' data-remote='true'> <ide> # # <input name='_method' value='delete' type='hidden' /> <ide> # # <input value='Destroy' type='submit' data-disable-with='loading...' data-confirm='Are you sure?' />
1
Text
Text
add note in "fetching from the server" section
d136d28f55ca1b52fa9cd4250bfd30b4a81136b2
<ide><path>docs/docs/tutorial.ja-JP.md <ide> ReactDOM.render( <ide> <ide> このコンポーネントは自身を再びレンダリングすることになるので、これまでのコンポーネントとは異なります。レスポンスがサーバから返ってくると、送られてきた新しいコメントをコンポーネントがレンダリングすることになります。ですが、その時点までコンポーネントには何もデータがないはずです。 <ide> <add>確認: 上のコードは、このステップではまだ動きません。 <add> <ide> ### Reactive state <ide> <ide> これまで、それぞれのコンポーネントは自身の props の値を用いて、一度だけレンダリングしていました。`props` はイミュータブルです。つまり、props は親から渡されますが、同時に props は親の「所有物」なのです。データが相互にやり取りされるのを実現するため、ここでミュータブルな **state**(状態)をコンポーネントに取り入れましょう。コンポーネントは `this.state` というプライベートな値を持ち、`this.setState()` を呼び出すことで state を更新することが出来ます。コンポーネントの state が更新されれば、そのコンポーネントは自身を再びレンダリングし直します。
1
Go
Go
fix data races in map access
392b089170dae9271af26ac766be3438892a644a
<ide><path>libnetwork/networkdb/delegate.go <ide> func (nDB *NetworkDB) handleBulkSync(buf []byte) { <ide> } <ide> <ide> var nodeAddr net.IP <add> nDB.RLock() <ide> if node, ok := nDB.nodes[bsm.NodeName]; ok { <ide> nodeAddr = node.Addr <ide> } <add> nDB.RUnlock() <ide> <ide> if err := nDB.bulkSyncNode(bsm.Networks, bsm.NodeName, false); err != nil { <ide> logrus.Errorf("Error in responding to bulk sync from node %s: %v", nodeAddr, err) <ide><path>libnetwork/networkdb/networkdb.go <ide> func (nDB *NetworkDB) JoinNetwork(nid string) error { <ide> nodeNetworks[nid] = &network{id: nid, ltime: ltime} <ide> nodeNetworks[nid].tableBroadcasts = &memberlist.TransmitLimitedQueue{ <ide> NumNodes: func() int { <del> return len(nDB.networkNodes[nid]) <add> nDB.RLock() <add> num := len(nDB.networkNodes[nid]) <add> nDB.RUnlock() <add> return num <ide> }, <ide> RetransmitMult: 4, <ide> }
2
Javascript
Javascript
simplify animationmixer to prevent bugs
ef42280373467e7e0b5f600b84d73ac881a915d0
<ide><path>src/animation/AnimationMixer.js <ide> THREE.AnimationMixer = function( root ) { <ide> this.time = 0; <ide> this.timeScale = 1.0; <ide> this.actions = []; <del> this.propertyBindings = []; <del> this.propertyBindingNamesToIndex = {}; <add> this.propertyBindingMap = {}; <ide> <ide> }; <ide> <ide> THREE.AnimationMixer.prototype = { <ide> <ide> var track = tracks[ i ]; <ide> <del> var j = this.getPropertyBindingIndex( root, track.name ) <add> var propertyBindingKey = root.uuid + '-' + track.name; <add> var propertyBinding = this.propertyBindingMap[ propertyBindingKey ]; <ide> <del> var propertyBinding; <del> <del> if( j < 0 ) { <add> if( propertyBinding === undefined ) { <ide> <ide> propertyBinding = new THREE.PropertyBinding( root, track.name ); <del> this.propertyBindings.push( propertyBinding ); <del> this.propertyBindingNamesToIndex[ root.uuid + '-' + track.name ] = this.propertyBindings.length - 1; <add> this.propertyBindingMap[ propertyBindingKey ] = propertyBinding; <ide> <ide> } <del> else { <del> propertyBinding = this.propertyBindings[ j ]; <del> } <ide> <ide> // push in the same order as the tracks. <ide> action.propertyBindings.push( propertyBinding ); <ide> THREE.AnimationMixer.prototype = { <ide> <ide> }, <ide> <del> getPropertyBindingIndex: function( rootNode, trackName ) { <del> <del> var index = this.propertyBindingNamesToIndex[ rootNode.uuid + '-' + trackName ]; <del> return ( index !== undefined ) ? index : -1; <del> <del> }, <del> <ide> removeAllActions: function() { <ide> <ide> for( var i = 0; i < this.actions.length; i ++ ) { <ide> THREE.AnimationMixer.prototype = { <ide> } <ide> <ide> // unbind all property bindings <del> for( var i = 0; i < this.propertyBindings.length; i ++ ) { <add> for( var properyBindingKey in this.propertyBindingMap ) { <ide> <del> this.propertyBindings[i].unbind(); <add> this.propertyBindingMap[ properyBindingKey ].unbind(); <ide> <ide> } <ide> <ide> this.actions = []; <del> this.propertyBindings = []; <del> this.propertyBindingNamesToIndex = {}; <add> this.propertyBindingMap = {}; <ide> <ide> return this; <ide> <ide> THREE.AnimationMixer.prototype = { <ide> for( var i = 0; i < tracks.length; i ++ ) { <ide> <ide> var track = tracks[ i ]; <del> var propertyBindingIndex = this.getPropertyBindingIndex( root, track.name ); <del> var propertyBinding = this.propertyBindings[ propertyBindingIndex ]; <ide> <add> var propertyBindingKey = root.uuid + '-' + track.name; <add> var propertyBinding = this.propertyBindingMap[ propertyBindingKey ]; <add> <ide> propertyBinding.referenceCount -= 1; <ide> <ide> if( propertyBinding.referenceCount <= 0 ) { <ide> <ide> propertyBinding.unbind(); <ide> <del> this.propertyBindings.splice( this.propertyBindings.indexOf( propertyBinding ), 1 ); <add> delete this.propertyBindingMap[ propertyBindingKey ]; <ide> <ide> } <ide> } <ide> THREE.AnimationMixer.prototype = { <ide> } <ide> <ide> // apply to nodes <del> for ( var i = 0; i < this.propertyBindings.length; i ++ ) { <add> for( var propertyBindingKey in this.propertyBindingMap ) { <ide> <del> this.propertyBindings[ i ].apply(); <add> this.propertyBindingMap[ propertyBindingKey ].apply(); <ide> <ide> } <ide>
1
Python
Python
add unit test for refresh endpoint
b5296f5bd9883eb77016d9426819241f834587dd
<ide><path>airflow/www/views.py <ide> def gantt(self): <ide> @login_required <ide> @wwwutils.action_logging <ide> def task_instances(self): <del> print request.args <ide> session = settings.Session() <ide> dag_id = request.args.get('dag_id') <ide> dag = dagbag.get_dag(dag_id) <ide><path>tests/core.py <ide> def test_dag_views(self): <ide> "dag_id=example_bash_operator&force=true&deps=true&" <ide> "execution_date={}&origin=/admin".format(DEFAULT_DATE_DS)) <ide> response = self.app.get(url) <add> url = ( <add> "/admin/airflow/object/task_instances?" <add> "dag_id=example_bash_operator&" <add> "execution_date={}".format(DEFAULT_DATE_DS)) <add> response = self.app.get(url) <add> assert "runme_0" in response.data.decode('utf-8') <ide> response = self.app.get( <ide> "/admin/airflow/refresh?dag_id=example_bash_operator") <ide> response = self.app.get("/admin/airflow/refresh_all")
2
Javascript
Javascript
add era info in generic locale
4acb0af24c7fb3705a197ca96adc532de4766a7a
<ide><path>i18n/src/converter.js <ide> function convertDatetimeData(dataObj) { <ide> datetimeFormats.AMPMS = dataObj.AMPMS; <ide> datetimeFormats.FIRSTDAYOFWEEK = dataObj.FIRSTDAYOFWEEK; <ide> datetimeFormats.WEEKENDRANGE = dataObj.WEEKENDRANGE; <add> datetimeFormats.ERAS = dataObj.ERAS; <add> datetimeFormats.ERANAMES = dataObj.ERANAMES; <ide> <ide> <ide> datetimeFormats.medium = dataObj.DATEFORMATS[2] + ' ' + dataObj.TIMEFORMATS[2]; <ide><path>src/ng/locale.js <ide> function $LocaleProvider() { <ide> mediumDate: 'MMM d, y', <ide> shortDate: 'M/d/yy', <ide> mediumTime: 'h:mm:ss a', <del> shortTime: 'h:mm a' <add> shortTime: 'h:mm a', <add> ERANAMES: [ <add> "Before Christ", <add> "Anno Domini" <add> ], <add> ERAS: [ <add> "BC", <add> "AD" <add> ] <ide> }, <ide> <ide> pluralCat: function(num) {
2
PHP
PHP
pass request to responsable
ef0e37d44182ac5043b5459bb25b1861e8e036df
<ide><path>src/Illuminate/Contracts/Support/Responsable.php <ide> interface Responsable <ide> /** <ide> * Create an HTTP response that represents the object. <ide> * <add> * @param \Illuminate\Http\Request $request <ide> * @return \Illuminate\Http\Response <ide> */ <del> public function toResponse(); <add> public function toResponse($request); <ide> } <ide><path>src/Illuminate/Foundation/Exceptions/Handler.php <ide> public function render($request, Exception $e) <ide> if (method_exists($e, 'render') && $response = $e->render($request)) { <ide> return Router::prepareResponse($request, $response); <ide> } elseif ($e instanceof Responsable) { <del> return $e->toResponse(); <add> return $e->toResponse($request); <ide> } <ide> <ide> $e = $this->prepareException($e); <ide><path>src/Illuminate/Routing/Router.php <ide> protected function sortMiddleware(Collection $middlewares) <ide> public static function prepareResponse($request, $response) <ide> { <ide> if ($response instanceof Responsable) { <del> $response = $response->toResponse(); <add> $response = $response->toResponse($request); <ide> } <ide> <ide> if ($response instanceof PsrResponseInterface) { <ide><path>tests/Foundation/FoundationExceptionsHandlerTest.php <ide> public function testReturnsJsonWithoutStackTraceWhenAjaxRequestAndDebugFalseAndA <ide> <ide> class CustomException extends Exception implements Responsable <ide> { <del> public function toResponse() <add> public function toResponse($request) <ide> { <ide> return response()->json(['response' => 'My custom exception response']); <ide> } <ide><path>tests/Integration/Routing/ResponsableTest.php <ide> public function test_responsable_objects_are_rendered() <ide> <ide> class TestResponsableResponse implements Responsable <ide> { <del> public function toResponse() <add> public function toResponse($request) <ide> { <ide> return response('hello world', 201, ['X-Test-Header' => 'Taylor']); <ide> }
5
Javascript
Javascript
fix enabletransitiontracing flag
88574c1b8bd4ed187f09a9c91d327784fe50dbe8
<ide><path>packages/react-noop-renderer/src/createReactNoop.js <ide> function createReactNoop(reconciler: Function, useMutation: boolean) { <ide> false, <ide> '', <ide> onRecoverableError, <add> null, <ide> ); <ide> roots.set(rootID, root); <ide> } <ide> function createReactNoop(reconciler: Function, useMutation: boolean) { <ide> false, <ide> '', <ide> onRecoverableError, <add> null, <ide> ); <ide> return { <ide> _Scheduler: Scheduler, <ide><path>packages/react-reconciler/src/ReactFiber.new.js <ide> export function createFiberFromLegacyHidden( <ide> const fiber = createFiber(LegacyHiddenComponent, pendingProps, key, mode); <ide> fiber.elementType = REACT_LEGACY_HIDDEN_TYPE; <ide> fiber.lanes = lanes; <add> // Adding a stateNode for legacy hidden because it's currently using <add> // the offscreen implementation, which depends on a state node <add> fiber.stateNode = {}; <ide> return fiber; <ide> } <ide> <ide><path>packages/react-reconciler/src/ReactFiber.old.js <ide> export function createFiberFromLegacyHidden( <ide> const fiber = createFiber(LegacyHiddenComponent, pendingProps, key, mode); <ide> fiber.elementType = REACT_LEGACY_HIDDEN_TYPE; <ide> fiber.lanes = lanes; <add> // Adding a stateNode for legacy hidden because it's currently using <add> // the offscreen implementation, which depends on a state node <add> fiber.stateNode = {}; <ide> return fiber; <ide> } <ide> <ide><path>packages/react/index.classic.fb.js <ide> export { <ide> startTransition, <ide> startTransition as unstable_startTransition, // TODO: Remove once call sights updated to startTransition <ide> unstable_Cache, <add> unstable_TracingMarker, <ide> unstable_DebugTracingMode, <ide> unstable_LegacyHidden, <ide> unstable_Offscreen, <ide><path>packages/shared/forks/ReactFeatureFlags.www.js <ide> export const { <ide> enableSyncDefaultUpdates, <ide> enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay, <ide> enableClientRenderFallbackOnTextMismatch, <add> enableTransitionTracing, <ide> } = dynamicFeatureFlags; <ide> <ide> // On WWW, __EXPERIMENTAL__ is used for a new modern build. <ide> export const enableUseMutableSource = true; <ide> <ide> export const enableCustomElementPropertySupport = __EXPERIMENTAL__; <ide> <del>export const enableTransitionTracing = false; <del> <ide> export const enableSymbolFallbackForWWW = true; <ide> // Flow magic to verify the exports of this file match the original version. <ide> // eslint-disable-next-line no-unused-vars
5
Javascript
Javascript
ignore babelrc in git-upgrade
b4a8630ea59bbc4a2b384c6e88dc5fd82ee5ee5a
<ide><path>react-native-git-upgrade/cli.js <ide> 'use strict'; <ide> <ide> require('babel-register')({ <add> babelrc: false, <ide> presets: [ <ide> require('babel-preset-es2015-node'), <ide> require('babel-preset-stage-3'),
1
Ruby
Ruby
convert time to string
dba022f3a9f1c0e256ae290ffffd332f7a9fd250
<ide><path>activerecord/test/cases/migration_test.rb <ide> def test_migrator_versions <ide> assert_equal m0_fingerprint, rows[0]["fingerprint"] <ide> assert_equal "valid_people_have_last_names", rows[0]["name"] <ide> rows.each do |row| <del> assert_match(/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/, row["migrated_at"], "missing migrated_at") <add> assert_match(/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/, row["migrated_at"].to_s, "missing migrated_at") # sometimes a String, sometimes a Time <ide> end <ide> <ide> ActiveRecord::Migrator.down(MIGRATIONS_ROOT + "/valid") <ide><path>activerecord/test/cases/schema_migration_test.rb <ide> def test_add_metadata_columns_to_exisiting_schema_migrations <ide> <ide> rows = connection.select_all("SELECT * FROM #{connection.quote_table_name(sm_table_name)}") <ide> assert rows[0].has_key?("migrated_at"), "missing column `migrated_at`" <del> assert_match(/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/, rows[0]["migrated_at"]) <add> assert_match(/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/, rows[0]["migrated_at"].to_s) # sometimes a String, sometimes a Time <ide> assert rows[0].has_key?("fingerprint"), "missing column `fingerprint`" <ide> assert rows[0].has_key?("name"), "missing column `name`" <ide> end
2
PHP
PHP
fix whitespace and remove duplicate method calls
15c94dee4dbab5a5e1710e980f20b47509e392bb
<ide><path>lib/Cake/Model/Permission.php <ide> public function getAclLink($aro, $aco) { <ide> if (empty($obj['Aro']) || empty($obj['Aco'])) { <ide> return false; <ide> } <add> $aro = Hash::extract($obj, 'Aro.0.' . $this->Aro->alias . '.id'); <add> $aco = Hash::extract($obj, 'Aco.0.' . $this->Aco->alias . '.id'); <add> $aro = current($aro); <add> $aco = current($aco); <ide> <ide> return array( <del> 'aro' => current(Hash::extract($obj, 'Aro.0.' . $this->Aro->alias . '.id')), <del> 'aco' => current(Hash::extract($obj, 'Aco.0.' . $this->Aco->alias . '.id')), <add> 'aro' => $aro, <add> 'aco' => $aco, <ide> 'link' => $this->find('all', array('conditions' => array( <del> $this->alias . '.aro_id' => current(Hash::extract($obj, 'Aro.0.' . $this->Aro->alias . '.id')), <del> $this->alias . '.aco_id' => current(Hash::extract($obj, 'Aco.0.' . $this->Aco->alias . '.id')) <add> $this->alias . '.aro_id' => $aro, <add> $this->alias . '.aco_id' => $aco <ide> ))) <ide> ); <ide> } <ide><path>lib/Cake/Test/Case/Utility/HashTest.php <ide> public function testSortNumeric() { <ide> */ <ide> public function testSortNatural() { <ide> if (version_compare(PHP_VERSION, '5.4.0', '<')) { <del> $this->markTestSkipped('SORT_NATURAL is available since PHP 5.4.'); <del> } <add> $this->markTestSkipped('SORT_NATURAL is available since PHP 5.4.'); <add> } <ide> $items = array( <ide> array('Item' => array('image' => 'img1.jpg')), <ide> array('Item' => array('image' => 'img99.jpg')),
2
Javascript
Javascript
get client app to work on edge
cc6e1fdbf45aa467261a53c1bdf3a68486a1601f
<ide><path>client/src/client/frame-runner.js <ide> import jQuery from 'jquery'; <ide> <ide> window.$ = jQuery; <ide> <del>const testId = 'fcc-test-frame'; <del>if (window.frameElement && window.frameElement.id === testId) { <del> document.addEventListener('DOMContentLoaded', initTestFrame); <del>} <del> <del>// For tests in CI. <ide> document.__initTestFrame = initTestFrame; <ide> <del>async function initTestFrame() { <del> const code = (document.__source || '').slice(0); <del> if (!document.__getUserInput) { <del> document.__getUserInput = () => code; <add>async function initTestFrame(e = {}) { <add> const code = (e.code || '').slice(0); <add> if (!e.getUserInput) { <add> e.getUserInput = () => code; <ide> } <ide> <ide> /* eslint-disable no-unused-vars */ <ide> async function initTestFrame() { <ide> /* eslint-enable no-unused-vars */ <ide> <ide> let Enzyme; <del> if (document.__loadEnzyme) { <add> if (e.loadEnzyme) { <ide> let Adapter16; <ide> /* eslint-disable no-inline-comments */ <ide> [{ default: Enzyme }, { default: Adapter16 }] = await Promise.all([ <ide> async function initTestFrame() { <ide> // eslint-disable-next-line no-eval <ide> const test = eval(testString); <ide> if (typeof test === 'function') { <del> await test(document.__getUserInput); <add> await test(e.getUserInput); <ide> } <ide> return { pass: true }; <ide> } catch (err) { <ide> async function initTestFrame() { <ide> }; <ide> } <ide> }; <del> <del> // notify that the window methods are ready to run <del> document.__frameReady(); <ide> } <ide><path>client/src/client/workers/sass-compile.js <del>// eslint-disable-next-line no-undef <del>importScripts('/js/sass.sync.js'); <add>// work around for SASS error in Edge <add>// https://github.com/medialize/sass.js/issues/96#issuecomment-424386171 <add>if (!self.crypto) { <add> self.crypto = { <add> getRandomValues: function(array) { <add> for (var i = 0, l = array.length; i < l; i++) { <add> array[i] = Math.floor(Math.random() * 256); <add> } <add> return array; <add> } <add> }; <add>} <add> <add>self.importScripts('/js/sass.sync.js'); <ide> <ide> self.onmessage = e => { <ide> const data = e.data; <ide> self.onmessage = e => { <ide> } <ide> }); <ide> }; <add> <add>self.postMessage({ type: 'contentLoaded' }); <ide><path>client/src/client/workers/test-evaluator.js <ide> self.onmessage = async e => { <ide> } <ide> } <ide> }; <add> <add>self.postMessage({ type: 'contentLoaded' }); <ide><path>client/src/templates/Challenges/components/CompletionModal.js <ide> const propTypes = { <ide> }; <ide> <ide> export class CompletionModal extends Component { <add> state = { <add> downloadURL: null <add> }; <add> <add> static getDerivedStateFromProps(props, state) { <add> const { files, isOpen } = props; <add> if (!isOpen) { <add> return null; <add> } <add> const { downloadURL } = state; <add> if (downloadURL) { <add> URL.revokeObjectURL(downloadURL); <add> } <add> let newURL = null; <add> if (Object.keys(files).length) { <add> const filesForDownload = Object.keys(files) <add> .map(key => files[key]) <add> .reduce( <add> (allFiles, { path, contents }) => ({ <add> ...allFiles, <add> [path]: contents <add> }), <add> {} <add> ); <add> const blob = new Blob([JSON.stringify(filesForDownload, null, 2)], { <add> type: 'text/json' <add> }); <add> newURL = URL.createObjectURL(blob); <add> } <add> return { downloadURL: newURL }; <add> } <add> <add> componentWillUnmount() { <add> if (this.state.downloadURL) { <add> URL.revokeObjectURL(this.state.downloadURL); <add> } <add> } <add> <ide> render() { <ide> const { <ide> close, <ide> isOpen, <ide> submitChallenge, <ide> handleKeypress, <ide> message, <del> files = {}, <ide> title <ide> } = this.props; <ide> if (isOpen) { <ide> ga.modalview('/completion-modal'); <ide> } <del> const showDownloadButton = Object.keys(files).length; <del> const filesForDownload = Object.keys(files) <del> .map(key => files[key]) <del> .reduce( <del> (allFiles, { path, contents }) => ({ <del> ...allFiles, <del> [path]: contents <del> }), <del> {} <del> ); <ide> const dashedName = dasherize(title); <ide> return ( <ide> <Modal <ide> export class CompletionModal extends Component { <ide> bsStyle='primary' <ide> onClick={submitChallenge} <ide> > <del> Submit and go to next challenge <span className='hidden-xs'>(Ctrl + Enter)</span> <add> Submit and go to next challenge{' '} <add> <span className='hidden-xs'>(Ctrl + Enter)</span> <ide> </Button> <del> {showDownloadButton ? ( <add> {this.state.downloadURL ? ( <ide> <Button <ide> block={true} <ide> bsSize='lg' <ide> bsStyle='primary' <ide> className='btn-primary-invert' <ide> download={`${dashedName}.json`} <del> href={`data:text/json;charset=utf-8,${encodeURIComponent( <del> JSON.stringify(filesForDownload) <del> )}`} <add> href={this.state.downloadURL} <ide> > <ide> Download my solution <ide> </Button> <ide> export class CompletionModal extends Component { <ide> CompletionModal.displayName = 'CompletionModal'; <ide> CompletionModal.propTypes = propTypes; <ide> <del>export default connect(mapStateToProps, mapDispatchToProps)(CompletionModal); <add>export default connect( <add> mapStateToProps, <add> mapDispatchToProps <add>)(CompletionModal); <ide><path>client/src/templates/Challenges/utils/frame.js <ide> const buildProxyConsole = proxyLogger => ctx => { <ide> return ctx; <ide> }; <ide> <del>const writeTestDepsToDocument = frameReady => ctx => { <del> const { sources, loadEnzyme } = ctx; <del> // default for classic challenges <del> // should not be used for modern <del> ctx.document.__source = sources && 'index' in sources ? sources['index'] : ''; <del> // provide the file name and get the original source <del> ctx.document.__getUserInput = fileName => toString(sources[fileName]); <del> ctx.document.__frameReady = frameReady; <del> ctx.document.__loadEnzyme = loadEnzyme; <add>const initTestFrame = frameReady => ctx => { <add> const contentLoaded = new Promise(resolve => { <add> if (ctx.document.readyState === 'loading') { <add> ctx.document.addEventListener('DOMContentLoaded', resolve); <add> } else { <add> resolve(); <add> } <add> }); <add> contentLoaded.then(async() => { <add> const { sources, loadEnzyme } = ctx; <add> // default for classic challenges <add> // should not be used for modern <add> const code = sources && 'index' in sources ? sources['index'] : ''; <add> // provide the file name and get the original source <add> const getUserInput = fileName => toString(sources[fileName]); <add> await ctx.document.__initTestFrame({ code, getUserInput, loadEnzyme }); <add> frameReady(); <add> }); <ide> return ctx; <ide> }; <ide> <ide> export const createTestFramer = (document, frameReady, proxyConsole) => <ide> flow( <ide> createFrame(document, testId), <ide> mountFrame(document), <del> writeTestDepsToDocument(frameReady), <add> writeContentToFrame, <ide> buildProxyConsole(proxyConsole), <del> writeContentToFrame <add> initTestFrame(frameReady) <ide> ); <ide><path>client/src/templates/Challenges/utils/worker-executor.js <ide> class WorkerExecutor { <ide> this.getWorker = this.getWorker.bind(this); <ide> } <ide> <del> getWorker() { <add> async getWorker() { <ide> if (this.worker === null) { <del> this.worker = new Worker(`${this.location}${this.workerName}.js`); <add> this.worker = await new Promise((resolve, reject) => { <add> const worker = new Worker(`${this.location}${this.workerName}.js`); <add> worker.onmessage = e => { <add> if (e.data && e.data.type && e.data.type === 'contentLoaded') { <add> resolve(worker); <add> } <add> }; <add> worker.onerror = e => reject(e.message); <add> }); <ide> } <ide> <ide> return this.worker; <ide> class WorkerExecutor { <ide> } <ide> } <ide> <del> execute(data, timeout = 1000) { <del> const worker = this.getWorker(); <add> async execute(data, timeout = 1000) { <add> const worker = await this.getWorker(); <ide> return new Promise((resolve, reject) => { <ide> // Handle timeout <ide> const timeoutId = setTimeout(() => { <ide><path>curriculum/test/test-challenges.js <ide> async function createTestRunnerForDOMChallenge( <ide> await context.setContent(build); <ide> await context.evaluate( <ide> async(sources, loadEnzyme) => { <del> document.__source = sources && 'index' in sources ? sources['index'] : ''; <del> document.__getUserInput = fileName => sources[fileName]; <del> document.__frameReady = () => {}; <del> document.__loadEnzyme = loadEnzyme; <del> await document.__initTestFrame(); <add> const code = sources && 'index' in sources ? sources['index'] : ''; <add> const getUserInput = fileName => sources[fileName]; <add> await document.__initTestFrame({ code, getUserInput, loadEnzyme }); <ide> }, <ide> sources, <ide> loadEnzyme
7
Python
Python
replace assertions with valueerror exeptions
fa4abdb3ea8860827e985dcbb59bf72ecb01b9eb
<ide><path>src/transformers/models/wav2vec2/convert_wav2vec2_original_pytorch_checkpoint_to_pytorch.py <ide> def set_recursively(hf_pointer, key, value, full_name, weight_type): <ide> else: <ide> hf_shape = hf_pointer.shape <ide> <del> assert ( <del> hf_shape == value.shape <del> ), f"Shape of hf {key + '.' + weight_type if weight_type is not None else ''} is {hf_shape}, but should be {value.shape} for {full_name}" <add> if hf_shape != value.shape: <add> raise ValueError( <add> f"Shape of hf {key + '.' + weight_type if weight_type is not None else ''} is {hf_shape}, but should be {value.shape} for {full_name}" <add> ) <ide> <ide> if weight_type == "weight": <ide> hf_pointer.weight.data = value <ide> def load_conv_layer(full_name, value, feature_extractor, unused_weights, use_gro <ide> <ide> if type_id == 0: <ide> if "bias" in name: <del> assert ( <del> value.shape == feature_extractor.conv_layers[layer_id].conv.bias.data.shape <del> ), f"{full_name} has size {value.shape}, but {feature_extractor.conv_layers[layer_id].conv.bias.data.shape} was found." <add> if value.shape != feature_extractor.conv_layers[layer_id].conv.bias.data.shape: <add> raise ValueError( <add> f"{full_name} has size {value.shape}, but {feature_extractor.conv_layers[layer_id].conv.bias.data.shape} was found." <add> ) <ide> feature_extractor.conv_layers[layer_id].conv.bias.data = value <ide> logger.info(f"Feat extract conv layer {layer_id} was initialized from {full_name}.") <ide> elif "weight" in name: <del> assert ( <del> value.shape == feature_extractor.conv_layers[layer_id].conv.weight.data.shape <del> ), f"{full_name} has size {value.shape}, but {feature_extractor.conv_layers[layer_id].conv.weight.data.shape} was found." <add> if value.shape == feature_extractor.conv_layers[layer_id].conv.weight.data.shape: <add> raise ValueError( <add> f"{full_name} has size {value.shape}, but {feature_extractor.conv_layers[layer_id].conv.weight.data.shape} was found." <add> ) <ide> feature_extractor.conv_layers[layer_id].conv.weight.data = value <ide> logger.info(f"Feat extract conv layer {layer_id} was initialized from {full_name}.") <ide> elif (type_id == 2 and not use_group_norm) or (type_id == 2 and layer_id == 0 and use_group_norm): <ide> if "bias" in name: <del> assert ( <del> value.shape == feature_extractor.conv_layers[layer_id].layer_norm.bias.data.shape <del> ), f"{full_name} has size {value.shape}, but {feature_extractor[layer_id].layer_norm.bias.data.shape} was found." <add> if value.shape != feature_extractor.conv_layers[layer_id].layer_norm.bias.data.shape: <add> raise ValueError( <add> f"{full_name} has size {value.shape}, but {feature_extractor[layer_id].layer_norm.bias.data.shape} was found." <add> ) <ide> feature_extractor.conv_layers[layer_id].layer_norm.bias.data = value <ide> logger.info(f"Feat extract layer norm weight of layer {layer_id} was initialized from {full_name}.") <ide> elif "weight" in name: <del> assert ( <del> value.shape == feature_extractor.conv_layers[layer_id].layer_norm.weight.data.shape <del> ), f"{full_name} has size {value.shape}, but {feature_extractor[layer_id].layer_norm.weight.data.shape} was found." <add> if value.shape != feature_extractor.conv_layers[layer_id].layer_norm.weight.data.shape: <add> raise ValueError( <add> f"{full_name} has size {value.shape}, but {feature_extractor[layer_id].layer_norm.weight.data.shape} was found." <add> ) <ide> feature_extractor.conv_layers[layer_id].layer_norm.weight.data = value <ide> logger.info(f"Feat extract layer norm weight of layer {layer_id} was initialized from {full_name}.") <ide> else:
1
Javascript
Javascript
handle helper paths
0a3cff6f74732213e90664b435dccd4dc8816072
<ide><path>threejs/resources/editor.js <ide> function getSourceBlob(htmlParts) { <ide> g.rootScriptInfo.source = htmlParts.js; <ide> makeBlobURLsForSources(g.rootScriptInfo); <ide> <del> const prefix = dirname(g.url); <add> const dname = dirname(g.url); <add> // HACK! for webgl-2d-vs... those examples are not in /webgl they're in /webgl/resources <add> // We basically assume url is https://foo/base/example.html so there will be 4 slashes <add> // If the path is longer than then we need '../' to back up so prefix works below <add> const prefix = `${dname}${dname.split('/').slice(4).map(() => '/..').join('')}`; <ide> let source = g.html; <ide> source = source.replace('${hackedParams}', JSON.stringify(g.query)); <ide> source = source.replace('${html}', htmlParts.html);
1
Javascript
Javascript
fix errors in children management
8f2d73d50bf4ce52bdc155db9c9d2da7306eb357
<ide><path>Libraries/Renderer/src/renderers/native/ReactNativeFiber.js <ide> const NativeRenderer = ReactFiberReconciler({ <ide> parentInstance: Instance | Container, <ide> child: Instance | TextInstance, <ide> ): void { <del> <del> const childTag = typeof child === 'number' <del> ? child <del> : child._nativeTag; <add> const childTag = typeof child === 'number' ? child : child._nativeTag; <ide> <ide> if (typeof parentInstance === 'number') { <ide> // Root container <ide> const NativeRenderer = ReactFiberReconciler({ <ide> } else { <ide> const children = parentInstance._children; <ide> <del> children.push(child); <add> const index = children.indexOf(child); <ide> <del> UIManager.manageChildren( <del> parentInstance._nativeTag, // containerTag <del> [], // moveFromIndices <del> [], // moveToIndices <del> [childTag], // addChildReactTags <del> [children.length - 1], // addAtIndices <del> [], // removeAtIndices <del> ); <add> if (index >= 0) { <add> children.splice(index, 1); <add> children.push(child); <add> <add> UIManager.manageChildren( <add> parentInstance._nativeTag, // containerTag <add> [index], // moveFromIndices <add> [children.length - 1], // moveToIndices <add> [], // addChildReactTags <add> [], // addAtIndices <add> [], // removeAtIndices <add> ); <add> } else { <add> children.push(child); <add> <add> UIManager.manageChildren( <add> parentInstance._nativeTag, // containerTag <add> [], // moveFromIndices <add> [], // moveToIndices <add> [childTag], // addChildReactTags <add> [children.length - 1], // addAtIndices <add> [], // removeAtIndices <add> ); <add> } <ide> } <ide> }, <ide> <ide> const NativeRenderer = ReactFiberReconciler({ <ide> <ide> const children = (parentInstance: any)._children; <ide> <del> const beforeChildIndex = children.indexOf(beforeChild); <ide> const index = children.indexOf(child); <ide> <ide> // Move existing child or add new child? <ide> if (index >= 0) { <ide> children.splice(index, 1); <add> const beforeChildIndex = children.indexOf(beforeChild); <ide> children.splice(beforeChildIndex, 0, child); <ide> <ide> UIManager.manageChildren( <ide> const NativeRenderer = ReactFiberReconciler({ <ide> [], // removeAtIndices <ide> ); <ide> } else { <add> const beforeChildIndex = children.indexOf(beforeChild); <ide> children.splice(beforeChildIndex, 0, child); <ide> <del> const childTag = typeof child === 'number' <del> ? child <del> : child._nativeTag; <add> const childTag = typeof child === 'number' ? child : child._nativeTag; <ide> <ide> UIManager.manageChildren( <ide> (parentInstance: any)._nativeTag, // containerID <ide> findNodeHandle.injection.injectFindNode((fiber: Fiber) => <ide> NativeRenderer.findHostInstance(fiber)); <ide> findNodeHandle.injection.injectFindRootNodeID(instance => instance); <ide> <del> <ide> // Intercept lifecycle errors and ensure they are shown with the correct stack <ide> // trace within the native redbox component. <ide> ReactFiberErrorLogger.injection.injectDialog(
1
Ruby
Ruby
indicate multiple named args in usage banner
cf654da251fff2d6487abaf6d4736161544a6772
<ide><path>Library/Homebrew/dev-cmd/bottle.rb <ide> module Homebrew <ide> def bottle_args <ide> Homebrew::CLI::Parser.new do <ide> usage_banner <<~EOS <del> `bottle` [<options>] <formula> <add> `bottle` [<options>] <formula> [<formula> ...] <ide> <ide> Generate a bottle (binary package) from a formula that was installed with <ide> `--build-bottle`. <ide><path>Library/Homebrew/dev-cmd/bump-unversioned-casks.rb <ide> module Homebrew <ide> def self.bump_unversioned_casks_args <ide> Homebrew::CLI::Parser.new do <ide> usage_banner <<~EOS <del> `bump-unversioned-casks` [<options>] [<cask>|<tap>] <add> `bump-unversioned-casks` [<options>] <cask>|<tap> [<cask>|<tap> ...] <ide> <ide> Check all casks with unversioned URLs in a given <tap> for updates. <ide> EOS <ide><path>Library/Homebrew/dev-cmd/bump.rb <ide> module Homebrew <ide> def bump_args <ide> Homebrew::CLI::Parser.new do <ide> usage_banner <<~EOS <del> `bump` [<options>] [<formula>] <add> `bump` [<options>] [<formula>] [<formula> ...] <ide> <ide> Display out-of-date brew formulae and the latest version available. <ide> Also displays whether a pull request has been opened with the URL. <ide><path>Library/Homebrew/dev-cmd/command.rb <ide> module Homebrew <ide> def command_args <ide> Homebrew::CLI::Parser.new do <ide> usage_banner <<~EOS <del> `command` <cmd> <add> `command` <cmd> [<cmd> ...] <ide> <ide> Display the path to the file being used when invoking `brew` <cmd>. <ide> EOS <ide><path>Library/Homebrew/dev-cmd/edit.rb <ide> module Homebrew <ide> def edit_args <ide> Homebrew::CLI::Parser.new do <ide> usage_banner <<~EOS <del> `edit` [<formula>|<cask>] <add> `edit` [<formula>|<cask>] [<formula>|<cask> ...] <ide> <ide> Open a <formula> or <cask> in the editor set by `EDITOR` or `HOMEBREW_EDITOR`, <ide> or open the Homebrew repository for editing if no formula is provided. <ide><path>Library/Homebrew/dev-cmd/formula.rb <ide> module Homebrew <ide> def formula_args <ide> Homebrew::CLI::Parser.new do <ide> usage_banner <<~EOS <del> `formula` <formula> <add> `formula` <formula> [<formula> ...] <ide> <ide> Display the path where <formula> is located. <ide> EOS <ide><path>Library/Homebrew/dev-cmd/irb.rb <ide> def irb_args <ide> switch "--pry", <ide> env: :pry, <ide> description: "Use Pry instead of IRB. Implied if `HOMEBREW_PRY` is set." <add> <add> named_args :none <ide> end <ide> end <ide> <ide><path>Library/Homebrew/dev-cmd/linkage.rb <ide> module Homebrew <ide> def linkage_args <ide> Homebrew::CLI::Parser.new do <ide> usage_banner <<~EOS <del> `linkage` [<options>] [<formula>] <add> `linkage` [<options>] [<formula>] [<formula> ...] <ide> <ide> Check the library links from the given <formula> kegs. If no <formula> are <ide> provided, check all kegs. Raises an error if run on uninstalled formulae. <ide><path>Library/Homebrew/dev-cmd/livecheck.rb <ide> module Homebrew <ide> def livecheck_args <ide> Homebrew::CLI::Parser.new do <ide> usage_banner <<~EOS <del> `livecheck` [<formulae>|<casks>] <add> `livecheck` [<formula>|<cask>] [<formula>|<cask> ...] <ide> <ide> Check for newer versions of formulae and/or casks from upstream. <ide> <ide><path>Library/Homebrew/dev-cmd/mirror.rb <ide> module Homebrew <ide> def mirror_args <ide> Homebrew::CLI::Parser.new do <ide> usage_banner <<~EOS <del> `mirror` <formula> <add> `mirror` <formula> [<formula> ...] <ide> <ide> Reupload the stable URL of a formula to Bintray for use as a mirror. <ide> EOS <ide><path>Library/Homebrew/dev-cmd/pr-publish.rb <ide> def pr_publish_args <ide> flag "--workflow=", <ide> description: "Target workflow filename (default: `publish-commit-bottles.yml`)." <ide> <del> named_args number: 1 <add> named_args min: 1 <ide> end <ide> end <ide> <ide><path>Library/Homebrew/dev-cmd/pr-pull.rb <ide> def pr_pull_args <ide> <ide> conflicts "--clean", "--autosquash" <ide> <del> named_args number: 1 <add> named_args min: 1 <ide> end <ide> end <ide> <ide><path>Library/Homebrew/dev-cmd/style.rb <ide> module Homebrew <ide> def style_args <ide> Homebrew::CLI::Parser.new do <ide> usage_banner <<~EOS <del> `style` [<options>] [<file>|<tap>|<formula>] <add> `style` [<options>] [<file>|<tap>|<formula>|<cask>] [<file>|<tap>|<formula>|<cask> ...] <ide> <ide> Check formulae or files for conformance to Homebrew style guidelines. <ide> <ide><path>Library/Homebrew/dev-cmd/test.rb <ide> module Homebrew <ide> def test_args <ide> Homebrew::CLI::Parser.new do <ide> usage_banner <<~EOS <del> `test` [<options>] <formula> <add> `test` [<options>] <formula> [<formula> ...] <ide> <ide> Run the test method provided by an installed formula. <ide> There is no standard output or return code, but generally it should notify the <ide><path>Library/Homebrew/dev-cmd/unbottled.rb <ide> module Homebrew <ide> def unbottled_args <ide> Homebrew::CLI::Parser.new do <ide> usage_banner <<~EOS <del> `unbottled` [<formula>] <add> `unbottled` [<formula>] [<formula> ...] <ide> <ide> Outputs the unbottled dependents of formulae. <ide> EOS <ide><path>Library/Homebrew/dev-cmd/unpack.rb <ide> module Homebrew <ide> def unpack_args <ide> Homebrew::CLI::Parser.new do <ide> usage_banner <<~EOS <del> `unpack` [<options>] <formula> <add> `unpack` [<options>] <formula> [<formula ...>] <ide> <ide> Unpack the source files for <formula> into subdirectories of the current <ide> working directory. <ide><path>Library/Homebrew/dev-cmd/update-python-resources.rb <ide> module Homebrew <ide> def update_python_resources_args <ide> Homebrew::CLI::Parser.new do <ide> usage_banner <<~EOS <del> `update-python-resources` [<options>] <formula> <add> `update-python-resources` [<options>] <formula> [<formula> ...] <ide> <ide> Update versions for PyPI resource blocks in <formula>. <ide> EOS <ide> def update_python_resources_args <ide> comma_array "--exclude-packages=", <ide> description: "Exclude these packages when finding resources." <ide> <del> named_args :formula, number: 1 <add> named_args :formula, min: 1 <ide> end <ide> end <ide>
17
Javascript
Javascript
implement accurate moment.duration({from, to})
621d98af101a1d6df7c946c133d555556acbc1ad
<ide><path>moment.js <ide> return (sign ? (forceSign ? '+' : '') : '-') + output; <ide> } <ide> <add> function positiveMomentsDifference(base, other) { <add> var res = {milliseconds: 0, months: 0}; <add> <add> res.months = other.month() - base.month() + <add> (other.year() - base.year()) * 12; <add> if (base.clone().add(res.months, 'M').isAfter(other)) { <add> -- res.months; <add> } <add> <add> res.milliseconds = +other - +(base.clone().add(res.months, 'M')); <add> <add> return res; <add> } <add> <add> function momentsDifference(base, other) { <add> var res; <add> other = makeAs(other, base); <add> if (base.isBefore(other)) { <add> res = positiveMomentsDifference(base, other); <add> } else { <add> res = positiveMomentsDifference(other, base); <add> res.milliseconds = - res.milliseconds; <add> res.months = - res.months; <add> } <add> <add> return res; <add> } <add> <ide> // helper function for _.addTime and _.subtractTime <ide> function addOrSubtractDurationFromMoment(mom, duration, isAdding, updateOffset) { <ide> var milliseconds = duration._milliseconds, <ide> match = null, <ide> sign, <ide> ret, <del> parseIso; <add> parseIso, <add> diffRes; <ide> <ide> if (moment.isDuration(input)) { <ide> duration = { <ide> s: parseIso(match[7]), <ide> w: parseIso(match[8]) <ide> }; <add> } else if (typeof duration === "object" && <add> ("from" in duration || "to" in duration)) { <add> diffRes = momentsDifference(moment(duration.from), moment(duration.to)); <add> <add> duration = {}; <add> duration.ms = diffRes.milliseconds; <add> duration.M = diffRes.months; <ide> } <ide> <ide> ret = new Duration(duration); <ide><path>test/moment/duration_from_moments.js <add>var moment = require("../../moment"); <add> <add>exports.duration_from_moments = { <add> setUp: function (done) { <add> moment.createFromInputFallback = function () { <add> throw new Error("input not handled by moment"); <add> }; <add> done(); <add> }, <add> <add> "pure year diff" : function (test) { <add> var m1 = moment("2012-01-01T00:00:00.000Z"), <add> m2 = moment("2013-01-01T00:00:00.000Z"); <add> <add> test.equal(moment.duration({from: m1, to: m2}).as("years"), 1, "year moment difference"); <add> test.equal(moment.duration({from: m2, to: m1}).as("years"), -1, "negative year moment difference"); <add> test.done(); <add> }, <add> <add> "month and day diff" : function (test) { <add> var m1 = moment("2012-01-15T00:00:00.000Z"), <add> m2 = moment("2012-02-17T00:00:00.000Z"), <add> d = moment.duration({from: m1, to: m2}); <add> <add> test.equal(d.get("days"), 2); <add> test.equal(d.get("months"), 1); <add> test.done(); <add> }, <add> <add> "day diff, separate months" : function (test) { <add> var m1 = moment("2012-01-15T00:00:00.000Z"), <add> m2 = moment("2012-02-13T00:00:00.000Z"), <add> d = moment.duration({from: m1, to: m2}); <add> <add> test.equal(d.as("days"), 29); <add> test.done(); <add> }, <add> <add> "hour diff" : function (test) { <add> var m1 = moment("2012-01-15T17:00:00.000Z"), <add> m2 = moment("2012-01-16T03:00:00.000Z"), <add> d = moment.duration({from: m1, to: m2}); <add> <add> test.equal(d.as("hours"), 10); <add> test.done(); <add> }, <add> <add> "minute diff" : function (test) { <add> var m1 = moment("2012-01-15T17:45:00.000Z"), <add> m2 = moment("2012-01-16T03:15:00.000Z"), <add> d = moment.duration({from: m1, to: m2}); <add> <add> test.equal(d.as("hours"), 9.5); <add> test.done(); <add> } <add>};
2
PHP
PHP
remove deprecated cookie, csrf components
2cfb801e10ed21502569ce5ab71debb6378dcdcb
<ide><path>src/Controller/Component/CookieComponent.php <del><?php <del>/** <del> * CakePHP(tm) : Rapid Development Framework (https://cakephp.org) <del> * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org) <del> * <del> * Licensed under The MIT License <del> * For full copyright and license information, please see the LICENSE.txt <del> * Redistributions of files must retain the above copyright notice. <del> * <del> * @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org) <del> * @link https://cakephp.org CakePHP(tm) Project <del> * @since 1.2.0 <del> * @license https://opensource.org/licenses/mit-license.php MIT License <del> */ <del>namespace Cake\Controller\Component; <del> <del>use Cake\Controller\Component; <del>use Cake\Http\ServerRequestFactory; <del>use Cake\I18n\Time; <del>use Cake\Utility\CookieCryptTrait; <del>use Cake\Utility\Hash; <del>use Cake\Utility\Security; <del> <del>/** <del> * Cookie Component. <del> * <del> * Provides enhanced cookie handling features for use in the controller layer. <del> * In addition to the basic features offered be Cake\Http\Response, this class lets you: <del> * <del> * - Create and read encrypted cookies. <del> * - Store non-scalar data. <del> * - Use hash compatible syntax to read/write/delete values. <del> * <del> * @link https://book.cakephp.org/3.0/en/controllers/components/cookie.html <del> * @deprecated 3.5.0 Use Cake\Http\Middleware\EncryptedCookieMiddleware and Cake\Http\Cookie\Cookie methods instead. <del> */ <del>class CookieComponent extends Component <del>{ <del> use CookieCryptTrait; <del> <del> /** <del> * Default config <del> * <del> * - `expires` - How long the cookies should last for. Defaults to 1 month. <del> * - `path` - The path on the server in which the cookie will be available on. <del> * If path is set to '/foo/', the cookie will only be available within the <del> * /foo/ directory and all sub-directories such as /foo/bar/ of domain. <del> * The default value is base path of app. For e.g. if your app is running <del> * under a subfolder "cakeapp" of document root the path would be "/cakeapp/" <del> * else it would be "/". <del> * - `domain` - The domain that the cookie is available. To make the cookie <del> * available on all subdomains of example.com set domain to '.example.com'. <del> * - `secure` - Indicates that the cookie should only be transmitted over a <del> * secure HTTPS connection. When set to true, the cookie will only be set if <del> * a secure connection exists. <del> * - `key` - Encryption key used when encrypted cookies are enabled. Defaults to Security.salt. <del> * - `httpOnly` - Set to true to make HTTP only cookies. Cookies that are HTTP only <del> * are not accessible in JavaScript. Default false. <del> * - `encryption` - Type of encryption to use. Defaults to 'aes'. <del> * <del> * @var array <del> */ <del> protected $_defaultConfig = [ <del> 'path' => null, <del> 'domain' => '', <del> 'secure' => false, <del> 'key' => null, <del> 'httpOnly' => false, <del> 'encryption' => 'aes', <del> 'expires' => '+1 month', <del> ]; <del> <del> /** <del> * Config specific to a given top level key name. <del> * <del> * The values in this array are merged with the general config <del> * to generate the configuration for a given top level cookie name. <del> * <del> * @var array <del> */ <del> protected $_keyConfig = []; <del> <del> /** <del> * Values stored in the cookie. <del> * <del> * Accessed in the controller using $this->Cookie->read('Name.key'); <del> * <del> * @var array <del> */ <del> protected $_values = []; <del> <del> /** <del> * A map of keys that have been loaded. <del> * <del> * Since CookieComponent lazily reads cookie data, <del> * we need to track which cookies have been read to account for <del> * read, delete, read patterns. <del> * <del> * @var array <del> */ <del> protected $_loaded = []; <del> <del> /** <del> * A reference to the Controller's Cake\Http\Response object. <del> * Currently unused. <del> * <del> * @var \Cake\Http\Response|null <del> * @deprecated 3.4.0 Will be removed in 4.0.0 <del> */ <del> protected $_response; <del> <del> /** <del> * Initialize config data and properties. <del> * <del> * @param array $config The config data. <del> * @return void <del> */ <del> public function initialize(array $config) <del> { <del> if (!$this->_config['key']) { <del> $this->setConfig('key', Security::getSalt()); <del> } <del> <del> $controller = $this->_registry->getController(); <del> <del> if ($controller === null) { <del> $this->request = ServerRequestFactory::fromGlobals(); <del> } <del> <del> if (empty($this->_config['path'])) { <del> $this->setConfig('path', $this->request->getAttribute('webroot')); <del> } <del> } <del> <del> /** <del> * Set the configuration for a specific top level key. <del> * <del> * ### Examples: <del> * <del> * Set a single config option for a key: <del> * <del> * ``` <del> * $this->Cookie->configKey('User', 'expires', '+3 months'); <del> * ``` <del> * <del> * Set multiple options: <del> * <del> * ``` <del> * $this->Cookie->configKey('User', [ <del> * 'expires', '+3 months', <del> * 'httpOnly' => true, <del> * ]); <del> * ``` <del> * <del> * @param string $keyname The top level keyname to configure. <del> * @param null|string|array $option Either the option name to set, or an array of options to set, <del> * or null to read config options for a given key. <del> * @param string|null $value Either the value to set, or empty when $option is an array. <del> * @return array|null <del> */ <del> public function configKey($keyname, $option = null, $value = null) <del> { <del> if ($option === null) { <del> $default = $this->_config; <del> $local = isset($this->_keyConfig[$keyname]) ? $this->_keyConfig[$keyname] : []; <del> <del> return $local + $default; <del> } <del> if (!is_array($option)) { <del> $option = [$option => $value]; <del> } <del> $this->_keyConfig[$keyname] = $option; <del> <del> return null; <del> } <del> <del> /** <del> * Events supported by this component. <del> * <del> * @return array <del> */ <del> public function implementedEvents() <del> { <del> return []; <del> } <del> <del> /** <del> * Write a value to the response cookies. <del> * <del> * You must use this method before any output is sent to the browser. <del> * Failure to do so will result in header already sent errors. <del> * <del> * @param string|array $key Key for the value <del> * @param mixed $value Value <del> * @return void <del> */ <del> public function write($key, $value = null) <del> { <del> if (!is_array($key)) { <del> $key = [$key => $value]; <del> } <del> <del> $keys = []; <del> foreach ($key as $name => $value) { <del> $this->_load($name); <del> <del> $this->_values = Hash::insert($this->_values, $name, $value); <del> $parts = explode('.', $name); <del> $keys[] = $parts[0]; <del> } <del> <del> foreach ($keys as $name) { <del> $this->_write($name, $this->_values[$name]); <del> } <del> } <del> <del> /** <del> * Read the value of key path from request cookies. <del> * <del> * This method will also allow you to read cookies that have been written in this <del> * request, but not yet sent to the client. <del> * <del> * @param string|null $key Key of the value to be obtained. <del> * @return string or null, value for specified key <del> */ <del> public function read($key = null) <del> { <del> $this->_load($key); <del> <del> return Hash::get($this->_values, $key); <del> } <del> <del> /** <del> * Load the cookie data from the request and response objects. <del> * <del> * Based on the configuration data, cookies will be decrypted. When cookies <del> * contain array data, that data will be expanded. <del> * <del> * @param string|array $key The key to load. <del> * @return void <del> */ <del> protected function _load($key) <del> { <del> $parts = explode('.', $key); <del> $first = array_shift($parts); <del> if (isset($this->_loaded[$first])) { <del> return; <del> } <del> $cookie = $this->request->getCookie($first); <del> if ($cookie === null) { <del> return; <del> } <del> $config = $this->configKey($first); <del> $this->_loaded[$first] = true; <del> $this->_values[$first] = $this->_decrypt($cookie, $config['encryption'], $config['key']); <del> } <del> <del> /** <del> * Returns true if given key is set in the cookie. <del> * <del> * @param string|null $key Key to check for <del> * @return bool True if the key exists <del> */ <del> public function check($key = null) <del> { <del> if (empty($key)) { <del> return false; <del> } <del> <del> return $this->read($key) !== null; <del> } <del> <del> /** <del> * Delete a cookie value <del> * <del> * You must use this method before any output is sent to the browser. <del> * Failure to do so will result in header already sent errors. <del> * <del> * Deleting a top level key will delete all keys nested within that key. <del> * For example deleting the `User` key, will also delete `User.email`. <del> * <del> * @param string $key Key of the value to be deleted <del> * @return void <del> */ <del> public function delete($key) <del> { <del> $this->_load($key); <del> <del> $this->_values = Hash::remove($this->_values, $key); <del> $parts = explode('.', $key); <del> $top = $parts[0]; <del> <del> if (isset($this->_values[$top])) { <del> $this->_write($top, $this->_values[$top]); <del> } else { <del> $this->_delete($top); <del> } <del> } <del> <del> /** <del> * Set cookie <del> * <del> * @param string $name Name for cookie <del> * @param string $value Value for cookie <del> * @return void <del> */ <del> protected function _write($name, $value) <del> { <del> $config = $this->configKey($name); <del> $expires = new Time($config['expires']); <del> <del> $controller = $this->getController(); <del> $controller->response = $controller->response->withCookie($name, [ <del> 'value' => $this->_encrypt($value, $config['encryption'], $config['key']), <del> 'expire' => $expires->format('U'), <del> 'path' => $config['path'], <del> 'domain' => $config['domain'], <del> 'secure' => (bool)$config['secure'], <del> 'httpOnly' => (bool)$config['httpOnly'] <del> ]); <del> } <del> <del> /** <del> * Sets a cookie expire time to remove cookie value. <del> * <del> * This is only done once all values in a cookie key have been <del> * removed with delete. <del> * <del> * @param string $name Name of cookie <del> * @return void <del> */ <del> protected function _delete($name) <del> { <del> $config = $this->configKey($name); <del> $expires = new Time('now'); <del> $controller = $this->getController(); <del> <del> $controller->response = $controller->response->withCookie($name, [ <del> 'value' => '', <del> 'expire' => $expires->format('U') - 42000, <del> 'path' => $config['path'], <del> 'domain' => $config['domain'], <del> 'secure' => $config['secure'], <del> 'httpOnly' => $config['httpOnly'] <del> ]); <del> } <del> <del> /** <del> * Returns the encryption key to be used. <del> * <del> * @return string <del> */ <del> protected function _getCookieEncryptionKey() <del> { <del> return $this->_config['key']; <del> } <del>} <ide><path>src/Controller/Component/CsrfComponent.php <del><?php <del>/** <del> * CakePHP(tm) : Rapid Development Framework (https://cakephp.org) <del> * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org) <del> * <del> * Licensed under The MIT License <del> * For full copyright and license information, please see the LICENSE.txt <del> * Redistributions of files must retain the above copyright notice. <del> * <del> * @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org) <del> * @link https://cakephp.org CakePHP(tm) Project <del> * @since 3.0.0 <del> * @license https://opensource.org/licenses/mit-license.php MIT License <del> */ <del>namespace Cake\Controller\Component; <del> <del>use Cake\Controller\Component; <del>use Cake\Event\Event; <del>use Cake\Http\Exception\InvalidCsrfTokenException; <del>use Cake\Http\Response; <del>use Cake\Http\ServerRequest; <del>use Cake\I18n\Time; <del>use Cake\Utility\Security; <del> <del>/** <del> * Provides CSRF protection & validation. <del> * <del> * This component adds a CSRF token to a cookie. The cookie value is compared to <del> * request data, or the X-CSRF-Token header on each PATCH, POST, <del> * PUT, or DELETE request. <del> * <del> * If the request data is missing or does not match the cookie data, <del> * an InvalidCsrfTokenException will be raised. <del> * <del> * This component integrates with the FormHelper automatically and when <del> * used together your forms will have CSRF tokens automatically added <del> * when `$this->Form->create(...)` is used in a view. <del> * <del> * @deprecated 3.5.0 Use Cake\Http\Middleware\CsrfProtectionMiddleware instead. <del> */ <del>class CsrfComponent extends Component <del>{ <del> <del> /** <del> * Default config for the CSRF handling. <del> * <del> * - cookieName = The name of the cookie to send. <del> * - expiry = How long the CSRF token should last. Defaults to browser session. <del> * - secure = Whether or not the cookie will be set with the Secure flag. Defaults to false. <del> * - httpOnly = Whether or not the cookie will be set with the HttpOnly flag. Defaults to false. <del> * - field = The form field to check. Changing this will also require configuring <del> * FormHelper. <del> * <del> * @var array <del> */ <del> protected $_defaultConfig = [ <del> 'cookieName' => 'csrfToken', <del> 'expiry' => 0, <del> 'secure' => false, <del> 'httpOnly' => false, <del> 'field' => '_csrfToken', <del> ]; <del> <del> /** <del> * Startup callback. <del> * <del> * Validates the CSRF token for POST data. If <del> * the request is a GET request, and the cookie value is absent a cookie will be set. <del> * <del> * Once a cookie is set it will be copied into request->getParam('_csrfToken') <del> * so that application and framework code can easily access the csrf token. <del> * <del> * RequestAction requests do not get checked, nor will <del> * they set a cookie should it be missing. <del> * <del> * @param \Cake\Event\Event $event Event instance. <del> * @return void <del> */ <del> public function startup(Event $event) <del> { <del> /** @var \Cake\Controller\Controller $controller */ <del> $controller = $event->getSubject(); <del> $request = $controller->request; <del> $response = $controller->response; <del> $cookieName = $this->_config['cookieName']; <del> <del> $cookieData = $request->getCookie($cookieName); <del> if ($cookieData) { <del> $request = $request->withParam('_csrfToken', $cookieData); <del> } <del> <del> if ($request->is('requested')) { <del> $controller->request = $request; <del> <del> return; <del> } <del> <del> if ($request->is('get') && $cookieData === null) { <del> list($request, $response) = $this->_setCookie($request, $response); <del> $controller->response = $response; <del> } <del> if ($request->is(['put', 'post', 'delete', 'patch']) || $request->getData()) { <del> $this->_validateToken($request); <del> $request = $request->withoutData($this->_config['field']); <del> } <del> $controller->request = $request; <del> } <del> <del> /** <del> * Events supported by this component. <del> * <del> * @return array <del> */ <del> public function implementedEvents() <del> { <del> return [ <del> 'Controller.startup' => 'startup', <del> ]; <del> } <del> <del> /** <del> * Set the cookie in the response. <del> * <del> * Also sets the request->params['_csrfToken'] so the newly minted <del> * token is available in the request data. <del> * <del> * @param \Cake\Http\ServerRequest $request The request object. <del> * @param \Cake\Http\Response $response The response object. <del> * @return array An array of the modified request, response. <del> */ <del> protected function _setCookie(ServerRequest $request, Response $response) <del> { <del> $expiry = new Time($this->_config['expiry']); <del> $value = hash('sha512', Security::randomBytes(16), false); <del> <del> $request = $request->withParam('_csrfToken', $value); <del> $response = $response->withCookie($this->_config['cookieName'], [ <del> 'value' => $value, <del> 'expire' => $expiry->format('U'), <del> 'path' => $request->getAttribute('webroot'), <del> 'secure' => $this->_config['secure'], <del> 'httpOnly' => $this->_config['httpOnly'], <del> ]); <del> <del> return [$request, $response]; <del> } <del> <del> /** <del> * Validate the request data against the cookie token. <del> * <del> * @param \Cake\Http\ServerRequest $request The request to validate against. <del> * @throws \Cake\Http\Exception\InvalidCsrfTokenException when the CSRF token is invalid or missing. <del> * @return void <del> */ <del> protected function _validateToken(ServerRequest $request) <del> { <del> $cookie = $request->getCookie($this->_config['cookieName']); <del> $post = $request->getData($this->_config['field']); <del> $header = $request->getHeaderLine('X-CSRF-Token'); <del> <del> if (!$cookie) { <del> throw new InvalidCsrfTokenException(__d('cake', 'Missing CSRF token cookie')); <del> } <del> <del> if (!Security::constantEquals($post, $cookie) && !Security::constantEquals($header, $cookie)) { <del> throw new InvalidCsrfTokenException(__d('cake', 'CSRF token mismatch.')); <del> } <del> } <del>} <ide><path>tests/TestCase/Controller/Component/CookieComponentTest.php <del><?php <del>/** <del> * CakePHP(tm) : Rapid Development Framework (https://cakephp.org) <del> * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org) <del> * <del> * Licensed under The MIT License <del> * For full copyright and license information, please see the LICENSE.txt <del> * Redistributions of files must retain the above copyright notice <del> * <del> * @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org) <del> * @link https://cakephp.org CakePHP(tm) Project <del> * @since 1.2.0 <del> * @license https://opensource.org/licenses/mit-license.php MIT License <del> */ <del>namespace Cake\Test\TestCase\Controller\Component; <del> <del>use Cake\Controller\ComponentRegistry; <del>use Cake\Controller\Component\CookieComponent; <del>use Cake\Http\Response; <del>use Cake\Http\ServerRequest; <del>use Cake\I18n\Time; <del>use Cake\TestSuite\TestCase; <del>use Cake\Utility\Security; <del> <del>/** <del> * CookieComponentTest class <del> */ <del>class CookieComponentTest extends TestCase <del>{ <del> <del> /** <del> * @var \Cake\Controller\Component\CookieComponent <del> */ <del> protected $Cookie; <del> <del> /** <del> * start <del> * <del> * @return void <del> */ <del> public function setUp() <del> { <del> parent::setUp(); <del> $controller = $this->getMockBuilder('Cake\Controller\Controller') <del> ->setMethods(['redirect']) <del> ->setConstructorArgs([new ServerRequest(), new Response()]) <del> ->getMock(); <del> $controller->loadComponent('Cookie'); <del> $this->Controller = $controller; <del> $this->Cookie = $controller->Cookie; <del> $this->request = $controller->request; <del> <del> $this->Cookie->setConfig([ <del> 'expires' => '+10 seconds', <del> 'path' => '/', <del> 'domain' => '', <del> 'secure' => false, <del> 'key' => 'somerandomhaskeysomerandomhaskey', <del> 'encryption' => false, <del> ]); <del> } <del> <del> /** <del> * Test setting config per key. <del> * <del> * @return void <del> */ <del> public function testConfigKey() <del> { <del> $this->Cookie->configKey('User', 'expires', '+3 days'); <del> $result = $this->Cookie->configKey('User'); <del> $expected = [ <del> 'expires' => '+3 days', <del> 'path' => '/', <del> 'domain' => '', <del> 'key' => 'somerandomhaskeysomerandomhaskey', <del> 'secure' => false, <del> 'httpOnly' => false, <del> 'encryption' => false, <del> ]; <del> $this->assertEquals($expected, $result); <del> } <del> <del> /** <del> * Test setting config per key. <del> * <del> * @return void <del> */ <del> public function testConfigKeyArray() <del> { <del> $this->Cookie->configKey('User', [ <del> 'expires' => '+3 days', <del> 'path' => '/shop' <del> ]); <del> $result = $this->Cookie->configKey('User'); <del> $expected = [ <del> 'expires' => '+3 days', <del> 'path' => '/shop', <del> 'domain' => '', <del> 'key' => 'somerandomhaskeysomerandomhaskey', <del> 'secure' => false, <del> 'httpOnly' => false, <del> 'encryption' => false, <del> ]; <del> $this->assertEquals($expected, $result); <del> } <del> <del> /** <del> * Test backwards compatibility with settings that use type juggling. <del> * <del> * @return void <del> */ <del> public function testSettingsCompatibility() <del> { <del> $this->Cookie->setConfig([ <del> 'expires' => '+10 seconds', <del> 'path' => '/', <del> 'domain' => '', <del> 'secure' => 0, <del> 'key' => 'somerandomhaskeysomerandomhaskey', <del> 'encryption' => 0, <del> ]); <del> $this->Cookie->write('key', 'value'); <del> $this->assertSame('value', $this->Cookie->read('key')); <del> } <del> <del> /** <del> * sets up some default cookie data. <del> * <del> * @return void <del> */ <del> protected function _setCookieData() <del> { <del> $this->Cookie->write(['Encrypted_array' => ['name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!']]); <del> $this->Cookie->write(['Encrypted_multi_cookies.name' => 'CakePHP']); <del> $this->Cookie->write(['Encrypted_multi_cookies.version' => '1.2.0.x']); <del> $this->Cookie->write(['Encrypted_multi_cookies.tag' => 'CakePHP Rocks!']); <del> <del> $this->Cookie->write(['Plain_array' => ['name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!']], null, false); <del> $this->Cookie->write(['Plain_multi_cookies.name' => 'CakePHP'], null, false); <del> $this->Cookie->write(['Plain_multi_cookies.version' => '1.2.0.x'], null, false); <del> $this->Cookie->write(['Plain_multi_cookies.tag' => 'CakePHP Rocks!'], null, false); <del> } <del> <del> /** <del> * test that initialize sets settings from components array <del> * <del> * @return void <del> */ <del> public function testSettings() <del> { <del> $settings = [ <del> 'time' => '5 days', <del> 'path' => '/' <del> ]; <del> $Cookie = new CookieComponent(new ComponentRegistry(), $settings); <del> $this->assertEquals($Cookie->getConfig('time'), $settings['time']); <del> $this->assertEquals($Cookie->getConfig('path'), $settings['path']); <del> } <del> <del> /** <del> * Test read when an invalid cipher is configured. <del> * <del> * @return void <del> */ <del> public function testReadInvalidCipher() <del> { <del> $this->expectException(\RuntimeException::class); <del> $this->expectExceptionMessage('Invalid encryption cipher. Must be one of aes.'); <del> $this->Controller->request = $this->request->withCookieParams([ <del> 'Test' => $this->_encrypt('value'), <del> ]); <del> $this->Cookie->setConfig('encryption', 'derp'); <del> $this->Cookie->read('Test'); <del> } <del> <del> /** <del> * testReadEncryptedCookieData <del> * <del> * @return void <del> */ <del> public function testReadEncryptedCookieData() <del> { <del> $this->_setCookieData(); <del> $data = $this->Cookie->read('Encrypted_array'); <del> $expected = ['name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!']; <del> $this->assertEquals($expected, $data); <del> <del> $data = $this->Cookie->read('Encrypted_multi_cookies'); <del> $expected = ['name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!']; <del> $this->assertEquals($expected, $data); <del> } <del> <del> /** <del> * testReadPlainCookieData <del> * <del> * @return void <del> */ <del> public function testReadPlainCookieData() <del> { <del> $this->_setCookieData(); <del> $data = $this->Cookie->read('Plain_array'); <del> $expected = ['name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!']; <del> $this->assertEquals($expected, $data); <del> <del> $data = $this->Cookie->read('Plain_multi_cookies'); <del> $expected = ['name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!']; <del> $this->assertEquals($expected, $data); <del> } <del> <del> /** <del> * test read() after switching the cookie name. <del> * <del> * @return void <del> */ <del> public function testReadMultipleNames() <del> { <del> $this->Controller->request = $this->request->withCookieParams([ <del> 'CakeCookie' => [ <del> 'key' => 'value' <del> ], <del> 'OtherCookie' => [ <del> 'key' => 'other value' <del> ] <del> ]); <del> $this->assertEquals('value', $this->Cookie->read('CakeCookie.key')); <del> $this->assertEquals(['key' => 'value'], $this->Cookie->read('CakeCookie')); <del> $this->assertEquals('other value', $this->Cookie->read('OtherCookie.key')); <del> } <del> <del> /** <del> * test a simple write() <del> * <del> * @return void <del> */ <del> public function testWriteSimple() <del> { <del> $this->Cookie->write('Testing', 'value'); <del> $result = $this->Cookie->read('Testing'); <del> <del> $this->assertEquals('value', $result); <del> } <del> <del> /** <del> * Test write when an invalid cipher is configured. <del> * <del> * @return void <del> */ <del> public function testWriteInvalidCipher() <del> { <del> $this->expectException(\RuntimeException::class); <del> $this->expectExceptionMessage('Invalid encryption cipher. Must be one of aes.'); <del> $this->Cookie->setConfig('encryption', 'derp'); <del> $this->Cookie->write('Test', 'nope'); <del> } <del> <del> /** <del> * Test writes don't omit request data from being read. <del> * <del> * @return void <del> */ <del> public function testWriteThanRead() <del> { <del> $this->Controller->request = $this->request->withCookieParams([ <del> 'User' => ['name' => 'mark'] <del> ]); <del> $this->Cookie->write('Testing', 'value'); <del> $this->assertEquals('mark', $this->Cookie->read('User.name')); <del> } <del> <del> /** <del> * test write() encrypted data with falsey value <del> * <del> * @return void <del> */ <del> public function testWriteWithFalseyValue() <del> { <del> $this->Cookie->setConfig([ <del> 'encryption' => 'aes', <del> 'key' => 'qSI232qs*&sXOw!adre@34SAv!@*(XSL#$%)asGb$@11~_+!@#HKis~#^', <del> ]); <del> <del> $this->Cookie->write('Testing'); <del> $result = $this->Cookie->read('Testing'); <del> $this->assertNull($result); <del> <del> $this->Cookie->write('Testing', ''); <del> $result = $this->Cookie->read('Testing'); <del> $this->assertEquals('', $result); <del> <del> $this->Cookie->write('Testing', false); <del> $result = $this->Cookie->read('Testing'); <del> $this->assertFalse($result); <del> <del> $this->Cookie->write('Testing', 1); <del> $result = $this->Cookie->read('Testing'); <del> $this->assertEquals(1, $result); <del> <del> $this->Cookie->write('Testing', '0'); <del> $result = $this->Cookie->read('Testing'); <del> $this->assertSame('0', $result); <del> <del> $this->Cookie->write('Testing', 0); <del> $result = $this->Cookie->read('Testing'); <del> $this->assertSame(0, $result); <del> } <del> <del> /** <del> * test write with distant future cookies <del> * <del> * @return void <del> */ <del> public function testWriteFarFuture() <del> { <del> $this->Cookie->configKey('Testing', 'expires', '+90 years'); <del> $this->Cookie->write('Testing', 'value'); <del> $future = new Time('now'); <del> $future = $future->modify('+90 years'); <del> <del> $expected = [ <del> 'name' => 'Testing', <del> 'value' => 'value', <del> 'path' => '/', <del> 'domain' => '', <del> 'secure' => false, <del> 'httpOnly' => false]; <del> $result = $this->Controller->response->getCookie('Testing'); <del> <del> $this->assertEquals($future->format('U'), $result['expire'], '', 3); <del> unset($result['expire']); <del> <del> $this->assertEquals($expected, $result); <del> } <del> <del> /** <del> * test write with httpOnly cookies <del> * <del> * @return void <del> */ <del> public function testWriteHttpOnly() <del> { <del> $this->Cookie->setConfig([ <del> 'httpOnly' => true, <del> 'secure' => false <del> ]); <del> $this->Cookie->write('Testing', 'value', false); <del> $expected = [ <del> 'name' => 'Testing', <del> 'value' => 'value', <del> 'expire' => (new Time('+10 seconds'))->format('U'), <del> 'path' => '/', <del> 'domain' => '', <del> 'secure' => false, <del> 'httpOnly' => true]; <del> $result = $this->Controller->response->getCookie('Testing'); <del> $this->assertEquals($expected, $result); <del> } <del> <del> /** <del> * Test writing multiple nested keys when some are encrypted. <del> * <del> * @return void <del> */ <del> public function testWriteMulitMixedEncryption() <del> { <del> $this->Cookie->configKey('Open', 'encryption', false); <del> $this->Cookie->configKey('Closed', 'encryption', 'aes'); <del> $this->Cookie->write([ <del> 'Closed.key' => 'secret', <del> 'Open.key' => 'not secret', <del> ]); <del> $expected = [ <del> 'name' => 'Open', <del> 'value' => '{"key":"not secret"}', <del> 'path' => '/', <del> 'domain' => '', <del> 'secure' => false, <del> 'httpOnly' => false <del> ]; <del> $result = $this->Controller->response->getCookie('Open'); <del> unset($result['expire']); <del> $this->assertEquals($expected, $result); <del> <del> $result = $this->Controller->response->getCookie('Closed'); <del> $this->assertContains('Q2FrZQ==.', $result['value']); <del> } <del> <del> /** <del> * Test writing with a custom encryption key using ConfigKey <del> * <del> * @return void <del> */ <del> public function testWriteConfigKeyWithCustomEncryptionKey() <del> { <del> $name = 'sampleCookieTest'; <del> $value = 'some data'; <del> $encryption = 'aes'; <del> $prefix = 'Q2FrZQ==.'; <del> $key = 'justanotherencryptionkeyjustanotherencryptionkey'; <del> <del> $this->Cookie->configKey($name, compact('key', 'encryption')); <del> $this->Cookie->write($name, $value); <del> <del> $cookie = $this->Controller->response->getCookie($name); <del> <del> $this->assertEquals($value, Security::decrypt(base64_decode(substr($cookie['value'], strlen($prefix))), $key)); <del> } <del> <del> /** <del> * Test reading with a custom encryption key using ConfigKey <del> * <del> * @return void <del> */ <del> public function testReadConfigKeyWithCustomEncryptionKey() <del> { <del> $name = 'sampleCookieTest'; <del> $value = 'some data'; <del> $encryption = 'aes'; <del> $key = 'justanotherencryptionkeyjustanotherencryptionkey'; <del> <del> $this->Cookie->configKey($name, compact('key', 'encryption')); <del> $this->Cookie->write($name, $value); <del> <del> $this->assertEquals('some data', $this->Cookie->read($name)); <del> } <del> <del> /** <del> * test delete with httpOnly <del> * <del> * @return void <del> */ <del> public function testDeleteHttpOnly() <del> { <del> $this->Cookie->setConfig([ <del> 'httpOnly' => true, <del> 'secure' => false <del> ]); <del> $this->Cookie->delete('Testing'); <del> $expected = [ <del> 'name' => 'Testing', <del> 'value' => '', <del> 'expire' => (new Time('now'))->format('U') - 42000, <del> 'path' => '/', <del> 'domain' => '', <del> 'secure' => false, <del> 'httpOnly' => true]; <del> $result = $this->Controller->response->getCookie('Testing'); <del> $this->assertEquals($expected, $result); <del> } <del> <del> /** <del> * test writing values that are not scalars <del> * <del> * @return void <del> */ <del> public function testWriteArrayValues() <del> { <del> $this->Cookie->write('Testing', [1, 2, 3]); <del> $expected = [ <del> 'name' => 'Testing', <del> 'value' => '[1,2,3]', <del> 'path' => '/', <del> 'domain' => '', <del> 'secure' => false, <del> 'httpOnly' => false <del> ]; <del> $result = $this->Controller->response->getCookie('Testing'); <del> <del> $time = new Time('now'); <del> $this->assertWithinRange($time->format('U') + 10, $result['expire'], 1); <del> unset($result['expire']); <del> $this->assertEquals($expected, $result); <del> } <del> <del> /** <del> * Test that writing mixed arrays results in the correct data. <del> * <del> * @return void <del> */ <del> public function testWriteMixedArray() <del> { <del> $this->Cookie->write('User', ['name' => 'mark'], false); <del> $this->Cookie->write('User.email', 'mark@example.com', false); <del> $expected = [ <del> 'name' => 'User', <del> 'value' => '{"name":"mark","email":"mark@example.com"}', <del> 'path' => '/', <del> 'domain' => '', <del> 'secure' => false, <del> 'httpOnly' => false <del> ]; <del> $result = $this->Controller->response->getCookie('User'); <del> unset($result['expire']); <del> <del> $this->assertEquals($expected, $result); <del> <del> $this->Cookie->write('User.email', 'mark@example.com', false); <del> $this->Cookie->write('User', ['name' => 'mark'], false); <del> $expected = [ <del> 'name' => 'User', <del> 'value' => '{"name":"mark"}', <del> 'path' => '/', <del> 'domain' => '', <del> 'secure' => false, <del> 'httpOnly' => false <del> ]; <del> $result = $this->Controller->response->getCookie('User'); <del> unset($result['expire']); <del> <del> $this->assertEquals($expected, $result); <del> } <del> <del> /** <del> * testDeleteCookieValue <del> * <del> * @return void <del> */ <del> public function testDeleteCookieValue() <del> { <del> $this->_setCookieData(); <del> $this->Cookie->delete('Encrypted_multi_cookies.name'); <del> $data = $this->Cookie->read('Encrypted_multi_cookies'); <del> $expected = ['version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!']; <del> $this->assertEquals($expected, $data); <del> <del> $this->Cookie->delete('Encrypted_array'); <del> $data = $this->Cookie->read('Encrypted_array'); <del> $this->assertNull($data); <del> <del> $this->Cookie->delete('Plain_multi_cookies.name'); <del> $data = $this->Cookie->read('Plain_multi_cookies'); <del> $expected = ['version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!']; <del> $this->assertEquals($expected, $data); <del> <del> $this->Cookie->delete('Plain_array'); <del> $data = $this->Cookie->read('Plain_array'); <del> $this->assertNull($data); <del> } <del> <del> /** <del> * testReadingCookieArray <del> * <del> * @return void <del> */ <del> public function testReadingCookieArray() <del> { <del> $this->_setCookieData(); <del> <del> $data = $this->Cookie->read('Encrypted_array.name'); <del> $expected = 'CakePHP'; <del> $this->assertEquals($expected, $data); <del> <del> $data = $this->Cookie->read('Encrypted_array.version'); <del> $expected = '1.2.0.x'; <del> $this->assertEquals($expected, $data); <del> <del> $data = $this->Cookie->read('Encrypted_array.tag'); <del> $expected = 'CakePHP Rocks!'; <del> $this->assertEquals($expected, $data); <del> <del> $data = $this->Cookie->read('Encrypted_multi_cookies.name'); <del> $expected = 'CakePHP'; <del> $this->assertEquals($expected, $data); <del> <del> $data = $this->Cookie->read('Encrypted_multi_cookies.version'); <del> $expected = '1.2.0.x'; <del> $this->assertEquals($expected, $data); <del> <del> $data = $this->Cookie->read('Encrypted_multi_cookies.tag'); <del> $expected = 'CakePHP Rocks!'; <del> $this->assertEquals($expected, $data); <del> <del> $data = $this->Cookie->read('Plain_array.name'); <del> $expected = 'CakePHP'; <del> $this->assertEquals($expected, $data); <del> <del> $data = $this->Cookie->read('Plain_array.version'); <del> $expected = '1.2.0.x'; <del> $this->assertEquals($expected, $data); <del> <del> $data = $this->Cookie->read('Plain_array.tag'); <del> $expected = 'CakePHP Rocks!'; <del> $this->assertEquals($expected, $data); <del> <del> $data = $this->Cookie->read('Plain_multi_cookies.name'); <del> $expected = 'CakePHP'; <del> $this->assertEquals($expected, $data); <del> <del> $data = $this->Cookie->read('Plain_multi_cookies.version'); <del> $expected = '1.2.0.x'; <del> $this->assertEquals($expected, $data); <del> <del> $data = $this->Cookie->read('Plain_multi_cookies.tag'); <del> $expected = 'CakePHP Rocks!'; <del> $this->assertEquals($expected, $data); <del> } <del> <del> /** <del> * testReadingCookieDataOnStartup <del> * <del> * @return void <del> */ <del> public function testReadingDataFromRequest() <del> { <del> $this->Cookie->configKey('Encrypted_array', 'encryption', 'aes'); <del> $this->Cookie->configKey('Encrypted_multi_cookies', 'encryption', 'aes'); <del> <del> $data = $this->Cookie->read('Encrypted_array'); <del> $this->assertNull($data); <del> <del> $data = $this->Cookie->read('Encrypted_multi_cookies'); <del> $this->assertNull($data); <del> <del> $data = $this->Cookie->read('Plain_array'); <del> $this->assertNull($data); <del> <del> $data = $this->Cookie->read('Plain_multi_cookies'); <del> $this->assertNull($data); <del> <del> $this->Controller->request = $this->request->withCookieParams([ <del> 'Encrypted_array' => $this->_encrypt(['name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!']), <del> 'Encrypted_multi_cookies' => [ <del> 'name' => $this->_encrypt('CakePHP'), <del> 'version' => $this->_encrypt('1.2.0.x'), <del> 'tag' => $this->_encrypt('CakePHP Rocks!') <del> ], <del> 'Plain_array' => '{"name":"CakePHP","version":"1.2.0.x","tag":"CakePHP Rocks!"}', <del> 'Plain_multi_cookies' => [ <del> 'name' => 'CakePHP', <del> 'version' => '1.2.0.x', <del> 'tag' => 'CakePHP Rocks!' <del> ] <del> ]); <del> <del> $data = $this->Cookie->read('Encrypted_array'); <del> $expected = ['name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!']; <del> $this->assertEquals($expected, $data); <del> <del> $data = $this->Cookie->read('Encrypted_multi_cookies'); <del> $expected = ['name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!']; <del> $this->assertEquals($expected, $data); <del> <del> $data = $this->Cookie->read('Plain_array'); <del> $expected = ['name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!']; <del> $this->assertEquals($expected, $data); <del> <del> $data = $this->Cookie->read('Plain_multi_cookies'); <del> $expected = ['name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!']; <del> $this->assertEquals($expected, $data); <del> } <del> <del> /** <del> * Test Reading legacy cookie values. <del> * <del> * @return void <del> */ <del> public function testReadLegacyCookieValue() <del> { <del> $this->Controller->request = $this->request->withCookieParams([ <del> 'Legacy' => ['value' => $this->_oldImplode([1, 2, 3])] <del> ]); <del> $result = $this->Cookie->read('Legacy.value'); <del> $expected = [1, 2, 3]; <del> $this->assertEquals($expected, $result); <del> } <del> <del> /** <del> * Test reading empty values. <del> * <del> * @return void <del> */ <del> public function testReadEmpty() <del> { <del> $this->Controller->request = $this->request->withCookieParams([ <del> 'JSON' => '{"name":"value"}', <del> 'Empty' => '', <del> 'String' => '{"somewhat:"broken"}', <del> 'Array' => '{}' <del> ]); <del> $this->assertEquals(['name' => 'value'], $this->Cookie->read('JSON')); <del> $this->assertEquals('value', $this->Cookie->read('JSON.name')); <del> $this->assertEquals('', $this->Cookie->read('Empty')); <del> $this->assertEquals('{"somewhat:"broken"}', $this->Cookie->read('String')); <del> $this->assertEquals([], $this->Cookie->read('Array')); <del> } <del> <del> /** <del> * testCheck method <del> * <del> * @return void <del> */ <del> public function testCheck() <del> { <del> $this->Cookie->write('CookieComponentTestCase', 'value'); <del> $this->assertTrue($this->Cookie->check('CookieComponentTestCase')); <del> <del> $this->assertFalse($this->Cookie->check('NotExistingCookieComponentTestCase')); <del> } <del> <del> /** <del> * testCheckingSavedEmpty method <del> * <del> * @return void <del> */ <del> public function testCheckingSavedEmpty() <del> { <del> $this->Cookie->write('CookieComponentTestCase', 0); <del> $this->assertTrue($this->Cookie->check('CookieComponentTestCase')); <del> <del> $this->Cookie->write('CookieComponentTestCase', '0'); <del> $this->assertTrue($this->Cookie->check('CookieComponentTestCase')); <del> } <del> <del> /** <del> * testCheckKeyWithSpaces method <del> * <del> * @return void <del> */ <del> public function testCheckKeyWithSpaces() <del> { <del> $this->Cookie->write('CookieComponent Test', 'test'); <del> $this->assertTrue($this->Cookie->check('CookieComponent Test')); <del> $this->Cookie->delete('CookieComponent Test'); <del> <del> $this->Cookie->write('CookieComponent Test.Test Case', 'test'); <del> $this->assertTrue($this->Cookie->check('CookieComponent Test.Test Case')); <del> } <del> <del> /** <del> * testCheckEmpty <del> * <del> * @return void <del> */ <del> public function testCheckEmpty() <del> { <del> $this->assertFalse($this->Cookie->check()); <del> } <del> <del> /** <del> * test that deleting a top level keys kills the child elements too. <del> * <del> * @return void <del> */ <del> public function testDeleteRemovesChildren() <del> { <del> $this->Controller->request = $this->request->withCookieParams([ <del> 'User' => ['email' => 'example@example.com', 'name' => 'mark'], <del> 'other' => 'value' <del> ]); <del> $this->assertEquals('mark', $this->Cookie->read('User.name')); <del> <del> $this->Cookie->delete('User'); <del> $this->assertNull($this->Cookie->read('User.email')); <del> $this->assertNull($this->Cookie->read('User.name')); <del> <del> $result = $this->Controller->response->getCookie('User'); <del> $this->assertEquals('', $result['value']); <del> $this->assertLessThan(time(), $result['expire']); <del> } <del> <del> /** <del> * Test deleting recursively with keys that don't exist. <del> * <del> * @return void <del> */ <del> public function testDeleteChildrenNotExist() <del> { <del> $this->assertNull($this->Cookie->delete('NotFound')); <del> $this->assertNull($this->Cookie->delete('Not.Found')); <del> } <del> <del> /** <del> * Helper method for generating old style encoded cookie values. <del> * <del> * @param array $array <del> * @return string <del> */ <del> protected function _oldImplode(array $array) <del> { <del> $string = ''; <del> foreach ($array as $key => $value) { <del> $string .= ',' . $key . '|' . $value; <del> } <del> <del> return substr($string, 1); <del> } <del> <del> /** <del> * Implode method to keep keys are multidimensional arrays <del> * <del> * @param array $array Map of key and values <del> * @return string String in the form key1|value1,key2|value2 <del> */ <del> protected function _implode(array $array) <del> { <del> return json_encode($array); <del> } <del> <del> /** <del> * encrypt method <del> * <del> * @param array|string $value <del> * @return string <del> */ <del> protected function _encrypt($value) <del> { <del> if (is_array($value)) { <del> $value = $this->_implode($value); <del> } <del> <del> return 'Q2FrZQ==.' . base64_encode(Security::encrypt($value, $this->Cookie->getConfig('key'))); <del> } <del>} <ide><path>tests/TestCase/Controller/Component/CsrfComponentTest.php <del><?php <del>/** <del> * CakePHP(tm) : Rapid Development Framework (https://cakephp.org) <del> * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org) <del> * <del> * Licensed under The MIT License <del> * For full copyright and license information, please see the LICENSE.txt <del> * Redistributions of files must retain the above copyright notice. <del> * <del> * @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org) <del> * @link https://cakephp.org CakePHP(tm) Project <del> * @since 3.0.0 <del> * @license https://opensource.org/licenses/mit-license.php MIT License <del> */ <del>namespace Cake\Test\TestCase\Controller\Component; <del> <del>use Cake\Controller\ComponentRegistry; <del>use Cake\Controller\Component\CsrfComponent; <del>use Cake\Event\Event; <del>use Cake\Http\Response; <del>use Cake\Http\ServerRequest; <del>use Cake\I18n\Time; <del>use Cake\TestSuite\TestCase; <del> <del>/** <del> * CsrfComponent test. <del> */ <del>class CsrfComponentTest extends TestCase <del>{ <del> <del> /** <del> * setup <del> * <del> * @return void <del> */ <del> public function setUp() <del> { <del> parent::setUp(); <del> <del> $controller = $this->getMockBuilder('Cake\Controller\Controller') <del> ->setMethods(['redirect']) <del> ->getMock(); <del> $this->registry = new ComponentRegistry($controller); <del> $this->component = new CsrfComponent($this->registry); <del> } <del> <del> /** <del> * teardown <del> * <del> * @return void <del> */ <del> public function tearDown() <del> { <del> parent::tearDown(); <del> unset($this->component); <del> } <del> <del> /** <del> * Test setting the cookie value <del> * <del> * @return void <del> * @triggers Controller.startup $controller <del> */ <del> public function testSettingCookie() <del> { <del> $controller = $this->getMockBuilder('Cake\Controller\Controller') <del> ->setMethods(['redirect']) <del> ->getMock(); <del> $controller->request = new ServerRequest([ <del> 'environment' => ['REQUEST_METHOD' => 'GET'], <del> 'webroot' => '/dir/', <del> ]); <del> $controller->response = new Response(); <del> <del> $event = new Event('Controller.startup', $controller); <del> $this->component->startup($event); <del> <del> $cookie = $controller->response->getCookie('csrfToken'); <del> $this->assertNotEmpty($cookie, 'Should set a token.'); <del> $this->assertRegExp('/^[a-f0-9]+$/', $cookie['value'], 'Should look like a hash.'); <del> $this->assertEquals(0, $cookie['expire'], 'session duration.'); <del> $this->assertEquals('/dir/', $cookie['path'], 'session path.'); <del> <del> $this->assertEquals($cookie['value'], $controller->request->getParam('_csrfToken')); <del> } <del> <del> /** <del> * Data provider for HTTP method tests. <del> * <del> * HEAD and GET do not populate $_POST or request->data. <del> * <del> * @return array <del> */ <del> public static function safeHttpMethodProvider() <del> { <del> return [ <del> ['GET'], <del> ['HEAD'], <del> ]; <del> } <del> <del> /** <del> * Test that the CSRF tokens are not required for idempotent operations <del> * <del> * @dataProvider safeHttpMethodProvider <del> * @return void <del> */ <del> public function testSafeMethodNoCsrfRequired($method) <del> { <del> $controller = $this->getMockBuilder('Cake\Controller\Controller') <del> ->setMethods(['redirect']) <del> ->getMock(); <del> $controller->request = new ServerRequest([ <del> 'environment' => [ <del> 'REQUEST_METHOD' => $method, <del> 'HTTP_X_CSRF_TOKEN' => 'nope', <del> ], <del> 'cookies' => ['csrfToken' => 'testing123'] <del> ]); <del> $controller->response = new Response(); <del> <del> $event = new Event('Controller.startup', $controller); <del> $result = $this->component->startup($event); <del> $this->assertNull($result, 'No exception means valid.'); <del> } <del> <del> /** <del> * Data provider for HTTP methods that can contain request bodies. <del> * <del> * @return array <del> */ <del> public static function httpMethodProvider() <del> { <del> return [ <del> ['OPTIONS'], ['PATCH'], ['PUT'], ['POST'], ['DELETE'], ['PURGE'], ['INVALIDMETHOD'] <del> ]; <del> } <del> <del> /** <del> * Test that the X-CSRF-Token works with the various http methods. <del> * <del> * @dataProvider httpMethodProvider <del> * @return void <del> * @triggers Controller.startup $controller <del> */ <del> public function testValidTokenInHeader($method) <del> { <del> $controller = $this->getMockBuilder('Cake\Controller\Controller') <del> ->setMethods(['redirect']) <del> ->getMock(); <del> $controller->request = new ServerRequest([ <del> 'environment' => [ <del> 'REQUEST_METHOD' => $method, <del> 'HTTP_X_CSRF_TOKEN' => 'testing123', <del> ], <del> 'post' => ['a' => 'b'], <del> 'cookies' => ['csrfToken' => 'testing123'] <del> ]); <del> $controller->response = new Response(); <del> <del> $event = new Event('Controller.startup', $controller); <del> $result = $this->component->startup($event); <del> $this->assertNull($result, 'No exception means valid.'); <del> } <del> <del> /** <del> * Test that the X-CSRF-Token works with the various http methods. <del> * <del> * @dataProvider httpMethodProvider <del> * @return void <del> * @triggers Controller.startup $controller <del> */ <del> public function testInvalidTokenInHeader($method) <del> { <del> $this->expectException(\Cake\Http\Exception\InvalidCsrfTokenException::class); <del> $controller = $this->getMockBuilder('Cake\Controller\Controller') <del> ->setMethods(['redirect']) <del> ->getMock(); <del> $controller->request = new ServerRequest([ <del> 'environment' => [ <del> 'REQUEST_METHOD' => $method, <del> 'HTTP_X_CSRF_TOKEN' => 'nope', <del> ], <del> 'post' => ['a' => 'b'], <del> 'cookies' => ['csrfToken' => 'testing123'] <del> ]); <del> $controller->response = new Response(); <del> <del> $event = new Event('Controller.startup', $controller); <del> $this->component->startup($event); <del> } <del> <del> /** <del> * Test that request data works with the various http methods. <del> * <del> * @dataProvider httpMethodProvider <del> * @return void <del> * @triggers Controller.startup $controller <del> */ <del> public function testValidTokenRequestData($method) <del> { <del> $controller = $this->getMockBuilder('Cake\Controller\Controller') <del> ->setMethods(['redirect']) <del> ->getMock(); <del> $controller->request = new ServerRequest([ <del> 'environment' => [ <del> 'REQUEST_METHOD' => $method, <del> ], <del> 'post' => ['_csrfToken' => 'testing123'], <del> 'cookies' => ['csrfToken' => 'testing123'] <del> ]); <del> $controller->response = new Response(); <del> <del> $event = new Event('Controller.startup', $controller); <del> $result = $this->component->startup($event); <del> $this->assertNull($result, 'No exception means valid.'); <del> $this->assertNull($controller->request->getData('_csrfToken')); <del> } <del> <del> /** <del> * Test that request data works with the various http methods. <del> * <del> * @dataProvider httpMethodProvider <del> * @return void <del> */ <del> public function testInvalidTokenRequestData($method) <del> { <del> $this->expectException(\Cake\Http\Exception\InvalidCsrfTokenException::class); <del> $controller = $this->getMockBuilder('Cake\Controller\Controller') <del> ->setMethods(['redirect']) <del> ->getMock(); <del> $controller->request = new ServerRequest([ <del> 'environment' => [ <del> 'REQUEST_METHOD' => $method, <del> ], <del> 'post' => ['_csrfToken' => 'nope'], <del> 'cookies' => ['csrfToken' => 'testing123'] <del> ]); <del> $controller->response = new Response(); <del> <del> $event = new Event('Controller.startup', $controller); <del> $this->component->startup($event); <del> } <del> <del> /** <del> * Test that missing post field fails <del> * <del> * @return void <del> */ <del> public function testInvalidTokenRequestDataMissing() <del> { <del> $this->expectException(\Cake\Http\Exception\InvalidCsrfTokenException::class); <del> $controller = $this->getMockBuilder('Cake\Controller\Controller') <del> ->setMethods(['redirect']) <del> ->getMock(); <del> $controller->request = new ServerRequest([ <del> 'environment' => [ <del> 'REQUEST_METHOD' => 'POST', <del> ], <del> 'post' => [], <del> 'cookies' => ['csrfToken' => 'testing123'] <del> ]); <del> $controller->response = new Response(); <del> <del> $event = new Event('Controller.startup', $controller); <del> $this->component->startup($event); <del> } <del> <del> /** <del> * Test that missing header and cookie fails <del> * <del> * @dataProvider httpMethodProvider <del> * @return void <del> */ <del> public function testInvalidTokenMissingCookie($method) <del> { <del> $this->expectException(\Cake\Http\Exception\InvalidCsrfTokenException::class); <del> $controller = $this->getMockBuilder('Cake\Controller\Controller') <del> ->setMethods(['redirect']) <del> ->getMock(); <del> $controller->request = new ServerRequest([ <del> 'environment' => [ <del> 'REQUEST_METHOD' => $method <del> ], <del> 'post' => ['_csrfToken' => 'could-be-valid'], <del> 'cookies' => [] <del> ]); <del> $controller->response = new Response(); <del> <del> $event = new Event('Controller.startup', $controller); <del> $this->component->startup($event); <del> } <del> <del> /** <del> * Test that CSRF checks are not applied to request action requests. <del> * <del> * @return void <del> * @triggers Controller.startup $controller <del> */ <del> public function testCsrfValidationSkipsRequestAction() <del> { <del> $controller = $this->getMockBuilder('Cake\Controller\Controller') <del> ->setMethods(['redirect']) <del> ->getMock(); <del> $controller->request = new ServerRequest([ <del> 'environment' => ['REQUEST_METHOD' => 'POST'], <del> 'params' => ['requested' => 1], <del> 'post' => ['_csrfToken' => 'nope'], <del> 'cookies' => ['csrfToken' => 'testing123'] <del> ]); <del> $controller->response = new Response(); <del> <del> $event = new Event('Controller.startup', $controller); <del> $result = $this->component->startup($event); <del> $this->assertNull($result, 'No error.'); <del> $this->assertEquals('testing123', $controller->request->getParam('_csrfToken')); <del> } <del> <del> /** <del> * Test that the configuration options work. <del> * <del> * @return void <del> * @triggers Controller.startup $controller <del> */ <del> public function testConfigurationCookieCreate() <del> { <del> $controller = $this->getMockBuilder('Cake\Controller\Controller') <del> ->setMethods(['redirect']) <del> ->getMock(); <del> $controller->request = new ServerRequest([ <del> 'environment' => ['REQUEST_METHOD' => 'GET'], <del> 'webroot' => '/dir/' <del> ]); <del> $controller->response = new Response(); <del> <del> $component = new CsrfComponent($this->registry, [ <del> 'cookieName' => 'token', <del> 'expiry' => '+1 hour', <del> 'secure' => true, <del> 'httpOnly' => true <del> ]); <del> <del> $event = new Event('Controller.startup', $controller); <del> $component->startup($event); <del> <del> $this->assertEmpty($controller->response->getCookie('csrfToken')); <del> $cookie = $controller->response->getCookie('token'); <del> $this->assertNotEmpty($cookie, 'Should set a token.'); <del> $this->assertRegExp('/^[a-f0-9]+$/', $cookie['value'], 'Should look like a hash.'); <del> $this->assertWithinRange((new Time('+1 hour'))->format('U'), $cookie['expire'], 1, 'session duration.'); <del> $this->assertEquals('/dir/', $cookie['path'], 'session path.'); <del> $this->assertTrue($cookie['secure'], 'cookie security flag missing'); <del> $this->assertTrue($cookie['httpOnly'], 'cookie httpOnly flag missing'); <del> } <del> <del> /** <del> * Test that the configuration options work. <del> * <del> * @return void <del> * @triggers Controller.startup $controller <del> */ <del> public function testConfigurationValidate() <del> { <del> $controller = $this->getMockBuilder('Cake\Controller\Controller') <del> ->setMethods(['redirect']) <del> ->getMock(); <del> $controller->request = new ServerRequest([ <del> 'environment' => ['REQUEST_METHOD' => 'POST'], <del> 'cookies' => ['csrfToken' => 'nope', 'token' => 'yes'], <del> 'post' => ['_csrfToken' => 'no match', 'token' => 'yes'], <del> ]); <del> $controller->response = new Response(); <del> <del> $component = new CsrfComponent($this->registry, [ <del> 'cookieName' => 'token', <del> 'field' => 'token', <del> 'expiry' => 90, <del> ]); <del> <del> $event = new Event('Controller.startup', $controller); <del> $result = $component->startup($event); <del> $this->assertNull($result, 'Config settings should work.'); <del> } <del>} <ide><path>tests/TestCase/Controller/ComponentRegistryTest.php <ide> <ide> use Cake\Controller\ComponentRegistry; <ide> use Cake\Controller\Component\AuthComponent; <del>use Cake\Controller\Component\CookieComponent; <add>use Cake\Controller\Component\FlashComponent; <ide> use Cake\Controller\Controller; <ide> use Cake\Core\Plugin; <ide> use Cake\Http\Response; <ide> use Cake\Http\ServerRequest; <ide> use Cake\TestSuite\TestCase; <ide> <ide> /** <del> * Extended CookieComponent <add> * Extended FlashComponent <ide> */ <del>class CookieAliasComponent extends CookieComponent <add>class FlashAliasComponent extends FlashComponent <ide> { <ide> } <ide> <ide> public function tearDown() <ide> */ <ide> public function testLoad() <ide> { <del> $result = $this->Components->load('Cookie'); <del> $this->assertInstanceOf('Cake\Controller\Component\CookieComponent', $result); <del> $this->assertInstanceOf('Cake\Controller\Component\CookieComponent', $this->Components->Cookie); <add> $result = $this->Components->load('Flash'); <add> $this->assertInstanceOf('Cake\Controller\Component\FlashComponent', $result); <add> $this->assertInstanceOf('Cake\Controller\Component\FlashComponent', $this->Components->Flash); <ide> <ide> $result = $this->Components->loaded(); <del> $this->assertEquals(['Cookie'], $result, 'loaded() results are wrong.'); <add> $this->assertEquals(['Flash'], $result, 'loaded() results are wrong.'); <ide> <del> $result = $this->Components->load('Cookie'); <del> $this->assertSame($result, $this->Components->Cookie); <add> $result = $this->Components->load('Flash'); <add> $this->assertSame($result, $this->Components->Flash); <ide> } <ide> <ide> /** <ide> public function testLoad() <ide> */ <ide> public function testLoadWithAlias() <ide> { <del> $result = $this->Components->load('Cookie', ['className' => __NAMESPACE__ . '\CookieAliasComponent', 'somesetting' => true]); <del> $this->assertInstanceOf(__NAMESPACE__ . '\CookieAliasComponent', $result); <del> $this->assertInstanceOf(__NAMESPACE__ . '\CookieAliasComponent', $this->Components->Cookie); <del> $this->assertTrue($this->Components->Cookie->getConfig('somesetting')); <add> $result = $this->Components->load('Flash', ['className' => __NAMESPACE__ . '\FlashAliasComponent', 'somesetting' => true]); <add> $this->assertInstanceOf(__NAMESPACE__ . '\FlashAliasComponent', $result); <add> $this->assertInstanceOf(__NAMESPACE__ . '\FlashAliasComponent', $this->Components->Flash); <add> $this->assertTrue($this->Components->Flash->getConfig('somesetting')); <ide> <ide> $result = $this->Components->loaded(); <del> $this->assertEquals(['Cookie'], $result, 'loaded() results are wrong.'); <add> $this->assertEquals(['Flash'], $result, 'loaded() results are wrong.'); <ide> <del> $result = $this->Components->load('Cookie'); <del> $this->assertInstanceOf(__NAMESPACE__ . '\CookieAliasComponent', $result); <add> $result = $this->Components->load('Flash'); <add> $this->assertInstanceOf(__NAMESPACE__ . '\FlashAliasComponent', $result); <ide> <ide> Plugin::load('TestPlugin'); <ide> $result = $this->Components->load('SomeOther', ['className' => 'TestPlugin.Other']); <ide> $this->assertInstanceOf('TestPlugin\Controller\Component\OtherComponent', $result); <ide> $this->assertInstanceOf('TestPlugin\Controller\Component\OtherComponent', $this->Components->SomeOther); <ide> <ide> $result = $this->Components->loaded(); <del> $this->assertEquals(['Cookie', 'SomeOther'], $result, 'loaded() results are wrong.'); <add> $this->assertEquals(['Flash', 'SomeOther'], $result, 'loaded() results are wrong.'); <ide> } <ide> <ide> /** <ide> public function testLoadWithEnableFalse() <ide> <ide> $this->Components->getController()->setEventManager($mock); <ide> <del> $result = $this->Components->load('Cookie', ['enabled' => false]); <del> $this->assertInstanceOf('Cake\Controller\Component\CookieComponent', $result); <del> $this->assertInstanceOf('Cake\Controller\Component\CookieComponent', $this->Components->Cookie); <add> $result = $this->Components->load('Flash', ['enabled' => false]); <add> $this->assertInstanceOf('Cake\Controller\Component\FlashComponent', $result); <add> $this->assertInstanceOf('Cake\Controller\Component\FlashComponent', $this->Components->Flash); <ide> } <ide> <ide> /** <ide><path>tests/TestCase/Controller/ComponentTest.php <ide> namespace Cake\Test\TestCase\Controller; <ide> <ide> use Cake\Controller\ComponentRegistry; <del>use Cake\Controller\Component\CookieComponent; <add>use Cake\Controller\Component\FlashComponent; <ide> use Cake\Controller\Controller; <ide> use Cake\Event\EventManager; <ide> use Cake\TestSuite\TestCase; <ide> use TestApp\Controller\Component\BananaComponent; <ide> use TestApp\Controller\Component\ConfiguredComponent; <ide> use TestApp\Controller\Component\OrangeComponent; <del>use TestApp\Controller\Component\SomethingWithCookieComponent; <add>use TestApp\Controller\Component\SomethingWithFlashComponent; <ide> <ide> /** <ide> * ComponentTest class <ide> public function testDuplicateComponentInitialize() <ide> * <ide> * @return void <ide> */ <del> public function testSomethingReferencingCookieComponent() <add> public function testSomethingReferencingFlashComponent() <ide> { <ide> $Controller = new ComponentTestController(); <del> $Controller->loadComponent('SomethingWithCookie'); <add> $Controller->loadComponent('SomethingWithFlash'); <ide> $Controller->startupProcess(); <ide> <del> $this->assertInstanceOf(SomethingWithCookieComponent::class, $Controller->SomethingWithCookie); <del> $this->assertInstanceOf(CookieComponent::class, $Controller->SomethingWithCookie->Cookie); <add> $this->assertInstanceOf(SomethingWithFlashComponent::class, $Controller->SomethingWithFlash); <add> $this->assertInstanceOf(FlashComponent::class, $Controller->SomethingWithFlash->Flash); <ide> } <ide> <ide> /** <ide><path>tests/TestCase/Controller/ControllerTest.php <ide> class ControllerTestAppController extends Controller <ide> * <ide> * @var array <ide> */ <del> public $components = ['Cookie']; <add> public $components = ['Flash']; <ide> } <ide> <ide> /** <ide> public function testMergeVars() <ide> <ide> $expected = [ <ide> 'Security' => null, <del> 'Cookie' => null, <add> 'Flash' => null, <ide> ]; <ide> $this->assertEquals($expected, $TestController->components); <ide> <add><path>tests/test_app/TestApp/Controller/Component/SomethingWithFlashComponent.php <del><path>tests/test_app/TestApp/Controller/Component/SomethingWithCookieComponent.php <ide> use Cake\Controller\Component; <ide> <ide> /** <del> * SomethingWithCookieComponent class <add> * SomethingWithFlashComponent class <ide> * <del> * @property \Cake\Controller\Component\CookieComponent $Cookie <add> * @property \Cake\Controller\Component\SomethingWithCookie $Flash <ide> */ <del>class SomethingWithCookieComponent extends Component <add>class SomethingWithFlashComponent extends Component <ide> { <ide> <ide> /** <ide> * components property <ide> * <ide> * @var array <ide> */ <del> public $components = ['Cookie']; <add> public $components = ['Flash']; <ide> }
8
Ruby
Ruby
redact boost149 from core
3ef1a9241de6ebc611456ae4728b53c8b295202d
<ide><path>Library/Homebrew/tap_migrations.rb <ide> 'blackbox' => 'homebrew/boneyard', <ide> 'libgtextutils' => 'homebrew/science', <ide> 'syslog-ng' => 'homebrew/boneyard', <add> 'librets' => 'homebrew/boneyard', <add> 'drizzle' => 'homebrew/boneyard', <add> 'boost149' => 'homebrew/versions, <ide> }
1
Ruby
Ruby
add patch level to ruby version information
5c099a6f06abe1ab75844c44e9716b8f8d7ecceb
<ide><path>railties/lib/rails/info.rb <ide> def to_html <ide> end <ide> end <ide> <del> # The Ruby version and platform, e.g. "1.8.2 (powerpc-darwin8.2.0)". <del> property 'Ruby version', "#{RUBY_VERSION} (#{RUBY_PLATFORM})" <add> # The Ruby version and platform, e.g. "2.0.0p247 (x86_64-darwin12.4.0)". <add> property 'Ruby version' do <add> "#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL} (#{RUBY_PLATFORM})" <add> end <ide> <ide> # The RubyGems version, if it's installed. <ide> property 'RubyGems version' do
1
Javascript
Javascript
skip animation on first render
1351ba2632b5011ad6eaddf004a7f0411bea8453
<ide><path>src/ng/animator.js <ide> * <ide> * The `event1` and `event2` attributes refer to the animation events specific to the directive that has been assigned. <ide> * <add> * Keep in mind that, by default, **all** initial animations will be skipped until the first digest cycle has fully <add> * passed. This helps prevent any unexpected animations from occurring while the application or directive is initializing. To <add> * override this behavior, you may pass "animateFirst: true" into the ngAnimate attribute expression. <add> * <ide> * <h2>CSS-defined Animations</h2> <ide> * By default, ngAnimate attaches two CSS3 classes per animation event to the DOM element to achieve the animation. <ide> * This is up to you, the developer, to ensure that the animations take place using cross-browser CSS3 transitions. <ide> var $AnimatorProvider = function() { <ide> */ <ide> var AnimatorService = function(scope, attrs) { <ide> var ngAnimateAttr = attrs.ngAnimate; <add> <add> // avoid running animations on start <add> var animationEnabled = false; <add> var ngAnimateValue = ngAnimateAttr && scope.$eval(ngAnimateAttr); <add> <add> if (!animationEnabled) { <add> if(isObject(ngAnimateValue) && ngAnimateValue['animateFirst']) { <add> animationEnabled = true; <add> } else { <add> var enableSubsequent = function() { <add> removeWatch(); <add> scope.$evalAsync(function() { <add> animationEnabled = true; <add> }); <add> }; <add> var removeWatch = noop; <add> <add> if (scope.$$phase) { <add> enableSubsequent(); <add> } else { <add> removeWatch = scope.$watch(enableSubsequent); <add> } <add> } <add> } <ide> var animator = {}; <ide> <ide> /** <ide> var $AnimatorProvider = function() { <ide> return animator; <ide> <ide> function animateActionFactory(type, beforeFn, afterFn) { <del> var ngAnimateValue = ngAnimateAttr && scope.$eval(ngAnimateAttr); <ide> var className = ngAnimateAttr <ide> ? isObject(ngAnimateValue) ? ngAnimateValue[type] : ngAnimateValue + '-' + type <ide> : ''; <ide> var $AnimatorProvider = function() { <ide> var startClass = className + '-start'; <ide> <ide> return function(element, parent, after) { <del> if (!globalAnimationEnabled || !$sniffer.supportsTransitions && !polyfillSetup && !polyfillStart) { <add> if (!animationEnabled || !globalAnimationEnabled || <add> (!$sniffer.supportsTransitions && !polyfillSetup && !polyfillStart)) { <ide> beforeFn(element, parent, after); <ide> afterFn(element, parent, after); <ide> return; <ide> var $AnimatorProvider = function() { <ide> 0, <ide> duration); <ide> }); <del> <ide> $window.setTimeout(done, duration * 1000); <ide> } else { <ide> done(); <ide><path>src/ngMock/angular-mocks.js <ide> angular.mock.createMockWindow = function() { <ide> if (setTimeoutQueue.length > 0) { <ide> return { <ide> process: function() { <del> setTimeoutQueue.shift().fn(); <add> var tick = setTimeoutQueue.shift(); <add> expect(tick.delay).toEqual(delay); <add> tick.fn(); <ide> } <ide> }; <ide> } else { <ide><path>test/ng/animatorSpec.js <ide> <ide> describe("$animator", function() { <ide> <del> var element; <add> var body, element; <add> <add> function html(html) { <add> body.html(html); <add> element = body.children().eq(0); <add> return element; <add> } <add> <add> beforeEach(function() { <add> // we need to run animation on attached elements; <add> body = jqLite(document.body); <add> }); <ide> <ide> afterEach(function(){ <del> dealoc(element); <add> dealoc(body); <ide> }); <ide> <ide> describe("enable / disable", function() { <ide> describe("$animator", function() { <ide> animator = $animator($rootScope, { <ide> ngAnimate : '{enter: \'custom\'}' <ide> }); <add> $rootScope.$digest(); // re-enable the animations; <ide> expect(element.contents().length).toBe(0); <ide> animator.enter(child, element); <ide> window.setTimeout.expect(1).process(); <ide> describe("$animator", function() { <ide> animator = $animator($rootScope, { <ide> ngAnimate : '{leave: \'custom\'}' <ide> }); <add> $rootScope.$digest(); <ide> element.append(child); <ide> expect(element.contents().length).toBe(1); <ide> animator.leave(child, element); <ide> describe("$animator", function() { <ide> animator = $animator($rootScope, { <ide> ngAnimate : '{move: \'custom\'}' <ide> }); <add> $rootScope.$digest(); <ide> var child1 = $compile('<div>1</div>')($rootScope); <ide> var child2 = $compile('<div>2</div>')($rootScope); <ide> element.append(child1); <ide> describe("$animator", function() { <ide> animator = $animator($rootScope, { <ide> ngAnimate : '{show: \'custom\'}' <ide> }); <add> $rootScope.$digest(); <ide> element.css('display','none'); <ide> expect(element.css('display')).toBe('none'); <ide> animator.show(element); <ide> describe("$animator", function() { <ide> animator = $animator($rootScope, { <ide> ngAnimate : '{hide: \'custom\'}' <ide> }); <add> $rootScope.$digest(); <ide> element.css('display','block'); <ide> expect(element.css('display')).toBe('block'); <ide> animator.hide(element); <ide> describe("$animator", function() { <ide> ngAnimate : '"custom"' <ide> }); <ide> <add> $rootScope.$digest(); <add> <ide> //enter <ide> animator.enter(child, element); <ide> expect(child.attr('class')).toContain('custom-enter-setup'); <ide> describe("$animator", function() { <ide> animator = $animator($rootScope, { <ide> ngAnimate : '{show: \'setup-memo\'}' <ide> }); <add> $rootScope.$digest(); <ide> expect(element.text()).toEqual(''); <ide> animator.show(element); <ide> window.setTimeout.expect(1).process(); <ide> describe("$animator", function() { <ide> animator = $animator($rootScope, { <ide> ngAnimate : '{show: \'setup-memo\'}' <ide> }); <add> $rootScope.$digest(); <add> <ide> element.text('123'); <ide> expect(element.text()).toBe('123'); <ide> animator.show(element); <ide> describe("$animator", function() { <ide> it("should skip animations if disabled and run when enabled", <ide> inject(function($animator, $rootScope, $compile, $sniffer) { <ide> $animator.enabled(false); <del> element = $compile('<div style="transition: 1s linear all">1</div>')($rootScope); <add> element = $compile(html('<div style="' + vendorPrefix + 'transition: 1s linear all">1</div>'))($rootScope); <ide> var animator = $animator($rootScope, { <ide> ngAnimate : '{show: \'inline-show\'}' <ide> }); <ide> <add> $rootScope.$digest(); // skip no-animate on first digest. <add> <ide> element.css('display','none'); <ide> expect(element.css('display')).toBe('none'); <ide> animator.show(element); <ide> describe("$animator", function() { <ide> it("should throw an error when an invalid ng-animate syntax is provided", inject(function($compile, $rootScope) { <ide> expect(function() { <ide> element = $compile('<div ng-repeat="i in is" ng-animate=":"></div>')($rootScope); <add> $rootScope.$digest(); <ide> }).toThrow("Syntax Error: Token ':' not a primary expression at column 1 of the expression [:] starting at [:]."); <ide> })); <ide> }); <ide><path>test/ng/directive/ngIncludeSpec.js <ide> describe('ngInclude', function() { <ide> }); <ide> <ide> describe('ngInclude ngAnimate', function() { <del> var element, vendorPrefix, window; <add> var vendorPrefix, window; <add> var body, element; <add> <add> function html(html) { <add> body.html(html); <add> element = body.children().eq(0); <add> return element; <add> } <add> <add> beforeEach(function() { <add> // we need to run animation on attached elements; <add> body = jqLite(document.body); <add> }); <add> <add> afterEach(function(){ <add> dealoc(body); <add> dealoc(element); <add> }); <ide> <ide> beforeEach(module(function($animationProvider, $provide) { <ide> $provide.value('$window', window = angular.mock.createMockWindow()); <ide> describe('ngInclude ngAnimate', function() { <ide> <ide> $templateCache.put('enter', [200, '<div>data</div>', {}]); <ide> $rootScope.tpl = 'enter'; <del> element = $compile( <add> element = $compile(html( <ide> '<div ' + <ide> 'ng-include="tpl" ' + <ide> 'ng-animate="{enter: \'custom-enter\'}">' + <ide> '</div>' <del> )($rootScope); <add> ))($rootScope); <ide> $rootScope.$digest(); <ide> <ide> //if we add the custom css stuff here then it will get picked up before the animation takes place <ide> describe('ngInclude ngAnimate', function() { <ide> inject(function($compile, $rootScope, $templateCache, $sniffer) { <ide> $templateCache.put('enter', [200, '<div>data</div>', {}]); <ide> $rootScope.tpl = 'enter'; <del> element = $compile( <add> element = $compile(html( <ide> '<div ' + <ide> 'ng-include="tpl" ' + <ide> 'ng-animate="{leave: \'custom-leave\'}">' + <ide> '</div>' <del> )($rootScope); <add> ))($rootScope); <ide> $rootScope.$digest(); <ide> <ide> //if we add the custom css stuff here then it will get picked up before the animation takes place <ide> describe('ngInclude ngAnimate', function() { <ide> inject(function($compile, $rootScope, $templateCache, $sniffer) { <ide> $templateCache.put('enter', [200, '<div>data</div>', {}]); <ide> $rootScope.tpl = 'enter'; <del> element = $compile( <add> element = $compile(html( <ide> '<div ' + <ide> 'ng-include="tpl" ' + <ide> 'ng-animate="{enter: \'custom-enter\'}">' + <ide> '</div>' <del> )($rootScope); <add> ))($rootScope); <ide> $rootScope.$digest(); <ide> <ide> //if we add the custom css stuff here then it will get picked up before the animation takes place <ide><path>test/ng/directive/ngRepeatSpec.js <ide> describe('ngRepeat', function() { <ide> }); <ide> <ide> describe('ngRepeat ngAnimate', function() { <del> var element, vendorPrefix, window; <add> var vendorPrefix, window; <add> var body, element; <add> <add> function html(html) { <add> body.html(html); <add> element = body.children().eq(0); <add> return element; <add> } <add> <add> beforeEach(function() { <add> // we need to run animation on attached elements; <add> body = jqLite(document.body); <add> }); <add> <add> afterEach(function(){ <add> dealoc(body); <add> dealoc(element); <add> }); <ide> <ide> beforeEach(module(function($animationProvider, $provide) { <ide> $provide.value('$window', window = angular.mock.createMockWindow()); <ide> describe('ngRepeat ngAnimate', function() { <ide> }; <ide> })); <ide> <del> afterEach(function(){ <del> dealoc(element); <del> }); <del> <ide> it('should fire off the enter animation + add and remove the css classes', <ide> inject(function($compile, $rootScope, $sniffer) { <ide> <del> element = $compile( <add> element = $compile(html( <ide> '<div><div ' + <ide> 'ng-repeat="item in items" ' + <ide> 'ng-animate="{enter: \'custom-enter\'}">' + <ide> '{{ item }}' + <ide> '</div></div>' <del> )($rootScope); <add> ))($rootScope); <add> <add> $rootScope.$digest(); // re-enable the animations; <ide> <ide> $rootScope.items = ['1','2','3']; <ide> $rootScope.$digest(); <ide> describe('ngRepeat ngAnimate', function() { <ide> it('should fire off the leave animation + add and remove the css classes', <ide> inject(function($compile, $rootScope, $sniffer) { <ide> <del> element = $compile( <add> element = $compile(html( <ide> '<div><div ' + <ide> 'ng-repeat="item in items" ' + <ide> 'ng-animate="{leave: \'custom-leave\'}">' + <ide> '{{ item }}' + <ide> '</div></div>' <del> )($rootScope); <add> ))($rootScope); <ide> <ide> $rootScope.items = ['1','2','3']; <ide> $rootScope.$digest(); <ide> describe('ngRepeat ngAnimate', function() { <ide> <ide> it('should fire off the move animation + add and remove the css classes', <ide> inject(function($compile, $rootScope, $sniffer) { <del> element = $compile( <add> element = $compile(html( <ide> '<div>' + <ide> '<div ng-repeat="item in items" ng-animate="{move: \'custom-move\'}">' + <ide> '{{ item }}' + <ide> '</div>' + <ide> '</div>' <del> )($rootScope); <add> ))($rootScope); <ide> <ide> $rootScope.items = ['1','2','3']; <ide> $rootScope.$digest(); <ide> describe('ngRepeat ngAnimate', function() { <ide> it('should catch and use the correct duration for animation', <ide> inject(function($compile, $rootScope, $sniffer) { <ide> <del> element = $compile( <add> element = $compile(html( <ide> '<div><div ' + <ide> 'ng-repeat="item in items" ' + <ide> 'ng-animate="{enter: \'custom-enter\'}">' + <ide> '{{ item }}' + <ide> '</div></div>' <del> )($rootScope); <add> ))($rootScope); <add> <add> $rootScope.$digest(); // re-enable the animations; <ide> <ide> $rootScope.items = ['a','b']; <ide> $rootScope.$digest(); <ide><path>test/ng/directive/ngShowHideSpec.js <ide> describe('ngShow / ngHide', function() { <ide> }); <ide> <ide> describe('ngShow / ngHide - ngAnimate', function() { <del> var element, window; <add> var window; <ide> var vendorPrefix; <add> var body, element; <add> <add> function html(html) { <add> body.html(html); <add> element = body.children().eq(0); <add> return element; <add> } <add> <add> beforeEach(function() { <add> // we need to run animation on attached elements; <add> body = jqLite(document.body); <add> }); <add> <add> afterEach(function(){ <add> dealoc(body); <add> dealoc(element); <add> }); <ide> <ide> beforeEach(module(function($animationProvider, $provide) { <ide> $provide.value('$window', window = angular.mock.createMockWindow()); <ide> describe('ngShow / ngHide - ngAnimate', function() { <ide> }; <ide> })); <ide> <del> afterEach(function() { <del> dealoc(element); <del> }); <del> <ide> describe('ngShow', function() { <ide> it('should fire off the animator.show and animator.hide animation', inject(function($compile, $rootScope, $sniffer) { <ide> var $scope = $rootScope.$new(); <ide> $scope.on = true; <del> element = $compile( <add> element = $compile(html( <ide> '<div ' + <ide> 'style="'+vendorPrefix+'transition: 1s linear all"' + <ide> 'ng-show="on" ' + <del> 'ng-animate="{show: \'custom-show\', hide: \'custom-hide\'}">' + <add> 'ng-animate="{show: \'custom-show\', hide: \'custom-hide\', animateFirst: true}">' + <ide> '</div>' <del> )($scope); <add> ))($scope); <ide> $scope.$digest(); <ide> <ide> if ($sniffer.supportsTransitions) { <ide> describe('ngShow / ngHide - ngAnimate', function() { <ide> expect(element.attr('class')).not.toContain('custom-hide-start'); <ide> expect(element.attr('class')).not.toContain('custom-hide-setup'); <ide> })); <add> <add> it('should skip the initial show state on the first digest', function() { <add> var fired = false; <add> inject(function($compile, $rootScope, $sniffer) { <add> $rootScope.val = true; <add> var element = $compile(html('<div ng-show="val" ng-animate="\'animation\'">123</div>'))($rootScope); <add> element.css('display','none'); <add> expect(element.css('display')).toBe('none'); <add> <add> $rootScope.$digest(); <add> expect(element[0].style.display).toBe(''); <add> expect(fired).toBe(false); <add> <add> $rootScope.val = false; <add> $rootScope.$digest(); <add> if ($sniffer.supportsTransitions) { <add> window.setTimeout.expect(1).process(); <add> window.setTimeout.expect(0).process(); <add> } else { <add> expect(window.setTimeout.queue).toEqual([]); <add> } <add> expect(element[0].style.display).toBe('none'); <add> }); <add> }); <ide> }); <ide> <ide> describe('ngHide', function() { <ide> it('should fire off the animator.show and animator.hide animation', inject(function($compile, $rootScope, $sniffer) { <ide> var $scope = $rootScope.$new(); <ide> $scope.off = true; <del> element = $compile( <add> element = $compile(html( <ide> '<div ' + <ide> 'style="'+vendorPrefix+'transition: 1s linear all"' + <ide> 'ng-hide="off" ' + <del> 'ng-animate="{show: \'custom-show\', hide: \'custom-hide\'}">' + <del> '</div>' <del> )($scope); <add> 'ng-animate="{show: \'custom-show\', hide: \'custom-hide\', animateFirst: true}">' + <add> '</div>' <add> ))($scope); <ide> $scope.$digest(); <ide> <ide> if ($sniffer.supportsTransitions) { <ide> describe('ngShow / ngHide - ngAnimate', function() { <ide> expect(element.attr('class')).not.toContain('custom-show-start'); <ide> expect(element.attr('class')).not.toContain('custom-show-setup'); <ide> })); <add> <add> it('should skip the initial hide state on the first digest', function() { <add> var fired = false; <add> module(function($animationProvider) { <add> $animationProvider.register('destructive-animation', function() { <add> return { <add> setup : function() {}, <add> start : function(element, done) { <add> fired = true; <add> } <add> }; <add> }); <add> }); <add> inject(function($compile, $rootScope) { <add> $rootScope.val = false; <add> var element = $compile(html('<div ng-hide="val" ng-animate="{ hide:\'destructive-animation\' }">123</div>'))($rootScope); <add> element.css('display','block'); <add> expect(element.css('display')).toBe('block'); <add> <add> $rootScope.val = true; <add> $rootScope.$digest(); <add> <add> expect(element.css('display')).toBe('none'); <add> expect(fired).toBe(false); <add> }); <add> }); <ide> }); <ide> }); <ide><path>test/ng/directive/ngSwitchSpec.js <ide> describe('ngSwitch', function() { <ide> }); <ide> <ide> describe('ngSwitch ngAnimate', function() { <del> var element, vendorPrefix, window; <add> var vendorPrefix, window; <add> var body, element; <add> <add> function html(html) { <add> body.html(html); <add> element = body.children().eq(0); <add> return element; <add> } <add> <add> beforeEach(function() { <add> // we need to run animation on attached elements; <add> body = jqLite(document.body); <add> }); <add> <add> afterEach(function(){ <add> dealoc(body); <add> dealoc(element); <add> }); <ide> <ide> beforeEach(module(function($animationProvider, $provide) { <ide> $provide.value('$window', window = angular.mock.createMockWindow()); <ide> describe('ngSwitch ngAnimate', function() { <ide> }; <ide> })); <ide> <del> afterEach(function(){ <del> dealoc(element); <del> }); <del> <ide> it('should fire off the enter animation + set and remove the classes', <ide> inject(function($compile, $rootScope, $sniffer) { <ide> var $scope = $rootScope.$new(); <ide> var style = vendorPrefix + 'transition: 1s linear all'; <del> element = $compile( <add> element = $compile(html( <ide> '<div ng-switch on="val" ng-animate="{enter: \'cool-enter\', leave: \'cool-leave\'}">' + <ide> '<div ng-switch-when="one" style="' + style + '">one</div>' + <ide> '<div ng-switch-when="two" style="' + style + '">two</div>' + <ide> '<div ng-switch-when="three" style="' + style + '">three</div>' + <ide> '</div>' <del> )($scope); <add> ))($scope); <ide> <add> $rootScope.$digest(); // re-enable the animations; <ide> $scope.val = 'one'; <ide> $scope.$digest(); <ide> <ide> describe('ngSwitch ngAnimate', function() { <ide> inject(function($compile, $rootScope, $sniffer) { <ide> var $scope = $rootScope.$new(); <ide> var style = vendorPrefix + 'transition: 1s linear all'; <del> element = $compile( <add> element = $compile(html( <ide> '<div ng-switch on="val" ng-animate="{enter: \'cool-enter\', leave: \'cool-leave\'}">' + <ide> '<div ng-switch-when="one" style="' + style + '">one</div>' + <ide> '<div ng-switch-when="two" style="' + style + '">two</div>' + <ide> '<div ng-switch-when="three" style="' + style + '">three</div>' + <ide> '</div>' <del> )($scope); <add> ))($scope); <ide> <add> $rootScope.$digest(); // re-enable the animations; <ide> $scope.val = 'two'; <ide> $scope.$digest(); <ide> <ide> describe('ngSwitch ngAnimate', function() { <ide> <ide> it('should catch and use the correct duration for animation', <ide> inject(function($compile, $rootScope, $sniffer) { <del> element = $compile( <add> element = $compile(html( <ide> '<div ng-switch on="val" ng-animate="{enter: \'cool-enter\', leave: \'cool-leave\'}">' + <ide> '<div ng-switch-when="one" style="' + vendorPrefix + 'transition: 0.5s linear all">one</div>' + <ide> '</div>' <del> )($rootScope); <add> ))($rootScope); <ide> <add> $rootScope.$digest(); // re-enable the animations; <ide> $rootScope.val = 'one'; <ide> $rootScope.$digest(); <ide> <ide><path>test/ng/directive/ngViewSpec.js <ide> describe('ngView', function() { <ide> }); <ide> <ide> describe('ngAnimate', function() { <del> var element, window; <add> var window; <add> var body, element; <add> <add> function html(html) { <add> body.html(html); <add> element = body.children().eq(0); <add> return element; <add> } <add> <add> beforeEach(function() { <add> // we need to run animation on attached elements; <add> body = jqLite(document.body); <add> }); <add> <add> afterEach(function(){ <add> dealoc(body); <add> dealoc(element); <add> }); <add> <add> <ide> <ide> beforeEach(module(function($provide, $routeProvider) { <ide> $provide.value('$window', window = angular.mock.createMockWindow()); <ide> describe('ngAnimate', function() { <ide> } <ide> })); <ide> <del> afterEach(function(){ <del> dealoc(element); <del> }); <del> <ide> it('should fire off the enter animation + add and remove the css classes', <ide> inject(function($compile, $rootScope, $sniffer, $location, $templateCache) { <del> element = $compile('<div ng-view ng-animate="{enter: \'custom-enter\'}"></div>')($rootScope); <add> element = $compile(html('<div ng-view ng-animate="{enter: \'custom-enter\'}"></div>'))($rootScope); <ide> <ide> $location.path('/foo'); <ide> $rootScope.$digest(); <ide> describe('ngAnimate', function() { <ide> it('should fire off the leave animation + add and remove the css classes', <ide> inject(function($compile, $rootScope, $sniffer, $location, $templateCache) { <ide> $templateCache.put('/foo.html', [200, '<div>foo</div>', {}]); <del> element = $compile('<div ng-view ng-animate="{leave: \'custom-leave\'}"></div>')($rootScope); <add> element = $compile(html('<div ng-view ng-animate="{leave: \'custom-leave\'}"></div>'))($rootScope); <ide> <ide> $location.path('/foo'); <ide> $rootScope.$digest(); <ide> describe('ngAnimate', function() { <ide> it('should catch and use the correct duration for animations', <ide> inject(function($compile, $rootScope, $sniffer, $location, $templateCache) { <ide> $templateCache.put('/foo.html', [200, '<div>foo</div>', {}]); <del> element = $compile( <add> element = $compile(html( <ide> '<div ' + <ide> 'ng-view ' + <del> 'ng-animate="{enter: \'customEnter\'}">' + <add> 'ng-animate="{enter: \'customEnter\', animateFirst: false}">' + <ide> '</div>' <del> )($rootScope); <add> ))($rootScope); <ide> <ide> $location.path('/foo'); <ide> $rootScope.$digest();
8
Ruby
Ruby
remove unnecessary explicit return val
f82da9009fe0f862df5ed534d3914a51bf4718f2
<ide><path>Library/Homebrew/utils/update.rb <ide> def display_version_data(outdated_packages) <ide> puts "==============Formatted outdated packages============\n" <ide> <ide> outdated_packages.each do |package_name, package_details| <del> puts "" <del> puts "Formula: #{package_name}" <add> puts "\nFormula: #{package_name}" <ide> puts "Current formula version: #{package_details['homebrew_version']}" <ide> puts "Repology latest version: #{package_details['repology_version']}" <ide> puts "Livecheck latest version: #{package_details['livecheck_latest_version']}" <ide><path>scripts/helpers/brew_commands.rb <ide> require "open3" <ide> <ide> class BrewCommands <del> <add> <ide> def livecheck_check_formula(formula_name) <ide> puts "- livecheck formula : #{formula_name}" <ide> command_args = [ <ide> def parse_livecheck_response(livecheck_output) <ide> <ide> # eg: ["burp", "2.2.18", "2.2.18"] <ide> package_name, brew_version, latest_version = livecheck_output <del> <add> <ide> {'name' => package_name, 'current_brew_version' => brew_version, 'livecheck_latest_version' => latest_version} <ide> end <ide> <ide> def bump_formula_pr(formula_name, url) <ide> <ide> def parse_formula_bump_response(formula_bump_response) <ide> response, status = formula_bump_response <del> response <add> response <ide> end <ide> <ide> def check_for_open_pr(formula_name, download_url) <ide> puts "- Checking for open PRs for formula : #{formula_name}" <ide> <ide> response = bump_formula_pr(formula_name, download_url) <ide> <del> return true if !response.include? 'Error: These open pull requests may be duplicates' <del> false <del> end <add> !response.include? 'Error: These open pull requests may be duplicates' <add> end <ide> <del>end <ide>\ No newline at end of file <add>end
2
Javascript
Javascript
remove sha from test expectations
00a55e62877faab053dbbe1178488f7cf8dee466
<ide><path>test/parallel/test-crypto.js <ide> const noCapitals = /^[^A-Z]+$/; <ide> assert(tlsCiphers.every((value) => noCapitals.test(value))); <ide> validateList(tlsCiphers); <ide> <del>// Assert that we have sha and sha1 but not SHA and SHA1. <add>// Assert that we have sha1 and sha256 but not SHA1 and SHA256. <ide> assert.notStrictEqual(0, crypto.getHashes().length); <ide> assert(crypto.getHashes().includes('sha1')); <del>assert(crypto.getHashes().includes('sha')); <add>assert(crypto.getHashes().includes('sha256')); <ide> assert(!crypto.getHashes().includes('SHA1')); <del>assert(!crypto.getHashes().includes('SHA')); <add>assert(!crypto.getHashes().includes('SHA256')); <ide> assert(crypto.getHashes().includes('RSA-SHA1')); <ide> assert(!crypto.getHashes().includes('rsa-sha1')); <ide> validateList(crypto.getHashes());
1
Python
Python
fix typo in naming
0f4dc5d864e2d80396d56067e2fb4479349c5289
<ide><path>src/transformers/models/bart/modeling_tf_bart.py <ide> def call( <ide> past_key_values=outputs.past_key_values, # index 1 of d outputs <ide> decoder_hidden_states=outputs.decoder_hidden_states, # index 2 of d outputs <ide> decoder_attentions=outputs.decoder_attentions, # index 3 of d outputs <del> encoder_last_hidden_state=outputs.last_hidden_state, # index 0 of encoder outputs <add> encoder_last_hidden_state=outputs.encoder_last_hidden_state, # index 0 of encoder outputs <ide> encoder_hidden_states=outputs.encoder_hidden_states, # 1 of e out <ide> encoder_attentions=outputs.encoder_attentions, # 2 of e out <ide> ) <ide><path>src/transformers/models/blenderbot/modeling_tf_blenderbot.py <ide> def call( <ide> past_key_values=outputs.past_key_values, # index 1 of d outputs <ide> decoder_hidden_states=outputs.decoder_hidden_states, # index 2 of d outputs <ide> decoder_attentions=outputs.decoder_attentions, # index 3 of d outputs <del> encoder_last_hidden_state=outputs.last_hidden_state, # index 0 of encoder outputs <add> encoder_last_hidden_state=outputs.encoder_last_hidden_state, # index 0 of encoder outputs <ide> encoder_hidden_states=outputs.encoder_hidden_states, # 1 of e out <ide> encoder_attentions=outputs.encoder_attentions, # 2 of e out <ide> ) <ide><path>src/transformers/models/blenderbot_small/modeling_tf_blenderbot_small.py <ide> def call( <ide> past_key_values=outputs.past_key_values, # index 1 of d outputs <ide> decoder_hidden_states=outputs.decoder_hidden_states, # index 2 of d outputs <ide> decoder_attentions=outputs.decoder_attentions, # index 3 of d outputs <del> encoder_last_hidden_state=outputs.last_hidden_state, # index 0 of encoder outputs <add> encoder_last_hidden_state=outputs.encoder_last_hidden_state, # index 0 of encoder outputs <ide> encoder_hidden_states=outputs.encoder_hidden_states, # 1 of e out <ide> encoder_attentions=outputs.encoder_attentions, # 2 of e out <ide> ) <ide><path>src/transformers/models/mbart/modeling_tf_mbart.py <ide> def call( <ide> past_key_values=outputs.past_key_values, # index 1 of d outputs <ide> decoder_hidden_states=outputs.decoder_hidden_states, # index 2 of d outputs <ide> decoder_attentions=outputs.decoder_attentions, # index 3 of d outputs <del> encoder_last_hidden_state=outputs.last_hidden_state, # index 0 of encoder outputs <add> encoder_last_hidden_state=outputs.encoder_last_hidden_state, # index 0 of encoder outputs <ide> encoder_hidden_states=outputs.encoder_hidden_states, # 1 of e out <ide> encoder_attentions=outputs.encoder_attentions, # 2 of e out <ide> ) <ide><path>src/transformers/models/pegasus/modeling_tf_pegasus.py <ide> def call( <ide> past_key_values=outputs.past_key_values, # index 1 of d outputs <ide> decoder_hidden_states=outputs.decoder_hidden_states, # index 2 of d outputs <ide> decoder_attentions=outputs.decoder_attentions, # index 3 of d outputs <del> encoder_last_hidden_state=outputs.last_hidden_state, # index 0 of encoder outputs <add> encoder_last_hidden_state=outputs.encoder_last_hidden_state, # index 0 of encoder outputs <ide> encoder_hidden_states=outputs.encoder_hidden_states, # 1 of e out <ide> encoder_attentions=outputs.encoder_attentions, # 2 of e out <ide> ) <ide><path>templates/adding_a_new_model/cookiecutter-template-{{cookiecutter.modelname}}/modeling_tf_{{cookiecutter.lowercase_modelname}}.py <ide> def call( <ide> past_key_values=outputs.past_key_values, # index 1 of d outputs <ide> decoder_hidden_states=outputs.decoder_hidden_states, # index 2 of d outputs <ide> decoder_attentions=outputs.decoder_attentions, # index 3 of d outputs <del> encoder_last_hidden_state=outputs.last_hidden_state, # index 0 of encoder outputs <add> encoder_last_hidden_state=outputs.encoder_last_hidden_state, # index 0 of encoder outputs <ide> encoder_hidden_states=outputs.encoder_hidden_states, # 1 of e out <ide> encoder_attentions=outputs.encoder_attentions, # 2 of e out <ide> )
6
Javascript
Javascript
remove unused variable
b6621397085f0d542d2ee79048978ec014c2a970
<ide><path>src/js/media.html5.js <ide> vjs.Html5.canPlaySource = function(srcObj){ <ide> }; <ide> <ide> vjs.Html5.canControlVolume = function(){ <del> var <del> volume = vjs.TEST_VID.volume, <del> volumeOptions = {}; <add> var volume = vjs.TEST_VID.volume; <ide> vjs.TEST_VID.volume = (volume / 2) + 0.1; <ide> return volume !== vjs.TEST_VID.volume; <ide> };
1
Text
Text
update changelog.md for 2.8.0
f9a9dca98f028f22c6817983d77b6606994c5a43
<ide><path>CHANGELOG.md <ide> # Ember Changelog <ide> <del>### 2.8.0-beta.5 (August 30, 2016) <add>### 2.8.0 (September 8, 2016) <ide> <add>- [#14229](https://github.com/emberjs/ember.js/pull/14229) [BUGFIX] Fix boot errors with `location: 'auto'` when using IE9. <add>- [#14219](https://github.com/emberjs/ember.js/pull/14219) [BUGFIX] Fix issue with template meta (i.e. compiled template `moduleName`) was being mutated during the rendering process. <ide> - [#14159](https://github.com/emberjs/ember.js/pull/14159) [BUGFIX] Fix rendering system cleanup. <del> <del>### 2.8.0-beta.4 (August 29, 2016) <del> <ide> - [#14123](https://github.com/emberjs/ember.js/pull/14123) [BUGFIX] Avoid rerendering outlet state during router destruction. <ide> - [#14077](https://github.com/emberjs/ember.js/pull/14077) [BUGFIX] Update route-recognizer. <ide> - [#14087](https://github.com/emberjs/ember.js/pull/14087) [BUGFIX] Check that route handler exists before triggering actions. <ide> - [#14117](https://github.com/emberjs/ember.js/pull/14117) [BUGFIX] Call ArrayProxy's content change hooks <ide> - [#14135](https://github.com/emberjs/ember.js/pull/14135) [BUGFIX] Fix issues around Engine setup and teardown. <ide> - [#14140](https://github.com/emberjs/ember.js/pull/14140) [BUGFIX] Ensure component injections happen in engine instances. <del> <del> <del>### 2.8.0-beta.3 (August 15, 2016) <del> <ide> - [#14009](https://github.com/emberjs/ember.js/pull/14009) [BUGFIX] Fix usage of `role` when used in `attributeBindings`. <ide> - [#14044](https://github.com/emberjs/ember.js/pull/14044) / [#14062](https://github.com/emberjs/ember.js/pull/14062) / [#14066](https://github.com/emberjs/ember.js/pull/14066) [BUGFIX] Update `router.js` so that `getHandlers` is invoked lazily. <ide> - [#14054](https://github.com/emberjs/ember.js/pull/14054) [BUGFIX] Ensure substates properly work with `resetNamespace`. <ide> - [#14033](https://github.com/emberjs/ember.js/pull/14033) [BUGFIX] Ensure `fillIn` acceptance test helper only sets value to first matched element. <ide> - [#14058](https://github.com/emberjs/ember.js/pull/14058) [BUGFIX] Fix issues related to `Ember.Router.map` changes in 2.7.0. <ide> - [#14068](https://github.com/emberjs/ember.js/pull/14068) [BUGFIX] Prevent errors when clicking a `{{link-to}}` during an existing transition. <del> <del> <del>### 2.8.0-beta.2 (August 1, 2016) <del> <ide> - [#13887](https://github.com/emberjs/ember.js/pull/13887) [BUGFIX] Add assertions for illegal component invocations. <ide> - [#13892](https://github.com/emberjs/ember.js/pull/13892) [CLEANUP] Remove `View#createElement` / `View#destroyElement`. <ide> - [#13895](https://github.com/emberjs/ember.js/pull/13895) [BUGFIX] Fix template meta lookup for nested tagless and blockless components. <ide> - [#13911](https://github.com/emberjs/ember.js/pull/13911) [BUGFIX] Avoid using clobbering `.env` property on components. <ide> - [#13913](https://github.com/emberjs/ember.js/pull/13913) [BUGFIX] Disallow paths beginning with @ in templates. <ide> - [#13920](https://github.com/emberjs/ember.js/pull/13920) [BUGFIX] Add more info to the `Ember.Binding` deprecation. <del> <del>### 2.8.0-beta.1 (July 25, 2016) <del> <ide> - [#13757](https://github.com/emberjs/ember.js/pull/13757) / [#13773](https://github.com/emberjs/ember.js/pull/13773) [CLEANUP] Remove legacy view layer features. <ide> - [#13819](https://github.com/emberjs/ember.js/pull/13819) [DOC] Add documentation for container (getOwner, etc.) <ide> - [#13855](https://github.com/emberjs/ember.js/pull/13855) [FEATURE ember-string-ishtmlsafe] Enable by defaut.
1
Ruby
Ruby
allow multiple digits in github version parts
5aa6aefa9664597ae9f004a9e0cb58edd31a2d6e
<ide><path>Library/Homebrew/extend/pathname.rb <ide> def version <ide> end <ide> <ide> # github tarballs, like v1.2.3 <del> %r[github.com/.*/(zip|tar)ball/v?((\d\.)+\d+)$].match to_s <add> %r[github.com/.*/(zip|tar)ball/v?((\d+\.)+\d+)$].match to_s <ide> return $2 if $2 <ide> <ide> # eg. https://github.com/sam-github/libnet/tarball/libnet-1.1.4 <del> %r[github.com/.*/(zip|tar)ball/.*-((\d\.)+\d+)$].match to_s <add> %r[github.com/.*/(zip|tar)ball/.*-((\d+\.)+\d+)$].match to_s <ide> return $2 if $2 <ide> <ide> # dashed version <ide> # eg. github.com/isaacs/npm/tarball/v0.2.5-1 <del> %r[github.com/.*/(zip|tar)ball/v?((\d\.)+\d+-(\d+))$].match to_s <add> %r[github.com/.*/(zip|tar)ball/v?((\d+\.)+\d+-(\d+))$].match to_s <ide> return $2 if $2 <ide> <ide> # underscore version <ide> # eg. github.com/petdance/ack/tarball/1.93_02 <del> %r[github.com/.*/(zip|tar)ball/v?((\d\.)+\d+_(\d+))$].match to_s <add> %r[github.com/.*/(zip|tar)ball/v?((\d+\.)+\d+_(\d+))$].match to_s <ide> return $2 if $2 <ide> <ide> # eg. boost_1_39_0
1
Text
Text
fix minor typo in how-to-create-and-maintain-a-tap
157a9191e3505d3b2eba1954143875787a7434d1
<ide><path>docs/How-to-Create-and-Maintain-a-Tap.md <ide> If they want to get your tap without installing any formula at the same time, <ide> users can add it with the [`brew tap` command](Taps.md). <ide> <ide> If it’s on GitHub, they can use `brew tap user/repo`, where `user` is your <del>GitHub username and `homebrew-repo` your repository. <add>GitHub username and `homebrew-repo` is your repository. <ide> <ide> If it’s hosted outside of GitHub, they have to use `brew tap user/repo <URL>`, <ide> where `user` and `repo` will be used to refer to your tap and `<URL>` is your
1
Javascript
Javascript
update http tests for econnreset change
862b16420918a56284a794c7de040a7ca5783d6b
<ide><path>test/simple/test-http-conn-reset.js <ide> function onListen() { <ide> }); <ide> req.on('error', function(err) { <ide> assert.equal(err.code, 'ECONNRESET'); <del> assert.equal(err.message, 'socket hang up'); <ide> caughtError = true; <ide> }); <ide> req.end(); <ide><path>test/simple/test-http-multi-line-headers.js <ide> var server = net.createServer(function(conn) { <ide> '\r\n' + <ide> body; <ide> <del> conn.write(response, function() { <del> conn.destroy(); <del> server.close(); <del> }); <add> conn.end(response); <add> server.close(); <ide> }); <ide> <ide> server.listen(common.PORT, function() { <ide> http.get({host: '127.0.0.1', port: common.PORT}, function(res) { <ide> assert.equal(res.headers['content-type'], <ide> 'text/plain;x-unix-mode=0600;name="hello.txt"'); <ide> gotResponse = true; <add> res.destroy(); <ide> }); <ide> }); <ide> <ide><path>test/simple/test-http-response-no-headers.js <ide> function test(httpVersion, callback) { <ide> var reply = 'HTTP/' + httpVersion + ' 200 OK\r\n\r\n' + <ide> expected[httpVersion]; <ide> <del> conn.write(reply, function() { <del> conn.destroy(); <del> }); <add> conn.end(reply); <ide> }); <ide> <ide> server.listen(common.PORT, '127.0.0.1', function() {
3
PHP
PHP
make wherein defalut to loose comparison
2f2f293ba232d69a8cb0b5ac81d78878b8d987af
<ide><path>src/Illuminate/Support/Collection.php <ide> protected function operatorForWhere($key, $operator, $value) <ide> * @param bool $strict <ide> * @return static <ide> */ <del> public function whereIn($key, array $values, $strict = true) <add> public function whereIn($key, array $values, $strict = false) <ide> { <ide> return $this->filter(function ($item) use ($key, $values, $strict) { <ide> return in_array(data_get($item, $key), $values, $strict); <ide> }); <ide> } <ide> <ide> /** <del> * Filter items by the given key value pair using loose comparison. <add> * Filter items by the given key value pair using strict comparison. <ide> * <ide> * @param string $key <ide> * @param array $values <ide> * @return static <ide> */ <del> public function whereInLoose($key, array $values) <add> public function whereInStrict($key, array $values) <ide> { <del> return $this->whereIn($key, $values, false); <add> return $this->whereIn($key, $values, true); <ide> } <ide> <ide> /** <ide><path>tests/Support/SupportCollectionTest.php <ide> public function testWhere() <ide> public function testWhereIn() <ide> { <ide> $c = new Collection([['v' => 1], ['v' => 2], ['v' => 3], ['v' => '3'], ['v' => 4]]); <del> $this->assertEquals([['v' => 1], ['v' => 3]], $c->whereIn('v', [1, 3])->values()->all()); <add> $this->assertEquals([['v' => 1], ['v' => 3], ['v' => '3']], $c->whereIn('v', [1, 3])->values()->all()); <ide> } <ide> <del> public function testWhereInLoose() <add> public function testWhereInStrict() <ide> { <ide> $c = new Collection([['v' => 1], ['v' => 2], ['v' => 3], ['v' => '3'], ['v' => 4]]); <del> $this->assertEquals([['v' => 1], ['v' => 3], ['v' => '3']], $c->whereInLoose('v', [1, 3])->values()->all()); <add> $this->assertEquals([['v' => 1], ['v' => 3]], $c->whereInStrict('v', [1, 3])->values()->all()); <ide> } <ide> <ide> public function testValues()
2
Go
Go
remove portbinding.fromstring() as it's unused
7c0d8fa5da077b092310a7d895677ffb54348c93
<ide><path>libnetwork/types/types.go <ide> func (p *PortBinding) String() string { <ide> return ret <ide> } <ide> <del>// FromString reads the PortBinding structure from string s. <del>// String s is a triple of "protocol/containerIP:port/hostIP:port" <del>// containerIP and hostIP can be in dotted decimal ("192.0.2.1") or IPv6 ("2001:db8::68") form. <del>// Zoned addresses ("169.254.0.23%eth0" or "fe80::1ff:fe23:4567:890a%eth0") are not supported. <del>// If string s is incorrectly formatted or the IP addresses or ports cannot be parsed, FromString <del>// returns an error. <del>func (p *PortBinding) FromString(s string) error { <del> ps := strings.Split(s, "/") <del> if len(ps) != 3 { <del> return BadRequestErrorf("invalid format for port binding: %s", s) <del> } <del> <del> p.Proto = ParseProtocol(ps[0]) <del> <del> var err error <del> if p.IP, p.Port, err = parseIPPort(ps[1]); err != nil { <del> return BadRequestErrorf("failed to parse Container IP/Port in port binding: %s", err.Error()) <del> } <del> <del> if p.HostIP, p.HostPort, err = parseIPPort(ps[2]); err != nil { <del> return BadRequestErrorf("failed to parse Host IP/Port in port binding: %s", err.Error()) <del> } <del> <del> return nil <del>} <del> <del>func parseIPPort(s string) (net.IP, uint16, error) { <del> hoststr, portstr, err := net.SplitHostPort(s) <del> if err != nil { <del> return nil, 0, err <del> } <del> <del> ip := net.ParseIP(hoststr) <del> if ip == nil { <del> return nil, 0, BadRequestErrorf("invalid ip: %s", hoststr) <del> } <del> <del> port, err := strconv.ParseUint(portstr, 10, 16) <del> if err != nil { <del> return nil, 0, BadRequestErrorf("invalid port: %s", portstr) <del> } <del> <del> return ip, uint16(port), nil <del>} <del> <ide> // Equal checks if this instance of PortBinding is equal to the passed one <ide> func (p *PortBinding) Equal(o *PortBinding) bool { <ide> if p == o { <ide><path>libnetwork/types/types_test.go <ide> package types <ide> import ( <ide> "net" <ide> "testing" <del> <del> "gotest.tools/v3/assert" <del> is "gotest.tools/v3/assert/cmp" <ide> ) <ide> <ide> func TestTransportPortConv(t *testing.T) { <ide> func TestTransportPortConv(t *testing.T) { <ide> } <ide> } <ide> <del>func TestTransportPortBindingConv(t *testing.T) { <del> input := []struct { <del> sform string <del> pb PortBinding <del> shouldFail bool <del> }{ <del> { // IPv4 -> IPv4 <del> sform: "tcp/172.28.30.23:80/112.0.43.56:8001", <del> pb: PortBinding{ <del> Proto: TCP, <del> IP: net.IPv4(172, 28, 30, 23), <del> Port: uint16(80), <del> HostIP: net.IPv4(112, 0, 43, 56), <del> HostPort: uint16(8001), <del> }, <del> }, <del> { // IPv6 -> IPv4 <del> sform: "tcp/[2001:db8::1]:80/112.0.43.56:8001", <del> pb: PortBinding{ <del> Proto: TCP, <del> IP: net.IP{0x20, 0x01, 0x0d, 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}, <del> Port: uint16(80), <del> HostIP: net.IPv4(112, 0, 43, 56), <del> HostPort: uint16(8001), <del> }, <del> }, <del> { // IPv4inIPv6 -> IPv4 <del> sform: "tcp/[::ffff:172.28.30.23]:80/112.0.43.56:8001", <del> pb: PortBinding{ <del> Proto: TCP, <del> IP: net.IPv4(172, 28, 30, 23), <del> Port: uint16(80), <del> HostIP: net.IPv4(112, 0, 43, 56), <del> HostPort: uint16(8001), <del> }, <del> }, <del> { // IPv4 -> IPv4 zoned <del> sform: "tcp/172.28.30.23:80/169.254.0.23%eth0:8001", <del> shouldFail: true, <del> }, <del> { // IPv4 -> IPv6 zoned <del> sform: "tcp/172.28.30.23:80/[fe80::1ff:fe23:4567:890a%eth0]:8001", <del> shouldFail: true, <del> }, <del> } <del> <del> for _, in := range input { <del> rc := new(PortBinding) <del> err := rc.FromString(in.sform) <del> if in.shouldFail { <del> assert.Assert(t, is.ErrorContains(err, ""), "Unexpected success parsing %s", in.sform) <del> } else { <del> assert.NilError(t, err) <del> assert.Assert(t, is.DeepEqual(in.pb, *rc), "input %s: expected %#v, got %#v", in.sform, in.pb, rc) <del> } <del> } <del>} <del> <ide> func TestErrorConstructors(t *testing.T) { <ide> var err error <ide>
2
Javascript
Javascript
replace usage of debug statements in ember-debug
847a7869f552ac480a09530b892b71f40450ec74
<ide><path>packages/ember-debug/lib/deprecate.js <ide> import Ember from 'ember-metal/core'; <ide> import EmberError from 'ember-metal/error'; <ide> import Logger from 'ember-metal/logger'; <add> <ide> import { registerHandler as genericRegisterHandler, invoke } from 'ember-debug/handlers'; <ide> <ide> export function registerHandler(handler) { <ide><path>packages/ember-debug/lib/main.js <ide> import Ember from 'ember-metal/core'; <del>import { setDebugFunction } from 'ember-metal/debug'; <add>import { <add> warn, <add> deprecate, <add> debug, <add> setDebugFunction <add>} from 'ember-metal/debug'; <ide> import isEnabled, { FEATURES } from 'ember-metal/features'; <ide> import EmberError from 'ember-metal/error'; <ide> import Logger from 'ember-metal/logger'; <ide> import environment from 'ember-metal/environment'; <del>import deprecate, { <add>import _deprecate, { <ide> registerHandler as registerDeprecationHandler <ide> } from 'ember-debug/deprecate'; <del>import warn, { <add>import _warn, { <ide> registerHandler as registerWarnHandler <ide> } from 'ember-debug/warn'; <ide> import isPlainFunction from 'ember-debug/is-plain-function'; <ide> import isPlainFunction from 'ember-debug/is-plain-function'; <ide> its return value will be used as condition. <ide> @public <ide> */ <del>function assert(desc, test) { <add>setDebugFunction('assert', function assert(desc, test) { <ide> var throwAssertion; <ide> <ide> if (isPlainFunction(test)) { <ide> function assert(desc, test) { <ide> if (throwAssertion) { <ide> throw new EmberError('Assertion Failed: ' + desc); <ide> } <del>} <add>}); <ide> <ide> /** <ide> Display a debug notice. Ember build tools will remove any calls to <ide> function assert(desc, test) { <ide> @param {String} message A debug message to display. <ide> @public <ide> */ <del>function debug(message) { <add>setDebugFunction('debug', function debug(message) { <ide> Logger.debug('DEBUG: ' + message); <del>} <add>}); <ide> <ide> /** <ide> Alias an old, deprecated method with its new counterpart. <ide> function debug(message) { <ide> @return {Function} a new function that wrapped the original function with a deprecation warning <ide> @private <ide> */ <del>function deprecateFunc(...args) { <add>setDebugFunction('deprecateFunc', function deprecateFunc(...args) { <ide> if (args.length === 3) { <ide> let [message, options, func] = args; <ide> return function() { <del> Ember.deprecate(message, false, options); <add> deprecate(message, false, options); <ide> return func.apply(this, arguments); <ide> }; <ide> } else { <ide> let [message, func] = args; <ide> return function() { <del> Ember.deprecate(message); <add> deprecate(message); <ide> return func.apply(this, arguments); <ide> }; <ide> } <del>} <add>}); <ide> <ide> <ide> /** <ide> function deprecateFunc(...args) { <ide> @since 1.5.0 <ide> @public <ide> */ <del>function runInDebug(func) { <add>setDebugFunction('runInDebug', function runInDebug(func) { <ide> func(); <del>} <del> <del>setDebugFunction('assert', assert); <del>setDebugFunction('warn', warn); <del>setDebugFunction('debug', debug); <del>setDebugFunction('deprecate', deprecate); <del>setDebugFunction('deprecateFunc', deprecateFunc); <del>setDebugFunction('runInDebug', runInDebug); <add>}); <ide> <add>setDebugFunction('deprecate', _deprecate); <add>setDebugFunction('warn', _warn); <ide> /** <ide> Will call `Ember.warn()` if ENABLE_ALL_FEATURES, ENABLE_OPTIONAL_FEATURES, or <ide> any specific FEATURES flag is truthy. <ide> setDebugFunction('runInDebug', runInDebug); <ide> */ <ide> export function _warnIfUsingStrippedFeatureFlags(FEATURES, featuresWereStripped) { <ide> if (featuresWereStripped) { <del> Ember.warn('Ember.ENV.ENABLE_ALL_FEATURES is only available in canary builds.', !Ember.ENV.ENABLE_ALL_FEATURES, { id: 'ember-debug.feature-flag-with-features-stripped' }); <del> Ember.warn('Ember.ENV.ENABLE_OPTIONAL_FEATURES is only available in canary builds.', !Ember.ENV.ENABLE_OPTIONAL_FEATURES, { id: 'ember-debug.feature-flag-with-features-stripped' }); <add> warn('Ember.ENV.ENABLE_ALL_FEATURES is only available in canary builds.', !Ember.ENV.ENABLE_ALL_FEATURES, { id: 'ember-debug.feature-flag-with-features-stripped' }); <add> warn('Ember.ENV.ENABLE_OPTIONAL_FEATURES is only available in canary builds.', !Ember.ENV.ENABLE_OPTIONAL_FEATURES, { id: 'ember-debug.feature-flag-with-features-stripped' }); <ide> <ide> for (var key in FEATURES) { <ide> if (FEATURES.hasOwnProperty(key) && key !== 'isEnabled') { <del> Ember.warn('FEATURE["' + key + '"] is set as enabled, but FEATURE flags are only available in canary builds.', !FEATURES[key], { id: 'ember-debug.feature-flag-with-features-stripped' }); <add> warn('FEATURE["' + key + '"] is set as enabled, but FEATURE flags are only available in canary builds.', !FEATURES[key], { id: 'ember-debug.feature-flag-with-features-stripped' }); <ide> } <ide> } <ide> } <ide> if (!Ember.testing) { <ide> downloadURL = 'https://addons.mozilla.org/en-US/firefox/addon/ember-inspector/'; <ide> } <ide> <del> Ember.debug('For more advanced debugging, install the Ember Inspector from ' + downloadURL); <add> debug('For more advanced debugging, install the Ember Inspector from ' + downloadURL); <ide> } <ide> }, false); <ide> } <ide> if (isEnabled('ember-debug-handlers')) { <ide> */ <ide> export var runningNonEmberDebugJS = false; <ide> if (runningNonEmberDebugJS) { <del> Ember.warn('Please use `ember.debug.js` instead of `ember.js` for development and debugging.'); <add> warn('Please use `ember.debug.js` instead of `ember.js` for development and debugging.'); <ide> } <ide><path>packages/ember-debug/lib/warn.js <del>import Ember from 'ember-metal/core'; <ide> import Logger from 'ember-metal/logger'; <add>import { deprecate } from 'ember-metal/debug'; <ide> import { registerHandler as genericRegisterHandler, invoke } from 'ember-debug/handlers'; <ide> <ide> export function registerHandler(handler) { <ide> export let missingOptionsIdDeprecation = 'When calling `Ember.warn` you must pro <ide> */ <ide> export default function warn(message, test, options) { <ide> if (!options) { <del> Ember.deprecate( <add> deprecate( <ide> missingOptionsDeprecation, <ide> false, <ide> { id: 'ember-debug.warn-options-missing', until: '3.0.0' } <ide> ); <ide> } <ide> <ide> if (options && !options.id) { <del> Ember.deprecate( <add> deprecate( <ide> missingOptionsIdDeprecation, <ide> false, <ide> { id: 'ember-debug.warn-id-missing', until: '3.0.0' } <ide><path>packages/ember-debug/tests/warn_if_using_stripped_feature_flags_test.js <ide> import Ember from 'ember-metal/core'; <add>import { getDebugFunction, setDebugFunction } from 'ember-metal/debug'; <ide> import { _warnIfUsingStrippedFeatureFlags } from 'ember-debug'; <ide> <ide> var oldWarn, oldRunInDebug, origEnvFeatures, origEnableAll, origEnableOptional; <ide> function confirmWarns(expectedMsg) { <ide> var featuresWereStripped = true; <ide> var FEATURES = Ember.ENV.FEATURES; <ide> <del> Ember.warn = function(msg, test) { <add> setDebugFunction('warn', function(msg, test) { <ide> if (!test) { <ide> equal(msg, expectedMsg); <ide> } <del> }; <add> }); <ide> <del> Ember.runInDebug = function (func) { <add> setDebugFunction('runInDebug', function (func) { <ide> func(); <del> }; <add> }); <ide> <ide> // Should trigger our 1 warning <ide> _warnIfUsingStrippedFeatureFlags(FEATURES, featuresWereStripped); <ide> function confirmWarns(expectedMsg) { <ide> <ide> QUnit.module('ember-debug - _warnIfUsingStrippedFeatureFlags', { <ide> setup() { <del> oldWarn = Ember.warn; <del> oldRunInDebug = Ember.runInDebug; <add> oldWarn = getDebugFunction('warn'); <add> oldRunInDebug = getDebugFunction('runInDebug'); <ide> origEnvFeatures = Ember.ENV.FEATURES; <ide> origEnableAll = Ember.ENV.ENABLE_ALL_FEATURES; <ide> origEnableOptional = Ember.ENV.ENABLE_OPTIONAL_FEATURES; <ide> }, <ide> <ide> teardown() { <del> Ember.warn = oldWarn; <del> Ember.runInDebug = oldRunInDebug; <add> setDebugFunction('warn', oldWarn); <add> setDebugFunction('runInDebug', oldRunInDebug); <ide> Ember.ENV.FEATURES = origEnvFeatures; <ide> Ember.ENV.ENABLE_ALL_FEATURES = origEnableAll; <ide> Ember.ENV.ENABLE_OPTIONAL_FEATURES = origEnableOptional; <ide> QUnit.test('Enabling a FEATURES flag in non-canary, debug build causes a warning <ide> <ide> confirmWarns('FEATURE["fred"] is set as enabled, but FEATURE flags are only available in canary builds.'); <ide> }); <del>
4