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 | fix axis ids in documentation | bf724abe8b314c45bc706617a36f40521f3c0a83 | <ide><path>docs/02-Line-Chart.md
<ide> var data = {
<ide> // The actual data
<ide> data: [65, 59, 80, 81, 56, 55, 40],
<ide>
<del> // String - If specified, binds the dataset to a certain y-axis. If not specified, the first y-axis is used.
<del> yAxisID: "y-axis-1",
<add> // String - If specified, binds the dataset to a certain y-axis. If not specified, the first y-axis is used. First id is y-axis-0
<add> yAxisID: "y-axis-0",
<ide> },
<ide> {
<ide> label: "My Second dataset",
<ide><path>docs/03-Bar-Chart.md
<ide> var data = {
<ide> data: [65, 59, 80, 81, 56, 55, 40],
<ide>
<ide> // String - If specified, binds the dataset to a certain y-axis. If not specified, the first y-axis is used.
<del> yAxisID: "y-axis-1",
<add> yAxisID: "y-axis-0",
<ide> },
<ide> {
<ide> label: "My Second dataset", | 2 |
Javascript | Javascript | add comment to webglbindingstates | 11ae6232065d52fb0412172bf1f5014ae5023efc | <ide><path>src/renderers/webgl/WebGLBindingStates.js
<ide> function WebGLBindingStates( gl, extensions, attributes, capabilities ) {
<ide>
<ide> }
<ide>
<add> // If we sacrifice some BufferGeometry/Attribute API flexibility
<add> // needsUpdate() and saveCache() can be much simpler. See #16287
<add>
<ide> function needsUpdate( geometry ) {
<ide>
<ide> var cachedAttributes = currentState.attributes; | 1 |
Javascript | Javascript | fix disambiguous locator warning in e2e tests | 8b568d7c38f9c99b2270671c0ce81cc1b823371e | <ide><path>src/ng/filter/filters.js
<ide> <div ng-controller="ExampleController">
<ide> <input type="number" ng-model="amount"> <br>
<ide> default currency symbol ($): <span id="currency-default">{{amount | currency}}</span><br>
<del> custom currency identifier (USD$): <span>{{amount | currency:"USD$"}}</span>
<del> no fractions (0): <span>{{amount | currency:"USD$":0}}</span>
<add> custom currency identifier (USD$): <span id="currency-custom">{{amount | currency:"USD$"}}</span>
<add> no fractions (0): <span id="currency-no-fractions">{{amount | currency:"USD$":0}}</span>
<ide> </div>
<ide> </file>
<ide> <file name="protractor.js" type="protractor">
<ide> it('should init with 1234.56', function() {
<ide> expect(element(by.id('currency-default')).getText()).toBe('$1,234.56');
<del> expect(element(by.binding('amount | currency:"USD$"')).getText()).toBe('USD$1,234.56');
<del> expect(element(by.binding('amount | currency:"USD$":0')).getText()).toBe('USD$1,235');
<add> expect(element(by.id('currency-custom')).getText()).toBe('USD$1,234.56');
<add> expect(element(by.id('currency-no-fractions')).getText()).toBe('USD$1,235');
<ide> });
<ide> it('should update', function() {
<ide> if (browser.params.browser == 'safari') {
<ide> element(by.model('amount')).clear();
<ide> element(by.model('amount')).sendKeys('-1234');
<ide> expect(element(by.id('currency-default')).getText()).toBe('($1,234.00)');
<del> expect(element(by.binding('amount | currency:"USD$"')).getText()).toBe('(USD$1,234.00)');
<del> expect(element(by.binding('amount | currency:"USD$":0')).getText()).toBe('(USD$1,234)');
<add> expect(element(by.id('currency-custom')).getText()).toBe('(USD$1,234.00)');
<add> expect(element(by.id('currency-no-fractions')).getText()).toBe('(USD$1,234)');
<ide> });
<ide> </file>
<ide> </example> | 1 |
Javascript | Javascript | check fd 0,1,2 are used, not access mode | 106d09ab7a2d63816346cb46277b218f05bcce92 | <ide><path>test/parallel/test-stdio-closed.js
<ide> const common = require('../common');
<ide> const assert = require('assert');
<ide> const spawn = require('child_process').spawn;
<add>const fs = require('fs');
<ide>
<ide> if (common.isWindows) {
<ide> common.skip('platform not supported.');
<ide> return;
<ide> }
<ide>
<ide> if (process.argv[2] === 'child') {
<del> try {
<del> process.stdout.write('stdout', function() {
<del> try {
<del> process.stderr.write('stderr', function() {
<del> process.exit(42);
<del> });
<del> } catch (e) {
<del> process.exit(84);
<del> }
<del> });
<del> } catch (e) {
<del> assert.strictEqual(e.code, 'EBADF');
<del> assert.strictEqual(e.message, 'EBADF: bad file descriptor, write');
<del> process.exit(126);
<del> }
<add> [0, 1, 2].forEach((i) => assert.doesNotThrow(() => fs.fstatSync(i)));
<ide> return;
<ide> }
<ide>
<ide> const cmd = `"${process.execPath}" "${__filename}" child 1>&- 2>&-`;
<ide> const proc = spawn('/bin/sh', ['-c', cmd], { stdio: 'inherit' });
<ide>
<ide> proc.on('exit', common.mustCall(function(exitCode) {
<del> assert.strictEqual(exitCode, common.isAix ? 126 : 42);
<add> assert.strictEqual(exitCode, 0);
<ide> })); | 1 |
Python | Python | remove extraneous grc test file | d48c01a6f77a90db06e936ae903d1d0ea151ae31 | <ide><path>spacy/lang/grc/test_text.py
<del>import pytest
<del>
<del>
<del>@pytest.mark.parametrize(
<del> "text,match",
<del> [
<del> ("ι", True),
<del> ("α", True),
<del> ("ϟα", True),
<del> ("ἑκατόν", True),
<del> ("ἐνακόσια", True),
<del> ("δισχίλια", True),
<del> ("μύρια", True),
<del> ("εἷς", True),
<del> ("λόγος", False),
<del> (",", False),
<del> ("λβ", True),
<del> ],
<del>)
<del>def test_lex_attrs_like_number(grc_tokenizer, text, match):
<del> tokens = grc_tokenizer(text)
<del> assert len(tokens) == 1
<del> assert tokens[0].like_num == match | 1 |
Text | Text | add line break | 9b51c70d45e898af0fe17cd56c39cdf89feb8b49 | <ide><path>guide/english/javascript/es6/destructuring/index.md
<ide> const {first: firstName, last: lastName} = fullName;
<ide> console.log(firstName, lastName); // John Smith
<ide> ```
<ide> **Array Destructuring with rest**
<add>
<ide> When destructuring an array, you can unpack and assign the remaining part of it to a variable using the rest pattern:
<ide> ```js
<ide> const [a, ...b] = [1, 2, 3]; | 1 |
Ruby | Ruby | avoid monkey patching redis | 5aa9d16969cd03c5d3b87d471823979d751ae233 | <ide><path>activesupport/lib/active_support/cache/redis_cache_store.rb
<ide>
<ide> module ActiveSupport
<ide> module Cache
<del> module ConnectionPoolLike
<del> def with
<del> yield self
<del> end
<del> end
<del>
<del> ::Redis.include(ConnectionPoolLike)
<del> ::Redis::Distributed.include(ConnectionPoolLike)
<del>
<ide> # Redis cache store.
<ide> #
<ide> # Deployment note: Take care to use a *dedicated Redis cache* rather
<ide> def delete_matched(matcher, options = nil)
<ide> unless String === matcher
<ide> raise ArgumentError, "Only Redis glob strings are supported: #{matcher.inspect}"
<ide> end
<del> redis.with do |c|
<add> redis.then do |c|
<ide> pattern = namespace_key(matcher, options)
<ide> cursor = "0"
<ide> # Fetch keys in batches using SCAN to avoid blocking the Redis server.
<ide> def increment(name, amount = 1, options = nil)
<ide> options = merged_options(options)
<ide> key = normalize_key(name, options)
<ide>
<del> redis.with do |c|
<add> redis.then do |c|
<ide> c.incrby(key, amount).tap do
<ide> write_key_expiry(c, key, options)
<ide> end
<ide> def decrement(name, amount = 1, options = nil)
<ide> options = merged_options(options)
<ide> key = normalize_key(name, options)
<ide>
<del> redis.with do |c|
<add> redis.then do |c|
<ide> c.decrby(key, amount).tap do
<ide> write_key_expiry(c, key, options)
<ide> end
<ide> def clear(options = nil)
<ide> if namespace = merged_options(options)[:namespace]
<ide> delete_matched "*", namespace: namespace
<ide> else
<del> redis.with { |c| c.flushdb }
<add> redis.then { |c| c.flushdb }
<ide> end
<ide> end
<ide> end
<ide>
<ide> # Get info from redis servers.
<ide> def stats
<del> redis.with { |c| c.info }
<add> redis.then { |c| c.info }
<ide> end
<ide>
<ide> def mset_capable? # :nodoc:
<ide> def read_entry(key, **options)
<ide>
<ide> def read_serialized_entry(key, raw: false, **options)
<ide> failsafe :read_entry do
<del> redis.with { |c| c.get(key) }
<add> redis.then { |c| c.get(key) }
<ide> end
<ide> end
<ide>
<ide> def read_multi_entries(names, **options)
<ide> keys = names.map { |name| normalize_key(name, options) }
<ide>
<ide> values = failsafe(:read_multi_entries, returning: {}) do
<del> redis.with { |c| c.mget(*keys) }
<add> redis.then { |c| c.mget(*keys) }
<ide> end
<ide>
<ide> names.zip(values).each_with_object({}) do |(name, value), results|
<ide> def write_serialized_entry(key, payload, raw: false, unless_exist: false, expire
<ide> end
<ide>
<ide> failsafe :write_entry, returning: false do
<del> redis.with { |c| c.set key, payload, **modifiers }
<add> redis.then { |c| c.set key, payload, **modifiers }
<ide> end
<ide> end
<ide>
<ide> def write_key_expiry(client, key, options)
<ide> # Delete an entry from the cache.
<ide> def delete_entry(key, options)
<ide> failsafe :delete_entry, returning: false do
<del> redis.with { |c| c.del key }
<add> redis.then { |c| c.del key }
<ide> end
<ide> end
<ide>
<ide> # Deletes multiple entries in the cache. Returns the number of entries deleted.
<ide> def delete_multi_entries(entries, **_options)
<del> redis.with { |c| c.del(entries) }
<add> redis.then { |c| c.del(entries) }
<ide> end
<ide>
<ide> # Nonstandard store provider API to write multiple values at once.
<ide> def write_multi_entries(entries, expires_in: nil, race_condition_ttl: nil, **opt
<ide> if mset_capable? && expires_in.nil? && race_condition_ttl.nil?
<ide> failsafe :write_multi_entries do
<ide> payload = serialize_entries(entries, **options)
<del> redis.with do |c|
<add> redis.then do |c|
<ide> c.mapped_mset(payload)
<ide> end
<ide> end | 1 |
Text | Text | revise agent.destroy() text | cde87ed761b47da2919a047d1be60a53cdc4541f | <ide><path>doc/api/http.md
<ide> Destroy any sockets that are currently in use by the agent.
<ide>
<ide> It is usually not necessary to do this. However, if using an
<ide> agent with `keepAlive` enabled, then it is best to explicitly shut down
<del>the agent when it will no longer be used. Otherwise,
<del>sockets may hang open for quite a long time before the server
<add>the agent when it is no longer needed. Otherwise,
<add>sockets might stay open for quite a long time before the server
<ide> terminates them.
<ide>
<ide> ### `agent.freeSockets` | 1 |
Go | Go | add support for netbsd | 6efa9e05756f709043790474e877e2df693e1922 | <ide><path>pkg/system/stat_netbsd.go
<add>package system // import "github.com/docker/docker/pkg/system"
<add>
<add>import "syscall"
<add>
<add>// fromStatT converts a syscall.Stat_t type to a system.Stat_t type
<add>func fromStatT(s *syscall.Stat_t) (*StatT, error) {
<add> return &StatT{size: s.Size,
<add> mode: uint32(s.Mode),
<add> uid: s.Uid,
<add> gid: s.Gid,
<add> rdev: uint64(s.Rdev),
<add> mtim: s.Mtimespec}, nil
<add>} | 1 |
PHP | PHP | add tap helper and test | e54e797432a60f165bea2b8c84c62a65fd7f2ca3 | <ide><path>src/Illuminate/Support/helpers.php
<ide> function studly_case($value)
<ide> }
<ide> }
<ide>
<add>if (! function_exists('tap')) {
<add> /**
<add> * Call the given Closure with a given value then return the value.
<add> *
<add> * @param mixed $value
<add> * @return mixed
<add> */
<add> function tap($value, $callback)
<add> {
<add> $callback($value);
<add>
<add> return $value;
<add> }
<add>}
<add>
<ide> if (! function_exists('title_case')) {
<ide> /**
<ide> * Convert a value to title case.
<ide><path>tests/Support/SupportHelpersTest.php
<ide> public function testArrayPull()
<ide> $this->assertEquals('Mövsümov', array_pull($developer, 'surname'));
<ide> $this->assertEquals(['firstname' => 'Ferid'], $developer);
<ide> }
<add>
<add> public function testTap()
<add> {
<add> $object = (object) ['id' => 1];
<add> $this->assertEquals(2, tap($object, function ($object) { $object->id = 2; })->id);
<add> }
<ide> }
<ide>
<ide> trait SupportTestTraitOne | 2 |
PHP | PHP | anticipate() | 0cbd8d97eff2c02046f49ce2641dcde77b13be56 | <ide><path>src/Illuminate/Console/Command.php
<ide> public function ask($question, $default = null)
<ide> * Prompt the user for input with auto completion.
<ide> *
<ide> * @param string $question
<del> * @param array $choices
<add> * @param array|callable $choices
<ide> * @param string|null $default
<ide> * @return mixed
<ide> */
<del> public function anticipate($question, array $choices, $default = null)
<add> public function anticipate($question, $choices, $default = null)
<ide> {
<ide> return $this->askWithCompletion($question, $choices, $default);
<ide> }
<ide> public function anticipate($question, array $choices, $default = null)
<ide> * Prompt the user for input with auto completion.
<ide> *
<ide> * @param string $question
<del> * @param array $choices
<add> * @param array|callable $choices
<ide> * @param string|null $default
<ide> * @return mixed
<ide> */
<del> public function askWithCompletion($question, array $choices, $default = null)
<add> public function askWithCompletion($question, $choices, $default = null)
<ide> {
<ide> $question = new Question($question, $default);
<ide>
<del> $question->setAutocompleterValues($choices);
<add> is_callable($choices) ? $question->setAutocompleterCallback($choices) : $question->setAutocompleterValues($choices);
<ide>
<ide> return $this->output->askQuestion($question);
<ide> } | 1 |
Text | Text | update proptypes doc | 4e0c57315afc2769fe13bbbb4235b0aa47343ca7 | <ide><path>docs/contributing/codebase-overview.md
<ide> While the code is separated in the source tree, the exact package boundaries are
<ide> The "core" of React includes all the [top-level `React` APIs](/react/docs/top-level-api.html#react), for example:
<ide>
<ide> * `React.createElement()`
<del>* `React.createClass()`
<ide> * `React.Component`
<ide> * `React.Children`
<del>* `React.PropTypes`
<ide>
<ide> **React core only includes the APIs necessary to define components.** It does not include the [reconciliation](/react/docs/reconciliation.html) algorithm or any platform-specific code. It is used both by React DOM and React Native components.
<ide> | 1 |
Javascript | Javascript | fix float input, auto joint or split node | 2f61147d63ac92d4dd43b87fc2ad44252e1d044d | <ide><path>examples/js/nodes/utils/SwitchNode.js
<ide>
<ide> THREE.SwitchNode = function( node, components ) {
<ide>
<del> THREE.GLNode.call( this, 'fv1' );
<add> THREE.GLNode.call( this );
<ide>
<ide> this.node = node;
<ide> this.components = components || 'x';
<ide> THREE.SwitchNode.prototype.generate = function( builder, output ) {
<ide>
<ide> if ( outputLength > inputLength ) outputLength = inputLength;
<ide>
<del> // build switch
<add> if ( inputLength > 0 ) {
<ide>
<del> node += '.';
<add> // split
<ide>
<del> for ( i = 0; i < len; i ++ ) {
<add> node += '.';
<ide>
<del> var elm = components.charAt( i );
<del> var idx = builder.getIndexByElement( components.charAt( i ) );
<add> for ( i = 0; i < len; i ++ ) {
<ide>
<del> if ( idx > outputLength ) idx = outputLength;
<add> var elm = components.charAt( i );
<add> var idx = builder.getIndexByElement( components.charAt( i ) );
<ide>
<del> if ( builder.getElementByIndex( idx ) == undefined ) {
<add> if ( idx > outputLength ) idx = outputLength;
<ide>
<del> console.log( builder.getElementByIndex( idx ) );
<add> node += builder.getElementByIndex( idx );
<ide>
<ide> }
<ide>
<del> node += builder.getElementByIndex( idx );
<add> } else {
<add>
<add> // join
<add>
<add> node = builder.format( node, type, this.getType( builder ) )
<ide>
<ide> }
<ide> | 1 |
Python | Python | allow output size different from state size | 4b2093ef67ab9a267dc371e3a193749ad764f78e | <ide><path>keras/backend/tensorflow_backend.py
<ide> def _step(input, state):
<ide> new_state = tf.concat(1, new_states)
<ide> return output, new_state
<ide>
<del> # state size is assumed to be the same as output size
<del> # (always the case)
<ide> _step.state_size = state_size * nb_states
<del> _step.output_size = state_size
<add> _step.output_size = int(_step(tf.unpack(inputs)[0], state)[0].get_shape()[-1])
<ide>
<ide> (outputs, final_state) = _dynamic_rnn_loop(
<ide> _step, | 1 |
Ruby | Ruby | remove broken `puts` from verbose `brew link` | ed83fa609b4c6c1ebe29d157ce564e1f85fa627a | <ide><path>Library/Homebrew/cmd/link.rb
<ide> def link
<ide> end
<ide>
<ide> print "Linking #{keg}... " do
<del> puts if ARGV.verbose?
<ide> puts "#{keg.link} symlinks created"
<ide> end
<ide> end | 1 |
Ruby | Ruby | add dev_tools_path to path if not in path already | a69ec7a22bd521d5a48b955bab9c319e761a7851 | <ide><path>Library/Homebrew/build.rb
<ide> ENV.setup_build_environment
<ide> # we must do this or tools like pkg-config won't get found by configure scripts etc.
<ide> ENV.prepend 'PATH', "#{HOMEBREW_PREFIX}/bin", ':' unless ORIGINAL_PATHS.include? "#{HOMEBREW_PREFIX}/bin"
<add> # this is a safety measure for Xcode 4.3 which started not installing
<add> # dev tools into /usr/bin as a default
<add> ENV.prepend 'PATH', MacOS.dev_tools_path, ':' unless ORIGINAL_PATHS.include? MacOS.dev_tools_path
<ide>
<ide> install(Formula.factory($0))
<ide> rescue Exception => e | 1 |
PHP | PHP | allow relative urls in to_asset | 653770a3eb2bbe91fcc445c4a436665a3b218aaf | <ide><path>laravel/url.php
<ide> protected static function convention($action, $parameters)
<ide> */
<ide> public static function to_asset($url, $https = null)
<ide> {
<del> if (static::valid($url)) return $url;
<add> if (static::valid($url) or starts_with($url, '//')) return $url;
<ide>
<ide> // If a base asset URL is defined in the configuration, use that and don't
<ide> // try and change the HTTP protocol. This allows the delivery of assets | 1 |
Go | Go | add deviceset singleton | ca2f7f955e697091f2b7bee9a33c6c4e106cecd0 | <ide><path>runtime.go
<ide> type Runtime struct {
<ide> volumes *Graph
<ide> srv *Server
<ide> Dns []string
<add> deviceSet DeviceSet
<ide> }
<ide>
<ide> var sysInitPath string
<ide> func (runtime *Runtime) getContainerElement(id string) *list.Element {
<ide> return nil
<ide> }
<ide>
<add>func (runtime *Runtime) GetDeviceSet() (DeviceSet, error) {
<add> if runtime.deviceSet == nil {
<add> return nil, fmt.Errorf("No device set available")
<add> }
<add> return runtime.deviceSet, nil
<add>}
<add>
<ide> // Get looks for a container by the specified ID or name, and returns it.
<ide> // If the container is not found, or if an error occurs, nil is returned.
<ide> func (runtime *Runtime) Get(name string) *Container {
<ide> func (runtime *Runtime) Commit(container *Container, repository, tag, comment, a
<ide> }
<ide>
<ide> // FIXME: harmonize with NewGraph()
<del>func NewRuntime(flGraphPath string, autoRestart bool, dns []string) (*Runtime, error) {
<del> runtime, err := NewRuntimeFromDirectory(flGraphPath, autoRestart)
<add>func NewRuntime(flGraphPath string, deviceSet DeviceSet, autoRestart bool, dns []string) (*Runtime, error) {
<add> runtime, err := NewRuntimeFromDirectory(flGraphPath, deviceSet, autoRestart)
<ide> if err != nil {
<ide> return nil, err
<ide> }
<ide> func NewRuntime(flGraphPath string, autoRestart bool, dns []string) (*Runtime, e
<ide> return runtime, nil
<ide> }
<ide>
<del>func NewRuntimeFromDirectory(root string, autoRestart bool) (*Runtime, error) {
<add>func NewRuntimeFromDirectory(root string, deviceSet DeviceSet, autoRestart bool) (*Runtime, error) {
<ide> runtimeRepo := path.Join(root, "containers")
<ide>
<ide> if err := os.MkdirAll(runtimeRepo, 0700); err != nil && !os.IsExist(err) {
<ide> func NewRuntimeFromDirectory(root string, autoRestart bool) (*Runtime, error) {
<ide> capabilities: &Capabilities{},
<ide> autoRestart: autoRestart,
<ide> volumes: volumes,
<add> deviceSet: deviceSet,
<ide> }
<ide>
<ide> if err := runtime.restore(); err != nil {
<ide><path>runtime_test.go
<ide> import (
<ide> "bytes"
<ide> "fmt"
<ide> "github.com/dotcloud/docker/utils"
<add> "github.com/dotcloud/docker/devmapper"
<ide> "io"
<ide> "log"
<ide> "net"
<ide> func init() {
<ide> NetworkBridgeIface = unitTestNetworkBridge
<ide>
<ide> // Make it our Store root
<del> if runtime, err := NewRuntimeFromDirectory(unitTestStoreBase, false); err != nil {
<add> if runtime, err := NewRuntimeFromDirectory(unitTestStoreBase, devmapper.NewDeviceSetDM(unitTestStoreBase), false); err != nil {
<ide> panic(err)
<ide> } else {
<ide> globalRuntime = runtime
<ide> func TestRestore(t *testing.T) {
<ide>
<ide> // Here are are simulating a docker restart - that is, reloading all containers
<ide> // from scratch
<del> runtime2, err := NewRuntimeFromDirectory(runtime1.root, false)
<add> runtime2, err := NewRuntimeFromDirectory(runtime1.root, devmapper.NewDeviceSetDM(runtime1.root), false)
<ide> if err != nil {
<ide> t.Fatal(err)
<ide> }
<ide><path>server.go
<ide> func NewServer(flGraphPath string, deviceSet DeviceSet, autoRestart, enableCors
<ide> if runtime.GOARCH != "amd64" {
<ide> log.Fatalf("The docker runtime currently only supports amd64 (not %s). This will change in the future. Aborting.", runtime.GOARCH)
<ide> }
<del> runtime, err := NewRuntime(flGraphPath, autoRestart, dns)
<add> runtime, err := NewRuntime(flGraphPath, deviceSet, autoRestart, dns)
<ide> if err != nil {
<ide> return nil, err
<ide> }
<ide><path>utils_test.go
<ide> package docker
<ide>
<ide> import (
<ide> "github.com/dotcloud/docker/utils"
<add> "github.com/dotcloud/docker/devmapper"
<ide> "io"
<ide> "io/ioutil"
<ide> "os"
<ide> func newTestRuntime() (*Runtime, error) {
<ide> return nil, err
<ide> }
<ide>
<del> runtime, err := NewRuntimeFromDirectory(root, false)
<add> runtime, err := NewRuntimeFromDirectory(root, devmapper.NewDeviceSetDM(root), false)
<ide> if err != nil {
<ide> return nil, err
<ide> } | 4 |
Javascript | Javascript | use numeric identifiers when building a bundle | cb4fca3590cf887e8d246bdbc1ceef196617f510 | <ide><path>Libraries/Utilities/Systrace.js
<ide> var Systrace = {
<ide>
<ide> Systrace.setEnabled(global.__RCTProfileIsProfiling || false);
<ide>
<add>if (__DEV__) {
<add> // This is needed, because require callis in polyfills are not processed as
<add> // other files. Therefore, calls to `require('moduleId')` are not replaced
<add> // with numeric IDs
<add> // TODO(davidaurelio) Scan polyfills for dependencies, too (t9759686)
<add> require.Systrace = Systrace;
<add>}
<ide> module.exports = Systrace;
<ide><path>packager/react-packager/src/Bundler/Bundle.js
<ide> class Bundle extends BundleBase {
<ide> response,
<ide> module,
<ide> transformed.code
<del> ).then(({code, name}) => {
<add> ).then(({code, id}) => {
<ide> const moduleTransport = new ModuleTransport({
<ide> code,
<del> name,
<add> name: id,
<ide> map: transformed.map,
<ide> sourceCode: transformed.sourceCode,
<ide> sourcePath: transformed.sourcePath,
<ide> class Bundle extends BundleBase {
<ide> }
<ide>
<ide> _addRequireCall(moduleId) {
<del> const code = ';require("' + moduleId + '");';
<add> const code = `;require(${JSON.stringify(moduleId)});`;
<ide> const name = 'require-' + moduleId;
<ide> super.addModule(new ModuleTransport({
<ide> name,
<ide><path>packager/react-packager/src/Bundler/__tests__/Bundler-test.js
<ide>
<ide> jest
<ide> .setMock('worker-farm', () => () => undefined)
<add> .dontMock('absolute-path')
<ide> .dontMock('underscore')
<ide> .dontMock('../../lib/ModuleTransport')
<add> .dontMock('../../DependencyResolver/AssetModule')
<add> .dontMock('../../DependencyResolver/Module')
<add> .dontMock('../../DependencyResolver/lib/getAssetDataFromName')
<ide> .setMock('uglify-js')
<ide> .dontMock('../');
<ide>
<ide> jest.mock('fs');
<ide>
<add>var AssetModule = require('../../DependencyResolver/AssetModule');
<ide> var Bundler = require('../');
<ide> var JSTransformer = require('../../JSTransformer');
<add>var Module = require('../../DependencyResolver/Module');
<ide> var Resolver = require('../../Resolver');
<add>
<ide> var sizeOf = require('image-size');
<ide> var fs = require('fs');
<ide>
<ide> describe('Bundler', function() {
<ide> isJSON,
<ide> resolution,
<ide> }) {
<add> if (isAsset) {
<add> const module = new AssetModule({
<add> file: path,
<add> cache: {get: () => Promise.resolve(path)}
<add> });
<add> module.getName = () => Promise.resolve(id);
<add> return module;
<add> }
<ide> return {
<ide> path,
<ide> resolution,
<ide> describe('Bundler', function() {
<ide> var bundler;
<ide> var assetServer;
<ide> var modules;
<add> const width = 50;
<add> const height = 100;
<ide>
<ide> beforeEach(function() {
<ide> getDependencies = jest.genMockFn();
<ide> describe('Bundler', function() {
<ide> }),
<ide> ];
<ide>
<add> const mainModule = new Module({file: '/root/foo'});
<ide> getDependencies.mockImpl(function() {
<ide> return Promise.resolve({
<ide> mainModuleId: 'foo',
<del> dependencies: modules
<add> dependencies: modules,
<add> getMainModule: () => mainModule,
<ide> });
<ide> });
<ide>
<ide> describe('Bundler', function() {
<ide> wrapModule.mockImpl(function(response, module, code) {
<ide> return module.getName().then(name => ({
<ide> name,
<add> id: name,
<ide> code: 'lol ' + code + ' lol'
<ide> }));
<ide> });
<ide>
<ide> sizeOf.mockImpl(function(path, cb) {
<del> cb(null, { width: 50, height: 100 });
<add> cb(null, { width, height });
<ide> });
<ide> });
<ide>
<ide> describe('Bundler', function() {
<ide> __packager_asset: true,
<ide> fileSystemLocation: '/root/img',
<ide> httpServerLocation: '/assets/img',
<del> width: 25,
<del> height: 50,
<add> width,
<add> height,
<ide> scales: [1, 2, 3],
<ide> files: [
<ide> '/root/img/img.png',
<ide><path>packager/react-packager/src/Bundler/index.js
<ide> class Bundler {
<ide> mtime = '';
<ide> }
<ide>
<add> this._getModuleId = createModuleIdGetter();
<add>
<ide> this._cache = new Cache({
<ide> resetCache: opts.resetCache,
<ide> cacheKey: [
<ide> class Bundler {
<ide> fileWatcher: opts.fileWatcher,
<ide> assetExts: opts.assetExts,
<ide> cache: this._cache,
<add> getModuleId: this._getModuleId,
<ide> });
<ide>
<ide> this._bundlesLayout = new BundlesLayout({
<ide> class Bundler {
<ide> const findEventId = Activity.startEvent('find dependencies');
<ide> let transformEventId;
<ide>
<add> if (isDev) {
<add> // `require` calls int the require polyfill itself are not analyzed and
<add> // replaced so that they use numeric module IDs. Therefore, we include
<add> // the Systrace module before any other module, and it will set itself
<add> // as property on the require function.
<add> // TODO(davidaurelio) Scan polyfills for dependencies, too (t9759686)
<add> runBeforeMainModule = ['Systrace'].concat(runBeforeMainModule);
<add> }
<add>
<add> const modulesByName = Object.create(null);
<ide> return this.getDependencies(entryFile, isDev, platform).then((response) => {
<ide> Activity.endEvent(findEventId);
<del> bundle.setMainModuleId(response.mainModuleId);
<add> bundle.setMainModuleId(this._getModuleId(response.getMainModule()));
<ide> transformEventId = Activity.startEvent('transform');
<ide>
<ide> const moduleSystemDeps = includeSystemDependencies
<ide> class Bundler {
<ide> platform,
<ide> hot,
<ide> ).then(transformed => {
<add> return module.getName().then(name => {
<add> modulesByName[name] = module;
<add> return transformed;
<add> });
<add> }).then(transformed => {
<ide> if (bar) {
<ide> bar.tick();
<ide> }
<ide> class Bundler {
<ide> ));
<ide> }).then(() => {
<ide> Activity.endEvent(transformEventId);
<del> bundle.finalize({runBeforeMainModule, runMainModule});
<add> const runBeforeIds = runBeforeMainModule
<add> .map(name => modulesByName[name])
<add> .filter(Boolean)
<add> .map(this._getModuleId, this);
<add> bundle.finalize({runBeforeMainModule: runBeforeIds, runMainModule});
<ide> return bundle;
<ide> });
<ide> }
<ide> class Bundler {
<ide> type: assetData.type,
<ide> };
<ide>
<del> const ASSET_TEMPLATE = 'module.exports = require("AssetRegistry").registerAsset(%json);';
<del> const code = ASSET_TEMPLATE.replace('%json', JSON.stringify(asset));
<add> const code = module.getCode(asset);
<ide>
<ide> return {asset, code};
<ide> });
<ide> function verifyRootExists(root) {
<ide> assert(fs.statSync(root).isDirectory(), 'Root has to be a valid directory');
<ide> }
<ide>
<del>class DummyCache {
<del> get(filepath, field, loaderCb) {
<del> return loaderCb();
<del> }
<ide>
<del> end(){}
<del> invalidate(filepath){}
<add>function createModuleIdGetter() {
<add> const fileToIdMap = Object.create(null);
<add> let nextId = 0;
<add> return (
<add> ({path}) => {
<add> if (!(path in fileToIdMap)) {
<add> // can't be a number for now, since we also replace in import / export
<add> // we can change that when we eventually change to analyzing dependencies
<add> // on transformed modules
<add> fileToIdMap[path] = String(nextId++);
<add> }
<add> return fileToIdMap[path];
<add> }
<add> );
<ide> }
<add>
<ide> module.exports = Bundler;
<ide><path>packager/react-packager/src/BundlesLayout/__tests__/BundlesLayoutIntegration-test.js
<ide> describe('BundlesLayout', () => {
<ide> cache: new Cache(),
<ide> assetExts: ['js', 'png'],
<ide> assetRoots: ['/root'],
<add> getModuleId: () => {},
<ide> });
<ide>
<ide> return new BundlesLayout({
<ide><path>packager/react-packager/src/DependencyResolver/AssetModule.js
<ide> class AssetModule extends Module {
<ide> }
<ide>
<ide> getDependencies() {
<del> return Promise.resolve([]);
<add> return Promise.resolve(['AssetRegistry']);
<ide> }
<ide>
<ide> getAsyncDependencies() {
<ide> return Promise.resolve([]);
<ide> }
<ide>
<add> getCode(assetData) {
<add> return `module.exports = require('AssetRegistry').registerAsset(${
<add> JSON.stringify(assetData)
<add> });`;
<add> }
<add>
<ide> read() {
<ide> return Promise.resolve({});
<ide> }
<ide><path>packager/react-packager/src/DependencyResolver/DependencyGraph/ResolutionResponse.js
<ide> class ResolutionResponse {
<ide> });
<ide> }
<ide>
<add> getMainModule() {
<add> this._assertFinalized();
<add> return this._mainModule;
<add> }
<add>
<ide> pushDependency(module) {
<ide> this._assertNotFinalized();
<ide> if (this.dependencies.length === 0) {
<ide><path>packager/react-packager/src/DependencyResolver/DependencyGraph/__tests__/DependencyGraph-test.js
<ide> describe('DependencyGraph', function() {
<ide> {
<ide> id: 'rootPackage/imgs/a.png',
<ide> path: '/root/imgs/a.png',
<del> dependencies: [],
<add> dependencies: ['AssetRegistry'],
<ide> isAsset: true,
<ide> resolution: 1,
<ide> isAsset_DEPRECATED: false,
<ide> describe('DependencyGraph', function() {
<ide> id: 'rootPackage/imgs/a.png',
<ide> path: '/root/imgs/a@1.5x.png',
<ide> resolution: 1.5,
<del> dependencies: [],
<add> dependencies: ['AssetRegistry'],
<ide> isAsset: true,
<ide> isAsset_DEPRECATED: false,
<ide> isJSON: false,
<ide> describe('DependencyGraph', function() {
<ide> id: 'rootPackage/imgs/b.png',
<ide> path: '/root/imgs/b@.7x.png',
<ide> resolution: 0.7,
<del> dependencies: [],
<add> dependencies: ['AssetRegistry'],
<ide> isAsset: true,
<ide> isAsset_DEPRECATED: false,
<ide> isJSON: false,
<ide> describe('DependencyGraph', function() {
<ide> id: 'rootPackage/imgs/c.png',
<ide> path: '/root/imgs/c.png',
<ide> resolution: 1,
<del> dependencies: [],
<add> dependencies: ['AssetRegistry'],
<ide> isAsset: true,
<ide> isAsset_DEPRECATED: false,
<ide> isJSON: false,
<ide> describe('DependencyGraph', function() {
<ide> id: 'rootPackage/imgs/a.png',
<ide> path: '/root/imgs/a@1.5x.ios.png',
<ide> resolution: 1.5,
<del> dependencies: [],
<add> dependencies: ['AssetRegistry'],
<ide> isAsset: true,
<ide> isAsset_DEPRECATED: false,
<ide> isJSON: false,
<ide> describe('DependencyGraph', function() {
<ide> id: 'rootPackage/imgs/b.png',
<ide> path: '/root/imgs/b@.7x.ios.png',
<ide> resolution: 0.7,
<del> dependencies: [],
<add> dependencies: ['AssetRegistry'],
<ide> isAsset: true,
<ide> isAsset_DEPRECATED: false,
<ide> isJSON: false,
<ide> describe('DependencyGraph', function() {
<ide> id: 'rootPackage/imgs/c.png',
<ide> path: '/root/imgs/c.ios.png',
<ide> resolution: 1,
<del> dependencies: [],
<add> dependencies: ['AssetRegistry'],
<ide> isAsset: true,
<ide> isAsset_DEPRECATED: false,
<ide> isJSON: false,
<ide> describe('DependencyGraph', function() {
<ide> {
<ide> id: 'rootPackage/imgs/a.png',
<ide> path: '/root/imgs/a.png',
<del> dependencies: [],
<add> dependencies: ['AssetRegistry'],
<ide> isAsset: true,
<ide> resolution: 1,
<ide> isAsset_DEPRECATED: false,
<ide> describe('DependencyGraph', function() {
<ide> {
<ide> id: 'aPackage/foo.png',
<ide> path: '/root/foo.png',
<del> dependencies: [],
<add> dependencies: ['AssetRegistry'],
<ide> isAsset: true,
<ide> resolution: 1,
<ide> isAsset_DEPRECATED: false,
<ide><path>packager/react-packager/src/DependencyResolver/lib/replacePatterns.js
<ide>
<ide> 'use strict';
<ide>
<del>exports.IMPORT_RE = /(\bimport\s+(?:[^'"]+\s+from\s+)??)(['"])([^'"]+)(\2)/g;
<del>exports.EXPORT_RE = /(\bexport\s+(?:[^'"]+\s+from\s+)??)(['"])([^'"]+)(\2)/g;
<del>exports.REQUIRE_RE = /(\brequire\s*?\(\s*?)(['"])([^'"]+)(\2\s*?\))/g;
<del>exports.SYSTEM_IMPORT_RE = /(\bSystem\.import\s*?\(\s*?)(['"])([^'"]+)(\2\s*?\))/g;
<add>exports.IMPORT_RE = /(\bimport\s*(?:[\s{][^'"]+[\s}]from\s*)??)(['"])([^'"]+)\2()/g;
<add>exports.EXPORT_RE = /(\bexport\s*(?:[\s{][^'"]+[\s}]from\s*)??)(['"])([^'"]+)\2()/g;
<add>exports.REQUIRE_RE = /(\brequire\s*?\(\s*?)(['"])([^'"]+)\2(\s*?\))/g;
<add>exports.SYSTEM_IMPORT_RE = /(\bSystem\.import\s*?\(\s*?)(['"])([^'"]+)\2(\s*?\))/g;
<ide><path>packager/react-packager/src/Resolver/__tests__/Resolver-test.js
<ide> describe('Resolver', function() {
<ide> });
<ide> });
<ide>
<add> const modulesWithIds = [];
<add> function getModuleId(module) {
<add> const index = modulesWithIds.indexOf(module);
<add> return String(index !== -1 ? index + 1 : modulesWithIds.push(module));
<add> }
<add>
<ide> class ResolutionResponseMock {
<ide> constructor({dependencies, mainModuleId, asyncDependencies}) {
<ide> this.dependencies = dependencies;
<ide> describe('Resolver', function() {
<ide>
<ide> var depResolver = new Resolver({
<ide> projectRoot: '/root',
<add> getModuleId,
<ide> });
<ide>
<ide> DependencyGraph.prototype.getDependencies.mockImpl(function() {
<ide> describe('Resolver', function() {
<ide>
<ide> var depResolver = new Resolver({
<ide> projectRoot: '/root',
<add> getModuleId,
<ide> });
<ide>
<ide> DependencyGraph.prototype.getDependencies.mockImpl(function() {
<ide> describe('Resolver', function() {
<ide> var depResolver = new Resolver({
<ide> projectRoot: '/root',
<ide> polyfillModuleNames: ['some module'],
<add> getModuleId,
<ide> });
<ide>
<ide> DependencyGraph.prototype.getDependencies.mockImpl(function() {
<ide> describe('Resolver', function() {
<ide> pit('should resolve modules', function() {
<ide> var depResolver = new Resolver({
<ide> projectRoot: '/root',
<add> getModuleId,
<ide> });
<ide>
<del> var dependencies = ['x', 'y', 'z', 'a', 'b'];
<add> const magicJoiner = '\n\n\n';
<ide>
<ide> /*eslint-disable */
<del> var code = [
<add> const testCases = [
<ide> // single line import
<ide> "import'x';",
<ide> "import 'x';",
<ide> describe('Resolver', function() {
<ide> 'import * as All from "x";',
<ide> 'import { } from "x";',
<ide> 'import { Foo } from "x";',
<add> 'import{Foo}from"x";',
<ide> 'import { Foo, } from "x";',
<ide> 'import { Foo as Bar } from "x";',
<ide> 'import { Foo as Bar, } from "x";',
<ide> describe('Resolver', function() {
<ide> "export { } from 'x';",
<ide> "export {Foo} from 'x';",
<ide> "export { Foo } from 'x';",
<add> "export{Foo}from'x';",
<ide> "export { Foo, } from 'x';",
<ide> "export {Foo as Bar} from 'x';",
<ide> "export { Foo as Bar } from 'x';",
<ide> describe('Resolver', function() {
<ide> 'require( \'z\' )',
<ide> 'require( "a")',
<ide> 'require("b" )',
<del> ].join('\n');
<add> ]
<ide> /*eslint-disable */
<add> const code = testCases.join(magicJoiner);
<ide>
<ide> const module = createModule('test module', ['x', 'y']);
<ide>
<ide> describe('Resolver', function() {
<ide> asyncDependencies: [],
<ide> });
<ide>
<del> resolutionResponse.getResolvedDependencyPairs = (module) => {
<del> return [
<del> ['x', createModule('changed')],
<del> ['y', createModule('Y')],
<del> ];
<add> const pairs = [
<add> ['x', createModule('changed')],
<add> ['y', createModule('Y')],
<add> ];
<add> resolutionResponse.getResolvedDependencyPairs = () => pairs;
<add>
<add> function makeExpected(code) {
<add> return pairs
<add> .reduce((code, [id, module]) =>
<add> code.replace(
<add> RegExp(`(['"])${id}\\1`),
<add> (_, quot) => `${quot}${getModuleId(module)}${quot} /* ${id} */`
<add> ),
<add> code
<add> );
<ide> }
<ide>
<ide> return depResolver.wrapModule(
<ide> describe('Resolver', function() {
<ide> code
<ide> ).then(processedCode => {
<ide> expect(processedCode.name).toEqual('test module');
<del> expect(processedCode.code).toEqual([
<del> '__d(\'test module\',function(global, require,' +
<del> ' module, exports) { ' +
<del> // single line import
<del> "import'x';",
<del> "import 'changed';",
<del> "import 'changed' ;",
<del> "import Default from 'changed';",
<del> "import * as All from 'changed';",
<del> "import {} from 'changed';",
<del> "import { } from 'changed';",
<del> "import {Foo} from 'changed';",
<del> "import { Foo } from 'changed';",
<del> "import { Foo, } from 'changed';",
<del> "import {Foo as Bar} from 'changed';",
<del> "import { Foo as Bar } from 'changed';",
<del> "import { Foo as Bar, } from 'changed';",
<del> "import { Foo, Bar } from 'changed';",
<del> "import { Foo, Bar, } from 'changed';",
<del> "import { Foo as Bar, Baz } from 'changed';",
<del> "import { Foo as Bar, Baz, } from 'changed';",
<del> "import { Foo, Bar as Baz } from 'changed';",
<del> "import { Foo, Bar as Baz, } from 'changed';",
<del> "import { Foo as Bar, Baz as Qux } from 'changed';",
<del> "import { Foo as Bar, Baz as Qux, } from 'changed';",
<del> "import { Foo, Bar, Baz } from 'changed';",
<del> "import { Foo, Bar, Baz, } from 'changed';",
<del> "import { Foo as Bar, Baz, Qux } from 'changed';",
<del> "import { Foo as Bar, Baz, Qux, } from 'changed';",
<del> "import { Foo, Bar as Baz, Qux } from 'changed';",
<del> "import { Foo, Bar as Baz, Qux, } from 'changed';",
<del> "import { Foo, Bar, Baz as Qux } from 'changed';",
<del> "import { Foo, Bar, Baz as Qux, } from 'changed';",
<del> "import { Foo as Bar, Baz as Qux, Norf } from 'changed';",
<del> "import { Foo as Bar, Baz as Qux, Norf, } from 'changed';",
<del> "import { Foo as Bar, Baz, Qux as Norf } from 'changed';",
<del> "import { Foo as Bar, Baz, Qux as Norf, } from 'changed';",
<del> "import { Foo, Bar as Baz, Qux as Norf } from 'changed';",
<del> "import { Foo, Bar as Baz, Qux as Norf, } from 'changed';",
<del> "import { Foo as Bar, Baz as Qux, Norf as Enuf } from 'changed';",
<del> "import { Foo as Bar, Baz as Qux, Norf as Enuf, } from 'changed';",
<del> "import Default, * as All from 'changed';",
<del> "import Default, { } from 'changed';",
<del> "import Default, { Foo } from 'changed';",
<del> "import Default, { Foo, } from 'changed';",
<del> "import Default, { Foo as Bar } from 'changed';",
<del> "import Default, { Foo as Bar, } from 'changed';",
<del> "import Default, { Foo, Bar } from 'changed';",
<del> "import Default, { Foo, Bar, } from 'changed';",
<del> "import Default, { Foo as Bar, Baz } from 'changed';",
<del> "import Default, { Foo as Bar, Baz, } from 'changed';",
<del> "import Default, { Foo, Bar as Baz } from 'changed';",
<del> "import Default, { Foo, Bar as Baz, } from 'changed';",
<del> "import Default, { Foo as Bar, Baz as Qux } from 'changed';",
<del> "import Default, { Foo as Bar, Baz as Qux, } from 'changed';",
<del> "import Default, { Foo, Bar, Baz } from 'changed';",
<del> "import Default, { Foo, Bar, Baz, } from 'changed';",
<del> "import Default, { Foo as Bar, Baz, Qux } from 'changed';",
<del> "import Default, { Foo as Bar, Baz, Qux, } from 'changed';",
<del> "import Default, { Foo, Bar as Baz, Qux } from 'changed';",
<del> "import Default, { Foo, Bar as Baz, Qux, } from 'changed';",
<del> "import Default, { Foo, Bar, Baz as Qux } from 'changed';",
<del> "import Default, { Foo, Bar, Baz as Qux, } from 'changed';",
<del> "import Default, { Foo as Bar, Baz as Qux, Norf } from 'changed';",
<del> "import Default, { Foo as Bar, Baz as Qux, Norf, } from 'changed';",
<del> "import Default, { Foo as Bar, Baz, Qux as Norf } from 'changed';",
<del> "import Default, { Foo as Bar, Baz, Qux as Norf, } from 'changed';",
<del> "import Default, { Foo, Bar as Baz, Qux as Norf } from 'changed';",
<del> "import Default, { Foo, Bar as Baz, Qux as Norf, } from 'changed';",
<del> "import Default, { Foo as Bar, Baz as Qux, Norf as NoMore } from 'changed';",
<del> "import Default, { Foo as Bar, Baz as Qux, Norf as NoMore, } from 'changed';",
<del> "import Default , { } from 'changed';",
<del> 'import "changed";',
<del> 'import Default from "changed";',
<del> 'import * as All from "changed";',
<del> 'import { } from "changed";',
<del> 'import { Foo } from "changed";',
<del> 'import { Foo, } from "changed";',
<del> 'import { Foo as Bar } from "changed";',
<del> 'import { Foo as Bar, } from "changed";',
<del> 'import { Foo, Bar } from "changed";',
<del> 'import { Foo, Bar, } from "changed";',
<del> 'import { Foo as Bar, Baz } from "changed";',
<del> 'import { Foo as Bar, Baz, } from "changed";',
<del> 'import { Foo, Bar as Baz } from "changed";',
<del> 'import { Foo, Bar as Baz, } from "changed";',
<del> 'import { Foo as Bar, Baz as Qux } from "changed";',
<del> 'import { Foo as Bar, Baz as Qux, } from "changed";',
<del> 'import { Foo, Bar, Baz } from "changed";',
<del> 'import { Foo, Bar, Baz, } from "changed";',
<del> 'import { Foo as Bar, Baz, Qux } from "changed";',
<del> 'import { Foo as Bar, Baz, Qux, } from "changed";',
<del> 'import { Foo, Bar as Baz, Qux } from "changed";',
<del> 'import { Foo, Bar as Baz, Qux, } from "changed";',
<del> 'import { Foo, Bar, Baz as Qux } from "changed";',
<del> 'import { Foo, Bar, Baz as Qux, } from "changed";',
<del> 'import { Foo as Bar, Baz as Qux, Norf } from "changed";',
<del> 'import { Foo as Bar, Baz as Qux, Norf, } from "changed";',
<del> 'import { Foo as Bar, Baz, Qux as Norf } from "changed";',
<del> 'import { Foo as Bar, Baz, Qux as Norf, } from "changed";',
<del> 'import { Foo, Bar as Baz, Qux as Norf } from "changed";',
<del> 'import { Foo, Bar as Baz, Qux as Norf, } from "changed";',
<del> 'import { Foo as Bar, Baz as Qux, Norf as NoMore } from "changed";',
<del> 'import { Foo as Bar, Baz as Qux, Norf as NoMore, } from "changed";',
<del> 'import Default, * as All from "changed";',
<del> 'import Default, { } from "changed";',
<del> 'import Default, { Foo } from "changed";',
<del> 'import Default, { Foo, } from "changed";',
<del> 'import Default, { Foo as Bar } from "changed";',
<del> 'import Default, { Foo as Bar, } from "changed";',
<del> 'import Default, { Foo, Bar } from "changed";',
<del> 'import Default, { Foo, Bar, } from "changed";',
<del> 'import Default, { Foo as Bar, Baz } from "changed";',
<del> 'import Default, { Foo as Bar, Baz, } from "changed";',
<del> 'import Default, { Foo, Bar as Baz } from "changed";',
<del> 'import Default, { Foo, Bar as Baz, } from "changed";',
<del> 'import Default, { Foo as Bar, Baz as Qux } from "changed";',
<del> 'import Default, { Foo as Bar, Baz as Qux, } from "changed";',
<del> 'import Default, { Foo, Bar, Baz } from "changed";',
<del> 'import Default, { Foo, Bar, Baz, } from "changed";',
<del> 'import Default, { Foo as Bar, Baz, Qux } from "changed";',
<del> 'import Default, { Foo as Bar, Baz, Qux, } from "changed";',
<del> 'import Default, { Foo, Bar as Baz, Qux } from "changed";',
<del> 'import Default, { Foo, Bar as Baz, Qux, } from "changed";',
<del> 'import Default, { Foo, Bar, Baz as Qux } from "changed";',
<del> 'import Default, { Foo, Bar, Baz as Qux, } from "changed";',
<del> 'import Default, { Foo as Bar, Baz as Qux, Norf } from "changed";',
<del> 'import Default, { Foo as Bar, Baz as Qux, Norf, } from "changed";',
<del> 'import Default, { Foo as Bar, Baz, Qux as Norf } from "changed";',
<del> 'import Default, { Foo as Bar, Baz, Qux as Norf, } from "changed";',
<del> 'import Default, { Foo, Bar as Baz, Qux as Norf } from "changed";',
<del> 'import Default, { Foo, Bar as Baz, Qux as Norf, } from "changed";',
<del> 'import Default, { Foo as Bar, Baz as Qux, Norf as Enuf } from "changed";',
<del> 'import Default, { Foo as Bar, Baz as Qux, Norf as Enuf, } from "changed";',
<del> 'import Default from "Y";',
<del> 'import * as All from \'z\';',
<del> // import with support for new lines
<del> "import { Foo,\n Bar }\n from 'changed';",
<del> "import { \nFoo,\nBar,\n }\n from 'changed';",
<del> "import { Foo as Bar,\n Baz\n }\n from 'changed';",
<del> "import { \nFoo as Bar,\n Baz\n, }\n from 'changed';",
<del> "import { Foo,\n Bar as Baz\n }\n from 'changed';",
<del> "import { Foo,\n Bar as Baz,\n }\n from 'changed';",
<del> "import { Foo as Bar,\n Baz as Qux\n }\n from 'changed';",
<del> "import { Foo as Bar,\n Baz as Qux,\n }\n from 'changed';",
<del> "import { Foo,\n Bar,\n Baz }\n from 'changed';",
<del> "import { Foo,\n Bar,\n Baz,\n }\n from 'changed';",
<del> "import { Foo as Bar,\n Baz,\n Qux\n }\n from 'changed';",
<del> "import { Foo as Bar,\n Baz,\n Qux,\n }\n from 'changed';",
<del> "import { Foo,\n Bar as Baz,\n Qux\n }\n from 'changed';",
<del> "import { Foo,\n Bar as Baz,\n Qux,\n }\n from 'changed';",
<del> "import { Foo,\n Bar,\n Baz as Qux\n }\n from 'changed';",
<del> "import { Foo,\n Bar,\n Baz as Qux,\n }\n from 'changed';",
<del> "import { Foo as Bar,\n Baz as Qux,\n Norf\n }\n from 'changed';",
<del> "import { Foo as Bar,\n Baz as Qux,\n Norf,\n }\n from 'changed';",
<del> "import { Foo as Bar,\n Baz,\n Qux as Norf\n }\n from 'changed';",
<del> "import { Foo as Bar,\n Baz,\n Qux as Norf,\n }\n from 'changed';",
<del> "import { Foo,\n Bar as Baz,\n Qux as Norf\n }\n from 'changed';",
<del> "import { Foo,\n Bar as Baz,\n Qux as Norf,\n }\n from 'changed';",
<del> "import { Foo as Bar,\n Baz as Qux,\n Norf as Enuf\n }\n from 'changed';",
<del> "import { Foo as Bar,\n Baz as Qux,\n Norf as Enuf,\n }\n from 'changed';",
<del> "import Default,\n * as All from 'changed';",
<del> "import Default,\n { } from 'changed';",
<del> "import Default,\n { Foo\n }\n from 'changed';",
<del> "import Default,\n { Foo,\n }\n from 'changed';",
<del> "import Default,\n { Foo as Bar\n }\n from 'changed';",
<del> "import Default,\n { Foo as Bar,\n }\n from 'changed';",
<del> "import Default,\n { Foo,\n Bar\n } from\n 'changed';",
<del> "import Default,\n { Foo,\n Bar,\n } from\n 'changed';",
<del> "import Default,\n { Foo as Bar,\n Baz\n }\n from 'changed';",
<del> "import Default,\n { Foo as Bar,\n Baz,\n }\n from 'changed';",
<del> "import Default,\n { Foo,\n Bar as Baz\n }\n from 'changed';",
<del> "import Default,\n { Foo,\n Bar as Baz,\n }\n from 'changed';",
<del> "import Default,\n { Foo as Bar,\n Baz as Qux\n }\n from 'changed';",
<del> "import Default,\n { Foo as Bar,\n Baz as Qux,\n }\n from 'changed';",
<del> "import Default,\n { Foo,\n Bar,\n Baz\n }\n from 'changed';",
<del> "import Default,\n { Foo,\n Bar,\n Baz,\n }\n from 'changed';",
<del> "import Default,\n { Foo as Bar,\n Baz,\n Qux\n }\n from 'changed';",
<del> "import Default,\n { Foo as Bar,\n Baz,\n Qux,\n }\n from 'changed';",
<del> "import Default,\n { Foo,\n Bar as Baz,\n Qux\n }\n from 'changed';",
<del> "import Default,\n { Foo,\n Bar as Baz,\n Qux,\n }\n from 'changed';",
<del> "import Default,\n { Foo,\n Bar,\n Baz as Qux\n }\n from 'changed';",
<del> "import Default,\n { Foo,\n Bar,\n Baz as Qux,\n }\n from 'changed';",
<del> "import Default,\n { Foo as Bar,\n Baz as Qux,\n Norf\n }\n from 'changed';",
<del> "import Default,\n { Foo as Bar,\n Baz as Qux,\n Norf,\n }\n from 'changed';",
<del> "import Default,\n { Foo as Bar,\n Baz,\n Qux as Norf }\n from 'changed';",
<del> "import Default,\n { Foo as Bar,\n Baz,\n Qux as Norf, }\n from 'changed';",
<del> "import Default,\n { Foo, Bar as Baz,\n Qux as Norf }\n from 'changed';",
<del> "import Default,\n { Foo, Bar as Baz,\n Qux as Norf, }\n from 'changed';",
<del> "import Default,\n { Foo as Bar,\n Baz as Qux,\n Norf as NoMore\n }\n from 'changed';",
<del> "import Default,\n { Foo as Bar,\n Baz as Qux,\n Norf as NoMore,\n }\n from 'changed';",
<del> "import Default\n , { } from 'changed';",
<del> // single line export
<del> "export'x';",
<del> "export 'changed';",
<del> "export 'changed' ;",
<del> "export Default from 'changed';",
<del> "export * as All from 'changed';",
<del> "export {} from 'changed';",
<del> "export { } from 'changed';",
<del> "export {Foo} from 'changed';",
<del> "export { Foo } from 'changed';",
<del> "export { Foo, } from 'changed';",
<del> "export {Foo as Bar} from 'changed';",
<del> "export { Foo as Bar } from 'changed';",
<del> "export { Foo as Bar, } from 'changed';",
<del> "export { Foo, Bar } from 'changed';",
<del> "export { Foo, Bar, } from 'changed';",
<del> "export { Foo as Bar, Baz } from 'changed';",
<del> "export { Foo as Bar, Baz, } from 'changed';",
<del> "export { Foo, Bar as Baz } from 'changed';",
<del> "export { Foo, Bar as Baz, } from 'changed';",
<del> "export { Foo as Bar, Baz as Qux } from 'changed';",
<del> "export { Foo as Bar, Baz as Qux, } from 'changed';",
<del> "export { Foo, Bar, Baz } from 'changed';",
<del> "export { Foo, Bar, Baz, } from 'changed';",
<del> "export { Foo as Bar, Baz, Qux } from 'changed';",
<del> "export { Foo as Bar, Baz, Qux, } from 'changed';",
<del> "export { Foo, Bar as Baz, Qux } from 'changed';",
<del> "export { Foo, Bar as Baz, Qux, } from 'changed';",
<del> "export { Foo, Bar, Baz as Qux } from 'changed';",
<del> "export { Foo, Bar, Baz as Qux, } from 'changed';",
<del> "export { Foo as Bar, Baz as Qux, Norf } from 'changed';",
<del> "export { Foo as Bar, Baz as Qux, Norf, } from 'changed';",
<del> "export { Foo as Bar, Baz, Qux as Norf } from 'changed';",
<del> "export { Foo as Bar, Baz, Qux as Norf, } from 'changed';",
<del> "export { Foo, Bar as Baz, Qux as Norf } from 'changed';",
<del> "export { Foo, Bar as Baz, Qux as Norf, } from 'changed';",
<del> "export { Foo as Bar, Baz as Qux, Norf as Enuf } from 'changed';",
<del> "export { Foo as Bar, Baz as Qux, Norf as Enuf, } from 'changed';",
<del> "export Default, * as All from 'changed';",
<del> "export Default, { } from 'changed';",
<del> "export Default, { Foo } from 'changed';",
<del> "export Default, { Foo, } from 'changed';",
<del> "export Default, { Foo as Bar } from 'changed';",
<del> "export Default, { Foo as Bar, } from 'changed';",
<del> "export Default, { Foo, Bar } from 'changed';",
<del> "export Default, { Foo, Bar, } from 'changed';",
<del> "export Default, { Foo as Bar, Baz } from 'changed';",
<del> "export Default, { Foo as Bar, Baz, } from 'changed';",
<del> "export Default, { Foo, Bar as Baz } from 'changed';",
<del> "export Default, { Foo, Bar as Baz, } from 'changed';",
<del> "export Default, { Foo as Bar, Baz as Qux } from 'changed';",
<del> "export Default, { Foo as Bar, Baz as Qux, } from 'changed';",
<del> "export Default, { Foo, Bar, Baz } from 'changed';",
<del> "export Default, { Foo, Bar, Baz, } from 'changed';",
<del> "export Default, { Foo as Bar, Baz, Qux } from 'changed';",
<del> "export Default, { Foo as Bar, Baz, Qux, } from 'changed';",
<del> "export Default, { Foo, Bar as Baz, Qux } from 'changed';",
<del> "export Default, { Foo, Bar as Baz, Qux, } from 'changed';",
<del> "export Default, { Foo, Bar, Baz as Qux } from 'changed';",
<del> "export Default, { Foo, Bar, Baz as Qux, } from 'changed';",
<del> "export Default, { Foo as Bar, Baz as Qux, Norf } from 'changed';",
<del> "export Default, { Foo as Bar, Baz as Qux, Norf, } from 'changed';",
<del> "export Default, { Foo as Bar, Baz, Qux as Norf } from 'changed';",
<del> "export Default, { Foo as Bar, Baz, Qux as Norf, } from 'changed';",
<del> "export Default, { Foo, Bar as Baz, Qux as Norf } from 'changed';",
<del> "export Default, { Foo, Bar as Baz, Qux as Norf, } from 'changed';",
<del> "export Default, { Foo as Bar, Baz as Qux, Norf as NoMore } from 'changed';",
<del> "export Default, { Foo as Bar, Baz as Qux, Norf as NoMore, } from 'changed';",
<del> "export Default , { } from 'changed';",
<del> 'export "changed";',
<del> 'export Default from "changed";',
<del> 'export * as All from "changed";',
<del> 'export { } from "changed";',
<del> 'export { Foo } from "changed";',
<del> 'export { Foo, } from "changed";',
<del> 'export { Foo as Bar } from "changed";',
<del> 'export { Foo as Bar, } from "changed";',
<del> 'export { Foo, Bar } from "changed";',
<del> 'export { Foo, Bar, } from "changed";',
<del> 'export { Foo as Bar, Baz } from "changed";',
<del> 'export { Foo as Bar, Baz, } from "changed";',
<del> 'export { Foo, Bar as Baz } from "changed";',
<del> 'export { Foo, Bar as Baz, } from "changed";',
<del> 'export { Foo as Bar, Baz as Qux } from "changed";',
<del> 'export { Foo as Bar, Baz as Qux, } from "changed";',
<del> 'export { Foo, Bar, Baz } from "changed";',
<del> 'export { Foo, Bar, Baz, } from "changed";',
<del> 'export { Foo as Bar, Baz, Qux } from "changed";',
<del> 'export { Foo as Bar, Baz, Qux, } from "changed";',
<del> 'export { Foo, Bar as Baz, Qux } from "changed";',
<del> 'export { Foo, Bar as Baz, Qux, } from "changed";',
<del> 'export { Foo, Bar, Baz as Qux } from "changed";',
<del> 'export { Foo, Bar, Baz as Qux, } from "changed";',
<del> 'export { Foo as Bar, Baz as Qux, Norf } from "changed";',
<del> 'export { Foo as Bar, Baz as Qux, Norf, } from "changed";',
<del> 'export { Foo as Bar, Baz, Qux as Norf } from "changed";',
<del> 'export { Foo as Bar, Baz, Qux as Norf, } from "changed";',
<del> 'export { Foo, Bar as Baz, Qux as Norf } from "changed";',
<del> 'export { Foo, Bar as Baz, Qux as Norf, } from "changed";',
<del> 'export { Foo as Bar, Baz as Qux, Norf as NoMore } from "changed";',
<del> 'export { Foo as Bar, Baz as Qux, Norf as NoMore, } from "changed";',
<del> 'export Default, * as All from "changed";',
<del> 'export Default, { } from "changed";',
<del> 'export Default, { Foo } from "changed";',
<del> 'export Default, { Foo, } from "changed";',
<del> 'export Default, { Foo as Bar } from "changed";',
<del> 'export Default, { Foo as Bar, } from "changed";',
<del> 'export Default, { Foo, Bar } from "changed";',
<del> 'export Default, { Foo, Bar, } from "changed";',
<del> 'export Default, { Foo as Bar, Baz } from "changed";',
<del> 'export Default, { Foo as Bar, Baz, } from "changed";',
<del> 'export Default, { Foo, Bar as Baz } from "changed";',
<del> 'export Default, { Foo, Bar as Baz, } from "changed";',
<del> 'export Default, { Foo as Bar, Baz as Qux } from "changed";',
<del> 'export Default, { Foo as Bar, Baz as Qux, } from "changed";',
<del> 'export Default, { Foo, Bar, Baz } from "changed";',
<del> 'export Default, { Foo, Bar, Baz, } from "changed";',
<del> 'export Default, { Foo as Bar, Baz, Qux } from "changed";',
<del> 'export Default, { Foo as Bar, Baz, Qux, } from "changed";',
<del> 'export Default, { Foo, Bar as Baz, Qux } from "changed";',
<del> 'export Default, { Foo, Bar as Baz, Qux, } from "changed";',
<del> 'export Default, { Foo, Bar, Baz as Qux } from "changed";',
<del> 'export Default, { Foo, Bar, Baz as Qux, } from "changed";',
<del> 'export Default, { Foo as Bar, Baz as Qux, Norf } from "changed";',
<del> 'export Default, { Foo as Bar, Baz as Qux, Norf, } from "changed";',
<del> 'export Default, { Foo as Bar, Baz, Qux as Norf } from "changed";',
<del> 'export Default, { Foo as Bar, Baz, Qux as Norf, } from "changed";',
<del> 'export Default, { Foo, Bar as Baz, Qux as Norf } from "changed";',
<del> 'export Default, { Foo, Bar as Baz, Qux as Norf, } from "changed";',
<del> 'export Default, { Foo as Bar, Baz as Qux, Norf as Enuf } from "changed";',
<del> 'export Default, { Foo as Bar, Baz as Qux, Norf as Enuf, } from "changed";',
<del> 'export Default from "Y";',
<del> 'export * as All from \'z\';',
<del> // export with support for new lines
<del> "export { Foo,\n Bar }\n from 'changed';",
<del> "export { \nFoo,\nBar,\n }\n from 'changed';",
<del> "export { Foo as Bar,\n Baz\n }\n from 'changed';",
<del> "export { \nFoo as Bar,\n Baz\n, }\n from 'changed';",
<del> "export { Foo,\n Bar as Baz\n }\n from 'changed';",
<del> "export { Foo,\n Bar as Baz,\n }\n from 'changed';",
<del> "export { Foo as Bar,\n Baz as Qux\n }\n from 'changed';",
<del> "export { Foo as Bar,\n Baz as Qux,\n }\n from 'changed';",
<del> "export { Foo,\n Bar,\n Baz }\n from 'changed';",
<del> "export { Foo,\n Bar,\n Baz,\n }\n from 'changed';",
<del> "export { Foo as Bar,\n Baz,\n Qux\n }\n from 'changed';",
<del> "export { Foo as Bar,\n Baz,\n Qux,\n }\n from 'changed';",
<del> "export { Foo,\n Bar as Baz,\n Qux\n }\n from 'changed';",
<del> "export { Foo,\n Bar as Baz,\n Qux,\n }\n from 'changed';",
<del> "export { Foo,\n Bar,\n Baz as Qux\n }\n from 'changed';",
<del> "export { Foo,\n Bar,\n Baz as Qux,\n }\n from 'changed';",
<del> "export { Foo as Bar,\n Baz as Qux,\n Norf\n }\n from 'changed';",
<del> "export { Foo as Bar,\n Baz as Qux,\n Norf,\n }\n from 'changed';",
<del> "export { Foo as Bar,\n Baz,\n Qux as Norf\n }\n from 'changed';",
<del> "export { Foo as Bar,\n Baz,\n Qux as Norf,\n }\n from 'changed';",
<del> "export { Foo,\n Bar as Baz,\n Qux as Norf\n }\n from 'changed';",
<del> "export { Foo,\n Bar as Baz,\n Qux as Norf,\n }\n from 'changed';",
<del> "export { Foo as Bar,\n Baz as Qux,\n Norf as Enuf\n }\n from 'changed';",
<del> "export { Foo as Bar,\n Baz as Qux,\n Norf as Enuf,\n }\n from 'changed';",
<del> "export Default,\n * as All from 'changed';",
<del> "export Default,\n { } from 'changed';",
<del> "export Default,\n { Foo\n }\n from 'changed';",
<del> "export Default,\n { Foo,\n }\n from 'changed';",
<del> "export Default,\n { Foo as Bar\n }\n from 'changed';",
<del> "export Default,\n { Foo as Bar,\n }\n from 'changed';",
<del> "export Default,\n { Foo,\n Bar\n } from\n 'changed';",
<del> "export Default,\n { Foo,\n Bar,\n } from\n 'changed';",
<del> "export Default,\n { Foo as Bar,\n Baz\n }\n from 'changed';",
<del> "export Default,\n { Foo as Bar,\n Baz,\n }\n from 'changed';",
<del> "export Default,\n { Foo,\n Bar as Baz\n }\n from 'changed';",
<del> "export Default,\n { Foo,\n Bar as Baz,\n }\n from 'changed';",
<del> "export Default,\n { Foo as Bar,\n Baz as Qux\n }\n from 'changed';",
<del> "export Default,\n { Foo as Bar,\n Baz as Qux,\n }\n from 'changed';",
<del> "export Default,\n { Foo,\n Bar,\n Baz\n }\n from 'changed';",
<del> "export Default,\n { Foo,\n Bar,\n Baz,\n }\n from 'changed';",
<del> "export Default,\n { Foo as Bar,\n Baz,\n Qux\n }\n from 'changed';",
<del> "export Default,\n { Foo as Bar,\n Baz,\n Qux,\n }\n from 'changed';",
<del> "export Default,\n { Foo,\n Bar as Baz,\n Qux\n }\n from 'changed';",
<del> "export Default,\n { Foo,\n Bar as Baz,\n Qux,\n }\n from 'changed';",
<del> "export Default,\n { Foo,\n Bar,\n Baz as Qux\n }\n from 'changed';",
<del> "export Default,\n { Foo,\n Bar,\n Baz as Qux,\n }\n from 'changed';",
<del> "export Default,\n { Foo as Bar,\n Baz as Qux,\n Norf\n }\n from 'changed';",
<del> "export Default,\n { Foo as Bar,\n Baz as Qux,\n Norf,\n }\n from 'changed';",
<del> "export Default,\n { Foo as Bar,\n Baz,\n Qux as Norf }\n from 'changed';",
<del> "export Default,\n { Foo as Bar,\n Baz,\n Qux as Norf, }\n from 'changed';",
<del> "export Default,\n { Foo, Bar as Baz,\n Qux as Norf }\n from 'changed';",
<del> "export Default,\n { Foo, Bar as Baz,\n Qux as Norf, }\n from 'changed';",
<del> "export Default,\n { Foo as Bar,\n Baz as Qux,\n Norf as NoMore\n }\n from 'changed';",
<del> "export Default,\n { Foo as Bar,\n Baz as Qux,\n Norf as NoMore,\n }\n from 'changed';",
<del> "export Default\n , { } from 'changed';",
<del> // require
<del> 'require("changed")',
<del> 'require("Y")',
<del> 'require( \'z\' )',
<del> 'require( "a")',
<del> 'require("b" )',
<del> '});',
<del> ].join('\n'));
<add>
<add> // extract the converted code from the module wrapper
<add> const cases =
<add> processedCode.code
<add> .match(/__d\(.*?\{\s*([\s\S]*)\}/)[1] // match code in wrapper
<add> .replace(/\s+$/, '') // remove trailing whitespace
<add> .split(magicJoiner); // extract every tested case
<add>
<add> testCases.forEach((inputCode, i) => {
<add> expect(cases[i]).toEqual(makeExpected(inputCode));
<add> if(cases[i]!==makeExpected(inputCode)) {
<add> console.log('FAIL %s: input(%s) expected(%s) actual(%s)', i, inputCode, makeExpected(inputCode), cases[i]);
<add> }
<add> });
<ide> });
<ide> });
<ide>
<ide><path>packager/react-packager/src/Resolver/index.js
<ide> const validateOpts = declareOpts({
<ide> type: 'object',
<ide> required: true,
<ide> },
<add> getModuleId: {
<add> type: 'function',
<add> required: true,
<add> }
<ide> });
<ide>
<ide> const getDependenciesValidateOpts = declareOpts({
<ide> class Resolver {
<ide> shouldThrowOnUnresolvedErrors: (_, platform) => platform === 'ios',
<ide> });
<ide>
<add> this._getModuleId = options.getModuleId;
<ide> this._polyfillModuleNames = opts.polyfillModuleNames || [];
<ide> }
<ide>
<ide> class Resolver {
<ide> }
<ide>
<ide> const resolvedDeps = Object.create(null);
<del> const resolvedDepsArr = [];
<ide>
<ide> return Promise.all(
<ide> resolutionResponse.getResolvedDependencyPairs(module).map(
<ide> ([depName, depModule]) => {
<ide> if (depModule) {
<del> return depModule.getName().then(name => {
<del> resolvedDeps[depName] = name;
<del> resolvedDepsArr.push(name);
<del> });
<add> resolvedDeps[depName] = this._getModuleId(depModule);
<ide> }
<ide> }
<ide> )
<ide> ).then(() => {
<del> const relativizeCode = (codeMatch, pre, quot, depName, post) => {
<del> const depId = resolvedDeps[depName];
<del> if (depId) {
<del> return pre + quot + depId + post;
<add> const replaceModuleId = (codeMatch, pre, quot, depName, post = '') => {
<add> if (depName in resolvedDeps) {
<add> const replacement = `${quot}${resolvedDeps[depName]}${quot}`;
<add> return `${pre}${replacement} /* ${depName} */${post}`;
<ide> } else {
<ide> return codeMatch;
<ide> }
<ide> };
<ide>
<ide> code = code
<del> .replace(replacePatterns.IMPORT_RE, relativizeCode)
<del> .replace(replacePatterns.EXPORT_RE, relativizeCode)
<del> .replace(replacePatterns.REQUIRE_RE, relativizeCode);
<add> .replace(replacePatterns.IMPORT_RE, replaceModuleId)
<add> .replace(replacePatterns.EXPORT_RE, replaceModuleId)
<add> .replace(replacePatterns.REQUIRE_RE, replaceModuleId);
<ide>
<ide> return module.getName().then(name => {
<del> return {name, code};
<add> return {name, code, id: this._getModuleId(module)};
<ide> });
<ide> });
<ide> });
<ide> class Resolver {
<ide> }
<ide>
<ide> return this.resolveRequires(resolutionResponse, module, code).then(
<del> ({name, code}) => {
<del> return {name, code: defineModuleCode(name, code)};
<add> ({name, code, id}) => {
<add> return {id, name, code: defineModuleCode(id, code, name)};
<ide> });
<ide> }
<ide>
<ide> class Resolver {
<ide>
<ide> }
<ide>
<del>function defineModuleCode(moduleName, code) {
<add>function defineModuleCode(moduleId, code, verboseName = '') {
<ide> return [
<ide> `__d(`,
<del> `'${moduleName}',`,
<add> `${JSON.stringify(moduleId)} /* ${verboseName} */ ,`,
<ide> 'function(global, require, module, exports) {',
<ide> ` ${code}`,
<ide> '\n});',
<ide><path>packager/react-packager/src/Resolver/polyfills/require.js
<ide> function requireImpl(id) {
<ide> );
<ide> }
<ide>
<add>
<add> // `require` calls int the require polyfill itself are not analyzed and
<add> // replaced so that they use numeric module IDs.
<add> // The systrace module will expose itself on the require function so that
<add> // it can be used here.
<add> // TODO(davidaurelio) Scan polyfills for dependencies, too (t9759686)
<add> const {Systrace} = require;
<ide> try {
<ide> // We must optimistically mark mod as initialized before running the factory to keep any
<ide> // require cycles inside the factory from causing an infinite require loop.
<ide> mod.isInitialized = true;
<ide>
<del> __DEV__ && Systrace().beginEvent('JS_require_' + id);
<add> if (__DEV__) {
<add> Systrace.beginEvent('JS_require_' + id);
<add> }
<ide>
<ide> // keep args in sync with with defineModuleCode in
<ide> // packager/react-packager/src/Resolver/index.js
<ide> mod.factory.call(global, global, require, mod.module, mod.module.exports);
<ide>
<del> __DEV__ && Systrace().endEvent();
<add> if (__DEV__) {
<add> Systrace.endEvent();
<add> }
<ide> } catch (e) {
<ide> mod.hasError = true;
<ide> mod.isInitialized = false;
<ide> function requireImpl(id) {
<ide> return mod.module.exports;
<ide> }
<ide>
<del>const Systrace = __DEV__ && (() => {
<del> var _Systrace;
<del> try {
<del> _Systrace = require('Systrace');
<del> } catch (e) {}
<del>
<del> return _Systrace && _Systrace.beginEvent ?
<del> _Systrace : { beginEvent: () => {}, endEvent: () => {} };
<del>});
<add>if (__DEV__) {
<add> require.Systrace = { beginEvent: () => {}, endEvent: () => {} };
<add>}
<ide>
<ide> global.__d = define;
<ide> global.require = require; | 12 |
Javascript | Javascript | use arrow functions in callbacks | b5c5d206af8fd32f33953d564a151a5a20bfb5b1 | <ide><path>test/parallel/test-stream-pipe-await-drain.js
<ide> writer1._write = common.mustCall(function(chunk, encoding, cb) {
<ide> cb();
<ide> }, 1);
<ide>
<del>writer1.once('chunk-received', function() {
<add>writer1.once('chunk-received', () => {
<ide> assert.strictEqual(
<ide> reader._readableState.awaitDrain,
<ide> 0,
<ide> 'awaitDrain initial value should be 0, actual is ' +
<ide> reader._readableState.awaitDrain
<ide> );
<del> setImmediate(function() {
<add> setImmediate(() => {
<ide> // This one should *not* get through to writer1 because writer2 is not
<ide> // "done" processing.
<ide> reader.push(buffer);
<ide> });
<ide> });
<ide>
<ide> // A "slow" consumer:
<del>writer2._write = common.mustCall(function(chunk, encoding, cb) {
<add>writer2._write = common.mustCall((chunk, encoding, cb) => {
<ide> assert.strictEqual(
<ide> reader._readableState.awaitDrain,
<ide> 1,
<ide> writer2._write = common.mustCall(function(chunk, encoding, cb) {
<ide> // will return false.
<ide> }, 1);
<ide>
<del>writer3._write = common.mustCall(function(chunk, encoding, cb) {
<add>writer3._write = common.mustCall((chunk, encoding, cb) => {
<ide> assert.strictEqual(
<ide> reader._readableState.awaitDrain,
<ide> 2, | 1 |
Text | Text | improve some portuguese expressions. | 538561756f77f7c7f4ef318ecad5128e8097e6c7 | <ide><path>guide/portuguese/user-experience-design/customer-journey-map/index.md
<ide> localeTitle: Mapa da jornada do cliente
<ide> ---
<ide> ## Mapa da jornada do cliente
<ide>
<del>Um mapa de jornada do cliente explica o potencial de orientação da experiência do cliente: desde o contato inicial, passando pelo processo de engajamento até um relacionamento de longo prazo. Ele pode se concentrar em uma parte específica do tabuleiro ou fornecer uma visão geral de toda a experiência. O que sempre faz é identificar as principais interações que o cliente tem com a organização. Ele fala sobre os sentimentos, motivações e perguntas do usuário para cada um desses pontos de contato. Muitas vezes, fornece uma sensação de maior motivação do cliente. O que eles desejam alcançar e quais são as expectativas deles em relação à organização? Um mapa de jornada do cliente assume muitas formas, mas normalmente aparece como algum tipo de infografia. Qualquer que seja sua forma, o objetivo é o mesmo: ensinar as organizações mais sobre seus clientes.
<add>Um mapa de jornada do cliente explica a potencial trajetoria da experiência do cliente: desde o contato inicial, passando pelo processo de engajamento até um relacionamento de longo prazo. Ele pode se concentrar em uma parte específica da trajetória ou fornecer uma visão geral de toda a experiência. O que sempre faz é identificar as principais interações que o cliente tem com a organização. Ele fala sobre os sentimentos, motivações e dúvidas do usuário para cada um desses pontos de contato. Muitas vezes, fornece uma idéia da maior motivação do cliente. O que eles desejam alcançar e quais são as expectativas deles em relação à organização? Um mapa de jornada do cliente assume muitas formas, mas normalmente aparece como um infográfico. Qualquer que seja sua forma, o objetivo é o mesmo: ensinar as organizações mais sobre seus clientes.
<ide>
<ide> 
<ide>
<ide> #### Mais Informações:
<ide>
<del>Tudo sobre o mapa da jornada do cliente aqui: https://www.smashingmagazine.com/2015/01/all-about-customer-journey-mapping/
<ide>\ No newline at end of file
<add>Tudo sobre o mapa da jornada do cliente aqui: https://www.smashingmagazine.com/2015/01/all-about-customer-journey-mapping/ | 1 |
Python | Python | handle properly values with str type in csvlogger | 1a707ea11e9a71e5cdf8095c70cc9cb8574d10c0 | <ide><path>keras/callbacks.py
<ide> def on_epoch_end(self, epoch, logs=None):
<ide>
<ide> def handle_value(k):
<ide> is_zero_dim_ndarray = isinstance(k, np.ndarray) and k.ndim == 0
<del> if isinstance(k, Iterable) and not is_zero_dim_ndarray:
<add> if isinstance(k, six.string_types):
<add> return k
<add> elif isinstance(k, Iterable) and not is_zero_dim_ndarray:
<ide> return '"[%s]"' % (', '.join(map(str, k)))
<ide> else:
<ide> return k | 1 |
Go | Go | fix typos in builder and client | ce0993270436c16a17e0afb08b9130556346b983 | <ide><path>builder/dockerfile/instructions/commands.go
<ide> import (
<ide> "github.com/docker/docker/api/types/strslice"
<ide> )
<ide>
<del>// KeyValuePair represent an arbitrary named value (useful in slice insted of map[string] string to preserve ordering)
<add>// KeyValuePair represent an arbitrary named value (useful in slice instead of map[string] string to preserve ordering)
<ide> type KeyValuePair struct {
<ide> Key string
<ide> Value string
<ide> func (c *WorkdirCommand) Expand(expander SingleWordExpander) error {
<ide> return nil
<ide> }
<ide>
<del>// ShellDependantCmdLine represents a cmdline optionaly prepended with the shell
<add>// ShellDependantCmdLine represents a cmdline optionally prepended with the shell
<ide> type ShellDependantCmdLine struct {
<ide> CmdLine strslice.StrSlice
<ide> PrependShell bool
<ide><path>client/client_test.go
<ide> func TestNegotiateAPIVersion(t *testing.T) {
<ide> }
<ide>
<ide> // TestNegotiateAPIVersionOverride asserts that we honor
<del>// the environment variable DOCKER_API_VERSION when negotianing versions
<add>// the environment variable DOCKER_API_VERSION when negotiating versions
<ide> func TestNegotiateAPVersionOverride(t *testing.T) {
<ide> env := envToMap()
<ide> defer mapToEnv(env) | 2 |
Text | Text | improve api documentation text in readme | bd162b6dc0f4d25239e58564a3a3228947af85b3 | <ide><path>README.md
<ide> Listed under their version string which includes their date (in UTC time) and
<ide> the commit SHA at the HEAD of the release.
<ide>
<ide> #### API Documentation
<del><https://nodejs.org/api/>
<ide>
<del>Points to the API documentation of the latest Current release.
<del>Version specific documentation are avalible in each release and nightly
<del>directory under _docs_ or at <https://nodejs.org/download/docs/>.
<add>Documentation for the latest Current release is at <https://nodejs.org/api/>.
<add>Version-specific documentation is available in each release directory in the
<add>_docs_ subdirectory. Version-specific documentation is also at
<add><https://nodejs.org/download/docs/>.
<ide>
<ide>
<ide> ### Verifying Binaries | 1 |
PHP | PHP | use the console kernel | 0a01aca6b4fcda26c8893d3cd5fa45578fc808ab | <ide><path>tests/TestCase.php
<ide> public function createApplication()
<ide> {
<ide> $app = require __DIR__.'/../bootstrap/app.php';
<ide>
<del> $app->make('Illuminate\Contracts\Http\Kernel')->bootstrap();
<add> $app->make('Illuminate\Contracts\Console\Kernel')->bootstrap();
<ide>
<ide> return $app;
<ide> } | 1 |
Javascript | Javascript | increase error information in test-cli-syntax-* | 914c49497cd92a9266cf5aaed1f425358d1023cc | <ide><path>test/sequential/test-cli-syntax-bad.js
<ide> const syntaxErrorRE = /^SyntaxError: \b/m;
<ide> const cmd = [node, ..._args].join(' ');
<ide> exec(cmd, common.mustCall((err, stdout, stderr) => {
<ide> assert.strictEqual(err instanceof Error, true);
<del> assert.strictEqual(err.code, 1);
<add> assert.strictEqual(err.code, 1,
<add> `code ${err.code} !== 1 for error:\n\n${err}`);
<ide>
<ide> // no stdout should be produced
<ide> assert.strictEqual(stdout, '');
<ide><path>test/sequential/test-cli-syntax-file-not-found.js
<ide> const notFoundRE = /^Error: Cannot find module/m;
<ide> // stderr should have a module not found error message
<ide> assert(notFoundRE.test(stderr), `${notFoundRE} === ${stderr}`);
<ide>
<del> assert.strictEqual(err.code, 1);
<add> assert.strictEqual(err.code, 1,
<add> `code ${err.code} !== 1 for error:\n\n${err}`);
<ide> }));
<ide> });
<ide> });
<ide><path>test/sequential/test-cli-syntax-require.js
<ide> const syntaxErrorRE = /^SyntaxError: \b/m;
<ide> const cmd = [node, ...args].join(' ');
<ide> exec(cmd, common.mustCall((err, stdout, stderr) => {
<ide> assert.strictEqual(err instanceof Error, true);
<del> assert.strictEqual(err.code, 1);
<add> assert.strictEqual(err.code, 1,
<add> `code ${err.code} !== 1 for error:\n\n${err}`);
<ide>
<ide> // no stdout should be produced
<ide> assert.strictEqual(stdout, ''); | 3 |
Javascript | Javascript | relax timer check in test-report-uv-handles.js | 80209cc4c991d4392f776a887c06f84c1319923b | <ide><path>test/report/test-report-uv-handles.js
<ide> if (process.argv[2] === 'child') {
<ide> }
<ide> assert(handle.is_referenced);
<ide> }, 3),
<del> timer: common.mustCall(function timer_validator(handle) {
<add> timer: common.mustCallAtLeast(function timer_validator(handle) {
<ide> assert(!handle.is_referenced);
<ide> assert.strictEqual(handle.repeat, 0);
<ide> }),
<ide> if (process.argv[2] === 'child') {
<ide> assert(handle.is_referenced);
<ide> }),
<ide> };
<add> console.log(report.libuv);
<ide> for (const entry of report.libuv) {
<ide> if (validators[entry.type]) validators[entry.type](entry);
<ide> } | 1 |
Text | Text | remove refenrence to destroy_all_in_batches config | 720f6b1ec21fb112522e664f86dfc28c5edbaefa | <ide><path>guides/source/configuring.md
<ide> Allows specifying the Active Job queue to use for destroy jobs. When this option
<ide>
<ide> When true, will always include column names in `SELECT` statements, and avoid wildcard `SELECT * FROM ...` queries. This avoids prepared statement cache errors when adding columns to a PostgreSQL database for example. Defaults to `false`.
<ide>
<del>#### `config.active_record.destroy_all_in_batches`
<del>
<del>Ensures `ActiveRecord::Relation#destroy_all` performs the record's deletion in
<del>batches. `ActiveRecord::Relation#destroy_all` will no longer return the collection
<del>of the deleted records after enabling this option.
<del>
<ide> #### `config.active_record.verify_foreign_keys_for_fixtures`
<ide>
<ide> Ensures all foreign key constraints are valid after fixtures are loaded in tests. Supported by PostgreSQL and SQLite only. Defaults to `false`. | 1 |
Ruby | Ruby | add example label to activesupport/configurable | f480b2cea69247239f6fc2ad171b231595cc08c6 | <ide><path>activesupport/lib/active_support/configurable.rb
<ide> def #{name}=(value); config.#{name} = value; end
<ide>
<ide> # Reads and writes attributes from a configuration <tt>OrderedHash</tt>.
<ide> #
<add> # Example:
<add> #
<ide> # require 'active_support/configurable'
<ide> #
<ide> # class User | 1 |
Javascript | Javascript | replace common.fixturesdir with fixtures | 6af889615dfb04a39b658e54cf1e5b4b7906d624 | <ide><path>test/parallel/test-fs-whatwg-url.js
<ide> 'use strict';
<ide>
<ide> const common = require('../common');
<add>const fixtures = require('../common/fixtures');
<ide> const assert = require('assert');
<ide> const path = require('path');
<ide> const fs = require('fs');
<ide> function pathToFileURL(p) {
<ide> return new URL(`file://${p}`);
<ide> }
<ide>
<del>const p = path.resolve(common.fixturesDir, 'a.js');
<add>const p = path.resolve(fixtures.fixturesDir, 'a.js');
<ide> const url = pathToFileURL(p);
<ide>
<ide> assert(url instanceof URL); | 1 |
Python | Python | use cudnn in convolution1d layer if available | 65b048455ba3fdd756b0b615ad608eafece05e91 | <ide><path>keras/layers/convolutional.py
<ide> def get_output(self, train):
<ide> X = T.reshape(X, (X.shape[0], X.shape[1], X.shape[2], 1)).dimshuffle(0, 2, 1, 3)
<ide>
<ide> border_mode = self.border_mode
<del> if border_mode == 'same':
<del> border_mode = 'full'
<add> if on_gpu() and dnn.dnn_available():
<add> if border_mode == 'same':
<add> assert(self.subsample_length == 1)
<add> pad_x = (self.filter_length - self.subsample_length) // 2
<add> conv_out = dnn.dnn_conv(img=X,
<add> kerns=self.W,
<add> border_mode=(pad_x, 0))
<add> else:
<add> conv_out = dnn.dnn_conv(img=X,
<add> kerns=self.W,
<add> border_mode=border_mode,
<add> subsample=self.subsample)
<add> else:
<add> if border_mode == 'same':
<add> border_mode = 'full'
<ide>
<del> conv_out = T.nnet.conv.conv2d(X, self.W, border_mode=border_mode, subsample=self.subsample)
<del> if self.border_mode == 'same':
<del> shift_x = (self.filter_length - 1) // 2
<del> conv_out = conv_out[:, :, shift_x:X.shape[2] + shift_x, :]
<add> conv_out = T.nnet.conv.conv2d(X, self.W,
<add> border_mode=border_mode,
<add> subsample=self.subsample)
<add> if self.border_mode == 'same':
<add> shift_x = (self.filter_length - 1) // 2
<add> conv_out = conv_out[:, :, shift_x:X.shape[2] + shift_x, :]
<ide>
<ide> output = self.activation(conv_out + self.b.dimshuffle('x', 0, 'x', 'x'))
<ide> output = T.reshape(output, (output.shape[0], output.shape[1], output.shape[2])).dimshuffle(0, 2, 1) | 1 |
Mixed | Ruby | accept block in travel_back time helper | 21f907bb51df95a26f129277fe817019b8c37f0a | <ide><path>activesupport/CHANGELOG.md
<add>* Add block support to `ActiveSupport::Testing::TimeHelpers#travel_back`.
<add>
<add> *Tim Masliuchenko*
<add>
<ide> * Update `ActiveSupport::Messages::Metadata#fresh?` to work for cookies with expiry set when
<ide> `ActiveSupport.parse_json_times = true`.
<ide>
<ide><path>activesupport/lib/active_support/testing/time_helpers.rb
<ide> def stubbing(object, method_name)
<ide> @stubs[object.object_id][method_name]
<ide> end
<ide>
<add> def stubbed?
<add> !@stubs.empty?
<add> end
<add>
<ide> private
<ide> def unstub_object(stub)
<ide> singleton_class = stub.object.singleton_class
<ide> def travel_to(date_or_time)
<ide> # +travel+, +travel_to+, and +freeze_time+.
<ide> #
<ide> # Time.current # => Sat, 09 Nov 2013 15:34:49 EST -05:00
<add> #
<ide> # travel_to Time.zone.local(2004, 11, 24, 01, 04, 44)
<ide> # Time.current # => Wed, 24 Nov 2004 01:04:44 EST -05:00
<add> #
<ide> # travel_back
<ide> # Time.current # => Sat, 09 Nov 2013 15:34:49 EST -05:00
<add> #
<add> # This method also accepts a block, which brings the stubs back at the end of the block:
<add> #
<add> # Time.current # => Sat, 09 Nov 2013 15:34:49 EST -05:00
<add> #
<add> # travel_to Time.zone.local(2004, 11, 24, 01, 04, 44)
<add> # Time.current # => Wed, 24 Nov 2004 01:04:44 EST -05:00
<add> #
<add> # travel_back do
<add> # Time.current # => Sat, 09 Nov 2013 15:34:49 EST -05:00
<add> # end
<add> #
<add> # Time.current # => Wed, 24 Nov 2004 01:04:44 EST -05:00
<ide> def travel_back
<add> stubbed_time = Time.current if block_given? && simple_stubs.stubbed?
<add>
<ide> simple_stubs.unstub_all!
<add> yield if block_given?
<add> ensure
<add> travel_to stubbed_time if stubbed_time
<ide> end
<ide> alias_method :unfreeze_time, :travel_back
<ide>
<ide><path>activesupport/test/time_travel_test.rb
<ide> def test_time_helper_travel_back
<ide> end
<ide> end
<ide>
<add> def test_time_helper_travel_back_with_block
<add> Time.stub(:now, Time.now) do
<add> expected_time = Time.new(2004, 11, 24, 01, 04, 44)
<add>
<add> travel_to expected_time
<add> assert_equal expected_time, Time.now
<add> assert_equal Date.new(2004, 11, 24), Date.today
<add> assert_equal expected_time.to_datetime, DateTime.now
<add>
<add> travel_back do
<add> assert_not_equal expected_time, Time.now
<add> assert_not_equal Date.new(2004, 11, 24), Date.today
<add> assert_not_equal expected_time.to_datetime, DateTime.now
<add> end
<add>
<add> assert_equal expected_time, Time.now
<add> assert_equal Date.new(2004, 11, 24), Date.today
<add> assert_equal expected_time.to_datetime, DateTime.now
<add> ensure
<add> travel_back
<add> end
<add> end
<add>
<ide> def test_time_helper_travel_to_with_nested_calls_with_blocks
<ide> Time.stub(:now, Time.now) do
<ide> outer_expected_time = Time.new(2004, 11, 24, 01, 04, 44) | 3 |
PHP | PHP | simplify connect code for redis | 4a4a35768b7b6d503333028b956039e70e6cd9a7 | <ide><path>lib/Cake/Cache/Engine/RedisEngine.php
<ide> public function init($settings = array()) {
<ide> * @return boolean True if Redis server was connected
<ide> */
<ide> protected function _connect() {
<del> $return = false;
<ide> try {
<ide> $this->_Redis = new Redis();
<ide> if (!empty($this->settings['unix_socket'])) {
<ide> protected function _connect() {
<ide> $return = $this->_Redis->pconnect($this->settings['server'], $this->settings['port'], $this->settings['timeout'], $persistentId);
<ide> }
<ide> } catch (RedisException $e) {
<del> return false;
<add> $return = false;
<ide> }
<del> if ($return && $this->settings['password']) {
<del> $return = $this->_Redis->auth($this->settings['password']);
<add> if (!$return) {
<add> return false;
<ide> }
<del> if ($return) {
<del> $return = $this->_Redis->select($this->settings['database']);
<add> if ($this->settings['password'] && !$this->_Redis->auth($this->settings['password'])) {
<add> return false;
<ide> }
<del> return $return;
<add> return $this->_Redis->select($this->settings['database']);
<ide> }
<ide>
<ide> /** | 1 |
Python | Python | update regularizer tests | 00e9d5b21979002558f27d070720b822e7d7a6ce | <ide><path>tests/keras/test_regularizers.py
<ide> max_train_samples = 5000
<ide> max_test_samples = 1000
<ide>
<del># the data, shuffled and split between tran and test sets
<del>(X_train, y_train), (X_test, y_test) = mnist.load_data()
<del>X_train = X_train.reshape(60000, 784)[:max_train_samples]
<del>X_test = X_test.reshape(10000, 784)[:max_test_samples]
<del>X_train = X_train.astype("float32") / 255
<del>X_test = X_test.astype("float32") / 255
<ide>
<del># convert class vectors to binary class matrices
<del>y_train = y_train[:max_train_samples]
<del>y_test = y_test[:max_test_samples]
<del>Y_train = np_utils.to_categorical(y_train, nb_classes)
<del>Y_test = np_utils.to_categorical(y_test, nb_classes)
<del>test_ids = np.where(y_test == np.array(weighted_class))[0]
<add>def get_data():
<add> # the data, shuffled and split between tran and test sets
<add> (X_train, y_train), (X_test, y_test) = mnist.load_data()
<add> X_train = X_train.reshape(60000, 784)[:max_train_samples]
<add> X_test = X_test.reshape(10000, 784)[:max_test_samples]
<add> X_train = X_train.astype("float32") / 255
<add> X_test = X_test.astype("float32") / 255
<add>
<add> # convert class vectors to binary class matrices
<add> y_train = y_train[:max_train_samples]
<add> y_test = y_test[:max_test_samples]
<add> Y_train = np_utils.to_categorical(y_train, nb_classes)
<add> Y_test = np_utils.to_categorical(y_test, nb_classes)
<add> test_ids = np.where(y_test == np.array(weighted_class))[0]
<add>
<add> return (X_train, Y_train), (X_test, Y_test), test_ids
<ide>
<ide>
<ide> def create_model(weight_reg=None, activity_reg=None):
<ide> def create_model(weight_reg=None, activity_reg=None):
<ide>
<ide>
<ide> def test_W_reg():
<add> (X_train, Y_train), (X_test, Y_test), test_ids = get_data()
<ide> for reg in [regularizers.l1(),
<ide> regularizers.l2(),
<ide> regularizers.l1l2()]:
<ide> def test_W_reg():
<ide>
<ide>
<ide> def test_A_reg():
<add> (X_train, Y_train), (X_test, Y_test), test_ids = get_data()
<ide> for reg in [regularizers.activity_l1(), regularizers.activity_l2()]:
<ide> model = create_model(activity_reg=reg)
<ide> model.compile(loss='categorical_crossentropy', optimizer='rmsprop') | 1 |
PHP | PHP | remove tasks related to 2.x upgrades | ef0e816061a646003072741aad8f71d5e77d6eb6 | <ide><path>lib/Cake/Console/Command/UpgradeShell.php
<ide> <?php
<ide> /**
<del> * Upgrade Shell
<del> *
<del> * PHP 5
<del> *
<ide> * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
<ide> * Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
<ide> *
<ide> *
<ide> * @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
<ide> * @link http://cakephp.org CakePHP(tm) Project
<del> * @package Cake.Console.Command
<ide> * @since CakePHP(tm) v 2.0
<ide> * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
<ide> */
<ide> namespace Cake\Console\Command;
<add>
<ide> use Cake\Console\Shell;
<ide> use Cake\Core\App;
<ide> use Cake\Core\Plugin;
<ide> class UpgradeShell extends Shell {
<ide> */
<ide> protected $_paths = array();
<ide>
<del>/**
<del> * Map
<del> *
<del> * @var array
<del> */
<del> protected $_map = array(
<del> 'Controller' => 'Controller',
<del> 'Component' => 'Controller/Component',
<del> 'Model' => 'Model',
<del> 'Behavior' => 'Model/Behavior',
<del> 'Datasource' => 'Model/Datasource',
<del> 'Dbo' => 'Model/Datasource/Database',
<del> 'View' => 'View',
<del> 'Helper' => 'View/Helper',
<del> 'Shell' => 'Console/Command',
<del> 'Task' => 'Console/Command/Task',
<del> 'Case' => 'Test/Case',
<del> 'Fixture' => 'Test/Fixture',
<del> 'Error' => 'Lib/Error',
<del> );
<del>
<ide> /**
<ide> * Shell startup, prints info message about dry run.
<ide> *
<ide> public function all() {
<ide> }
<ide> }
<ide>
<del>/**
<del> * Update tests.
<del> *
<del> * - Update tests class names to FooTest rather than FooTestCase.
<del> *
<del> * @return void
<del> */
<del> public function tests() {
<del> $this->_paths = array(APP . 'tests' . DS);
<del> if (!empty($this->params['plugin'])) {
<del> $this->_paths = array(App::pluginPath($this->params['plugin']) . 'tests' . DS);
<del> }
<del> $patterns = array(
<del> array(
<del> '*TestCase extends \Cake\TestSuite\TestCase to *Test extends \Cake\TestSuite\TestCase',
<del> '/([a-zA-Z]*Test)Case extends \Cake\TestSuite\TestCase/',
<del> '\1 extends \Cake\TestSuite\TestCase'
<del> ),
<del> );
<del>
<del> $this->_filesRegexpUpdate($patterns);
<del> }
<del>
<del>/**
<del> * Move files and folders to their new homes
<del> *
<del> * Moves folders containing files which cannot necessarily be auto-detected (libs and templates)
<del> * and then looks for all php files except vendors, and moves them to where Cake 2.0 expects
<del> * to find them.
<del> *
<del> * @return void
<del> */
<del> public function locations() {
<del> $cwd = getcwd();
<del>
<del> if (!empty($this->params['plugin'])) {
<del> chdir(App::pluginPath($this->params['plugin']));
<del> }
<del>
<del> if (is_dir('plugins')) {
<del> $Folder = new Folder('plugins');
<del> list($plugins) = $Folder->read();
<del> foreach ($plugins as $plugin) {
<del> chdir($cwd . DS . 'plugins' . DS . $plugin);
<del> $this->out(__d('cake_console', 'Upgrading locations for plugin %s', $plugin));
<del> $this->locations();
<del> }
<del> $this->_files = array();
<del> chdir($cwd);
<del> $this->out(__d('cake_console', 'Upgrading locations for app directory'));
<del> }
<del> $moves = array(
<del> 'config' => 'Config',
<del> 'Config' . DS . 'schema' => 'Config' . DS . 'Schema',
<del> 'libs' => 'Lib',
<del> 'tests' => 'Test',
<del> 'views' => 'View',
<del> 'models' => 'Model',
<del> 'Model' . DS . 'behaviors' => 'Model' . DS . 'Behavior',
<del> 'Model' . DS . 'datasources' => 'Model' . DS . 'Datasource',
<del> 'Test' . DS . 'cases' => 'Test' . DS . 'Case',
<del> 'Test' . DS . 'fixtures' => 'Test' . DS . 'Fixture',
<del> 'vendors' . DS . 'shells' . DS . 'templates' => 'Console' . DS . 'Templates',
<del> );
<del> foreach ($moves as $old => $new) {
<del> if (is_dir($old)) {
<del> $this->out(__d('cake_console', 'Moving %s to %s', $old, $new));
<del> if (!$this->params['dry-run']) {
<del> if ($this->params['git']) {
<del> exec('git mv -f ' . escapeshellarg($old) . ' ' . escapeshellarg($old . '__'));
<del> exec('git mv -f ' . escapeshellarg($old . '__') . ' ' . escapeshellarg($new));
<del> } else {
<del> $Folder = new Folder($old);
<del> $Folder->move($new);
<del> }
<del> }
<del> }
<del> }
<del>
<del> $this->_moveViewFiles();
<del> $this->_moveAppClasses();
<del>
<del> $sourceDirs = array(
<del> '.' => array('recursive' => false),
<del> 'Console',
<del> 'controllers',
<del> 'Controller',
<del> 'Lib' => array('checkFolder' => false),
<del> 'models',
<del> 'Model',
<del> 'tests',
<del> 'Test' => array('regex' => '@class (\S*Test) extends \\Cake\\TestSuite\\TestCase@'),
<del> 'views',
<del> 'View',
<del> 'vendors/shells',
<del> );
<del>
<del> $defaultOptions = array(
<del> 'recursive' => true,
<del> 'checkFolder' => true,
<del> 'regex' => '@class (\S*) .*(\s|\v)*{@i'
<del> );
<del> foreach ($sourceDirs as $dir => $options) {
<del> if (is_numeric($dir)) {
<del> $dir = $options;
<del> $options = array();
<del> }
<del> $options = array_merge($defaultOptions, $options);
<del> $this->_movePhpFiles($dir, $options);
<del> }
<del> }
<del>
<del>/**
<del> * Update helpers.
<del> *
<del> * - Converts helpers usage to new format.
<del> *
<del> * @return void
<del> */
<del> public function helpers() {
<del> $this->_paths = array_diff(App::path('views'), App::core('views'));
<del>
<del> if (!empty($this->params['plugin'])) {
<del> $this->_paths = array(App::pluginPath($this->params['plugin']) . 'views' . DS);
<del> }
<del>
<del> $patterns = array();
<del> App::build(array(
<del> 'View/Helper' => App::core('View/Helper'),
<del> ), App::APPEND);
<del> $helpers = App::objects('helper');
<del> $plugins = App::objects('plugin');
<del> $pluginHelpers = array();
<del> foreach ($plugins as $plugin) {
<del> Plugin::load($plugin);
<del> $pluginHelpers = array_merge(
<del> $pluginHelpers,
<del> App::objects('helper', App::pluginPath($plugin) . DS . 'views' . DS . 'helpers' . DS, false)
<del> );
<del> }
<del> $helpers = array_merge($pluginHelpers, $helpers);
<del> foreach ($helpers as $helper) {
<del> $helper = preg_replace('/Helper$/', '', $helper);
<del> $oldHelper = $helper;
<del> $oldHelper{0} = strtolower($oldHelper{0});
<del> $patterns[] = array(
<del> "\${$oldHelper} to \$this->{$helper}",
<del> "/\\\${$oldHelper}->/",
<del> "\\\$this->{$helper}->"
<del> );
<del> }
<del>
<del> $this->_filesRegexpUpdate($patterns);
<del> }
<del>
<del>/**
<del> * Update i18n.
<del> *
<del> * - Removes extra true param.
<del> * - Add the echo to __*() calls that didn't need them before.
<del> *
<del> * @return void
<del> */
<del> public function i18n() {
<del> $this->_paths = array(
<del> APP
<del> );
<del> if (!empty($this->params['plugin'])) {
<del> $this->_paths = array(App::pluginPath($this->params['plugin']));
<del> }
<del>
<del> $patterns = array(
<del> array(
<del> '<?php __*(*) to <?php echo __*(*)',
<del> '/<\?php\s*(__[a-z]*\(.*?\))/',
<del> '<?php echo \1'
<del> ),
<del> array(
<del> '<?php __*(*, true) to <?php echo __*()',
<del> '/<\?php\s*(__[a-z]*\(.*?)(,\s*true)(\))/',
<del> '<?php echo \1\3'
<del> ),
<del> array('__*(*, true) to __*(*)', '/(__[a-z]*\(.*?)(,\s*true)(\))/', '\1\3')
<del> );
<del>
<del> $this->_filesRegexpUpdate($patterns);
<del> }
<del>
<del>/**
<del> * Upgrade the removed basics functions.
<del> *
<del> * - a(*) -> array(*)
<del> * - e(*) -> echo *
<del> * - ife(*, *, *) -> !empty(*) ? * : *
<del> * - a(*) -> array(*)
<del> * - r(*, *, *) -> str_replace(*, *, *)
<del> * - up(*) -> strtoupper(*)
<del> * - low(*, *, *) -> strtolower(*)
<del> * - getMicrotime() -> microtime(true)
<del> *
<del> * @return void
<del> */
<del> public function basics() {
<del> $this->_paths = array(
<del> APP
<del> );
<del> if (!empty($this->params['plugin'])) {
<del> $this->_paths = array(App::pluginPath($this->params['plugin']));
<del> }
<del> $patterns = array(
<del> array(
<del> 'a(*) -> array(*)',
<del> '/\ba\((.*)\)/',
<del> 'array(\1)'
<del> ),
<del> array(
<del> 'e(*) -> echo *',
<del> '/\be\((.*)\)/',
<del> 'echo \1'
<del> ),
<del> array(
<del> 'ife(*, *, *) -> !empty(*) ? * : *',
<del> '/ife\((.*), (.*), (.*)\)/',
<del> '!empty(\1) ? \2 : \3'
<del> ),
<del> array(
<del> 'r(*, *, *) -> str_replace(*, *, *)',
<del> '/\br\(/',
<del> 'str_replace('
<del> ),
<del> array(
<del> 'up(*) -> strtoupper(*)',
<del> '/\bup\(/',
<del> 'strtoupper('
<del> ),
<del> array(
<del> 'low(*) -> strtolower(*)',
<del> '/\blow\(/',
<del> 'strtolower('
<del> ),
<del> array(
<del> 'getMicrotime() -> microtime(true)',
<del> '/getMicrotime\(\)/',
<del> 'microtime(true)'
<del> ),
<del> );
<del> $this->_filesRegexpUpdate($patterns);
<del> }
<del>
<del>/**
<del> * Update the properties moved to \Cake\Network\Request.
<del> *
<del> * @return void
<del> */
<del> public function request() {
<del> $views = array_diff(App::path('views'), App::core('views'));
<del> $controllers = array_diff(App::path('controllers'), App::core('controllers'), array(APP));
<del> $components = array_diff(App::path('components'), App::core('components'));
<del>
<del> $this->_paths = array_merge($views, $controllers, $components);
<del>
<del> if (!empty($this->params['plugin'])) {
<del> $pluginPath = App::pluginPath($this->params['plugin']);
<del> $this->_paths = array(
<del> $pluginPath . 'controllers' . DS,
<del> $pluginPath . 'controllers' . DS . 'components' . DS,
<del> $pluginPath . 'views' . DS,
<del> );
<del> }
<del> $patterns = array(
<del> array(
<del> '$this->data -> $this->request->data',
<del> '/(\$this->data\b(?!\())/',
<del> '$this->request->data'
<del> ),
<del> array(
<del> '$this->params -> $this->request->params',
<del> '/(\$this->params\b(?!\())/',
<del> '$this->request->params'
<del> ),
<del> array(
<del> '$this->webroot -> $this->request->webroot',
<del> '/(\$this->webroot\b(?!\())/',
<del> '$this->request->webroot'
<del> ),
<del> array(
<del> '$this->base -> $this->request->base',
<del> '/(\$this->base\b(?!\())/',
<del> '$this->request->base'
<del> ),
<del> array(
<del> '$this->here -> $this->request->here',
<del> '/(\$this->here\b(?!\())/',
<del> '$this->request->here'
<del> ),
<del> array(
<del> '$this->action -> $this->request->action',
<del> '/(\$this->action\b(?!\())/',
<del> '$this->request->action'
<del> ),
<del> );
<del> $this->_filesRegexpUpdate($patterns);
<del> }
<del>
<del>/**
<del> * Update Configure::read() calls with no params.
<del> *
<del> * @return void
<del> */
<del> public function configure() {
<del> $this->_paths = array(
<del> APP
<del> );
<del> if (!empty($this->params['plugin'])) {
<del> $this->_paths = array(App::pluginPath($this->params['plugin']));
<del> }
<del> $patterns = array(
<del> array(
<del> "Configure::read() -> Configure::read('debug')",
<del> '/Configure::read\(\)/',
<del> 'Configure::read(\'debug\')'
<del> ),
<del> );
<del> $this->_filesRegexpUpdate($patterns);
<del> }
<del>
<del>/**
<del> * constants
<del> *
<del> * @return void
<del> */
<del> public function constants() {
<del> $this->_paths = array(
<del> APP
<del> );
<del> if (!empty($this->params['plugin'])) {
<del> $this->_paths = array(App::pluginPath($this->params['plugin']));
<del> }
<del> $patterns = array(
<del> array(
<del> "LIBS -> CAKE",
<del> '/\bLIBS\b/',
<del> 'CAKE'
<del> ),
<del> array(
<del> "CONFIGS -> APP . 'Config' . DS",
<del> '/\bCONFIGS\b/',
<del> 'APP . \'Config\' . DS'
<del> ),
<del> array(
<del> "CONTROLLERS -> APP . 'Controller' . DS",
<del> '/\bCONTROLLERS\b/',
<del> 'APP . \'Controller\' . DS'
<del> ),
<del> array(
<del> "COMPONENTS -> APP . 'Controller' . DS . 'Component' . DS",
<del> '/\bCOMPONENTS\b/',
<del> 'APP . \'Controller\' . DS . \'Component\''
<del> ),
<del> array(
<del> "MODELS -> APP . 'Model' . DS",
<del> '/\bMODELS\b/',
<del> 'APP . \'Model\' . DS'
<del> ),
<del> array(
<del> "BEHAVIORS -> APP . 'Model' . DS . 'Behavior' . DS",
<del> '/\bBEHAVIORS\b/',
<del> 'APP . \'Model\' . DS . \'Behavior\' . DS'
<del> ),
<del> array(
<del> "VIEWS -> APP . 'View' . DS",
<del> '/\bVIEWS\b/',
<del> 'APP . \'View\' . DS'
<del> ),
<del> array(
<del> "HELPERS -> APP . 'View' . DS . 'Helper' . DS",
<del> '/\bHELPERS\b/',
<del> 'APP . \'View\' . DS . \'Helper\' . DS'
<del> ),
<del> array(
<del> "LAYOUTS -> APP . 'View' . DS . 'Layouts' . DS",
<del> '/\bLAYOUTS\b/',
<del> 'APP . \'View\' . DS . \'Layouts\' . DS'
<del> ),
<del> array(
<del> "ELEMENTS -> APP . 'View' . DS . 'Elements' . DS",
<del> '/\bELEMENTS\b/',
<del> 'APP . \'View\' . DS . \'Elements\' . DS'
<del> ),
<del> array(
<del> "CONSOLE_LIBS -> CAKE . 'Console' . DS",
<del> '/\bCONSOLE_LIBS\b/',
<del> 'CAKE . \'Console\' . DS'
<del> ),
<del> array(
<del> "CAKE_TESTS_LIB -> CAKE . 'TestSuite' . DS",
<del> '/\bCAKE_TESTS_LIB\b/',
<del> 'CAKE . \'TestSuite\' . DS'
<del> ),
<del> array(
<del> "CAKE_TESTS -> CAKE . 'Test' . DS",
<del> '/\bCAKE_TESTS\b/',
<del> 'CAKE . \'Test\' . DS'
<del> )
<del> );
<del> $this->_filesRegexpUpdate($patterns);
<del> }
<del>
<del>/**
<del> * Update components.
<del> *
<del> * - Make components that extend Object to extend Component.
<del> *
<del> * @return void
<del> */
<del> public function components() {
<del> $this->_paths = App::Path('Controller/Component');
<del> if (!empty($this->params['plugin'])) {
<del> $this->_paths = App::Path('Controller/Component', $this->params['plugin']);
<del> }
<del> $patterns = array(
<del> array(
<del> '*Component extends Object to *Component extends Component',
<del> '/([a-zA-Z]*Component extends) Object/',
<del> '\1 Component'
<del> ),
<del> );
<del>
<del> $this->_filesRegexpUpdate($patterns);
<del> }
<del>
<del>/**
<del> * Replace cakeError with built-in exceptions.
<del> * NOTE: this ignores calls where you've passed your own secondary parameters to cakeError().
<del> * @return void
<del> */
<del> public function exceptions() {
<del> $controllers = array_diff(App::path('controllers'), App::core('controllers'), array(APP));
<del> $components = array_diff(App::path('components'), App::core('components'));
<del>
<del> $this->_paths = array_merge($controllers, $components);
<del>
<del> if (!empty($this->params['plugin'])) {
<del> $pluginPath = App::pluginPath($this->params['plugin']);
<del> $this->_paths = array(
<del> $pluginPath . 'controllers' . DS,
<del> $pluginPath . 'controllers' . DS . 'components' . DS,
<del> );
<del> }
<del> $patterns = array(
<del> array(
<del> '$this->cakeError("error400") -> throw new BadRequestException()',
<del> '/(\$this->cakeError\(["\']error400["\']\));/',
<del> 'throw new BadRequestException();'
<del> ),
<del> array(
<del> '$this->cakeError("error404") -> throw new NotFoundException()',
<del> '/(\$this->cakeError\(["\']error404["\']\));/',
<del> 'throw new NotFoundException();'
<del> ),
<del> array(
<del> '$this->cakeError("error500") -> throw new InternalErrorException()',
<del> '/(\$this->cakeError\(["\']error500["\']\));/',
<del> 'throw new InternalErrorException();'
<del> ),
<del> );
<del> $this->_filesRegexpUpdate($patterns);
<del> }
<del>
<del>/**
<del> * Move application views files to where they now should be
<del> *
<del> * Find all view files in the folder and determine where cake expects the file to be
<del> *
<del> * @return void
<del> */
<del> protected function _moveViewFiles() {
<del> if (!is_dir('View')) {
<del> return;
<del> }
<del>
<del> $dirs = scandir('View');
<del> foreach ($dirs as $old) {
<del> if (!is_dir('View' . DS . $old) || $old === '.' || $old === '..') {
<del> continue;
<del> }
<del>
<del> $new = 'View' . DS . Inflector::camelize($old);
<del> $old = 'View' . DS . $old;
<del> if ($new == $old) {
<del> continue;
<del> }
<del>
<del> $this->out(__d('cake_console', 'Moving %s to %s', $old, $new));
<del> if (!$this->params['dry-run']) {
<del> if ($this->params['git']) {
<del> exec('git mv -f ' . escapeshellarg($old) . ' ' . escapeshellarg($old . '__'));
<del> exec('git mv -f ' . escapeshellarg($old . '__') . ' ' . escapeshellarg($new));
<del> } else {
<del> $Folder = new Folder($old);
<del> $Folder->move($new);
<del> }
<del> }
<del> }
<del> }
<del>
<del>/**
<del> * Move the AppController, and AppModel classes.
<del> *
<del> * @return void
<del> */
<del> protected function _moveAppClasses() {
<del> $files = array(
<del> APP . 'app_controller.php' => APP . 'Controller' . DS . 'AppController.php',
<del> APP . 'controllers' . DS . 'app_controller.php' => APP . 'Controller' . DS . 'AppController.php',
<del> APP . 'app_model.php' => APP . 'Model' . DS . 'AppModel.php',
<del> APP . 'models' . DS . 'app_model.php' => APP . 'Model' . DS . 'AppModel.php',
<del> );
<del> foreach ($files as $old => $new) {
<del> if (file_exists($old)) {
<del> $this->out(__d('cake_console', 'Moving %s to %s', $old, $new));
<del>
<del> if ($this->params['dry-run']) {
<del> continue;
<del> }
<del> if ($this->params['git']) {
<del> exec('git mv -f ' . escapeshellarg($old) . ' ' . escapeshellarg($old . '__'));
<del> exec('git mv -f ' . escapeshellarg($old . '__') . ' ' . escapeshellarg($new));
<del> } else {
<del> rename($old, $new);
<del> }
<del> }
<del> }
<del> }
<del>
<del>/**
<del> * Move application php files to where they now should be
<del> *
<del> * Find all php files in the folder (honoring recursive) and determine where cake expects the file to be
<del> * If the file is not exactly where cake expects it - move it.
<del> *
<del> * @param string $path
<del> * @param array $options array(recursive, checkFolder)
<del> * @return void
<del> */
<del> protected function _movePhpFiles($path, $options) {
<del> if (!is_dir($path)) {
<del> return;
<del> }
<del>
<del> $paths = $this->_paths;
<del>
<del> $this->_paths = array($path);
<del> $this->_files = array();
<del> if ($options['recursive']) {
<del> $this->_findFiles('php');
<del> } else {
<del> $this->_files = scandir($path);
<del> foreach ($this->_files as $i => $file) {
<del> if (strlen($file) < 5 || substr($file, -4) !== '.php') {
<del> unset($this->_files[$i]);
<del> }
<del> }
<del> }
<del>
<del> $cwd = getcwd();
<del> foreach ($this->_files as &$file) {
<del> $file = $cwd . DS . $file;
<del>
<del> $contents = file_get_contents($file);
<del> preg_match($options['regex'], $contents, $match);
<del> if (!$match) {
<del> continue;
<del> }
<del>
<del> $class = $match[1];
<del>
<del> if (substr($class, 0, 3) === 'Dbo') {
<del> $type = 'Dbo';
<del> } else {
<del> preg_match('@([A-Z][^A-Z]*)$@', $class, $match);
<del> if ($match) {
<del> $type = $match[1];
<del> } else {
<del> $type = 'unknown';
<del> }
<del> }
<del>
<del> preg_match('@^.*[\\\/]plugins[\\\/](.*?)[\\\/]@', $file, $match);
<del> $base = $cwd . DS;
<del> $plugin = false;
<del> if ($match) {
<del> $base = $match[0];
<del> $plugin = $match[1];
<del> }
<del>
<del> if ($options['checkFolder'] && !empty($this->_map[$type])) {
<del> $folder = str_replace('/', DS, $this->_map[$type]);
<del> $new = $base . $folder . DS . $class . '.php';
<del> } else {
<del> $new = dirname($file) . DS . $class . '.php';
<del> }
<del>
<del> if ($file === $new) {
<del> continue;
<del> }
<del>
<del> $dir = dirname($new);
<del> if (!is_dir($dir)) {
<del> new Folder($dir, true);
<del> }
<del>
<del> $this->out(__d('cake_console', 'Moving %s to %s', $file, $new), 1, Shell::VERBOSE);
<del> if (!$this->params['dry-run']) {
<del> if ($this->params['git']) {
<del> exec('git mv -f ' . escapeshellarg($file) . ' ' . escapeshellarg($file . '__'));
<del> exec('git mv -f ' . escapeshellarg($file . '__') . ' ' . escapeshellarg($new));
<del> } else {
<del> rename($file, $new);
<del> }
<del> }
<del> }
<del>
<del> $this->_paths = $paths;
<del> }
<del>
<ide> /**
<ide> * Updates files based on regular expressions.
<ide> *
<ide> public function getOptionParser() {
<ide> 'help' => __d('cake_console', 'The extension(s) to search. A pipe delimited list, or a preg_match compatible subpattern'),
<ide> 'default' => 'php|ctp|thtml|inc|tpl'
<ide> ),
<del> 'git' => array(
<del> 'short' => 'g',
<del> 'help' => __d('cake_console', 'Use git command for moving files around.'),
<del> 'boolean' => true
<del> ),
<ide> 'dry-run' => array(
<ide> 'short' => 'd',
<ide> 'help' => __d('cake_console', 'Dry run the update, no files will actually be modified.'),
<ide> public function getOptionParser() {
<ide> 'help' => __d('cake_console', 'Run all upgrade commands.'),
<ide> 'parser' => $subcommandParser
<ide> ))
<del> ->addSubcommand('tests', array(
<del> 'help' => __d('cake_console', 'Update tests class names to FooTest rather than FooTestCase.'),
<del> 'parser' => $subcommandParser
<del> ))
<del> ->addSubcommand('locations', array(
<del> 'help' => __d('cake_console', 'Move files and folders to their new homes.'),
<del> 'parser' => $subcommandParser
<del> ))
<del> ->addSubcommand('i18n', array(
<del> 'help' => __d('cake_console', 'Update the i18n translation method calls.'),
<del> 'parser' => $subcommandParser
<del> ))
<del> ->addSubcommand('helpers', array(
<del> 'help' => __d('cake_console', 'Update calls to helpers.'),
<del> 'parser' => $subcommandParser
<del> ))
<del> ->addSubcommand('basics', array(
<del> 'help' => __d('cake_console', 'Update removed basics functions to PHP native functions.'),
<del> 'parser' => $subcommandParser
<del> ))
<del> ->addSubcommand('request', array(
<del> 'help' => __d('cake_console', 'Update removed request access, and replace with $this->request.'),
<del> 'parser' => $subcommandParser
<del> ))
<del> ->addSubcommand('configure', array(
<del> 'help' => __d('cake_console', "Update Configure::read() to Configure::read('debug')"),
<add> ->addSubcommand('app_uses', array(
<add> 'help' => __d('cake_console', 'Replace App::uses() with use statements'),
<ide> 'parser' => $subcommandParser
<ide> ))
<del> ->addSubcommand('constants', array(
<del> 'help' => __d('cake_console', "Replace Obsolete constants"),
<add> ->addSubcommand('namespaces', array(
<add> 'help' => __d('cake_console', 'Add namespaces to files based on their file path.'),
<ide> 'parser' => $subcommandParser
<ide> ))
<del> ->addSubcommand('components', array(
<del> 'help' => __d('cake_console', 'Update components to extend Component class.'),
<add> ->addSubcommand('cache', array(
<add> 'help' => __d('cake_console', "Replace Cache::config() with Configure."),
<ide> 'parser' => $subcommandParser
<ide> ))
<del> ->addSubcommand('exceptions', array(
<del> 'help' => __d('cake_console', 'Replace use of cakeError with exceptions.'),
<add> ->addSubcommand('log', array(
<add> 'help' => __d('cake_console', "Replace CakeLog::config() with Configure."),
<ide> 'parser' => $subcommandParser
<ide> ));
<ide> } | 1 |
Text | Text | update changelog for 1.5.0-beta.4 | dbbc9aa0fe9d22efaae1f1574bc465d2ea10e4c4 | <ide><path>CHANGELOG.md
<ide> # Ember Changelog
<ide>
<add>### Ember 1.5.0-beta.4 (March 10, 2014)
<add>
<add>* Allow Ember Inspector to access models with custom resolver.
<add>* [BUGFIX] Allow components with layoutName specified by parent class to specify templateName.
<add>* [BUGFIX] Don't raise error when a destroyed array is assigned to ArrayProxy.
<add>* [BUGFIX] Use better ajax events for ember-testing counters.
<add>* [BUGFIX] Move AJAX listeners into Ember.setupForTesting.
<add>
<ide> ### Ember 1.5.0-beta.3 (March 1, 2014)
<ide>
<ide> * [BUGFIX] PromiseProxyMixin reset isFulfilled and isRejected. | 1 |
Javascript | Javascript | replace harmonyinit calls by initfragments | dcebd57aa447128b0d520bdb4aafd38d898ed2f5 | <ide><path>lib/ConstPlugin.js
<ide>
<ide> const { evaluateToString } = require("./JavascriptParserHelpers");
<ide> const NullFactory = require("./NullFactory");
<add>const CachedConstDependency = require("./dependencies/CachedConstDependency");
<ide> const ConstDependency = require("./dependencies/ConstDependency");
<ide>
<ide> const getQuery = request => {
<ide> class ConstPlugin {
<ide> new ConstDependency.Template()
<ide> );
<ide>
<add> compilation.dependencyFactories.set(
<add> CachedConstDependency,
<add> new NullFactory()
<add> );
<add> compilation.dependencyTemplates.set(
<add> CachedConstDependency,
<add> new CachedConstDependency.Template()
<add> );
<add>
<ide> const handler = parser => {
<ide> parser.hooks.statementIf.tap("ConstPlugin", statement => {
<ide> const param = parser.evaluateExpression(statement.test);
<ide> class ConstPlugin {
<ide> });
<ide> parser.hooks.expression
<ide> .for("__resourceQuery")
<del> .tap("ConstPlugin", () => {
<add> .tap("ConstPlugin", expr => {
<ide> if (!parser.state.module) return;
<del> parser.state.current.addVariable(
<del> "__resourceQuery",
<del> JSON.stringify(getQuery(parser.state.module.resource))
<add> const dep = new CachedConstDependency(
<add> JSON.stringify(getQuery(parser.state.module.resource)),
<add> expr.range,
<add> "__resourceQuery"
<ide> );
<add> dep.loc = expr.loc;
<add> parser.state.current.addDependency(dep);
<ide> return true;
<ide> });
<ide> };
<ide><path>lib/InitFragment.js
<add>/*
<add> MIT License http://www.opensource.org/licenses/mit-license.php
<add> Author Florent Cailhol @ooflorent
<add>*/
<add>
<add>"use strict";
<add>
<add>/** @typedef {import("webpack-sources").Source} Source */
<add>
<add>class InitFragment {
<add> /**
<add> * @param {string|Source} content [TODO]
<add> * @param {number} order [TODO]
<add> * @param {string=} key [TODO]
<add> */
<add> constructor(content, order, key) {
<add> this.content = content;
<add> this.order = order;
<add> this.key = key;
<add> }
<add>}
<add>
<add>module.exports = InitFragment;
<ide><path>lib/JavascriptGenerator.js
<ide>
<ide> "use strict";
<ide>
<del>const { RawSource, ReplaceSource } = require("webpack-sources");
<add>const { ConcatSource, RawSource, ReplaceSource } = require("webpack-sources");
<ide>
<ide> // TODO: clean up this file
<ide> // replace with newer constructs
<ide>
<ide> // TODO: remove DependencyVariables and replace them with something better
<ide>
<add>const extractFragmentIndex = (fragment, index) => [fragment, index];
<add>
<add>const sortByFragmentIndex = ([a, i], [b, j]) => {
<add> const x = a.order - b.order;
<add> return x !== 0 ? x : i - j;
<add>};
<add>
<ide> class JavascriptGenerator {
<ide> generate(module, dependencyTemplates, runtimeTemplate) {
<ide> const originalSource = module.originalSource();
<ide> class JavascriptGenerator {
<ide> }
<ide>
<ide> const source = new ReplaceSource(originalSource);
<add> const dependencyFragments = [];
<ide>
<ide> this.sourceBlock(
<ide> module,
<ide> module,
<ide> [],
<ide> dependencyTemplates,
<add> dependencyFragments,
<ide> source,
<ide> runtimeTemplate
<ide> );
<ide>
<del> return source;
<add> if (dependencyFragments.length > 0) {
<add> const sortedFragments = dependencyFragments
<add> .map(extractFragmentIndex)
<add> .sort(sortByFragmentIndex);
<add>
<add> const concatSource = new ConcatSource();
<add> for (const [fragment] of sortedFragments) {
<add> concatSource.add(fragment.content);
<add> }
<add>
<add> concatSource.add(source);
<add> return concatSource;
<add> } else {
<add> return source;
<add> }
<ide> }
<ide>
<ide> sourceBlock(
<ide> module,
<ide> block,
<ide> availableVars,
<ide> dependencyTemplates,
<add> dependencyFragments,
<ide> source,
<ide> runtimeTemplate
<ide> ) {
<ide> for (const dependency of block.dependencies) {
<ide> this.sourceDependency(
<ide> dependency,
<ide> dependencyTemplates,
<add> dependencyFragments,
<ide> source,
<ide> runtimeTemplate
<ide> );
<ide> class JavascriptGenerator {
<ide> childBlock,
<ide> availableVars.concat(vars),
<ide> dependencyTemplates,
<add> dependencyFragments,
<ide> source,
<ide> runtimeTemplate
<ide> );
<ide> }
<ide> }
<ide>
<del> sourceDependency(dependency, dependencyTemplates, source, runtimeTemplate) {
<add> sourceDependency(
<add> dependency,
<add> dependencyTemplates,
<add> dependencyFragments,
<add> source,
<add> runtimeTemplate
<add> ) {
<ide> const template = dependencyTemplates.get(dependency.constructor);
<ide> if (!template) {
<ide> throw new Error(
<ide> "No template for dependency: " + dependency.constructor.name
<ide> );
<ide> }
<add>
<ide> template.apply(dependency, source, runtimeTemplate, dependencyTemplates);
<add>
<add> if (typeof template.getInitFragments === "function") {
<add> const fragments = template.getInitFragments(
<add> dependency,
<add> source, // TODO remove this argument
<add> runtimeTemplate,
<add> dependencyTemplates
<add> );
<add> for (const fragment of fragments) {
<add> dependencyFragments.push(fragment);
<add> }
<add> }
<ide> }
<ide>
<ide> sourceVariables(
<ide><path>lib/JavascriptParserHelpers.js
<ide> const ConstDependency = require("./dependencies/ConstDependency");
<ide>
<ide> exports.addParsedVariableToModule = (parser, name, expression) => {
<ide> if (!parser.state.current.addVariable) return false;
<del> var deps = [];
<add> const deps = [];
<ide> parser.parse(expression, {
<ide> current: {
<ide> addDependency: dep => {
<ide> exports.addParsedVariableToModule = (parser, name, expression) => {
<ide> };
<ide>
<ide> exports.requireFileAsExpression = (context, pathToModule) => {
<del> var moduleJsPath = path.relative(context, pathToModule);
<add> let moduleJsPath = path.relative(context, pathToModule);
<ide> if (!/^[A-Z]:/i.test(moduleJsPath)) {
<ide> moduleJsPath = "./" + moduleJsPath.replace(/\\/g, "/");
<ide> }
<ide> exports.requireFileAsExpression = (context, pathToModule) => {
<ide>
<ide> exports.toConstantDependency = (parser, value) => {
<ide> return function constDependency(expr) {
<del> var dep = new ConstDependency(value, expr.range, false);
<add> const dep = new ConstDependency(value, expr.range, false);
<ide> dep.loc = expr.loc;
<ide> parser.state.current.addDependency(dep);
<ide> return true;
<ide> exports.toConstantDependency = (parser, value) => {
<ide>
<ide> exports.toConstantDependencyWithWebpackRequire = (parser, value) => {
<ide> return function constDependencyWithWebpackRequire(expr) {
<del> var dep = new ConstDependency(value, expr.range, true);
<add> const dep = new ConstDependency(value, expr.range, true);
<ide> dep.loc = expr.loc;
<ide> parser.state.current.addDependency(dep);
<ide> return true;
<ide> exports.evaluateToIdentifier = (identifier, truthy) => {
<ide>
<ide> exports.expressionIsUnsupported = (parser, message) => {
<ide> return function unsupportedExpression(expr) {
<del> var dep = new ConstDependency("(void 0)", expr.range, false);
<add> const dep = new ConstDependency("(void 0)", expr.range, false);
<ide> dep.loc = expr.loc;
<ide> parser.state.current.addDependency(dep);
<ide> if (!parser.state.module) return;
<ide><path>lib/NodeStuffPlugin.js
<ide> const {
<ide> toConstantDependency,
<ide> toConstantDependencyWithWebpackRequire
<ide> } = require("./JavascriptParserHelpers");
<del>const NullFactory = require("./NullFactory");
<del>const ConstDependency = require("./dependencies/ConstDependency");
<add>const CachedConstDependency = require("./dependencies/CachedConstDependency");
<ide>
<ide> class NodeStuffPlugin {
<ide> constructor(options) {
<ide> class NodeStuffPlugin {
<ide> compiler.hooks.compilation.tap(
<ide> "NodeStuffPlugin",
<ide> (compilation, { normalModuleFactory }) => {
<del> compilation.dependencyFactories.set(ConstDependency, new NullFactory());
<del> compilation.dependencyTemplates.set(
<del> ConstDependency,
<del> new ConstDependency.Template()
<del> );
<del>
<ide> const handler = (parser, parserOptions) => {
<ide> if (parserOptions.node === false) return;
<ide>
<ide> class NodeStuffPlugin {
<ide> localOptions = Object.assign({}, localOptions, parserOptions.node);
<ide> }
<ide>
<del> const setConstant = (expressionName, value) => {
<del> parser.hooks.expression
<del> .for(expressionName)
<del> .tap("NodeStuffPlugin", () => {
<del> parser.state.current.addVariable(
<del> expressionName,
<del> JSON.stringify(value)
<del> );
<del> return true;
<del> });
<del> };
<del>
<ide> const setModuleConstant = (expressionName, fn) => {
<ide> parser.hooks.expression
<ide> .for(expressionName)
<del> .tap("NodeStuffPlugin", () => {
<del> parser.state.current.addVariable(
<del> expressionName,
<del> JSON.stringify(fn(parser.state.module))
<add> .tap("NodeStuffPlugin", expr => {
<add> const dep = new CachedConstDependency(
<add> JSON.stringify(fn(parser.state.module)),
<add> expr.range,
<add> expressionName
<ide> );
<add> dep.loc = expr.loc;
<add> parser.state.current.addDependency(dep);
<ide> return true;
<ide> });
<ide> };
<add>
<add> const setConstant = (expressionName, value) =>
<add> setModuleConstant(expressionName, () => value);
<add>
<ide> const context = compiler.context;
<ide> if (localOptions.__filename === "mock") {
<ide> setConstant("__filename", "/index.js");
<ide><path>lib/dependencies/AMDPlugin.js
<ide> class AMDPlugin {
<ide>
<ide> parser.hooks.expression
<ide> .for("__webpack_amd_options__")
<del> .tap("AMDPlugin", () =>
<del> parser.state.current.addVariable(
<del> "__webpack_amd_options__",
<del> JSON.stringify(amdOptions)
<del> )
<add> .tap(
<add> "AMDPlugin",
<add> toConstantDependency(parser, JSON.stringify(amdOptions))
<ide> );
<ide> parser.hooks.evaluateTypeof
<ide> .for("define.amd")
<ide><path>lib/dependencies/CachedConstDependency.js
<add>/*
<add> MIT License http://www.opensource.org/licenses/mit-license.php
<add> Author Florent Cailhol @ooflorent
<add>*/
<add>
<add>"use strict";
<add>
<add>const InitFragment = require("../InitFragment");
<add>const NullDependency = require("./NullDependency");
<add>
<add>class CachedConstDependency extends NullDependency {
<add> constructor(expression, range, identifier) {
<add> super();
<add> this.expression = expression;
<add> this.range = range;
<add> this.identifier = identifier;
<add> }
<add>
<add> updateHash(hash) {
<add> hash.update(this.identifier + "");
<add> hash.update(this.range + "");
<add> hash.update(this.expression + "");
<add> }
<add>}
<add>
<add>CachedConstDependency.Template = class CachedConstDependencyTemplate {
<add> apply(dep, source) {
<add> if (typeof dep.range === "number") {
<add> source.insert(dep.range, dep.identifier);
<add> return;
<add> }
<add>
<add> source.replace(dep.range[0], dep.range[1] - 1, dep.identifier);
<add> }
<add>
<add> getInitFragments(dep, source, runtime) {
<add> return [
<add> new InitFragment(
<add> `var ${dep.identifier} = ${dep.expression};\n`,
<add> 1,
<add> `const ${dep.identifier}`
<add> )
<add> ];
<add> }
<add>};
<add>
<add>module.exports = CachedConstDependency;
<ide><path>lib/dependencies/HarmonyDetectionParserPlugin.js
<ide> "use strict";
<ide>
<ide> const HarmonyCompatibilityDependency = require("./HarmonyCompatibilityDependency");
<del>const HarmonyInitDependency = require("./HarmonyInitDependency");
<ide>
<ide> module.exports = class HarmonyDetectionParserPlugin {
<ide> apply(parser) {
<ide> module.exports = class HarmonyDetectionParserPlugin {
<ide> index: -3
<ide> };
<ide> module.addDependency(compatDep);
<del> const initDep = new HarmonyInitDependency(module);
<del> initDep.loc = {
<del> start: {
<del> line: -1,
<del> column: 0
<del> },
<del> end: {
<del> line: -1,
<del> column: 0
<del> },
<del> index: -2
<del> };
<del> module.addDependency(initDep);
<ide> parser.state.harmonyParserScope = parser.state.harmonyParserScope || {};
<ide> parser.scope.isStrict = true;
<ide> module.buildMeta.exportsType = "namespace";
<ide><path>lib/dependencies/HarmonyExportImportedSpecifierDependency.js
<ide> "use strict";
<ide>
<ide> const HarmonyLinkingError = require("../HarmonyLinkingError");
<add>const InitFragment = require("../InitFragment");
<ide> const Template = require("../Template");
<ide> const DependencyReference = require("./DependencyReference");
<ide> const HarmonyImportDependency = require("./HarmonyImportDependency");
<ide> class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
<ide> module.exports = HarmonyExportImportedSpecifierDependency;
<ide>
<ide> HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedSpecifierDependencyTemplate extends HarmonyImportDependency.Template {
<del> harmonyInit(dep, source, runtime, dependencyTemplates) {
<del> super.harmonyInit(dep, source, runtime, dependencyTemplates);
<del> const content = this.getContent(dep);
<del> source.insert(-1, content);
<add> getInitFragments(dependency, source, runtimeTemplate, dependencyTemplates) {
<add> if (this.isUsed(dependency)) {
<add> return super
<add> .getInitFragments(
<add> dependency,
<add> source,
<add> runtimeTemplate,
<add> dependencyTemplates
<add> )
<add> .concat(
<add> new InitFragment(this.getContent(dependency), dependency.sourceOrder)
<add> );
<add> } else {
<add> return [];
<add> }
<ide> }
<ide>
<del> getHarmonyInitOrder(dep) {
<add> isUsed(dep) {
<ide> if (dep.name) {
<del> const used = dep.originModule.isUsed(dep.name);
<del> if (!used) return NaN;
<add> return dep.originModule.isUsed(dep.name);
<ide> } else {
<ide> const importedModule = dep._module;
<del>
<ide> const activeFromOtherStarExports = dep._discoverActiveExportsFromOtherStartExports();
<ide>
<ide> if (Array.isArray(dep.originModule.usedExports)) {
<ide> // we know which exports are used
<del>
<ide> const unused = dep.originModule.usedExports.every(id => {
<ide> if (id === "default") return true;
<ide> if (dep.activeExports.has(id)) return true;
<ide> if (importedModule.isProvided(id) === false) return true;
<ide> if (activeFromOtherStarExports.has(id)) return true;
<ide> return false;
<ide> });
<del> if (unused) return NaN;
<add> return !unused;
<ide> } else if (
<ide> dep.originModule.usedExports &&
<ide> importedModule &&
<ide> Array.isArray(importedModule.buildMeta.providedExports)
<ide> ) {
<ide> // not sure which exports are used, but we know which are provided
<del>
<ide> const unused = importedModule.buildMeta.providedExports.every(id => {
<ide> if (id === "default") return true;
<ide> if (dep.activeExports.has(id)) return true;
<ide> if (activeFromOtherStarExports.has(id)) return true;
<ide> return false;
<ide> });
<del> if (unused) return NaN;
<add> return !unused;
<ide> }
<add> return true;
<ide> }
<del> return super.getHarmonyInitOrder(dep);
<ide> }
<ide>
<ide> getContent(dep) {
<ide><path>lib/dependencies/HarmonyExportSpecifierDependency.js
<ide>
<ide> "use strict";
<ide>
<add>const InitFragment = require("../InitFragment");
<ide> const NullDependency = require("./NullDependency");
<ide>
<ide> /** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
<ide> HarmonyExportSpecifierDependency.Template = class HarmonyExportSpecifierDependen
<ide> // no-op
<ide> }
<ide>
<del> getHarmonyInitOrder(dep) {
<del> return 0;
<del> }
<del>
<del> harmonyInit(dep, source, runtime) {
<del> const content = this.getContent(dep);
<del> source.insert(-1, content);
<add> getInitFragments(dependency, source, runtimeTemplate, dependencyTemplates) {
<add> return [new InitFragment(this.getContent(dependency), 0)];
<ide> }
<ide>
<ide> getContent(dep) {
<ide><path>lib/dependencies/HarmonyImportDependency.js
<ide>
<ide> "use strict";
<ide>
<add>const InitFragment = require("../InitFragment");
<ide> const Template = require("../Template");
<ide> const DependencyReference = require("./DependencyReference");
<ide> const ModuleDependency = require("./ModuleDependency");
<ide> HarmonyImportDependency.Template = class HarmonyImportDependencyTemplate extends
<ide> // no-op
<ide> }
<ide>
<del> getHarmonyInitOrder(dep) {
<del> return dep.sourceOrder;
<del> }
<del>
<ide> static isImportEmitted(dep, source) {
<ide> let sourceInfo = importEmittedMap.get(source);
<ide> if (!sourceInfo) return false;
<ide> const key = dep._module || dep.request;
<ide> return key && sourceInfo.emittedImports.get(key);
<ide> }
<ide>
<del> harmonyInit(dep, source, runtime, dependencyTemplates) {
<add> getInitFragments(dependency, source, runtimeTemplate, dependencyTemplates) {
<add> // TODO do not use source
<add> // TODO figure out a better way
<ide> let sourceInfo = importEmittedMap.get(source);
<ide> if (!sourceInfo) {
<ide> importEmittedMap.set(
<ide> HarmonyImportDependency.Template = class HarmonyImportDependencyTemplate extends
<ide> })
<ide> );
<ide> }
<del> const key = dep._module || dep.request;
<del> if (key && sourceInfo.emittedImports.get(key)) return;
<add>
<add> const key = dependency._module || dependency.request;
<add> if (!key || sourceInfo.emittedImports.get(key)) {
<add> return [];
<add> }
<add>
<ide> sourceInfo.emittedImports.set(key, true);
<del> const content = dep.getImportStatement(false, runtime);
<del> source.insert(-1, content);
<add>
<add> return [
<add> new InitFragment(
<add> dependency.getImportStatement(false, runtimeTemplate),
<add> dependency.sourceOrder
<add> )
<add> ];
<ide> }
<ide> };
<ide><path>lib/dependencies/HarmonyImportSideEffectDependency.js
<ide> class HarmonyImportSideEffectDependency extends HarmonyImportDependency {
<ide> * @returns {DependencyReference} reference
<ide> */
<ide> getReference() {
<del> if (this._module && this._module.factoryMeta.sideEffectFree) return null;
<del>
<add> if (this._module && this._module.factoryMeta.sideEffectFree) {
<add> return null;
<add> }
<ide> return super.getReference();
<ide> }
<ide>
<ide> class HarmonyImportSideEffectDependency extends HarmonyImportDependency {
<ide> }
<ide>
<ide> HarmonyImportSideEffectDependency.Template = class HarmonyImportSideEffectDependencyTemplate extends HarmonyImportDependency.Template {
<del> getHarmonyInitOrder(dep) {
<del> if (dep._module && dep._module.factoryMeta.sideEffectFree) return NaN;
<del> return super.getHarmonyInitOrder(dep);
<add> getInitFragments(dependency, source, runtimeTemplate, dependencyTemplates) {
<add> if (dependency._module && dependency._module.factoryMeta.sideEffectFree) {
<add> return [];
<add> } else {
<add> return super.getInitFragments(
<add> dependency,
<add> source,
<add> runtimeTemplate,
<add> dependencyTemplates
<add> );
<add> }
<ide> }
<ide> };
<ide>
<ide><path>lib/dependencies/HarmonyInitDependency.js
<del>/*
<del> MIT License http://www.opensource.org/licenses/mit-license.php
<del> Author Tobias Koppers @sokra
<del>*/
<del>
<del>"use strict";
<del>
<del>const NullDependency = require("./NullDependency");
<del>
<del>/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
<del>/** @typedef {import("../Dependency")} Dependency */
<del>/** @typedef {import("../DependencyTemplate")} DependencyTemplate */
<del>/** @typedef {import("../DependencyTemplates")} DependencyTemplates */
<del>/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
<del>
<del>class HarmonyInitDependency extends NullDependency {
<del> constructor(originModule) {
<del> super();
<del> this.originModule = originModule;
<del> }
<del>
<del> get type() {
<del> return "harmony init";
<del> }
<del>}
<del>
<del>module.exports = HarmonyInitDependency;
<del>
<del>HarmonyInitDependency.Template = class HarmonyInitDependencyTemplate extends NullDependency.Template {
<del> /**
<del> * @param {Dependency} dependency the dependency for which the template should be applied
<del> * @param {ReplaceSource} source the current replace source which can be modified
<del> * @param {RuntimeTemplate} runtimeTemplate the runtime template
<del> * @param {DependencyTemplates} dependencyTemplates the dependency templates
<del> * @returns {void}
<del> */
<del> apply(dependency, source, runtimeTemplate, dependencyTemplates) {
<del> const dep = /** @type {HarmonyInitDependency} */ (dependency);
<del> const module = dep.originModule;
<del> const list = [];
<del> for (const dependency of module.dependencies) {
<del> const tmpl = dependencyTemplates.get(dependency.constructor);
<del> /** @typedef {DependencyTemplate & { harmonyInit?: Function, getHarmonyInitOrder?: Function }} DepTemplWithHarmony */
<del> const template = /** @type {DepTemplWithHarmony} */ (tmpl);
<del> if (
<del> template &&
<del> typeof template.harmonyInit === "function" &&
<del> typeof template.getHarmonyInitOrder === "function"
<del> ) {
<del> const order = template.getHarmonyInitOrder(dependency);
<del> if (!isNaN(order)) {
<del> list.push({
<del> order,
<del> listOrder: list.length,
<del> dependency,
<del> template
<del> });
<del> }
<del> }
<del> }
<del>
<del> list.sort((a, b) => {
<del> const x = a.order - b.order;
<del> if (x) return x;
<del> return a.listOrder - b.listOrder;
<del> });
<del>
<del> for (const item of list) {
<del> item.template.harmonyInit(
<del> item.dependency,
<del> source,
<del> runtimeTemplate,
<del> dependencyTemplates
<del> );
<del> }
<del> }
<del>};
<ide><path>lib/dependencies/HarmonyModulesPlugin.js
<ide> class HarmonyModulesPlugin {
<ide> new HarmonyCompatibilityDependency.Template()
<ide> );
<ide>
<del> compilation.dependencyFactories.set(
<del> HarmonyInitDependency,
<del> new NullFactory()
<del> );
<del> compilation.dependencyTemplates.set(
<del> HarmonyInitDependency,
<del> new HarmonyInitDependency.Template()
<del> );
<del>
<ide> compilation.dependencyFactories.set(
<ide> HarmonyImportSideEffectDependency,
<ide> normalModuleFactory
<ide><path>lib/dependencies/NullDependency.js
<ide> const DependencyTemplate = require("../DependencyTemplate");
<ide> /** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
<ide> /** @typedef {import("../Dependency")} Dependency */
<ide> /** @typedef {import("../DependencyTemplates")} DependencyTemplates */
<add>/** @typedef {import("../InitFragment")} InitFragment */
<ide> /** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
<ide> /** @typedef {import("../util/createHash").Hash} Hash */
<ide>
<ide> NullDependency.Template = class NullDependencyTemplate extends DependencyTemplat
<ide> * @returns {void}
<ide> */
<ide> apply(dependency, source, runtimeTemplate, dependencyTemplates) {}
<add>
<add> /**
<add> * @param {Dependency} dependency the dependency for which the template should be applied
<add> * @param {ReplaceSource} source the current replace source which can be modified
<add> * @param {RuntimeTemplate} runtimeTemplate the runtime template
<add> * @param {DependencyTemplates} dependencyTemplates the dependency templates
<add> * @returns {InitFragment[]}
<add> */
<add> getInitFragments(dependency, source, runtimeTemplate, dependencyTemplates) {
<add> return [];
<add> }
<ide> };
<ide>
<ide> module.exports = NullDependency;
<ide><path>lib/optimize/ConcatenatedModule.js
<ide> class HarmonyImportSpecifierDependencyConcatenatedTemplate extends DependencyTem
<ide> this.modulesMap = modulesMap;
<ide> }
<ide>
<del> getHarmonyInitOrder(dep) {
<add> getInitFragments(dep, source, runtime) {
<ide> const module = dep._module;
<ide> const info = this.modulesMap.get(module);
<ide> if (!info) {
<del> return this.originalTemplate.getHarmonyInitOrder(dep);
<del> }
<del> return NaN;
<del> }
<del>
<del> harmonyInit(dep, source, runtimeTemplate, dependencyTemplates) {
<del> const module = dep._module;
<del> const info = this.modulesMap.get(module);
<del> if (!info) {
<del> this.originalTemplate.harmonyInit(
<del> dep,
<del> source,
<del> runtimeTemplate,
<del> dependencyTemplates
<del> );
<del> return;
<add> return this.originalTemplate.getInitFragments(dep, source, runtime);
<add> } else {
<add> return [];
<ide> }
<ide> }
<ide>
<ide> class HarmonyImportSideEffectDependencyConcatenatedTemplate extends DependencyTe
<ide> this.modulesMap = modulesMap;
<ide> }
<ide>
<del> getHarmonyInitOrder(dep) {
<add> getInitFragments(dep, source, runtime) {
<ide> const module = dep._module;
<ide> const info = this.modulesMap.get(module);
<ide> if (!info) {
<del> return this.originalTemplate.getHarmonyInitOrder(dep);
<del> }
<del> return NaN;
<del> }
<del>
<del> harmonyInit(dep, source, runtime, dependencyTemplates) {
<del> const module = dep._module;
<del> const info = this.modulesMap.get(module);
<del> if (!info) {
<del> this.originalTemplate.harmonyInit(
<del> dep,
<del> source,
<del> runtime,
<del> dependencyTemplates
<del> );
<del> return;
<add> return this.originalTemplate.getInitFragments(dep, source, runtime);
<add> } else {
<add> return [];
<ide> }
<ide> }
<ide>
<ide> class HarmonyExportSpecifierDependencyConcatenatedTemplate extends DependencyTem
<ide> this.rootModule = rootModule;
<ide> }
<ide>
<del> getHarmonyInitOrder(dep) {
<del> if (dep.originModule === this.rootModule) {
<del> return this.originalTemplate.getHarmonyInitOrder(dep);
<del> }
<del> return NaN;
<del> }
<del>
<del> harmonyInit(dep, source, runtime, dependencyTemplates) {
<add> getInitFragments(dep, source, runtime) {
<ide> if (dep.originModule === this.rootModule) {
<del> this.originalTemplate.harmonyInit(
<del> dep,
<del> source,
<del> runtime,
<del> dependencyTemplates
<del> );
<del> return;
<add> return this.originalTemplate.getInitFragments(dep, source, runtime);
<add> } else {
<add> return [];
<ide> }
<ide> }
<ide>
<ide> class HarmonyExportImportedSpecifierDependencyConcatenatedTemplate extends Depen
<ide> });
<ide> }
<ide>
<del> getHarmonyInitOrder(dep) {
<add> getInitFragments(dep, source, runtime) {
<ide> const module = dep._module;
<ide> const info = this.modulesMap.get(module);
<ide> if (!info) {
<del> return this.originalTemplate.getHarmonyInitOrder(dep);
<del> }
<del> return NaN;
<del> }
<del>
<del> harmonyInit(dep, source, runtime, dependencyTemplates) {
<del> const module = dep._module;
<del> const info = this.modulesMap.get(module);
<del> if (!info) {
<del> this.originalTemplate.harmonyInit(
<del> dep,
<del> source,
<del> runtime,
<del> dependencyTemplates
<del> );
<del> return;
<add> return this.originalTemplate.getInitFragments(dep, source, runtime);
<add> } else {
<add> return [];
<ide> }
<ide> }
<ide> | 16 |
Python | Python | save vectors init | 1e38bea6e9e08eeae0bbae59776003a2fb0f9767 | <ide><path>spacy/cli/init_model.py
<ide> def init_model(lang, output_dir, freqs_loc=None, clusters_loc=None, jsonl_loc=No
<ide> vectors_loc = ensure_path(vectors_loc)
<ide> if vectors_loc and vectors_loc.parts[-1].endswith('.npz'):
<ide> vectors_data = numpy.load(vectors_loc.open('rb'))
<del> vector_keys = [lex['orth'] for lex in lex_attrs if 'id' in lex]
<add> vector_keys = [lex['orth'] for lex in lex_attrs
<add> if 'rank' in lex and lex['rank'] < vectors_data.shape[0]]
<ide> else:
<ide> vectors_data, vector_keys = read_vectors(vectors_loc) if vectors_loc else (None, None)
<ide> nlp = create_model(lang, lex_attrs, vectors_data, vector_keys, prune_vectors) | 1 |
Python | Python | fix bug finally??!!" | 94886747a73cd3143f1e040dd855842e8d5d7276 | <ide><path>research/object_detection/dataset_tools/create_ava_tf_record.py
<del># Copyright 2019 The MediaPipe Authors.
<add># Copyright 2020 The TensorFlow Authors. All Rights Reserved.
<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> # You may obtain a copy of the License at
<ide> #
<del># http://www.apache.org/licenses/LICENSE-2.0
<add># http://www.apache.org/licenses/LICENSE-2.0
<ide> #
<ide> # Unless required by applicable law or agreed to in writing, software
<ide> # distributed under the License is distributed on an "AS IS" BASIS,
<ide> # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<ide> # See the License for the specific language governing permissions and
<ide> # limitations under the License.
<add># ==============================================================================
<ide>
<ide> # Modified by Kaushik Shivakumar for the AVA Actions Dataset
<ide> # to work without MediaPipe, code started by Bryan Seybold.
<ide>
<del>r"""Code to download and parse the AVA dataset for TensorFlow models.
<add>r"""Code to download and parse the AVA Actions dataset for TensorFlow models.
<ide>
<ide> The [AVA data set](
<ide> https://research.google.com/ava/index.html)
<ide> https://github.com/cvdfoundation/ava-datset
<ide>
<ide> Prior to running this script, please run download_and_preprocess_ava.sh to
<del>download and trim input videos.
<add>download input videos.
<ide>
<ide> Running this code as a module generates the data set on disk. First, the
<ide> required files are downloaded (_download_data) which enables constructing the
<ide> label map. Then (in generate_examples), for each split in the data set, the
<del>metadata is generated from the annotations for each example
<del>(_generate_metadata), and MediaPipe is used to fill in the video frames
<del>(_run_mediapipe). This script processes local video files defined in a custom
<del>CSV in a comparable manner to the Kinetics data set for evaluating and
<del>predicting values on your own data. The data set is written to disk as a set of
<add>metadata and image frames are generated from the annotations for each sequence
<add>example (_generate_metadata). The data set is written to disk as a set of
<ide> numbered TFRecord files.
<ide>
<del>The custom CSV format must match the Kinetics data set format, with columns
<del>corresponding to [[label_name], video, start, end, split] followed by lines with
<del>those fields. (Label_name is optional.) These field names can be used to
<del>construct the paths to the video files using the Python string formatting
<del>specification and the video_path_format_string flag:
<del> --video_path_format_string="/path/to/video/{video}.mp4"
<del>
<ide> Generating the data on disk can take considerable time and disk space.
<del>(Image compression quality is the primary determiner of disk usage. TVL1 flow
<del>determines runtime.)
<del>
<del>Once the data is on disk, reading the data as a tf.data.Dataset is accomplished
<del>with the following lines:
<del>
<del> kinetics = Kinetics("kinetics_data_path")
<del> dataset = kinetics.as_dataset("custom")
<del> # implement additional processing and batching here
<del> images_and_labels = dataset.make_one_shot_iterator().get_next()
<del> images = images_and_labels["images"]
<del> labels = image_and_labels["labels"]
<add>(Image compression quality is the primary determiner of disk usage.
<ide>
<del>IF using TFOD API, use the sequence example configuration in the config.proto.
<add>IF using the Tensorflow Object Detection API, set the input_type field
<add>in the input_reader to TF_SEQUENCE_EXAMPLE.
<ide>
<ide> This data is structured for per-clip action classification where images is
<ide> the sequence of images and labels are a one-hot encoded value. See
<ide> as_dataset() for more details.
<ide>
<ide> Note that the number of videos changes in the data set over time, so it will
<ide> likely be necessary to change the expected number of examples.
<add>
<add>The argument video_path_format_string expects a value as such:
<add> "/path/to/videos/{0}"
<add>
<ide> """
<ide>
<ide> from __future__ import absolute_import
<ide> def generate_examples(self,
<ide> def _generate_metadata(self, annotation_file, excluded_file, label_map,
<ide> seconds_per_sequence, hop_between_sequences,
<ide> video_path_format_string):
<del> """For each row in the annotation CSV, generates the corresponding metadata.
<add> """For each row in the annotation CSV, generates the corresponding metadata
<ide>
<ide> Args:
<ide> annotation_file: path to the file of AVA CSV annotations.
<ide> def _generate_metadata(self, annotation_file, excluded_file, label_map,
<ide> hop_between_sequences: The hop between sequences. If less than
<ide> seconds_per_sequence, will overlap.
<ide> Yields:
<del> Each tf.SequenceExample of metadata, ready to pass to MediaPipe.
<add> Each prepared tf.SequenceExample of metadata also containing video frames
<ide> """
<ide> global GLOBAL_SOURCE_ID
<ide> fieldnames = ["id", "timestamp_seconds", "xmin", "ymin", "xmax", "ymax",
<ide> def _generate_metadata(self, annotation_file, excluded_file, label_map,
<ide> while windowed_timestamp < end_time:
<ide> skipped_frame_count = 0;
<ide>
<add> if (media_id, windowed_timestamp) in frame_excluded:
<add> end_time += 1
<add> windowed_timestamp += 1
<add> skipped_frame_count += 1
<add> logging.info("Ignoring and skipping excluded frame.")
<add> continue
<add>
<ide> cur_vid.set(cv2.CAP_PROP_POS_MSEC,
<ide> (windowed_timestamp) * SECONDS_TO_MILLI)
<ide> _, image = cur_vid.read()
<ide> _, buffer = cv2.imencode('.jpg', image)
<ide>
<ide> bufstring = buffer.tostring()
<ide> total_images.append(dataset_util.bytes_feature(bufstring))
<del>
<ide> source_id = str(GLOBAL_SOURCE_ID) + "_" + media_id
<ide> total_source_ids.append(dataset_util.bytes_feature(
<ide> source_id.encode("utf8")))
<ide> total_is_annotated.append(dataset_util.int64_feature(1))
<ide> GLOBAL_SOURCE_ID += 1
<del> if (media_id, windowed_timestamp) in frame_excluded:
<del> end_time += 1
<del> windowed_timestamp += 1
<del> skipped_frame_count += 1
<del> logging.info("Ignoring and skipping excluded frame.")
<del> continue
<del> else:
<del> xmins = []
<del> xmaxs = []
<del> ymins = []
<del> ymaxs = []
<del> labels = []
<del> label_strings = []
<del> confidences = []
<del> for row in frame_annotations[(media_id, windowed_timestamp)]:
<del> if len(row) > 2 and int(row["action_label"]) in label_map:
<del> xmins.append(float(row["xmin"]))
<del> xmaxs.append(float(row["xmax"]))
<del> ymins.append(float(row["ymin"]))
<del> ymaxs.append(float(row["ymax"]))
<del> labels.append(int(row["action_label"]))
<del> label_strings.append(label_map[int(row["action_label"])])
<del> confidences.append(1)
<del> else:
<del> logging.warning("Unknown label: %s", row["action_label"])
<add>
<add> xmins = []
<add> xmaxs = []
<add> ymins = []
<add> ymaxs = []
<add> labels = []
<add> label_strings = []
<add> confidences = []
<add> for row in frame_annotations[(media_id, windowed_timestamp)]:
<add> if len(row) > 2 and int(row["action_label"]) in label_map:
<add> xmins.append(float(row["xmin"]))
<add> xmaxs.append(float(row["xmax"]))
<add> ymins.append(float(row["ymin"]))
<add> ymaxs.append(float(row["ymax"]))
<add> labels.append(int(row["action_label"]))
<add> label_strings.append(label_map[int(row["action_label"])])
<add> confidences.append(1)
<add> else:
<add> logging.warning("Unknown label: %s", row["action_label"])
<ide>
<ide> #Display the image and bounding boxes being
<ide> #processed (for debugging purposes) if desired. | 1 |
Python | Python | add a flag to disable remote control | 0384c7f0c90f53a8c4bab1e4fda69f077a672790 | <ide><path>celery/app/defaults.py
<ide> def __repr__(self):
<ide> 'DEFAULT_DELIVERY_MODE': Option(2, type='string'),
<ide> 'EAGER_PROPAGATES_EXCEPTIONS': Option(False, type='bool'),
<ide> 'ENABLE_UTC': Option(True, type='bool'),
<add> 'ENABLE_REMOTE_CONTROL': Option(True, type='bool'),
<ide> 'EVENT_SERIALIZER': Option('json'),
<ide> 'IMPORTS': Option((), type='tuple'),
<ide> 'INCLUDE': Option((), type='tuple'),
<ide><path>celery/worker/consumer.py
<ide> class Blueprint(bootsteps.Blueprint):
<ide> 'celery.worker.consumer:Events',
<ide> 'celery.worker.consumer:Gossip',
<ide> 'celery.worker.consumer:Heart',
<del> 'celery.worker.consumer:Control',
<ide> 'celery.worker.consumer:Tasks',
<ide> 'celery.worker.consumer:Evloop',
<ide> 'celery.worker.consumer:Agent',
<ide> def __init__(self, on_task,
<ide> # connect again.
<ide> self.app.conf.BROKER_CONNECTION_TIMEOUT = None
<ide>
<add>
<add> additional_steps = None
<add> if self.app.conf.CELERY_ENABLE_REMOTE_CONTROL:
<add> additional_steps = ['celery.worker.consumer:Control']
<add>
<ide> self.steps = []
<ide> self.blueprint = self.Blueprint(
<del> app=self.app, on_close=self.on_close,
<add> app=self.app, on_close=self.on_close, steps=additional_steps,
<ide> )
<ide> self.blueprint.apply(self, **dict(worker_options or {}, **kwargs))
<ide>
<ide> def __init__(self, c, **kwargs):
<ide>
<ide>
<ide> class Tasks(bootsteps.StartStopStep):
<del> requires = (Control, )
<add> requires = ()
<ide>
<ide> def __init__(self, c, initial_prefetch_count=2, **kwargs):
<ide> c.task_consumer = c.qos = None | 2 |
Text | Text | remove colors shown as keywords | 40d7dc4af96658582b0a9710e71922239a75a201 | <ide><path>curriculum/challenges/english/01-responsive-web-design/applied-visual-design/adjust-the-hue-of-a-color.md
<ide> Change the `background-color` of each `div` element based on the class names (`g
<ide>
<ide> # --hints--
<ide>
<del>Your code should use the `hsl()` function to declare the color `green`.
<add>Your code should use the `hsl()` function to declare the color green.
<ide>
<ide> ```js
<ide> assert(code.match(/\.green\s*?{\s*?background-color\s*:\s*?hsl/gi));
<ide> ```
<ide>
<del>Your code should use the `hsl()` function to declare the color `cyan`.
<add>Your code should use the `hsl()` function to declare the color cyan.
<ide>
<ide> ```js
<ide> assert(code.match(/\.cyan\s*?{\s*?background-color\s*:\s*?hsl/gi));
<ide> ```
<ide>
<del>Your code should use the `hsl()` function to declare the color `blue`.
<add>Your code should use the `hsl()` function to declare the color blue.
<ide>
<ide> ```js
<ide> assert(code.match(/\.blue\s*?{\s*?background-color\s*:\s*?hsl/gi)); | 1 |
Javascript | Javascript | use american spelling as per style guide | 45307fde5c82488d1a12c1eeee24714d49745706 | <ide><path>lib/buffer.js
<ide> Buffer.prototype.readInt32BE = function readInt32BE(offset, noAssert) {
<ide> //
<ide> // An all-bits-one exponent is either a positive or negative infinity, if
<ide> // the fraction is zero, or NaN when it is non-zero. The standard allows
<del>// both quiet and signalling NaNs but since NaN is a canonical value in
<add>// both quiet and signaling NaNs but since NaN is a canonical value in
<ide> // JavaScript, we cannot (and do not) distinguish between the two.
<ide> //
<ide> // Other exponents are regular numbers and are computed by subtracting the bias | 1 |
Python | Python | replace print with logger | ff5cdc086be1e0c3e2bbad8e3469b34cffb55a85 | <ide><path>examples/pytorch/question-answering/utils_qa.py
<ide> def postprocess_qa_predictions_with_beam_search(
<ide> output_dir, "null_odds.json" if prefix is None else f"{prefix}_null_odds.json"
<ide> )
<ide>
<del> print(f"Saving predictions to {prediction_file}.")
<add> logger.info(f"Saving predictions to {prediction_file}.")
<ide> with open(prediction_file, "w") as writer:
<ide> writer.write(json.dumps(all_predictions, indent=4) + "\n")
<del> print(f"Saving nbest_preds to {nbest_file}.")
<add> logger.info(f"Saving nbest_preds to {nbest_file}.")
<ide> with open(nbest_file, "w") as writer:
<ide> writer.write(json.dumps(all_nbest_json, indent=4) + "\n")
<ide> if version_2_with_negative:
<del> print(f"Saving null_odds to {null_odds_file}.")
<add> logger.info(f"Saving null_odds to {null_odds_file}.")
<ide> with open(null_odds_file, "w") as writer:
<ide> writer.write(json.dumps(scores_diff_json, indent=4) + "\n")
<ide> | 1 |
Text | Text | fix changes for 1.3.0-beta.13 | 6addac397d82119bd9caaf35c762f908c6a71dce | <ide><path>CHANGELOG.md
<del>Reading git log since v1.3.0-beta.12
<del>Parsed 1 commits
<del>Generating changelog to stdout ( undefined )
<ide> <a name="1.3.0-beta.13"></a>
<ide> # 1.3.0-beta.13 idiosyncratic-numerification (2014-06-16)
<ide> | 1 |
Python | Python | add addition asserts to proxy tests | 133d5633c151e1cdbf0c2af51bd622de9abe9d66 | <ide><path>libcloud/test/test_connection.py
<ide> def test_constructor(self):
<ide> self.assertEqual(conn.proxy_scheme, 'http')
<ide> self.assertEqual(conn.proxy_host, '127.0.0.2')
<ide> self.assertEqual(conn.proxy_port, 3128)
<add> self.assertEqual(conn.session.proxies, {
<add> 'http': 'http://127.0.0.2:3128'
<add> })
<ide>
<ide> _ = os.environ.pop('http_proxy', None)
<ide> conn = LibcloudConnection(host='localhost', port=80)
<ide> def test_constructor(self):
<ide> self.assertEqual(conn.proxy_scheme, 'http')
<ide> self.assertEqual(conn.proxy_host, '127.0.0.3')
<ide> self.assertEqual(conn.proxy_port, 3128)
<add> self.assertEqual(conn.session.proxies, {
<add> 'http': 'http://127.0.0.3:3128'
<add> })
<ide>
<ide> proxy_url = 'http://127.0.0.4:3128'
<ide> conn = LibcloudConnection(host='localhost', port=80,
<ide> proxy_url=proxy_url)
<ide> self.assertEqual(conn.proxy_scheme, 'http')
<ide> self.assertEqual(conn.proxy_host, '127.0.0.4')
<ide> self.assertEqual(conn.proxy_port, 3128)
<add> self.assertEqual(conn.session.proxies, {
<add> 'http': 'http://127.0.0.4:3128'
<add> })
<ide>
<ide> os.environ['http_proxy'] = proxy_url
<ide> proxy_url = 'http://127.0.0.5:3128'
<ide> def test_constructor(self):
<ide> self.assertEqual(conn.proxy_scheme, 'http')
<ide> self.assertEqual(conn.proxy_host, '127.0.0.5')
<ide> self.assertEqual(conn.proxy_port, 3128)
<add> self.assertEqual(conn.session.proxies, {
<add> 'http': 'http://127.0.0.5:3128'
<add> })
<ide>
<ide> os.environ['http_proxy'] = proxy_url
<ide> proxy_url = 'https://127.0.0.6:3129'
<ide> def test_constructor(self):
<ide> self.assertEqual(conn.proxy_scheme, 'https')
<ide> self.assertEqual(conn.proxy_host, '127.0.0.6')
<ide> self.assertEqual(conn.proxy_port, 3129)
<add> self.assertEqual(conn.session.proxies, {
<add> 'https': 'https://127.0.0.6:3129'
<add> })
<ide>
<ide> def test_connection_to_unusual_port(self):
<ide> conn = LibcloudConnection(host='localhost', port=8080) | 1 |
PHP | PHP | create notificationfailed event | deeada07e03dc5a48b6d8c0cc7f493d58599d002 | <ide><path>src/Illuminate/Notifications/Events/NotificationFailed.php
<add><?php
<add>
<add>namespace Illuminate\Notifications\Events;
<add>
<add>class NotificationFailed
<add>{
<add> /**
<add> * The notifiable entity who received the notification.
<add> *
<add> * @var mixed
<add> */
<add> public $notifiable;
<add>
<add> /**
<add> * The notification instance.
<add> *
<add> * @var \Illuminate\Notifications\Notification
<add> */
<add> public $notification;
<add>
<add> /**
<add> * The channel name.
<add> *
<add> * @var string
<add> */
<add> public $channel;
<add>
<add> /**
<add> * The data needed to process this failure.
<add> *
<add> * @var array
<add> */
<add> public $data = [];
<add>
<add> /**
<add> * Create a new event instance.
<add> *
<add> * @param mixed $notifiable
<add> * @param \Illuminate\Notifications\Notification $notification
<add> * @param string $channel
<add> * @param array $data
<add> * @return void
<add> */
<add> public function __construct($notifiable, $notification, $channel, $data = [])
<add> {
<add> $this->channel = $channel;
<add> $this->notifiable = $notifiable;
<add> $this->notification = $notification;
<add> $this->data = $data;
<add> }
<add>} | 1 |
Text | Text | remove hacktoberfest comment | 88524556e7ac486385c571950a31606c299e04db | <ide><path>.github/PULL_REQUEST_TEMPLATE.md
<del><!-- Please note that low quality PRs and PRs that do not follow our contributing guidelines will be marked as invalid for Hacktoberfest. -->
<del>
<ide> Checklist:
<ide>
<ide> <!-- Please follow this checklist and put an x in each of the boxes, like this: [x]. It will ensure that our team takes your pull request seriously. --> | 1 |
Text | Text | enable multi lines | d661dc71343a64ac91393732c34fef21ecfd2963 | <ide><path>.github/ISSUE_TEMPLATE.md
<ide> This is a (multiple allowed):
<ide> * [ ] feature-discussion (RFC)
<ide>
<ide> ## DESCRIPTIVE TITLE HERE
<del>CakePHP Version: EXACT RELEASE VERSION OR COMMIT HASH, HERE.
<del>Platform and Target: YOUR WEB-SERVER, DATABASE AND OTHER RELEVANT INFO AND HOW THE REQUEST IS BEING MADE, HERE.
<add>* CakePHP Version: EXACT RELEASE VERSION OR COMMIT HASH, HERE.
<add>* Platform and Target: YOUR WEB-SERVER, DATABASE AND OTHER RELEVANT INFO AND HOW THE REQUEST IS BEING MADE, HERE.
<ide>
<ide> ### What you did
<ide> EXPLAIN WHAT YOU DID, PREFERABLY WITH CODE EXAMPLES, HERE. | 1 |
Text | Text | add circular option documentation for grid lines | 246b9a1a40b72e57ba256d679ca6e44f1cd82411 | <ide><path>docs/axes/styling.md
<ide> The grid line configuration is nested under the scale configuration in the `grid
<ide> | Name | Type | Default | Description
<ide> | -----| ---- | --------| -----------
<ide> | `display` | `Boolean` | `true` | If false, do not display grid lines for this axis.
<add>| `circular` | `Boolean` | `false` | If true, gridlines are circular (on radar chart only)
<ide> | `color` | `Color/Color[]` | `'rgba(0, 0, 0, 0.1)'` | The color of the grid lines. If specified as an array, the first color applies to the first grid line, the second to the second grid line and so on.
<ide> | `borderDash` | `Number[]` | `[]` | Length and spacing of dashes on grid lines. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setLineDash)
<ide> | `borderDashOffset` | `Number` | `0` | Offset for line dashes. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineDashOffset) | 1 |
Javascript | Javascript | fix nits in test/fixtures/tls-connect.js | 834a413eed7c5f6a415e00b14d499c5cb0a34fca | <ide><path>test/fixtures/tls-connect.js
<ide> exports.debug = util.debuglog('test');
<ide> exports.tls = tls;
<ide>
<ide> // Pre-load keys from common fixtures for ease of use by tests.
<del>const keys = exports.keys = {
<add>exports.keys = {
<ide> agent1: load('agent1', 'ca1'),
<ide> agent2: load('agent2', 'agent2'),
<ide> agent3: load('agent3', 'ca2'),
<ide> const keys = exports.keys = {
<ide> ec: load('ec', 'ec'),
<ide> };
<ide>
<del>// root is the self-signed root of the trust chain, not an intermediate ca.
<add>// `root` is the self-signed root of the trust chain, not an intermediate ca.
<ide> function load(cert, root) {
<del> root = root || cert; // Assume self-signed if no issuer
<add> root = root || cert; // Assume self-signed if no issuer.
<ide> const id = {
<ide> key: fixtures.readKey(cert + '-key.pem', 'binary'),
<ide> cert: fixtures.readKey(cert + '-cert.pem', 'binary'),
<ide> exports.connect = function connect(options, callback) {
<ide> tls.createServer(options.server, function(conn) {
<ide> server.conn = conn;
<ide> conn.pipe(conn);
<del> maybeCallback()
<add> maybeCallback();
<ide> }).listen(0, function() {
<ide> server.server = this;
<ide>
<ide> exports.connect = function connect(options, callback) {
<ide> function maybeCallback() {
<ide> if (!callback)
<ide> return;
<del> if (server.conn && (client.conn || client.err)) {
<add> if (server.conn && client.conn) {
<ide> const err = pair.client.err || pair.server.err;
<ide> callback(err, pair, cleanup);
<ide> callback = null;
<ide> exports.connect = function connect(options, callback) {
<ide> if (client.conn)
<ide> client.conn.end();
<ide> }
<del>}
<add>}; | 1 |
Python | Python | raise exception when field source is a built-in | 7179ea9984cae9bf20f69d4ddd48071f6e3de2fa | <ide><path>rest_framework/fields.py
<ide> class empty:
<ide> pass
<ide>
<ide>
<add>class BuiltinSignatureError(Exception):
<add> """
<add> Built-in function signatures are not inspectable. This exception is raised
<add> so the serializer can raise a helpful error message.
<add> """
<add> pass
<add>
<add>
<ide> def is_simple_callable(obj):
<ide> """
<ide> True if the object is a callable that takes no arguments.
<ide> """
<add> # Bail early since we cannot inspect built-in function signatures.
<add> if inspect.isbuiltin(obj):
<add> raise BuiltinSignatureError(
<add> 'Built-in function signatures are not inspectable. '
<add> 'Wrap the function call in a simple, pure Python function.')
<add>
<ide> if not (inspect.isfunction(obj) or inspect.ismethod(obj) or isinstance(obj, functools.partial)):
<ide> return False
<ide>
<ide> def get_attribute(self, instance):
<ide> """
<ide> try:
<ide> return get_attribute(instance, self.source_attrs)
<add> except BuiltinSignatureError as exc:
<add> msg = (
<add> 'Field source for `{serializer}.{field}` maps to a built-in '
<add> 'function type and is invalid. Define a property or method on '
<add> 'the `{instance}` instance that wraps the call to the built-in '
<add> 'function.'.format(
<add> serializer=self.parent.__class__.__name__,
<add> field=self.field_name,
<add> instance=instance.__class__.__name__,
<add> )
<add> )
<add> raise type(exc)(msg)
<ide> except (KeyError, AttributeError) as exc:
<ide> if self.default is not empty:
<ide> return self.get_default()
<ide><path>tests/test_fields.py
<ide> import rest_framework
<ide> from rest_framework import exceptions, serializers
<ide> from rest_framework.compat import ProhibitNullCharactersValidator
<del>from rest_framework.fields import DjangoImageField, is_simple_callable
<add>from rest_framework.fields import (
<add> BuiltinSignatureError, DjangoImageField, is_simple_callable
<add>)
<ide>
<ide> # Tests for helper functions.
<ide> # ---------------------------
<ide> class Meta:
<ide>
<ide> assert is_simple_callable(ChoiceModel().get_choice_field_display)
<ide>
<add> def test_builtin_function(self):
<add> # Built-in function signatures are not easily inspectable, so the
<add> # current expectation is to just raise a helpful error message.
<add> timestamp = datetime.datetime.now()
<add>
<add> with pytest.raises(BuiltinSignatureError) as exc_info:
<add> is_simple_callable(timestamp.date)
<add>
<add> assert str(exc_info.value) == (
<add> 'Built-in function signatures are not inspectable. Wrap the '
<add> 'function call in a simple, pure Python function.')
<add>
<ide> def test_type_annotation(self):
<ide> # The annotation will otherwise raise a syntax error in python < 3.5
<ide> locals = {}
<ide> def example_callable(self):
<ide>
<ide> assert 'method call failed' in str(exc_info.value)
<ide>
<add> def test_builtin_callable_source_raises(self):
<add> class BuiltinSerializer(serializers.Serializer):
<add> date = serializers.ReadOnlyField(source='timestamp.date')
<add>
<add> with pytest.raises(BuiltinSignatureError) as exc_info:
<add> BuiltinSerializer({'timestamp': datetime.datetime.now()}).data
<add>
<add> assert str(exc_info.value) == (
<add> 'Field source for `BuiltinSerializer.date` maps to a built-in '
<add> 'function type and is invalid. Define a property or method on '
<add> 'the `dict` instance that wraps the call to the built-in function.')
<add>
<ide>
<ide> class TestReadOnly:
<ide> def setup(self): | 2 |
Javascript | Javascript | remove unused variable in awdloader | feee8a9c023f645878c7a9ad01c6024a55b84b46 | <ide><path>examples/js/loaders/AWDLoader.js
<ide> num_subs = this.readU16(),
<ide> geom,
<ide> subs_parsed = 0,
<del> props,
<ide> buffer,
<ide> skinW, skinI,
<ide> geometries = [];
<del>
<del> props = this.parseProperties( {
<del> 1: this._geoNrType,
<del> 2: this._geoNrType
<del> } );
<add>
<add> // Ignore for now
<add> this.parseProperties( { 1: this._geoNrType, 2: this._geoNrType } );
<ide>
<ide> // Loop through sub meshes
<ide> while ( subs_parsed < num_subs ) { | 1 |
Javascript | Javascript | fix meridiem parsing for bn,bo,dv,ml,si,tzl | a9ec578a391721e56b43db3d7bce3bbf47001255 | <ide><path>src/locale/bn.js
<ide> export default moment.defineLocale('bn', {
<ide> });
<ide> },
<ide> meridiemParse: /রাত|সকাল|দুপুর|বিকাল|রাত/,
<del> isPM: function (input) {
<del> return /^(দুপুর|বিকাল|রাত)$/.test(input);
<add> meridiemHour : function (hour, meridiem) {
<add> if (hour === 12) {
<add> hour = 0;
<add> }
<add> if ((meridiem === 'রাত' && hour >= 4) ||
<add> (meridiem === 'দুপুর' && hour < 5) ||
<add> meridiem === 'বিকাল') {
<add> return hour + 12;
<add> } else {
<add> return hour;
<add> }
<ide> },
<del> //Bengali is a vast language its spoken
<del> //in different forms in various parts of the world.
<del> //I have just generalized with most common one used
<ide> meridiem : function (hour, minute, isLower) {
<ide> if (hour < 4) {
<ide> return 'রাত';
<ide><path>src/locale/bo.js
<ide> export default moment.defineLocale('bo', {
<ide> });
<ide> },
<ide> meridiemParse: /མཚན་མོ|ཞོགས་ཀས|ཉིན་གུང|དགོང་དག|མཚན་མོ/,
<del> isPM: function (input) {
<del> return /^(ཉིན་གུང|དགོང་དག|མཚན་མོ)$/.test(input);
<add> meridiemHour : function (hour, meridiem) {
<add> if (hour === 12) {
<add> hour = 0;
<add> }
<add> if ((meridiem === 'མཚན་མོ' && hour >= 4) ||
<add> (meridiem === 'ཉིན་གུང' && hour < 5) ||
<add> meridiem === 'དགོང་དག') {
<add> return hour + 12;
<add> } else {
<add> return hour;
<add> }
<ide> },
<ide> meridiem : function (hour, minute, isLower) {
<ide> if (hour < 4) {
<ide><path>src/locale/dv.js
<ide> export default moment.defineLocale('dv', {
<ide> },
<ide> meridiemParse: /މކ|މފ/,
<ide> isPM : function (input) {
<del> return '' === input;
<add> return 'މފ' === input;
<ide> },
<ide> meridiem : function (hour, minute, isLower) {
<ide> if (hour < 12) {
<ide><path>src/locale/ml.js
<ide> export default moment.defineLocale('ml', {
<ide> yy : '%d വർഷം'
<ide> },
<ide> meridiemParse: /രാത്രി|രാവിലെ|ഉച്ച കഴിഞ്ഞ്|വൈകുന്നേരം|രാത്രി/i,
<del> isPM : function (input) {
<del> return /^(ഉച്ച കഴിഞ്ഞ്|വൈകുന്നേരം|രാത്രി)$/.test(input);
<add> meridiemHour : function (hour, meridiem) {
<add> if (hour === 12) {
<add> hour = 0;
<add> }
<add> if ((meridiem === 'രാത്രി' && hour >= 4) ||
<add> meridiem === 'ഉച്ച കഴിഞ്ഞ്' ||
<add> meridiem === 'വൈകുന്നേരം') {
<add> return hour + 12;
<add> } else {
<add> return hour;
<add> }
<ide> },
<ide> meridiem : function (hour, minute, isLower) {
<ide> if (hour < 4) {
<ide><path>src/locale/si.js
<ide> export default moment.defineLocale('si', {
<ide> ordinal : function (number) {
<ide> return number + ' වැනි';
<ide> },
<add> meridiemParse : /පෙර වරු|පස් වරු|පෙ.ව|ප.ව./,
<add> isPM : function (input) {
<add> return input === 'ප.ව.' || input === 'පස් වරු';
<add> },
<ide> meridiem : function (hours, minutes, isLower) {
<ide> if (hours > 11) {
<ide> return isLower ? 'ප.ව.' : 'පස් වරු';
<ide><path>src/locale/tzl.js
<ide> export default moment.defineLocale('tzl', {
<ide> LLL : 'D. MMMM [dallas] YYYY HH.mm',
<ide> LLLL : 'dddd, [li] D. MMMM [dallas] YYYY HH.mm'
<ide> },
<add> meridiemParse: /d\'o|d\'a/i,
<add> isPM : function (input) {
<add> return 'd\'o' === input.toLowerCase();
<add> },
<ide> meridiem : function (hours, minutes, isLower) {
<ide> if (hours > 11) {
<ide> return isLower ? 'd\'o' : 'D\'O'; | 6 |
Ruby | Ruby | create explicit folders for more language libs | 6fbf1259707a359111ddf2478dfe3a62535744e0 | <ide><path>Library/Homebrew/keg.rb
<ide> def link
<ide> $n=0
<ide> $d=0
<ide>
<del> mkpaths=(1..9).collect {|x| "man/man#{x}"} <<'man'<<'doc'<<'locale'<<'info'<<'aclocal'
<add> share_mkpaths=%w[aclocal doc info locale man]+(1..9).collect{|x|"man/man#{x}"}
<ide>
<ide> # yeah indeed, you have to force anything you need in the main tree into
<ide> # these dirs REMEMBER that *NOT* everything needs to be in the main tree
<ide> link_dir('etc') {:mkpath}
<ide> link_dir('bin') {:skip}
<ide> link_dir('sbin') {:link}
<ide> link_dir('include') {:link}
<del> link_dir('share') {|path| :mkpath if mkpaths.include? path.to_s}
<add> link_dir('share') {|path| :mkpath if share_mkpaths.include? path.to_s}
<ide>
<ide> link_dir('lib') do |path|
<ide> case path.to_s
<del> when /^pkgconfig/ then :mkpath
<del> when /^php/ then :mkpath
<add> # pkg-config database gets explicitly created
<add> when 'pkgconfig' then :mkpath
<add> # lib/language folders also get explicitly created
<add> when 'ghc' then :mkpath
<add> when 'lua' then :mkpath
<add> when 'ocaml' then :mkpath
<ide> when /^perl5/ then :mkpath
<del> when /^python2\.6/ then :mkpath
<add> when 'php' then :mkpath
<add> when /^python[23]\.\d$/ then :mkpath
<add> else :link
<ide> end
<ide> end
<ide> | 1 |
Text | Text | fix suspicious heading emphasis in n-api.md | 7dd6d864cb3c4e5411bc8d29bfdf54b969126293 | <ide><path>doc/api/n-api.md
<ide> is sufficient and appropriate. Use of the `napi_make_callback` function
<ide> may be required when implementing custom async behavior that does not use
<ide> `napi_create_async_work`.
<ide>
<del>### *napi_open_callback_scope*
<add>### napi_open_callback_scope
<ide> <!-- YAML
<ide> added: v9.6.0
<ide> -->
<ide> the stack the [`napi_open_callback_scope`][] and
<ide> [`napi_close_callback_scope`][] functions can be used to open/close
<ide> the required scope.
<ide>
<del>### *napi_close_callback_scope*
<add>### napi_close_callback_scope
<ide> <!-- YAML
<ide> added: v9.6.0
<ide> --> | 1 |
Go | Go | remove locator check on endpoint force removal | 64673bce0a1dec6a473f143620a605228ac76659 | <ide><path>libnetwork/endpoint.go
<ide> func (ep *endpoint) sbLeave(sb *sandbox, force bool, options ...EndpointOption)
<ide> return nil
<ide> }
<ide>
<del>func (n *network) validateForceDelete(locator string) error {
<del> if n.Scope() == datastore.LocalScope {
<del> return nil
<del> }
<del>
<del> if locator == "" {
<del> return fmt.Errorf("invalid endpoint locator identifier")
<del> }
<del>
<del> return nil
<del>}
<del>
<ide> func (ep *endpoint) Delete(force bool) error {
<ide> var err error
<ide> n, err := ep.getNetworkFromStore()
<ide> func (ep *endpoint) Delete(force bool) error {
<ide> epid := ep.id
<ide> name := ep.name
<ide> sbid := ep.sandboxID
<del> locator := ep.locator
<ide> ep.Unlock()
<ide>
<del> if force {
<del> if err = n.validateForceDelete(locator); err != nil {
<del> return fmt.Errorf("unable to force delete endpoint %s: %v", name, err)
<del> }
<del> }
<del>
<ide> sb, _ := n.getController().SandboxByID(sbid)
<ide> if sb != nil && !force {
<ide> return &ActiveContainerError{name: name, id: epid} | 1 |
Text | Text | update job reference in collaborator_guide.md | d4c81be4a0035b2d96cd62ae3a846d4435d941e6 | <ide><path>COLLABORATOR_GUIDE.md
<ide> that the tests are reliable.
<ide> runs the standard V8 tests. Run it when updating V8 in Node.js or floating new
<ide> patches on V8.
<ide>
<del>* [`node-test-commit-custom-suites`](https://ci.nodejs.org/job/node-test-commit-custom-suites/)
<add>* [`node-test-commit-custom-suites-freestyle`](https://ci.nodejs.org/job/node-test-commit-custom-suites-freestyle/)
<ide> enables customization of test suites and parameters. It can execute test suites
<ide> not used in other CI test runs (such as tests in the `internet` or `pummel`
<ide> directories). It can also make sure tests pass when provided with a flag not | 1 |
Text | Text | update description and user stories | f353278905b5e27807cb22ddcca28eac2e5364c6 | <ide><path>curriculum/challenges/english/05-apis-and-microservices/apis-and-microservices-projects/file-metadata-microservice.md
<ide> forumTopicId: 301506
<ide> ## Description
<ide>
<ide> <section id='description'>
<del>Build a full stack JavaScript app that is functionally similar to this: <a href='https://file-metadata-microservice.freecodecamp.rocks/' target='_blank'>https://file-metadata-microservice.freecodecamp.rocks/</a>.
<del>Working on this project will involve you writing your code on Repl.it on our starter project. After completing this project you can copy your public Repl.it URL (to the homepage of your app) into this screen to test it! Optionally you may choose to write your project on another platform but it must be publicly visible for our testing.
<del>Start this project on Repl.it using <a href='https://repl.it/github/freeCodeCamp/boilerplate-project-filemetadata' target='_blank'>this link</a> or clone <a href='https://github.com/freeCodeCamp/boilerplate-project-filemetadata/'>this repository</a> on GitHub! If you use Repl.it, remember to save the link to your project somewhere safe!
<add>Build a full stack JavaScript app that is functionally similar to this: <a href='https://file-metadata-microservice.freecodecamp.rocks/' target='_blank'>https://file-metadata-microservice.freecodecamp.rocks/</a>. Working on this project will involve you writing your code using one of the following methods:
<add>
<add>- Clone <a href='https://github.com/freeCodeCamp/boilerplate-project-filemetadata/'>this GitHub repo</a> and complete your project locally.
<add>- Use <a href='https://repl.it/github/freeCodeCamp/boilerplate-project-filemetadata' target='_blank'>our repl.it starter project</a> to complete your project.
<add>- Use a site builder of your choice to complete the project. Be sure to incorporate all the files from our GitHub repo.
<add>
<add>When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field. Optionally, also submit a link to your projects source code in the `GitHub Link` field.
<ide> </section>
<ide>
<ide> ## Instructions
<ide>
<ide> <section id='instructions'>
<ide>
<add>**HINT:** You can use the `multer` npm package to handle file uploading.
<ide> </section>
<ide>
<ide> ## Tests
<ide> Start this project on Repl.it using <a href='https://repl.it/github/freeCodeCamp
<ide>
<ide> ```yml
<ide> tests:
<del> - text: I can provide my own project, not the example URL.
<add> - text: You should provide your own project, not the example URL.
<ide> testString: |
<ide> getUserInput => {
<ide> assert(!/.*\/file-metadata-microservice\.freecodecamp\.rocks/.test(getUserInput('url')));
<ide> }
<del> - text: I can submit a form that includes a file upload.
<add> - text: You can submit a form that includes a file upload.
<ide> testString: "async getUserInput => {
<ide> const site = await fetch(getUserInput('url'));
<ide> const data = await site.text();
<ide> const doc = new DOMParser().parseFromString(data, 'text/html');
<ide> assert(doc.querySelector('input[type=\"file\"]'));
<ide> }"
<del> - text: The form file input field has the <code>name</code> attribute set to <code>upfile</code>.
<add> - text: The form file input field has the `name` attribute set to `upfile`.
<ide> testString: "async getUserInput => {
<ide> const site = await fetch(getUserInput('url'));
<ide> const data = await site.text();
<ide> const doc = new DOMParser().parseFromString(data, 'text/html');
<ide> assert(doc.querySelector('input[name=\"upfile\"]'));
<ide> }"
<del> - text: When I submit something, I will receive the file <code>name</code>, <code>type</code>, and <code>size</code> in bytes within the JSON response.
<add> - text: When you submit a file, you receive the file `name`, `type`, and `size` in bytes within the JSON response.
<ide> testString: "async getUserInput => {
<ide> const formData = new FormData();
<ide> const fileData = await fetch('https://cdn.freecodecamp.org/weather-icons/01d.png'); | 1 |
Python | Python | move impersonation test back to quarantine | 2811851f80d6f5852d2401f7c57d2e4520b4f2ab | <ide><path>tests/test_impersonation.py
<ide> def create_user():
<ide> )
<ide>
<ide>
<del>@pytest.mark.heisentests
<add>@pytest.mark.quarantined
<ide> class TestImpersonation(unittest.TestCase):
<ide>
<ide> def setUp(self): | 1 |
Javascript | Javascript | fix redirect link failures to /account | d9d44ae509d771b34ebe2a18919c8720cd0254fb | <ide><path>server/passport-providers.js
<ide> var successRedirect = '/';
<ide> var failureRedirect = '/login';
<add>var linkFailureRedirect = '/account';
<ide> module.exports = {
<ide> local: {
<ide> provider: 'local',
<ide> module.exports = {
<ide> callbackURL: '/link/facebook/callback',
<ide> callbackPath: '/link/facebook/callback',
<ide> successRedirect: successRedirect,
<del> failureRedirect: failureRedirect,
<add> failureRedirect: linkFailureRedirect,
<ide> scope: ['email', 'user_likes'],
<ide> link: true,
<ide> failureFlash: true
<ide> module.exports = {
<ide> callbackURL: '/link/google/callback',
<ide> callbackPath: '/link/google/callback',
<ide> successRedirect: successRedirect,
<del> failureRedirect: failureRedirect,
<add> failureRedirect: linkFailureRedirect,
<ide> scope: ['email', 'profile'],
<ide> link: true,
<ide> failureFlash: true
<ide> module.exports = {
<ide> callbackURL: '/link/twitter/callback',
<ide> callbackPath: '/link/twitter/callback',
<ide> successRedirect: successRedirect,
<del> failureRedirect: failureRedirect,
<add> failureRedirect: linkFailureRedirect,
<ide> consumerKey: process.env.TWITTER_KEY,
<ide> consumerSecret: process.env.TWITTER_SECRET,
<ide> link: true,
<ide> module.exports = {
<ide> callbackURL: '/link/linkedin/callback',
<ide> callbackPath: '/link/linkedin/callback',
<ide> successRedirect: successRedirect,
<del> failureRedirect: failureRedirect,
<add> failureRedirect: linkFailureRedirect,
<ide> clientID: process.env.LINKEDIN_ID,
<ide> clientSecret: process.env.LINKEDIN_SECRET,
<ide> scope: ['r_basicprofile', 'r_emailaddress'],
<ide> module.exports = {
<ide> callbackURL: '/auth/github/callback/link',
<ide> callbackPath: '/auth/github/callback/link',
<ide> successRedirect: successRedirect,
<del> failureRedirect: failureRedirect,
<add> failureRedirect: linkFailureRedirect,
<ide> clientID: process.env.GITHUB_ID,
<ide> clientSecret: process.env.GITHUB_SECRET,
<ide> scope: ['email'], | 1 |
Text | Text | update documentation to stateless components | ec41af055753161341c0b32be12bcc1657719289 | <ide><path>docs/docs/06-transferring-props.it-IT.md
<ide> Nel resto di questo tutorial vengono illustrate le best practices, usando JSX e
<ide> Nella maggior parte dei casi dovresti esplicitamente passare le proprietà. Ciò assicura che venga esposto soltanto un sottoinsieme dell'API interna, del cui funzionamento si è certi.
<ide>
<ide> ```javascript
<del>var FancyCheckbox = React.createClass({
<del> render: function() {
<del> var fancyClass = this.props.checked ? 'FancyChecked' : 'FancyUnchecked';
<del> return (
<del> <div className={fancyClass} onClick={this.props.onClick}>
<del> {this.props.children}
<del> </div>
<del> );
<del> }
<del>});
<add>function FancyCheckbox(props) {
<add> var fancyClass = props.checked ? 'FancyChecked' : 'FancyUnchecked';
<add> return (
<add> <div className={fancyClass} onClick={props.onClick}>
<add> {props.children}
<add> </div>
<add> );
<add>}
<ide> ReactDOM.render(
<ide> <FancyCheckbox checked={true} onClick={console.log.bind(console)}>
<ide> Ciao mondo!
<ide> A volte passare manualmente ciascuna proprietà può essere noioso e fragile. In
<ide> Elenca tutte le proprietà che desideri consumare, seguite da `...other`.
<ide>
<ide> ```javascript
<del>var { checked, ...other } = this.props;
<add>var { checked, ...other } = props;
<ide> ```
<ide>
<ide> Ciò assicura che vengano passate tutte le proprietà TRANNE quelle che stai consumando tu stesso.
<ide>
<ide> ```javascript
<del>var FancyCheckbox = React.createClass({
<del> render: function() {
<del> var { checked, ...other } = this.props;
<del> var fancyClass = checked ? 'FancyChecked' : 'FancyUnchecked';
<del> // `other` contiene { onClick: console.log } ma non la proprietà checked
<del> return (
<del> <div {...other} className={fancyClass} />
<del> );
<del> }
<del>});
<add>function FancyCheckbox(props) {
<add> var { checked, ...other } = props;
<add> var fancyClass = checked ? 'FancyChecked' : 'FancyUnchecked';
<add> // `other` contiene { onClick: console.log } ma non la proprietà checked
<add> return (
<add> <div {...other} className={fancyClass} />
<add> );
<add>}
<ide> ReactDOM.render(
<ide> <FancyCheckbox checked={true} onClick={console.log.bind(console)}>
<ide> Ciao mondo!
<ide> ReactDOM.render(
<ide> Usa sempre il pattern di destrutturazione quando trasferisci altre proprietà sconosciute in `other`.
<ide>
<ide> ```javascript
<del>var FancyCheckbox = React.createClass({
<del> render: function() {
<del> var fancyClass = this.props.checked ? 'FancyChecked' : 'FancyUnchecked';
<del> // ANTI-PATTERN: `checked` sarebbe passato al componente interno
<del> return (
<del> <div {...this.props} className={fancyClass} />
<del> );
<del> }
<del>});
<add>function FancyCheckbox(props) {
<add> var fancyClass = props.checked ? 'FancyChecked' : 'FancyUnchecked';
<add> // ANTI-PATTERN: `checked` sarebbe passato al componente interno
<add> return (
<add> <div {...props} className={fancyClass} />
<add> );
<add>}
<ide> ```
<ide>
<ide> ## Consumare e Trasferire la Stessa Proprietà
<ide>
<ide> Se il tuo componente desidera consumare una proprietà, ma anche passarla ad altri, puoi passarla esplicitamente mediante `checked={checked}`. Questo è preferibile a passare l'intero oggetto `this.props` dal momento che è più facile effettuarne il linting e il refactoring.
<ide>
<ide> ```javascript
<del>var FancyCheckbox = React.createClass({
<del> render: function() {
<del> var { checked, title, ...other } = this.props;
<del> var fancyClass = checked ? 'FancyChecked' : 'FancyUnchecked';
<del> var fancyTitle = checked ? 'X ' + title : 'O ' + title;
<del> return (
<del> <label>
<del> <input {...other}
<del> checked={checked}
<del> className={fancyClass}
<del> type="checkbox"
<del> />
<del> {fancyTitle}
<del> </label>
<del> );
<del> }
<del>});
<add>function FancyCheckbox(props) {
<add> var { checked, title, ...other } = props;
<add> var fancyClass = checked ? 'FancyChecked' : 'FancyUnchecked';
<add> var fancyTitle = checked ? 'X ' + title : 'O ' + title;
<add> return (
<add> <label>
<add> <input {...other}
<add> checked={checked}
<add> className={fancyClass}
<add> type="checkbox"
<add> />
<add> {fancyTitle}
<add> </label>
<add> );
<add>}
<ide> ```
<ide>
<ide> > NOTA:
<ide> z; // { a: 3, b: 4 }
<ide> Se non usi JSX, puoi usare una libreria per ottenere il medesimo pattern. Underscore supporta `_.omit` per omettere delle proprietà ed `_.extend` per copiare le proprietà in un nuovo oggetto.
<ide>
<ide> ```javascript
<del>var FancyCheckbox = React.createClass({
<del> render: function() {
<del> var checked = this.props.checked;
<del> var other = _.omit(this.props, 'checked');
<del> var fancyClass = checked ? 'FancyChecked' : 'FancyUnchecked';
<del> return (
<del> React.DOM.div(_.extend({}, other, { className: fancyClass }))
<del> );
<del> }
<del>});
<add>function FancyCheckbox(props) {
<add> var checked = props.checked;
<add> var other = _.omit(props, 'checked');
<add> var fancyClass = checked ? 'FancyChecked' : 'FancyUnchecked';
<add> return (
<add> React.DOM.div(_.extend({}, other, { className: fancyClass }))
<add> );
<add>}
<ide> ```
<ide><path>docs/docs/06-transferring-props.ja-JP.md
<ide> React.createElement(Component, Object.assign({}, this.props, { more: 'values' })
<ide> ほとんどの場合、プロパティを明確に子要素に渡すべきです。それは、内部のAPIのサブセットだけを外に出していることと、認識しているプロパティが動作することを保証します。
<ide>
<ide> ```javascript
<del>var FancyCheckbox = React.createClass({
<del> render: function() {
<del> var fancyClass = this.props.checked ? 'FancyChecked' : 'FancyUnchecked';
<del> return (
<del> <div className={fancyClass} onClick={this.props.onClick}>
<del> {this.props.children}
<del> </div>
<del> );
<del> }
<del>});
<add>function FancyCheckbox(props) {
<add> var fancyClass = props.checked ? 'FancyChecked' : 'FancyUnchecked';
<add> return (
<add> <div className={fancyClass} onClick={props.onClick}>
<add> {props.children}
<add> </div>
<add> );
<add>}
<ide> ReactDOM.render(
<ide> <FancyCheckbox checked={true} onClick={console.log.bind(console)}>
<ide> Hello world!
<ide> ReactDOM.render(
<ide> 以下のように `...other` を使うことで、使いたいプロパティを一覧にすることができます。
<ide>
<ide> ```javascript
<del>var { checked, ...other } = this.props;
<add>var { checked, ...other } = props;
<ide> ```
<ide>
<ide> これは、自分で指定したものは 除き 、全てのpropsを渡すことを保証します。
<ide>
<ide> ```javascript
<del>var FancyCheckbox = React.createClass({
<del> render: function() {
<del> var { checked, ...other } = this.props;
<del> var fancyClass = checked ? 'FancyChecked' : 'FancyUnchecked';
<del> // `other` は { onClick: console.log } を含みますが、 checked プロパティは含みません。
<del> return (
<del> <div {...other} className={fancyClass} />
<del> );
<del> }
<del>});
<add>function FancyCheckbox(props) {
<add> var { checked, ...other } = props;
<add> var fancyClass = checked ? 'FancyChecked' : 'FancyUnchecked';
<add> // `other` は { onClick: console.log } を含みますが、 checked プロパティは含みません。
<add> return (
<add> <div {...other} className={fancyClass} />
<add> );
<add>}
<ide> ReactDOM.render(
<ide> <FancyCheckbox checked={true} onClick={console.log.bind(console)}>
<ide> Hello world!
<ide> ReactDOM.render(
<ide> 未知の `other` propsを移譲する際には、分割代入パターンを常に使ってください。
<ide>
<ide> ```javascript
<del>var FancyCheckbox = React.createClass({
<del> render: function() {
<del> var fancyClass = this.props.checked ? 'FancyChecked' : 'FancyUnchecked';
<del> // アンチパターン: `checked` が内部のコンポーネントに渡されます。
<del> return (
<del> <div {...this.props} className={fancyClass} />
<del> );
<del> }
<del>});
<add>function FancyCheckbox(props) {
<add> var fancyClass = props.checked ? 'FancyChecked' : 'FancyUnchecked';
<add> // アンチパターン: `checked` が内部のコンポーネントに渡されます。
<add> return (
<add> <div {...props} className={fancyClass} />
<add> );
<add>}
<ide> ```
<ide>
<ide> ## 同じpropを使い、移譲する
<ide>
<ide> コンポーネントがプロパティを使うだけでなく、子要素に渡したい場合は、明確に `checked={checked}` と記述することで再度渡すことができます。 `this.props` オブジェクトで全てを渡すほうが、リファクタリングやチェックをしやすいので好ましいです。
<ide>
<ide> ```javascript
<del>var FancyCheckbox = React.createClass({
<del> render: function() {
<del> var { checked, title, ...other } = this.props;
<del> var fancyClass = checked ? 'FancyChecked' : 'FancyUnchecked';
<del> var fancyTitle = checked ? 'X ' + title : 'O ' + title;
<del> return (
<del> <label>
<del> <input {...other}
<del> checked={checked}
<del> className={fancyClass}
<del> type="checkbox"
<del> />
<del> {fancyTitle}
<del> </label>
<del> );
<del> }
<del>});
<add>function FancyCheckbox(props) {
<add> var { checked, title, ...other } = props;
<add> var fancyClass = checked ? 'FancyChecked' : 'FancyUnchecked';
<add> var fancyTitle = checked ? 'X ' + title : 'O ' + title;
<add> return (
<add> <label>
<add> <input {...other}
<add> checked={checked}
<add> className={fancyClass}
<add> type="checkbox"
<add> />
<add> {fancyTitle}
<add> </label>
<add> );
<add>}
<ide> ```
<ide>
<ide> > 注意:
<ide> z; // { a: 3, b: 4 }
<ide> JSXを使わない際には、同じパターンを行うライブラリを使うことができます。Underscoreでは、 `_.omit` を使ってプロパティをフィルタしたり、 `_.extend` を使って新しいオブジェクトにプロパティをコピーしたりできます。
<ide>
<ide> ```javascript
<del>var FancyCheckbox = React.createClass({
<del> render: function() {
<del> var checked = this.props.checked;
<del> var other = _.omit(this.props, 'checked');
<del> var fancyClass = checked ? 'FancyChecked' : 'FancyUnchecked';
<del> return (
<del> React.DOM.div(_.extend({}, other, { className: fancyClass }))
<del> );
<del> }
<del>});
<add>function FancyCheckbox(props) {
<add> var checked = props.checked;
<add> var other = _.omit(props, 'checked');
<add> var fancyClass = checked ? 'FancyChecked' : 'FancyUnchecked';
<add> return (
<add> React.DOM.div(_.extend({}, other, { className: fancyClass }))
<add> );
<add>}
<ide> ```
<ide><path>docs/docs/06-transferring-props.ko-KR.md
<ide> React.createElement(Component, Object.assign({}, this.props, { more: 'values' })
<ide> 대부분의 경우 명시적으로 프로퍼티를 아래로 전달해야 합니다. 이는 동작을 확신하는 내부 API의 일부만 공개하도록 합니다.
<ide>
<ide> ```javascript
<del>var FancyCheckbox = React.createClass({
<del> render: function() {
<del> var fancyClass = this.props.checked ? 'FancyChecked' : 'FancyUnchecked';
<del> return (
<del> <div className={fancyClass} onClick={this.props.onClick}>
<del> {this.props.children}
<del> </div>
<del> );
<del> }
<del>});
<add>function FancyCheckbox(props) {
<add> var fancyClass = props.checked ? 'FancyChecked' : 'FancyUnchecked';
<add> return (
<add> <div className={fancyClass} onClick={props.onClick}>
<add> {props.children}
<add> </div>
<add> );
<add>}
<ide> ReactDOM.render(
<ide> <FancyCheckbox checked={true} onClick={console.log.bind(console)}>
<ide> 세상아 안녕!
<ide> ReactDOM.render(
<ide> 소비할 프로퍼티들을 나열하고, 그 뒤에 `...other`를 넣습니다.
<ide>
<ide> ```javascript
<del>var { checked, ...other } = this.props;
<add>var { checked, ...other } = props;
<ide> ```
<ide>
<ide> 이는 지금 소비한 props를 *제외한* 나머지를 아래로 전달합니다.
<ide>
<ide> ```javascript
<del>var FancyCheckbox = React.createClass({
<del> render: function() {
<del> var { checked, ...other } = this.props;
<del> var fancyClass = checked ? 'FancyChecked' : 'FancyUnchecked';
<del> // `other`에는 { onClick: console.log }가 포함되지만 checked 프로퍼티는 제외됩니다
<del> return (
<del> <div {...other} className={fancyClass} />
<del> );
<del> }
<del>});
<add>function FancyCheckbox(props) {
<add> var { checked, ...other } = props;
<add> var fancyClass = checked ? 'FancyChecked' : 'FancyUnchecked';
<add> // `other`에는 { onClick: console.log }가 포함되지만 checked 프로퍼티는 제외됩니다
<add> return (
<add> <div {...other} className={fancyClass} />
<add> );
<add>}
<ide> ReactDOM.render(
<ide> <FancyCheckbox checked={true} onClick={console.log.bind(console)}>
<ide> 세상아 안녕!
<ide> ReactDOM.render(
<ide> 미상의 `other` props을 전달할 때는 항상 구조 해체 패턴을 사용하세요.
<ide>
<ide> ```javascript
<del>var FancyCheckbox = React.createClass({
<del> render: function() {
<del> var fancyClass = this.props.checked ? 'FancyChecked' : 'FancyUnchecked';
<del> // 반례: `checked` 또한 내부 컴포넌트로 전달될 것입니다
<del> return (
<del> <div {...this.props} className={fancyClass} />
<del> );
<del> }
<del>});
<add>function FancyCheckbox(props) {
<add> var fancyClass = props.checked ? 'FancyChecked' : 'FancyUnchecked';
<add> // 반례: `checked` 또한 내부 컴포넌트로 전달될 것입니다
<add> return (
<add> <div {...props} className={fancyClass} />
<add> );
<add>}
<ide> ```
<ide>
<ide> ## 같은 Prop을 소비하고 전달하기
<ide>
<ide> 컴포넌트가 프로퍼티를 사용하지만 계속 넘기길 원한다면, `checked={checked}`처럼 명시적으로 다시 넘길 수 있습니다. 리팩토링과 린트(lint)하기가 더 쉬우므로 이 방식이 `this.props` 객체 전부를 넘기는 것보다 낫습니다.
<ide>
<ide> ```javascript
<del>var FancyCheckbox = React.createClass({
<del> render: function() {
<del> var { checked, title, ...other } = this.props;
<del> var fancyClass = checked ? 'FancyChecked' : 'FancyUnchecked';
<del> var fancyTitle = checked ? 'X ' + title : 'O ' + title;
<del> return (
<del> <label>
<del> <input {...other}
<del> checked={checked}
<del> className={fancyClass}
<del> type="checkbox"
<del> />
<del> {fancyTitle}
<del> </label>
<del> );
<del> }
<del>});
<add>function FancyCheckbox(props) {
<add> var { checked, title, ...other } = props;
<add> var fancyClass = checked ? 'FancyChecked' : 'FancyUnchecked';
<add> var fancyTitle = checked ? 'X ' + title : 'O ' + title;
<add> return (
<add> <label>
<add> <input {...other}
<add> checked={checked}
<add> className={fancyClass}
<add> type="checkbox"
<add> />
<add> {fancyTitle}
<add> </label>
<add> );
<add>}
<ide> ```
<ide>
<ide> > 주의:
<ide> z; // { a: 3, b: 4 }
<ide> JSX를 사용하지 않는다면 라이브러리를 사용해 같은 패턴을 쓸 수 있습니다. Underscore에서는 `_.omit`을 사용해 특정 프로퍼티를 제외하거나 `_.extend`를 사용해 새로운 객체로 프로퍼티를 복사할 수 있습니다.
<ide>
<ide> ```javascript
<del>var FancyCheckbox = React.createClass({
<del> render: function() {
<del> var checked = this.props.checked;
<del> var other = _.omit(this.props, 'checked');
<del> var fancyClass = checked ? 'FancyChecked' : 'FancyUnchecked';
<del> return (
<del> React.DOM.div(_.extend({}, other, { className: fancyClass }))
<del> );
<del> }
<del>});
<add>function FancyCheckbox(props) {
<add> var checked = props.checked;
<add> var other = _.omit(props, 'checked');
<add> var fancyClass = checked ? 'FancyChecked' : 'FancyUnchecked';
<add> return (
<add> React.DOM.div(_.extend({}, other, { className: fancyClass }))
<add> );
<add>}
<ide> ```
<ide><path>docs/docs/06-transferring-props.md
<ide> The rest of this tutorial explains best practices. It uses JSX and experimental
<ide> Most of the time you should explicitly pass the properties down. This ensures that you only expose a subset of the inner API, one that you know will work.
<ide>
<ide> ```javascript
<del>var FancyCheckbox = React.createClass({
<del> render: function() {
<del> var fancyClass = this.props.checked ? 'FancyChecked' : 'FancyUnchecked';
<del> return (
<del> <div className={fancyClass} onClick={this.props.onClick}>
<del> {this.props.children}
<del> </div>
<del> );
<del> }
<del>});
<add>function FancyCheckbox(props) {
<add> var fancyClass = props.checked ? 'FancyChecked' : 'FancyUnchecked';
<add> return (
<add> <div className={fancyClass} onClick={props.onClick}>
<add> {props.children}
<add> </div>
<add> );
<add>}
<ide> ReactDOM.render(
<ide> <FancyCheckbox checked={true} onClick={console.log.bind(console)}>
<ide> Hello world!
<ide> Sometimes it's fragile and tedious to pass every property along. In that case yo
<ide> List out all the properties that you would like to consume, followed by `...other`.
<ide>
<ide> ```javascript
<del>var { checked, ...other } = this.props;
<add>var { checked, ...other } = props;
<ide> ```
<ide>
<ide> This ensures that you pass down all the props EXCEPT the ones you're consuming yourself.
<ide>
<ide> ```javascript
<del>var FancyCheckbox = React.createClass({
<del> render: function() {
<del> var { checked, ...other } = this.props;
<del> var fancyClass = checked ? 'FancyChecked' : 'FancyUnchecked';
<del> // `other` contains { onClick: console.log } but not the checked property
<del> return (
<del> <div {...other} className={fancyClass} />
<del> );
<del> }
<del>});
<add>function FancyCheckbox(props) {
<add> var { checked, ...other } = props;
<add> var fancyClass = checked ? 'FancyChecked' : 'FancyUnchecked';
<add> // `other` contains { onClick: console.log } but not the checked property
<add> return (
<add> <div {...other} className={fancyClass} />
<add> );
<add>}
<ide> ReactDOM.render(
<ide> <FancyCheckbox checked={true} onClick={console.log.bind(console)}>
<ide> Hello world!
<ide> ReactDOM.render(
<ide> Always use the destructuring pattern when transferring unknown `other` props.
<ide>
<ide> ```javascript
<del>var FancyCheckbox = React.createClass({
<del> render: function() {
<del> var fancyClass = this.props.checked ? 'FancyChecked' : 'FancyUnchecked';
<del> // ANTI-PATTERN: `checked` would be passed down to the inner component
<del> return (
<del> <div {...this.props} className={fancyClass} />
<del> );
<del> }
<del>});
<add>function FancyCheckbox(props) {
<add> var fancyClass = props.checked ? 'FancyChecked' : 'FancyUnchecked';
<add> // ANTI-PATTERN: `checked` would be passed down to the inner component
<add> return (
<add> <div {...props} className={fancyClass} />
<add> );
<add>}
<ide> ```
<ide>
<ide> ## Consuming and Transferring the Same Prop
<ide>
<del>If your component wants to consume a property but also wants to pass it along, you can repass it explicitly with `checked={checked}`. This is preferable to passing the full `this.props` object since it's easier to refactor and lint.
<add>If your component wants to consume a property but also wants to pass it along, you can repass it explicitly with `checked={checked}`. This is preferable to passing the full `props` object since it's easier to refactor and lint.
<ide>
<ide> ```javascript
<del>var FancyCheckbox = React.createClass({
<del> render: function() {
<del> var { checked, title, ...other } = this.props;
<del> var fancyClass = checked ? 'FancyChecked' : 'FancyUnchecked';
<del> var fancyTitle = checked ? 'X ' + title : 'O ' + title;
<del> return (
<del> <label>
<del> <input {...other}
<del> checked={checked}
<del> className={fancyClass}
<del> type="checkbox"
<del> />
<del> {fancyTitle}
<del> </label>
<del> );
<del> }
<del>});
<add>function FancyCheckbox(props) {
<add> var { checked, title, ...other } = props;
<add> var fancyClass = checked ? 'FancyChecked' : 'FancyUnchecked';
<add> var fancyTitle = checked ? 'X ' + title : 'O ' + title;
<add> return (
<add> <label>
<add> <input {...other}
<add> checked={checked}
<add> className={fancyClass}
<add> type="checkbox"
<add> />
<add> {fancyTitle}
<add> </label>
<add> );
<add>}
<ide> ```
<ide>
<ide> > NOTE:
<ide> z; // { a: 3, b: 4 }
<ide> If you don't use JSX, you can use a library to achieve the same pattern. Underscore supports `_.omit` to filter out properties and `_.extend` to copy properties onto a new object.
<ide>
<ide> ```javascript
<del>var FancyCheckbox = React.createClass({
<del> render: function() {
<del> var checked = this.props.checked;
<del> var other = _.omit(this.props, 'checked');
<del> var fancyClass = checked ? 'FancyChecked' : 'FancyUnchecked';
<del> return (
<del> React.DOM.div(_.extend({}, other, { className: fancyClass }))
<del> );
<del> }
<del>});
<add>function FancyCheckbox(props) {
<add> var checked = props.checked;
<add> var other = _.omit(props, 'checked');
<add> var fancyClass = checked ? 'FancyChecked' : 'FancyUnchecked';
<add> return (
<add> React.DOM.div(_.extend({}, other, { className: fancyClass }))
<add> );
<add>}
<ide> ```
<ide><path>docs/docs/06-transferring-props.zh-CN.md
<ide> React.createElement(Component, Object.assign({}, this.props, { more: 'values' })
<ide> 大部分情况下你应该显式地向下传递 props。这样可以确保只公开你认为是安全的内部 API 的子集。
<ide>
<ide> ```javascript
<del>var FancyCheckbox = React.createClass({
<del> render: function() {
<del> var fancyClass = this.props.checked ? 'FancyChecked' : 'FancyUnchecked';
<del> return (
<del> <div className={fancyClass} onClick={this.props.onClick}>
<del> {this.props.children}
<del> </div>
<del> );
<del> }
<del>});
<add>function FancyCheckbox(props) {
<add> var fancyClass = props.checked ? 'FancyChecked' : 'FancyUnchecked';
<add> return (
<add> <div className={fancyClass} onClick={props.onClick}>
<add> {props.children}
<add> </div>
<add> );
<add>}
<ide> ReactDOM.render(
<ide> <FancyCheckbox checked={true} onClick={console.log.bind(console)}>
<ide> Hello world!
<ide> ReactDOM.render(
<ide> 列出所有要当前使用的属性,后面跟着 `...other`。
<ide>
<ide> ```javascript
<del>var { checked, ...other } = this.props;
<add>var { checked, ...other } = props;
<ide> ```
<ide>
<ide> 这样能确保把所有 props 传下去,*除了* 那些已经被使用了的。
<ide>
<ide> ```javascript
<del>var FancyCheckbox = React.createClass({
<del> render: function() {
<del> var { checked, ...other } = this.props;
<del> var fancyClass = checked ? 'FancyChecked' : 'FancyUnchecked';
<del> // `other` 包含 { onClick: console.log } 但 checked 属性除外
<del> return (
<del> <div {...other} className={fancyClass} />
<del> );
<del> }
<del>});
<add>function FancyCheckbox(props) {
<add> var { checked, ...other } = props;
<add> var fancyClass = checked ? 'FancyChecked' : 'FancyUnchecked';
<add> // `other` 包含 { onClick: console.log } 但 checked 属性除外
<add> return (
<add> <div {...other} className={fancyClass} />
<add> );
<add>}
<ide> ReactDOM.render(
<ide> <FancyCheckbox checked={true} onClick={console.log.bind(console)}>
<ide> Hello world!
<ide> ReactDOM.render(
<ide> 在传递这些未知的 `other` 属性时,要经常使用解构赋值模式。
<ide>
<ide> ```javascript
<del>var FancyCheckbox = React.createClass({
<del> render: function() {
<del> var fancyClass = this.props.checked ? 'FancyChecked' : 'FancyUnchecked';
<del> // 反模式:`checked` 会被传到里面的组件里
<del> return (
<del> <div {...this.props} className={fancyClass} />
<del> );
<del> }
<del>});
<add>function FancyCheckbox(props) {
<add> var fancyClass = props.checked ? 'FancyChecked' : 'FancyUnchecked';
<add> // 反模式:`checked` 会被传到里面的组件里
<add> return (
<add> <div {...props} className={fancyClass} />
<add> );
<add>}
<ide> ```
<ide>
<ide> ## 使用和传递同一个 Prop
<ide>
<ide> 如果组件需要使用一个属性又要往下传递,可以直接使用 `checked={checked}` 再传一次。这样做比传整个 `this.props` 对象要好,因为更利于重构和语法检查。
<ide>
<ide> ```javascript
<del>var FancyCheckbox = React.createClass({
<del> render: function() {
<del> var { checked, title, ...other } = this.props;
<del> var fancyClass = checked ? 'FancyChecked' : 'FancyUnchecked';
<del> var fancyTitle = checked ? 'X ' + title : 'O ' + title;
<del> return (
<del> <label>
<del> <input {...other}
<del> checked={checked}
<del> className={fancyClass}
<del> type="checkbox"
<del> />
<del> {fancyTitle}
<del> </label>
<del> );
<del> }
<del>});
<add>function FancyCheckbox(props) {
<add> var { checked, title, ...other } = props;
<add> var fancyClass = checked ? 'FancyChecked' : 'FancyUnchecked';
<add> var fancyTitle = checked ? 'X ' + title : 'O ' + title;
<add> return (
<add> <label>
<add> <input {...other}
<add> checked={checked}
<add> className={fancyClass}
<add> type="checkbox"
<add> />
<add> {fancyTitle}
<add> </label>
<add> );
<add>}
<ide> ```
<ide>
<ide> > 注意:
<ide> z; // { a: 3, b: 4 }
<ide> 如果不使用 JSX,可以使用一些库来实现相同效果。Underscore 提供 `_.omit` 来过滤属性,`_.extend` 复制属性到新的对象。
<ide>
<ide> ```javascript
<del>var FancyCheckbox = React.createClass({
<del> render: function() {
<del> var checked = this.props.checked;
<del> var other = _.omit(this.props, 'checked');
<del> var fancyClass = checked ? 'FancyChecked' : 'FancyUnchecked';
<del> return (
<del> React.DOM.div(_.extend({}, other, { className: fancyClass }))
<del> );
<del> }
<del>});
<add>function FancyCheckbox(props) {
<add> var checked = props.checked;
<add> var other = _.omit(props, 'checked');
<add> var fancyClass = checked ? 'FancyChecked' : 'FancyUnchecked';
<add> return (
<add> React.DOM.div(_.extend({}, other, { className: fancyClass }))
<add> );
<add>}
<ide> ```
<ide><path>docs/tips/14-communicate-between-components.ko-KR.md
<ide> next: expose-component-functions-ko-KR.html
<ide> `GroceryList` 컴포넌트가 배열로 생성된 아이템 목록을 가지고 있다고 해봅시다. 목록의 아이템이 클릭되면 아이템의 이름이 보이길 원할 겁니다:
<ide>
<ide> ```js
<del>var GroceryList = React.createClass({
<del> handleClick: function(i) {
<del> console.log('클릭한 아이템: ' + this.props.items[i]);
<del> },
<add>var handleClick = function(i, props) {
<add> console.log('클릭한 아이템: ' + props.items[i]);
<add>}
<ide>
<del> render: function() {
<del> return (
<del> <div>
<del> {this.props.items.map(function(item, i) {
<del> return (
<del> <div onClick={this.handleClick.bind(this, i)} key={i}>{item}</div>
<del> );
<del> }, this)}
<del> </div>
<del> );
<del> }
<del>});
<add>function GroceryList(props) {
<add> return (
<add> <div>
<add> {props.items.map(function(item, i) {
<add> return (
<add> <div onClick={handleClick.bind(this, i, props)} key={i}>{item}</div>
<add> );
<add> })}
<add> </div>
<add> );
<add>}
<ide>
<ide> ReactDOM.render(
<ide> <GroceryList items={['사과', '바나나', '크랜베리']} />, mountNode
<ide><path>docs/tips/14-communicate-between-components.md
<ide> For child-parent communication:
<ide> Say your `GroceryList` component has a list of items generated through an array. When a list item is clicked, you want to display its name:
<ide>
<ide> ```js
<del>var GroceryList = React.createClass({
<del> handleClick: function(i) {
<del> console.log('You clicked: ' + this.props.items[i]);
<del> },
<add>var handleClick = function(i, props) {
<add> console.log('You clicked: ' + props.items[i]);
<add>}
<ide>
<del> render: function() {
<del> return (
<del> <div>
<del> {this.props.items.map(function(item, i) {
<del> return (
<del> <div onClick={this.handleClick.bind(this, i)} key={i}>{item}</div>
<del> );
<del> }, this)}
<del> </div>
<del> );
<del> }
<del>});
<add>function GroceryList(props) {
<add> return (
<add> <div>
<add> {props.items.map(function(item, i) {
<add> return (
<add> <div onClick={handleClick.bind(this, i, props)} key={i}>{item}</div>
<add> );
<add> })}
<add> </div>
<add> );
<add>}
<ide>
<ide> ReactDOM.render(
<ide> <GroceryList items={['Apple', 'Banana', 'Cranberry']} />, mountNode | 7 |
Ruby | Ruby | improve wording in cache documentation [ci skip] | 5103a5ef4b2ca822b7271d5bfe6892ed3960bca3 | <ide><path>activesupport/lib/active_support/cache.rb
<ide> def exist?(name, options = nil)
<ide> #
<ide> # Options are passed to the underlying cache implementation.
<ide> #
<del> # All implementations may not support this method.
<add> # Some implementations may not support this method.
<ide> def delete_matched(matcher, options = nil)
<ide> raise NotImplementedError.new("#{self.class.name} does not support delete_matched")
<ide> end
<ide> def delete_matched(matcher, options = nil)
<ide> #
<ide> # Options are passed to the underlying cache implementation.
<ide> #
<del> # All implementations may not support this method.
<add> # Some implementations may not support this method.
<ide> def increment(name, amount = 1, options = nil)
<ide> raise NotImplementedError.new("#{self.class.name} does not support increment")
<ide> end
<ide> def increment(name, amount = 1, options = nil)
<ide> #
<ide> # Options are passed to the underlying cache implementation.
<ide> #
<del> # All implementations may not support this method.
<add> # Some implementations may not support this method.
<ide> def decrement(name, amount = 1, options = nil)
<ide> raise NotImplementedError.new("#{self.class.name} does not support decrement")
<ide> end
<ide> def decrement(name, amount = 1, options = nil)
<ide> #
<ide> # Options are passed to the underlying cache implementation.
<ide> #
<del> # All implementations may not support this method.
<add> # Some implementations may not support this method.
<ide> def cleanup(options = nil)
<ide> raise NotImplementedError.new("#{self.class.name} does not support cleanup")
<ide> end
<ide> def cleanup(options = nil)
<ide> #
<ide> # The options hash is passed to the underlying cache implementation.
<ide> #
<del> # All implementations may not support this method.
<add> # Some implementations may not support this method.
<ide> def clear(options = nil)
<ide> raise NotImplementedError.new("#{self.class.name} does not support clear")
<ide> end | 1 |
PHP | PHP | fix failing tests on case-sensitive file systems | cdf32475d5ef4a53819247e547b7446f26b030e5 | <ide><path>src/Console/ShellDispatcher.php
<ide> public function findShell($shell) {
<ide> * @return string|boolean Either the classname or false.
<ide> */
<ide> protected function _shellExists($shell) {
<del> $class = Inflector::camelize($shell);
<add> $class = array_map('Cake\Utility\Inflector::camelize', explode('.', $shell));
<add> $class = implode('.', $class);
<ide> $class = App::classname($class, 'Console/Command', 'Shell');
<ide> if (class_exists($class)) {
<ide> return $class; | 1 |
PHP | PHP | change line length in emails | 7ad11f59bbad6a66a06054dc0daa6bc0a31b7479 | <ide><path>lib/Cake/Network/Email/CakeEmail.php
<ide> protected function _encodeString($text, $charset) {
<ide> * @param string $message Message to wrap
<ide> * @return array Wrapped message
<ide> */
<del> protected function _wrap($message) {
<add> protected function _wrap($message, $wrapLength = CakeEmail::LINE_LENGTH_MUST) {
<ide> $message = str_replace(array("\r\n", "\r"), "\n", $message);
<ide> $lines = explode("\n", $message);
<ide> $formatted = array();
<ide> protected function _wrap($message) {
<ide> continue;
<ide> }
<ide> if (!preg_match('/\<[a-z]/i', $line)) {
<del> $formatted = array_merge($formatted, explode("\n", wordwrap($line, self::LINE_LENGTH_SHOULD, "\n")));
<add> $formatted = array_merge(
<add> $formatted,
<add> explode("\n", wordwrap($line, $wrapLength, "\n"))
<add> );
<ide> continue;
<ide> }
<ide>
<ide> protected function _wrap($message) {
<ide> $tag .= $char;
<ide> if ($char === '>') {
<ide> $tagLength = strlen($tag);
<del> if ($tagLength + $tmpLineLength < self::LINE_LENGTH_SHOULD) {
<add> if ($tagLength + $tmpLineLength < $wrapLength) {
<ide> $tmpLine .= $tag;
<ide> $tmpLineLength += $tagLength;
<ide> } else {
<ide> protected function _wrap($message) {
<ide> $tmpLine = '';
<ide> $tmpLineLength = 0;
<ide> }
<del> if ($tagLength > self::LINE_LENGTH_SHOULD) {
<add> if ($tagLength > $wrapLength) {
<ide> $formatted[] = $tag;
<ide> } else {
<ide> $tmpLine = $tag;
<ide> protected function _wrap($message) {
<ide> $tag = '<';
<ide> continue;
<ide> }
<del> if ($char === ' ' && $tmpLineLength >= self::LINE_LENGTH_SHOULD) {
<add> if ($char === ' ' && $tmpLineLength >= $wrapLength) {
<ide> $formatted[] = $tmpLine;
<ide> $tmpLineLength = 0;
<ide> continue;
<ide> }
<ide> $tmpLine .= $char;
<ide> $tmpLineLength++;
<del> if ($tmpLineLength === self::LINE_LENGTH_SHOULD) {
<add> if ($tmpLineLength === $wrapLength) {
<ide> $nextChar = $line[$i + 1];
<ide> if ($nextChar === ' ' || $nextChar === '<') {
<ide> $formatted[] = trim($tmpLine);
<ide><path>lib/Cake/Test/Case/Network/Email/CakeEmailTest.php
<ide> public function formatAddress($address) {
<ide> * Wrap to protected method
<ide> *
<ide> */
<del> public function wrap($text) {
<del> return parent::_wrap($text);
<add> public function wrap($text, $length = CakeEmail::LINE_LENGTH_MUST) {
<add> return parent::_wrap($text, $length);
<ide> }
<ide>
<ide> /**
<ide> public function testResetWithCharset() {
<ide> */
<ide> public function testWrap() {
<ide> $text = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec ac turpis orci, non commodo odio. Morbi nibh nisi, vehicula pellentesque accumsan amet.';
<del> $result = $this->CakeEmail->wrap($text);
<add> $result = $this->CakeEmail->wrap($text, CakeEmail::LINE_LENGTH_SHOULD);
<ide> $expected = array(
<ide> 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec ac turpis orci,',
<ide> 'non commodo odio. Morbi nibh nisi, vehicula pellentesque accumsan amet.',
<ide> public function testWrap() {
<ide> $this->assertSame($expected, $result);
<ide>
<ide> $text = 'Lorem ipsum dolor sit amet, consectetur < adipiscing elit. Donec ac turpis orci, non commodo odio. Morbi nibh nisi, vehicula > pellentesque accumsan amet.';
<del> $result = $this->CakeEmail->wrap($text);
<add> $result = $this->CakeEmail->wrap($text, CakeEmail::LINE_LENGTH_SHOULD);
<ide> $expected = array(
<ide> 'Lorem ipsum dolor sit amet, consectetur < adipiscing elit. Donec ac turpis',
<ide> 'orci, non commodo odio. Morbi nibh nisi, vehicula > pellentesque accumsan',
<ide> public function testWrap() {
<ide> $this->assertSame($expected, $result);
<ide>
<ide> $text = '<p>Lorem ipsum dolor sit amet,<br> consectetur adipiscing elit.<br> Donec ac turpis orci, non <b>commodo</b> odio. <br /> Morbi nibh nisi, vehicula pellentesque accumsan amet.<hr></p>';
<del> $result = $this->CakeEmail->wrap($text);
<add> $result = $this->CakeEmail->wrap($text, CakeEmail::LINE_LENGTH_SHOULD);
<ide> $expected = array(
<ide> '<p>Lorem ipsum dolor sit amet,<br> consectetur adipiscing elit.<br> Donec ac',
<ide> 'turpis orci, non <b>commodo</b> odio. <br /> Morbi nibh nisi, vehicula',
<ide> public function testWrap() {
<ide> $this->assertSame($expected, $result);
<ide>
<ide> $text = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec ac <a href="http://cakephp.org">turpis</a> orci, non commodo odio. Morbi nibh nisi, vehicula pellentesque accumsan amet.';
<del> $result = $this->CakeEmail->wrap($text);
<add> $result = $this->CakeEmail->wrap($text, CakeEmail::LINE_LENGTH_SHOULD);
<ide> $expected = array(
<ide> 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec ac',
<ide> '<a href="http://cakephp.org">turpis</a> orci, non commodo odio. Morbi nibh',
<ide> public function testWrap() {
<ide> $this->assertSame($expected, $result);
<ide>
<ide> $text = 'Lorem ipsum <a href="http://www.cakephp.org/controller/action/param1/param2" class="nice cool fine amazing awesome">ok</a>';
<del> $result = $this->CakeEmail->wrap($text);
<add> $result = $this->CakeEmail->wrap($text, CakeEmail::LINE_LENGTH_SHOULD);
<ide> $expected = array(
<ide> 'Lorem ipsum',
<ide> '<a href="http://www.cakephp.org/controller/action/param1/param2" class="nice cool fine amazing awesome">',
<ide> public function testWrap() {
<ide> $this->assertSame($expected, $result);
<ide>
<ide> $text = 'Lorem ipsum withonewordverybigMorethanthelineshouldsizeofrfcspecificationbyieeeavailableonieeesite ok.';
<del> $result = $this->CakeEmail->wrap($text);
<add> $result = $this->CakeEmail->wrap($text, CakeEmail::LINE_LENGTH_SHOULD);
<ide> $expected = array(
<ide> 'Lorem ipsum',
<ide> 'withonewordverybigMorethanthelineshouldsizeofrfcspecificationbyieeeavailableonieeesite', | 2 |
Python | Python | add support for fujitsu compiler to numpy. | 4950fd10e678faea859fc8d8bd5d7ea9df2007b1 | <ide><path>numpy/distutils/fcompiler/__init__.py
<ide> def wrap_unlinkable_objects(self, objects, output_dir, extra_dll_dir):
<ide> 'intelvem', 'intelem', 'flang')),
<ide> ('cygwin.*', ('gnu', 'intelv', 'absoft', 'compaqv', 'intelev', 'gnu95', 'g95')),
<ide> ('linux.*', ('gnu95', 'intel', 'lahey', 'pg', 'nv', 'absoft', 'nag', 'vast', 'compaq',
<del> 'intele', 'intelem', 'gnu', 'g95', 'pathf95', 'nagfor')),
<add> 'intele', 'intelem', 'gnu', 'g95', 'pathf95', 'nagfor', 'fujitsu')),
<ide> ('darwin.*', ('gnu95', 'nag', 'absoft', 'ibm', 'intel', 'gnu', 'g95', 'pg')),
<ide> ('sunos.*', ('sun', 'gnu', 'gnu95', 'g95')),
<ide> ('irix.*', ('mips', 'gnu', 'gnu95',)),
<ide><path>numpy/distutils/fcompiler/fujitsu.py
<add>"""
<add>fujitsu
<add>
<add>Supports Fujitsu compiler function.
<add>This compiler is developed by Fujitsu and is used in A64FX on Fugaku.
<add>"""
<add>from numpy.distutils.fcompiler import FCompiler
<add>
<add>compilers = ['FujitsuFCompiler']
<add>
<add>class FujitsuFCompiler(FCompiler):
<add> compiler_type = 'fujitsu'
<add> description = 'Fujitsu Fortran Compiler'
<add>
<add> possible_executables = ['frt']
<add> version_pattern = r'frt \(FRT\) (?P<version>[a-z\d.]+)'
<add> # $ frt --version
<add> # frt (FRT) x.x.x yyyymmdd
<add>
<add> executables = {
<add> 'version_cmd' : ["<F77>", "--version"],
<add> 'compiler_f77' : ["frt", "-Fixed"],
<add> 'compiler_fix' : ["frt", "-Fixed"],
<add> 'compiler_f90' : ["frt"],
<add> 'linker_so' : ["frt", "-shared"],
<add> 'archiver' : ["ar", "-cr"],
<add> 'ranlib' : ["ranlib"]
<add> }
<add> pic_flags = ['-KPIC']
<add> module_dir_switch = '-M'
<add> module_include_switch = '-I'
<add>
<add> def get_flags_opt(self):
<add> return ['-O3']
<add> def get_flags_debug(self):
<add> return ['-g']
<add> def runtime_library_dir_option(self, dir):
<add> return f'-Wl,-rpath={dir}'
<add> def get_libraries(self):
<add> return ['fj90f', 'fj90i', 'fjsrcinfo']
<add>
<add>if __name__ == '__main__':
<add> from distutils import log
<add> from numpy.distutils import customized_fcompiler
<add> log.set_verbosity(2)
<add> print(customized_fcompiler('fujitsu').get_version())
<ide><path>numpy/tests/test_public_api.py
<ide> def test_NPY_NO_EXPORT():
<ide> "distutils.fcompiler.nv",
<ide> "distutils.fcompiler.sun",
<ide> "distutils.fcompiler.vast",
<add> "distutils.fcompiler.fujitsu",
<ide> "distutils.from_template",
<ide> "distutils.intelccompiler",
<ide> "distutils.lib2def", | 3 |
PHP | PHP | allow various methods of passing token | 939cc94812c1f2e6be155410681de1ddbd7d6b82 | <ide><path>src/Illuminate/Auth/TokenGuard.php
<ide>
<ide> namespace Illuminate\Auth;
<ide>
<add>use Illuminate\Support\Str;
<ide> use Illuminate\Http\Request;
<ide> use Illuminate\Contracts\Auth\Guard;
<ide> use Illuminate\Contracts\Auth\UserProvider;
<ide> public function user()
<ide>
<ide> $user = null;
<ide>
<del> $token = $this->request->input($this->inputKey);
<add> $token = $this->getTokenForRequest();
<ide>
<del> if (! is_null($token)) {
<add> if (! empty($token)) {
<ide> $user = $this->provider->retrieveByCredentials(
<ide> [$this->storageKey => $token]
<ide> );
<ide> public function user()
<ide> return $this->user = $user;
<ide> }
<ide>
<add> /**
<add> * Get the token for the current request.
<add> *
<add> * @return string
<add> */
<add> protected function getTokenForRequest()
<add> {
<add> $token = $this->request->input($this->inputKey);
<add>
<add> if (empty($token)) {
<add> $token = $this->request->getPassword();
<add> }
<add>
<add> if (empty($token)) {
<add> $header = $this->request->header('Authorization');
<add>
<add> if (Str::startsWith($header, 'Bearer ')) {
<add> $token = Str::substr($header, 7);
<add> }
<add> }
<add>
<add> return $token;
<add> }
<add>
<ide> /**
<ide> * Get the ID for the currently authenticated user.
<ide> * | 1 |
Ruby | Ruby | fix regex for comments | bf4f871f23c1746c7dfd62ccab0c7bc054ce361c | <ide><path>activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
<ide> class AbstractAdapter
<ide> include Savepoints
<ide>
<ide> SIMPLE_INT = /\A\d+\z/
<del> COMMENT_REGEX = %r{/\*(?:[^*]|\*[^/])*\*/}m
<add> COMMENT_REGEX = %r{(?:--.*\n)*|/\*(?:[^*]|\*[^/])*\*/}m
<ide>
<ide> attr_accessor :pool
<ide> attr_reader :visitor, :owner, :logger, :lock | 1 |
Ruby | Ruby | remember the parameter hash we return | b7ac0790682e0a56b406127891dfefc15a5eaa64 | <ide><path>actionpack/lib/action_dispatch/http/parameters.rb
<ide> def path_parameters=(parameters) #:nodoc:
<ide> #
<ide> # {'action' => 'my_action', 'controller' => 'my_controller'}
<ide> def path_parameters
<del> get_header(PARAMETERS_KEY) || {}
<add> get_header(PARAMETERS_KEY) || set_header(PARAMETERS_KEY, {})
<ide> end
<ide>
<ide> private | 1 |
Python | Python | fix recurrent layers issue | 2082bafd183eb6fea4778701f4c2c047970014f4 | <ide><path>keras/layers/recurrent.py
<ide> def __init__(self, return_sequences=False,
<ide> self.go_backwards = go_backwards
<ide> self.stateful = stateful
<ide> self.unroll = unroll
<del> self.implementation = 0
<add> self.implementation = implementation
<ide> self.supports_masking = True
<ide> self.input_spec = InputSpec(ndim=3)
<ide> self.state_spec = None
<ide> def step(self, inputs, states):
<ide> x_h = K.dot(inputs * dp_mask[2], self.kernel_h)
<ide> if self.use_bias:
<ide> x_z = K.bias_add(x_z, self.bias_z)
<del> x_r = K.bias_add(self.bias_r)
<del> x_h = K.bias_add(self.bias_h)
<add> x_r = K.bias_add(x_r, self.bias_r)
<add> x_h = K.bias_add(x_r, self.bias_h)
<ide> else:
<ide> raise ValueError('Unknown `implementation` mode.')
<ide> z = self.recurrent_activation(x_z + K.dot(h_tm1 * rec_dp_mask[0], | 1 |
Ruby | Ruby | remove some 10.5 hacks | be9c5d5d16332ffa888853745c7792a0c8bffd9c | <ide><path>Library/Homebrew/download_strategy.rb
<ide> def fetch_repo target, url, revision=nil, ignore_externals=false
<ide> # cache as it will make any changes to get the right revision.
<ide> svncommand = target.directory? ? 'up' : 'checkout'
<ide> args = ['svn', svncommand] + fetch_args
<del> # SVN shipped with XCode 3.1.4 can't force a checkout.
<del> args << '--force' unless MacOS.version == :leopard
<ide> args << url unless target.directory?
<ide> args << target
<ide> args << '-r' << revision if revision
<ide><path>Library/Homebrew/utils.rb
<ide> def curl *args
<ide> flags = flags.delete("#") if ARGV.verbose?
<ide>
<ide> args = [flags, HOMEBREW_USER_AGENT, *args]
<del> # See https://github.com/Homebrew/homebrew/issues/6103
<del> args << "--insecure" if MacOS.version < "10.6"
<ide> args << "--verbose" if ENV['HOMEBREW_CURL_VERBOSE']
<ide> args << "--silent" unless $stdout.tty?
<ide> | 2 |
Javascript | Javascript | add gc test for disabled asynclocalstorage | 96e70c4ce786f43de16a0267a92ee73abf218356 | <ide><path>test/async-hooks/test-async-local-storage-gcable.js
<add>'use strict';
<add>// Flags: --expose_gc
<add>
<add>// This test ensures that AsyncLocalStorage gets gced once it was disabled
<add>// and no strong references remain in userland.
<add>
<add>const common = require('../common');
<add>const { AsyncLocalStorage } = require('async_hooks');
<add>const onGC = require('../common/ongc');
<add>
<add>let asyncLocalStorage = new AsyncLocalStorage();
<add>
<add>asyncLocalStorage.runSyncAndReturn({}, () => {
<add> asyncLocalStorage.disable();
<add>
<add> onGC(asyncLocalStorage, { ongc: common.mustCall() });
<add>});
<add>
<add>asyncLocalStorage = null;
<add>global.gc(); | 1 |
Python | Python | check extra action func.__name__ | 1e383f103a1a84461e949e59b001ee61a2e0f7c4 | <ide><path>rest_framework/viewsets.py
<ide> def _is_extra_action(attr):
<ide> return hasattr(attr, 'mapping') and isinstance(attr.mapping, MethodMapper)
<ide>
<ide>
<add>def _check_attr_name(func, name):
<add> assert func.__name__ == name, (
<add> 'Expected function (`{func.__name__}`) to match its attribute name '
<add> '(`{name}`). If using a decorator, ensure the inner function is '
<add> 'decorated with `functools.wraps`, or that `{func.__name__}.__name__` '
<add> 'is otherwise set to `{name}`.').format(func=func, name=name)
<add> return func
<add>
<add>
<ide> class ViewSetMixin:
<ide> """
<ide> This is the magic.
<ide> def get_extra_actions(cls):
<ide> """
<ide> Get the methods that are marked as an extra ViewSet `@action`.
<ide> """
<del> return [method for _, method in getmembers(cls, _is_extra_action)]
<add> return [_check_attr_name(method, name)
<add> for name, method
<add> in getmembers(cls, _is_extra_action)]
<ide>
<ide> def get_extra_action_url_map(self):
<ide> """
<ide><path>tests/test_viewsets.py
<ide> from collections import OrderedDict
<add>from functools import wraps
<ide>
<ide> import pytest
<ide> from django.conf.urls import include, url
<ide> class Action(models.Model):
<ide> pass
<ide>
<ide>
<add>def decorate(fn):
<add> @wraps(fn)
<add> def wrapper(self, request, *args, **kwargs):
<add> return fn(self, request, *args, **kwargs)
<add> return wrapper
<add>
<add>
<ide> class ActionViewSet(GenericViewSet):
<ide> queryset = Action.objects.all()
<ide>
<ide> def custom_detail_action(self, request, *args, **kwargs):
<ide> def unresolvable_detail_action(self, request, *args, **kwargs):
<ide> raise NotImplementedError
<ide>
<add> @action(detail=False)
<add> @decorate
<add> def wrapped_list_action(self, request, *args, **kwargs):
<add> raise NotImplementedError
<add>
<add> @action(detail=True)
<add> @decorate
<add> def wrapped_detail_action(self, request, *args, **kwargs):
<add> raise NotImplementedError
<add>
<ide>
<ide> class ActionNamesViewSet(GenericViewSet):
<ide>
<ide> def test_extra_actions(self):
<ide> 'detail_action',
<ide> 'list_action',
<ide> 'unresolvable_detail_action',
<add> 'wrapped_detail_action',
<add> 'wrapped_list_action',
<ide> ]
<ide>
<ide> self.assertEqual(actual, expected)
<ide> def test_should_only_return_decorated_methods(self):
<ide> 'detail_action',
<ide> 'list_action',
<ide> 'unresolvable_detail_action',
<add> 'wrapped_detail_action',
<add> 'wrapped_list_action',
<ide> ]
<ide> self.assertEqual(actual, expected)
<ide>
<add> def test_attr_name_check(self):
<add> def decorate(fn):
<add> def wrapper(self, request, *args, **kwargs):
<add> return fn(self, request, *args, **kwargs)
<add> return wrapper
<add>
<add> class ActionViewSet(GenericViewSet):
<add> queryset = Action.objects.all()
<add>
<add> @action(detail=False)
<add> @decorate
<add> def wrapped_list_action(self, request, *args, **kwargs):
<add> raise NotImplementedError
<add>
<add> view = ActionViewSet()
<add> with pytest.raises(AssertionError) as excinfo:
<add> view.get_extra_actions()
<add>
<add> assert str(excinfo.value) == (
<add> 'Expected function (`wrapper`) to match its attribute name '
<add> '(`wrapped_list_action`). If using a decorator, ensure the inner '
<add> 'function is decorated with `functools.wraps`, or that '
<add> '`wrapper.__name__` is otherwise set to `wrapped_list_action`.')
<add>
<ide>
<ide> @override_settings(ROOT_URLCONF='tests.test_viewsets')
<ide> class GetExtraActionUrlMapTests(TestCase):
<ide> def test_list_view(self):
<ide> expected = OrderedDict([
<ide> ('Custom list action', 'http://testserver/api/actions/custom_list_action/'),
<ide> ('List action', 'http://testserver/api/actions/list_action/'),
<add> ('Wrapped list action', 'http://testserver/api/actions/wrapped_list_action/'),
<ide> ])
<ide>
<ide> self.assertEqual(view.get_extra_action_url_map(), expected)
<ide> def test_detail_view(self):
<ide> expected = OrderedDict([
<ide> ('Custom detail action', 'http://testserver/api/actions/1/custom_detail_action/'),
<ide> ('Detail action', 'http://testserver/api/actions/1/detail_action/'),
<add> ('Wrapped detail action', 'http://testserver/api/actions/1/wrapped_detail_action/'),
<ide> # "Unresolvable detail action" excluded, since it's not resolvable
<ide> ])
<ide> | 2 |
Go | Go | fix panic in getremoteimagelayer | 9c413e3e6f1c6bd6abada707c442862049d29743 | <ide><path>registry/session.go
<ide> func (r *Session) GetRemoteImageLayer(imgID, registry string, token []string, im
<ide> for i := 1; i <= retries; i++ {
<ide> res, client, err = r.doRequest(req)
<ide> if err != nil {
<del> res.Body.Close()
<add> if res.Body != nil {
<add> res.Body.Close()
<add> }
<ide> if i == retries {
<ide> return nil, fmt.Errorf("Server error: Status %d while fetching image layer (%s)",
<ide> res.StatusCode, imgID) | 1 |
Ruby | Ruby | move type annotations into files | 24ae318a3d5f0519f5fe29d08e01e8a044d99d87 | <ide><path>Library/Homebrew/PATH.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> # Represention of a `*PATH` environment variable.
<ide><path>Library/Homebrew/bintray.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "utils/curl"
<ide><path>Library/Homebrew/brew.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> if ENV["HOMEBREW_STACKPROF"]
<ide><path>Library/Homebrew/build.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> # This script is loaded by formula_installer as a separate instance.
<ide><path>Library/Homebrew/build_environment.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> # Settings for the build environment.
<ide><path>Library/Homebrew/build_options.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> # Options for a formula build.
<ide><path>Library/Homebrew/cache_store.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> require "json"
<ide><path>Library/Homebrew/cask.rb
<add># typed: strict
<ide> # frozen_string_literal: true
<ide>
<ide> require "cask/artifact"
<ide><path>Library/Homebrew/cask/artifact.rb
<add># typed: strict
<ide> # frozen_string_literal: true
<ide>
<ide> require "cask/artifact/app"
<ide><path>Library/Homebrew/cask/artifact/abstract_artifact.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> module Cask
<ide><path>Library/Homebrew/cask/artifact/abstract_flight_block.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> require "cask/artifact/abstract_artifact"
<ide><path>Library/Homebrew/cask/artifact/abstract_uninstall.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "timeout"
<ide><path>Library/Homebrew/cask/artifact/app.rb
<add># typed: strict
<ide> # frozen_string_literal: true
<ide>
<ide> require "cask/artifact/moved"
<ide><path>Library/Homebrew/cask/artifact/artifact.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "cask/artifact/moved"
<ide><path>Library/Homebrew/cask/artifact/audio_unit_plugin.rb
<add># typed: strict
<ide> # frozen_string_literal: true
<ide>
<ide> require "cask/artifact/moved"
<ide><path>Library/Homebrew/cask/artifact/binary.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> require "cask/artifact/symlinked"
<ide><path>Library/Homebrew/cask/artifact/colorpicker.rb
<add># typed: strict
<ide> # frozen_string_literal: true
<ide>
<ide> require "cask/artifact/moved"
<ide><path>Library/Homebrew/cask/artifact/dictionary.rb
<add># typed: strict
<ide> # frozen_string_literal: true
<ide>
<ide> require "cask/artifact/moved"
<ide><path>Library/Homebrew/cask/artifact/font.rb
<add># typed: strict
<ide> # frozen_string_literal: true
<ide>
<ide> require "cask/artifact/moved"
<ide><path>Library/Homebrew/cask/artifact/input_method.rb
<add># typed: strict
<ide> # frozen_string_literal: true
<ide>
<ide> require "cask/artifact/moved"
<ide><path>Library/Homebrew/cask/artifact/installer.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "cask/artifact/abstract_artifact"
<ide><path>Library/Homebrew/cask/artifact/internet_plugin.rb
<add># typed: strict
<ide> # frozen_string_literal: true
<ide>
<ide> require "cask/artifact/moved"
<ide><path>Library/Homebrew/cask/artifact/manpage.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> require "cask/artifact/symlinked"
<ide><path>Library/Homebrew/cask/artifact/mdimporter.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "cask/artifact/moved"
<ide><path>Library/Homebrew/cask/artifact/moved.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "cask/artifact/relocated"
<ide><path>Library/Homebrew/cask/artifact/pkg.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "plist"
<ide><path>Library/Homebrew/cask/artifact/postflight_block.rb
<add># typed: strict
<ide> # frozen_string_literal: true
<ide>
<ide> require "cask/artifact/abstract_flight_block"
<ide><path>Library/Homebrew/cask/artifact/preflight_block.rb
<add># typed: strict
<ide> # frozen_string_literal: true
<ide>
<ide> require "cask/artifact/abstract_flight_block"
<ide><path>Library/Homebrew/cask/artifact/prefpane.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> require "cask/artifact/moved"
<ide><path>Library/Homebrew/cask/artifact/qlplugin.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "cask/artifact/moved"
<ide><path>Library/Homebrew/cask/artifact/relocated.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> require "cask/artifact/abstract_artifact"
<ide><path>Library/Homebrew/cask/artifact/screen_saver.rb
<add># typed: strict
<ide> # frozen_string_literal: true
<ide>
<ide> require "cask/artifact/moved"
<ide><path>Library/Homebrew/cask/artifact/service.rb
<add># typed: strict
<ide> # frozen_string_literal: true
<ide>
<ide> require "cask/artifact/moved"
<ide><path>Library/Homebrew/cask/artifact/stage_only.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> require "cask/artifact/abstract_artifact"
<ide><path>Library/Homebrew/cask/artifact/suite.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> require "cask/artifact/moved"
<ide><path>Library/Homebrew/cask/artifact/symlinked.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "cask/artifact/relocated"
<ide><path>Library/Homebrew/cask/artifact/uninstall.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "cask/artifact/abstract_uninstall"
<ide><path>Library/Homebrew/cask/artifact/vst3_plugin.rb
<add># typed: strict
<ide> # frozen_string_literal: true
<ide>
<ide> require "cask/artifact/moved"
<ide><path>Library/Homebrew/cask/artifact/vst_plugin.rb
<add># typed: strict
<ide> # frozen_string_literal: true
<ide>
<ide> require "cask/artifact/moved"
<ide><path>Library/Homebrew/cask/artifact/zap.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "cask/artifact/abstract_uninstall"
<ide><path>Library/Homebrew/cask/audit.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "cask/denylist"
<ide><path>Library/Homebrew/cask/auditor.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> require "cask/audit"
<ide><path>Library/Homebrew/cask/cache.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> module Cask
<ide><path>Library/Homebrew/cask/cask.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "cask/cask_loader"
<ide><path>Library/Homebrew/cask/cask_loader.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "cask/cache"
<ide><path>Library/Homebrew/cask/caskroom.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "utils/user"
<ide><path>Library/Homebrew/cask/cmd.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "optparse"
<ide><path>Library/Homebrew/cask/cmd/--cache.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> module Cask
<ide><path>Library/Homebrew/cask/cmd/abstract_command.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "search"
<ide><path>Library/Homebrew/cask/cmd/abstract_internal_command.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> module Cask
<ide><path>Library/Homebrew/cask/cmd/audit.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "utils/github/actions"
<ide><path>Library/Homebrew/cask/cmd/cat.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> module Cask
<ide><path>Library/Homebrew/cask/cmd/create.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> module Cask
<ide><path>Library/Homebrew/cask/cmd/doctor.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> module Cask
<ide><path>Library/Homebrew/cask/cmd/edit.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> module Cask
<ide><path>Library/Homebrew/cask/cmd/fetch.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> module Cask
<ide><path>Library/Homebrew/cask/cmd/help.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> module Cask
<ide><path>Library/Homebrew/cask/cmd/home.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> module Cask
<ide><path>Library/Homebrew/cask/cmd/info.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "json"
<ide><path>Library/Homebrew/cask/cmd/install.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> module Cask
<ide><path>Library/Homebrew/cask/cmd/internal_help.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> module Cask
<ide><path>Library/Homebrew/cask/cmd/internal_stanza.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "cask/dsl"
<ide><path>Library/Homebrew/cask/cmd/list.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "cask/artifact/relocated"
<ide><path>Library/Homebrew/cask/cmd/outdated.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> module Cask
<ide><path>Library/Homebrew/cask/cmd/reinstall.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> module Cask
<ide><path>Library/Homebrew/cask/cmd/style.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "json"
<ide><path>Library/Homebrew/cask/cmd/uninstall.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> module Cask
<ide><path>Library/Homebrew/cask/cmd/upgrade.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "env_config"
<ide><path>Library/Homebrew/cask/cmd/zap.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> module Cask
<ide><path>Library/Homebrew/cask/config.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "json"
<ide><path>Library/Homebrew/cask/denylist.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> module Cask
<ide><path>Library/Homebrew/cask/download.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> require "fileutils"
<ide><path>Library/Homebrew/cask/dsl.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "locale"
<ide><path>Library/Homebrew/cask/dsl/appcast.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> module Cask
<ide><path>Library/Homebrew/cask/dsl/base.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "cask/utils"
<ide><path>Library/Homebrew/cask/dsl/caveats.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> module Cask
<ide><path>Library/Homebrew/cask/dsl/conflicts_with.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "delegate"
<ide><path>Library/Homebrew/cask/dsl/container.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> require "unpack_strategy"
<ide><path>Library/Homebrew/cask/dsl/depends_on.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "delegate"
<ide><path>Library/Homebrew/cask/dsl/postflight.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> require "cask/staged"
<ide><path>Library/Homebrew/cask/dsl/preflight.rb
<add># typed: strict
<ide> # frozen_string_literal: true
<ide>
<ide> module Cask
<ide><path>Library/Homebrew/cask/dsl/uninstall_postflight.rb
<add># typed: strict
<ide> # frozen_string_literal: true
<ide>
<ide> module Cask
<ide><path>Library/Homebrew/cask/dsl/uninstall_preflight.rb
<add># typed: strict
<ide> # frozen_string_literal: true
<ide>
<ide> require "cask/staged"
<ide><path>Library/Homebrew/cask/dsl/version.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> module Cask
<ide><path>Library/Homebrew/cask/exceptions.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> module Cask
<ide><path>Library/Homebrew/cask/installer.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "formula_installer"
<ide><path>Library/Homebrew/cask/macos.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> require "os/mac/version"
<ide><path>Library/Homebrew/cask/metadata.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> module Cask
<ide><path>Library/Homebrew/cask/pkg.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> require "cask/macos"
<ide><path>Library/Homebrew/cask/quarantine.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "development_tools"
<ide><path>Library/Homebrew/cask/staged.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "utils/user"
<ide><path>Library/Homebrew/cask/topological_hash.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "tsort"
<ide><path>Library/Homebrew/cask/url.rb
<del># typed: strict
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> # Class corresponding to the `url` stanza.
<ide><path>Library/Homebrew/cask/utils.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "utils/user"
<ide><path>Library/Homebrew/cask/verify.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> module Cask
<ide><path>Library/Homebrew/cask_dependent.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> # An adapter for casks to provide dependency information in a formula-like interface
<ide><path>Library/Homebrew/caveats.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "language/python"
<ide><path>Library/Homebrew/checksum.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> # A formula's checksum.
<ide><path>Library/Homebrew/cleaner.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> # Cleans a newly installed keg.
<ide><path>Library/Homebrew/cleanup.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "utils/bottles"
<ide><path>Library/Homebrew/cli/args.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> require "cli/named_args"
<ide><path>Library/Homebrew/cli/named_args.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "delegate"
<ide><path>Library/Homebrew/cli/parser.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "env_config"
<ide><path>Library/Homebrew/cmd/--cache.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "fetch"
<ide><path>Library/Homebrew/cmd/--caskroom.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> module Homebrew
<ide><path>Library/Homebrew/cmd/--cellar.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "cli/parser"
<ide><path>Library/Homebrew/cmd/--env.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "extend/ENV"
<ide><path>Library/Homebrew/cmd/--prefix.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "cli/parser"
<ide><path>Library/Homebrew/cmd/--repository.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "cli/parser"
<ide><path>Library/Homebrew/cmd/--version.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "cli/parser"
<ide><path>Library/Homebrew/cmd/analytics.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "cli/parser"
<ide><path>Library/Homebrew/cmd/cask.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "cask/cmd"
<ide><path>Library/Homebrew/cmd/cleanup.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "cleanup"
<ide><path>Library/Homebrew/cmd/commands.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "cli/parser"
<ide><path>Library/Homebrew/cmd/config.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "system_config"
<ide><path>Library/Homebrew/cmd/deps.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "formula"
<ide><path>Library/Homebrew/cmd/desc.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "descriptions"
<ide><path>Library/Homebrew/cmd/doctor.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "diagnostic"
<ide><path>Library/Homebrew/cmd/fetch.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "formula"
<ide><path>Library/Homebrew/cmd/gist-logs.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "formula"
<ide><path>Library/Homebrew/cmd/help.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> require "help"
<ide><path>Library/Homebrew/cmd/home.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "cli/parser"
<ide><path>Library/Homebrew/cmd/info.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "missing_formula"
<ide><path>Library/Homebrew/cmd/install.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "cask/config"
<ide><path>Library/Homebrew/cmd/leaves.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "formula"
<ide><path>Library/Homebrew/cmd/link.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "ostruct"
<ide><path>Library/Homebrew/cmd/list.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "metafiles"
<ide><path>Library/Homebrew/cmd/log.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "formula"
<ide><path>Library/Homebrew/cmd/migrate.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "migrator"
<ide><path>Library/Homebrew/cmd/missing.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "formula"
<ide><path>Library/Homebrew/cmd/options.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "formula"
<ide><path>Library/Homebrew/cmd/outdated.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "formula"
<ide><path>Library/Homebrew/cmd/pin.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "formula"
<ide><path>Library/Homebrew/cmd/postinstall.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "sandbox"
<ide><path>Library/Homebrew/cmd/readall.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "readall"
<ide><path>Library/Homebrew/cmd/reinstall.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "formula_installer"
<ide><path>Library/Homebrew/cmd/search.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "formula"
<ide><path>Library/Homebrew/cmd/switch.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "formula"
<ide><path>Library/Homebrew/cmd/tap-info.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "cli/parser"
<ide><path>Library/Homebrew/cmd/tap.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "cli/parser"
<ide><path>Library/Homebrew/cmd/uninstall.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "keg"
<ide><path>Library/Homebrew/cmd/unlink.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "ostruct"
<ide><path>Library/Homebrew/cmd/unpin.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "formula"
<ide><path>Library/Homebrew/cmd/untap.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "cli/parser"
<ide><path>Library/Homebrew/cmd/update-report.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "formula_versions"
<ide><path>Library/Homebrew/cmd/upgrade.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "cli/parser"
<ide><path>Library/Homebrew/cmd/uses.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> # `brew uses foo bar` returns formulae that use both foo and bar
<ide><path>Library/Homebrew/commands.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "cask/cmd"
<ide><path>Library/Homebrew/compat.rb
<add># typed: strict
<ide> # frozen_string_literal: true
<ide>
<ide> require "compat/dependencies_helpers"
<ide><path>Library/Homebrew/compat/cli/parser.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> module Homebrew
<ide><path>Library/Homebrew/compat/dependencies_helpers.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> require "cli/args"
<ide><path>Library/Homebrew/compat/extend/nil.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> class NilClass
<ide><path>Library/Homebrew/compat/extend/string.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> class String
<ide><path>Library/Homebrew/compat/formula.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> class Formula
<ide><path>Library/Homebrew/compat/language/haskell.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> module Language
<ide><path>Library/Homebrew/compat/language/java.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> module Language
<ide><path>Library/Homebrew/compat/language/python.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> module Language
<ide><path>Library/Homebrew/compat/os/mac.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> module OS
<ide><path>Library/Homebrew/compilers.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> # @private
<ide><path>Library/Homebrew/config.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> raise "HOMEBREW_BREW_FILE was not exported! Please call bin/brew directly!" unless ENV["HOMEBREW_BREW_FILE"]
<ide><path>Library/Homebrew/context.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> require "monitor"
<ide><path>Library/Homebrew/cxxstdlib.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> require "compilers"
<ide><path>Library/Homebrew/debrew.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "mutex_m"
<ide><path>Library/Homebrew/debrew/irb.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> require "irb"
<ide><path>Library/Homebrew/dependable.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> require "options"
<ide><path>Library/Homebrew/dependencies.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "delegate"
<ide><path>Library/Homebrew/dependencies_helpers.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> require "cask_dependent"
<ide><path>Library/Homebrew/dependency.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "dependable"
<ide><path>Library/Homebrew/dependency_collector.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> require "dependency"
<ide><path>Library/Homebrew/deprecate_disable.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> # Helper module for handling disable! and deprecate!
<ide><path>Library/Homebrew/description_cache_store.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> require "set"
<ide><path>Library/Homebrew/descriptions.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> require "formula"
<ide><path>Library/Homebrew/dev-cmd/audit.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "formula"
<ide><path>Library/Homebrew/dev-cmd/bottle.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "formula"
<ide><path>Library/Homebrew/dev-cmd/bump-cask-pr.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "cask"
<ide><path>Library/Homebrew/dev-cmd/bump-formula-pr.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "formula"
<ide><path>Library/Homebrew/dev-cmd/bump-revision.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "formula"
<ide><path>Library/Homebrew/dev-cmd/bump.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "cli/parser"
<ide><path>Library/Homebrew/dev-cmd/cat.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "cli/parser"
<ide><path>Library/Homebrew/dev-cmd/command.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "commands"
<ide><path>Library/Homebrew/dev-cmd/create.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "formula"
<ide><path>Library/Homebrew/dev-cmd/diy.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "formula"
<ide><path>Library/Homebrew/dev-cmd/edit.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "formula"
<ide><path>Library/Homebrew/dev-cmd/extract.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "cli/parser"
<ide><path>Library/Homebrew/dev-cmd/formula.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "formula"
<ide><path>Library/Homebrew/dev-cmd/install-bundler-gems.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "formula"
<ide><path>Library/Homebrew/dev-cmd/irb.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "cli/parser"
<ide><path>Library/Homebrew/dev-cmd/linkage.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "cache_store"
<ide><path>Library/Homebrew/dev-cmd/livecheck.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "cli/parser"
<ide><path>Library/Homebrew/dev-cmd/man.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "formula"
<ide><path>Library/Homebrew/dev-cmd/mirror.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "bintray"
<ide><path>Library/Homebrew/dev-cmd/pr-automerge.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "cli/parser"
<ide><path>Library/Homebrew/dev-cmd/pr-publish.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "cli/parser"
<ide><path>Library/Homebrew/dev-cmd/pr-pull.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "download_strategy"
<ide><path>Library/Homebrew/dev-cmd/pr-upload.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "cli/parser"
<ide><path>Library/Homebrew/dev-cmd/prof.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "cli/parser"
<ide><path>Library/Homebrew/dev-cmd/pull.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "net/http"
<ide><path>Library/Homebrew/dev-cmd/release-notes.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "cli/parser"
<ide><path>Library/Homebrew/dev-cmd/ruby.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "cli/parser"
<ide><path>Library/Homebrew/dev-cmd/sh.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "extend/ENV"
<ide><path>Library/Homebrew/dev-cmd/sponsors.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "cli/parser"
<ide><path>Library/Homebrew/dev-cmd/style.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "json"
<ide><path>Library/Homebrew/dev-cmd/tap-new.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "tap"
<ide><path>Library/Homebrew/dev-cmd/test.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "extend/ENV"
<ide><path>Library/Homebrew/dev-cmd/tests.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "cli/parser"
<ide><path>Library/Homebrew/dev-cmd/typecheck.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "cli/parser"
<ide><path>Library/Homebrew/dev-cmd/unpack.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "stringio"
<ide><path>Library/Homebrew/dev-cmd/update-license-data.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "cli/parser"
<ide><path>Library/Homebrew/dev-cmd/update-python-resources.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "cli/parser"
<ide><path>Library/Homebrew/dev-cmd/update-test.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "cli/parser"
<ide><path>Library/Homebrew/dev-cmd/vendor-gems.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "formula"
<ide><path>Library/Homebrew/development_tools.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> # @private
<ide><path>Library/Homebrew/diagnostic.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "keg"
<ide><path>Library/Homebrew/download_strategy.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "json"
<ide><path>Library/Homebrew/env_config.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> module Homebrew
<ide><path>Library/Homebrew/exceptions.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "shellwords"
<ide><path>Library/Homebrew/extend/ENV.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "hardware"
<ide><path>Library/Homebrew/extend/ENV/shared.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "compilers"
<ide><path>Library/Homebrew/extend/ENV/std.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "hardware"
<ide><path>Library/Homebrew/extend/ENV/super.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "extend/ENV/shared"
<ide><path>Library/Homebrew/extend/cachable.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> module Cachable
<ide><path>Library/Homebrew/extend/git_repository.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "utils/git"
<ide><path>Library/Homebrew/extend/hash_validator.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> module HashValidator
<ide><path>Library/Homebrew/extend/io.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> class IO
<ide><path>Library/Homebrew/extend/module.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> class Module
<ide><path>Library/Homebrew/extend/optparse.rb
<add># typed: strict
<ide> # frozen_string_literal: true
<ide>
<ide> require "optparse"
<ide><path>Library/Homebrew/extend/os/bottles.rb
<add># typed: strict
<ide> # frozen_string_literal: true
<ide>
<ide> require "extend/os/mac/utils/bottles" if OS.mac?
<ide><path>Library/Homebrew/extend/os/caveats.rb
<add># typed: strict
<ide> # frozen_string_literal: true
<ide>
<ide> require "extend/os/mac/caveats" if OS.mac?
<ide><path>Library/Homebrew/extend/os/cleaner.rb
<add># typed: strict
<ide> # frozen_string_literal: true
<ide>
<ide> if OS.mac?
<ide><path>Library/Homebrew/extend/os/dependency_collector.rb
<add># typed: strict
<ide> # frozen_string_literal: true
<ide>
<ide> if OS.mac?
<ide><path>Library/Homebrew/extend/os/development_tools.rb
<add># typed: strict
<ide> # frozen_string_literal: true
<ide>
<ide> if OS.mac?
<ide><path>Library/Homebrew/extend/os/diagnostic.rb
<add># typed: strict
<ide> # frozen_string_literal: true
<ide>
<ide> if OS.mac?
<ide><path>Library/Homebrew/extend/os/extend/ENV/shared.rb
<add># typed: strict
<ide> # frozen_string_literal: true
<ide>
<ide> if OS.mac?
<ide><path>Library/Homebrew/extend/os/extend/ENV/std.rb
<add># typed: strict
<ide> # frozen_string_literal: true
<ide>
<ide> if OS.mac?
<ide><path>Library/Homebrew/extend/os/extend/ENV/super.rb
<add># typed: strict
<ide> # frozen_string_literal: true
<ide>
<ide> if OS.mac?
<ide><path>Library/Homebrew/extend/os/formula.rb
<add># typed: strict
<ide> # frozen_string_literal: true
<ide>
<ide> if OS.mac?
<ide><path>Library/Homebrew/extend/os/formula_cellar_checks.rb
<add># typed: strict
<ide> # frozen_string_literal: true
<ide>
<ide> if OS.mac?
<ide><path>Library/Homebrew/extend/os/formula_support.rb
<add># typed: strict
<ide> # frozen_string_literal: true
<ide>
<ide> require "extend/os/mac/formula_support" if OS.mac?
<ide><path>Library/Homebrew/extend/os/hardware.rb
<add># typed: strict
<ide> # frozen_string_literal: true
<ide>
<ide> if OS.mac?
<ide><path>Library/Homebrew/extend/os/install.rb
<add># typed: strict
<ide> # frozen_string_literal: true
<ide>
<ide> require "extend/os/linux/install" if OS.linux?
<ide><path>Library/Homebrew/extend/os/keg.rb
<add># typed: strict
<ide> # frozen_string_literal: true
<ide>
<ide> require "extend/os/mac/keg" if OS.mac?
<ide><path>Library/Homebrew/extend/os/keg_relocate.rb
<add># typed: strict
<ide> # frozen_string_literal: true
<ide>
<ide> if OS.mac?
<ide><path>Library/Homebrew/extend/os/language/java.rb
<add># typed: strict
<ide> # frozen_string_literal: true
<ide>
<ide> require "extend/os/mac/language/java" if OS.mac?
<ide><path>Library/Homebrew/extend/os/linkage_checker.rb
<add># typed: strict
<ide> # frozen_string_literal: true
<ide>
<ide> require "extend/os/linux/linkage_checker" if OS.linux?
<ide><path>Library/Homebrew/extend/os/linux/cleaner.rb
<add># typed: strict
<ide> # frozen_string_literal: true
<ide>
<ide> class Cleaner
<ide><path>Library/Homebrew/extend/os/linux/dependency_collector.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> class DependencyCollector
<ide><path>Library/Homebrew/extend/os/linux/development_tools.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> class DevelopmentTools
<ide><path>Library/Homebrew/extend/os/linux/diagnostic.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "tempfile"
<ide><path>Library/Homebrew/extend/os/linux/extend/ENV/shared.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> module SharedEnvExtension
<ide><path>Library/Homebrew/extend/os/linux/extend/ENV/std.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> module Stdenv
<ide><path>Library/Homebrew/extend/os/linux/extend/ENV/super.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> module Superenv
<ide><path>Library/Homebrew/extend/os/linux/extend/pathname.rb
<add># typed: strict
<ide> # frozen_string_literal: true
<ide>
<ide> require "os/linux/elf"
<ide><path>Library/Homebrew/extend/os/linux/formula.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> class Formula
<ide><path>Library/Homebrew/extend/os/linux/formula_cellar_checks.rb
<add># typed: strict
<ide> # frozen_string_literal: true
<ide>
<ide> module FormulaCellarChecks
<ide><path>Library/Homebrew/extend/os/linux/hardware/cpu.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> module Hardware
<ide><path>Library/Homebrew/extend/os/linux/install.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> module Homebrew
<ide><path>Library/Homebrew/extend/os/linux/keg_relocate.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> class Keg
<ide><path>Library/Homebrew/extend/os/linux/linkage_checker.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> class LinkageChecker
<ide><path>Library/Homebrew/extend/os/linux/readall.rb
<add># typed: strict
<ide> # frozen_string_literal: true
<ide>
<ide> module Readall
<ide><path>Library/Homebrew/extend/os/linux/requirements/java_requirement.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "language/java"
<ide><path>Library/Homebrew/extend/os/linux/requirements/osxfuse_requirement.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "requirement"
<ide><path>Library/Homebrew/extend/os/linux/resource.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> class Resource
<ide><path>Library/Homebrew/extend/os/linux/software_spec.rb
<add># typed: strict
<ide> # frozen_string_literal: true
<ide>
<ide> class BottleSpecification
<ide><path>Library/Homebrew/extend/os/linux/system_config.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> require "formula"
<ide><path>Library/Homebrew/extend/os/linux/tap.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> class CoreTap < Tap
<ide><path>Library/Homebrew/extend/os/linux/utils/analytics.rb
<add># typed: strict
<ide> # frozen_string_literal: true
<ide>
<ide> module Utils
<ide><path>Library/Homebrew/extend/os/mac/caveats.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> class Caveats
<ide><path>Library/Homebrew/extend/os/mac/cleaner.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> class Cleaner
<ide><path>Library/Homebrew/extend/os/mac/dependency_collector.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> class DependencyCollector
<ide><path>Library/Homebrew/extend/os/mac/development_tools.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> require "os/mac/xcode"
<ide><path>Library/Homebrew/extend/os/mac/diagnostic.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> module Homebrew
<ide><path>Library/Homebrew/extend/os/mac/extend/ENV/shared.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> module SharedEnvExtension
<ide><path>Library/Homebrew/extend/os/mac/extend/ENV/std.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> module Stdenv
<ide><path>Library/Homebrew/extend/os/mac/extend/ENV/super.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> module Superenv
<ide><path>Library/Homebrew/extend/os/mac/extend/pathname.rb
<add># typed: strict
<ide> # frozen_string_literal: true
<ide>
<ide> require "os/mac/mach"
<ide><path>Library/Homebrew/extend/os/mac/formula.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> class Formula
<ide><path>Library/Homebrew/extend/os/mac/formula_cellar_checks.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "cache_store"
<ide><path>Library/Homebrew/extend/os/mac/formula_support.rb
<add># typed: strict
<ide> # frozen_string_literal: true
<ide>
<ide> class KegOnlyReason
<ide><path>Library/Homebrew/extend/os/mac/hardware.rb
<add># typed: strict
<ide> # frozen_string_literal: true
<ide>
<ide> module Hardware
<ide><path>Library/Homebrew/extend/os/mac/hardware/cpu.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "macho"
<ide><path>Library/Homebrew/extend/os/mac/keg.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> class Keg
<ide><path>Library/Homebrew/extend/os/mac/keg_relocate.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> class Keg
<ide><path>Library/Homebrew/extend/os/mac/language/java.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> module Language
<ide><path>Library/Homebrew/extend/os/mac/missing_formula.rb
<add># typed: strict
<ide> # frozen_string_literal: true
<ide>
<ide> require "cask/cmd/abstract_command"
<ide><path>Library/Homebrew/extend/os/mac/requirements/java_requirement.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> class JavaRequirement < Requirement
<ide><path>Library/Homebrew/extend/os/mac/requirements/osxfuse_requirement.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "requirement"
<ide><path>Library/Homebrew/extend/os/mac/requirements/x11_requirement.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "requirement"
<ide><path>Library/Homebrew/extend/os/mac/resource.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> class Resource
<ide><path>Library/Homebrew/extend/os/mac/search.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> require "cask/cask"
<ide><path>Library/Homebrew/extend/os/mac/software_spec.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> class SoftwareSpec
<ide><path>Library/Homebrew/extend/os/mac/system_config.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> module SystemConfig
<ide><path>Library/Homebrew/extend/os/mac/unpack_strategy/zip.rb
<add># typed: false
<ide> # frozen_string_literal: true
<ide>
<ide> module UnpackStrategy
<ide><path>Library/Homebrew/extend/os/mac/utils/analytics.rb
<add># typed: strict
<ide> # frozen_string_literal: true
<ide>
<ide> module Utils
<ide><path>Library/Homebrew/extend/os/mac/utils/bottles.rb
<add># typed: true
<ide> # frozen_string_literal: true
<ide>
<ide> module Utils
<ide><path>Library/Homebrew/extend/os/missing_formula.rb
<add># typed: strict
<ide> # frozen_string_literal: true
<ide>
<ide> require "extend/os/mac/missing_formula" if OS.mac?
<ide><path>Library/Homebrew/extend/os/pathname.rb
<add># typed: strict
<ide> # frozen_string_literal: true
<ide>
<ide> if OS.mac?
<ide><path>Library/Homebrew/extend/os/readall.rb
<add># typed: strict
<ide> # frozen_string_literal: true
<ide>
<ide> require "extend/os/linux/readall" if OS.linux?
<ide><path>Library/Homebrew/extend/os/requirements/java_requirement.rb
<add># typed: strict
<ide> # frozen_string_literal: true
<ide>
<ide> if OS.mac?
<ide><path>Library/Homebrew/extend/os/requirements/osxfuse_requirement.rb
<add># typed: strict
<ide> # frozen_string_literal: true
<ide>
<ide> if OS.mac?
<ide><path>Library/Homebrew/extend/os/requirements/x11_requirement.rb
<add># typed: strict
<ide> # frozen_string_literal: true
<ide>
<ide> require "extend/os/mac/requirements/x11_requirement" if OS.mac? | 300 |
Javascript | Javascript | fix copy material | 0dac7b9c20a73a2cd82495de5ff041de637ec2dd | <ide><path>src/materials/MeshPhongMaterial.js
<ide> THREE.MeshPhongMaterial = function ( parameters ) {
<ide> THREE.MeshPhongMaterial.prototype = Object.create( THREE.Material.prototype );
<ide> THREE.MeshPhongMaterial.prototype.constructor = THREE.MeshPhongMaterial;
<ide>
<del>THREE.MeshPhongMaterial.prototype.clone = function () {
<add>THREE.MeshPhongMaterial.prototype.copy = function ( source ) {
<ide>
<del> var material = new THREE.MeshPhongMaterial();
<add> THREE.Material.prototype.copy.call( this, source );
<ide>
<del> THREE.Material.prototype.clone.call( this, material );
<add> this.color.copy( source.color );
<add> this.emissive.copy( source.emissive );
<add> this.specular.copy( source.specular );
<add> this.shininess = source.shininess;
<ide>
<del> material.color.copy( this.color );
<del> material.emissive.copy( this.emissive );
<del> material.specular.copy( this.specular );
<del> material.shininess = this.shininess;
<add> this.metal = source.metal;
<ide>
<del> material.metal = this.metal;
<add> this.map = source.map;
<ide>
<del> material.map = this.map;
<add> this.lightMap = source.lightMap;
<add> this.lightMapIntensity = source.lightMapIntensity;
<ide>
<del> material.lightMap = this.lightMap;
<del> material.lightMapIntensity = this.lightMapIntensity;
<add> this.aoMap = source.aoMap;
<add> this.aoMapIntensity = source.aoMapIntensity;
<ide>
<del> material.aoMap = this.aoMap;
<del> material.aoMapIntensity = this.aoMapIntensity;
<add> this.emissiveMap = source.emissiveMap;
<ide>
<del> material.emissiveMap = this.emissiveMap;
<add> this.bumpMap = source.bumpMap;
<add> this.bumpScale = source.bumpScale;
<ide>
<del> material.bumpMap = this.bumpMap;
<del> material.bumpScale = this.bumpScale;
<add> this.normalMap = source.normalMap;
<add> this.normalScale.copy( source.normalScale );
<ide>
<del> material.normalMap = this.normalMap;
<del> material.normalScale.copy( this.normalScale );
<add> this.specularMap = source.specularMap;
<ide>
<del> material.specularMap = this.specularMap;
<add> this.alphaMap = source.alphaMap;
<ide>
<del> material.alphaMap = this.alphaMap;
<add> this.envMap = source.envMap;
<add> this.combine = source.combine;
<add> this.reflectivity = source.reflectivity;
<add> this.refractionRatio = source.refractionRatio;
<ide>
<del> material.envMap = this.envMap;
<del> material.combine = this.combine;
<del> material.reflectivity = this.reflectivity;
<del> material.refractionRatio = this.refractionRatio;
<add> this.fog = source.fog;
<ide>
<del> material.fog = this.fog;
<add> this.shading = source.shading;
<ide>
<del> material.shading = this.shading;
<add> this.wireframe = source.wireframe;
<add> this.wireframeLinewidth = source.wireframeLinewidth;
<add> this.wireframeLinecap = source.wireframeLinecap;
<add> this.wireframeLinejoin = source.wireframeLinejoin;
<ide>
<del> material.wireframe = this.wireframe;
<del> material.wireframeLinewidth = this.wireframeLinewidth;
<del> material.wireframeLinecap = this.wireframeLinecap;
<del> material.wireframeLinejoin = this.wireframeLinejoin;
<add> this.vertexColors = source.vertexColors;
<ide>
<del> material.vertexColors = this.vertexColors;
<add> this.skinning = source.skinning;
<add> this.morphTargets = source.morphTargets;
<add> this.morphNormals = source.morphNormals;
<ide>
<del> material.skinning = this.skinning;
<del> material.morphTargets = this.morphTargets;
<del> material.morphNormals = this.morphNormals;
<add> return this;
<add>
<add>};
<ide>
<del> return material;
<add>THREE.MeshPhongMaterial.prototype.clone = function () {
<add>
<add> var material = new THREE.MeshPhongMaterial();
<add> return material.copy( this );
<ide>
<ide> }; | 1 |
Javascript | Javascript | turn distdecode into a typed array | 4d70cb4aaf2442ff001ccf2468595d6337bf19db | <ide><path>pdf.js
<ide> var FlateStream = (function() {
<ide> 0x00102, 0x00102, 0x00102
<ide> ]);
<ide>
<del> const distDecode = [
<del> [0, 1],
<del> [0, 2],
<del> [0, 3],
<del> [0, 4],
<del> [1, 5],
<del> [1, 7],
<del> [2, 9],
<del> [2, 13],
<del> [3, 17],
<del> [3, 25],
<del> [4, 33],
<del> [4, 49],
<del> [5, 65],
<del> [5, 97],
<del> [6, 129],
<del> [6, 193],
<del> [7, 257],
<del> [7, 385],
<del> [8, 513],
<del> [8, 769],
<del> [9, 1025],
<del> [9, 1537],
<del> [10, 2049],
<del> [10, 3073],
<del> [11, 4097],
<del> [11, 6145],
<del> [12, 8193],
<del> [12, 12289],
<del> [13, 16385],
<del> [13, 24577]
<del> ];
<add> const distDecode = new Uint32Array([
<add> 0x00001, 0x00002, 0x00003, 0x00004, 0x10005, 0x10007, 0x20009,
<add> 0x2000d, 0x30011, 0x30019, 0x40021, 0x40031, 0x50041, 0x50061,
<add> 0x60081, 0x600c1, 0x70101, 0x70181, 0x80201, 0x80301, 0x90401,
<add> 0x90601, 0xa0801, 0xa0c01, 0xb1001, 0xb1801, 0xc2001, 0xc3001,
<add> 0xd4001, 0xd6001
<add> ]);
<ide>
<ide> const fixedLitCodeTab = [[
<ide> [7, 0x0100],
<ide> var FlateStream = (function() {
<ide> code2 = this.getBits(code2);
<ide> var len = (code1 & 0xffff) + code2;
<ide> code1 = this.getCode(distCodeTable);
<del> code2 = distDecode[code1][0];
<add> code1 = distDecode[code1];
<add> code2 = code1 >> 16;
<ide> if (code2 > 0)
<ide> code2 = this.getBits(code2);
<del> var dist = distDecode[code1][1] + code2;
<add> var dist = (code1 & 0xffff) + code2;
<ide> var buffer = this.ensureBuffer(pos + len);
<ide> for (var k = 0; k < len; ++k, ++pos)
<ide> buffer[pos] = buffer[pos - dist]; | 1 |
PHP | PHP | remove explicit middleware implements | e968f3362a0f5c43c6ceb576508e0fed3aa6f21c | <ide><path>src/Illuminate/Session/Middleware/StartSession.php
<ide> use Illuminate\Session\CookieSessionHandler;
<ide> use Symfony\Component\HttpFoundation\Response;
<ide> use Illuminate\Contracts\Routing\TerminableMiddleware;
<del>use Illuminate\Contracts\Routing\Middleware as MiddlewareContract;
<ide>
<del>class StartSession implements MiddlewareContract, TerminableMiddleware {
<add>class StartSession implements TerminableMiddleware {
<ide>
<ide> /**
<ide> * The session manager. | 1 |
Ruby | Ruby | prefer cached_location method over @clone ivar | ddf6f51776c59edf07c5b06f8b8892d4660870be | <ide><path>Library/Homebrew/download_strategy.rb
<ide> def initialize(name, resource)
<ide> end
<ide>
<ide> def fetch
<del> clear_cache unless @url.chomp("/") == repo_url or quiet_system "svn", "switch", @url, @clone
<add> clear_cache unless @url.chomp("/") == repo_url or quiet_system "svn", "switch", @url, cached_location
<ide> super
<ide> end
<ide>
<ide> def stage
<ide> super
<del> quiet_safe_system "svn", "export", "--force", @clone, Dir.pwd
<add> quiet_safe_system "svn", "export", "--force", cached_location, Dir.pwd
<ide> end
<ide>
<ide> private
<ide>
<ide> def repo_url
<del> `svn info '#{@clone}' 2>/dev/null`.strip[/^URL: (.+)$/, 1]
<add> `svn info '#{cached_location}' 2>/dev/null`.strip[/^URL: (.+)$/, 1]
<ide> end
<ide>
<ide> def shell_quote str
<ide> def cache_tag
<ide> end
<ide>
<ide> def repo_valid?
<del> @clone.join(".svn").directory?
<add> cached_location.join(".svn").directory?
<ide> end
<ide>
<ide> def clone_repo
<ide> case @ref_type
<ide> when :revision
<del> fetch_repo @clone, @url, @ref
<add> fetch_repo cached_location, @url, @ref
<ide> when :revisions
<ide> # nil is OK for main_revision, as fetch_repo will then get latest
<ide> main_revision = @ref[:trunk]
<del> fetch_repo @clone, @url, main_revision, true
<add> fetch_repo cached_location, @url, main_revision, true
<ide>
<ide> get_externals do |external_name, external_url|
<del> fetch_repo @clone+external_name, external_url, @ref[external_name], true
<add> fetch_repo cached_location+external_name, external_url, @ref[external_name], true
<ide> end
<ide> else
<del> fetch_repo @clone, @url
<add> fetch_repo cached_location, @url
<ide> end
<ide> end
<ide> alias_method :update, :clone_repo
<ide> def stage
<ide> super
<ide>
<ide> dst = Dir.getwd
<del> @clone.cd do
<add> cached_location.cd do
<ide> # http://stackoverflow.com/questions/160608/how-to-do-a-git-export-like-svn-export
<ide> safe_system 'git', 'checkout-index', '-a', '-f', "--prefix=#{dst}/"
<ide> checkout_submodules(dst) if submodules?
<ide> def cache_tag
<ide> end
<ide>
<ide> def update
<del> @clone.cd do
<add> cached_location.cd do
<ide> config_repo
<ide> update_repo
<ide> checkout
<ide> def support_depth?
<ide> end
<ide>
<ide> def git_dir
<del> @clone.join(".git")
<add> cached_location.join(".git")
<ide> end
<ide>
<ide> def has_ref?
<ide> def repo_valid?
<ide> end
<ide>
<ide> def submodules?
<del> @clone.join(".gitmodules").exist?
<add> cached_location.join(".gitmodules").exist?
<ide> end
<ide>
<ide> def clone_args
<ide> def clone_args
<ide> when :branch, :tag then args << '--branch' << @ref
<ide> end
<ide>
<del> args << @url << @clone
<add> args << @url << cached_location
<ide> end
<ide>
<ide> def refspec
<ide> def update_repo
<ide>
<ide> def clone_repo
<ide> safe_system 'git', *clone_args
<del> @clone.cd { update_submodules } if submodules?
<add> cached_location.cd { update_submodules } if submodules?
<ide> end
<ide>
<ide> def checkout
<ide> def update_submodules
<ide> end
<ide>
<ide> def checkout_submodules(dst)
<del> escaped_clone_path = @clone.to_s.gsub(/\//, '\/')
<add> escaped_clone_path = cached_location.to_s.gsub(/\//, '\/')
<ide> sub_cmd = "git checkout-index -a -f --prefix=#{dst}/${toplevel/#{escaped_clone_path}/}/$path/"
<ide> quiet_safe_system "git", "submodule", "foreach", "--recursive", sub_cmd
<ide> end
<ide> end
<ide>
<ide> class CVSDownloadStrategy < VCSDownloadStrategy
<ide> def stage
<del> FileUtils.cp_r Dir[@clone+"{.}"], Dir.pwd
<add> FileUtils.cp_r Dir[cached_location+"{.}"], Dir.pwd
<ide> end
<ide>
<ide> private
<ide> def cache_tag
<ide> end
<ide>
<ide> def repo_valid?
<del> @clone.join("CVS").directory?
<add> cached_location.join("CVS").directory?
<ide> end
<ide>
<ide> def clone_repo
<ide> def clone_repo
<ide> end
<ide>
<ide> def update
<del> @clone.cd { quiet_safe_system cvspath, { :quiet_flag => "-Q" }, "up" }
<add> cached_location.cd { quiet_safe_system cvspath, { :quiet_flag => "-Q" }, "up" }
<ide> end
<ide>
<ide> def split_url(in_url)
<ide> def stage
<ide> super
<ide>
<ide> dst = Dir.getwd
<del> @clone.cd do
<add> cached_location.cd do
<ide> if @ref_type and @ref
<ide> safe_system hgpath, 'archive', '--subrepos', '-y', '-r', @ref, '-t', 'files', dst
<ide> else
<ide> def cache_tag
<ide> end
<ide>
<ide> def repo_valid?
<del> @clone.join(".hg").directory?
<add> cached_location.join(".hg").directory?
<ide> end
<ide>
<ide> def clone_repo
<ide> url = @url.sub(%r[^hg://], "")
<del> safe_system hgpath, "clone", url, @clone
<add> safe_system hgpath, "clone", url, cached_location
<ide> end
<ide>
<ide> def update
<del> @clone.cd { quiet_safe_system hgpath, "pull", "--update" }
<add> cached_location.cd { quiet_safe_system hgpath, "pull", "--update" }
<ide> end
<ide>
<ide> def hgpath
<ide> class BazaarDownloadStrategy < VCSDownloadStrategy
<ide> def stage
<ide> # The export command doesn't work on checkouts
<ide> # See https://bugs.launchpad.net/bzr/+bug/897511
<del> FileUtils.cp_r Dir[@clone+"{.}"], Dir.pwd
<add> FileUtils.cp_r Dir[cached_location+"{.}"], Dir.pwd
<ide> FileUtils.rm_r ".bzr"
<ide> end
<ide>
<ide> def cache_tag
<ide> end
<ide>
<ide> def repo_valid?
<del> @clone.join(".bzr").directory?
<add> cached_location.join(".bzr").directory?
<ide> end
<ide>
<ide> def clone_repo
<ide> url = @url.sub(%r[^bzr://], "")
<ide> # "lightweight" means history-less
<del> safe_system bzrpath, "checkout", "--lightweight", url, @clone
<add> safe_system bzrpath, "checkout", "--lightweight", url, cached_location
<ide> end
<ide>
<ide> def update
<del> @clone.cd { quiet_safe_system bzrpath, "update" }
<add> cached_location.cd { quiet_safe_system bzrpath, "update" }
<ide> end
<ide>
<ide> def bzrpath
<ide> def bzrpath
<ide> class FossilDownloadStrategy < VCSDownloadStrategy
<ide> def stage
<ide> super
<del> args = [fossilpath, "open", @clone]
<add> args = [fossilpath, "open", cached_location]
<ide> args << @ref if @ref_type && @ref
<ide> safe_system(*args)
<ide> end
<ide> def cache_tag
<ide>
<ide> def clone_repo
<ide> url = @url.sub(%r[^fossil://], "")
<del> safe_system fossilpath, "clone", url, @clone
<add> safe_system fossilpath, "clone", url, cached_location
<ide> end
<ide>
<ide> def update
<del> safe_system fossilpath, "pull", "-R", @clone
<add> safe_system fossilpath, "pull", "-R", cached_location
<ide> end
<ide>
<ide> def fossilpath | 1 |
Ruby | Ruby | fix tests in railties | d9b732fcadc001b6757e648761acf97833827b58 | <ide><path>railties/test/railties/engine_test.rb
<ide> class Engine < ::Rails::Engine
<ide> env = Rack::MockRequest.env_for("/bukkits")
<ide> response = Rails.application.call(env)
<ide>
<del> assert_equal ["HELLO WORLD"], response[2]
<add> assert_equal rack_body(["HELLO WORLD"]), rack_body(response[2])
<ide> end
<ide>
<ide> test "it provides routes as default endpoint" do
<ide> class Engine < ::Rails::Engine
<ide>
<ide> env = Rack::MockRequest.env_for("/bukkits/foo")
<ide> response = Rails.application.call(env)
<del> assert_equal ["foo"], response[2]
<add> assert_equal rack_body(["foo"]), rack_body(response[2])
<ide> end
<ide>
<ide> test "engine can load its own plugins" do
<ide> def bar
<ide>
<ide> env = Rack::MockRequest.env_for("/foo")
<ide> response = Rails.application.call(env)
<del> assert_equal ["Something... Something... Something..."], response[2]
<add> assert_equal rack_body(["Something... Something... Something..."]), rack_body(response[2])
<ide>
<ide> env = Rack::MockRequest.env_for("/foo/show")
<ide> response = Rails.application.call(env)
<del> assert_equal ["/foo"], response[2]
<add> assert_equal rack_body(["/foo"]), rack_body(response[2])
<ide>
<ide> env = Rack::MockRequest.env_for("/foo/bar")
<ide> response = Rails.application.call(env)
<del> assert_equal ["It's a bar."], response[2]
<add> assert_equal rack_body(["It's a bar."]), rack_body(response[2])
<ide> end
<ide>
<ide> test "isolated engine should include only its own routes and helpers" do
<ide> class MyMailer < ActionMailer::Base
<ide>
<ide> env = Rack::MockRequest.env_for("/bukkits/from_app")
<ide> response = AppTemplate::Application.call(env)
<del> assert_equal ["false"], response[2]
<add> assert_equal rack_body(["false"]), rack_body(response[2])
<ide>
<ide> env = Rack::MockRequest.env_for("/bukkits/foo/show")
<ide> response = AppTemplate::Application.call(env)
<del> assert_equal ["/bukkits/foo"], response[2]
<add> assert_equal rack_body(["/bukkits/foo"]), rack_body(response[2])
<ide>
<ide> env = Rack::MockRequest.env_for("/bukkits/foo")
<ide> response = AppTemplate::Application.call(env)
<del> assert_equal ["Helped."], response[2]
<add> assert_equal rack_body(["Helped."]), rack_body(response[2])
<ide>
<ide> env = Rack::MockRequest.env_for("/bukkits/routes_helpers_in_view")
<ide> response = AppTemplate::Application.call(env)
<del> assert_equal ["/bukkits/foo, /bar"], response[2]
<add> assert_equal rack_body(["/bukkits/foo, /bar"]), rack_body(response[2])
<ide>
<ide> env = Rack::MockRequest.env_for("/bukkits/polymorphic_path_without_namespace")
<ide> response = AppTemplate::Application.call(env)
<del> assert_equal ["/bukkits/posts/1"], response[2]
<add> assert_equal rack_body(["/bukkits/posts/1"]), rack_body(response[2])
<ide> end
<ide>
<ide> test "isolated engine should avoid namespace in names if that's possible" do
<ide><path>railties/test/railties/railtie_test.rb
<ide> def app
<ide>
<ide> test "Railtie provides railtie_name" do
<ide> begin
<del> class ::Foo < Rails::Railtie ; end
<del> assert_equal "foo", ::Foo.railtie_name
<add> class ::FooBarBaz < Rails::Railtie ; end
<add> assert_equal "foo_bar_baz", ::FooBarBaz.railtie_name
<ide> ensure
<del> Object.send(:remove_const, :"Foo")
<add> Object.send(:remove_const, :"FooBarBaz")
<ide> end
<ide> end
<ide> | 2 |
Text | Text | remove reference to deprecated navigator.js | 67a3b4c224eb4f46d6ab0659c3f4c6fb7d04d62f | <ide><path>docs/Navigation.md
<ide> next: images
<ide> previous: animations
<ide> ---
<ide>
<del>This guide covers the various navigation components available in React Native. If you are just getting started with navigation, you will probably want to use React Navigation.
<add>This guide covers the various navigation components available in React Native. If you are just getting started with navigation, you will probably want to use [React Navigation](docs/navigation.html#react-navigation).
<ide>
<del>If you are only targeting iOS and would like to stick to the native look and feel, check out `NavigatorIOS`. The `Navigator` component is older but has been thoroughly tested in production.
<add>If you are only targeting iOS and would like to stick to the native look and feel, check out [NavigatorIOS](docs/navigation.html#navigatorios).
<add>
<add>If you're targeting both iOS and Android, the following libraries provide native navigation on both platforms: [native-navigation](http://airbnb.io/native-navigation/), [react-native-navigation](https://github.com/wix/react-native-navigation).
<ide>
<ide> ## React Navigation
<ide>
<ide> The community solution to navigation is a standalone library that allows developers to set up the screens of an app with just a few lines of code.
<ide>
<del>The first step is to install in your app:
<add>The first step is to install in your project:
<ide>
<ide> ```
<ide> npm install --save react-navigation
<ide> import {
<ide> } from 'react-navigation';
<ide>
<ide> const App = StackNavigator({
<del> Main: {screen: MainScreen},
<del> Profile: {screen: ProfileScreen},
<add> Home: { screen: HomeScreen },
<add> Profile: { screen: ProfileScreen },
<ide> });
<ide> ```
<ide>
<ide> Each screen component can set navigation options such as the header title. It can use action creators on the `navigation` prop to link to other screens:
<ide>
<ide> ```
<del>class MainScreen extends React.Component {
<add>class HomeScreen extends React.Component {
<ide> static navigationOptions = {
<ide> title: 'Welcome',
<ide> };
<ide> class MainScreen extends React.Component {
<ide>
<ide> React Navigation routers make it easy to override navigation logic or integrate it into redux. Because routers can be nested inside each other, developers can override navigation logic for one area of the app without making widespread changes.
<ide>
<del>The views in React Navigation use native components and the `Animated` library to deliver 60fps animations that are run on the native thread. Plus, the animations and gestures can be easily customized.
<del>
<del>For a complete intro to React Navigation, follow the [getting started guide](https://reactnavigation.org/docs/intro/), or browse other docs such as the [intro to navigators](https://reactnavigation.org/docs/navigators/).
<del>
<del>## Navigator
<del>
<del>Like React Navigation, `Navigator` provides a JavaScript implementation of a navigation stack, so it works on both iOS and Android and is easy to customize. Navigator was released alongside React Native in 2015, so it predates the Animated library with native-thread animations.
<del>
<del>
<del>
<del>`Navigator` can be adapted to render different components based on the current route in its `renderScene` function. It will transition new scenes onto the screen by sliding in from the right by default, but you can control this behavior by using the `configureScene` function. You can also configure a navigation bar through the `navigationBar` prop.
<add>The views in React Navigation use native components and the [`Animated`](docs/animated.html) library to deliver 60fps animations that are run on the native thread. Plus, the animations and gestures can be easily customized.
<ide>
<del>Check out the [Navigator API reference](docs/navigator.html) for specific examples that cover each of these scenarios.
<add>For a complete intro to React Navigation, follow the [React Navigation Getting Started Guide](https://reactnavigation.org/docs/intro/), or browse other docs such as the [Intro to Navigators](https://reactnavigation.org/docs/navigators/).
<ide>
<ide> ## NavigatorIOS
<ide>
<del>If you are targeting iOS only, you may also want to consider using [NavigatorIOS](docs/navigatorios.html). It looks and feels just like [`UINavigationController`](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UINavigationController_Class/), because it is actually built on top of it.
<add>If you are targeting iOS only, you may also want to consider using [`NavigatorIOS`](docs/navigatorios.html). It looks and feels just like [`UINavigationController`](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UINavigationController_Class/), because it is actually built on top of it.
<ide>
<ide> 
<ide>
<ide> Like other navigation systems, `NavigatorIOS` uses routes to represent screens,
<ide> As `NavigatorIOS` leverages native UIKit navigation, it will automatically render a navigation bar with a back button and title.
<ide>
<ide> ```javascript
<del>import React, { Component, PropTypes } from 'react';
<del>import { NavigatorIOS, Text, TouchableHighlight, View } from 'react-native';
<add>import React from 'react';
<add>import PropTypes from 'prop-types';
<add>import { Button, NavigatorIOS, Text, View } from 'react-native';
<ide>
<del>export default class NavigatorIOSApp extends Component {
<add>export default class NavigatorIOSApp extends React.Component {
<ide> render() {
<ide> return (
<ide> <NavigatorIOS
<ide> export default class NavigatorIOSApp extends Component {
<ide> }
<ide> }
<ide>
<del>class MyScene extends Component {
<add>class MyScene extends React.Component {
<ide> static propTypes = {
<ide> title: PropTypes.string.isRequired,
<ide> navigator: PropTypes.object.isRequired,
<ide> class MyScene extends Component {
<ide> return (
<ide> <View>
<ide> <Text>Current Scene: { this.props.title }</Text>
<del> <TouchableHighlight onPress={this._onForward}>
<del> <Text>Tap me to load the next scene</Text>
<del> </TouchableHighlight>
<add> <Button
<add> onPress={this._onForward}
<add> title="Tap me to load the next scene"
<add> />
<ide> </View>
<ide> )
<ide> }
<ide> }
<ide> ```
<ide>
<ide> Check out the [`NavigatorIOS` reference docs](docs/navigatorios.html) to learn more about this component.
<del>
<del>> You may also want to check out [react-native-navigation](https://github.com/wix/react-native-navigation), a component that aims to provide native navigation on both iOS and Android.
<del>
<del>## NavigationExperimental
<del>
<del>Since early 2016, React Native has shipped with an experimental re-implementation of the original `Navigator` component called `CardStack`. The major benefit it had over `Navigator` is the smooth native-thread animations provided by the Animated library.
<del>
<del>Because `NavigationExperimental` only included view components, it required a lot of boilerplate to use by itself. Several libraries sprung up around it, making it easier to use. Libraries such as `react-native-router-flux` and `ex-navigation` wrapped NavigationExperimental views in an easier-to-use API. Authors of many of these libraries now support React Navigation.
<del>
<del>The `CardStack` and other NavigationExperimental views live on as a part of the React Navigation project. The new library aims to be easy to use, while continuing to enable the smooth and customizable animations that NavigationExperimental pioneered.
<del>
<del>As of React Native 0.43, `NavigationExperimental` is deprecated. It will be removed from the codebase in a later version. | 1 |
Javascript | Javascript | make 'close' event async | 7349d7fd998cba97f3b6c76376862ae81b5d6418 | <ide><path>lib/dgram.js
<ide> Socket.prototype.close = function() {
<ide> this._stopReceiving();
<ide> this._handle.close();
<ide> this._handle = null;
<del> this.emit('close');
<add> var self = this;
<add> process.nextTick(function() {
<add> self.emit('close');
<add> });
<ide>
<ide> return this;
<ide> };
<ide><path>test/parallel/test-dgram-close.js
<ide> buf.fill(42);
<ide>
<ide> var socket = dgram.createSocket('udp4');
<ide> var handle = socket._handle;
<add>var closeEvents = 0;
<ide> socket.send(buf, 0, buf.length, common.PORT, 'localhost');
<ide> assert.strictEqual(socket.close(), socket);
<add>socket.on('close', function() {
<add> ++closeEvents;
<add>});
<ide> socket = null;
<ide>
<ide> // Verify that accessing handle after closure doesn't throw
<ide> setImmediate(function() {
<ide> console.log('Handle fd is: ', handle.fd);
<ide> });
<ide> });
<add>
<add>process.on('exit', function() {
<add> assert.equal(closeEvents, 1);
<add>}); | 2 |
Python | Python | remove "bench" from testing modules `__init__`s | 6126789e4addb609b6c99e46a338f5b0bb6f9be3 | <ide><path>numpy/__init__.py
<ide> def pkgload(*packages, **options):
<ide> # no-one else in the world is using it (though I hope not)
<ide> from .testing import Tester, _numpy_tester
<ide> test = _numpy_tester().test
<del> bench = _numpy_tester().bench
<ide>
<ide> # Allow distributors to run custom init code
<ide> from . import _distributor_init
<ide><path>numpy/core/__init__.py
<ide>
<ide> from numpy.testing import _numpy_tester
<ide> test = _numpy_tester().test
<del>bench = _numpy_tester().bench
<ide>
<ide> # Make it possible so that ufuncs can be pickled
<ide> # Here are the loading and unloading functions
<ide><path>numpy/f2py/__init__.py
<ide> def compile(source,
<ide>
<ide> from numpy.testing import _numpy_tester
<ide> test = _numpy_tester().test
<del>bench = _numpy_tester().bench
<ide><path>numpy/fft/__init__.py
<ide>
<ide> from numpy.testing import _numpy_tester
<ide> test = _numpy_tester().test
<del>bench = _numpy_tester().bench
<ide><path>numpy/lib/__init__.py
<ide>
<ide> from numpy.testing import _numpy_tester
<ide> test = _numpy_tester().test
<del>bench = _numpy_tester().bench
<ide><path>numpy/linalg/__init__.py
<ide>
<ide> from numpy.testing import _numpy_tester
<ide> test = _numpy_tester().test
<del>bench = _numpy_tester().bench
<ide><path>numpy/ma/__init__.py
<ide>
<ide> from numpy.testing import _numpy_tester
<ide> test = _numpy_tester().test
<del>bench = _numpy_tester().bench
<ide><path>numpy/matrixlib/__init__.py
<ide>
<ide> from numpy.testing import _numpy_tester
<ide> test = _numpy_tester().test
<del>bench = _numpy_tester().bench
<ide><path>numpy/polynomial/__init__.py
<ide>
<ide> from numpy.testing import _numpy_tester
<ide> test = _numpy_tester().test
<del>bench = _numpy_tester().bench
<ide><path>numpy/random/__init__.py
<ide> def __RandomState_ctor():
<ide>
<ide> from numpy.testing import _numpy_tester
<ide> test = _numpy_tester().test
<del>bench = _numpy_tester().bench | 10 |
Ruby | Ruby | compare file mode directly | 673f08f17e036b7fa200553ae9a6d0a9f73ca4ac | <ide><path>Library/Homebrew/cmd/audit.rb
<ide> def initialize(formula)
<ide> end
<ide>
<ide> def audit_file
<del> unless formula.path.stat.mode.to_s(8) == "100644"
<add> unless formula.path.stat.mode == 0100644
<ide> problem "Incorrect file permissions: chmod 644 #{formula.path}"
<ide> end
<ide> | 1 |
Javascript | Javascript | implement text onlongpress | f022681a1eb1f7ad63f86f376fcf9e578f1e126a | <ide><path>Libraries/Text/Text.js
<ide> const Text = React.createClass({
<ide> * This function is called on press.
<ide> */
<ide> onPress: React.PropTypes.func,
<add> /**
<add> * This function is called on long press.
<add> */
<add> onLongPress: React.PropTypes.func,
<ide> /**
<ide> * When true, no visual change is made when text is pressed down. By
<ide> * default, a gray oval highlights the text on press down.
<ide> const Text = React.createClass({
<ide> * Only assigned if touch is needed.
<ide> */
<ide> _handlers: (null: ?Object),
<add> _hasPressHandler(): boolean {
<add> return !!this.props.onPress || !!this.props.onLongPress;
<add> },
<ide> /**
<ide> * These are assigned lazily the first time the responder is set to make plain
<ide> * text nodes as cheap as possible.
<ide> */
<ide> touchableHandleActivePressIn: (null: ?Function),
<ide> touchableHandleActivePressOut: (null: ?Function),
<ide> touchableHandlePress: (null: ?Function),
<add> touchableHandleLongPress: (null: ?Function),
<ide> touchableGetPressRectOffset: (null: ?Function),
<ide> render(): ReactElement {
<ide> let newProps = this.props;
<del> if (this.props.onStartShouldSetResponder || this.props.onPress) {
<add> if (this.props.onStartShouldSetResponder || this._hasPressHandler()) {
<ide> if (!this._handlers) {
<ide> this._handlers = {
<ide> onStartShouldSetResponder: (): bool => {
<ide> const shouldSetFromProps = this.props.onStartShouldSetResponder &&
<ide> this.props.onStartShouldSetResponder();
<del> const setResponder = shouldSetFromProps || !!this.props.onPress;
<add> const setResponder = shouldSetFromProps || this._hasPressHandler();
<ide> if (setResponder && !this.touchableHandleActivePressIn) {
<ide> // Attach and bind all the other handlers only the first time a touch
<ide> // actually happens.
<ide> const Text = React.createClass({
<ide> }
<ide> }
<ide> this.touchableHandleActivePressIn = () => {
<del> if (this.props.suppressHighlighting || !this.props.onPress) {
<add> if (this.props.suppressHighlighting || !this._hasPressHandler()) {
<ide> return;
<ide> }
<ide> this.setState({
<ide> const Text = React.createClass({
<ide> };
<ide>
<ide> this.touchableHandleActivePressOut = () => {
<del> if (this.props.suppressHighlighting || !this.props.onPress) {
<add> if (this.props.suppressHighlighting || !this._hasPressHandler()) {
<ide> return;
<ide> }
<ide> this.setState({
<ide> const Text = React.createClass({
<ide> this.props.onPress && this.props.onPress();
<ide> };
<ide>
<add> this.touchableHandleLongPress = () => {
<add> this.props.onLongPress && this.props.onLongPress();
<add> };
<add>
<ide> this.touchableGetPressRectOffset = function(): RectOffset {
<ide> return PRESS_RECT_OFFSET;
<ide> }; | 1 |
Javascript | Javascript | improve http2 benchmark configs | 82b1660b1d7921a9b7d55156bd67f17da34eb106 | <ide><path>benchmark/http2/headers.js
<ide> const PORT = common.PORT;
<ide> const bench = common.createBenchmark(main, {
<ide> n: [1e3],
<ide> nheaders: [0, 10, 100, 1000],
<del>}, { flags: ['--no-warnings'] });
<add> benchmarker: ['h2load']
<add>}, { flags: ['--no-warnings', '--expose-http2'] });
<ide>
<ide> function main(conf) {
<ide> const n = +conf.n;
<ide><path>benchmark/http2/respond-with-fd.js
<ide> const file = path.join(path.resolve(__dirname, '../fixtures'), 'alice.html');
<ide> const bench = common.createBenchmark(main, {
<ide> requests: [100, 1000, 10000, 100000, 1000000],
<ide> streams: [100, 200, 1000],
<del> clients: [1, 2]
<del>}, { flags: ['--no-warnings'] });
<add> clients: [1, 2],
<add> benchmarker: ['h2load']
<add>}, { flags: ['--no-warnings', '--expose-http2'] });
<ide>
<ide> function main(conf) {
<ide>
<ide><path>benchmark/http2/simple.js
<ide> const file = path.join(path.resolve(__dirname, '../fixtures'), 'alice.html');
<ide> const bench = common.createBenchmark(main, {
<ide> requests: [100, 1000, 10000, 100000],
<ide> streams: [100, 200, 1000],
<del> clients: [1, 2]
<del>}, { flags: ['--no-warnings'] });
<add> clients: [1, 2],
<add> benchmarker: ['h2load']
<add>}, { flags: ['--no-warnings', '--expose-http2'] });
<ide>
<ide> function main(conf) {
<ide> const n = +conf.requests;
<ide><path>benchmark/http2/write.js
<ide> const PORT = common.PORT;
<ide> const bench = common.createBenchmark(main, {
<ide> streams: [100, 200, 1000],
<ide> length: [64 * 1024, 128 * 1024, 256 * 1024, 1024 * 1024],
<del> size: [100000]
<del>}, { flags: ['--no-warnings'] });
<add> size: [100000],
<add> benchmarker: ['h2load']
<add>}, { flags: ['--no-warnings', '--expose-http2'] });
<ide>
<ide> function main(conf) {
<ide> const m = +conf.streams; | 4 |
Javascript | Javascript | fix codemirror ssr | 8049dddfdf40cc485b31ce0134b8a143eaee45b1 | <ide><path>packages/learn/src/templates/Challenges/views/classic/Editor.js
<ide> import { executeChallenge, updateFile } from '../../redux';
<ide> import 'codemirror/lib/codemirror.css';
<ide> import 'codemirror/theme/material.css';
<ide>
<del>require('codemirror/mode/htmlmixed/htmlmixed');
<del>require('codemirror/mode/javascript/javascript');
<add>if (typeof window !== 'undefined') {
<add> require('codemirror/mode/htmlmixed/htmlmixed');
<add> require('codemirror/mode/javascript/javascript');
<add>}
<ide>
<ide> const propTypes = {
<ide> contents: PropTypes.string, | 1 |
Text | Text | add readme for model | 0d491c61a9463182d1a0df70d61d01ee2e017917 | <ide><path>threejs/resources/models/mountain_landscape/readme.md
<add>This model is licensed [CC-BY 4.0](https://creativecommons.org/licenses/by/4.0/)
<add>Author: [elsergio217](https://sketchfab.com/elsergio217) | 1 |
PHP | PHP | add connection settings to cache config | 8f6db28661f6e763c0cc95f141bad8f3a5553c62 | <ide><path>config/cache.php
<ide> 'database' => [
<ide> 'driver' => 'database',
<ide> 'table' => 'cache',
<add> 'connection' => null,
<ide> ],
<ide>
<ide> 'file' => [
<ide> ],
<ide>
<ide> 'redis' => [
<del> 'driver' => 'redis'
<add> 'driver' => 'redis',
<add> 'connection' => 'default',
<ide> ],
<ide>
<ide> ], | 1 |
Text | Text | fix a typo in n-api documentation | f2cb78c4e7b799ad9f758d1c677f790bab636d72 | <ide><path>doc/api/n-api.md
<ide> must be called in order to determine if an exception is pending or not.
<ide>
<ide> When an exception is pending one of two approaches can be employed.
<ide>
<del>The first appoach is to do any appropriate cleanup and then return so that
<add>The first approach is to do any appropriate cleanup and then return so that
<ide> execution will return to JavaScript. As part of the transition back to
<ide> JavaScript the exception will be thrown at the point in the JavaScript
<ide> code where the native method was invoked. The behavior of most N-API calls | 1 |
Javascript | Javascript | fix typo in new modulecache args | 29febb9b1e6c17c61000d80ef3703f697c5c1a03 | <ide><path>packager/react-packager/src/node-haste/index.js
<ide> class DependencyGraph {
<ide> depGraphHelpers: this._helpers,
<ide> assetDependencies: this._assetDependencies,
<ide> moduleOptions: this._opts.moduleOptions,
<del> }, this._opts.platfomrs);
<add> }, this._opts.platforms);
<ide>
<ide> this._hasteMap = new HasteMap({
<ide> fastfs: this._fastfs, | 1 |
Text | Text | fix typo in migration guide | 873223fc784bd761fb9b18159b7c99856003e7d7 | <ide><path>docs/getting-started/v3-migration.md
<ide> A number of changes were made to the configuration options passed to the `Chart`
<ide>
<ide> * Indexable options are now looping. `backgroundColor: ['red', 'green']` will result in alternating `'red'` / `'green'` if there are more than 2 data points.
<ide> * The input properties of object data can now be freely specified, see [data structures](../general/data-structures.md) for details.
<del>* Most options are resolved utilizing proxies, instead merging with defaults. In addition to easily enabling different resolution routes for different contexts, it allows using other resolved options in scriptable options.
<add>* Most options are resolved utilizing proxies, instead of merging with defaults. In addition to easily enabling different resolution routes for different contexts, it allows using other resolved options in scriptable options.
<ide> * Options are by default scriptable and indexable, unless disabled for some reason.
<ide> * Scriptable options receive a option reolver as second parameter for accessing other options in same context.
<ide> * Resolution falls to upper scopes, if no match is found earlier. See [options](./general/options.md) for details. | 1 |
PHP | PHP | fix variable name and docblock | 76189fe7c8dafe8a1be63aab032c174db10f0ac2 | <ide><path>src/Illuminate/Foundation/helpers.php
<ide> function dispatch($job)
<ide> * Get the path to a versioned Elixir file.
<ide> *
<ide> * @param string $file
<add> * @param string $buildDirectory
<ide> * @return string
<ide> *
<ide> * @throws \InvalidArgumentException
<ide> */
<del> function elixir($file, $customFolder = 'build')
<add> function elixir($file, $buildDirectory = 'build')
<ide> {
<ide> static $manifest = null;
<ide>
<ide> if (is_null($manifest)) {
<del> $manifest = json_decode(file_get_contents(public_path($customFolder.'/rev-manifest.json')), true);
<add> $manifest = json_decode(file_get_contents(public_path($buildDirectory.'/rev-manifest.json')), true);
<ide> }
<ide>
<ide> if (isset($manifest[$file])) {
<del> return '/'.$customFolder.'/'.$manifest[$file];
<add> return '/'.$buildDirectory.'/'.$manifest[$file];
<ide> }
<ide>
<ide> throw new InvalidArgumentException("File {$file} not defined in asset manifest."); | 1 |
Python | Python | allow legacy optimizer in mg's optimizer factory | 03c41a1ee62ef4fbffa68e84c919ec1bb5688389 | <ide><path>official/modeling/optimization/optimizer_factory.py
<ide> def build_optimizer(
<ide> optimizer, **self._ema_config.as_dict())
<ide> if postprocessor:
<ide> optimizer = postprocessor(optimizer)
<del> if not isinstance(optimizer, tf.keras.optimizers.Optimizer):
<del> # tf.keras.optimizers.experimental only exist in tf-nightly.
<del> # The following check makes sure the function wont' break in older TF
<del> # version because of missing the experimental package.
<del> if hasattr(tf.keras.optimizers, 'experimental'):
<del> if not isinstance(optimizer,
<del> tf.keras.optimizers.experimental.Optimizer):
<del> raise TypeError('OptimizerFactory.build_optimizer returning a '
<del> 'non-optimizer object: {}'.format(optimizer))
<del> else:
<del> raise TypeError('OptimizerFactory.build_optimizer returning a '
<del> 'non-optimizer object: {}'.format(optimizer))
<del>
<del> return optimizer
<add> if isinstance(optimizer, tf.keras.optimizers.Optimizer):
<add> return optimizer
<add> # The following check makes sure the function won't break in older TF
<add> # version because of missing the experimental/legacy package.
<add> if hasattr(tf.keras.optimizers, 'experimental'):
<add> if isinstance(optimizer, tf.keras.optimizers.experimental.Optimizer):
<add> return optimizer
<add> if hasattr(tf.keras.optimizers, 'legacy'):
<add> if isinstance(optimizer, tf.keras.optimizers.legacy.Optimizer):
<add> return optimizer
<add> raise TypeError('OptimizerFactory.build_optimizer returning a '
<add> 'non-optimizer object: {}'.format(optimizer)) | 1 |
PHP | PHP | add collection@issingle method | b72178dbe9d8971c9f8bd1823cb1aa344bcb9637 | <ide><path>src/Illuminate/Collections/Collection.php
<ide> public function isEmpty()
<ide> return empty($this->items);
<ide> }
<ide>
<add> /**
<add> * Determine if the collection contains a single element.
<add> *
<add> * @return bool
<add> */
<add> public function isSingle()
<add> {
<add> return $this->count() === 1;
<add> }
<add>
<ide> /**
<ide> * Join all items from the collection using a string. The final items can use a separate glue string.
<ide> *
<ide><path>src/Illuminate/Collections/LazyCollection.php
<ide> public function isEmpty()
<ide> return ! $this->getIterator()->valid();
<ide> }
<ide>
<add> /**
<add> * Determine if the collection contains a single element.
<add> *
<add> * @return bool
<add> */
<add> public function isSingle()
<add> {
<add> return $this->take(2)->count() === 1;
<add> }
<add>
<ide> /**
<ide> * Join all items from the collection using a string. The final items can use a separate glue string.
<ide> *
<ide><path>tests/Support/SupportCollectionTest.php
<ide> public function testCountableByWithCallback($collection)
<ide> })->all());
<ide> }
<ide>
<add> /**
<add> * @dataProvider collectionClassProvider
<add> */
<add> public function testIsSingle($collection)
<add> {
<add> $this->assertFalse((new $collection([]))->isSingle());
<add> $this->assertTrue((new $collection([1]))->isSingle());
<add> $this->assertFalse((new $collection([1, 2]))->isSingle());
<add> }
<add>
<ide> public function testIterable()
<ide> {
<ide> $c = new Collection(['foo']);
<ide><path>tests/Support/SupportLazyCollectionIsLazyTest.php
<ide> public function testIsNotEmptyIsLazy()
<ide> });
<ide> }
<ide>
<add> public function testIsSingleIsLazy()
<add> {
<add> $this->assertEnumerates(2, function ($collection) {
<add> $collection->isSingle();
<add> });
<add> }
<add>
<ide> public function testJoinIsLazy()
<ide> {
<ide> $this->assertEnumeratesOnce(function ($collection) { | 4 |
PHP | PHP | fix arguments type and add typehint | 17be680352a5dd427cff2feaa3e27695843ceb82 | <ide><path>src/ORM/Marshaller.php
<ide> protected function _mergeAssociation($original, Association $assoc, $value, arra
<ide> * Creates a new sub-marshaller and merges the associated data for a BelongstoMany
<ide> * association.
<ide> *
<del> * @param \Cake\Datasource\EntityInterface $original The original entity
<add> * @param \Cake\Datasource\EntityInterface[] $original The original entities list.
<ide> * @param \Cake\ORM\Association $assoc The association to marshall
<ide> * @param array $value The data to hydrate
<ide> * @param array $options List of options.
<ide> * @return \Cake\Datasource\EntityInterface[]
<ide> */
<del> protected function _mergeBelongsToMany($original, Association $assoc, $value, array $options): array
<add> protected function _mergeBelongsToMany(array $original, Association $assoc, $value, array $options): array
<ide> {
<ide> $associated = $options['associated'] ?? [];
<ide>
<ide> protected function _mergeBelongsToMany($original, Association $assoc, $value, ar
<ide> /**
<ide> * Merge the special _joinData property into the entity set.
<ide> *
<del> * @param \Cake\Datasource\EntityInterface $original The original entity
<add> * @param \Cake\Datasource\EntityInterface[] $original The original entities list.
<ide> * @param \Cake\ORM\Association\BelongsToMany $assoc The association to marshall
<ide> * @param array $value The data to hydrate
<ide> * @param array $options List of options.
<ide> * @return \Cake\Datasource\EntityInterface[] An array of entities
<ide> */
<del> protected function _mergeJoinData($original, BelongsToMany $assoc, array $value, array $options): array
<add> protected function _mergeJoinData(array $original, BelongsToMany $assoc, array $value, array $options): array
<ide> {
<ide> $associated = $options['associated'] ?? [];
<ide> $extra = []; | 1 |
Ruby | Ruby | use fc accessor | 8828187b4c7d9b0220875d607fd5ff73d3894b89 | <ide><path>Library/Homebrew/extend/ENV/shared.rb
<ide> def userpaths!
<ide> end
<ide>
<ide> def fortran
<del> if self['FC']
<add> if fc
<ide> ohai "Building with an alternative Fortran compiler"
<ide> puts "This is unsupported."
<del> self['F77'] ||= self['FC']
<add> self['F77'] ||= fc
<ide>
<ide> if ARGV.include? '--default-fortran-flags'
<ide> flags_to_set = FC_FLAG_VARS.reject { |key| self[key] } | 1 |
Text | Text | add badges to readme | 09034d9e177ff929eb94e7a3edb73b2e4993552d | <ide><path>README.md
<ide> # Keras: Deep Learning library for Theano and TensorFlow
<ide>
<del>
<add>[](https://travis-ci.org/fchollet/keras)
<add>[](https://badge.fury.io/py/keras)
<ide>
<ide> ## You have just found Keras.
<ide> | 1 |
Python | Python | fix input shape of ocr model | d4f6ff8a88e215875480da985de6b9acbb322f44 | <ide><path>examples/image_ocr.py
<ide> def speckle(img):
<ide> # and a random amount of speckle noise
<ide>
<ide> def paint_text(text, w, h, rotate=False, ud=False, multi_fonts=False):
<del> surface = cairo.ImageSurface(cairo.FORMAT_RGB24, w, h)
<add> surface = cairo.ImageSurface(cairo.FORMAT_RGB24, width=w, height=h)
<ide> with cairo.Context(surface) as context:
<ide> context.set_source_rgb(1, 1, 1) # White
<ide> context.paint()
<ide> def get_batch(self, index, size, train):
<ide> # width and height are backwards from typical Keras convention
<ide> # because width is the time dimension when it gets fed into the RNN
<ide> if K.image_data_format() == 'channels_first':
<del> X_data = np.ones([size, 1, self.img_w, self.img_h])
<add> X_data = np.ones([size, 1, self.img_h, self.img_w])
<ide> else:
<del> X_data = np.ones([size, self.img_w, self.img_h, 1])
<add> X_data = np.ones([size, self.img_h, self.img_w, 1])
<ide>
<ide> labels = np.ones([size, self.absolute_max_string_len])
<ide> input_length = np.zeros([size, 1])
<ide> def get_batch(self, index, size, train):
<ide> # achieving translational invariance
<ide> if train and i > size - 4:
<ide> if K.image_data_format() == 'channels_first':
<del> X_data[i, 0, 0:self.img_w, :] = self.paint_func('')[0, :, :].T
<add> X_data[i, 0, 0:self.img_h, :] = self.paint_func('')[0, :, :]
<ide> else:
<del> X_data[i, 0:self.img_w, :, 0] = self.paint_func('',)[0, :, :].T
<add> X_data[i, 0:self.img_h, :, 0] = self.paint_func('',)[0, :, :]
<ide> labels[i, 0] = self.blank_label
<ide> input_length[i] = self.img_w // self.downsample_factor - 2
<ide> label_length[i] = 1
<ide> source_str.append('')
<ide> else:
<ide> if K.image_data_format() == 'channels_first':
<del> X_data[i, 0, 0:self.img_w, :] = self.paint_func(self.X_text[index + i])[0, :, :].T
<add> X_data[i, 0, 0:self.img_h, :] = self.paint_func(self.X_text[index + i])[0, :, :]
<ide> else:
<del> X_data[i, 0:self.img_w, :, 0] = self.paint_func(self.X_text[index + i])[0, :, :].T
<add> X_data[i, 0:self.img_h, :, 0] = self.paint_func(self.X_text[index + i])[0, :, :]
<ide> labels[i, :] = self.Y_data[index + i]
<ide> input_length[i] = self.img_w // self.downsample_factor - 2
<ide> label_length[i] = self.Y_len[index + i]
<ide> def on_epoch_end(self, epoch, logs={}):
<ide> the_input = word_batch['the_input'][i, 0, :, :]
<ide> else:
<ide> the_input = word_batch['the_input'][i, :, :, 0]
<del> pylab.imshow(the_input.T, cmap='Greys_r')
<add> pylab.imshow(the_input, cmap='Greys_r')
<ide> pylab.xlabel('Truth = \'%s\'\nDecoded = \'%s\'' % (word_batch['source_str'][i], res[i]))
<ide> fig = pylab.gcf()
<ide> fig.set_size_inches(10, 13)
<ide> def train(run_name, start_epoch, stop_epoch, img_w):
<ide> minibatch_size = 32
<ide>
<ide> if K.image_data_format() == 'channels_first':
<del> input_shape = (1, img_w, img_h)
<add> input_shape = (1, img_h, img_w)
<ide> else:
<del> input_shape = (img_w, img_h, 1)
<add> input_shape = (img_h, img_w, 1)
<ide>
<ide> fdir = os.path.dirname(get_file('wordlists.tgz',
<ide> origin='http://www.mythic-ai.com/datasets/wordlists.tgz', untar=True))
<ide> def train(run_name, start_epoch, stop_epoch, img_w):
<ide> name='conv2')(inner)
<ide> inner = MaxPooling2D(pool_size=(pool_size, pool_size), name='max2')(inner)
<ide>
<del> conv_to_rnn_dims = (img_w // (pool_size ** 2), (img_h // (pool_size ** 2)) * conv_filters)
<add> conv_to_rnn_dims = ((img_h // (pool_size ** 2)) * conv_filters, img_w // (pool_size ** 2))
<ide> inner = Reshape(target_shape=conv_to_rnn_dims, name='reshape')(inner)
<ide>
<ide> # cuts down input size going into RNN: | 1 |
Ruby | Ruby | remove extra sort from test | 7f5dd5b629cf4e43d60a40db9b7d13af6d6dfe7f | <ide><path>activerecord/test/cases/migration/change_schema_test.rb
<ide> def test_create_table_adds_id
<ide> t.column :foo, :string
<ide> end
<ide>
<del> assert_equal %w(foo id), connection.columns(:testings).map(&:name).sort
<add> assert_equal %w(id foo), connection.columns(:testings).map(&:name)
<ide> end
<ide>
<ide> def test_create_table_with_not_null_column
<ide> def test_create_table_with_primary_key_prefix_as_table_name_with_underscore
<ide> t.column :foo, :string
<ide> end
<ide>
<del> assert_equal %w(foo testing_id), connection.columns(:testings).map(&:name).sort
<add> assert_equal %w(testing_id foo), connection.columns(:testings).map(&:name)
<ide> end
<ide>
<ide> def test_create_table_with_primary_key_prefix_as_table_name
<ide> def test_create_table_with_primary_key_prefix_as_table_name
<ide> t.column :foo, :string
<ide> end
<ide>
<del> assert_equal %w(foo testingid), connection.columns(:testings).map(&:name).sort
<add> assert_equal %w(testingid foo), connection.columns(:testings).map(&:name)
<ide> end
<ide>
<ide> def test_create_table_raises_when_redefining_primary_key_column | 1 |
Ruby | Ruby | ask column if it is a pk | c1003d99b00b3afb5417b6853a3e2ba92638cbe8 | <ide><path>activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
<ide> def sql_type
<ide> base.type_to_sql(type.to_sym, limit, precision, scale)
<ide> end
<ide>
<add> def primary_key?
<add> type == :primary_key
<add> end
<add>
<ide> def to_sql
<ide> column_sql = "#{base.quote_column_name(name)} #{sql_type}"
<ide> column_options = {}
<ide> def new_column_definition(base, name, type)
<ide> end
<ide>
<ide> def primary_key_column_name
<del> primary_key_column = columns.detect { |c| c.type == :primary_key }
<add> primary_key_column = columns.detect { |c| c.primary_key? }
<ide> primary_key_column && primary_key_column.name
<ide> end
<ide> | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.