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
|
|---|---|---|---|---|---|
Python
|
Python
|
remove datasets requirement
|
d194d639abb51711ee212a61077fe91c0cfa727d
|
<ide><path>src/transformers/testing_utils.py
<ide>
<ide> from .deepspeed import is_deepspeed_available
<ide> from .file_utils import (
<del> is_datasets_available,
<ide> is_detectron2_available,
<ide> is_faiss_available,
<ide> is_flax_available,
<ide> def require_torch_tf32(test_case):
<ide> return test_case
<ide>
<ide>
<del>def require_datasets(test_case):
<del> """Decorator marking a test that requires datasets."""
<del>
<del> if not is_datasets_available():
<del> return unittest.skip("test requires `datasets`")(test_case)
<del> else:
<del> return test_case
<del>
<del>
<ide> def require_detectron2(test_case):
<ide> """Decorator marking a test that requires detectron2."""
<ide> if not is_detectron2_available():
<ide><path>tests/test_modeling_flax_wav2vec2.py
<ide> from transformers.testing_utils import (
<ide> is_librosa_available,
<ide> is_pyctcdecode_available,
<del> require_datasets,
<ide> require_flax,
<ide> require_librosa,
<ide> require_pyctcdecode,
<ide> def test_sample_negatives_with_attn_mask(self):
<ide>
<ide>
<ide> @require_flax
<del>@require_datasets
<ide> @require_soundfile
<ide> @slow
<ide> class FlaxWav2Vec2ModelIntegrationTest(unittest.TestCase):
<ide><path>tests/test_modeling_hubert.py
<ide>
<ide> from tests.test_modeling_common import floats_tensor, ids_tensor, random_attention_mask
<ide> from transformers import HubertConfig, is_torch_available
<del>from transformers.testing_utils import require_datasets, require_soundfile, require_torch, slow, torch_device
<add>from transformers.testing_utils import require_soundfile, require_torch, slow, torch_device
<ide>
<ide> from .test_configuration_common import ConfigTester
<ide> from .test_modeling_common import ModelTesterMixin, _config_zero_init
<ide> def test_compute_mask_indices_overlap(self):
<ide>
<ide>
<ide> @require_torch
<del>@require_datasets
<ide> @require_soundfile
<ide> @slow
<ide> class HubertModelIntegrationTest(unittest.TestCase):
<ide><path>tests/test_modeling_sew.py
<ide>
<ide> from tests.test_modeling_common import floats_tensor, ids_tensor, random_attention_mask
<ide> from transformers import SEWConfig, is_torch_available
<del>from transformers.testing_utils import require_datasets, require_soundfile, require_torch, slow, torch_device
<add>from transformers.testing_utils import require_soundfile, require_torch, slow, torch_device
<ide>
<ide> from .test_configuration_common import ConfigTester
<ide> from .test_modeling_common import ModelTesterMixin, _config_zero_init
<ide> def test_compute_mask_indices_overlap(self):
<ide>
<ide>
<ide> @require_torch
<del>@require_datasets
<ide> @require_soundfile
<ide> @slow
<ide> class SEWModelIntegrationTest(unittest.TestCase):
<ide><path>tests/test_modeling_sew_d.py
<ide>
<ide> from tests.test_modeling_common import floats_tensor, ids_tensor, random_attention_mask
<ide> from transformers import SEWDConfig, is_torch_available
<del>from transformers.testing_utils import require_datasets, require_soundfile, require_torch, slow, torch_device
<add>from transformers.testing_utils import require_soundfile, require_torch, slow, torch_device
<ide>
<ide> from .test_configuration_common import ConfigTester
<ide> from .test_modeling_common import ModelTesterMixin, _config_zero_init
<ide> def test_compute_mask_indices_overlap(self):
<ide>
<ide>
<ide> @require_torch
<del>@require_datasets
<ide> @require_soundfile
<ide> @slow
<ide> class SEWDModelIntegrationTest(unittest.TestCase):
<ide><path>tests/test_modeling_tf_hubert.py
<ide> import pytest
<ide>
<ide> from transformers import is_tf_available
<del>from transformers.testing_utils import require_datasets, require_soundfile, require_tf, slow
<add>from transformers.testing_utils import require_soundfile, require_tf, slow
<ide>
<ide> from .test_configuration_common import ConfigTester
<ide> from .test_modeling_tf_common import TFModelTesterMixin, ids_tensor
<ide> def test_compute_mask_indices_overlap(self):
<ide>
<ide> @require_tf
<ide> @slow
<del>@require_datasets
<ide> @require_soundfile
<ide> class TFHubertModelIntegrationTest(unittest.TestCase):
<ide> def _load_datasamples(self, num_samples):
<ide><path>tests/test_modeling_tf_wav2vec2.py
<ide>
<ide> from transformers import Wav2Vec2Config, is_tf_available
<ide> from transformers.file_utils import is_librosa_available, is_pyctcdecode_available
<del>from transformers.testing_utils import require_datasets, require_librosa, require_pyctcdecode, require_tf, slow
<add>from transformers.testing_utils import require_librosa, require_pyctcdecode, require_tf, slow
<ide>
<ide> from .test_configuration_common import ConfigTester
<ide> from .test_modeling_tf_common import TFModelTesterMixin, ids_tensor
<ide> def test_compute_mask_indices_overlap(self):
<ide>
<ide> @require_tf
<ide> @slow
<del>@require_datasets
<ide> class TFWav2Vec2ModelIntegrationTest(unittest.TestCase):
<ide> def _load_datasamples(self, num_samples):
<ide> from datasets import load_dataset
<ide><path>tests/test_modeling_unispeech.py
<ide>
<ide> from tests.test_modeling_common import floats_tensor, ids_tensor, random_attention_mask
<ide> from transformers import UniSpeechConfig, is_torch_available
<del>from transformers.testing_utils import require_datasets, require_soundfile, require_torch, slow, torch_device
<add>from transformers.testing_utils import require_soundfile, require_torch, slow, torch_device
<ide>
<ide> from .test_configuration_common import ConfigTester
<ide> from .test_modeling_common import ModelTesterMixin, _config_zero_init
<ide> def test_model_from_pretrained(self):
<ide>
<ide>
<ide> @require_torch
<del>@require_datasets
<ide> @require_soundfile
<ide> @slow
<ide> class UniSpeechModelIntegrationTest(unittest.TestCase):
<ide><path>tests/test_modeling_unispeech_sat.py
<ide>
<ide> from tests.test_modeling_common import floats_tensor, ids_tensor, random_attention_mask
<ide> from transformers import UniSpeechSatConfig, is_torch_available
<del>from transformers.testing_utils import require_datasets, require_soundfile, require_torch, slow, torch_device
<add>from transformers.testing_utils import require_soundfile, require_torch, slow, torch_device
<ide>
<ide> from .test_configuration_common import ConfigTester
<ide> from .test_modeling_common import ModelTesterMixin, _config_zero_init
<ide> def test_model_from_pretrained(self):
<ide>
<ide>
<ide> @require_torch
<del>@require_datasets
<ide> @require_soundfile
<ide> @slow
<ide> class UniSpeechSatModelIntegrationTest(unittest.TestCase):
<ide><path>tests/test_modeling_wav2vec2.py
<ide> is_pt_flax_cross_test,
<ide> is_pyctcdecode_available,
<ide> is_torchaudio_available,
<del> require_datasets,
<ide> require_pyctcdecode,
<ide> require_soundfile,
<ide> require_torch,
<ide> def test_sample_negatives_with_mask(self):
<ide>
<ide>
<ide> @require_torch
<del>@require_datasets
<ide> @require_soundfile
<ide> @slow
<ide> class Wav2Vec2ModelIntegrationTest(unittest.TestCase):
<ide><path>tests/test_pipelines_audio_classification.py
<ide> from transformers.testing_utils import (
<ide> is_pipeline_test,
<ide> nested_simplify,
<del> require_datasets,
<ide> require_tf,
<ide> require_torch,
<ide> require_torchaudio,
<ide> def run_pipeline_test(self, audio_classifier, examples):
<ide>
<ide> self.run_torchaudio(audio_classifier)
<ide>
<del> @require_datasets
<ide> @require_torchaudio
<ide> def run_torchaudio(self, audio_classifier):
<ide> import datasets
<ide> def test_small_model_pt(self):
<ide> )
<ide>
<ide> @require_torch
<del> @require_datasets
<ide> @slow
<ide> def test_large_model_pt(self):
<ide> import datasets
<ide><path>tests/test_pipelines_automatic_speech_recognition.py
<ide> Wav2Vec2ForCTC,
<ide> )
<ide> from transformers.pipelines import AutomaticSpeechRecognitionPipeline, pipeline
<del>from transformers.testing_utils import (
<del> is_pipeline_test,
<del> require_datasets,
<del> require_tf,
<del> require_torch,
<del> require_torchaudio,
<del> slow,
<del>)
<add>from transformers.testing_utils import is_pipeline_test, require_tf, require_torch, require_torchaudio, slow
<ide>
<ide> from .test_pipelines_common import ANY, PipelineTestCaseMeta
<ide>
<ide> def test_torch_small_no_tokenizer_files(self):
<ide> framework="pt",
<ide> )
<ide>
<del> @require_datasets
<ide> @require_torch
<ide> @slow
<ide> def test_torch_large(self):
<ide> def test_torch_large(self):
<ide> output = speech_recognizer(filename)
<ide> self.assertEqual(output, {"text": "A MAN SAID TO THE UNIVERSE SIR I EXIST"})
<ide>
<del> @require_datasets
<ide> @require_torch
<ide> @slow
<ide> def test_torch_speech_encoder_decoder(self):
<ide> def test_torch_speech_encoder_decoder(self):
<ide>
<ide> @slow
<ide> @require_torch
<del> @require_datasets
<ide> def test_simple_wav2vec2(self):
<ide> import numpy as np
<ide> from datasets import load_dataset
<ide> def test_simple_wav2vec2(self):
<ide> @slow
<ide> @require_torch
<ide> @require_torchaudio
<del> @require_datasets
<ide> def test_simple_s2t(self):
<ide> import numpy as np
<ide> from datasets import load_dataset
<ide> def test_simple_s2t(self):
<ide> @slow
<ide> @require_torch
<ide> @require_torchaudio
<del> @require_datasets
<ide> def test_xls_r_to_en(self):
<ide> speech_recognizer = pipeline(
<ide> task="automatic-speech-recognition",
<ide> def test_xls_r_to_en(self):
<ide> @slow
<ide> @require_torch
<ide> @require_torchaudio
<del> @require_datasets
<ide> def test_xls_r_from_en(self):
<ide> speech_recognizer = pipeline(
<ide> task="automatic-speech-recognition",
<ide><path>tests/test_pipelines_image_classification.py
<ide> from transformers.testing_utils import (
<ide> is_pipeline_test,
<ide> nested_simplify,
<del> require_datasets,
<ide> require_tf,
<ide> require_torch,
<ide> require_vision,
<ide> def get_test_pipeline(self, model, tokenizer, feature_extractor):
<ide> ]
<ide> return image_classifier, examples
<ide>
<del> @require_datasets
<ide> def run_pipeline_test(self, image_classifier, examples):
<ide> outputs = image_classifier("./tests/fixtures/tests_samples/COCO/000000039769.png")
<ide>
<ide><path>tests/test_pipelines_image_segmentation.py
<ide> from transformers.testing_utils import (
<ide> is_pipeline_test,
<ide> nested_simplify,
<del> require_datasets,
<ide> require_tf,
<ide> require_timm,
<ide> require_torch,
<ide> def get_test_pipeline(self, model, tokenizer, feature_extractor):
<ide> "./tests/fixtures/tests_samples/COCO/000000039769.png",
<ide> ]
<ide>
<del> @require_datasets
<ide> def run_pipeline_test(self, image_segmenter, examples):
<ide> outputs = image_segmenter("./tests/fixtures/tests_samples/COCO/000000039769.png", threshold=0.0)
<ide> self.assertEqual(outputs, [{"score": ANY(float), "label": ANY(str), "mask": ANY(str)}] * 12)
<ide><path>tests/test_pipelines_object_detection.py
<ide> from transformers.testing_utils import (
<ide> is_pipeline_test,
<ide> nested_simplify,
<del> require_datasets,
<ide> require_tf,
<ide> require_timm,
<ide> require_torch,
<ide> def get_test_pipeline(self, model, tokenizer, feature_extractor):
<ide> object_detector = ObjectDetectionPipeline(model=model, feature_extractor=feature_extractor)
<ide> return object_detector, ["./tests/fixtures/tests_samples/COCO/000000039769.png"]
<ide>
<del> @require_datasets
<ide> def run_pipeline_test(self, object_detector, examples):
<ide> outputs = object_detector("./tests/fixtures/tests_samples/COCO/000000039769.png", threshold=0.0)
<ide>
<ide><path>tests/test_retrieval_rag.py
<ide> from transformers.models.rag.configuration_rag import RagConfig
<ide> from transformers.models.rag.retrieval_rag import CustomHFIndex, RagRetriever
<ide> from transformers.models.roberta.tokenization_roberta import VOCAB_FILES_NAMES as BART_VOCAB_FILES_NAMES
<del>from transformers.testing_utils import (
<del> require_datasets,
<del> require_faiss,
<del> require_sentencepiece,
<del> require_tokenizers,
<del> require_torch,
<del>)
<add>from transformers.testing_utils import require_faiss, require_sentencepiece, require_tokenizers, require_torch
<ide>
<ide>
<ide> if is_faiss_available():
<ide> import faiss
<ide>
<ide>
<ide> @require_faiss
<del>@require_datasets
<ide> class RagRetrieverTest(TestCase):
<ide> def setUp(self):
<ide> self.tmpdirname = tempfile.mkdtemp()
<ide><path>tests/test_tokenization_rag.py
<ide> from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES as DPR_VOCAB_FILES_NAMES
<ide> from transformers.models.dpr.configuration_dpr import DPRConfig
<ide> from transformers.models.roberta.tokenization_roberta import VOCAB_FILES_NAMES as BART_VOCAB_FILES_NAMES
<del>from transformers.testing_utils import require_datasets, require_faiss, require_tokenizers, require_torch, slow
<add>from transformers.testing_utils import require_faiss, require_tokenizers, require_torch, slow
<ide>
<ide>
<ide> if is_torch_available() and is_datasets_available() and is_faiss_available():
<ide>
<ide>
<ide> @require_faiss
<del>@require_datasets
<ide> @require_torch
<ide> class RagTokenizerTest(TestCase):
<ide> def setUp(self):
<ide><path>tests/test_trainer.py
<ide> get_gpu_count,
<ide> get_tests_dir,
<ide> is_staging_test,
<del> require_datasets,
<ide> require_optuna,
<ide> require_ray,
<ide> require_sentencepiece,
<ide> def test_reproducible_training(self):
<ide> trainer.train()
<ide> self.check_trained_model(trainer.model, alternate_seed=True)
<ide>
<del> @require_datasets
<ide> def test_trainer_with_datasets(self):
<ide> import datasets
<ide>
<ide><path>tests/test_trainer_seq2seq.py
<ide>
<ide> from transformers import BertTokenizer, EncoderDecoderModel, Seq2SeqTrainer, Seq2SeqTrainingArguments
<ide> from transformers.file_utils import is_datasets_available
<del>from transformers.testing_utils import TestCasePlus, require_datasets, require_torch, slow
<add>from transformers.testing_utils import TestCasePlus, require_torch, slow
<ide>
<ide>
<ide> if is_datasets_available():
<ide> class Seq2seqTrainerTester(TestCasePlus):
<ide> @slow
<ide> @require_torch
<del> @require_datasets
<ide> def test_finetune_bert2bert(self):
<ide> bert2bert = EncoderDecoderModel.from_encoder_decoder_pretrained("prajjwal1/bert-tiny", "prajjwal1/bert-tiny")
<ide> tokenizer = BertTokenizer.from_pretrained("bert-base-uncased")
| 19
|
Python
|
Python
|
add binomial heap
|
f31a812c468e41c3f5f7f170ae1dd5fa13bae6dd
|
<ide><path>data_structures/heap/binomial_heap.py
<add>"""
<add> Binomial Heap
<add>
<add> Reference: Advanced Data Structures, Peter Brass
<add>"""
<add>
<add>
<add>class Node:
<add> """
<add> Node in a doubly-linked binomial tree, containing:
<add> - value
<add> - size of left subtree
<add> - link to left, right and parent nodes
<add> """
<add>
<add> def __init__(self, val):
<add> self.val = val
<add> # Number of nodes in left subtree
<add> self.left_tree_size = 0
<add> self.left = None
<add> self.right = None
<add> self.parent = None
<add>
<add> def mergeTrees(self, other):
<add> """
<add> In-place merge of two binomial trees of equal size.
<add> Returns the root of the resulting tree
<add> """
<add> assert (
<add> self.left_tree_size == other.left_tree_size
<add> ), "Unequal Sizes of Blocks"
<add>
<add> if self.val < other.val:
<add> other.left = self.right
<add> other.parent = None
<add> if self.right:
<add> self.right.parent = other
<add> self.right = other
<add> self.left_tree_size = (
<add> self.left_tree_size * 2 + 1
<add> )
<add> return self
<add> else:
<add> self.left = other.right
<add> self.parent = None
<add> if other.right:
<add> other.right.parent = self
<add> other.right = self
<add> other.left_tree_size = (
<add> other.left_tree_size * 2 + 1
<add> )
<add> return other
<add>
<add>
<add>class BinomialHeap:
<add> """
<add> Min-oriented priority queue implemented with the Binomial Heap data
<add> structure implemented with the BinomialHeap class. It supports:
<add>
<add> - Insert element in a heap with n elemnts: Guaranteed logn, amoratized 1
<add> - Merge (meld) heaps of size m and n: O(logn + logm)
<add> - Delete Min: O(logn)
<add> - Peek (return min without deleting it): O(1)
<add>
<add> Example:
<add>
<add> Create a random permutation of 30 integers to be inserted and
<add> 19 of them deleted
<add> >>> import numpy as np
<add> >>> permutation = np.random.permutation(list(range(30)))
<add>
<add> Create a Heap and insert the 30 integers
<add>
<add> __init__() test
<add> >>> first_heap = BinomialHeap()
<add>
<add> 30 inserts - insert() test
<add> >>> for number in permutation:
<add> ... first_heap.insert(number)
<add>
<add> Size test
<add> >>> print(first_heap.size)
<add> 30
<add>
<add> Deleting - delete() test
<add> >>> for i in range(25):
<add> ... print(first_heap.deleteMin(), end=" ")
<add> 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
<add>
<add> Create a new Heap
<add> >>> second_heap = BinomialHeap()
<add> >>> vals = [17, 20, 31, 34]
<add> >>> for value in vals:
<add> ... second_heap.insert(value)
<add>
<add>
<add> The heap should have the following structure:
<add>
<add> 17
<add> / \
<add> # 31
<add> / \
<add> 20 34
<add> / \ / \
<add> # # # #
<add>
<add> preOrder() test
<add> >>> print(second_heap.preOrder())
<add> [(17, 0), ('#', 1), (31, 1), (20, 2), ('#', 3), ('#', 3), (34, 2), ('#', 3), ('#', 3)]
<add>
<add> printing Heap - __str__() test
<add> >>> print(second_heap)
<add> 17
<add> -#
<add> -31
<add> --20
<add> ---#
<add> ---#
<add> --34
<add> ---#
<add> ---#
<add>
<add> mergeHeaps() test
<add> >>> merged = second_heap.mergeHeaps(first_heap)
<add> >>> merged.peek()
<add> 17
<add>
<add> values in merged heap; (merge is inplace)
<add> >>> while not first_heap.isEmpty():
<add> ... print(first_heap.deleteMin(), end=" ")
<add> 17 20 25 26 27 28 29 31 34
<add>
<add> """
<add>
<add> def __init__(
<add> self, bottom_root=None, min_node=None, heap_size=0
<add> ):
<add> self.size = heap_size
<add> self.bottom_root = bottom_root
<add> self.min_node = min_node
<add>
<add> def mergeHeaps(self, other):
<add> """
<add> In-place merge of two binomial heaps.
<add> Both of them become the resulting merged heap
<add> """
<add>
<add> # Empty heaps corner cases
<add> if other.size == 0:
<add> return
<add> if self.size == 0:
<add> self.size = other.size
<add> self.bottom_root = other.bottom_root
<add> self.min_node = other.min_node
<add> return
<add> # Update size
<add> self.size = self.size + other.size
<add>
<add> # Update min.node
<add> if self.min_node.val > other.min_node.val:
<add> self.min_node = other.min_node
<add> # Merge
<add>
<add> # Order roots by left_subtree_size
<add> combined_roots_list = []
<add> i, j = self.bottom_root, other.bottom_root
<add> while i or j:
<add> if i and (
<add> (not j)
<add> or i.left_tree_size < j.left_tree_size
<add> ):
<add> combined_roots_list.append((i, True))
<add> i = i.parent
<add> else:
<add> combined_roots_list.append((j, False))
<add> j = j.parent
<add> # Insert links between them
<add> for i in range(len(combined_roots_list) - 1):
<add> if (
<add> combined_roots_list[i][1]
<add> != combined_roots_list[i + 1][1]
<add> ):
<add> combined_roots_list[i][
<add> 0
<add> ].parent = combined_roots_list[i + 1][0]
<add> combined_roots_list[i + 1][
<add> 0
<add> ].left = combined_roots_list[i][0]
<add> # Consecutively merge roots with same left_tree_size
<add> i = combined_roots_list[0][0]
<add> while i.parent:
<add> if (
<add> (
<add> i.left_tree_size
<add> == i.parent.left_tree_size
<add> )
<add> and (not i.parent.parent)
<add> ) or (
<add> i.left_tree_size == i.parent.left_tree_size
<add> and i.left_tree_size
<add> != i.parent.parent.left_tree_size
<add> ):
<add>
<add> # Neighbouring Nodes
<add> previous_node = i.left
<add> next_node = i.parent.parent
<add>
<add> # Merging trees
<add> i = i.mergeTrees(i.parent)
<add>
<add> # Updating links
<add> i.left = previous_node
<add> i.parent = next_node
<add> if previous_node:
<add> previous_node.parent = i
<add> if next_node:
<add> next_node.left = i
<add> else:
<add> i = i.parent
<add> # Updating self.bottom_root
<add> while i.left:
<add> i = i.left
<add> self.bottom_root = i
<add>
<add> # Update other
<add> other.size = self.size
<add> other.bottom_root = self.bottom_root
<add> other.min_node = self.min_node
<add>
<add> # Return the merged heap
<add> return self
<add>
<add> def insert(self, val):
<add> """
<add> insert a value in the heap
<add> """
<add> if self.size == 0:
<add> self.bottom_root = Node(val)
<add> self.size = 1
<add> self.min_node = self.bottom_root
<add> else:
<add> # Create new node
<add> new_node = Node(val)
<add>
<add> # Update size
<add> self.size += 1
<add>
<add> # update min_node
<add> if val < self.min_node.val:
<add> self.min_node = new_node
<add> # Put new_node as a bottom_root in heap
<add> self.bottom_root.left = new_node
<add> new_node.parent = self.bottom_root
<add> self.bottom_root = new_node
<add>
<add> # Consecutively merge roots with same left_tree_size
<add> while (
<add> self.bottom_root.parent
<add> and self.bottom_root.left_tree_size
<add> == self.bottom_root.parent.left_tree_size
<add> ):
<add>
<add> # Next node
<add> next_node = self.bottom_root.parent.parent
<add>
<add> # Merge
<add> self.bottom_root = self.bottom_root.mergeTrees(
<add> self.bottom_root.parent
<add> )
<add>
<add> # Update Links
<add> self.bottom_root.parent = next_node
<add> self.bottom_root.left = None
<add> if next_node:
<add> next_node.left = self.bottom_root
<add>
<add> def peek(self):
<add> """
<add> return min element without deleting it
<add> """
<add> return self.min_node.val
<add>
<add> def isEmpty(self):
<add> return self.size == 0
<add>
<add> def deleteMin(self):
<add> """
<add> delete min element and return it
<add> """
<add> # assert not self.isEmpty(), "Empty Heap"
<add>
<add> # Save minimal value
<add> min_value = self.min_node.val
<add>
<add> # Last element in heap corner case
<add> if self.size == 1:
<add> # Update size
<add> self.size = 0
<add>
<add> # Update bottom root
<add> self.bottom_root = None
<add>
<add> # Update min_node
<add> self.min_node = None
<add>
<add> return min_value
<add> # No right subtree corner case
<add> # The structure of the tree implies that this should be the bottom root
<add> # and there is at least one other root
<add> if self.min_node.right == None:
<add> # Update size
<add> self.size -= 1
<add>
<add> # Update bottom root
<add> self.bottom_root = self.bottom_root.parent
<add> self.bottom_root.left = None
<add>
<add> # Update min_node
<add> self.min_node = self.bottom_root
<add> i = self.bottom_root.parent
<add> while i:
<add> if i.val < self.min_node.val:
<add> self.min_node = i
<add> i = i.parent
<add> return min_value
<add> # General case
<add> # Find the BinomialHeap of the right subtree of min_node
<add> bottom_of_new = self.min_node.right
<add> bottom_of_new.parent = None
<add> min_of_new = bottom_of_new
<add> size_of_new = 1
<add>
<add> # Size, min_node and bottom_root
<add> while bottom_of_new.left:
<add> size_of_new = size_of_new * 2 + 1
<add> bottom_of_new = bottom_of_new.left
<add> if bottom_of_new.val < min_of_new.val:
<add> min_of_new = bottom_of_new
<add> # Corner case of single root on top left path
<add> if (not self.min_node.left) and (
<add> not self.min_node.parent
<add> ):
<add> self.size = size_of_new
<add> self.bottom_root = bottom_of_new
<add> self.min_node = min_of_new
<add> # print("Single root, multiple nodes case")
<add> return min_value
<add> # Remaining cases
<add> # Construct heap of right subtree
<add> newHeap = BinomialHeap(
<add> bottom_root=bottom_of_new,
<add> min_node=min_of_new,
<add> heap_size=size_of_new,
<add> )
<add>
<add> # Update size
<add> self.size = self.size - 1 - size_of_new
<add>
<add> # Neighbour nodes
<add> previous_node = self.min_node.left
<add> next_node = self.min_node.parent
<add>
<add> # Initialize new bottom_root and min_node
<add> self.min_node = previous_node or next_node
<add> self.bottom_root = next_node
<add>
<add> # Update links of previous_node and search below for new min_node and
<add> # bottom_root
<add> if previous_node:
<add> previous_node.parent = next_node
<add>
<add> # Update bottom_root and search for min_node below
<add> self.bottom_root = previous_node
<add> self.min_node = previous_node
<add> while self.bottom_root.left:
<add> self.bottom_root = self.bottom_root.left
<add> if self.bottom_root.val < self.min_node.val:
<add> self.min_node = self.bottom_root
<add> if next_node:
<add> next_node.left = previous_node
<add>
<add> # Search for new min_node above min_node
<add> i = next_node
<add> while i:
<add> if i.val < self.min_node.val:
<add> self.min_node = i
<add> i = i.parent
<add> # Merge heaps
<add> self.mergeHeaps(newHeap)
<add>
<add> return min_value
<add>
<add> def preOrder(self):
<add> """
<add> Returns the Pre-order representation of the heap including
<add> values of nodes plus their level distance from the root;
<add> Empty nodes appear as #
<add> """
<add> # Find top root
<add> top_root = self.bottom_root
<add> while top_root.parent:
<add> top_root = top_root.parent
<add> # preorder
<add> heap_preOrder = []
<add> self.__traversal(top_root, heap_preOrder)
<add> return heap_preOrder
<add>
<add> def __traversal(self, curr_node, preorder, level=0):
<add> """
<add> Pre-order traversal of nodes
<add> """
<add> if curr_node:
<add> preorder.append((curr_node.val, level))
<add> self.__traversal(
<add> curr_node.left, preorder, level + 1
<add> )
<add> self.__traversal(
<add> curr_node.right, preorder, level + 1
<add> )
<add> else:
<add> preorder.append(("#", level))
<add>
<add> def __str__(self):
<add> """
<add> Overwriting str for a pre-order print of nodes in heap;
<add> Performance is poor, so use only for small examples
<add> """
<add> if self.isEmpty():
<add> return ""
<add> preorder_heap = self.preOrder()
<add>
<add> return "\n".join(
<add> ("-" * level + str(value))
<add> for value, level in preorder_heap
<add> )
<add>
<add>
<add># Unit Tests
<add>if __name__ == "__main__":
<add> import doctest
<add>
<add> doctest.testmod()
| 1
|
PHP
|
PHP
|
use link to migration guide instead
|
15aba9ad3db623e885d3c036065c1e88fb1be7ff
|
<ide><path>src/Controller/Component/RequestHandlerComponent.php
<ide> * It can also check for HTTP caching headers like `Last-Modified`, `If-Modified-Since`
<ide> * etc. and return a response accordingly.
<ide> *
<del> * ## Replacing Deprecated methods
<del> *
<del> * - Replace `accepts()` with `$this->request->accepts()`.
<del> * - Replace `requestedWith()` with a custom request detector.
<del> * eg. `$this->request->is('json')`
<del> * - Replace `prefers()` with `ContentTypeNegotiation` or the negotiation features
<del> * on `Controller`.
<del> * - Replace `renderAs()` with controller content negotiation features on `Controller`.
<del> * - Replace `checkHttpCache` option with `CheckHttpCacheComponent`.
<del> *
<ide> * @link https://book.cakephp.org/4/en/controllers/components/request-handling.html
<del> * @deprecated 4.4.0 Use altenative methods listed above.
<add> * @deprecated 4.4.0 See the 4.4 migration guide for how to upgrade.
<add> * https://book.cakephp.org/4/en/appendices/4-4-migration-guide.html#requesthandlercomponent
<ide> */
<ide> class RequestHandlerComponent extends Component
<ide> {
| 1
|
Ruby
|
Ruby
|
add support for fish shell completions
|
de43ac75032e7a1170b0def6500dffb48dba9bf7
|
<ide><path>Library/Homebrew/caveats.rb
<ide> def caveats
<ide> caveats << f.keg_only_text if f.keg_only? && f.respond_to?(:keg_only_text)
<ide> caveats << bash_completion_caveats
<ide> caveats << zsh_completion_caveats
<add> caveats << fish_completion_caveats
<ide> caveats << plist_caveats
<ide> caveats << python_caveats
<ide> caveats << app_caveats
<ide> def zsh_completion_caveats
<ide> end
<ide> end
<ide>
<add> def fish_completion_caveats
<add> if keg and keg.completion_installed? :fish and which("fish") then <<-EOS.undent
<add> fish completion has been installed to:
<add> #{HOMEBREW_PREFIX}/share/fish/vendor_completions.d
<add> EOS
<add> end
<add> end
<add>
<ide> def python_caveats
<ide> return unless keg
<ide> return unless keg.python_site_packages_installed?
<ide><path>Library/Homebrew/formula.rb
<ide> def var; HOMEBREW_PREFIX+'var' end
<ide> # installed.
<ide> # This is symlinked into `HOMEBREW_PREFIX` after installation or with
<ide> # `brew link` for formulae that are not keg-only.
<del> def bash_completion; prefix+'etc/bash_completion.d' end
<add> def bash_completion; prefix+'etc/bash_completion.d' end
<ide>
<ide> # The directory where the formula's ZSH completion files should be
<ide> # installed.
<ide> # This is symlinked into `HOMEBREW_PREFIX` after installation or with
<ide> # `brew link` for formulae that are not keg-only.
<del> def zsh_completion; share+'zsh/site-functions' end
<add> def zsh_completion; share+'zsh/site-functions' end
<add>
<add> # The directory where the formula's fish completion files should be
<add> # installed.
<add> # This is symlinked into `HOMEBREW_PREFIX` after installation or with
<add> # `brew link` for formulae that are not keg-only.
<add> def fish_completion; share+'fish/vendor_completions.d' end
<ide>
<ide> # The directory used for as the prefix for {#etc} and {#var} files on
<ide> # installation so, despite not being in `HOMEBREW_CELLAR`, they are installed
<ide><path>Library/Homebrew/keg.rb
<ide> def completion_installed? shell
<ide> dir = case shell
<ide> when :bash then path.join("etc", "bash_completion.d")
<ide> when :zsh then path.join("share", "zsh", "site-functions")
<add> when :fish then path.join("share", "fish", "vendor_completions.d")
<ide> end
<ide> dir && dir.directory? && dir.children.any?
<ide> end
| 3
|
Python
|
Python
|
remove redundant ``session.commit()`` in migration
|
e81c7df9dc634d7bbad401c677c71e627f7601b8
|
<ide><path>airflow/migrations/versions/cc1e65623dc7_add_max_tries_column_to_task_instance.py
<ide> def upgrade():
<ide> sessionmaker = sa.orm.sessionmaker()
<ide> session = sessionmaker(bind=connection)
<ide> if not bool(session.query(TaskInstance).first()):
<del> session.commit()
<ide> return
<ide> dagbag = DagBag(settings.DAGS_FOLDER)
<ide> query = session.query(sa.func.count(TaskInstance.max_tries)).filter(TaskInstance.max_tries == -1)
| 1
|
Java
|
Java
|
extract unsubscribetester to top level
|
12954a69895db8e60522c72557b93c53973dc436
|
<ide><path>rxjava-core/src/main/java/rx/subjects/RepeatSubject.java
<ide>
<ide> import org.junit.Test;
<ide> import org.mockito.Mockito;
<del>import rx.Observable;
<ide> import rx.Observer;
<ide> import rx.Subscription;
<ide> import rx.subscriptions.Subscriptions;
<add>import rx.testing.UnsubscribeTester;
<ide> import rx.util.functions.Func1;
<ide>
<ide> import java.util.ArrayList;
<ide> import java.util.List;
<ide> import java.util.Map;
<ide>
<del>import static org.junit.Assert.assertTrue;
<ide> import static org.mockito.Matchers.any;
<ide> import static org.mockito.Mockito.mock;
<ide> import static org.mockito.Mockito.times;
<ide> private void assertObservedUntilTwo(Observer<String> aObserver)
<ide> public void testUnsubscribeFromOnNext() {
<ide> RepeatSubject<Object> subject = RepeatSubject.create();
<ide>
<del> UnsubscribeTest test1 = UnsubscribeTest.createOnNext(subject);
<del> UnsubscribeTest test2 = UnsubscribeTest.createOnNext(subject);
<add> UnsubscribeTester test1 = UnsubscribeTester.createOnNext(subject);
<add> UnsubscribeTester test2 = UnsubscribeTester.createOnNext(subject);
<ide>
<ide> subject.onNext("one");
<ide>
<ide> public void testUnsubscribeFromOnNext() {
<ide> public void testUnsubscribeFromOnCompleted() {
<ide> RepeatSubject<Object> subject = RepeatSubject.create();
<ide>
<del> UnsubscribeTest test1 = UnsubscribeTest.createOnCompleted(subject);
<del> UnsubscribeTest test2 = UnsubscribeTest.createOnCompleted(subject);
<add> UnsubscribeTester test1 = UnsubscribeTester.createOnCompleted(subject);
<add> UnsubscribeTester test2 = UnsubscribeTester.createOnCompleted(subject);
<ide>
<ide> subject.onCompleted();
<ide>
<ide> public void testUnsubscribeFromOnCompleted() {
<ide> public void testUnsubscribeFromOnError() {
<ide> RepeatSubject<Object> subject = RepeatSubject.create();
<ide>
<del> UnsubscribeTest test1 = UnsubscribeTest.createOnError(subject);
<del> UnsubscribeTest test2 = UnsubscribeTest.createOnError(subject);
<add> UnsubscribeTester test1 = UnsubscribeTester.createOnError(subject);
<add> UnsubscribeTester test2 = UnsubscribeTester.createOnError(subject);
<ide>
<ide> subject.onError(new Exception());
<ide>
<ide> test1.assertPassed();
<ide> test2.assertPassed();
<ide> }
<ide>
<del> private static class UnsubscribeTest
<del> {
<del> private Subscription subscription;
<del>
<del> private UnsubscribeTest() {}
<del>
<del> public static <T> UnsubscribeTest createOnNext(Observable<T> observable)
<del> {
<del> final UnsubscribeTest test = new UnsubscribeTest();
<del> test.setSubscription(observable.subscribe(new Observer<T>()
<del> {
<del> @Override
<del> public void onCompleted()
<del> {
<del> }
<del>
<del> @Override
<del> public void onError(Exception e)
<del> {
<del> }
<del>
<del> @Override
<del> public void onNext(T args)
<del> {
<del> test.doUnsubscribe();
<del> }
<del> }));
<del> return test;
<del> }
<del>
<del> public static <T> UnsubscribeTest createOnCompleted(Observable<T> observable)
<del> {
<del> final UnsubscribeTest test = new UnsubscribeTest();
<del> test.setSubscription(observable.subscribe(new Observer<T>()
<del> {
<del> @Override
<del> public void onCompleted()
<del> {
<del> test.doUnsubscribe();
<del> }
<del>
<del> @Override
<del> public void onError(Exception e)
<del> {
<del> }
<del>
<del> @Override
<del> public void onNext(T args)
<del> {
<del> }
<del> }));
<del> return test;
<del> }
<del>
<del> public static <T> UnsubscribeTest createOnError(Observable<T> observable)
<del> {
<del> final UnsubscribeTest test = new UnsubscribeTest();
<del> test.setSubscription(observable.subscribe(new Observer<T>()
<del> {
<del> @Override
<del> public void onCompleted()
<del> {
<del> }
<del>
<del> @Override
<del> public void onError(Exception e)
<del> {
<del> test.doUnsubscribe();
<del> }
<del>
<del> @Override
<del> public void onNext(T args)
<del> {
<del> }
<del> }));
<del> return test;
<del> }
<del>
<del> private void setSubscription(Subscription subscription)
<del> {
<del> this.subscription = subscription;
<del> }
<del>
<del> private void doUnsubscribe()
<del> {
<del> Subscription subscription = this.subscription;
<del> this.subscription = null;
<del> subscription.unsubscribe();
<del> }
<del>
<del> public void assertPassed()
<del> {
<del> assertTrue("expected notification was received", subscription == null);
<del> }
<del> }
<ide> }
<ide> }
<ide><path>rxjava-core/src/main/java/rx/testing/UnsubscribeTester.java
<add>package rx.testing;
<add>
<add>import rx.Observable;
<add>import rx.Observer;
<add>import rx.Subscription;
<add>
<add>import static org.junit.Assert.assertTrue;
<add>
<add>public class UnsubscribeTester
<add>{
<add> private Subscription subscription;
<add>
<add> public UnsubscribeTester() {}
<add>
<add> public static <T> UnsubscribeTester createOnNext(Observable<T> observable)
<add> {
<add> final UnsubscribeTester test = new UnsubscribeTester();
<add> test.setSubscription(observable.subscribe(new Observer<T>()
<add> {
<add> @Override
<add> public void onCompleted()
<add> {
<add> }
<add>
<add> @Override
<add> public void onError(Exception e)
<add> {
<add> }
<add>
<add> @Override
<add> public void onNext(T args)
<add> {
<add> test.doUnsubscribe();
<add> }
<add> }));
<add> return test;
<add> }
<add>
<add> public static <T> UnsubscribeTester createOnCompleted(Observable<T> observable)
<add> {
<add> final UnsubscribeTester test = new UnsubscribeTester();
<add> test.setSubscription(observable.subscribe(new Observer<T>()
<add> {
<add> @Override
<add> public void onCompleted()
<add> {
<add> test.doUnsubscribe();
<add> }
<add>
<add> @Override
<add> public void onError(Exception e)
<add> {
<add> }
<add>
<add> @Override
<add> public void onNext(T args)
<add> {
<add> }
<add> }));
<add> return test;
<add> }
<add>
<add> public static <T> UnsubscribeTester createOnError(Observable<T> observable)
<add> {
<add> final UnsubscribeTester test = new UnsubscribeTester();
<add> test.setSubscription(observable.subscribe(new Observer<T>()
<add> {
<add> @Override
<add> public void onCompleted()
<add> {
<add> }
<add>
<add> @Override
<add> public void onError(Exception e)
<add> {
<add> test.doUnsubscribe();
<add> }
<add>
<add> @Override
<add> public void onNext(T args)
<add> {
<add> }
<add> }));
<add> return test;
<add> }
<add>
<add> private void setSubscription(Subscription subscription)
<add> {
<add> this.subscription = subscription;
<add> }
<add>
<add> private void doUnsubscribe()
<add> {
<add> Subscription subscription = this.subscription;
<add> this.subscription = null;
<add> subscription.unsubscribe();
<add> }
<add>
<add> public void assertPassed()
<add> {
<add> assertTrue("expected notification was received", subscription == null);
<add> }
<add>}
| 2
|
Text
|
Text
|
correct first argument name into mapstatetoprops
|
ae866e34ef4a03a0d5bc5ce7f2ae23fcc6784c21
|
<ide><path>docs/recipes/WritingTests.md
<ide> import { connect } from 'react-redux'
<ide> export class App extends Component { /* ... */ }
<ide>
<ide> // Use default export for the connected component (for app)
<del>export default connect(mapDispatchToProps)(App)
<add>export default connect(mapStateToProps)(App)
<ide> ```
<ide>
<ide> Since the default export is still the decorated component, the import statement pictured above will work as before so you won’t have to change your application code. However, you can now import the undecorated `App` components in your test file like this:
| 1
|
Text
|
Text
|
provide a template for new issues
|
6c11d07759bcb6e697d2aea37ce7e88b5e0c0260
|
<ide><path>CONTRIBUTING.md
<ide> Please also include the steps required to reproduce the problem if
<ide> possible and applicable. This information will help us review and fix
<ide> your issue faster.
<ide>
<add>### Template
<add>
<add>```
<add>Description of problem:
<add>
<add>
<add>`docker version`:
<add>
<add>
<add>`docker info`:
<add>
<add>
<add>`uname -a`:
<add>
<add>
<add>Environment details (AWS, VirtualBox, physical, etc.):
<add>
<add>
<add>How reproducible:
<add>
<add>
<add>Steps to Reproduce:
<add>1.
<add>2.
<add>3.
<add>
<add>
<add>Actual Results:
<add>
<add>
<add>Expected Results:
<add>
<add>
<add>Additional info:
<add>
<add>
<add>
<add>```
<add>
<ide> ## Build Environment
<ide>
<ide> For instructions on setting up your development environment, please
| 1
|
Javascript
|
Javascript
|
throw error if port/path does not exist in options
|
4a0466f23a67a8b17d652ea5c5b89dd202f3160c
|
<ide><path>lib/net.js
<ide> const errors = require('internal/errors');
<ide> const {
<ide> ERR_INVALID_ADDRESS_FAMILY,
<ide> ERR_INVALID_ARG_TYPE,
<add> ERR_INVALID_ARG_VALUE,
<ide> ERR_INVALID_FD_TYPE,
<ide> ERR_INVALID_IP_ADDRESS,
<ide> ERR_INVALID_OPT_VALUE,
<ide> Server.prototype.listen = function(...args) {
<ide> return this;
<ide> }
<ide>
<add> if (!(('port' in options) || ('path' in options))) {
<add> throw new ERR_INVALID_ARG_VALUE('options', options,
<add> 'must have the property "port" or "path"');
<add> }
<add>
<ide> throw new ERR_INVALID_OPT_VALUE('options', util.inspect(options));
<ide> };
<ide>
<ide><path>test/parallel/test-net-server-listen-options.js
<ide> const listenOnPort = [
<ide> const block = () => {
<ide> net.createServer().listen(options, common.mustNotCall());
<ide> };
<del> common.expectsError(block,
<del> {
<del> code: 'ERR_INVALID_OPT_VALUE',
<del> type: TypeError,
<del> message: /^The value "{.*}" is invalid for option "options"$/
<del> });
<add>
<add> if (typeof options === 'object' &&
<add> !(('port' in options) || ('path' in options))) {
<add> common.expectsError(block,
<add> {
<add> code: 'ERR_INVALID_ARG_VALUE',
<add> type: TypeError,
<add> message: /^The argument 'options' must have the property "port" or "path"\. Received .+$/,
<add> });
<add> } else {
<add> common.expectsError(block,
<add> {
<add> code: 'ERR_INVALID_OPT_VALUE',
<add> type: TypeError,
<add> message: /^The value "{.*}" is invalid for option "options"(?:\. .+)?$/,
<add> });
<add> }
<ide> }
<ide>
<ide> shouldFailToListen(false, { port: false });
<ide> const listenOnPort = [
<ide> shouldFailToListen({ fd: -1 });
<ide> // Invalid path in listen(options)
<ide> shouldFailToListen({ path: -1 });
<del> // Host without port
<add>
<add> // Neither port or path are specified in options
<add> shouldFailToListen({});
<ide> shouldFailToListen({ host: 'localhost' });
<add> shouldFailToListen({ host: 'localhost:3000' });
<add> shouldFailToListen({ host: { port: 3000 } });
<add> shouldFailToListen({ exclusive: true });
<ide> }
| 2
|
Text
|
Text
|
fix travis links in readme
|
18a70fff662488926c719715086dbc53b7c63aad
|
<ide><path>README.md
<ide> We encourage you to contribute to Ruby on Rails! Please check out the
<ide>
<ide> ## Code Status
<ide>
<del>* [](http://travis-ci.org/rails/rails)
<add>* [](https://travis-ci.org/rails/rails)
<ide> * [](https://gemnasium.com/rails/rails)
<ide>
<ide> ## License
| 1
|
Mixed
|
Javascript
|
add abortsignal support
|
20de5f7efce655d435cfb5ae0811577314fbdeb9
|
<ide><path>doc/api/child_process.md
<ide> lsExample();
<ide> <!-- YAML
<ide> added: v0.1.91
<ide> changes:
<add> - version: REPLACEME
<add> pr-url: https://github.com/nodejs/node/pull/36308
<add> description: AbortSignal support was added.
<ide> - version: v8.8.0
<ide> pr-url: https://github.com/nodejs/node/pull/15380
<ide> description: The `windowsHide` option is supported now.
<ide> changes:
<ide> `'/bin/sh'` on Unix, and `process.env.ComSpec` on Windows. A different
<ide> shell can be specified as a string. See [Shell requirements][] and
<ide> [Default Windows shell][]. **Default:** `false` (no shell).
<add> * `signal` {AbortSignal} allows aborting the execFile using an AbortSignal
<ide> * `callback` {Function} Called with the output when process terminates.
<ide> * `error` {Error}
<ide> * `stdout` {string|Buffer}
<ide> getVersion();
<ide> function. Any input containing shell metacharacters may be used to trigger
<ide> arbitrary command execution.**
<ide>
<add>If the `signal` option is enabled, calling `.abort()` on the corresponding
<add>`AbortController` is similar to calling `.kill()` on the child process except
<add>the error passed to the callback will be an `AbortError`:
<add>
<add>```js
<add>const controller = new AbortController();
<add>const { signal } = controller;
<add>const child = execFile('node', ['--version'], { signal }, (error) => {
<add> console.log(error); // an AbortError
<add>});
<add>signal.abort();
<add>```
<add>
<ide> ### `child_process.fork(modulePath[, args][, options])`
<ide> <!-- YAML
<ide> added: v0.5.0
<ide><path>lib/child_process.js
<ide> let debug = require('internal/util/debuglog').debuglog(
<ide> );
<ide> const { Buffer } = require('buffer');
<ide> const { Pipe, constants: PipeConstants } = internalBinding('pipe_wrap');
<add>
<add>const {
<add> AbortError,
<add> codes: errorCodes,
<add>} = require('internal/errors');
<ide> const {
<ide> ERR_INVALID_ARG_VALUE,
<ide> ERR_CHILD_PROCESS_IPC_REQUIRED,
<ide> ERR_CHILD_PROCESS_STDIO_MAXBUFFER,
<ide> ERR_INVALID_ARG_TYPE,
<del> ERR_OUT_OF_RANGE
<del>} = require('internal/errors').codes;
<add> ERR_OUT_OF_RANGE,
<add>} = errorCodes;
<ide> const { clearTimeout, setTimeout } = require('timers');
<del>const { validateString, isInt32 } = require('internal/validators');
<add>const {
<add> validateString,
<add> isInt32,
<add> validateAbortSignal,
<add>} = require('internal/validators');
<ide> const child_process = require('internal/child_process');
<ide> const {
<ide> getValidStdio,
<ide> function execFile(file /* , args, options, callback */) {
<ide> // Validate maxBuffer, if present.
<ide> validateMaxBuffer(options.maxBuffer);
<ide>
<add> // Validate signal, if present
<add> validateAbortSignal(options.signal, 'options.signal');
<add>
<ide> options.killSignal = sanitizeKillSignal(options.killSignal);
<ide>
<ide> const child = spawn(file, args, {
<ide> function execFile(file /* , args, options, callback */) {
<ide> timeoutId = null;
<ide> }, options.timeout);
<ide> }
<add> if (options.signal) {
<add> if (options.signal.aborted) {
<add> process.nextTick(() => kill());
<add> } else {
<add> options.signal.addEventListener('abort', () => {
<add> if (!ex) {
<add> ex = new AbortError();
<add> }
<add> kill();
<add> });
<add> const remove = () => options.signal.removeEventListener('abort', kill);
<add> child.once('close', remove);
<add> }
<add> }
<ide>
<ide> if (child.stdout) {
<ide> if (encoding)
<ide><path>test/parallel/test-bootstrap-modules.js
<ide> if (!common.isMainThread) {
<ide> 'Internal Binding performance',
<ide> 'Internal Binding symbols',
<ide> 'Internal Binding worker',
<add> 'NativeModule internal/streams/add-abort-signal',
<ide> 'NativeModule internal/streams/duplex',
<ide> 'NativeModule internal/streams/passthrough',
<ide> 'NativeModule internal/streams/readable',
<ide><path>test/parallel/test-child-process-execfile.js
<ide> const { getSystemErrorName } = require('util');
<ide> const fixtures = require('../common/fixtures');
<ide>
<ide> const fixture = fixtures.path('exit.js');
<add>const echoFixture = fixtures.path('echo.js');
<ide> const execOpts = { encoding: 'utf8', shell: true };
<ide>
<ide> {
<ide> const execOpts = { encoding: 'utf8', shell: true };
<ide> // Verify the shell option works properly
<ide> execFile(process.execPath, [fixture, 0], execOpts, common.mustSucceed());
<ide> }
<add>
<add>{
<add> // Verify that the signal option works properly
<add> const ac = new AbortController();
<add> const { signal } = ac;
<add>
<add> const callback = common.mustCall((err) => {
<add> assert.strictEqual(err.code, 'ABORT_ERR');
<add> assert.strictEqual(err.name, 'AbortError');
<add> });
<add> execFile(process.execPath, [echoFixture, 0], { signal }, callback);
<add> ac.abort();
<add>}
| 4
|
Ruby
|
Ruby
|
fix rubocop warnings
|
fb0e121686fa5212362d701b1d0dfb705c56c5d6
|
<ide><path>Library/Homebrew/requirements/java_requirement.rb
<ide> class JavaRequirement < Requirement
<ide> next false unless File.executable? "/usr/libexec/java_home"
<ide>
<ide> args = %w[--failfast]
<del> args << "--version" << "#{@version}" if @version
<add> args << "--version" << @version.to_s if @version
<ide> @java_home = Utils.popen_read("/usr/libexec/java_home", *args).chomp
<ide> $?.success?
<ide> end
<ide> class JavaRequirement < Requirement
<ide> end
<ide>
<ide> def initialize(tags)
<del> @version = tags.shift if /(\d\.)+\d/ === tags.first
<add> @version = tags.shift if /(\d\.)+\d/ =~ tags.first
<ide> super
<ide> end
<ide>
| 1
|
Python
|
Python
|
fix node matching bug caused by lower function
|
d010f5a123e724a168e2f30a3a6c903f7c0443d1
|
<ide><path>spacy/pattern/pattern.py
<ide> def match_token(token,
<ide> 'lemma': lambda t: t.lemma_,
<ide> }
<ide>
<del> if lower:
<del> bind_map = {key: lambda t: func(t).lower() for key, func in
<del> bind_map.items()}
<del>
<ide> for target_key, target_value in target_attributes.items():
<ide> is_special_key = target_key[0] == '_'
<ide>
<ide> def match_token(token,
<ide> if target_key in bind_map:
<ide> token_attr = bind_map[target_key](token)
<ide>
<add> if lower:
<add> token_attr = token_attr.lower()
<add>
<ide> if hasattr(target_value, 'match'): # if it is a compiled regex
<ide> if target_value.match(token_attr) is None:
<ide> break
| 1
|
Go
|
Go
|
fix panic due to nil bind options
|
4c2e1a9cb04614d360e91a81959cb196380283b1
|
<ide><path>api/client/service/opts.go
<ide> func (m *MountOpt) Set(value string) error {
<ide> return mount.VolumeOptions
<ide> }
<ide>
<add> bindOptions := func() *swarm.BindOptions {
<add> if mount.BindOptions == nil {
<add> mount.BindOptions = new(swarm.BindOptions)
<add> }
<add> return mount.BindOptions
<add> }
<add>
<ide> setValueOnMap := func(target map[string]string, value string) {
<ide> parts := strings.SplitN(value, "=", 2)
<ide> if len(parts) == 1 {
<ide> func (m *MountOpt) Set(value string) error {
<ide> return fmt.Errorf("invalid value for writable: %s", value)
<ide> }
<ide> case "bind-propagation":
<del> mount.BindOptions.Propagation = swarm.MountPropagation(strings.ToUpper(value))
<add> bindOptions().Propagation = swarm.MountPropagation(strings.ToUpper(value))
<ide> case "volume-populate":
<ide> volumeOptions().Populate, err = strconv.ParseBool(value)
<ide> if err != nil {
| 1
|
Java
|
Java
|
use volatile for sdidinit in reactbridge
|
c3a07b6dcc56260b288dc11ed168fd723c7c4256
|
<ide><path>ReactAndroid/src/main/java/com/facebook/react/bridge/ReactBridge.java
<ide> public class ReactBridge {
<ide> private static volatile long sLoadStartTime = 0;
<ide> private static volatile long sLoadEndTime = 0;
<ide>
<del> private static boolean sDidInit = false;
<add> private static volatile boolean sDidInit = false;
<ide>
<ide> public static boolean isInitialized() {
<ide> return sDidInit;
| 1
|
PHP
|
PHP
|
move loader to contracts.
|
442ea4d4dc8f4035da8adb23ee16e3caefee6f68
|
<add><path>src/Illuminate/Contracts/Translation/Loader.php
<del><path>src/Illuminate/Translation/LoaderInterface.php
<ide> <?php
<ide>
<del>namespace Illuminate\Translation;
<add>namespace Illuminate\Contracts\Translation;
<ide>
<del>interface LoaderInterface
<add>interface Loader
<ide> {
<ide> /**
<ide> * Load the messages for the given locale.
<ide><path>src/Illuminate/Translation/ArrayLoader.php
<ide>
<ide> namespace Illuminate\Translation;
<ide>
<del>class ArrayLoader implements LoaderInterface
<add>use Illuminate\Contracts\Translation\Loader;
<add>
<add>class ArrayLoader implements Loader
<ide> {
<ide> /**
<ide> * All of the translation messages.
<ide><path>src/Illuminate/Translation/FileLoader.php
<ide> namespace Illuminate\Translation;
<ide>
<ide> use Illuminate\Filesystem\Filesystem;
<add>use Illuminate\Contracts\Translation\Loader;
<ide>
<del>class FileLoader implements LoaderInterface
<add>class FileLoader implements Loader
<ide> {
<ide> /**
<ide> * The filesystem instance.
<ide><path>src/Illuminate/Translation/Translator.php
<ide> use Illuminate\Support\Str;
<ide> use Illuminate\Support\Collection;
<ide> use Illuminate\Support\Traits\Macroable;
<add>use Illuminate\Contracts\Translation\Loader;
<ide> use Illuminate\Support\NamespacedItemResolver;
<ide> use Illuminate\Contracts\Translation\Translator as TranslatorContract;
<ide>
<ide> class Translator extends NamespacedItemResolver implements TranslatorContract
<ide> /**
<ide> * The loader implementation.
<ide> *
<del> * @var \Illuminate\Translation\LoaderInterface
<add> * @var \Illuminate\Contracts\Translation\Loader
<ide> */
<ide> protected $loader;
<ide>
<ide> class Translator extends NamespacedItemResolver implements TranslatorContract
<ide> /**
<ide> * Create a new translator instance.
<ide> *
<del> * @param \Illuminate\Translation\LoaderInterface $loader
<add> * @param \Illuminate\Contracts\Translation\Loader $loader
<ide> * @param string $locale
<ide> * @return void
<ide> */
<del> public function __construct(LoaderInterface $loader, $locale)
<add> public function __construct(Loader $loader, $locale)
<ide> {
<ide> $this->loader = $loader;
<ide> $this->locale = $locale;
<ide> public function setSelector(MessageSelector $selector)
<ide> /**
<ide> * Get the language line loader implementation.
<ide> *
<del> * @return \Illuminate\Translation\LoaderInterface
<add> * @return \Illuminate\Contracts\Translation\Loader
<ide> */
<ide> public function getLoader()
<ide> {
<ide><path>tests/Translation/TranslationTranslatorTest.php
<ide> public function testGetJsonForNonExistingReturnsSameKeyAndReplaces()
<ide>
<ide> protected function getLoader()
<ide> {
<del> return m::mock('Illuminate\Translation\LoaderInterface');
<add> return m::mock(\Illuminate\Contracts\Translation\Loader::class);
<ide> }
<ide> }
| 5
|
Ruby
|
Ruby
|
add null check on style results
|
23846d6ca82225c1e6941df199a1ea643981884b
|
<ide><path>Library/Homebrew/dev-cmd/audit.rb
<ide> def audit
<ide> formula_count += 1
<ide> problem_count += fa.problems.size
<ide> problem_lines = format_problem_lines(fa.problems)
<del> corrected_problem_count = options[:style_offenses].count(&:corrected?)
<add> corrected_problem_count = options[:style_offenses]&.count(&:corrected?)
<ide> new_formula_problem_lines = format_problem_lines(fa.new_formula_problems)
<ide> if args.display_filename?
<ide> puts problem_lines.map { |s| "#{f.path}: #{s}" }
| 1
|
Text
|
Text
|
add link to node-code-ide-configs in testing
|
e55d65384d3feb3dd1bb7341a23766663fbcdba6
|
<ide><path>BUILDING.md
<ide> loopback interface on Ubuntu:
<ide> sudo sysctl -w net.ipv6.conf.lo.disable_ipv6=0
<ide> ```
<ide>
<add>You can use
<add>[node-code-ide-configs](https://github.com/nodejs/node-code-ide-configs)
<add>to run/debug tests, if your IDE configs are present.
<add>
<ide> #### Running Coverage
<ide>
<ide> It's good practice to ensure any code you add or change is covered by tests.
| 1
|
Ruby
|
Ruby
|
use nehalem flags on >= sierra
|
04fbdce3bb963d300179ca6c14812e282d379dbd
|
<ide><path>Library/Homebrew/extend/os/hardware.rb
<ide> if OS.mac?
<add> require "extend/os/mac/hardware"
<ide> require "extend/os/mac/hardware/cpu"
<ide> elsif OS.linux?
<ide> require "extend/os/linux/hardware/cpu"
<ide><path>Library/Homebrew/extend/os/mac/hardware.rb
<add>module Hardware
<add> def self.oldest_cpu
<add> if MacOS.version >= :sierra
<add> :nehalem
<add> else
<add> generic_oldest_cpu
<add> end
<add> end
<add>end
<ide><path>Library/Homebrew/hardware.rb
<ide> class CPU
<ide>
<ide> class << self
<ide> OPTIMIZATION_FLAGS = {
<del> core2: "-march=core2",
<del> core: "-march=prescott",
<del> armv6: "-march=armv6",
<del> armv8: "-march=armv8-a",
<add> nehalem: "-march=nehalem -msse4.2",
<add> core2: "-march=core2",
<add> core: "-march=prescott",
<add> armv6: "-march=armv6",
<add> armv8: "-march=armv8-a",
<ide> }.freeze
<ide>
<ide> def optimization_flags
<ide> def can_run?(arch)
<ide> end
<ide> end
<ide>
<del> def self.cores_as_words
<del> case Hardware::CPU.cores
<del> when 1 then "single"
<del> when 2 then "dual"
<del> when 4 then "quad"
<del> when 6 then "hexa"
<del> when 8 then "octa"
<del> when 12 then "dodeca"
<del> else
<del> Hardware::CPU.cores
<del> end
<del> end
<del>
<del> def self.oldest_cpu
<del> if Hardware::CPU.intel?
<del> if Hardware::CPU.is_64_bit?
<del> :core2
<add> class << self
<add> def cores_as_words
<add> case Hardware::CPU.cores
<add> when 1 then "single"
<add> when 2 then "dual"
<add> when 4 then "quad"
<add> when 6 then "hexa"
<add> when 8 then "octa"
<add> when 12 then "dodeca"
<ide> else
<del> :core
<add> Hardware::CPU.cores
<ide> end
<del> elsif Hardware::CPU.arm?
<del> if Hardware::CPU.is_64_bit?
<del> :armv8
<add> end
<add>
<add> def oldest_cpu
<add> if Hardware::CPU.intel?
<add> if Hardware::CPU.is_64_bit?
<add> :core2
<add> else
<add> :core
<add> end
<add> elsif Hardware::CPU.arm?
<add> if Hardware::CPU.is_64_bit?
<add> :armv8
<add> else
<add> :armv6
<add> end
<ide> else
<del> :armv6
<add> Hardware::CPU.family
<ide> end
<del> else
<del> Hardware::CPU.family
<ide> end
<add> alias generic_oldest_cpu oldest_cpu
<ide> end
<ide> end
<ide>
| 3
|
PHP
|
PHP
|
fix return type in cache contract
|
cf188c7fb6cadbd53c3971f56e6fd3252281d87e
|
<ide><path>src/Illuminate/Cache/RedisTaggedCache.php
<ide> class RedisTaggedCache extends TaggedCache
<ide> * @param string $key
<ide> * @param mixed $value
<ide> * @param \DateTime|float|int|null $minutes
<del> * @return void
<add> * @return bool
<ide> */
<ide> public function put($key, $value, $minutes = null)
<ide> {
<ide> $this->pushStandardKeys($this->tags->getNamespace(), $key);
<ide>
<del> parent::put($key, $value, $minutes);
<add> return parent::put($key, $value, $minutes);
<ide> }
<ide>
<ide> /**
<ide> public function decrement($key, $value = 1)
<ide> *
<ide> * @param string $key
<ide> * @param mixed $value
<del> * @return void
<add> * @return bool
<ide> */
<ide> public function forever($key, $value)
<ide> {
<ide> $this->pushForeverKeys($this->tags->getNamespace(), $key);
<ide>
<del> parent::forever($key, $value);
<add> return parent::forever($key, $value);
<ide> }
<ide>
<ide> /**
<ide><path>src/Illuminate/Contracts/Cache/Repository.php
<ide> public function pull($key, $default = null);
<ide> * @param string $key
<ide> * @param mixed $value
<ide> * @param \DateTimeInterface|\DateInterval|float|int $minutes
<del> * @return void
<add> * @return bool
<ide> */
<ide> public function put($key, $value, $minutes);
<ide>
<ide> public function decrement($key, $value = 1);
<ide> *
<ide> * @param string $key
<ide> * @param mixed $value
<del> * @return void
<add> * @return bool
<ide> */
<ide> public function forever($key, $value);
<ide>
| 2
|
Java
|
Java
|
improve illegal mimetype checks
|
50c11028d5816a6cc390f85167736fa412d1eb29
|
<ide><path>spring-core/src/main/java/org/springframework/util/MimeTypeUtils.java
<ide> /*
<del> * Copyright 2002-2015 the original author or authors.
<add> * Copyright 2002-2016 the original author or authors.
<ide> *
<ide> * Licensed under the Apache License, Version 2.0 (the "License");
<ide> * you may not use this file except in compliance with the License.
<ide> public static MimeType parseMimeType(String mimeType) {
<ide> throw new InvalidMimeTypeException(mimeType, "'mimeType' must not be empty");
<ide> }
<ide> String[] parts = StringUtils.tokenizeToStringArray(mimeType, ";");
<add> if (parts.length == 0) {
<add> throw new InvalidMimeTypeException(mimeType, "'mimeType' must not be empty");
<add> }
<ide>
<ide> String fullType = parts[0].trim();
<ide> // java.net.HttpURLConnection returns a *; q=.2 Accept header
<ide><path>spring-core/src/test/java/org/springframework/util/MimeTypeTests.java
<ide> public void parseMimeTypeIllegalSubtype() {
<ide> MimeTypeUtils.parseMimeType("audio/basic)");
<ide> }
<ide>
<add> @Test(expected = InvalidMimeTypeException.class)
<add> public void parseMimeTypeMissingTypeAndSubtype() throws Exception {
<add> MimeTypeUtils.parseMimeType(" ;a=b");
<add> }
<add>
<ide> @Test(expected = InvalidMimeTypeException.class)
<ide> public void parseMimeTypeEmptyParameterAttribute() {
<ide> MimeTypeUtils.parseMimeType("audio/*;=value");
<ide> public void compareTo() {
<ide>
<ide> assertTrue("Invalid comparison result", audioBasicLevel.compareTo(audio) > 0);
<ide>
<del> List<MimeType> expected = new ArrayList<MimeType>();
<add> List<MimeType> expected = new ArrayList<>();
<ide> expected.add(audio);
<ide> expected.add(audioBasic);
<ide> expected.add(audioBasicLevel);
<ide> expected.add(audioWave);
<ide>
<del> List<MimeType> result = new ArrayList<MimeType>(expected);
<add> List<MimeType> result = new ArrayList<>(expected);
<ide> Random rnd = new Random();
<ide> // shuffle & sort 10 times
<ide> for (int i = 0; i < 10; i++) {
| 2
|
Javascript
|
Javascript
|
improve error message for code generating errors
|
37e4f24f1029ecd43437afa3f1345d89876e1b8b
|
<ide><path>lib/ModuleTemplate.js
<ide> module.exports = class ModuleTemplate extends Tapable {
<ide> }
<ide>
<ide> render(module, dependencyTemplates, options) {
<del> const moduleSource = module.source(
<del> dependencyTemplates,
<del> this.runtimeTemplate,
<del> this.type
<del> );
<del> const moduleSourcePostContent = this.hooks.content.call(
<del> moduleSource,
<del> module,
<del> options,
<del> dependencyTemplates
<del> );
<del> const moduleSourcePostModule = this.hooks.module.call(
<del> moduleSourcePostContent,
<del> module,
<del> options,
<del> dependencyTemplates
<del> );
<del> const moduleSourcePostRender = this.hooks.render.call(
<del> moduleSourcePostModule,
<del> module,
<del> options,
<del> dependencyTemplates
<del> );
<del> return this.hooks.package.call(
<del> moduleSourcePostRender,
<del> module,
<del> options,
<del> dependencyTemplates
<del> );
<add> try {
<add> const moduleSource = module.source(
<add> dependencyTemplates,
<add> this.runtimeTemplate,
<add> this.type
<add> );
<add> const moduleSourcePostContent = this.hooks.content.call(
<add> moduleSource,
<add> module,
<add> options,
<add> dependencyTemplates
<add> );
<add> const moduleSourcePostModule = this.hooks.module.call(
<add> moduleSourcePostContent,
<add> module,
<add> options,
<add> dependencyTemplates
<add> );
<add> const moduleSourcePostRender = this.hooks.render.call(
<add> moduleSourcePostModule,
<add> module,
<add> options,
<add> dependencyTemplates
<add> );
<add> return this.hooks.package.call(
<add> moduleSourcePostRender,
<add> module,
<add> options,
<add> dependencyTemplates
<add> );
<add> } catch (e) {
<add> e.message = `${module.identifier()}\n${e.message}`;
<add> throw e;
<add> }
<ide> }
<ide>
<ide> updateHash(hash) {
| 1
|
PHP
|
PHP
|
add tests for unknown type scenario
|
125389e7ab9485c1da8c9846c50983484a3e9a3d
|
<ide><path>tests/TestCase/Http/Middleware/BodyParserMiddlewareTest.php
<ide> public function testAddParserOverwrite()
<ide>
<ide> $this->assertAttributeEquals(['application/json' => 'strpos'], 'parsers', $parser);
<ide> }
<add>
<add> /**
<add> * test skipping parsing on unknown type
<add> *
<add> * @dataProvider httpMethodProvider
<add> * @return void
<add> */
<add> public function testInvokeMismatchedType($method)
<add> {
<add> $parser = new BodyParserMiddleware();
<add>
<add> $request = new ServerRequest([
<add> 'environment' => [
<add> 'REQUEST_METHOD' => $method,
<add> 'CONTENT_TYPE' => 'text/csv',
<add> ],
<add> 'input' => 'a,b,c'
<add> ]);
<add> $response = new Response();
<add> $next = function ($req, $res) {
<add> $this->assertEquals([], $req->getParsedBody());
<add> };
<add> $parser($request, $response, $next);
<add> }
<add>
<ide> /**
<ide> * test parsing on valid http method
<ide> *
| 1
|
Text
|
Text
|
update style guide
|
296409d9d08a159e6416aa6854f461522e00898d
|
<ide><path>CONTRIBUTING.md
<ide> For more information on how to work with Atom's official packages, see
<ide> * Avoid spaces inside the curly-braces of hash literals:
<ide> * `{a: 1, b: 2}` instead of `{ a: 1, b: 2 }`
<ide> * Include a single line of whitespace between methods.
<add>* Capitalize initialisms and acronyms in names, except for the first word, which
<add> should be lower-case:
<add> * `getURI` instead of `getUri`
<add> * `uriToOpen` instead of `URIToOpen`
<ide>
<ide> ## Documentation Styleguide
<ide>
| 1
|
Go
|
Go
|
set network id as part of parsenetworkoptions
|
798021af9f7ab8078bd3d93ae0ade666fae3a0a1
|
<ide><path>libnetwork/drivers/macvlan/macvlan_network.go
<ide> func (d *driver) CreateNetwork(nid string, option map[string]interface{}, nInfo
<ide> if err != nil {
<ide> return err
<ide> }
<del> config.ID = nid
<ide> err = config.processIPAM(nid, ipV4Data, ipV6Data)
<ide> if err != nil {
<ide> return err
<ide> func parseNetworkOptions(id string, option options.Generic) (*configuration, err
<ide> config.Internal = true
<ide> }
<ide> }
<del>
<add> config.ID = id
<ide> return config, nil
<ide> }
<ide>
| 1
|
Javascript
|
Javascript
|
improve assert message
|
625971271b1b9208cd0da53d55f4e5669df3f129
|
<ide><path>test/parallel/test-http-client-timeout-agent.js
<ide> server.listen(0, options.host, function() {
<ide>
<ide> process.on('exit', function() {
<ide> console.error(`done=${requests_done} sent=${requests_sent}`);
<del> assert.strictEqual(requests_done, requests_sent,
<del> 'timeout on http request called too much');
<add> // check that timeout on http request was not called too much
<add> assert.strictEqual(requests_done, requests_sent);
<ide> });
| 1
|
Ruby
|
Ruby
|
use private attr_reader
|
6d63b5e49a399fe246afcebad45c3c962de268fa
|
<ide><path>activerecord/lib/active_record/associations/join_dependency/join_association.rb
<ide> def table
<ide> tables.first
<ide> end
<ide>
<del> protected
<add> private
<ide> attr_reader :alias_tracker
<ide> end
<ide> end
<ide><path>activerecord/lib/active_record/associations/preloader.rb
<ide> def preloaded_records
<ide> owners.flat_map { |owner| owner.association(reflection.name).target }
<ide> end
<ide>
<del> protected
<add> private
<ide> attr_reader :owners, :reflection
<ide> end
<ide>
<ide><path>activerecord/lib/active_record/associations/preloader/association.rb
<ide> def run(preloader)
<ide> end
<ide> end
<ide>
<del> protected
<add> private
<ide> attr_reader :owners, :reflection, :preload_scope, :model, :klass
<ide>
<del> private
<ide> # The name of the key on the associated records
<ide> def association_key_name
<ide> reflection.join_primary_key(klass)
<ide><path>activerecord/lib/active_record/attribute_methods.rb
<ide> def accessed_fields
<ide> @attributes.accessed
<ide> end
<ide>
<del> protected
<del>
<del> def attribute_method?(attr_name) # :nodoc:
<add> private
<add> def attribute_method?(attr_name)
<ide> # We check defined? because Syck calls respond_to? before actually calling initialize.
<ide> defined?(@attributes) && @attributes.key?(attr_name)
<ide> end
<ide>
<del> private
<del>
<ide> def arel_attributes_with_values_for_create(attribute_names)
<ide> arel_attributes_with_values(attributes_for_create(attribute_names))
<ide> end
<ide><path>activerecord/lib/active_record/connection_adapters/postgresql/column.rb
<ide> def serial?
<ide> end
<ide> end
<ide>
<del> protected
<add> private
<ide> attr_reader :max_identifier_length
<ide>
<del> private
<ide> def sequence_name_from_parts(table_name, column_name, suffix)
<ide> over_length = [table_name, column_name, suffix].map(&:length).sum + 2 - max_identifier_length
<ide>
<ide><path>activerecord/lib/active_record/relation/predicate_builder.rb
<ide> def build_bind_attribute(column_name, value)
<ide> end
<ide>
<ide> protected
<del>
<del> attr_reader :table
<del>
<ide> def expand_from_hash(attributes)
<ide> return ["1=0"] if attributes.empty?
<ide>
<ide> def expand_from_hash(attributes)
<ide> end
<ide>
<ide> private
<add> attr_reader :table
<ide>
<ide> def associated_predicate_builder(association_name)
<ide> self.class.new(table.associated_table(association_name))
<ide><path>activerecord/lib/active_record/relation/predicate_builder/array_handler.rb
<ide> def call(attribute, value)
<ide> array_predicates.inject(&:or)
<ide> end
<ide>
<del> protected
<del>
<add> private
<ide> attr_reader :predicate_builder
<ide>
<ide> module NullPredicate # :nodoc:
<ide><path>activerecord/lib/active_record/relation/predicate_builder/base_handler.rb
<ide> def call(attribute, value)
<ide> predicate_builder.build(attribute, value.id)
<ide> end
<ide>
<del> protected
<del>
<add> private
<ide> attr_reader :predicate_builder
<ide> end
<ide> end
<ide><path>activerecord/lib/active_record/relation/predicate_builder/basic_object_handler.rb
<ide> def call(attribute, value)
<ide> attribute.eq(bind)
<ide> end
<ide>
<del> protected
<del>
<add> private
<ide> attr_reader :predicate_builder
<ide> end
<ide> end
<ide><path>activerecord/lib/active_record/relation/predicate_builder/range_handler.rb
<ide> def call(attribute, value)
<ide> end
<ide> end
<ide>
<del> protected
<del>
<add> private
<ide> attr_reader :predicate_builder
<ide> end
<ide> end
<ide><path>activerecord/lib/active_record/relation/where_clause_factory.rb
<ide> def build(opts, other)
<ide> WhereClause.new(parts)
<ide> end
<ide>
<del> protected
<del>
<add> private
<ide> attr_reader :klass, :predicate_builder
<ide> end
<ide> end
<ide><path>activerecord/lib/active_record/statement_cache.rb
<ide> def self.unsupported_value?(value)
<ide> end
<ide> end
<ide>
<del> protected
<del>
<add> private
<ide> attr_reader :query_builder, :bind_map, :klass
<ide> end
<ide> end
| 12
|
Java
|
Java
|
fix lint for d2880851
|
804b23811b6243bf4d8405c36720b0819edd27c9
|
<ide><path>ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java
<ide> public class ReactEditText extends EditText {
<ide> private @Nullable SelectionWatcher mSelectionWatcher;
<ide> private final InternalKeyListener mKeyListener;
<ide>
<del> private static KeyListener sKeyListener = QwertyKeyListener.getInstanceForFullKeyboard();
<add> private static final KeyListener sKeyListener = QwertyKeyListener.getInstanceForFullKeyboard();
<ide>
<ide> public ReactEditText(Context context) {
<ide> super(context);
<ide><path>ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java
<ide> public void setMaxLength(ReactEditText view, @Nullable Integer maxLength) {
<ide> list.add(currentFilters[i]);
<ide> }
<ide> }
<del> if (list.size() > 0) {
<del> newFilters = (InputFilter[])list.toArray();
<add> if (!list.isEmpty()) {
<add> newFilters = (InputFilter[]) list.toArray();
<ide> }
<ide> }
<ide> } else {
| 2
|
Javascript
|
Javascript
|
send credentials with on-demand-entries-ping
|
48e4c771c2655c4799dc05a66d0ef3dd8dfaa427
|
<ide><path>client/on-demand-entries-client.js
<ide> export default ({assetPrefix}) => {
<ide> try {
<ide> const url = `${assetPrefix || ''}/_next/on-demand-entries-ping?page=${Router.pathname}`
<ide> const res = await fetch(url, {
<del> credentials: 'omit'
<add> credentials: 'same-origin'
<ide> })
<ide> const payload = await res.json()
<ide> if (payload.invalid) {
<ide> // Payload can be invalid even if the page is not exists.
<ide> // So, we need to make sure it's exists before reloading.
<ide> const pageRes = await fetch(location.href, {
<del> credentials: 'omit'
<add> credentials: 'same-origin'
<ide> })
<ide> if (pageRes.status === 200) {
<ide> location.reload()
| 1
|
Python
|
Python
|
use `assertraises` to simplify testing code
|
b949a3bea8fedc81b9426c50f7864639ea2731ef
|
<ide><path>libcloud/test/compute/test_cloudstack.py
<ide> def test_create_node_immediate_failure(self):
<ide> size = self.driver.list_sizes()[0]
<ide> image = self.driver.list_images()[0]
<ide> CloudStackMockHttp.fixture_tag = 'deployfail'
<del> try:
<del> self.driver.create_node(name='node-name',
<del> image=image,
<del> size=size)
<del> except:
<del> return
<del> self.assertTrue(False)
<add> self.assertRaises(
<add> Exception,
<add> self.driver.create_node,
<add> name='node-name', image=image, size=size)
<ide>
<ide> def test_create_node_delayed_failure(self):
<ide> size = self.driver.list_sizes()[0]
<ide> image = self.driver.list_images()[0]
<ide> CloudStackMockHttp.fixture_tag = 'deployfail2'
<del> try:
<del> self.driver.create_node(name='node-name',
<del> image=image,
<del> size=size)
<del> except:
<del> return
<del> self.assertTrue(False)
<add> self.assertRaises(
<add> Exception,
<add> self.driver.create_node,
<add> name='node-name', image=image, size=size)
<ide>
<ide> def test_create_node_default_location_success(self):
<ide> size = self.driver.list_sizes()[0]
<ide><path>libcloud/test/compute/test_gridspot.py
<ide> def test_invalid_creds(self):
<ide> Tests the error-handling for passing a bad API Key to the Gridspot API
<ide> """
<ide> GridspotMockHttp.type = 'BAD_AUTH'
<del> try:
<del> self.driver.list_nodes()
<del> # Above command should have thrown an InvalidCredsException
<del> self.assertTrue(False)
<del> except InvalidCredsError:
<del> pass
<add> self.assertRaises(InvalidCredsError, self.driver.list_nodes)
<ide>
<ide> def test_list_nodes(self):
<ide> nodes = self.driver.list_nodes()
<ide><path>libcloud/test/compute/test_ktucloud.py
<ide> def test_create_node_immediate_failure(self):
<ide> size = self.driver.list_sizes()[0]
<ide> image = self.driver.list_images()[0]
<ide> KTUCloudStackMockHttp.fixture_tag = 'deployfail'
<del> try:
<del> self.driver.create_node(name='node-name', image=image, size=size)
<del> except:
<del> return
<del> self.assertTrue(False)
<add> self.assertRaises(
<add> Exception,
<add> self.driver.create_node,
<add> name='node-name', image=image, size=size)
<ide>
<ide> def test_create_node_delayed_failure(self):
<ide> size = self.driver.list_sizes()[0]
<ide> image = self.driver.list_images()[0]
<ide> KTUCloudStackMockHttp.fixture_tag = 'deployfail2'
<del> try:
<del> self.driver.create_node(name='node-name', image=image, size=size)
<del> except:
<del> return
<del> self.assertTrue(False)
<add> self.assertRaises(
<add> Exception,
<add> self.driver.create_node,
<add> name='node-name', image=image, size=size)
<ide>
<ide> def test_list_images_no_images_available(self):
<ide> KTUCloudStackMockHttp.fixture_tag = 'notemplates'
| 3
|
Text
|
Text
|
use the canonical router on the changelog entry
|
ebc5bdb8e728d236d4b6cdf4d26246dfd1d62899
|
<ide><path>actionview/CHANGELOG.md
<ide> After:
<ide>
<ide> link_to(action: 'bar', controller: 'foo') { content_tag(:span, 'Example site') }
<del> # => "<a href=\"/\"><span>Example site</span></a>"
<add> # => "<a href=\"/foo/bar\"><span>Example site</span></a>"
<ide>
<ide> *Murahashi Sanemat Kenichi*
<ide>
| 1
|
Javascript
|
Javascript
|
add keystream tests
|
b3f592aa6c605d7e12f2f009eb3bdb1aaae8b36d
|
<ide><path>packages/ember-metal/tests/streams/key-stream-test.js
<ide> import Stream from "ember-metal/streams/stream";
<ide> import KeyStream from "ember-metal/streams/key-stream";
<add>import { set } from "ember-metal/property_set";
<ide>
<del>var source, value;
<add>var source, object, count;
<add>
<add>function incrementCount() {
<add> count++;
<add>}
<ide>
<ide> QUnit.module('KeyStream', {
<ide> setup: function() {
<del> value = { foo: "zlurp" };
<add> count = 0;
<add> object = { name: "mmun" };
<ide>
<ide> source = new Stream(function() {
<del> return value;
<add> return object;
<ide> });
<ide>
<del> source.setValue = function(_value) {
<del> value = _value;
<add> source.setValue = function(value) {
<add> object = value;
<ide> this.notify();
<ide> };
<ide> },
<ide> teardown: function() {
<del> value = undefined;
<add> count = undefined;
<add> object = undefined;
<ide> source = undefined;
<ide> }
<ide> });
<ide>
<del>QUnit.test('can be instantiated manually', function() {
<del> var stream = new KeyStream(source, 'foo');
<del> equal(stream.value(), "zlurp");
<add>QUnit.test("can be instantiated manually", function() {
<add> var nameStream = new KeyStream(source, 'name');
<add> equal(nameStream.value(), "mmun", "Stream value is correct");
<add>});
<add>
<add>QUnit.test("can be instantiated via `Stream.prototype.get`", function() {
<add> var nameStream = source.get('name');
<add> equal(nameStream.value(), "mmun", "Stream value is correct");
<add>});
<add>
<add>QUnit.test("is notified when the observed object's property is mutated", function() {
<add> var nameStream = source.get('name');
<add> nameStream.subscribe(incrementCount);
<add>
<add> equal(count, 0, "Subscribers called correct number of times");
<add>
<add> nameStream.value(); // Prime the stream to notify subscribers
<add> set(object, 'name', "wycats");
<add>
<add> equal(count, 1, "Subscribers called correct number of times");
<add> equal(nameStream.value(), "wycats", "Stream value is correct");
<add>});
<add>
<add>QUnit.test("is notified when the source stream's value changes to a new object", function() {
<add> var nameStream = source.get('name');
<add> nameStream.subscribe(incrementCount);
<add>
<add> equal(count, 0, "Subscribers called correct number of times");
<add>
<add> nameStream.value(); // Prime the stream to notify subscribers
<add> source.setValue({ name: "wycats" });
<add>
<add> equal(count, 1, "Subscribers called correct number of times");
<add> equal(nameStream.value(), "wycats", "Stream value is correct");
<add>});
<add>
<add>QUnit.test("is notified when the source stream's value changes to the same object", function() {
<add> var nameStream = source.get('name');
<add> nameStream.subscribe(incrementCount);
<add>
<add> equal(count, 0, "Subscribers called correct number of times");
<add>
<add> nameStream.value(); // Prime the stream to notify subscribers
<add> source.setValue(object);
<add>
<add> equal(count, 1, "Subscribers called correct number of times");
<add> equal(nameStream.value(), "mmun", "Stream value is correct");
<ide> });
<ide>
<del>QUnit.test('can be instantiated via `Stream.prototype.get`', function() {
<del> var stream = source.get('foo');
<del> equal(stream.value(), "zlurp");
<add>QUnit.test("is notified when setSource is called with a new stream whose value is a new object", function() {
<add> var nameStream = source.get('name');
<add> nameStream.subscribe(incrementCount);
<add>
<add> equal(count, 0, "Subscribers called correct number of times");
<add>
<add> nameStream.value(); // Prime the stream to notify subscribers
<add> nameStream.setSource(new Stream(function() {
<add> return { name: "wycats" };
<add> }));
<add>
<add> equal(count, 1, "Subscribers called correct number of times");
<add> equal(nameStream.value(), "wycats", "Stream value is correct");
<add>});
<add>
<add>QUnit.test("is notified when setSource is called with a new stream whose value is the same object", function() {
<add> var nameStream = source.get('name');
<add> nameStream.subscribe(incrementCount);
<add>
<add> equal(count, 0, "Subscribers called correct number of times");
<add>
<add> nameStream.value(); // Prime the stream to notify subscribers
<add> nameStream.setSource(new Stream(function() {
<add> return object;
<add> }));
<add>
<add> equal(count, 1, "Subscribers called correct number of times");
<add> equal(nameStream.value(), "mmun", "Stream value is correct");
<ide> });
| 1
|
Ruby
|
Ruby
|
install bundler <2
|
5b7404a0d2a1168267b7e69aecc4c51fe4b80852
|
<ide><path>Library/Homebrew/dev-cmd/tests.rb
<ide> def tests
<ide> ENV["GIT_#{role}_DATE"] = "Sun Jan 22 19:59:13 2017 +0000"
<ide> end
<ide>
<del> Homebrew.install_gem_setup_path! "bundler"
<add> Homebrew.install_gem_setup_path! "bundler", "<2"
<ide> system "bundle", "install" unless quiet_system("bundle", "check")
<ide>
<ide> parallel = true
<ide><path>Library/Homebrew/dev-cmd/vendor-gems.rb
<ide> def vendor_gems
<ide> switch :debug
<ide> end.parse
<ide>
<del> Homebrew.install_gem_setup_path! "bundler"
<add> Homebrew.install_gem_setup_path! "bundler", "<2"
<ide>
<ide> ohai "cd #{HOMEBREW_LIBRARY_PATH}/vendor"
<ide> (HOMEBREW_LIBRARY_PATH/"vendor").cd do
| 2
|
Java
|
Java
|
fix issue with generic @requestbody arguments
|
c0baea58c0a14ea34d53f3823704892154b7803e
|
<ide><path>spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/AbstractMessageConverterMethodArgumentResolver.java
<ide> package org.springframework.web.servlet.mvc.method.annotation;
<ide>
<ide> import java.io.IOException;
<add>import java.lang.reflect.Array;
<add>import java.lang.reflect.GenericArrayType;
<add>import java.lang.reflect.ParameterizedType;
<ide> import java.lang.reflect.Type;
<ide> import java.util.ArrayList;
<ide> import java.util.Collections;
<ide> protected <T> Object readWithMessageConverters(NativeWebRequest webRequest,
<ide> * @throws HttpMediaTypeNotSupportedException if no suitable message converter is found
<ide> */
<ide> @SuppressWarnings("unchecked")
<del> protected <T> Object readWithMessageConverters(HttpInputMessage inputMessage, MethodParameter methodParam,
<del> Type paramType) throws IOException, HttpMediaTypeNotSupportedException {
<add> protected <T> Object readWithMessageConverters(HttpInputMessage inputMessage,
<add> MethodParameter methodParam, Type paramType) throws IOException, HttpMediaTypeNotSupportedException {
<ide>
<ide> MediaType contentType = inputMessage.getHeaders().getContentType();
<ide> if (contentType == null) {
<ide> contentType = MediaType.APPLICATION_OCTET_STREAM;
<ide> }
<ide>
<del> Class<T> paramClass = (paramType instanceof Class) ? (Class) paramType : null;
<add> Class<T> paramClass = getParamClass(paramType);
<ide>
<ide> for (HttpMessageConverter<?> messageConverter : this.messageConverters) {
<ide> if (messageConverter instanceof GenericHttpMessageConverter) {
<ide> protected <T> Object readWithMessageConverters(HttpInputMessage inputMessage, Me
<ide> throw new HttpMediaTypeNotSupportedException(contentType, allSupportedMediaTypes);
<ide> }
<ide>
<add> private Class getParamClass(Type paramType) {
<add> if (paramType instanceof Class) {
<add> return (Class) paramType;
<add> }
<add> else if (paramType instanceof GenericArrayType) {
<add> Type componentType = ((GenericArrayType) paramType).getGenericComponentType();
<add> if (componentType instanceof Class) {
<add> // Surely, there should be a nicer way to determine the array type
<add> return Array.newInstance((Class<?>) componentType, 0).getClass();
<add> }
<add> }
<add> else if (paramType instanceof ParameterizedType) {
<add> ParameterizedType parameterizedType = (ParameterizedType) paramType;
<add> if (parameterizedType.getRawType() instanceof Class) {
<add> return (Class) parameterizedType.getRawType();
<add> }
<add> }
<add> return null;
<add> }
<add>
<ide> /**
<ide> * Creates a new {@link HttpInputMessage} from the given {@link NativeWebRequest}.
<ide> *
<ide><path>spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/HttpEntityMethodProcessor.java
<ide> package org.springframework.web.servlet.mvc.method.annotation;
<ide>
<ide> import java.io.IOException;
<del>import java.lang.reflect.Array;
<del>import java.lang.reflect.GenericArrayType;
<ide> import java.lang.reflect.ParameterizedType;
<ide> import java.lang.reflect.Type;
<ide> import java.util.List;
<ide> private Type getHttpEntityType(MethodParameter parameter) {
<ide> Assert.isAssignable(HttpEntity.class, parameter.getParameterType());
<ide> ParameterizedType type = (ParameterizedType) parameter.getGenericParameterType();
<ide> if (type.getActualTypeArguments().length == 1) {
<del> Type typeArgument = type.getActualTypeArguments()[0];
<del> if (typeArgument instanceof Class) {
<del> return (Class<?>) typeArgument;
<del> }
<del> else if (typeArgument instanceof GenericArrayType) {
<del> Type componentType = ((GenericArrayType) typeArgument).getGenericComponentType();
<del> if (componentType instanceof Class) {
<del> // Surely, there should be a nicer way to determine the array type
<del> return Array.newInstance((Class<?>) componentType, 0).getClass();
<del> }
<del> }
<del> else if (typeArgument instanceof ParameterizedType) {
<del> return typeArgument;
<del> }
<add> return type.getActualTypeArguments()[0];
<ide> }
<del> throw new IllegalArgumentException("HttpEntity parameter (" + parameter.getParameterName() + ") "
<del> + "in method " + parameter.getMethod() + "is not parameterized");
<add> throw new IllegalArgumentException("HttpEntity parameter ("
<add> + parameter.getParameterName() + ") in method " + parameter.getMethod()
<add> + " is not parameterized or has more than one parameter");
<ide> }
<ide>
<ide> public void handleReturnValue(
<ide><path>spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestResponseBodyMethodProcessorMockTests.java
<ide> private void testResolveArgumentWithValidation(SimpleBean simpleBean) throws IOE
<ide> }
<ide>
<ide> @Test(expected = HttpMediaTypeNotSupportedException.class)
<del> public void resolveArgumentNotReadable() throws Exception {
<add> public void resolveArgumentCannotRead() throws Exception {
<ide> MediaType contentType = MediaType.TEXT_PLAIN;
<ide> servletRequest.addHeader("Content-Type", contentType.toString());
<del> servletRequest.setContent(new byte[] {});
<ide>
<ide> expect(messageConverter.canRead(String.class, contentType)).andReturn(false);
<ide> replay(messageConverter);
<ide>
<ide> processor.resolveArgument(paramRequestBodyString, mavContainer, webRequest, null);
<ide> }
<ide>
<del> @Test(expected = HttpMediaTypeNotSupportedException.class)
<add> @Test
<ide> public void resolveArgumentNoContentType() throws Exception {
<del> servletRequest.setContent(new byte[] {});
<del> processor.resolveArgument(paramRequestBodyString, mavContainer, webRequest, null);
<del> }
<del>
<del> @Test(expected = HttpMessageNotReadableException.class)
<del> public void resolveArgumentRequiredNoContent() throws Exception {
<del> processor.resolveArgument(paramRequestBodyString, mavContainer, webRequest, null);
<add> expect(messageConverter.canRead(String.class, MediaType.APPLICATION_OCTET_STREAM)).andReturn(false);
<add> replay(messageConverter);
<add> try {
<add> processor.resolveArgument(paramRequestBodyString, mavContainer, webRequest, null);
<add> fail("Expected exception");
<add> }
<add> catch (HttpMediaTypeNotSupportedException ex) {
<add> }
<add> verify(messageConverter);
<ide> }
<ide>
<ide> @Test
<ide> public void resolveArgumentNotRequiredNoContent() throws Exception {
<add> servletRequest.setContent(null);
<add> assertNull(processor.resolveArgument(paramStringNotRequired, mavContainer, webRequest, new ValidatingBinderFactory()));
<add>
<add> servletRequest.setContent(new byte[0]);
<ide> assertNull(processor.resolveArgument(paramStringNotRequired, mavContainer, webRequest, new ValidatingBinderFactory()));
<ide> }
<ide>
<ide><path>spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestResponseBodyMethodProcessorTests.java
<ide>
<ide> import java.lang.reflect.Method;
<ide> import java.util.ArrayList;
<add>import java.util.Collection;
<ide> import java.util.List;
<ide>
<ide> import org.junit.Before;
<ide> import org.junit.Test;
<ide> import org.springframework.core.MethodParameter;
<add>import org.springframework.http.MediaType;
<ide> import org.springframework.http.converter.ByteArrayHttpMessageConverter;
<ide> import org.springframework.http.converter.HttpMessageConverter;
<ide> import org.springframework.http.converter.StringHttpMessageConverter;
<ide> import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
<add>import org.springframework.http.converter.xml.XmlAwareFormHttpMessageConverter;
<ide> import org.springframework.mock.web.MockHttpServletRequest;
<ide> import org.springframework.mock.web.MockHttpServletResponse;
<add>import org.springframework.util.MultiValueMap;
<ide> import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;
<ide> import org.springframework.web.bind.WebDataBinder;
<ide> import org.springframework.web.bind.annotation.RequestBody;
<ide> public class RequestResponseBodyMethodProcessorTests {
<ide>
<ide> private MethodParameter paramGenericList;
<ide> private MethodParameter paramSimpleBean;
<add> private MethodParameter paramMultiValueMap;
<add> private MethodParameter paramString;
<ide> private MethodParameter returnTypeString;
<ide>
<ide> private ModelAndViewContainer mavContainer;
<ide> public class RequestResponseBodyMethodProcessorTests {
<ide> @Before
<ide> public void setUp() throws Exception {
<ide>
<del> Method method = getClass().getMethod("handle", List.class, SimpleBean.class);
<add> Method method = getClass().getMethod("handle",
<add> List.class, SimpleBean.class, MultiValueMap.class, String.class);
<add>
<ide> paramGenericList = new MethodParameter(method, 0);
<ide> paramSimpleBean = new MethodParameter(method, 1);
<add> paramMultiValueMap = new MethodParameter(method, 2);
<add> paramString = new MethodParameter(method, 3);
<ide> returnTypeString = new MethodParameter(method, -1);
<ide>
<ide> mavContainer = new ModelAndViewContainer();
<ide> public void setUp() throws Exception {
<ide>
<ide>
<ide> @Test
<del> public void resolveGenericArgument() throws Exception {
<add> public void resolveArgumentParameterizedType() throws Exception {
<ide> String content = "[{\"name\" : \"Jad\"}, {\"name\" : \"Robert\"}]";
<ide> this.servletRequest.setContent(content.getBytes("UTF-8"));
<del> this.servletRequest.setContentType("application/json");
<add> this.servletRequest.setContentType(MediaType.APPLICATION_JSON_VALUE);
<ide>
<ide> List<HttpMessageConverter<?>> converters = new ArrayList<HttpMessageConverter<?>>();
<ide> converters.add(new MappingJackson2HttpMessageConverter());
<ide> public void resolveGenericArgument() throws Exception {
<ide> }
<ide>
<ide> @Test
<del> public void resolveArgument() throws Exception {
<add> public void resolveArgumentRawTypeFromParameterizedType() throws Exception {
<add> String content = "fruit=apple&vegetable=kale";
<add> this.servletRequest.setContent(content.getBytes("UTF-8"));
<add> this.servletRequest.setContentType(MediaType.APPLICATION_FORM_URLENCODED_VALUE);
<add>
<add> List<HttpMessageConverter<?>> converters = new ArrayList<HttpMessageConverter<?>>();
<add> converters.add(new XmlAwareFormHttpMessageConverter());
<add> RequestResponseBodyMethodProcessor processor = new RequestResponseBodyMethodProcessor(converters);
<add>
<add> @SuppressWarnings("unchecked")
<add> MultiValueMap<String, String> result = (MultiValueMap<String, String>) processor.resolveArgument(
<add> paramMultiValueMap, mavContainer, webRequest, new ValidatingBinderFactory());
<add>
<add> assertNotNull(result);
<add> assertEquals("apple", result.getFirst("fruit"));
<add> assertEquals("kale", result.getFirst("vegetable"));
<add> }
<add>
<add> @Test
<add> public void resolveArgumentClassJson() throws Exception {
<ide> String content = "{\"name\" : \"Jad\"}";
<ide> this.servletRequest.setContent(content.getBytes("UTF-8"));
<ide> this.servletRequest.setContentType("application/json");
<ide> public void resolveArgument() throws Exception {
<ide> assertEquals("Jad", result.getName());
<ide> }
<ide>
<add> @Test
<add> public void resolveArgumentClassString() throws Exception {
<add> String content = "foobarbaz";
<add> this.servletRequest.setContent(content.getBytes("UTF-8"));
<add> this.servletRequest.setContentType("application/json");
<add>
<add> List<HttpMessageConverter<?>> converters = new ArrayList<HttpMessageConverter<?>>();
<add> converters.add(new StringHttpMessageConverter());
<add> RequestResponseBodyMethodProcessor processor = new RequestResponseBodyMethodProcessor(converters);
<add>
<add> String result = (String) processor.resolveArgument(
<add> paramString, mavContainer, webRequest, new ValidatingBinderFactory());
<add>
<add> assertNotNull(result);
<add> assertEquals("foobarbaz", result);
<add> }
<add>
<ide> // SPR-9160
<ide>
<ide> @Test
<ide> public void handleReturnValueStringAcceptCharset() throws Exception {
<ide> }
<ide>
<ide>
<del> public String handle(@RequestBody List<SimpleBean> list, @RequestBody SimpleBean simpleBean) {
<add> public String handle(
<add> @RequestBody List<SimpleBean> list,
<add> @RequestBody SimpleBean simpleBean,
<add> @RequestBody MultiValueMap<String, String> multiValueMap,
<add> @RequestBody String string) {
<add>
<ide> return null;
<ide> }
<ide>
| 4
|
Javascript
|
Javascript
|
remove duplicate tests
|
85776c0d37316c5aaecd84eedec275bac2cd0298
|
<ide><path>test/ng/directive/booleanAttrsSpec.js
<ide> describe('boolean attr directives', function() {
<ide> });
<ide>
<ide>
<del> it('should bind href', inject(function($rootScope, $compile) {
<del> element = $compile('<a ng-href="{{url}}"></a>')($rootScope)
<del> $rootScope.url = 'http://server';
<del> $rootScope.$digest();
<del> expect(element.attr('href')).toEqual('http://server');
<del> }));
<del>
<del>
<del> it('should bind href even if no interpolation', inject(function($rootScope, $compile) {
<del> element = $compile('<a ng-href="http://server"></a>')($rootScope)
<del> $rootScope.$digest();
<del> expect(element.attr('href')).toEqual('http://server');
<del> }));
<del>
<del>
<ide> it('should properly evaluate 0 as false', inject(function($rootScope, $compile) {
<ide> // jQuery does not treat 0 as false, when setting attr()
<ide> element = $compile('<button ng-disabled="isDisabled">Button</button>')($rootScope)
<ide> describe('boolean attr directives', function() {
<ide> $rootScope.$digest();
<ide> expect(element.attr('multiple')).toBeTruthy();
<ide> }));
<del>
<del>
<del> it('should bind src', inject(function($rootScope, $compile) {
<del> element = $compile('<div ng-src="{{url}}" />')($rootScope)
<del> $rootScope.url = 'http://localhost/';
<del> $rootScope.$digest();
<del> expect(element.attr('src')).toEqual('http://localhost/');
<del> }));
<del>
<del>
<del> it('should bind href and merge with other attrs', inject(function($rootScope, $compile) {
<del> element = $compile('<a ng-href="{{url}}" rel="{{rel}}"></a>')($rootScope);
<del> $rootScope.url = 'http://server';
<del> $rootScope.rel = 'REL';
<del> $rootScope.$digest();
<del> expect(element.attr('href')).toEqual('http://server');
<del> expect(element.attr('rel')).toEqual('REL');
<del> }));
<ide> });
<ide>
<ide>
<ide> describe('ng-src', function() {
<ide>
<ide>
<ide> describe('ng-href', function() {
<add> var element;
<add>
<add> afterEach(function() {
<add> dealoc(element);
<add> });
<add>
<ide>
<ide> it('should interpolate the expression and bind to href', inject(function($compile, $rootScope) {
<del> var element = $compile('<div ng-href="some/{{id}}"></div>')($rootScope)
<add> element = $compile('<div ng-href="some/{{id}}"></div>')($rootScope)
<ide> $rootScope.$digest();
<ide> expect(element.attr('href')).toEqual('some/');
<ide>
<ide> $rootScope.$apply(function() {
<ide> $rootScope.id = 1;
<ide> });
<ide> expect(element.attr('href')).toEqual('some/1');
<add> }));
<ide>
<del> dealoc(element);
<add>
<add> it('should bind href and merge with other attrs', inject(function($rootScope, $compile) {
<add> element = $compile('<a ng-href="{{url}}" rel="{{rel}}"></a>')($rootScope);
<add> $rootScope.url = 'http://server';
<add> $rootScope.rel = 'REL';
<add> $rootScope.$digest();
<add> expect(element.attr('href')).toEqual('http://server');
<add> expect(element.attr('rel')).toEqual('REL');
<add> }));
<add>
<add>
<add> it('should bind href even if no interpolation', inject(function($rootScope, $compile) {
<add> element = $compile('<a ng-href="http://server"></a>')($rootScope)
<add> $rootScope.$digest();
<add> expect(element.attr('href')).toEqual('http://server');
<ide> }));
<ide> });
| 1
|
Javascript
|
Javascript
|
submit backend projects
|
740c839f3fcedde5398d9ccc3bf97e93f8ce3502
|
<ide><path>client/src/templates/Challenges/projects/ProjectForm.js
<ide> export class ProjectForm extends Component {
<ide> componentDidMount() {
<ide> this.props.updateProjectForm({});
<ide> }
<del> componentDidUpdate() {
<del> this.props.updateProjectForm({});
<del> }
<del> componentWillUnmount() {
<del> this.props.updateProjectForm({});
<del> }
<ide> handleSubmit(values) {
<ide> this.props.updateProjectForm(values);
<ide> this.props.onSubmit();
| 1
|
Ruby
|
Ruby
|
remove more nesting in python_helper
|
53c97c3c96620734cbf55a487d9529f03568577e
|
<ide><path>Library/Homebrew/python_helper.rb
<ide> def python_helper(options={:allowed_major_versions => [2, 3]}, &block)
<ide> filtered_python_reqs.sort_by{ |py| py.version }.map do |py|
<ide> # Now is the time to set the site_packages to the correct value
<ide> py.site_packages = lib/py.xy/'site-packages'
<del> if !block_given?
<del> return py
<del> else
<del> puts "brew: Python block (#{py.binary})..." if ARGV.verbose? && ARGV.debug?
<del> # Ensure env changes are only temporary
<del> begin
<del> old_env = ENV.to_hash
<del> # In order to install into the Cellar, the dir must exist and be in the
<del> # PYTHONPATH. This will be executed in the context of the formula
<del> # so that lib points to the HOMEBREW_PREFIX/Cellar/<formula>/<version>/lib
<del> puts "brew: Appending to PYTHONPATH: #{py.site_packages}" if ARGV.verbose?
<del> mkdir_p py.site_packages
<del> ENV.append 'PYTHONPATH', py.site_packages, ':'
<del> ENV['PYTHON'] = py.binary
<del> ENV.prepend 'CMAKE_INCLUDE_PATH', py.incdir, ':'
<del> ENV.prepend 'PKG_CONFIG_PATH', py.pkg_config_path, ':' if py.pkg_config_path
<del> ENV.prepend 'PATH', py.binary.dirname, ':' unless py.from_osx?
<del> #Note: Don't set LDFLAGS to point to the Python.framework, because
<del> # it breaks builds (for example scipy.)
<add> return py if !block_given?
<add>
<add> puts "brew: Python block (#{py.binary})..." if ARGV.verbose? && ARGV.debug?
<add> # Ensure env changes are only temporary
<add> begin
<add> old_env = ENV.to_hash
<add> # In order to install into the Cellar, the dir must exist and be in the
<add> # PYTHONPATH. This will be executed in the context of the formula
<add> # so that lib points to the HOMEBREW_PREFIX/Cellar/<formula>/<version>/lib
<add> puts "brew: Appending to PYTHONPATH: #{py.site_packages}" if ARGV.verbose?
<add> mkdir_p py.site_packages
<add> ENV.append 'PYTHONPATH', py.site_packages, ':'
<add> ENV['PYTHON'] = py.binary
<add> ENV.prepend 'CMAKE_INCLUDE_PATH', py.incdir, ':'
<add> ENV.prepend 'PKG_CONFIG_PATH', py.pkg_config_path, ':' if py.pkg_config_path
<add> ENV.prepend 'PATH', py.binary.dirname, ':' unless py.from_osx?
<add> #Note: Don't set LDFLAGS to point to the Python.framework, because
<add> # it breaks builds (for example scipy.)
<ide>
<del> # Track the state of the currently selected python for this block,
<del> # so if this python_helper is called again _inside_ the block,
<del> # we can just return the right python (see `else`-branch a few lines down):
<del> @current_python = py
<del> res = instance_eval(&block)
<del> @current_python = nil
<del> res
<del> ensure
<del> ENV.replace(old_env)
<del> end
<add> # Track the state of the currently selected python for this block,
<add> # so if this python_helper is called again _inside_ the block,
<add> # we can just return the right python (see `else`-branch a few lines down):
<add> @current_python = py
<add> res = instance_eval(&block)
<add> @current_python = nil
<add> res
<add> ensure
<add> ENV.replace(old_env)
<ide> end
<ide> end
<ide> end
| 1
|
PHP
|
PHP
|
adopt new consoleio methods in shell
|
4edb83f3cddbd71cf1ff7c5190b02cef3a05b7b5
|
<ide><path>src/Console/Shell.php
<ide> public function out($message = null, $newlines = 1, $level = Shell::NORMAL)
<ide> */
<ide> public function err($message = null, $newlines = 1)
<ide> {
<del> $messageType = 'error';
<del> $message = $this->wrapMessageWithType($messageType, $message);
<del>
<del> return $this->_io->err($message, $newlines);
<add> return $this->_io->error($message, $newlines);
<ide> }
<ide>
<ide> /**
<ide> public function err($message = null, $newlines = 1)
<ide> */
<ide> public function info($message = null, $newlines = 1, $level = Shell::NORMAL)
<ide> {
<del> $messageType = 'info';
<del> $message = $this->wrapMessageWithType($messageType, $message);
<del>
<del> return $this->out($message, $newlines, $level);
<add> return $this->_io->info($message, $newlines, $level);
<ide> }
<ide>
<ide> /**
<ide> public function info($message = null, $newlines = 1, $level = Shell::NORMAL)
<ide> */
<ide> public function warn($message = null, $newlines = 1)
<ide> {
<del> $messageType = 'warning';
<del> $message = $this->wrapMessageWithType($messageType, $message);
<del>
<del> return $this->_io->err($message, $newlines);
<add> return $this->_io->warning($message, $newlines);
<ide> }
<ide>
<ide> /**
<ide> public function warn($message = null, $newlines = 1)
<ide> */
<ide> public function success($message = null, $newlines = 1, $level = Shell::NORMAL)
<ide> {
<del> $messageType = 'success';
<del> $message = $this->wrapMessageWithType($messageType, $message);
<del>
<del> return $this->out($message, $newlines, $level);
<add> return $this->_io->success($message, $newlines, $level);
<ide> }
<ide>
<ide> /**
<ide> public function success($message = null, $newlines = 1, $level = Shell::NORMAL)
<ide> * @param string $messageType The message type, e.g. "warning".
<ide> * @param string|array $message The message to wrap.
<ide> * @return array|string The message wrapped with the given message type.
<add> * @deprecated 3.6.0 Will be removed in 4.0.0 as it is no longer in use.
<ide> */
<ide> protected function wrapMessageWithType($messageType, $message)
<ide> {
<ide><path>tests/TestCase/Console/ShellTest.php
<ide> public function testOut()
<ide> public function testErr()
<ide> {
<ide> $this->io->expects($this->once())
<del> ->method('err')
<del> ->with('<error>Just a test</error>', 1);
<add> ->method('error')
<add> ->with('Just a test', 1);
<ide>
<ide> $this->Shell->err('Just a test');
<ide> }
<ide> public function testErr()
<ide> public function testErrArray()
<ide> {
<ide> $this->io->expects($this->once())
<del> ->method('err')
<del> ->with(['<error>Just</error>', '<error>a</error>', '<error>test</error>'], 1);
<add> ->method('error')
<add> ->with(['Just', 'a', 'test'], 1);
<ide>
<ide> $this->Shell->err(['Just', 'a', 'test']);
<ide> }
<ide> public function testErrArray()
<ide> public function testInfo()
<ide> {
<ide> $this->io->expects($this->once())
<del> ->method('out')
<del> ->with('<info>Just a test</info>', 1);
<add> ->method('info')
<add> ->with('Just a test', 1);
<ide>
<ide> $this->Shell->info('Just a test');
<ide> }
<ide> public function testInfo()
<ide> public function testInfoArray()
<ide> {
<ide> $this->io->expects($this->once())
<del> ->method('out')
<del> ->with(['<info>Just</info>', '<info>a</info>', '<info>test</info>'], 1);
<add> ->method('info')
<add> ->with(['Just', 'a', 'test'], 1);
<ide>
<ide> $this->Shell->info(['Just', 'a', 'test']);
<ide> }
<ide> public function testInfoArray()
<ide> public function testWarn()
<ide> {
<ide> $this->io->expects($this->once())
<del> ->method('err')
<del> ->with('<warning>Just a test</warning>', 1);
<add> ->method('warning')
<add> ->with('Just a test', 1);
<ide>
<ide> $this->Shell->warn('Just a test');
<ide> }
<ide> public function testWarn()
<ide> public function testWarnArray()
<ide> {
<ide> $this->io->expects($this->once())
<del> ->method('err')
<del> ->with(['<warning>Just</warning>', '<warning>a</warning>', '<warning>test</warning>'], 1);
<add> ->method('warning')
<add> ->with(['Just', 'a', 'test'], 1);
<ide>
<ide> $this->Shell->warn(['Just', 'a', 'test']);
<ide> }
<ide> public function testWarnArray()
<ide> public function testSuccess()
<ide> {
<ide> $this->io->expects($this->once())
<del> ->method('out')
<del> ->with('<success>Just a test</success>', 1);
<add> ->method('success')
<add> ->with('Just a test', 1);
<ide>
<ide> $this->Shell->success('Just a test');
<ide> }
<ide> public function testSuccess()
<ide> public function testSuccessArray()
<ide> {
<ide> $this->io->expects($this->once())
<del> ->method('out')
<del> ->with(['<success>Just</success>', '<success>a</success>', '<success>test</success>'], 1);
<add> ->method('success')
<add> ->with(['Just', 'a', 'test'], 1);
<ide>
<ide> $this->Shell->success(['Just', 'a', 'test']);
<ide> }
<ide> public function testRunCommandMainMissingArgument()
<ide> $shell->expects($this->never())->method('main');
<ide>
<ide> $io->expects($this->once())
<del> ->method('err')
<del> ->with('<error>Error: Missing required arguments. filename is required.</error>');
<add> ->method('error')
<add> ->with('Error: Missing required arguments. filename is required.');
<ide> $result = $shell->runCommand([]);
<ide> $this->assertFalse($result, 'Shell should fail');
<ide> }
| 2
|
Javascript
|
Javascript
|
fix direct uploads in ie 11
|
1a5bf01fe024eb1d91903094327d937f7abcb24d
|
<ide><path>activestorage/app/assets/javascripts/activestorage.js
<del>!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.ActiveStorage=e():t.ActiveStorage=e()}(this,function(){return function(t){function e(n){if(r[n])return r[n].exports;var i=r[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,e),i.l=!0,i.exports}var r={};return e.m=t,e.c=r,e.d=function(t,r,n){e.o(t,r)||Object.defineProperty(t,r,{configurable:!1,enumerable:!0,get:n})},e.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,"a",r),r},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=2)}([function(t,e,r){"use strict";function n(t){var e=a(document.head,'meta[name="'+t+'"]');if(e)return e.getAttribute("content")}function i(t,e){return"string"==typeof t&&(e=t,t=document),o(t.querySelectorAll(e))}function a(t,e){return"string"==typeof t&&(e=t,t=document),t.querySelector(e)}function u(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=r.bubbles,i=r.cancelable,a=r.detail,u=document.createEvent("Event");return u.initEvent(e,n||!0,i||!0),u.detail=a||{},t.dispatchEvent(u),u}function o(t){return Array.isArray(t)?t:Array.from?Array.from(t):[].slice.call(t)}e.d=n,e.c=i,e.b=a,e.a=u,e.e=o},function(t,e,r){"use strict";function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if(t&&"function"==typeof t[e]){for(var r=arguments.length,n=Array(r>2?r-2:0),i=2;i<r;i++)n[i-2]=arguments[i];return t[e].apply(t,n)}}r.d(e,"a",function(){return c});var a=r(6),u=r(8),o=r(9),s=function(){function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}(),f=0,c=function(){function t(e,r,i){n(this,t),this.id=++f,this.file=e,this.url=r,this.delegate=i}return s(t,[{key:"create",value:function(t){var e=this;a.a.create(this.file,function(r,n){var a=new u.a(e.file,n,e.url);i(e.delegate,"directUploadWillCreateBlobWithXHR",a.xhr),a.create(function(r){if(r)t(r);else{var n=new o.a(a);i(e.delegate,"directUploadWillStoreFileWithXHR",n.xhr),n.create(function(e){e?t(e):t(null,a.toJSON())})}})})}}]),t}()},function(t,e,r){"use strict";function n(){window.ActiveStorage&&Object(i.a)()}Object.defineProperty(e,"__esModule",{value:!0});var i=r(3),a=r(1);r.d(e,"start",function(){return i.a}),r.d(e,"DirectUpload",function(){return a.a}),setTimeout(n,1)},function(t,e,r){"use strict";function n(){d||(d=!0,document.addEventListener("submit",i),document.addEventListener("ajax:before",a))}function i(t){u(t)}function a(t){"FORM"==t.target.tagName&&u(t)}function u(t){var e=t.target;if(e.hasAttribute(l))return void t.preventDefault();var r=new c.a(e),n=r.inputs;n.length&&(t.preventDefault(),e.setAttribute(l,""),n.forEach(s),r.start(function(t){e.removeAttribute(l),t?n.forEach(f):o(e)}))}function o(t){var e=Object(h.b)(t,"input[type=submit]");if(e){var r=e,n=r.disabled;e.disabled=!1,e.focus(),e.click(),e.disabled=n}else e=document.createElement("input"),e.type="submit",e.style="display:none",t.appendChild(e),e.click(),t.removeChild(e)}function s(t){t.disabled=!0}function f(t){t.disabled=!1}e.a=n;var c=r(4),h=r(0),l="data-direct-uploads-processing",d=!1},function(t,e,r){"use strict";function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}r.d(e,"a",function(){return s});var i=r(5),a=r(0),u=function(){function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}(),o="input[type=file][data-direct-upload-url]:not([disabled])",s=function(){function t(e){n(this,t),this.form=e,this.inputs=Object(a.c)(e,o).filter(function(t){return t.files.length})}return u(t,[{key:"start",value:function(t){var e=this,r=this.createDirectUploadControllers();this.dispatch("start"),function n(){var i=r.shift();i?i.start(function(r){r?(t(r),e.dispatch("end")):n()}):(t(),e.dispatch("end"))}()}},{key:"createDirectUploadControllers",value:function(){var t=[];return this.inputs.forEach(function(e){Object(a.e)(e.files).forEach(function(r){var n=new i.a(e,r);t.push(n)})}),t}},{key:"dispatch",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Object(a.a)(this.form,"direct-uploads:"+t,{detail:e})}}]),t}()},function(t,e,r){"use strict";function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}r.d(e,"a",function(){return o});var i=r(1),a=r(0),u=function(){function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}(),o=function(){function t(e,r){n(this,t),this.input=e,this.file=r,this.directUpload=new i.a(this.file,this.url,this),this.dispatch("initialize")}return u(t,[{key:"start",value:function(t){var e=this,r=document.createElement("input");r.type="hidden",r.name=this.input.name,this.input.insertAdjacentElement("beforebegin",r),this.dispatch("start"),this.directUpload.create(function(n,i){n?(r.parentNode.removeChild(r),e.dispatchError(n)):r.value=i.signed_id,e.dispatch("end"),t(n)})}},{key:"uploadRequestDidProgress",value:function(t){var e=t.loaded/t.total*100;e&&this.dispatch("progress",{progress:e})}},{key:"dispatch",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e.file=this.file,e.id=this.directUpload.id,Object(a.a)(this.input,"direct-upload:"+t,{detail:e})}},{key:"dispatchError",value:function(t){this.dispatch("error",{error:t}).defaultPrevented||alert(t)}},{key:"directUploadWillCreateBlobWithXHR",value:function(t){this.dispatch("before-blob-request",{xhr:t})}},{key:"directUploadWillStoreFileWithXHR",value:function(t){var e=this;this.dispatch("before-storage-request",{xhr:t}),t.upload.addEventListener("progress",function(t){return e.uploadRequestDidProgress(t)})}},{key:"url",get:function(){return this.input.getAttribute("data-direct-upload-url")}}]),t}()},function(t,e,r){"use strict";function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}r.d(e,"a",function(){return s});var i=r(7),a=r.n(i),u=function(){function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}(),o=File.prototype.slice||File.prototype.mozSlice||File.prototype.webkitSlice,s=function(){function t(e){n(this,t),this.file=e,this.chunkSize=2097152,this.chunkCount=Math.ceil(this.file.size/this.chunkSize),this.chunkIndex=0}return u(t,null,[{key:"create",value:function(e,r){new t(e).create(r)}}]),u(t,[{key:"create",value:function(t){var e=this;this.callback=t,this.md5Buffer=new a.a.ArrayBuffer,this.fileReader=new FileReader,this.fileReader.addEventListener("load",function(t){return e.fileReaderDidLoad(t)}),this.fileReader.addEventListener("error",function(t){return e.fileReaderDidError(t)}),this.readNextChunk()}},{key:"fileReaderDidLoad",value:function(t){if(this.md5Buffer.append(t.target.result),!this.readNextChunk()){var e=this.md5Buffer.end(!0),r=btoa(e);this.callback(null,r)}}},{key:"fileReaderDidError",value:function(t){this.callback("Error reading "+this.file.name)}},{key:"readNextChunk",value:function(){if(this.chunkIndex<this.chunkCount){var t=this.chunkIndex*this.chunkSize,e=Math.min(t+this.chunkSize,this.file.size),r=o.call(this.file,t,e);return this.fileReader.readAsArrayBuffer(r),this.chunkIndex++,!0}return!1}}]),t}()},function(t,e,r){!function(e){t.exports=e()}(function(t){"use strict";function e(t,e){var r=t[0],n=t[1],i=t[2],a=t[3];r+=(n&i|~n&a)+e[0]-680876936|0,r=(r<<7|r>>>25)+n|0,a+=(r&n|~r&i)+e[1]-389564586|0,a=(a<<12|a>>>20)+r|0,i+=(a&r|~a&n)+e[2]+606105819|0,i=(i<<17|i>>>15)+a|0,n+=(i&a|~i&r)+e[3]-1044525330|0,n=(n<<22|n>>>10)+i|0,r+=(n&i|~n&a)+e[4]-176418897|0,r=(r<<7|r>>>25)+n|0,a+=(r&n|~r&i)+e[5]+1200080426|0,a=(a<<12|a>>>20)+r|0,i+=(a&r|~a&n)+e[6]-1473231341|0,i=(i<<17|i>>>15)+a|0,n+=(i&a|~i&r)+e[7]-45705983|0,n=(n<<22|n>>>10)+i|0,r+=(n&i|~n&a)+e[8]+1770035416|0,r=(r<<7|r>>>25)+n|0,a+=(r&n|~r&i)+e[9]-1958414417|0,a=(a<<12|a>>>20)+r|0,i+=(a&r|~a&n)+e[10]-42063|0,i=(i<<17|i>>>15)+a|0,n+=(i&a|~i&r)+e[11]-1990404162|0,n=(n<<22|n>>>10)+i|0,r+=(n&i|~n&a)+e[12]+1804603682|0,r=(r<<7|r>>>25)+n|0,a+=(r&n|~r&i)+e[13]-40341101|0,a=(a<<12|a>>>20)+r|0,i+=(a&r|~a&n)+e[14]-1502002290|0,i=(i<<17|i>>>15)+a|0,n+=(i&a|~i&r)+e[15]+1236535329|0,n=(n<<22|n>>>10)+i|0,r+=(n&a|i&~a)+e[1]-165796510|0,r=(r<<5|r>>>27)+n|0,a+=(r&i|n&~i)+e[6]-1069501632|0,a=(a<<9|a>>>23)+r|0,i+=(a&n|r&~n)+e[11]+643717713|0,i=(i<<14|i>>>18)+a|0,n+=(i&r|a&~r)+e[0]-373897302|0,n=(n<<20|n>>>12)+i|0,r+=(n&a|i&~a)+e[5]-701558691|0,r=(r<<5|r>>>27)+n|0,a+=(r&i|n&~i)+e[10]+38016083|0,a=(a<<9|a>>>23)+r|0,i+=(a&n|r&~n)+e[15]-660478335|0,i=(i<<14|i>>>18)+a|0,n+=(i&r|a&~r)+e[4]-405537848|0,n=(n<<20|n>>>12)+i|0,r+=(n&a|i&~a)+e[9]+568446438|0,r=(r<<5|r>>>27)+n|0,a+=(r&i|n&~i)+e[14]-1019803690|0,a=(a<<9|a>>>23)+r|0,i+=(a&n|r&~n)+e[3]-187363961|0,i=(i<<14|i>>>18)+a|0,n+=(i&r|a&~r)+e[8]+1163531501|0,n=(n<<20|n>>>12)+i|0,r+=(n&a|i&~a)+e[13]-1444681467|0,r=(r<<5|r>>>27)+n|0,a+=(r&i|n&~i)+e[2]-51403784|0,a=(a<<9|a>>>23)+r|0,i+=(a&n|r&~n)+e[7]+1735328473|0,i=(i<<14|i>>>18)+a|0,n+=(i&r|a&~r)+e[12]-1926607734|0,n=(n<<20|n>>>12)+i|0,r+=(n^i^a)+e[5]-378558|0,r=(r<<4|r>>>28)+n|0,a+=(r^n^i)+e[8]-2022574463|0,a=(a<<11|a>>>21)+r|0,i+=(a^r^n)+e[11]+1839030562|0,i=(i<<16|i>>>16)+a|0,n+=(i^a^r)+e[14]-35309556|0,n=(n<<23|n>>>9)+i|0,r+=(n^i^a)+e[1]-1530992060|0,r=(r<<4|r>>>28)+n|0,a+=(r^n^i)+e[4]+1272893353|0,a=(a<<11|a>>>21)+r|0,i+=(a^r^n)+e[7]-155497632|0,i=(i<<16|i>>>16)+a|0,n+=(i^a^r)+e[10]-1094730640|0,n=(n<<23|n>>>9)+i|0,r+=(n^i^a)+e[13]+681279174|0,r=(r<<4|r>>>28)+n|0,a+=(r^n^i)+e[0]-358537222|0,a=(a<<11|a>>>21)+r|0,i+=(a^r^n)+e[3]-722521979|0,i=(i<<16|i>>>16)+a|0,n+=(i^a^r)+e[6]+76029189|0,n=(n<<23|n>>>9)+i|0,r+=(n^i^a)+e[9]-640364487|0,r=(r<<4|r>>>28)+n|0,a+=(r^n^i)+e[12]-421815835|0,a=(a<<11|a>>>21)+r|0,i+=(a^r^n)+e[15]+530742520|0,i=(i<<16|i>>>16)+a|0,n+=(i^a^r)+e[2]-995338651|0,n=(n<<23|n>>>9)+i|0,r+=(i^(n|~a))+e[0]-198630844|0,r=(r<<6|r>>>26)+n|0,a+=(n^(r|~i))+e[7]+1126891415|0,a=(a<<10|a>>>22)+r|0,i+=(r^(a|~n))+e[14]-1416354905|0,i=(i<<15|i>>>17)+a|0,n+=(a^(i|~r))+e[5]-57434055|0,n=(n<<21|n>>>11)+i|0,r+=(i^(n|~a))+e[12]+1700485571|0,r=(r<<6|r>>>26)+n|0,a+=(n^(r|~i))+e[3]-1894986606|0,a=(a<<10|a>>>22)+r|0,i+=(r^(a|~n))+e[10]-1051523|0,i=(i<<15|i>>>17)+a|0,n+=(a^(i|~r))+e[1]-2054922799|0,n=(n<<21|n>>>11)+i|0,r+=(i^(n|~a))+e[8]+1873313359|0,r=(r<<6|r>>>26)+n|0,a+=(n^(r|~i))+e[15]-30611744|0,a=(a<<10|a>>>22)+r|0,i+=(r^(a|~n))+e[6]-1560198380|0,i=(i<<15|i>>>17)+a|0,n+=(a^(i|~r))+e[13]+1309151649|0,n=(n<<21|n>>>11)+i|0,r+=(i^(n|~a))+e[4]-145523070|0,r=(r<<6|r>>>26)+n|0,a+=(n^(r|~i))+e[11]-1120210379|0,a=(a<<10|a>>>22)+r|0,i+=(r^(a|~n))+e[2]+718787259|0,i=(i<<15|i>>>17)+a|0,n+=(a^(i|~r))+e[9]-343485551|0,n=(n<<21|n>>>11)+i|0,t[0]=r+t[0]|0,t[1]=n+t[1]|0,t[2]=i+t[2]|0,t[3]=a+t[3]|0}function r(t){var e,r=[];for(e=0;e<64;e+=4)r[e>>2]=t.charCodeAt(e)+(t.charCodeAt(e+1)<<8)+(t.charCodeAt(e+2)<<16)+(t.charCodeAt(e+3)<<24);return r}function n(t){var e,r=[];for(e=0;e<64;e+=4)r[e>>2]=t[e]+(t[e+1]<<8)+(t[e+2]<<16)+(t[e+3]<<24);return r}function i(t){var n,i,a,u,o,s,f=t.length,c=[1732584193,-271733879,-1732584194,271733878];for(n=64;n<=f;n+=64)e(c,r(t.substring(n-64,n)));for(t=t.substring(n-64),i=t.length,a=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],n=0;n<i;n+=1)a[n>>2]|=t.charCodeAt(n)<<(n%4<<3);if(a[n>>2]|=128<<(n%4<<3),n>55)for(e(c,a),n=0;n<16;n+=1)a[n]=0;return u=8*f,u=u.toString(16).match(/(.*?)(.{0,8})$/),o=parseInt(u[2],16),s=parseInt(u[1],16)||0,a[14]=o,a[15]=s,e(c,a),c}function a(t){var r,i,a,u,o,s,f=t.length,c=[1732584193,-271733879,-1732584194,271733878];for(r=64;r<=f;r+=64)e(c,n(t.subarray(r-64,r)));for(t=r-64<f?t.subarray(r-64):new Uint8Array(0),i=t.length,a=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],r=0;r<i;r+=1)a[r>>2]|=t[r]<<(r%4<<3);if(a[r>>2]|=128<<(r%4<<3),r>55)for(e(c,a),r=0;r<16;r+=1)a[r]=0;return u=8*f,u=u.toString(16).match(/(.*?)(.{0,8})$/),o=parseInt(u[2],16),s=parseInt(u[1],16)||0,a[14]=o,a[15]=s,e(c,a),c}function u(t){var e,r="";for(e=0;e<4;e+=1)r+=p[t>>8*e+4&15]+p[t>>8*e&15];return r}function o(t){var e;for(e=0;e<t.length;e+=1)t[e]=u(t[e]);return t.join("")}function s(t){return/[\u0080-\uFFFF]/.test(t)&&(t=unescape(encodeURIComponent(t))),t}function f(t,e){var r,n=t.length,i=new ArrayBuffer(n),a=new Uint8Array(i);for(r=0;r<n;r+=1)a[r]=t.charCodeAt(r);return e?a:i}function c(t){return String.fromCharCode.apply(null,new Uint8Array(t))}function h(t,e,r){var n=new Uint8Array(t.byteLength+e.byteLength);return n.set(new Uint8Array(t)),n.set(new Uint8Array(e),t.byteLength),r?n:n.buffer}function l(t){var e,r=[],n=t.length;for(e=0;e<n-1;e+=2)r.push(parseInt(t.substr(e,2),16));return String.fromCharCode.apply(String,r)}function d(){this.reset()}var p=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];return"5d41402abc4b2a76b9719d911017c592"!==o(i("hello"))&&function(t,e){var r=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(r>>16)<<16|65535&r},"undefined"==typeof ArrayBuffer||ArrayBuffer.prototype.slice||function(){function e(t,e){return t=0|t||0,t<0?Math.max(t+e,0):Math.min(t,e)}ArrayBuffer.prototype.slice=function(r,n){var i,a,u,o,s=this.byteLength,f=e(r,s),c=s;return n!==t&&(c=e(n,s)),f>c?new ArrayBuffer(0):(i=c-f,a=new ArrayBuffer(i),u=new Uint8Array(a),o=new Uint8Array(this,f,i),u.set(o),a)}}(),d.prototype.append=function(t){return this.appendBinary(s(t)),this},d.prototype.appendBinary=function(t){this._buff+=t,this._length+=t.length;var n,i=this._buff.length;for(n=64;n<=i;n+=64)e(this._hash,r(this._buff.substring(n-64,n)));return this._buff=this._buff.substring(n-64),this},d.prototype.end=function(t){var e,r,n=this._buff,i=n.length,a=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(e=0;e<i;e+=1)a[e>>2]|=n.charCodeAt(e)<<(e%4<<3);return this._finish(a,i),r=o(this._hash),t&&(r=l(r)),this.reset(),r},d.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},d.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash}},d.prototype.setState=function(t){return this._buff=t.buff,this._length=t.length,this._hash=t.hash,this},d.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},d.prototype._finish=function(t,r){var n,i,a,u=r;if(t[u>>2]|=128<<(u%4<<3),u>55)for(e(this._hash,t),u=0;u<16;u+=1)t[u]=0;n=8*this._length,n=n.toString(16).match(/(.*?)(.{0,8})$/),i=parseInt(n[2],16),a=parseInt(n[1],16)||0,t[14]=i,t[15]=a,e(this._hash,t)},d.hash=function(t,e){return d.hashBinary(s(t),e)},d.hashBinary=function(t,e){var r=i(t),n=o(r);return e?l(n):n},d.ArrayBuffer=function(){this.reset()},d.ArrayBuffer.prototype.append=function(t){var r,i=h(this._buff.buffer,t,!0),a=i.length;for(this._length+=t.byteLength,r=64;r<=a;r+=64)e(this._hash,n(i.subarray(r-64,r)));return this._buff=r-64<a?new Uint8Array(i.buffer.slice(r-64)):new Uint8Array(0),this},d.ArrayBuffer.prototype.end=function(t){var e,r,n=this._buff,i=n.length,a=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(e=0;e<i;e+=1)a[e>>2]|=n[e]<<(e%4<<3);return this._finish(a,i),r=o(this._hash),t&&(r=l(r)),this.reset(),r},d.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},d.ArrayBuffer.prototype.getState=function(){var t=d.prototype.getState.call(this);return t.buff=c(t.buff),t},d.ArrayBuffer.prototype.setState=function(t){return t.buff=f(t.buff,!0),d.prototype.setState.call(this,t)},d.ArrayBuffer.prototype.destroy=d.prototype.destroy,d.ArrayBuffer.prototype._finish=d.prototype._finish,d.ArrayBuffer.hash=function(t,e){var r=a(new Uint8Array(t)),n=o(r);return e?l(n):n},d})},function(t,e,r){"use strict";function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}r.d(e,"a",function(){return u});var i=r(0),a=function(){function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}(),u=function(){function t(e,r,a){var u=this;n(this,t),this.file=e,this.attributes={filename:e.name,content_type:e.type,byte_size:e.size,checksum:r},this.xhr=new XMLHttpRequest,this.xhr.open("POST",a,!0),this.xhr.responseType="json",this.xhr.setRequestHeader("Content-Type","application/json"),this.xhr.setRequestHeader("Accept","application/json"),this.xhr.setRequestHeader("X-Requested-With","XMLHttpRequest"),this.xhr.setRequestHeader("X-CSRF-Token",Object(i.d)("csrf-token")),this.xhr.addEventListener("load",function(t){return u.requestDidLoad(t)}),this.xhr.addEventListener("error",function(t){return u.requestDidError(t)})}return a(t,[{key:"create",value:function(t){this.callback=t,this.xhr.send(JSON.stringify({blob:this.attributes}))}},{key:"requestDidLoad",value:function(t){var e=this.xhr,r=e.status,n=e.response;if(r>=200&&r<300){var i=n.direct_upload;delete n.direct_upload,this.attributes=n,this.directUploadData=i,this.callback(null,this.toJSON())}else this.requestDidError(t)}},{key:"requestDidError",value:function(t){this.callback('Error creating Blob for "'+this.file.name+'". Status: '+this.xhr.status)}},{key:"toJSON",value:function(){var t={};for(var e in this.attributes)t[e]=this.attributes[e];return t}}]),t}()},function(t,e,r){"use strict";function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}r.d(e,"a",function(){return a});var i=function(){function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}(),a=function(){function t(e){var r=this;n(this,t),this.blob=e,this.file=e.file;var i=e.directUploadData,a=i.url,u=i.headers;this.xhr=new XMLHttpRequest,this.xhr.open("PUT",a,!0),this.xhr.responseType="text";for(var o in u)this.xhr.setRequestHeader(o,u[o]);this.xhr.addEventListener("load",function(t){return r.requestDidLoad(t)}),this.xhr.addEventListener("error",function(t){return r.requestDidError(t)})}return i(t,[{key:"create",value:function(t){this.callback=t,this.xhr.send(this.file)}},{key:"requestDidLoad",value:function(t){var e=this.xhr,r=e.status,n=e.response;r>=200&&r<300?this.callback(null,n):this.requestDidError(t)}},{key:"requestDidError",value:function(t){this.callback('Error storing "'+this.file.name+'". Status: '+this.xhr.status)}}]),t}()}])});
<ide>\ No newline at end of file
<add>!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.ActiveStorage=e():t.ActiveStorage=e()}(this,function(){return function(t){function e(n){if(r[n])return r[n].exports;var i=r[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,e),i.l=!0,i.exports}var r={};return e.m=t,e.c=r,e.d=function(t,r,n){e.o(t,r)||Object.defineProperty(t,r,{configurable:!1,enumerable:!0,get:n})},e.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,"a",r),r},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=2)}([function(t,e,r){"use strict";function n(t){var e=a(document.head,'meta[name="'+t+'"]');if(e)return e.getAttribute("content")}function i(t,e){return"string"==typeof t&&(e=t,t=document),o(t.querySelectorAll(e))}function a(t,e){return"string"==typeof t&&(e=t,t=document),t.querySelector(e)}function u(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=r.bubbles,i=r.cancelable,a=r.detail,u=document.createEvent("Event");return u.initEvent(e,n||!0,i||!0),u.detail=a||{},t.dispatchEvent(u),u}function o(t){return Array.isArray(t)?t:Array.from?Array.from(t):[].slice.call(t)}e.d=n,e.c=i,e.b=a,e.a=u,e.e=o},function(t,e,r){"use strict";function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if(t&&"function"==typeof t[e]){for(var r=arguments.length,n=Array(r>2?r-2:0),i=2;i<r;i++)n[i-2]=arguments[i];return t[e].apply(t,n)}}r.d(e,"a",function(){return c});var a=r(6),u=r(8),o=r(9),s=function(){function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}(),f=0,c=function(){function t(e,r,i){n(this,t),this.id=++f,this.file=e,this.url=r,this.delegate=i}return s(t,[{key:"create",value:function(t){var e=this;a.a.create(this.file,function(r,n){var a=new u.a(e.file,n,e.url);i(e.delegate,"directUploadWillCreateBlobWithXHR",a.xhr),a.create(function(r){if(r)t(r);else{var n=new o.a(a);i(e.delegate,"directUploadWillStoreFileWithXHR",n.xhr),n.create(function(e){e?t(e):t(null,a.toJSON())})}})})}}]),t}()},function(t,e,r){"use strict";function n(){window.ActiveStorage&&Object(i.a)()}Object.defineProperty(e,"__esModule",{value:!0});var i=r(3),a=r(1);r.d(e,"start",function(){return i.a}),r.d(e,"DirectUpload",function(){return a.a}),setTimeout(n,1)},function(t,e,r){"use strict";function n(){d||(d=!0,document.addEventListener("submit",i),document.addEventListener("ajax:before",a))}function i(t){u(t)}function a(t){"FORM"==t.target.tagName&&u(t)}function u(t){var e=t.target;if(e.hasAttribute(l))return void t.preventDefault();var r=new c.a(e),n=r.inputs;n.length&&(t.preventDefault(),e.setAttribute(l,""),n.forEach(s),r.start(function(t){e.removeAttribute(l),t?n.forEach(f):o(e)}))}function o(t){var e=Object(h.b)(t,"input[type=submit]");if(e){var r=e,n=r.disabled;e.disabled=!1,e.focus(),e.click(),e.disabled=n}else e=document.createElement("input"),e.type="submit",e.style="display:none",t.appendChild(e),e.click(),t.removeChild(e)}function s(t){t.disabled=!0}function f(t){t.disabled=!1}e.a=n;var c=r(4),h=r(0),l="data-direct-uploads-processing",d=!1},function(t,e,r){"use strict";function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}r.d(e,"a",function(){return s});var i=r(5),a=r(0),u=function(){function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}(),o="input[type=file][data-direct-upload-url]:not([disabled])",s=function(){function t(e){n(this,t),this.form=e,this.inputs=Object(a.c)(e,o).filter(function(t){return t.files.length})}return u(t,[{key:"start",value:function(t){var e=this,r=this.createDirectUploadControllers();this.dispatch("start"),function n(){var i=r.shift();i?i.start(function(r){r?(t(r),e.dispatch("end")):n()}):(t(),e.dispatch("end"))}()}},{key:"createDirectUploadControllers",value:function(){var t=[];return this.inputs.forEach(function(e){Object(a.e)(e.files).forEach(function(r){var n=new i.a(e,r);t.push(n)})}),t}},{key:"dispatch",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Object(a.a)(this.form,"direct-uploads:"+t,{detail:e})}}]),t}()},function(t,e,r){"use strict";function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}r.d(e,"a",function(){return o});var i=r(1),a=r(0),u=function(){function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}(),o=function(){function t(e,r){n(this,t),this.input=e,this.file=r,this.directUpload=new i.a(this.file,this.url,this),this.dispatch("initialize")}return u(t,[{key:"start",value:function(t){var e=this,r=document.createElement("input");r.type="hidden",r.name=this.input.name,this.input.insertAdjacentElement("beforebegin",r),this.dispatch("start"),this.directUpload.create(function(n,i){n?(r.parentNode.removeChild(r),e.dispatchError(n)):r.value=i.signed_id,e.dispatch("end"),t(n)})}},{key:"uploadRequestDidProgress",value:function(t){var e=t.loaded/t.total*100;e&&this.dispatch("progress",{progress:e})}},{key:"dispatch",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e.file=this.file,e.id=this.directUpload.id,Object(a.a)(this.input,"direct-upload:"+t,{detail:e})}},{key:"dispatchError",value:function(t){this.dispatch("error",{error:t}).defaultPrevented||alert(t)}},{key:"directUploadWillCreateBlobWithXHR",value:function(t){this.dispatch("before-blob-request",{xhr:t})}},{key:"directUploadWillStoreFileWithXHR",value:function(t){var e=this;this.dispatch("before-storage-request",{xhr:t}),t.upload.addEventListener("progress",function(t){return e.uploadRequestDidProgress(t)})}},{key:"url",get:function(){return this.input.getAttribute("data-direct-upload-url")}}]),t}()},function(t,e,r){"use strict";function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}r.d(e,"a",function(){return s});var i=r(7),a=r.n(i),u=function(){function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}(),o=File.prototype.slice||File.prototype.mozSlice||File.prototype.webkitSlice,s=function(){function t(e){n(this,t),this.file=e,this.chunkSize=2097152,this.chunkCount=Math.ceil(this.file.size/this.chunkSize),this.chunkIndex=0}return u(t,null,[{key:"create",value:function(e,r){new t(e).create(r)}}]),u(t,[{key:"create",value:function(t){var e=this;this.callback=t,this.md5Buffer=new a.a.ArrayBuffer,this.fileReader=new FileReader,this.fileReader.addEventListener("load",function(t){return e.fileReaderDidLoad(t)}),this.fileReader.addEventListener("error",function(t){return e.fileReaderDidError(t)}),this.readNextChunk()}},{key:"fileReaderDidLoad",value:function(t){if(this.md5Buffer.append(t.target.result),!this.readNextChunk()){var e=this.md5Buffer.end(!0),r=btoa(e);this.callback(null,r)}}},{key:"fileReaderDidError",value:function(t){this.callback("Error reading "+this.file.name)}},{key:"readNextChunk",value:function(){if(this.chunkIndex<this.chunkCount){var t=this.chunkIndex*this.chunkSize,e=Math.min(t+this.chunkSize,this.file.size),r=o.call(this.file,t,e);return this.fileReader.readAsArrayBuffer(r),this.chunkIndex++,!0}return!1}}]),t}()},function(t,e,r){!function(e){t.exports=e()}(function(t){"use strict";function e(t,e){var r=t[0],n=t[1],i=t[2],a=t[3];r+=(n&i|~n&a)+e[0]-680876936|0,r=(r<<7|r>>>25)+n|0,a+=(r&n|~r&i)+e[1]-389564586|0,a=(a<<12|a>>>20)+r|0,i+=(a&r|~a&n)+e[2]+606105819|0,i=(i<<17|i>>>15)+a|0,n+=(i&a|~i&r)+e[3]-1044525330|0,n=(n<<22|n>>>10)+i|0,r+=(n&i|~n&a)+e[4]-176418897|0,r=(r<<7|r>>>25)+n|0,a+=(r&n|~r&i)+e[5]+1200080426|0,a=(a<<12|a>>>20)+r|0,i+=(a&r|~a&n)+e[6]-1473231341|0,i=(i<<17|i>>>15)+a|0,n+=(i&a|~i&r)+e[7]-45705983|0,n=(n<<22|n>>>10)+i|0,r+=(n&i|~n&a)+e[8]+1770035416|0,r=(r<<7|r>>>25)+n|0,a+=(r&n|~r&i)+e[9]-1958414417|0,a=(a<<12|a>>>20)+r|0,i+=(a&r|~a&n)+e[10]-42063|0,i=(i<<17|i>>>15)+a|0,n+=(i&a|~i&r)+e[11]-1990404162|0,n=(n<<22|n>>>10)+i|0,r+=(n&i|~n&a)+e[12]+1804603682|0,r=(r<<7|r>>>25)+n|0,a+=(r&n|~r&i)+e[13]-40341101|0,a=(a<<12|a>>>20)+r|0,i+=(a&r|~a&n)+e[14]-1502002290|0,i=(i<<17|i>>>15)+a|0,n+=(i&a|~i&r)+e[15]+1236535329|0,n=(n<<22|n>>>10)+i|0,r+=(n&a|i&~a)+e[1]-165796510|0,r=(r<<5|r>>>27)+n|0,a+=(r&i|n&~i)+e[6]-1069501632|0,a=(a<<9|a>>>23)+r|0,i+=(a&n|r&~n)+e[11]+643717713|0,i=(i<<14|i>>>18)+a|0,n+=(i&r|a&~r)+e[0]-373897302|0,n=(n<<20|n>>>12)+i|0,r+=(n&a|i&~a)+e[5]-701558691|0,r=(r<<5|r>>>27)+n|0,a+=(r&i|n&~i)+e[10]+38016083|0,a=(a<<9|a>>>23)+r|0,i+=(a&n|r&~n)+e[15]-660478335|0,i=(i<<14|i>>>18)+a|0,n+=(i&r|a&~r)+e[4]-405537848|0,n=(n<<20|n>>>12)+i|0,r+=(n&a|i&~a)+e[9]+568446438|0,r=(r<<5|r>>>27)+n|0,a+=(r&i|n&~i)+e[14]-1019803690|0,a=(a<<9|a>>>23)+r|0,i+=(a&n|r&~n)+e[3]-187363961|0,i=(i<<14|i>>>18)+a|0,n+=(i&r|a&~r)+e[8]+1163531501|0,n=(n<<20|n>>>12)+i|0,r+=(n&a|i&~a)+e[13]-1444681467|0,r=(r<<5|r>>>27)+n|0,a+=(r&i|n&~i)+e[2]-51403784|0,a=(a<<9|a>>>23)+r|0,i+=(a&n|r&~n)+e[7]+1735328473|0,i=(i<<14|i>>>18)+a|0,n+=(i&r|a&~r)+e[12]-1926607734|0,n=(n<<20|n>>>12)+i|0,r+=(n^i^a)+e[5]-378558|0,r=(r<<4|r>>>28)+n|0,a+=(r^n^i)+e[8]-2022574463|0,a=(a<<11|a>>>21)+r|0,i+=(a^r^n)+e[11]+1839030562|0,i=(i<<16|i>>>16)+a|0,n+=(i^a^r)+e[14]-35309556|0,n=(n<<23|n>>>9)+i|0,r+=(n^i^a)+e[1]-1530992060|0,r=(r<<4|r>>>28)+n|0,a+=(r^n^i)+e[4]+1272893353|0,a=(a<<11|a>>>21)+r|0,i+=(a^r^n)+e[7]-155497632|0,i=(i<<16|i>>>16)+a|0,n+=(i^a^r)+e[10]-1094730640|0,n=(n<<23|n>>>9)+i|0,r+=(n^i^a)+e[13]+681279174|0,r=(r<<4|r>>>28)+n|0,a+=(r^n^i)+e[0]-358537222|0,a=(a<<11|a>>>21)+r|0,i+=(a^r^n)+e[3]-722521979|0,i=(i<<16|i>>>16)+a|0,n+=(i^a^r)+e[6]+76029189|0,n=(n<<23|n>>>9)+i|0,r+=(n^i^a)+e[9]-640364487|0,r=(r<<4|r>>>28)+n|0,a+=(r^n^i)+e[12]-421815835|0,a=(a<<11|a>>>21)+r|0,i+=(a^r^n)+e[15]+530742520|0,i=(i<<16|i>>>16)+a|0,n+=(i^a^r)+e[2]-995338651|0,n=(n<<23|n>>>9)+i|0,r+=(i^(n|~a))+e[0]-198630844|0,r=(r<<6|r>>>26)+n|0,a+=(n^(r|~i))+e[7]+1126891415|0,a=(a<<10|a>>>22)+r|0,i+=(r^(a|~n))+e[14]-1416354905|0,i=(i<<15|i>>>17)+a|0,n+=(a^(i|~r))+e[5]-57434055|0,n=(n<<21|n>>>11)+i|0,r+=(i^(n|~a))+e[12]+1700485571|0,r=(r<<6|r>>>26)+n|0,a+=(n^(r|~i))+e[3]-1894986606|0,a=(a<<10|a>>>22)+r|0,i+=(r^(a|~n))+e[10]-1051523|0,i=(i<<15|i>>>17)+a|0,n+=(a^(i|~r))+e[1]-2054922799|0,n=(n<<21|n>>>11)+i|0,r+=(i^(n|~a))+e[8]+1873313359|0,r=(r<<6|r>>>26)+n|0,a+=(n^(r|~i))+e[15]-30611744|0,a=(a<<10|a>>>22)+r|0,i+=(r^(a|~n))+e[6]-1560198380|0,i=(i<<15|i>>>17)+a|0,n+=(a^(i|~r))+e[13]+1309151649|0,n=(n<<21|n>>>11)+i|0,r+=(i^(n|~a))+e[4]-145523070|0,r=(r<<6|r>>>26)+n|0,a+=(n^(r|~i))+e[11]-1120210379|0,a=(a<<10|a>>>22)+r|0,i+=(r^(a|~n))+e[2]+718787259|0,i=(i<<15|i>>>17)+a|0,n+=(a^(i|~r))+e[9]-343485551|0,n=(n<<21|n>>>11)+i|0,t[0]=r+t[0]|0,t[1]=n+t[1]|0,t[2]=i+t[2]|0,t[3]=a+t[3]|0}function r(t){var e,r=[];for(e=0;e<64;e+=4)r[e>>2]=t.charCodeAt(e)+(t.charCodeAt(e+1)<<8)+(t.charCodeAt(e+2)<<16)+(t.charCodeAt(e+3)<<24);return r}function n(t){var e,r=[];for(e=0;e<64;e+=4)r[e>>2]=t[e]+(t[e+1]<<8)+(t[e+2]<<16)+(t[e+3]<<24);return r}function i(t){var n,i,a,u,o,s,f=t.length,c=[1732584193,-271733879,-1732584194,271733878];for(n=64;n<=f;n+=64)e(c,r(t.substring(n-64,n)));for(t=t.substring(n-64),i=t.length,a=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],n=0;n<i;n+=1)a[n>>2]|=t.charCodeAt(n)<<(n%4<<3);if(a[n>>2]|=128<<(n%4<<3),n>55)for(e(c,a),n=0;n<16;n+=1)a[n]=0;return u=8*f,u=u.toString(16).match(/(.*?)(.{0,8})$/),o=parseInt(u[2],16),s=parseInt(u[1],16)||0,a[14]=o,a[15]=s,e(c,a),c}function a(t){var r,i,a,u,o,s,f=t.length,c=[1732584193,-271733879,-1732584194,271733878];for(r=64;r<=f;r+=64)e(c,n(t.subarray(r-64,r)));for(t=r-64<f?t.subarray(r-64):new Uint8Array(0),i=t.length,a=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],r=0;r<i;r+=1)a[r>>2]|=t[r]<<(r%4<<3);if(a[r>>2]|=128<<(r%4<<3),r>55)for(e(c,a),r=0;r<16;r+=1)a[r]=0;return u=8*f,u=u.toString(16).match(/(.*?)(.{0,8})$/),o=parseInt(u[2],16),s=parseInt(u[1],16)||0,a[14]=o,a[15]=s,e(c,a),c}function u(t){var e,r="";for(e=0;e<4;e+=1)r+=p[t>>8*e+4&15]+p[t>>8*e&15];return r}function o(t){var e;for(e=0;e<t.length;e+=1)t[e]=u(t[e]);return t.join("")}function s(t){return/[\u0080-\uFFFF]/.test(t)&&(t=unescape(encodeURIComponent(t))),t}function f(t,e){var r,n=t.length,i=new ArrayBuffer(n),a=new Uint8Array(i);for(r=0;r<n;r+=1)a[r]=t.charCodeAt(r);return e?a:i}function c(t){return String.fromCharCode.apply(null,new Uint8Array(t))}function h(t,e,r){var n=new Uint8Array(t.byteLength+e.byteLength);return n.set(new Uint8Array(t)),n.set(new Uint8Array(e),t.byteLength),r?n:n.buffer}function l(t){var e,r=[],n=t.length;for(e=0;e<n-1;e+=2)r.push(parseInt(t.substr(e,2),16));return String.fromCharCode.apply(String,r)}function d(){this.reset()}var p=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];return"5d41402abc4b2a76b9719d911017c592"!==o(i("hello"))&&function(t,e){var r=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(r>>16)<<16|65535&r},"undefined"==typeof ArrayBuffer||ArrayBuffer.prototype.slice||function(){function e(t,e){return t=0|t||0,t<0?Math.max(t+e,0):Math.min(t,e)}ArrayBuffer.prototype.slice=function(r,n){var i,a,u,o,s=this.byteLength,f=e(r,s),c=s;return n!==t&&(c=e(n,s)),f>c?new ArrayBuffer(0):(i=c-f,a=new ArrayBuffer(i),u=new Uint8Array(a),o=new Uint8Array(this,f,i),u.set(o),a)}}(),d.prototype.append=function(t){return this.appendBinary(s(t)),this},d.prototype.appendBinary=function(t){this._buff+=t,this._length+=t.length;var n,i=this._buff.length;for(n=64;n<=i;n+=64)e(this._hash,r(this._buff.substring(n-64,n)));return this._buff=this._buff.substring(n-64),this},d.prototype.end=function(t){var e,r,n=this._buff,i=n.length,a=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(e=0;e<i;e+=1)a[e>>2]|=n.charCodeAt(e)<<(e%4<<3);return this._finish(a,i),r=o(this._hash),t&&(r=l(r)),this.reset(),r},d.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},d.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash}},d.prototype.setState=function(t){return this._buff=t.buff,this._length=t.length,this._hash=t.hash,this},d.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},d.prototype._finish=function(t,r){var n,i,a,u=r;if(t[u>>2]|=128<<(u%4<<3),u>55)for(e(this._hash,t),u=0;u<16;u+=1)t[u]=0;n=8*this._length,n=n.toString(16).match(/(.*?)(.{0,8})$/),i=parseInt(n[2],16),a=parseInt(n[1],16)||0,t[14]=i,t[15]=a,e(this._hash,t)},d.hash=function(t,e){return d.hashBinary(s(t),e)},d.hashBinary=function(t,e){var r=i(t),n=o(r);return e?l(n):n},d.ArrayBuffer=function(){this.reset()},d.ArrayBuffer.prototype.append=function(t){var r,i=h(this._buff.buffer,t,!0),a=i.length;for(this._length+=t.byteLength,r=64;r<=a;r+=64)e(this._hash,n(i.subarray(r-64,r)));return this._buff=r-64<a?new Uint8Array(i.buffer.slice(r-64)):new Uint8Array(0),this},d.ArrayBuffer.prototype.end=function(t){var e,r,n=this._buff,i=n.length,a=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(e=0;e<i;e+=1)a[e>>2]|=n[e]<<(e%4<<3);return this._finish(a,i),r=o(this._hash),t&&(r=l(r)),this.reset(),r},d.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},d.ArrayBuffer.prototype.getState=function(){var t=d.prototype.getState.call(this);return t.buff=c(t.buff),t},d.ArrayBuffer.prototype.setState=function(t){return t.buff=f(t.buff,!0),d.prototype.setState.call(this,t)},d.ArrayBuffer.prototype.destroy=d.prototype.destroy,d.ArrayBuffer.prototype._finish=d.prototype._finish,d.ArrayBuffer.hash=function(t,e){var r=a(new Uint8Array(t)),n=o(r);return e?l(n):n},d})},function(t,e,r){"use strict";function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}r.d(e,"a",function(){return u});var i=r(0),a=function(){function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}(),u=function(){function t(e,r,a){var u=this;n(this,t),this.file=e,this.attributes={filename:e.name,content_type:e.type,byte_size:e.size,checksum:r},this.xhr=new XMLHttpRequest,this.xhr.open("POST",a,!0),this.xhr.responseType="json",this.xhr.setRequestHeader("Content-Type","application/json"),this.xhr.setRequestHeader("Accept","application/json"),this.xhr.setRequestHeader("X-Requested-With","XMLHttpRequest"),this.xhr.setRequestHeader("X-CSRF-Token",Object(i.d)("csrf-token")),this.xhr.addEventListener("load",function(t){return u.requestDidLoad(t)}),this.xhr.addEventListener("error",function(t){return u.requestDidError(t)})}return a(t,[{key:"create",value:function(t){this.callback=t,this.xhr.send(JSON.stringify({blob:this.attributes}))}},{key:"requestDidLoad",value:function(t){if(this.status>=200&&this.status<300){var e=this.response,r=e.direct_upload;delete e.direct_upload,this.attributes=e,this.directUploadData=r,this.callback(null,this.toJSON())}else this.requestDidError(t)}},{key:"requestDidError",value:function(t){this.callback('Error creating Blob for "'+this.file.name+'". Status: '+this.status)}},{key:"toJSON",value:function(){var t={};for(var e in this.attributes)t[e]=this.attributes[e];return t}},{key:"status",get:function(){return this.xhr.status}},{key:"response",get:function(){var t=this.xhr,e=t.responseType,r=t.response;return"json"==e?r:JSON.parse(r)}}]),t}()},function(t,e,r){"use strict";function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}r.d(e,"a",function(){return a});var i=function(){function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}(),a=function(){function t(e){var r=this;n(this,t),this.blob=e,this.file=e.file;var i=e.directUploadData,a=i.url,u=i.headers;this.xhr=new XMLHttpRequest,this.xhr.open("PUT",a,!0),this.xhr.responseType="text";for(var o in u)this.xhr.setRequestHeader(o,u[o]);this.xhr.addEventListener("load",function(t){return r.requestDidLoad(t)}),this.xhr.addEventListener("error",function(t){return r.requestDidError(t)})}return i(t,[{key:"create",value:function(t){this.callback=t,this.xhr.send(this.file)}},{key:"requestDidLoad",value:function(t){var e=this.xhr,r=e.status,n=e.response;r>=200&&r<300?this.callback(null,n):this.requestDidError(t)}},{key:"requestDidError",value:function(t){this.callback('Error storing "'+this.file.name+'". Status: '+this.xhr.status)}}]),t}()}])});
<ide>\ No newline at end of file
<ide><path>activestorage/app/javascript/activestorage/blob_record.js
<ide> export class BlobRecord {
<ide> this.xhr.addEventListener("error", event => this.requestDidError(event))
<ide> }
<ide>
<add> get status() {
<add> return this.xhr.status
<add> }
<add>
<add> get response() {
<add> const { responseType, response } = this.xhr
<add> if (responseType == "json") {
<add> return response
<add> } else {
<add> // Shim for IE 11: https://connect.microsoft.com/IE/feedback/details/794808
<add> return JSON.parse(response)
<add> }
<add> }
<add>
<ide> create(callback) {
<ide> this.callback = callback
<ide> this.xhr.send(JSON.stringify({ blob: this.attributes }))
<ide> }
<ide>
<ide> requestDidLoad(event) {
<del> const { status, response } = this.xhr
<del> if (status >= 200 && status < 300) {
<add> if (this.status >= 200 && this.status < 300) {
<add> const { response } = this
<ide> const { direct_upload } = response
<ide> delete response.direct_upload
<ide> this.attributes = response
<ide> export class BlobRecord {
<ide> }
<ide>
<ide> requestDidError(event) {
<del> this.callback(`Error creating Blob for "${this.file.name}". Status: ${this.xhr.status}`)
<add> this.callback(`Error creating Blob for "${this.file.name}". Status: ${this.status}`)
<ide> }
<ide>
<ide> toJSON() {
| 2
|
Java
|
Java
|
update @since tag
|
cd619a2f095de60638cf343220606559d8b9464a
|
<ide><path>spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestScopedControllerAdviceIntegrationTests.java
<ide> * Integration tests for request-scoped {@link ControllerAdvice @ControllerAdvice} beans.
<ide> *
<ide> * @author Sam Brannen
<del> * @since 5.2.2
<add> * @since 5.1.12
<ide> */
<ide> class RequestScopedControllerAdviceIntegrationTests {
<ide>
| 1
|
PHP
|
PHP
|
fix failing test
|
42feb8dff63cecd7bac4278e8a271369d573de8a
|
<ide><path>lib/Cake/Test/Case/View/Helper/FormHelperTest.php
<ide> public function testPostLink() {
<ide> ),
<ide> 'input' => array('type' => 'hidden', 'name' => '_method', 'value' => 'POST'),
<ide> '/form',
<del> 'a' => array('class' => 'btn btn-danger', 'href' => '#', 'onclick' => 'preg:/if \(confirm\(\'Confirm thing\'\)\) \{ document\.post_\w+\.submit\(\); \} event\.returnValue = false; return false;/'),
<add> 'a' => array('class' => 'btn btn-danger', 'href' => '#', 'onclick' => 'preg:/if \(confirm\(\"\;Confirm thing\"\;\)\) \{ document\.post_\w+\.submit\(\); \} event\.returnValue = false; return false;/'),
<ide> '/a'
<ide> ));
<ide> }
| 1
|
Ruby
|
Ruby
|
fix non-condition `elsif`
|
db8e957c846ee89f6832cc39a304a016ac493c7c
|
<ide><path>activerecord/test/cases/migration_test.rb
<ide> def migrate(x)
<ide> else
<ide> assert_match(/check that column\/key exists/, error.message)
<ide> end
<del> elsif
<add> elsif current_adapter?(:PostgreSQLAdapter)
<ide> assert_match(/column \"last_name\" of relation \"people\" does not exist/, error.message)
<ide> end
<ide> end
| 1
|
Javascript
|
Javascript
|
remove unnecessary calculation in vector3.project
|
9796f88f0c84dff13ff3723dc7ff3f6da345c610
|
<ide><path>src/math/Vector3.js
<ide> Object.assign( Vector3.prototype, {
<ide>
<ide> return function project( camera ) {
<ide>
<del> matrix.multiplyMatrices( camera.projectionMatrix, matrix.getInverse( camera.matrixWorld ) );
<add> matrix.multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse );
<ide> return this.applyMatrix4( matrix );
<ide>
<ide> };
| 1
|
Java
|
Java
|
enforce standard java types in yamlprocessor
|
58e9b187fedf03da21c4e2270bb5335b941ccf61
|
<ide><path>spring-beans/src/main/java/org/springframework/beans/factory/config/YamlProcessor.java
<ide> /*
<del> * Copyright 2002-2020 the original author or authors.
<add> * Copyright 2002-2021 the original author or authors.
<ide> *
<ide> * Licensed under the Apache License, Version 2.0 (the "License");
<ide> * you may not use this file except in compliance with the License.
<ide> * @author Dave Syer
<ide> * @author Juergen Hoeller
<ide> * @author Sam Brannen
<add> * @author Brian Clozel
<ide> * @since 4.1
<ide> */
<ide> public abstract class YamlProcessor {
<ide> public void setResources(Resource... resources) {
<ide>
<ide> /**
<ide> * Set the supported types that can be loaded from YAML documents.
<del> * <p>If no supported types are configured, all types encountered in YAML
<del> * documents will be supported. If an unsupported type is encountered, an
<del> * {@link IllegalStateException} will be thrown when the corresponding YAML
<del> * node is processed.
<add> * <p>If no supported types are configured, only Java standard classes
<add> * (as defined in {@link org.yaml.snakeyaml.constructor.SafeConstructor})
<add> * encountered in YAML documents will be supported.
<add> * If an unsupported type is encountered, an {@link IllegalStateException}
<add> * will be thrown when the corresponding YAML node is processed.
<ide> * @param supportedTypes the supported types, or an empty array to clear the
<ide> * supported types
<ide> * @since 5.1.16
<ide> protected void process(MatchCallback callback) {
<ide> protected Yaml createYaml() {
<ide> LoaderOptions loaderOptions = new LoaderOptions();
<ide> loaderOptions.setAllowDuplicateKeys(false);
<del>
<del> if (!this.supportedTypes.isEmpty()) {
<del> return new Yaml(new FilteringConstructor(loaderOptions), new Representer(),
<del> new DumperOptions(), loaderOptions);
<del> }
<del> return new Yaml(loaderOptions);
<add> return new Yaml(new FilteringConstructor(loaderOptions), new Representer(),
<add> new DumperOptions(), loaderOptions);
<ide> }
<ide>
<ide> private boolean process(MatchCallback callback, Yaml yaml, Resource resource) {
<ide><path>spring-beans/src/test/java/org/springframework/beans/factory/config/YamlProcessorTests.java
<ide> /*
<del> * Copyright 2002-2020 the original author or authors.
<add> * Copyright 2002-2021 the original author or authors.
<ide> *
<ide> * Licensed under the Apache License, Version 2.0 (the "License");
<ide> * you may not use this file except in compliance with the License.
<ide> package org.springframework.beans.factory.config;
<ide>
<ide> import java.net.URL;
<add>import java.util.ArrayList;
<ide> import java.util.LinkedHashMap;
<ide> import java.util.List;
<ide> import java.util.Map;
<add>import java.util.Set;
<ide>
<ide> import org.junit.jupiter.api.Test;
<ide> import org.yaml.snakeyaml.constructor.ConstructorException;
<ide>
<ide> import org.springframework.core.io.ByteArrayResource;
<ide>
<del>import static java.util.stream.Collectors.toList;
<ide> import static org.assertj.core.api.Assertions.assertThat;
<ide> import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
<ide> import static org.assertj.core.api.Assertions.entry;
<ide> * @author Dave Syer
<ide> * @author Juergen Hoeller
<ide> * @author Sam Brannen
<add> * @author Brian Clozel
<ide> */
<ide> class YamlProcessorTests {
<ide>
<del> private final YamlProcessor processor = new YamlProcessor() {};
<add> private final YamlProcessor processor = new YamlProcessor() {
<add> };
<ide>
<ide>
<ide> @Test
<ide> void badDocumentStart() {
<ide> void badResource() {
<ide> setYaml("foo: bar\ncd\nspam:\n foo: baz");
<ide> assertThatExceptionOfType(ScannerException.class)
<del> .isThrownBy(() -> this.processor.process((properties, map) -> {}))
<del> .withMessageContaining("line 3, column 1");
<add> .isThrownBy(() -> this.processor.process((properties, map) -> {}))
<add> .withMessageContaining("line 3, column 1");
<ide> }
<ide>
<ide> @Test
<ide> void flattenedMapIsSameAsPropertiesButOrdered() {
<ide> Map<String, Object> bar = (Map<String, Object>) map.get("bar");
<ide> assertThat(bar.get("spam")).isEqualTo("bucket");
<ide>
<del> List<Object> keysFromProperties = properties.keySet().stream().collect(toList());
<del> List<String> keysFromFlattenedMap = flattenedMap.keySet().stream().collect(toList());
<add> List<Object> keysFromProperties = new ArrayList<>(properties.keySet());
<add> List<String> keysFromFlattenedMap = new ArrayList<>(flattenedMap.keySet());
<ide> assertThat(keysFromProperties).containsExactlyInAnyOrderElementsOf(keysFromFlattenedMap);
<ide> // Keys in the Properties object are sorted.
<ide> assertThat(keysFromProperties).containsExactly("bar.spam", "cat", "foo");
<ide> void flattenedMapIsSameAsPropertiesButOrdered() {
<ide> }
<ide>
<ide> @Test
<del> void customTypeSupportedByDefault() throws Exception {
<del> URL url = new URL("https://localhost:9000/");
<del> setYaml("value: !!java.net.URL [\"" + url + "\"]");
<del>
<add> void standardTypesSupportedByDefault() throws Exception {
<add> setYaml("value: !!set\n ? first\n ? second");
<ide> this.processor.process((properties, map) -> {
<del> assertThat(properties).containsExactly(entry("value", url));
<del> assertThat(map).containsExactly(entry("value", url));
<add> assertThat(properties).containsExactly(entry("value[0]", "first"), entry("value[1]", "second"));
<add> assertThat(map.get("value")).isInstanceOf(Set.class);
<add> Set<String> set = (Set<String>) map.get("value");
<add> assertThat(set).containsExactly("first", "second");
<ide> });
<ide> }
<ide>
<add> @Test
<add> void customTypeNotSupportedByDefault() throws Exception {
<add> URL url = new URL("https://localhost:9000/");
<add> setYaml("value: !!java.net.URL [\"" + url + "\"]");
<add> assertThatExceptionOfType(ConstructorException.class)
<add> .isThrownBy(() -> this.processor.process((properties, map) -> {}))
<add> .withMessageContaining("Unsupported type encountered in YAML document: java.net.URL");
<add> }
<add>
<ide> @Test
<ide> void customTypesSupportedDueToExplicitConfiguration() throws Exception {
<ide> this.processor.setSupportedTypes(URL.class, String.class);
<ide> void customTypeNotSupportedDueToExplicitConfiguration() {
<ide> setYaml("value: !!java.net.URL [\"https://localhost:9000/\"]");
<ide>
<ide> assertThatExceptionOfType(ConstructorException.class)
<del> .isThrownBy(() -> this.processor.process((properties, map) -> {}))
<del> .withMessageContaining("Unsupported type encountered in YAML document: java.net.URL");
<add> .isThrownBy(() -> this.processor.process((properties, map) -> {}))
<add> .withMessageContaining("Unsupported type encountered in YAML document: java.net.URL");
<ide> }
<ide>
<ide> private void setYaml(String yaml) {
| 2
|
Text
|
Text
|
add personal pronoun for danbev
|
e0ae50f6366f5d919dcb71bddc1944c296dcd08f
|
<ide><path>README.md
<ide> For more information about the governance of the Node.js project, see
<ide> * [cjihrig](https://github.com/cjihrig) -
<ide> **Colin Ihrig** <cjihrig@gmail.com> (he/him)
<ide> * [danbev](https://github.com/danbev) -
<del>**Daniel Bevenius** <daniel.bevenius@gmail.com>
<add>**Daniel Bevenius** <daniel.bevenius@gmail.com> (he/him)
<ide> * [fhinkel](https://github.com/fhinkel) -
<ide> **Franziska Hinkelmann** <franziska.hinkelmann@gmail.com> (she/her)
<ide> * [Fishrock123](https://github.com/Fishrock123) -
<ide> For more information about the governance of the Node.js project, see
<ide> * [codebytere](https://github.com/codebytere) -
<ide> **Shelley Vohr** <codebytere@gmail.com> (she/her)
<ide> * [danbev](https://github.com/danbev) -
<del>**Daniel Bevenius** <daniel.bevenius@gmail.com>
<add>**Daniel Bevenius** <daniel.bevenius@gmail.com> (he/him)
<ide> * [DavidCai1993](https://github.com/DavidCai1993) -
<ide> **David Cai** <davidcai1993@yahoo.com> (he/him)
<ide> * [davisjam](https://github.com/davisjam) -
| 1
|
PHP
|
PHP
|
apply fixes from styleci
|
3cca78e9c1e26b694eb27f3d3ff522f2d6de1d98
|
<ide><path>src/Illuminate/Auth/AuthManager.php
<ide>
<ide> use Closure;
<ide> use Illuminate\Contracts\Auth\Factory as FactoryContract;
<del>use Illuminate\Support\Str;
<ide> use InvalidArgumentException;
<del>use LogicException;
<ide>
<ide> class AuthManager implements FactoryContract
<ide> {
<ide><path>tests/Auth/AuthTokenGuardTest.php
<ide>
<ide> namespace Illuminate\Tests\Auth;
<ide>
<del>use Illuminate\Auth\AuthManager;
<ide> use Illuminate\Auth\TokenGuard;
<del>use Illuminate\Container\Container;
<ide> use Illuminate\Contracts\Auth\UserProvider;
<ide> use Illuminate\Http\Request;
<del>use LogicException;
<ide> use Mockery as m;
<ide> use PHPUnit\Framework\TestCase;
<ide>
| 2
|
Go
|
Go
|
add unit tests for comparekernelversion
|
c42a4179fc6954a2363b181969978641553955c4
|
<ide><path>utils_test.go
<ide> func assertIndexGet(t *testing.T, index *TruncIndex, input, expectedResult strin
<ide> t.Fatalf("Getting '%s' returned '%s' instead of '%s'", input, result, expectedResult)
<ide> }
<ide> }
<add>
<add>func assertKernelVersion(t *testing.T, a, b *KernelVersionInfo, result int) {
<add> if r := CompareKernelVersion(a, b); r != result {
<add> t.Fatalf("Unepected kernel version comparaison result. Found %d, expected %d", r, result)
<add> }
<add>}
<add>
<add>func TestCompareKernelVersion(t *testing.T) {
<add> assertKernelVersion(t,
<add> &KernelVersionInfo{Kernel: 3, Major: 8, Minor: 0, Specific: 0},
<add> &KernelVersionInfo{Kernel: 3, Major: 8, Minor: 0, Specific: 0},
<add> 0)
<add> assertKernelVersion(t,
<add> &KernelVersionInfo{Kernel: 2, Major: 6, Minor: 0, Specific: 0},
<add> &KernelVersionInfo{Kernel: 3, Major: 8, Minor: 0, Specific: 0},
<add> -1)
<add> assertKernelVersion(t,
<add> &KernelVersionInfo{Kernel: 3, Major: 8, Minor: 0, Specific: 0},
<add> &KernelVersionInfo{Kernel: 2, Major: 6, Minor: 0, Specific: 0},
<add> 1)
<add> assertKernelVersion(t,
<add> &KernelVersionInfo{Kernel: 3, Major: 8, Minor: 0, Specific: 0},
<add> &KernelVersionInfo{Kernel: 3, Major: 8, Minor: 0, Specific: 16},
<add> -1)
<add> assertKernelVersion(t,
<add> &KernelVersionInfo{Kernel: 3, Major: 8, Minor: 5, Specific: 0},
<add> &KernelVersionInfo{Kernel: 3, Major: 8, Minor: 0, Specific: 0},
<add> 1)
<add> assertKernelVersion(t,
<add> &KernelVersionInfo{Kernel: 3, Major: 0, Minor: 20, Specific: 25},
<add> &KernelVersionInfo{Kernel: 3, Major: 8, Minor: 0, Specific: 0},
<add> -1)
<add>}
| 1
|
Javascript
|
Javascript
|
fix config to prefer .web.* exts
|
644a1ef187dada46cf411141b27813c1cb0219e2
|
<ide><path>examples/with-react-native-web/next.config.js
<ide> module.exports = {
<del> webpack: (config, { defaultLoaders }) => {
<add> webpack: config => {
<ide> config.resolve.alias = {
<ide> ...(config.resolve.alias || {}),
<ide> // Transform all direct `react-native` imports to `react-native-web`
<ide> 'react-native$': 'react-native-web',
<ide> }
<del> config.resolve.extensions.push('.web.js', '.web.ts', '.web.tsx')
<add> config.resolve.extensions = [
<add> '.web.js',
<add> '.web.ts',
<add> '.web.tsx',
<add> ...config.resolve.extensions,
<add> ]
<ide> return config
<ide> },
<ide> }
| 1
|
Javascript
|
Javascript
|
enable module.exports mocking in react-test.js
|
204796868d377acbcbbb1e2de4698b8827dc6b83
|
<ide><path>src/test/mock-modules.js
<ide> * @providesModule mock-modules
<ide> */
<ide>
<add>var mocks = require("mocks");
<add>var exportsRegistry = {};
<add>var hasOwn = exportsRegistry.hasOwnProperty;
<add>var explicitMockMap = {};
<add>
<add>function getMock(exports) {
<add> try {
<add> return mocks.generateFromMetadata(mocks.getMetadata(exports));
<add> } catch (err) {
<add> console.warn(err);
<add> return exports;
<add> }
<add>}
<add>
<add>// This function should be called at the bottom of any module that might
<add>// need to be mocked, after the final value of module.exports is known.
<ide> exports.register = function(id, module) {
<del> // TODO
<add> exportsRegistry[id] = {
<add> module: module,
<add> actual: module.exports,
<add> mocked: null // Filled in lazily later.
<add> };
<add>
<add> // If doMock or doNotMock was called earlier, before the module was
<add> // registered, then the choice should have been recorded in
<add> // explicitMockMap. Now that the module is registered, we can finally
<add> // fulfill the request.
<add> if (hasOwn.call(explicitMockMap, id)) {
<add> if (explicitMockMap[id]) {
<add> doMock(id);
<add> } else {
<add> doNotMock(id);
<add> }
<add> }
<add>
<add> return exports;
<ide> };
<ide>
<add>function resetEntry(id) {
<add> if (hasOwn.call(exportsRegistry, id)) {
<add> delete exportsRegistry[id].module.exports;
<add> delete exportsRegistry[id];
<add> }
<add>}
<add>
<ide> exports.dumpCache = function() {
<del> require("mocks").clear();
<del> return exports;
<del>};
<add> require("mocks").clear();
<ide>
<del>exports.dontMock = function() {
<del> return exports;
<del>};
<add> // Deleting module.exports will cause the module to be lazily
<add> // reevaluated the next time it is required.
<add> for (var id in exportsRegistry) {
<add> resetEntry(id);
<add> }
<ide>
<del>exports.mock = function() {
<del> return exports;
<add> return exports;
<ide> };
<ide>
<add>// Call this function to ensure that require(id) returns the actual
<add>// exports object created by the module.
<add>function doNotMock(id) {
<add> explicitMockMap[id] = false;
<add>
<add> var entry = exportsRegistry[id];
<add> if (entry && entry.module && entry.actual) {
<add> entry.module.exports = entry.actual;
<add> }
<add>
<add> return exports;
<add>}
<add>
<add>// Call this function to ensure that require(id) returns a mock exports
<add>// object based on the actual exports object created by the module.
<add>function doMock(id) {
<add> explicitMockMap[id] = true;
<add>
<add> var entry = exportsRegistry[id];
<add> if (entry && entry.module && entry.actual) {
<add> // Because mocking can be expensive, create the mock exports object on
<add> // demand, the first time doMock is called.
<add> entry.mocked || (entry.mocked = getMock(entry.actual));
<add> entry.module.exports = entry.mocked;
<add> }
<add>
<add> return exports;
<add>}
<add>
<ide> var global = Function("return this")();
<ide> require('test/mock-timers').installMockTimers(global);
<add>
<add>// Exported names are different for backwards compatibility.
<add>exports.dontMock = doNotMock;
<add>exports.mock = doMock;
| 1
|
Python
|
Python
|
fix maximum_sctype for integer data-types
|
1ea3f17a8dd077b82b5a1dbf59a8ebdedc40b4f0
|
<ide><path>numpy/core/numerictypes.py
<ide> def _set_array_types():
<ide> _add_array_type('complex', 2*bits)
<ide> _gi = dtype('p')
<ide> if _gi.type not in sctypes['int']:
<del> sctypes['int'].append(_gi.type)
<del> sctypes['uint'].append(dtype('P').type)
<add> indx = 0
<add> sz = _gi.itemsize
<add> _lst = sctypes['int']
<add> while (indx < len(_lst) and sz >= _lst[indx](0).itemsize):
<add> indx += 1
<add> sctypes['int'].insert(indx, _gi.type)
<add> sctypes['uint'].insert(indx, dtype('P').type)
<ide> _set_array_types()
<ide>
<ide>
| 1
|
Java
|
Java
|
use int for maxparts instead of long
|
fd9678833fc2384c7f61cdb0a734a6d0dddd9628
|
<ide><path>spring-web/src/main/java/org/springframework/http/codec/multipart/SynchronossPartHttpMessageReader.java
<ide> public class SynchronossPartHttpMessageReader extends LoggingCodecSupport implem
<ide>
<ide> private long maxDiskUsagePerPart = -1;
<ide>
<del> private long maxParts = -1;
<add> private int maxParts = -1;
<ide>
<ide>
<ide> /**
<ide> public long getMaxDiskUsagePerPart() {
<ide> * Specify the maximum number of parts allowed in a given multipart request.
<ide> * @since 5.1.11
<ide> */
<del> public void setMaxParts(long maxParts) {
<add> public void setMaxParts(int maxParts) {
<ide> this.maxParts = maxParts;
<ide> }
<ide>
<ide> /**
<ide> * Return the {@link #setMaxParts configured} limit on the number of parts.
<ide> * @since 5.1.11
<ide> */
<del> public long getMaxParts() {
<add> public int getMaxParts() {
<ide> return this.maxParts;
<ide> }
<ide>
| 1
|
Javascript
|
Javascript
|
use es6 import for safeareaview component
|
a69bd9dadfd86afba4cbd88569d86abad9cd3071
|
<ide><path>Libraries/Components/SafeAreaView/SafeAreaView.js
<ide> * @format
<ide> */
<ide>
<del>const Platform = require('../../Utilities/Platform');
<del>const React = require('react');
<del>const View = require('../View/View');
<add>import Platform from '../../Utilities/Platform';
<add>import * as React from 'react';
<add>import View from '../View/View';
<ide>
<ide> import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes';
<ide> import type {ViewProps} from '../View/ViewPropTypes';
| 1
|
Javascript
|
Javascript
|
move each proxies into a weak map
|
00a74888f7776f3808534d6a2a3af5dc9c6d5b98
|
<ide><path>packages/ember-metal/lib/chains.js
<ide> import { get } from './property_get';
<ide> import { descriptorFor, meta as metaFor, peekMeta } from './meta';
<ide> import { watchKey, unwatchKey } from './watch_key';
<ide> import { cacheFor } from './computed';
<add>import { eachProxyFor } from './each_proxy';
<ide>
<ide> const FIRST_KEY = /^([^\.]+)/;
<ide>
<ide> function lazyGet(obj, key) {
<ide> }
<ide>
<ide> // Use `get` if the return value is an EachProxy or an uncacheable value.
<del> if (isVolatile(obj, key, meta)) {
<add> if (key === '@each') {
<add> return eachProxyFor(obj);
<add> } else if (isVolatile(obj, key, meta)) {
<ide> return get(obj, key);
<ide> // Otherwise attempt to get the cached value of the computed property
<ide> } else {
<ide><path>packages/ember-metal/lib/each_proxy.js
<add>import { assert } from 'ember-debug';
<add>import { get } from './property_get';
<add>import { notifyPropertyChange } from './property_events';
<add>import { addObserver, removeObserver } from './observer';
<add>import { meta, peekMeta } from './meta';
<add>import { objectAt } from './array';
<add>
<add>const EACH_PROXIES = new WeakMap();
<add>
<add>export function eachProxyFor(array) {
<add> let eachProxy = EACH_PROXIES.get(array);
<add> if (eachProxy === undefined) {
<add> eachProxy = new EachProxy(array);
<add> EACH_PROXIES.set(array, eachProxy);
<add> }
<add> return eachProxy;
<add>}
<add>
<add>export function eachProxyArrayWillChange(array, idx, removedCnt, addedCnt) {
<add> let eachProxy = EACH_PROXIES.get(array);
<add> if (eachProxy !== undefined) {
<add> eachProxy.arrayWillChange(array, idx, removedCnt, addedCnt);
<add> }
<add>}
<add>
<add>export function eachProxyArrayDidChange(array, idx, removedCnt, addedCnt) {
<add> let eachProxy = EACH_PROXIES.get(array);
<add> if (eachProxy !== undefined) {
<add> eachProxy.arrayDidChange(array, idx, removedCnt, addedCnt);
<add> }
<add>}
<add>
<add>class EachProxy {
<add> constructor(content) {
<add> this._content = content;
<add> this._keys = undefined;
<add> meta(this);
<add> }
<add>
<add> // ..........................................................
<add> // ARRAY CHANGES
<add> // Invokes whenever the content array itself changes.
<add>
<add> arrayWillChange(content, idx, removedCnt, addedCnt) { // eslint-disable-line no-unused-vars
<add> let keys = this._keys;
<add> let lim = removedCnt > 0 ? idx + removedCnt : -1;
<add> for (let key in keys) {
<add> if (lim > 0) {
<add> removeObserverForContentKey(content, key, this, idx, lim);
<add> }
<add> }
<add> }
<add>
<add> arrayDidChange(content, idx, removedCnt, addedCnt) {
<add> let keys = this._keys;
<add> let lim = addedCnt > 0 ? idx + addedCnt : -1;
<add> let meta = peekMeta(this);
<add> for (let key in keys) {
<add> if (lim > 0) {
<add> addObserverForContentKey(content, key, this, idx, lim);
<add> }
<add> notifyPropertyChange(this, key, meta);
<add> }
<add> }
<add>
<add> // ..........................................................
<add> // LISTEN FOR NEW OBSERVERS AND OTHER EVENT LISTENERS
<add> // Start monitoring keys based on who is listening...
<add>
<add> willWatchProperty(property) {
<add> this.beginObservingContentKey(property);
<add> }
<add>
<add> didUnwatchProperty(property) {
<add> this.stopObservingContentKey(property);
<add> }
<add>
<add> // ..........................................................
<add> // CONTENT KEY OBSERVING
<add> // Actual watch keys on the source content.
<add>
<add> beginObservingContentKey(keyName) {
<add> let keys = this._keys;
<add> if (!keys) {
<add> keys = this._keys = Object.create(null);
<add> }
<add>
<add> if (!keys[keyName]) {
<add> keys[keyName] = 1;
<add> let content = this._content;
<add> let len = get(content, 'length');
<add>
<add> addObserverForContentKey(content, keyName, this, 0, len);
<add> } else {
<add> keys[keyName]++;
<add> }
<add> }
<add>
<add> stopObservingContentKey(keyName) {
<add> let keys = this._keys;
<add> if (keys && (keys[keyName] > 0) && (--keys[keyName] <= 0)) {
<add> let content = this._content;
<add> let len = get(content, 'length');
<add>
<add> removeObserverForContentKey(content, keyName, this, 0, len);
<add> }
<add> }
<add>
<add> contentKeyDidChange(obj, keyName) {
<add> notifyPropertyChange(this, keyName);
<add> }
<add>}
<add>
<add>function addObserverForContentKey(content, keyName, proxy, idx, loc) {
<add> while (--loc >= idx) {
<add> let item = objectAt(content, loc);
<add> if (item) {
<add> assert(`When using @each to observe the array \`${toString(content)}\`, the array must return an object`, typeof item === 'object');
<add> addObserver(item, keyName, proxy, 'contentKeyDidChange');
<add> }
<add> }
<add>}
<add>
<add>function removeObserverForContentKey(content, keyName, proxy, idx, loc) {
<add> while (--loc >= idx) {
<add> let item = objectAt(content, loc);
<add> if (item) {
<add> removeObserver(item, keyName, proxy, 'contentKeyDidChange');
<add> }
<add> }
<add>}
<ide><path>packages/ember-metal/lib/index.js
<ide> export {
<ide> trySet
<ide> } from './property_set';
<ide> export { objectAt } from './array';
<add>export {
<add> eachProxyFor,
<add> eachProxyArrayWillChange,
<add> eachProxyArrayDidChange
<add>} from './each_proxy';
<ide> export {
<ide> addListener,
<ide> hasListeners,
<ide><path>packages/ember-runtime/lib/mixins/array.js
<ide> import {
<ide> removeListener,
<ide> sendEvent,
<ide> hasListeners,
<del> addObserver,
<del> removeObserver,
<del> meta,
<ide> peekMeta,
<add> eachProxyFor,
<add> eachProxyArrayWillChange,
<add> eachProxyArrayDidChange,
<ide> beginPropertyChanges,
<ide> endPropertyChanges
<ide> } from 'ember-metal';
<del>import { assert } from 'ember-debug';
<add>import { assert, deprecate } from 'ember-debug';
<ide> import Enumerable from './enumerable';
<ide> import compare from '../compare';
<ide> import { ENV } from 'ember-environment';
<ide> export function arrayContentWillChange(array, startIdx, removeAmt, addAmt) {
<ide> }
<ide> }
<ide>
<del> if (array.__each) {
<del> array.__each.arrayWillChange(array, startIdx, removeAmt, addAmt);
<del> }
<add> eachProxyArrayWillChange(array, startIdx, removeAmt, addAmt);
<ide>
<ide> sendEvent(array, '@array:before', [array, startIdx, removeAmt, addAmt]);
<ide>
<ide> export function arrayContentDidChange(array, startIdx, removeAmt, addAmt) {
<ide>
<ide> notifyPropertyChange(array, '[]');
<ide>
<del> if (array.__each) {
<del> array.__each.arrayDidChange(array, startIdx, removeAmt, addAmt);
<del> }
<add> eachProxyArrayDidChange(array, startIdx, removeAmt, addAmt);
<ide>
<ide> sendEvent(array, '@array:change', [array, startIdx, removeAmt, addAmt]);
<ide>
<ide> const ArrayMixin = Mixin.create(Enumerable, {
<ide> @public
<ide> */
<ide> '@each': computed(function() {
<del> // TODO use Symbol or add to meta
<del> if (!this.__each) {
<del> this.__each = new EachProxy(this);
<del> }
<del>
<del> return this.__each;
<del> }).volatile().readOnly()
<del>});
<del>
<del>/**
<del> This is the object instance returned when you get the `@each` property on an
<del> array. It uses the unknownProperty handler to automatically create
<del> EachArray instances for property names.
<del> @class EachProxy
<del> @private
<del>*/
<del>function EachProxy(content) {
<del> this._content = content;
<del> this._keys = undefined;
<del> meta(this);
<del>}
<del>
<del>EachProxy.prototype = {
<del> __defineNonEnumerable(property) {
<del> this[property.name] = property.descriptor.value;
<del> },
<del>
<del> // ..........................................................
<del> // ARRAY CHANGES
<del> // Invokes whenever the content array itself changes.
<del>
<del> arrayWillChange(content, idx, removedCnt, addedCnt) { // eslint-disable-line no-unused-vars
<del> let keys = this._keys;
<del> let lim = removedCnt > 0 ? idx + removedCnt : -1;
<del> for (let key in keys) {
<del> if (lim > 0) {
<del> removeObserverForContentKey(content, key, this, idx, lim);
<add> deprecate(
<add> `Getting the '@each' property on object ${toString(this)} is deprecated`,
<add> false,
<add> {
<add> id: 'ember-metal.getting-each',
<add> until: '3.5.0',
<add> url: 'https://emberjs.com/deprecations/v3.x#toc_getting-the-each-property'
<ide> }
<del> }
<del> },
<del>
<del> arrayDidChange(content, idx, removedCnt, addedCnt) {
<del> let keys = this._keys;
<del> let lim = addedCnt > 0 ? idx + addedCnt : -1;
<del> let meta = peekMeta(this);
<del> for (let key in keys) {
<del> if (lim > 0) {
<del> addObserverForContentKey(content, key, this, idx, lim);
<del> }
<del> notifyPropertyChange(this, key, meta);
<del> }
<del> },
<del>
<del> // ..........................................................
<del> // LISTEN FOR NEW OBSERVERS AND OTHER EVENT LISTENERS
<del> // Start monitoring keys based on who is listening...
<del>
<del> willWatchProperty(property) {
<del> this.beginObservingContentKey(property);
<del> },
<del>
<del> didUnwatchProperty(property) {
<del> this.stopObservingContentKey(property);
<del> },
<add> );
<ide>
<del> // ..........................................................
<del> // CONTENT KEY OBSERVING
<del> // Actual watch keys on the source content.
<del>
<del> beginObservingContentKey(keyName) {
<del> let keys = this._keys;
<del> if (!keys) {
<del> keys = this._keys = Object.create(null);
<del> }
<del>
<del> if (!keys[keyName]) {
<del> keys[keyName] = 1;
<del> let content = this._content;
<del> let len = get(content, 'length');
<del>
<del> addObserverForContentKey(content, keyName, this, 0, len);
<del> } else {
<del> keys[keyName]++;
<del> }
<del> },
<del>
<del> stopObservingContentKey(keyName) {
<del> let keys = this._keys;
<del> if (keys && (keys[keyName] > 0) && (--keys[keyName] <= 0)) {
<del> let content = this._content;
<del> let len = get(content, 'length');
<del>
<del> removeObserverForContentKey(content, keyName, this, 0, len);
<del> }
<del> },
<del>
<del> contentKeyDidChange(obj, keyName) {
<del> notifyPropertyChange(this, keyName);
<del> }
<del>};
<del>
<del>function addObserverForContentKey(content, keyName, proxy, idx, loc) {
<del> while (--loc >= idx) {
<del> let item = objectAt(content, loc);
<del> if (item) {
<del> assert(`When using @each to observe the array \`${toString(content)}\`, the array must return an object`, typeof item === 'object');
<del> addObserver(item, keyName, proxy, 'contentKeyDidChange');
<del> }
<del> }
<del>}
<del>
<del>function removeObserverForContentKey(content, keyName, proxy, idx, loc) {
<del> while (--loc >= idx) {
<del> let item = objectAt(content, loc);
<del> if (item) {
<del> removeObserver(item, keyName, proxy, 'contentKeyDidChange');
<del> }
<del> }
<del>}
<add> return eachProxyFor(this);
<add> }).readOnly()
<add>});
<ide>
<ide>
<ide> const OUT_OF_RANGE_EXCEPTION = 'Index out of range';
<ide><path>packages/ember-runtime/lib/system/core_object.js
<ide> function makeCtor() {
<ide> property === 'willWatchProperty' ||
<ide> property === 'didUnwatchProperty' ||
<ide> property === 'didAddListener' ||
<del> property === '__each' ||
<ide> property in target
<ide> ) {
<ide> return Reflect.get(target, property, receiver);
<ide><path>packages/ember-runtime/tests/mixins/array_test.js
<ide> QUnit.test('adding an object should notify (@each.isDone)', function(assert) {
<ide> assert.equal(called, 1, 'calls observer when object is pushed');
<ide> });
<ide>
<add>QUnit.test('getting @each is deprecated', function(assert) {
<add> assert.expect(1);
<add>
<add> expectDeprecation(() => {
<add> get(ary, '@each');
<add> }, /Getting the '@each' property on object .* is deprecated/);
<add>});
<add>
<ide> QUnit.test('@each is readOnly', function(assert) {
<ide> assert.expect(1);
<ide>
<ide> QUnit.test('modifying the array should also indicate the isDone prop itself has
<ide> // important because it tests the case where we don't have an isDone
<ide> // EachArray materialized but just want to know when the property has
<ide> // changed.
<del>
<del> let each = get(ary, '@each');
<add> let each;
<add> expectDeprecation(() => {
<add> each = get(ary, '@each');
<add> });
<ide> let count = 0;
<ide>
<ide> addObserver(each, 'isDone', () => count++);
| 6
|
PHP
|
PHP
|
use test job classes to fix seralization issue
|
71745f4f9d3e14f240a32ebffcddf379f807926e
|
<ide><path>tests/Bus/BusBatchTest.php
<ide> public function test_chain_can_be_added_to_batch()
<ide>
<ide> $batch = $this->createTestBatch($queue);
<ide>
<del> $chainHeadJob = new class implements ShouldQueue {
<del> use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, Batchable;
<del> };
<add> $chainHeadJob = new ChainHeadJob();
<ide>
<del> $secondJob = new class implements ShouldQueue {
<del> use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, Batchable;
<del> };
<add> $secondJob = new SecondTestJob();
<ide>
<del> $thirdJob = new class implements ShouldQueue {
<del> use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, Batchable;
<del> };
<add> $thirdJob = new ThirdTestJob();
<ide>
<ide> $queue->shouldReceive('connection')->once()
<ide> ->with('test-connection')
<ide> protected function schema()
<ide> return $this->connection()->getSchemaBuilder();
<ide> }
<ide> }
<add>
<add>class ChainHeadJob implements ShouldQueue
<add>{
<add> use Dispatchable, Queueable, Batchable;
<add>}
<add>
<add>class SecondTestJob implements ShouldQueue
<add>{
<add> use Dispatchable, Queueable, Batchable;
<add>}
<add>
<add>class ThirdTestJob implements ShouldQueue
<add>{
<add> use Dispatchable, Queueable, Batchable;
<add>}
| 1
|
PHP
|
PHP
|
add check for migration table in reset command
|
4fd9aafa15c85a36eb4e61b873ef1188d11a769d
|
<ide><path>src/Illuminate/Database/Console/Migrations/ResetCommand.php
<ide> public function fire()
<ide>
<ide> $this->migrator->setConnection($this->input->getOption('database'));
<ide>
<add> if ( ! $this->migrator->repositoryExists())
<add> {
<add> $this->output->writeln('<comment>Migration table not found.</comment>');
<add>
<add> return;
<add> }
<add>
<ide> $pretend = $this->input->getOption('pretend');
<ide>
<ide> $this->migrator->reset($pretend);
<ide><path>tests/Database/DatabaseMigrationResetCommandTest.php
<ide> public function testResetCommandCallsMigratorWithProperArguments()
<ide> $command = new ResetCommand($migrator = m::mock('Illuminate\Database\Migrations\Migrator'));
<ide> $command->setLaravel(new AppDatabaseMigrationStub());
<ide> $migrator->shouldReceive('setConnection')->once()->with(null);
<add> $migrator->shouldReceive('repositoryExists')->once()->andReturn(true);
<ide> $migrator->shouldReceive('reset')->once()->with(false);
<ide> $migrator->shouldReceive('getNotes')->andReturn([]);
<ide>
<ide> public function testResetCommandCanBePretended()
<ide> $command = new ResetCommand($migrator = m::mock('Illuminate\Database\Migrations\Migrator'));
<ide> $command->setLaravel(new AppDatabaseMigrationStub());
<ide> $migrator->shouldReceive('setConnection')->once()->with('foo');
<add> $migrator->shouldReceive('repositoryExists')->once()->andReturn(true);
<ide> $migrator->shouldReceive('reset')->once()->with(true);
<ide> $migrator->shouldReceive('getNotes')->andReturn([]);
<ide>
| 2
|
Javascript
|
Javascript
|
increase strictness for test-trace-event
|
773cdc31ef3e17327d1eb0a3b92828e25457f015
|
<ide><path>test/parallel/test-trace-event.js
<ide> proc_no_categories.once('exit', common.mustCall(() => {
<ide>
<ide> proc.once('exit', common.mustCall(() => {
<ide> assert(common.fileExists(FILE_NAME));
<del> fs.readFile(FILE_NAME, (err, data) => {
<add> fs.readFile(FILE_NAME, common.mustCall((err, data) => {
<ide> const traces = JSON.parse(data.toString()).traceEvents;
<ide> assert(traces.length > 0);
<ide> // Values that should be present on all runs to approximate correctness.
<del> assert(traces.some((trace) => { return trace.pid === proc.pid; }));
<del> assert(traces.some((trace) => { return trace.cat === 'v8'; }));
<ide> assert(traces.some((trace) => {
<del> return trace.name === 'V8.ScriptCompiler';
<add> if (trace.pid !== proc.pid)
<add> return false;
<add> if (trace.cat !== 'v8')
<add> return false;
<add> if (trace.name !== 'V8.ScriptCompiler')
<add> return false;
<add> return true;
<ide> }));
<del> });
<add> }));
<ide> }));
<ide> }));
| 1
|
Python
|
Python
|
correct complex data xml parsing
|
2966c343520147c4027ea48f3fea47913da3ebdb
|
<ide><path>djangorestframework/parsers.py
<ide> def parse(self, stream):
<ide> `data` will simply be a string representing the body of the request.
<ide> `files` will always be `None`.
<ide> """
<del> data = {}
<ide> tree = ET.parse(stream)
<ide> data = self._xml_convert(tree.getroot())
<del>
<add>
<ide> return (data, None)
<del>
<add>
<ide> def _xml_convert(self, element):
<ide> """
<ide> convert the xml `element` into the corresponding python object
<ide> def _xml_convert(self, element):
<ide> if len(children) == 0:
<ide> return self._type_convert(element.text)
<ide> else:
<del> if element.tag == "resource":
<add> # if the fist child tag is list-item means all children are list-item
<add> if children[0].tag == "list-item":
<ide> data = []
<ide> for child in children:
<del> data.append(self._xml_convert(child))
<add> data.append(self._xml_convert(child))
<ide> else:
<del> if children[0].tag == "resource":
<del> data = []
<del> for child in children:
<del> data.append(self._xml_convert(child))
<del> else:
<del> data = {}
<del> for child in children:
<del> data[child.tag] = self._xml_convert(child)
<add> data = {}
<add> for child in children:
<add> data[child.tag] = self._xml_convert(child)
<ide>
<ide> return data
<ide>
| 1
|
Text
|
Text
|
remove extraneous word "both"
|
ae7a2b0dfadc8f2ac5b648ad4391101bab7baf51
|
<ide><path>docs/api-guide/parsers.md
<ide> You will typically want to use both `FormParser` and `MultiPartParser` together
<ide>
<ide> ## MultiPartParser
<ide>
<del>Parses multipart HTML form content, which supports file uploads. Both `request.data` will be populated with a `QueryDict`.
<add>Parses multipart HTML form content, which supports file uploads. `request.data` and `request.FILES` will be populated with a `QueryDict` and `MultiValueDict` respectively.
<ide>
<ide> You will typically want to use both `FormParser` and `MultiPartParser` together in order to fully support HTML form data.
<ide>
| 1
|
Javascript
|
Javascript
|
replace fixturesdir with fixtures module
|
c11a30dc5159c52aaeff2bcec39f5d5181f8bba2
|
<ide><path>test/parallel/test-tls-ecdh.js
<ide>
<ide> 'use strict';
<ide> const common = require('../common');
<add>const fixtures = require('../common/fixtures');
<ide>
<ide> if (!common.hasCrypto)
<ide> common.skip('missing crypto');
<ide> const assert = require('assert');
<ide> const tls = require('tls');
<ide>
<ide> const exec = require('child_process').exec;
<del>const fs = require('fs');
<ide>
<ide> const options = {
<del> key: fs.readFileSync(`${common.fixturesDir}/keys/agent2-key.pem`),
<del> cert: fs.readFileSync(`${common.fixturesDir}/keys/agent2-cert.pem`),
<add> key: fixtures.readKey('agent2-key.pem'),
<add> cert: fixtures.readKey('agent2-cert.pem'),
<ide> ciphers: '-ALL:ECDHE-RSA-AES128-SHA256',
<ide> ecdhCurve: 'prime256v1'
<ide> };
| 1
|
Text
|
Text
|
update amp docs
|
4801dcdd15132f485f2701101e4c2ee77b8666c3
|
<ide><path>docs/advanced-features/amp-support/introduction.md
<ide> You can read more about AMP in the official [amp.dev](https://amp.dev/) site.
<ide>
<ide> To enable AMP support for a page, and to learn more about the different AMP configs, read the [API documentation for `next/amp`](/docs/api-reference/next/amp.md).
<ide>
<add>## Caveats
<add>
<add>- Only CSS-in-JS is supported. [CSS Modules](/docs/basic-features/built-in-css-support.md) aren't supported by AMP pages at the moment. You can [contribute CSS Modules support to Next.js](https://github.com/zeit/next.js/issues/10549).
<add>
<ide> ## Related
<ide>
<ide> For more information on what to do next, we recommend the following sections:
| 1
|
Ruby
|
Ruby
|
fix the output a bit
|
3e06ec89447510340dfd27179c5eb2bd613e9035
|
<ide><path>railties/lib/rails/generators/rails/app/templates/config/application.rb
<ide> class Application < Rails::Application
<ide> # Configure sensitive parameters which will be filtered from the log file.
<ide> config.filter_parameters += [:password]
<ide>
<del> <% unless options.skip_sprockets? %>
<add><% unless options.skip_sprockets? -%>
<ide> # Enable the asset pipeline
<ide> config.assets.enabled = true
<del> <% end %>
<add><% end -%>
<ide> end
<ide> end
| 1
|
PHP
|
PHP
|
tweak a few things
|
124d0451d2c0fdf22e3e18b2338afbf867317457
|
<ide><path>src/Illuminate/Database/Eloquent/Builder.php
<ide> public function getModels($columns = array('*'))
<ide> {
<ide> $connection = $this->model->getConnectionName();
<ide>
<del> // We will first get the raw results from the query builder. We'll then
<add> // First, We will get the raw results from the query builder. We'll then
<ide> // transform the raw results into Eloquent models, while also setting
<ide> // the proper database connection on every Eloquent model instance.
<ide> return $this->query->get($columns)->map(function($result) use ($connection)
| 1
|
Text
|
Text
|
fix changelog typo [ci skip]
|
9298d60af08767d427d28f1b0dbf76b2d54418b4
|
<ide><path>activerecord/CHANGELOG.md
<ide> ## Rails 4.0.0 (unreleased) ##
<ide>
<ide> * Allow ActiveRecord::Relation#pluck to accept multiple columns. Returns an
<del> array of arrays containing the type casted values:
<add> array of arrays containing the typecasted values:
<ide>
<ide> Person.pluck(:id, :name)
<ide> # SELECT people.id, people.name FROM people
| 1
|
Ruby
|
Ruby
|
improve display in `brew info`
|
a232ac8b1e451aa1345206f8f5043f183b1e6988
|
<ide><path>Library/Homebrew/requirement.rb
<ide> def inspect
<ide> end
<ide>
<ide> def display_s
<del> name
<add> name.capitalize
<ide> end
<ide>
<ide> def mktemp(&block)
<ide><path>Library/Homebrew/requirements/java_requirement.rb
<ide> def display_s
<ide> else
<ide> ">="
<ide> end
<del> "#{name} #{op} #{version_without_plus}"
<add> "#{name.capitalize} #{op} #{version_without_plus}"
<ide> else
<del> name
<add> name.capitalize
<ide> end
<ide> end
<ide>
<ide><path>Library/Homebrew/requirements/macos_requirement.rb
<ide> def inspect
<ide> end
<ide>
<ide> def display_s
<del> return "macOS is required" unless version_specified?
<add> return "macOS" unless version_specified?
<ide>
<ide> "macOS #{@comparator} #{@version}"
<ide> end
<ide><path>Library/Homebrew/requirements/osxfuse_requirement.rb
<ide> #
<ide> # @api private
<ide> class OsxfuseRequirement < Requirement
<add> extend T::Sig
<ide> cask "osxfuse"
<ide> fatal true
<add>
<add> sig { returns(String) }
<add> def display_s
<add> "FUSE"
<add> end
<ide> end
<ide>
<ide> require "extend/os/requirements/osxfuse_requirement"
<ide><path>Library/Homebrew/requirements/xcode_requirement.rb
<ide> def message
<ide> def inspect
<ide> "#<#{self.class.name}: #{tags.inspect} version=#{@version.inspect}>"
<ide> end
<add>
<add> def display_s
<add> return name.capitalize unless @version
<add>
<add> "#{name.capitalize} >= #{@version}"
<add> end
<ide> end
<ide>
<ide> require "extend/os/requirements/xcode_requirement"
<ide><path>Library/Homebrew/test/java_requirement_spec.rb
<ide>
<ide> describe "#display_s" do
<ide> context "without specific version" do
<del> its(:display_s) { is_expected.to eq("java") }
<add> its(:display_s) { is_expected.to eq("Java") }
<ide> end
<ide>
<ide> context "with version 1.8" do
<ide> subject { described_class.new(%w[1.8]) }
<ide>
<del> its(:display_s) { is_expected.to eq("java = 1.8") }
<add> its(:display_s) { is_expected.to eq("Java = 1.8") }
<ide> end
<ide>
<ide> context "with version 1.8+" do
<ide> subject { described_class.new(%w[1.8+]) }
<ide>
<del> its(:display_s) { is_expected.to eq("java >= 1.8") }
<add> its(:display_s) { is_expected.to eq("Java >= 1.8") }
<ide> end
<ide> end
<ide>
<ide><path>Library/Homebrew/test/requirements/java_requirement_spec.rb
<ide> describe "initialize" do
<ide> it "parses '1.8' tag correctly" do
<ide> req = described_class.new(["1.8"])
<del> expect(req.display_s).to eq("java = 1.8")
<add> expect(req.display_s).to eq("Java = 1.8")
<ide> end
<ide>
<ide> it "parses '9' tag correctly" do
<ide> req = described_class.new(["9"])
<del> expect(req.display_s).to eq("java = 9")
<add> expect(req.display_s).to eq("Java = 9")
<ide> end
<ide>
<ide> it "parses '9+' tag correctly" do
<ide> req = described_class.new(["9+"])
<del> expect(req.display_s).to eq("java >= 9")
<add> expect(req.display_s).to eq("Java >= 9")
<ide> end
<ide>
<ide> it "parses '11' tag correctly" do
<ide> req = described_class.new(["11"])
<del> expect(req.display_s).to eq("java = 11")
<add> expect(req.display_s).to eq("Java = 11")
<ide> end
<ide>
<ide> it "parses bogus tag correctly" do
<ide> req = described_class.new(["bogus1.8"])
<del> expect(req.display_s).to eq("java")
<add> expect(req.display_s).to eq("Java")
<ide> end
<ide> end
<ide> end
| 7
|
Java
|
Java
|
implement scheduler method with duetime
|
d2a3f29496d22df52ba4bf66aa5c408cf286d4bc
|
<ide><path>rxjava-core/src/main/java/rx/Scheduler.java
<ide> */
<ide> package rx;
<ide>
<add>import java.util.Date;
<ide> import java.util.concurrent.TimeUnit;
<ide>
<ide> import rx.subscriptions.Subscriptions;
<ide> * <ol>
<ide> * <li>Java doesn't support extension methods and there are many overload methods needing default implementations.</li>
<ide> * <li>Virtual extension methods aren't available until Java8 which RxJava will not set as a minimum target for a long time.</li>
<del> * <li>If only an interface were used Scheduler implementations would then need to extend from an AbstractScheduler pair that gives all of the functionality unless they intend on copy/pasting the functionality.</li>
<add> * <li>If only an interface were used Scheduler implementations would then need to extend from an AbstractScheduler pair that gives all of the functionality unless they intend on copy/pasting the
<add> * functionality.</li>
<ide> * <li>Without virtual extension methods even additive changes are breaking and thus severely impede library maintenance.</li>
<ide> * </ol>
<ide> */
<ide> public abstract class Scheduler {
<ide> */
<ide> public abstract <T> Subscription schedule(T state, Func2<Scheduler, T, Subscription> action, long delayTime, TimeUnit unit);
<ide>
<add> /**
<add> * Schedules a cancelable action to be executed at dueTime.
<add> *
<add> * @param state
<add> * State to pass into the action.
<add> * @param action
<add> * Action to schedule.
<add> * @param dueTime
<add> * Time the action is to be executed. If in the past it will be executed immediately.
<add> * @return a subscription to be able to unsubscribe from action.
<add> */
<add> public <T> Subscription schedule(T state, Func2<Scheduler, T, Subscription> action, Date dueTime) {
<add> long scheduledTime = dueTime.getTime();
<add> long timeInFuture = scheduledTime - now();
<add> if (timeInFuture <= 0) {
<add> return schedule(state, action);
<add> } else {
<add> return schedule(state, action, timeInFuture, TimeUnit.MILLISECONDS);
<add> }
<add> }
<add>
<ide> /**
<ide> * Schedules a cancelable action to be executed.
<ide> *
<ide><path>rxjava-core/src/test/java/rx/concurrency/TestSchedulers.java
<ide> import static org.junit.Assert.*;
<ide> import static org.mockito.Mockito.*;
<ide>
<add>import java.util.Date;
<ide> import java.util.concurrent.CountDownLatch;
<ide> import java.util.concurrent.TimeUnit;
<ide> import java.util.concurrent.atomic.AtomicBoolean;
<ide> public void onNext(Integer args) {
<ide> assertTrue(completed.get());
<ide> }
<ide>
<add> @Test
<add> public void testSchedulingWithDueTime() throws InterruptedException {
<add>
<add> final CountDownLatch latch = new CountDownLatch(5);
<add> final AtomicInteger counter = new AtomicInteger();
<add>
<add> long start = System.currentTimeMillis();
<add>
<add> Schedulers.threadPoolForComputation().schedule(null, new Func2<Scheduler, String, Subscription>() {
<add>
<add> @Override
<add> public Subscription call(Scheduler scheduler, String state) {
<add> System.out.println("doing work");
<add> latch.countDown();
<add> counter.incrementAndGet();
<add> if (latch.getCount() == 0) {
<add> return Subscriptions.empty();
<add> } else {
<add> return scheduler.schedule(state, this, new Date(System.currentTimeMillis() + 50));
<add> }
<add> }
<add> }, new Date(System.currentTimeMillis() + 100));
<add>
<add> if (!latch.await(3000, TimeUnit.MILLISECONDS)) {
<add> fail("didn't execute ... timed out");
<add> }
<add>
<add> long end = System.currentTimeMillis();
<add>
<add> assertEquals(5, counter.get());
<add> if ((end - start) < 250) {
<add> fail("it should have taken over 250ms since each step was scheduled 50ms in the future");
<add> }
<add> }
<add>
<ide> }
| 2
|
PHP
|
PHP
|
remove unneeded use() statement
|
7df9ef53f81e8d99cab2ddd30fe2c69b7fedafce
|
<ide><path>src/Illuminate/Session/SessionServiceProvider.php
<ide> protected function registerBootingEvent()
<ide> {
<ide> $app = $this->app;
<ide>
<del> $this->app->booting(function($app) use ($app)
<add> $this->app->booting(function($app)
<ide> {
<ide> $app['session']->start();
<ide> });
<ide> protected function getDriver()
<ide> return $this->app['config']['session.driver'];
<ide> }
<ide>
<del>}
<ide>\ No newline at end of file
<add>}
| 1
|
Python
|
Python
|
allow head method
|
d3557bdcd0f4d6a7106267ea0f8a3024f21fd9f9
|
<ide><path>djangorestframework/compat.py
<ide> def request(self, **request):
<ide> # django.views.generic.View (Django >= 1.3)
<ide> try:
<ide> from django.views.generic import View
<add> if not hasattr(View, 'head'):
<add> # First implementation of Django class-based views did not include head method
<add> # in base View class - https://code.djangoproject.com/ticket/15688
<add> class ViewPlusHead(View):
<add> def head(self, request, *args, **kwargs):
<add> return self.get(request, *args, **kwargs)
<add> View = ViewPlusHead
<add>
<ide> except ImportError:
<ide> from django import http
<ide> from django.utils.functional import update_wrapper
<ide> def http_method_not_allowed(self, request, *args, **kwargs):
<ide> #)
<ide> return http.HttpResponseNotAllowed(allowed_methods)
<ide>
<add> def head(self, request, *args, **kwargs):
<add> return self.get(request, *args, **kwargs)
<ide>
<ide> try:
<ide> import markdown
<ide> def apply_markdown(text):
<ide> return md.convert(text)
<ide>
<ide> except ImportError:
<del> apply_markdown = None
<ide>\ No newline at end of file
<add> apply_markdown = None
<ide><path>djangorestframework/tests/content.py
<ide> from djangorestframework.mixins import RequestMixin
<ide> from djangorestframework.parsers import FormParser, MultiPartParser, PlainTextParser
<ide>
<del>
<ide> class TestContentParsing(TestCase):
<ide> def setUp(self):
<ide> self.req = RequestFactory()
<ide> def ensure_determines_no_content_GET(self, view):
<ide> view.request = self.req.get('/')
<ide> self.assertEqual(view.DATA, None)
<ide>
<add> def ensure_determines_no_content_HEAD(self, view):
<add> """Ensure view.DATA returns None for HEAD request."""
<add> view.request = self.req.head('/')
<add> self.assertEqual(view.DATA, None)
<add>
<ide> def ensure_determines_form_content_POST(self, view):
<ide> """Ensure view.DATA returns content for POST request with form content."""
<ide> form_data = {'qwerty': 'uiop'}
<ide> def test_standard_behaviour_determines_no_content_GET(self):
<ide> """Ensure view.DATA returns None for GET request with no content."""
<ide> self.ensure_determines_no_content_GET(RequestMixin())
<ide>
<add> def test_standard_behaviour_determines_no_content_HEAD(self):
<add> """Ensure view.DATA returns None for HEAD request."""
<add> self.ensure_determines_no_content_HEAD(RequestMixin())
<add>
<ide> def test_standard_behaviour_determines_form_content_POST(self):
<ide> """Ensure view.DATA returns content for POST request with form content."""
<ide> self.ensure_determines_form_content_POST(RequestMixin())
<ide><path>djangorestframework/tests/methods.py
<ide> def test_overloaded_POST_behaviour_determines_overloaded_method(self):
<ide> view = RequestMixin()
<ide> view.request = self.req.post('/', {view._METHOD_PARAM: 'DELETE'})
<ide> self.assertEqual(view.method, 'DELETE')
<add>
<add> def test_HEAD_is_a_valid_method(self):
<add> """HEAD requests identified"""
<add> view = RequestMixin()
<add> view.request = self.req.head('/')
<add> self.assertEqual(view.method, 'HEAD')
<ide><path>djangorestframework/tests/renderers.py
<ide> def test_default_renderer_serializes_content(self):
<ide> self.assertEquals(resp.content, RENDERER_A_SERIALIZER(DUMMYCONTENT))
<ide> self.assertEquals(resp.status_code, DUMMYSTATUS)
<ide>
<add> def test_head_method_serializes_no_content(self):
<add> """No response must be included in HEAD requests."""
<add> resp = self.client.head('/')
<add> self.assertEquals(resp.status_code, DUMMYSTATUS)
<add> self.assertEquals(resp['Content-Type'], RendererA.media_type)
<add> self.assertEquals(resp.content, '')
<add>
<ide> def test_default_renderer_serializes_content_on_accept_any(self):
<ide> """If the Accept header is set to */* the default renderer should serialize the response."""
<ide> resp = self.client.get('/', HTTP_ACCEPT='*/*')
<ide> def test_unsatisfiable_accept_header_on_request_returns_406_status(self):
<ide> resp = self.client.get('/', HTTP_ACCEPT='foo/bar')
<ide> self.assertEquals(resp.status_code, 406)
<ide>
<del>
<del>
<ide> _flat_repr = '{"foo": ["bar", "baz"]}'
<ide>
<ide> _indented_repr = """{
| 4
|
Ruby
|
Ruby
|
add tap class
|
f7bcfe5115f92e5e88596bf77d34f9a954e4c4b0
|
<ide><path>Library/Homebrew/tap.rb
<add>class Tap
<add> TAP_DIRECTORY = HOMEBREW_LIBRARY/"Taps"
<add>
<add> extend Enumerable
<add>
<add> attr_reader :user
<add> attr_reader :repo
<add> attr_reader :name
<add> attr_reader :path
<add> attr_reader :remote
<add>
<add> def initialize(user, repo, remote=nil)
<add> # we special case homebrew so users don't have to shift in a terminal
<add> @user = user == "homebrew" ? "Homebrew" : user
<add> @repo = repo
<add> @name = "#{@user}/#{@repo}".downcase
<add> @path = TAP_DIRECTORY/"#{@user}/homebrew-#{@repo}".downcase
<add> if installed?
<add> @path.cd do
<add> @remote = Utils.popen_read("git", "config", "--get", "remote.origin.url").chomp
<add> end
<add> else
<add> @remote = remote || "https://github.com/#{@user}/homebrew-#{@repo}"
<add> end
<add> end
<add>
<add> def to_s
<add> name
<add> end
<add>
<add> def official?
<add> @user == "Homebrew"
<add> end
<add>
<add> def private?
<add> return true if custom_remote?
<add> GitHub.private_repo?(@user, "homebrew-#{@repo}")
<add> rescue GitHub::HTTPNotFoundError
<add> true
<add> rescue GitHub::Error
<add> false
<add> end
<add>
<add> def installed?
<add> (@path/".git").directory?
<add> end
<add>
<add> def custom_remote?
<add> @remote.casecmp("https://github.com/#{@user}/homebrew-#{@repo}") != 0
<add> end
<add>
<add> def formula_files
<add> dir = [@path/"Formula", @path/"HomebrewFormula", @path].detect(&:directory?)
<add> return [] unless dir
<add> dir.children.select { |p| p.extname == ".rb" }
<add> end
<add>
<add> def formula_names
<add> formula_files.map { |f| "#{name}/#{f.basename(".rb")}" }
<add> end
<add>
<add> def command_files
<add> Pathname.glob("#{path}/cmd/brew-*").select(&:executable?)
<add> end
<add>
<add> def to_hash
<add> {
<add> "name" => @name,
<add> "user" => @user,
<add> "repo" => @repo,
<add> "path" => @path.to_s,
<add> "remote" => @remote,
<add> "installed" => installed?,
<add> "official" => official?,
<add> "custom_remote" => custom_remote?,
<add> "formula_names" => formula_names,
<add> "formula_files" => formula_files.map(&:to_s),
<add> "command_files" => command_files.map(&:to_s),
<add> }
<add> end
<add>
<add> def self.each
<add> return unless TAP_DIRECTORY.directory?
<add>
<add> TAP_DIRECTORY.subdirs.each do |user|
<add> user.subdirs.each do |repo|
<add> if (repo/".git").directory?
<add> yield new(user.basename.to_s, repo.basename.to_s.sub("homebrew-", ""))
<add> end
<add> end
<add> end
<add> end
<add>
<add> def self.names
<add> map(&:name)
<add> end
<add>end
| 1
|
PHP
|
PHP
|
add validate with bag method
|
05227c32f3ae4619d141b2cd5a4918cb13ad944b
|
<ide><path>src/Illuminate/Validation/Validator.php
<ide> public function validate()
<ide> return $this->validated();
<ide> }
<ide>
<add> /**
<add> * Run the validator's rules against its data.
<add> *
<add> * @param string $errorBag
<add> * @return array
<add> *
<add> * @throws \Illuminate\Validation\ValidationException
<add> */
<add> public function validateWithBag(string $errorBag)
<add> {
<add> try {
<add> return $this->validate();
<add> } catch (ValidationException $e) {
<add> $e->errorBag = $errorBag;
<add>
<add> throw $e;
<add> }
<add> }
<add>
<ide> /**
<ide> * Get the attributes and values that were validated.
<ide> *
| 1
|
Text
|
Text
|
make createpushresponse() more detailled
|
e7b4ba90035cb5f56166606a348a8468dcd01492
|
<ide><path>doc/api/http2.md
<ide> will result in a [`TypeError`][] being thrown.
<ide> added: v8.4.0
<ide> -->
<ide> * `headers` {HTTP/2 Headers Object} An object describing the headers
<del>* `callback` {Function}
<del>
<del>Call [`http2stream.pushStream()`][] with the given headers, and wraps the
<del>given newly created [`Http2Stream`] on `Http2ServerResponse`.
<add>* `callback` {Function} Called once `http2stream.pushStream()` is finished,
<add> or either when the attempt to create the pushed `Http2Stream` has failed or
<add> has been rejected, or the state of `Http2ServerRequest` is closed prior to
<add> calling the `http2stream.pushStream()` method
<add> * `err` {Error}
<add> * `stream` {ServerHttp2Stream} The newly-created `ServerHttp2Stream` object
<ide>
<del>The callback will be called with an error with code `ERR_HTTP2_INVALID_STREAM`
<del>if the stream is closed.
<add>Call [`http2stream.pushStream()`][] with the given headers, and wrap the
<add>given [`Http2Stream`] on a newly created `Http2ServerResponse` as the callback
<add>parameter if successful. When `Http2ServerRequest` is closed, the callback is
<add>called with an error `ERR_HTTP2_INVALID_STREAM`.
<ide>
<ide> ## Collecting HTTP/2 Performance Metrics
<ide>
| 1
|
Javascript
|
Javascript
|
remove registerextension, add .extensions. tests
|
0f16af7ee41edc29e9c850a4650b90a6e5e49f37
|
<ide><path>src/node.js
<ide> var module = (function () {
<ide> // Set the environ variable NODE_MODULE_CONTEXTS=1 to make node load all
<ide> // modules in thier own context.
<ide> var contextLoad = false;
<del> if (parseInt(process.env["NODE_MODULE_CONTEXTS"]) > 0) contextLoad = true;
<add> if (+process.env["NODE_MODULE_CONTEXTS"] > 0) contextLoad = true;
<ide> var Script;
<ide>
<ide> var internalModuleCache = {};
<del> var extensionCache = {};
<ide>
<ide> function Module (id, parent) {
<ide> this.id = id;
<ide> var module = (function () {
<ide> modulePaths = process.env["NODE_PATH"].split(":").concat(modulePaths);
<ide> }
<ide>
<del> var moduleNativeExtensions = ['js', 'node'];
<add> var extensions = {};
<add> var registerExtension = removed('require.registerExtension() removed. Use require.extensions instead');
<ide>
<ide> // Which files to traverse while finding id? Returns generator function.
<ide> function traverser (id, dirs) {
<del> var head = [], inDir = [], _dirs = dirs.slice();
<add> var head = [], inDir = [], dirs = dirs.slice(),
<add> exts = Object.keys(extensions);
<ide> return function next () {
<ide> var result = head.shift();
<ide> if (result) { return result; }
<ide>
<ide> var gen = inDir.shift();
<ide> if (gen) { head = gen(); return next(); }
<ide>
<del> var dir = _dirs.shift();
<add> var dir = dirs.shift();
<ide> if (dir !== undefined) {
<del> function direct (ext) { return path.join(dir, id + '.' + ext); }
<del> function index (ext) { return path.join(dir, id, 'index.' + ext); }
<del> var userExts = Object.keys(extensionCache);
<add> function direct (ext) { return path.join(dir, id + ext); }
<add> function index (ext) { return path.join(dir, id, 'index' + ext); }
<ide> inDir = [
<del> function () { return moduleNativeExtensions.map(direct); },
<del> function () { return userExts.map(direct); },
<del> function () { return moduleNativeExtensions.map(index); },
<del> function () { return userExts.map(index); }
<add> function () { return exts.map(direct); },
<add> function () { return exts.map(index); },
<ide> ];
<ide> head = [path.join(dir, id)];
<ide> return next();
<ide> var module = (function () {
<ide> // sync - no i/o performed
<ide> function resolveModulePath(request, parent) {
<ide> var start = request.substring(0, 2);
<del> if (start !== "./" && start !== "..") { return [request, modulePaths]; }
<del>
<del> // Relative request
<del> var exts = moduleNativeExtensions.concat(Object.keys(extensionCache)),
<del> indexRE = new RegExp('^index\\.(' + exts.join('|') + ')$'),
<del> // XXX dangerous code: ^^^ what if exts contained some RE control chars?
<del> isIndex = path.basename(parent.filename).match(indexRE),
<del> parentIdPath = isIndex ? parent.id : path.dirname(parent.id),
<del> id = path.join(parentIdPath, request);
<add> if (start !== "./" && start !== "..") {
<add> return [request, modulePaths];
<add> }
<add>
<add> // Is the parent an index module?
<add> // We can assume the parent has a valid extension,
<add> // as it already has been accepted as a module.
<add> var isIndex = /^index\.\w+?$/.test(path.basename(parent.filename)),
<add> parentIdPath = isIndex ? parent.id : path.dirname(parent.id),
<add> id = path.join(parentIdPath, request);
<add>
<ide> // make sure require('./path') and require('path') get distinct ids, even
<ide> // when called from the toplevel js file
<ide> if (parentIdPath === '.' && id.indexOf('/') === -1) {
<ide> var module = (function () {
<ide>
<ide>
<ide> function loadModule (request, parent) {
<del> var resolvedModule = resolveModulePath(request, parent),
<del> id = resolvedModule[0],
<del> paths = resolvedModule[1];
<del>
<ide> debug("loadModule REQUEST " + (request) + " parent: " + parent.id);
<ide>
<del> // native modules always take precedence.
<del> var cachedNative = internalModuleCache[id];
<add> // With natives id === request
<add> // We deal with these first
<add> var cachedNative = internalModuleCache[request];
<ide> if (cachedNative) {
<ide> return cachedNative.exports;
<ide> }
<del> if (natives[id]) {
<del> debug('load native module ' + id);
<del> return loadNative(id).exports;
<add> if (natives[request]) {
<add> debug('load native module ' + request);
<add> return loadNative(request).exports;
<ide> }
<ide>
<add> var resolvedModule = resolveModulePath(request, parent),
<add> id = resolvedModule[0],
<add> paths = resolvedModule[1];
<add>
<ide> // look up the filename first, since that's the cache key.
<ide> debug("looking for " + JSON.stringify(id) + " in " + JSON.stringify(paths));
<ide> var filename = findModulePath(request, paths);
<ide> var module = (function () {
<ide> };
<ide>
<ide>
<del> // This function allows the user to register file extensions to custom
<del> // Javascript 'compilers'. It accepts 2 arguments, where ext is a file
<del> // extension as a string. E.g. '.coffee' for coffee-script files. compiler
<del> // is the second argument, which is a function that gets called when the
<del> // specified file extension is found. The compiler is passed a single
<del> // argument, which is, the file contents, which need to be compiled.
<del> //
<del> // The function needs to return the compiled source, or an non-string
<del> // variable that will get attached directly to the module exports. Example:
<del> //
<del> // require.registerExtension('.coffee', function(content) {
<del> // return doCompileMagic(content);
<del> // });
<del> function registerExtension(ext, compiler) {
<del> if ('string' !== typeof ext && false === /\.\w+$/.test(ext)) {
<del> throw new Error('require.registerExtension: First argument not a valid extension string.');
<del> }
<del>
<del> if ('function' !== typeof compiler) {
<del> throw new Error('require.registerExtension: Second argument not a valid compiler function.');
<del> }
<del>
<del> extensionCache[ext.slice(1)] = compiler;
<del> }
<del>
<del>
<ide> Module.prototype.load = function (filename) {
<ide> debug("load " + JSON.stringify(filename) + " for module " + JSON.stringify(this.id));
<ide>
<ide> process.assert(!this.loaded);
<ide> this.filename = filename;
<ide>
<del> if (filename.match(/\.node$/)) {
<del> this._loadObject(filename);
<del> } else {
<del> this._loadScript(filename);
<del> }
<del> };
<del>
<del>
<del> Module.prototype._loadObject = function (filename) {
<del> process.dlopen(filename, this.exports);
<add> var extension = path.extname(filename) || '.js';
<add> extensions[extension](this, filename);
<add> this.loaded = true;
<ide> };
<ide>
<ide>
<ide> var module = (function () {
<ide> // remove shebang
<ide> content = content.replace(/^\#\!.*/, '');
<ide>
<del> // Compile content if needed
<del> var ext = path.extname(filename).slice(1);
<del> if (extensionCache[ext]) {
<del> content = extensionCache[ext](content);
<del> }
<del>
<del> if ("string" !== typeof content) {
<del> self.exports = content;
<del> return;
<del> }
<del>
<ide> function require (path) {
<ide> return loadModule(path, self);
<ide> }
<ide>
<ide> require.paths = modulePaths;
<ide> require.main = process.mainModule;
<add> // Enable support to add extra extension types
<add> require.extensions = extensions;
<add> // TODO: Insert depreciation warning
<ide> require.registerExtension = registerExtension;
<ide>
<ide> var dirname = path.dirname(filename);
<ide> var module = (function () {
<ide> };
<ide>
<ide>
<del> Module.prototype._loadScript = function (filename) {
<add> // Native extension for .js
<add> extensions['.js'] = function (module, filename) {
<ide> var content = requireNative('fs').readFileSync(filename, 'utf8');
<del> this._compile(content, filename);
<del> this.loaded = true;
<add> module._compile(content, filename);
<add> };
<add>
<add>
<add> // Native extension for .node
<add> extensions['.node'] = function (module, filename) {
<add> process.dlopen(filename, module.exports);
<ide> };
<ide>
<ide>
<ide><path>test/simple/test-module-loading.js
<ide> common = require("../common");
<ide> assert = common.assert
<del>var path = require('path');
<add>var path = require('path'),
<add> fs = require('fs');
<ide>
<ide> common.debug("load test-module-loading.js");
<ide>
<ide> try {
<ide>
<ide> assert.equal(require('path').dirname(__filename), __dirname);
<ide>
<del>common.debug('load custom file types with registerExtension');
<del>require.registerExtension('.test', function(content) {
<add>common.debug('load custom file types with extensions');
<add>require.extensions['.test'] = function (module, filename) {
<add> var content = fs.readFileSync(filename).toString();
<ide> assert.equal("this is custom source\n", content);
<del>
<del> return content.replace("this is custom source", "exports.test = 'passed'");
<del>});
<add> content = content.replace("this is custom source", "exports.test = 'passed'");
<add> module._compile(content, filename);
<add>};
<ide>
<ide> assert.equal(require('../fixtures/registerExt').test, "passed");
<ide>
<ide> common.debug('load custom file types that return non-strings');
<del>require.registerExtension('.test', function(content) {
<del> return {
<add>require.extensions['.test'] = function (module, filename) {
<add> module.exports = {
<ide> custom: 'passed'
<ide> };
<del>});
<add>};
<ide>
<ide> assert.equal(require('../fixtures/registerExt2').custom, 'passed');
<ide> common.debug("load modules by absolute id, then change require.paths, and load another module with the same absolute id.");
<ide> common.debug('load order');
<ide> var loadOrder = '../fixtures/module-load-order/',
<ide> msg = "Load order incorrect.";
<ide>
<del>require.registerExtension('.reg', function(content) { return content; });
<del>require.registerExtension('.reg2', function(content) { return content; });
<add>require.extensions['.reg'] = require.extensions['.js'];
<add>require.extensions['.reg2'] = require.extensions['.js'];
<ide>
<ide> assert.equal(require(loadOrder + 'file1').file1, 'file1', msg);
<ide> assert.equal(require(loadOrder + 'file2').file2, 'file2.js', msg);
| 2
|
Javascript
|
Javascript
|
add tests for $position for small arrays/objects
|
bb39d34279fe1e221d35f5d2a274aaf039ea62d4
|
<ide><path>test/widgetsSpec.js
<ide> describe("widget", function(){
<ide> scope.items.push('frodo');
<ide> scope.$eval();
<ide> expect(element.text()).toEqual('misko:first|shyam:middle|doug:middle|frodo:last|');
<add>
<add> scope.items.pop();
<add> scope.items.pop();
<add> scope.$eval();
<add> expect(element.text()).toEqual('misko:first|shyam:last|');
<ide> });
<ide>
<ide> it('should expose iterator position as $position when iterating over objects', function() {
<ide> describe("widget", function(){
<ide> scope.items = {'misko':'m', 'shyam':'s', 'doug':'d', 'frodo':'f'};
<ide> scope.$eval();
<ide> expect(element.text()).toEqual('misko:m:first|shyam:s:middle|doug:d:middle|frodo:f:last|');
<add>
<add> delete scope.items.doug;
<add> delete scope.items.frodo;
<add> scope.$eval();
<add> expect(element.text()).toEqual('misko:m:first|shyam:s:last|');
<ide> });
<ide> });
<ide>
| 1
|
Python
|
Python
|
add provide_file_and_upload to gcshook
|
917e6c4424985271c53dd8c413b211896ee55726
|
<ide><path>airflow/providers/google/cloud/hooks/gcs.py
<ide> def provide_file(
<ide> tmp_file.flush()
<ide> yield tmp_file
<ide>
<add> @_fallback_object_url_to_object_name_and_bucket_name()
<add> @contextmanager
<add> def provide_file_and_upload(
<add> self,
<add> bucket_name: Optional[str] = None,
<add> object_name: Optional[str] = None,
<add> object_url: Optional[str] = None, # pylint: disable=unused-argument
<add> ):
<add> """
<add> Creates temporary file, returns a file handle and uploads the files content
<add> on close.
<add>
<add> You can use this method by passing the bucket_name and object_name parameters
<add> or just object_url parameter.
<add>
<add> :param bucket_name: The bucket to fetch from.
<add> :type bucket_name: str
<add> :param object_name: The object to fetch.
<add> :type object_name: str
<add> :param object_url: File reference url. Must start with "gs: //"
<add> :type object_url: str
<add> :return: File handler
<add> """
<add> if object_name is None:
<add> raise ValueError("Object name can not be empty")
<add>
<add> _, _, file_name = object_name.rpartition("/")
<add> with NamedTemporaryFile(suffix=file_name) as tmp_file:
<add> yield tmp_file
<add> tmp_file.flush()
<add> self.upload(bucket_name=bucket_name, object_name=object_name, filename=tmp_file.name)
<add>
<ide> def upload(
<ide> self,
<ide> bucket_name: str,
<ide><path>tests/providers/google/cloud/hooks/test_gcs.py
<ide> def test_provide_file(self, mock_service, mock_temp_file):
<ide> ]
<ide> )
<ide>
<add> @mock.patch(GCS_STRING.format('NamedTemporaryFile'))
<add> @mock.patch(GCS_STRING.format('GCSHook.upload'))
<add> def test_provide_file_upload(self, mock_upload, mock_temp_file):
<add> test_bucket = 'test_bucket'
<add> test_object = 'test_object'
<add> test_file = 'test_file'
<add>
<add> mock_temp_file.return_value.__enter__.return_value = mock.MagicMock()
<add> mock_temp_file.return_value.__enter__.return_value.name = test_file
<add>
<add> with self.gcs_hook.provide_file_and_upload(
<add> bucket_name=test_bucket, object_name=test_object
<add> ) as fhandle:
<add> assert fhandle.name == test_file
<add> fhandle.write()
<add>
<add> mock_upload.assert_called_once_with(
<add> bucket_name=test_bucket, object_name=test_object, filename=test_file
<add> )
<add> mock_temp_file.assert_has_calls(
<add> [
<add> mock.call(suffix='test_object'),
<add> mock.call().__enter__(),
<add> mock.call().__enter__().write(),
<add> mock.call().__enter__().flush(),
<add> mock.call().__exit__(None, None, None),
<add> ]
<add> )
<add>
<ide>
<ide> class TestGCSHookUpload(unittest.TestCase):
<ide> def setUp(self):
| 2
|
Python
|
Python
|
add check for remove_listener method
|
7886d59c5650f4d8abe1e97d78300c707053f8c8
|
<ide><path>spacy/language.py
<ide> def replace_listeners(
<ide> if (
<ide> not hasattr(tok2vec, "model")
<ide> or not hasattr(tok2vec, "listener_map")
<add> or not hasattr(tok2vec, "remove_listener")
<ide> or "model" not in tok2vec_cfg
<ide> ):
<ide> raise ValueError(Errors.E888.format(name=tok2vec_name, pipe=type(tok2vec)))
| 1
|
PHP
|
PHP
|
use container contract, add class member
|
7c827d0d2226e4e0788852a7d3837d128081c090
|
<ide><path>src/Illuminate/Validation/Validator.php
<ide> use DateTimeZone;
<ide> use Illuminate\Support\Fluent;
<ide> use Illuminate\Support\MessageBag;
<del>use Illuminate\Container\Container;
<add>use Illuminate\Contracts\Container\Container;
<ide> use Symfony\Component\HttpFoundation\File\File;
<ide> use Symfony\Component\Translation\TranslatorInterface;
<ide> use Symfony\Component\HttpFoundation\File\UploadedFile;
<ide> class Validator implements ValidatorContract {
<ide> */
<ide> protected $presenceVerifier;
<ide>
<add> /**
<add> * The container instance.
<add> *
<add> * @var \Illuminate\Contracts\Container\Container
<add> */
<add> protected $container;
<add>
<ide> /**
<ide> * The failed validation rules.
<ide> *
<ide> public function getMessageBag()
<ide> /**
<ide> * Set the IoC container instance.
<ide> *
<del> * @param \Illuminate\Container\Container $container
<add> * @param \Illuminate\Contracts\Container\Container $container
<ide> * @return void
<ide> */
<ide> public function setContainer(Container $container)
| 1
|
Python
|
Python
|
remove deprecated np.lib.ufunclike.log2 function
|
f7a4ff1b9133440133936fa04442e40f8829d1ab
|
<ide><path>numpy/lib/tests/test_ufunclike.py
<ide> def test_isneginf(self):
<ide> assert_equal(res, tgt)
<ide> assert_equal(out, tgt)
<ide>
<del> @deprecated()
<del> def test_log2(self):
<del> a = nx.array([4.5, 2.3, 6.5])
<del> out = nx.zeros(a.shape, float)
<del> tgt = nx.array([2.169925, 1.20163386, 2.70043972])
<del> res = ufl.log2(a)
<del> assert_almost_equal(res, tgt)
<del> res = ufl.log2(a, out)
<del> assert_almost_equal(res, tgt)
<del> assert_almost_equal(out, tgt)
<del>
<ide> def test_fix(self):
<ide> a = nx.array([[1.0, 1.1, 1.5, 1.8], [-1.0, -1.1, -1.5, -1.8]])
<ide> out = nx.zeros(a.shape, float)
<ide> def __array_wrap__(self, obj, context=None):
<ide> m = MyArray(a, metadata='foo')
<ide> f = ufl.fix(m)
<ide> assert_array_equal(f, nx.array([1,-1]))
<del> assert isinstance(f, MyArray)
<add> assert_(isinstance(f, MyArray))
<ide> assert_equal(f.metadata, 'foo')
<ide>
<ide> if __name__ == "__main__":
<ide><path>numpy/lib/ufunclike.py
<ide> def isneginf(x, y=None):
<ide> y = nx.empty(x.shape, dtype=nx.bool_)
<ide> nx.logical_and(nx.isinf(x), nx.signbit(x), y)
<ide> return y
<del>
<del>
<del>_log2 = nx.log(2)
<del>def log2(x, y=None):
<del> """
<del> Return the base 2 logarithm of the input array, element-wise.
<del> This function is now deprecated, use the np.log2 ufunc instead.
<del>
<del> Parameters
<del> ----------
<del> x : array_like
<del> Input array.
<del> y : array_like
<del> Optional output array with the same shape as `x`.
<del>
<del> Returns
<del> -------
<del> y : ndarray
<del> The logarithm to the base 2 of `x` element-wise.
<del> NaNs are returned where `x` is negative.
<del>
<del> See Also
<del> --------
<del> log, log1p, log10
<del>
<del> Examples
<del> --------
<del> >>> np.log2([-1, 2, 4])
<del> array([ NaN, 1., 2.])
<del>
<del> """
<del> import warnings
<del> msg = "numpy.lib.log2 is deprecated, use np.log2 instead."
<del> warnings.warn(msg, DeprecationWarning)
<del>
<del> x = nx.asanyarray(x)
<del> if y is None:
<del> y = nx.log(x)
<del> else:
<del> nx.log(x, y)
<del> y /= _log2
<del> return y
| 2
|
Ruby
|
Ruby
|
fix typo in inet and cidr saving
|
6f400dabf79faedec258963a6b37b7614f5d4902
|
<ide><path>activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb
<ide> def type_cast(value, column, array_member = false)
<ide> else super(value, column)
<ide> end
<ide> when IPAddr
<del> return super(value, column) unless ['inet','cidr'].includes? column.sql_type
<add> return super(value, column) unless ['inet','cidr'].include? column.sql_type
<ide> PostgreSQLColumn.cidr_to_string(value)
<ide> else
<ide> super(value, column)
<ide><path>activerecord/test/cases/adapters/postgresql/quoting_test.rb
<ide> require "cases/helper"
<add>require 'ipaddr'
<ide>
<ide> module ActiveRecord
<ide> module ConnectionAdapters
<ide> def test_type_cast_false
<ide> assert_equal 'f', @conn.type_cast(false, c)
<ide> end
<ide>
<add> def test_type_cast_cidr
<add> ip = IPAddr.new('255.0.0.0/8')
<add> c = Column.new(nil, ip, 'cidr')
<add> assert_equal ip, @conn.type_cast(ip, c)
<add> end
<add>
<add> def test_type_cast_inet
<add> ip = IPAddr.new('255.1.0.0/8')
<add> c = Column.new(nil, ip, 'inet')
<add> assert_equal ip, @conn.type_cast(ip, c)
<add> end
<add>
<ide> def test_quote_float_nan
<ide> nan = 0.0/0
<ide> c = Column.new(nil, 1, 'float')
| 2
|
Ruby
|
Ruby
|
create dependencieshelpers file, add tests
|
e05538a7d9f50c821b5605deff534beed85b8a04
|
<ide><path>Library/Homebrew/cmd/deps.rb
<ide> require "ostruct"
<ide> require "cli/parser"
<ide> require "cask/caskroom"
<add>require "dependencies_helpers"
<ide>
<ide> module Homebrew
<ide> extend DependenciesHelpers
<ide><path>Library/Homebrew/cmd/uses.rb
<ide> require "formula"
<ide> require "cli/parser"
<ide> require "cask/caskroom"
<add>require "dependencies_helpers"
<ide>
<ide> module Homebrew
<ide> extend DependenciesHelpers
<ide><path>Library/Homebrew/dependencies.rb
<ide> def inspect
<ide> "#<#{self.class.name}: {#{to_a.join(", ")}}>"
<ide> end
<ide> end
<del>
<del>module DependenciesHelpers
<del> def argv_includes_ignores(argv)
<del> includes = []
<del> ignores = []
<del>
<del> if argv.include? "--include-build"
<del> includes << "build?"
<del> else
<del> ignores << "build?"
<del> end
<del>
<del> if argv.include? "--include-test"
<del> includes << "test?"
<del> else
<del> ignores << "test?"
<del> end
<del>
<del> if argv.include? "--include-optional"
<del> includes << "optional?"
<del> else
<del> ignores << "optional?"
<del> end
<del>
<del> ignores << "recommended?" if args.skip_recommended?
<del>
<del> [includes, ignores]
<del> end
<del>
<del> def recursive_includes(klass, root_dependent, includes, ignores)
<del> type = if klass == Dependency
<del> :dependencies
<del> elsif klass == Requirement
<del> :requirements
<del> else
<del> raise ArgumentError, "Invalid class argument: #{klass}"
<del> end
<del>
<del> root_dependent.send("recursive_#{type}") do |dependent, dep|
<del> if dep.recommended?
<del> klass.prune if ignores.include?("recommended?") || dependent.build.without?(dep)
<del> elsif dep.optional?
<del> klass.prune if !includes.include?("optional?") && !dependent.build.with?(dep)
<del> elsif dep.build? || dep.test?
<del> keep = false
<del> keep ||= dep.test? && includes.include?("test?") && dependent == formula
<del> keep ||= dep.build? && includes.include?("build?")
<del> klass.prune unless keep
<del> end
<del>
<del> # If a tap isn't installed, we can't find the dependencies of one of
<del> # its formulae, and an exception will be thrown if we try.
<del> if type == :dependencies &&
<del> dep.is_a?(TapDependency) &&
<del> !dep.tap.installed?
<del> Dependency.keep_but_prune_recursive_deps
<del> end
<del> end
<del> end
<del>
<del> def reject_ignores(dependables, ignores, includes)
<del> dependables.reject do |dep|
<del> next false unless ignores.any? { |ignore| dep.send(ignore) }
<del>
<del> includes.none? { |include| dep.send(include) }
<del> end
<del> end
<del>
<del> def dependents(formulae_or_casks)
<del> formulae_or_casks.map do |formula_or_cask|
<del> if formula_or_cask.is_a?(Formula)
<del> formula_or_cask
<del> else
<del> CaskDependent.new(formula_or_cask)
<del> end
<del> end
<del> end
<del>end
<ide><path>Library/Homebrew/dependencies_helpers.rb
<add># frozen_string_literal: true
<add>
<add>require "cask_dependent"
<add>
<add>module DependenciesHelpers
<add> def argv_includes_ignores(argv)
<add> includes = []
<add> ignores = []
<add>
<add> if argv.include? "--include-build"
<add> includes << "build?"
<add> else
<add> ignores << "build?"
<add> end
<add>
<add> if argv.include? "--include-test"
<add> includes << "test?"
<add> else
<add> ignores << "test?"
<add> end
<add>
<add> if argv.include? "--include-optional"
<add> includes << "optional?"
<add> else
<add> ignores << "optional?"
<add> end
<add>
<add> ignores << "recommended?" if args.skip_recommended?
<add>
<add> [includes, ignores]
<add> end
<add>
<add> def recursive_includes(klass, root_dependent, includes, ignores)
<add> type = if klass == Dependency
<add> :dependencies
<add> elsif klass == Requirement
<add> :requirements
<add> else
<add> raise ArgumentError, "Invalid class argument: #{klass}"
<add> end
<add>
<add> root_dependent.send("recursive_#{type}") do |dependent, dep|
<add> if dep.recommended?
<add> klass.prune if ignores.include?("recommended?") || dependent.build.without?(dep)
<add> elsif dep.optional?
<add> klass.prune if !includes.include?("optional?") && !dependent.build.with?(dep)
<add> elsif dep.build? || dep.test?
<add> keep = false
<add> keep ||= dep.test? && includes.include?("test?") && dependent == formula
<add> keep ||= dep.build? && includes.include?("build?")
<add> klass.prune unless keep
<add> end
<add>
<add> # If a tap isn't installed, we can't find the dependencies of one of
<add> # its formulae, and an exception will be thrown if we try.
<add> if type == :dependencies &&
<add> dep.is_a?(TapDependency) &&
<add> !dep.tap.installed?
<add> Dependency.keep_but_prune_recursive_deps
<add> end
<add> end
<add> end
<add>
<add> def reject_ignores(dependables, ignores, includes)
<add> dependables.reject do |dep|
<add> next false unless ignores.any? { |ignore| dep.send(ignore) }
<add>
<add> includes.none? { |include| dep.send(include) }
<add> end
<add> end
<add>
<add> def dependents(formulae_or_casks)
<add> formulae_or_casks.map do |formula_or_cask|
<add> if formula_or_cask.is_a?(Formula)
<add> formula_or_cask
<add> else
<add> CaskDependent.new(formula_or_cask)
<add> end
<add> end
<add> end
<add> module_function :dependents
<add>end
<ide><path>Library/Homebrew/test/dependencies_helpers_spec.rb
<add># frozen_string_literal: true
<add>
<add>require "dependencies_helpers"
<add>
<add>describe DependenciesHelpers do
<add> specify "#dependents" do
<add> foo = formula "foo" do
<add> url "foo"
<add> version "1.0"
<add> end
<add>
<add> foo_cask = Cask::CaskLoader.load(+<<-RUBY)
<add> cask "foo_cask" do
<add> end
<add> RUBY
<add>
<add> bar = formula "bar" do
<add> url "bar-url"
<add> version "1.0"
<add> end
<add>
<add> bar_cask = Cask::CaskLoader.load(+<<-RUBY)
<add> cask "bar-cask" do
<add> end
<add> RUBY
<add>
<add> methods = [
<add> :name,
<add> :full_name,
<add> :runtime_dependencies,
<add> :deps,
<add> :requirements,
<add> :recursive_dependencies,
<add> :recursive_requirements,
<add> :any_version_installed?,
<add> ]
<add>
<add> dependents = described_class.dependents([foo, foo_cask, bar, bar_cask])
<add>
<add> dependents.each do |dependent|
<add> methods.each do |method|
<add> expect(dependent.respond_to?(method))
<add> .to be true
<add> end
<add> end
<add> end
<add>end
| 5
|
Ruby
|
Ruby
|
handle inconsistent jenkins git_urls
|
2a61c84be38866c5be788eebea932510608ba805
|
<ide><path>Library/Homebrew/dev-cmd/test-bot.rb
<ide> def diff_formulae(start_revision, end_revision, path, filter)
<ide> elsif ENV["GIT_BRANCH"] && ENV["GIT_URL"]
<ide> %r{origin/pr/(\d+)/(merge|head)} =~ ENV["GIT_BRANCH"]
<ide> pr = $1
<del> @url = "#{ENV["GIT_URL"]}/pull/#{pr}"
<add> @url = "#{ENV["GIT_URL"].chomp("/")}/pull/#{pr}"
<ide> @hash = nil
<ide> # Use Travis CI pull-request variables for pull request jobs.
<ide> elsif travis_pr
| 1
|
Python
|
Python
|
switch constraints to oo model
|
0f12e0119bc8c5c987c741e39024bb87234c8a76
|
<ide><path>keras/constraints.py
<ide> import theano.tensor as T
<ide> import numpy as np
<ide>
<del>def maxnorm(m=2):
<del> def maxnorm_wrap(p):
<add>class Constraint(object):
<add> def __call__(self, p):
<add> return p
<add>
<add>class MaxNorm(Constraint):
<add> def __init__(self, m=2):
<add> self.m = m
<add>
<add> def __call__(self, p):
<ide> norms = T.sqrt(T.sum(T.sqr(p), axis=0))
<del> desired = T.clip(norms, 0, m)
<add> desired = T.clip(norms, 0, self.m)
<ide> p = p * (desired / (1e-7 + norms))
<ide> return p
<del> return maxnorm_wrap
<ide>
<del>def nonneg(p):
<del> p *= T.ge(p, 0)
<del> return p
<add>class NonNeg(Constraint):
<add> def __call__(self, p):
<add> p *= T.ge(p, 0)
<add> return p
<ide>
<del>def identity(g):
<del> return g
<add>def UnitNorm(Constraint):
<add> def __call__(self, p):
<add> return e / T.sqrt(T.sum(e**2, axis=-1, keepdims=True))
<ide>
<del>def unitnorm(e):
<del> return e / T.sqrt(T.sum(e**2, axis=-1, keepdims=True))
<add>identity = Constraint
<add>maxnorm = MaxNorm
<add>nonneg = NonNeg
<add>unitnorm = UnitNorm
<ide>\ No newline at end of file
| 1
|
Javascript
|
Javascript
|
remove double registering of form
|
1faafa31582c4e9413f48dc7d12f5b681f9fe9fd
|
<ide><path>src/directive/form.js
<ide> function FormController(name, element, attrs) {
<ide> addClass((isValid ? VALID_CLASS : INVALID_CLASS) + validationErrorKey);
<ide> }
<ide>
<del> if (parentForm) {
<del> parentForm.$addControl(form);
<del> }
<del>
<ide> form.$addControl = function(control) {
<ide> if (control.$name && !form.hasOwnProperty(control.$name)) {
<ide> form[control.$name] = control;
| 1
|
Text
|
Text
|
fix typos in text
|
46c346bfcca46d19786d906eb7c59b81e598a94f
|
<ide><path>guide/english/vim/copy-and-paste/index.md
<ide> title: Copy and Paste
<ide>
<ide> # Copying and Pasting in Vim
<ide>
<del>In Vim, copying is commonly refered to as 'yanking', and pasting remains the same.
<add>In Vim, copying is commonly referred to as 'yanking', and pasting remains the same.
<ide>
<ide> ### Command Keys
<ide> The keys used for yanking and pasting in Vim are:
<ide> To yank or cut, type `y` or `d`, followed by a 'text object'. These describe ho
<ide>
<ide> A register is just another name for clipboard. But unlike other text editors, Vim has many of such "clipboards".
<ide>
<del>To yank or delete to a register, type `"<register name><command>` (e.g.: `"ayw` to [y]ank [w]ord to register `a`). Register names can be only one character long for obvious reasons (`"m`,`"M`, `"3` are allowed, but `"mr`, `"MyReg`, `"MyRegisterName` are not). The default register that is stored to when no register is specified is `"` and the system clipboard that can be accessed in other programs is `+`. You can also use lower case characters to access registers and use upper case characters to append to registers. For example `"dyy` copies the current line to the `d` register, typing `"D3yw` copies the next 3 words and adds them to what is already stored in `d`.
<add>To yank or delete to a register, type `"<register name><command>` (e.g.: `"ayw` to [y]ank [w]ord to register `a`). Register names can be only one character long for obvious reasons (`"m`,`"M`, `"3` are allowed, but `"mr`, `"MyReg`, `"MyRegisterName` are not). The default register that is stored to when no register is specified is `"` and the system clipboard that can be accessed in other programs is `+`. You can also use lower case characters to access registers and use uppercase characters to append to registers. For example `"dyy` copies the current line to the `d` register, typing `"D3yw` copies the next 3 words and adds them to what is already stored in `d`.
<ide>
<ide>
<ide> ### Pasting
| 1
|
Text
|
Text
|
fix typo in api routes documentation.
|
b533f2afab7ac7574170eb287d0b54ab74a38a0f
|
<ide><path>docs/api-routes/introduction.md
<ide> For example, the following API route `pages/api/user.js` handles a simple `json`
<ide> export default (req, res) => {
<ide> res.statusCode = 200
<ide> res.setHeader('Content-Type', 'application/json')
<del> res.end(JSON.stringify({ name: 'Jhon Doe' }))
<add> res.end(JSON.stringify({ name: 'John Doe' }))
<ide> }
<ide> ```
<ide>
| 1
|
Javascript
|
Javascript
|
accept undefined animation.samplers.interpolation
|
f4401306b089a0a8f5100761e41de5b7ff8dc0af
|
<ide><path>examples/js/loaders/GLTFLoader.js
<ide> THREE.GLTFLoader = ( function () {
<ide> : THREE.VectorKeyframeTrack;
<ide>
<ide> var targetName = node.name ? node.name : node.uuid;
<add> var interpolation = sampler.interpolation !== undefined ? INTERPOLATION[ sampler.interpolation ] : THREE.InterpolateLinear;
<ide>
<ide> // KeyframeTrack.optimize() will modify given 'times' and 'values'
<ide> // buffers before creating a truncated copy to keep. Because buffers may
<ide> THREE.GLTFLoader = ( function () {
<ide> targetName + '.' + PATH_PROPERTIES[ target.path ],
<ide> THREE.AnimationUtils.arraySlice( inputAccessor.array, 0 ),
<ide> THREE.AnimationUtils.arraySlice( outputAccessor.array, 0 ),
<del> INTERPOLATION[ sampler.interpolation ]
<add> interpolation
<ide> ) );
<ide>
<ide> }
| 1
|
Python
|
Python
|
preserve ndarray subclasses in median
|
e6f0c9023d9a57a83d83684c2f63ad924038be69
|
<ide><path>numpy/lib/function_base.py
<ide> def median(a, axis=None, out=None, overwrite_input=False):
<ide> >>> assert not np.all(a==b)
<ide>
<ide> """
<del> a = np.asarray(a)
<add> a = np.asanyarray(a)
<ide> if axis is not None and axis >= a.ndim:
<ide> raise IndexError(
<ide> "axis %d out of bounds (%d)" % (axis, a.ndim))
<ide><path>numpy/lib/tests/test_function_base.py
<ide> def test_array_like(self):
<ide> assert_almost_equal(np.median(x2), 2)
<ide> assert_allclose(np.median(x2, axis=0), x)
<ide>
<add> def test_subclass(self):
<add> # gh-3846
<add> class MySubClass(np.ndarray):
<add> def __new__(cls, input_array, info=None):
<add> obj = np.asarray(input_array).view(cls)
<add> obj.info = info
<add> return obj
<add>
<add> def mean(self, axis=None, dtype=None, out=None):
<add> return -7
<add>
<add> a = MySubClass([1,2,3])
<add> assert_equal(np.median(a), -7)
<ide>
<ide> class TestAdd_newdoc_ufunc(TestCase):
<ide>
| 2
|
Javascript
|
Javascript
|
add test case for large assets
|
d3035701f48a329acc6ce558dbd56f0fdfbad87e
|
<ide><path>lib/TemplatedPathPlugin.js
<ide> const replacePathVariables = (path, data, assetInfo) => {
<ide> // [path] - /some/path/
<ide> // [name] - file
<ide> // [ext] - .js
<del> if (data.filename) {
<del> if (typeof data.filename === "string") {
<del> const { path: file, query, fragment } = parseResource(data.filename);
<del>
<del> const ext = extname(file);
<del> const base = basename(file);
<del> const name = base.slice(0, base.length - ext.length);
<del> const path = file.slice(0, file.length - base.length);
<del>
<del> replacements.set("file", replacer(file));
<del> replacements.set("query", replacer(query, true));
<del> replacements.set("fragment", replacer(fragment, true));
<del> replacements.set("path", replacer(path, true));
<del> replacements.set("base", replacer(base));
<del> replacements.set("name", replacer(name));
<del> replacements.set("ext", replacer(ext, true));
<del> // Legacy
<del> replacements.set(
<del> "filebase",
<del> deprecated(
<del> replacer(base),
<del> "[filebase] is now [base]",
<del> "DEP_WEBPACK_TEMPLATE_PATH_PLUGIN_REPLACE_PATH_VARIABLES_FILENAME"
<del> )
<del> );
<del> }
<add> if (typeof data.filename === "string") {
<add> const { path: file, query, fragment } = parseResource(data.filename);
<add>
<add> const ext = extname(file);
<add> const base = basename(file);
<add> const name = base.slice(0, base.length - ext.length);
<add> const path = file.slice(0, file.length - base.length);
<add>
<add> replacements.set("file", replacer(file));
<add> replacements.set("query", replacer(query, true));
<add> replacements.set("fragment", replacer(fragment, true));
<add> replacements.set("path", replacer(path, true));
<add> replacements.set("base", replacer(base));
<add> replacements.set("name", replacer(name));
<add> replacements.set("ext", replacer(ext, true));
<add> // Legacy
<add> replacements.set(
<add> "filebase",
<add> deprecated(
<add> replacer(base),
<add> "[filebase] is now [base]",
<add> "DEP_WEBPACK_TEMPLATE_PATH_PLUGIN_REPLACE_PATH_VARIABLES_FILENAME"
<add> )
<add> );
<ide> }
<ide>
<ide> // Compilation context
<ide><path>test/TestCases.template.js
<ide> const describeCases = config => {
<ide> category.name,
<ide> testName
<ide> );
<add> let testConfig = {};
<add> const testConfigPath = path.join(testDirectory, "test.config.js");
<add> if (fs.existsSync(testConfigPath)) {
<add> testConfig = require(testConfigPath);
<add> }
<ide> const options = {
<ide> context: casesPath,
<ide> entry: "./" + category.name + "/" + testName + "/",
<ide> const describeCases = config => {
<ide> rimraf(cacheDirectory, done);
<ide> });
<ide> if (config.cache) {
<del> it(`${testName} should pre-compile to fill disk cache (1st)`, done => {
<del> const oldPath = options.output.path;
<del> options.output.path = path.join(
<del> options.output.path,
<del> "cache1"
<del> );
<del> const deprecationTracker = deprecationTracking.start();
<del> webpack(options, err => {
<del> deprecationTracker();
<del> options.output.path = oldPath;
<del> if (err) return done(err);
<del> done();
<del> });
<del> }, 60000);
<del> it(`${testName} should pre-compile to fill disk cache (2nd)`, done => {
<del> const oldPath = options.output.path;
<del> options.output.path = path.join(
<del> options.output.path,
<del> "cache2"
<del> );
<del> const deprecationTracker = deprecationTracking.start();
<del> webpack(options, err => {
<del> deprecationTracker();
<del> options.output.path = oldPath;
<del> if (err) return done(err);
<del> done();
<del> });
<del> }, 10000);
<add> it(
<add> `${testName} should pre-compile to fill disk cache (1st)`,
<add> done => {
<add> const oldPath = options.output.path;
<add> options.output.path = path.join(
<add> options.output.path,
<add> "cache1"
<add> );
<add> const deprecationTracker = deprecationTracking.start();
<add> webpack(options, err => {
<add> deprecationTracker();
<add> options.output.path = oldPath;
<add> if (err) return done(err);
<add> done();
<add> });
<add> },
<add> testConfig.timeout || 60000
<add> );
<add> it(
<add> `${testName} should pre-compile to fill disk cache (2nd)`,
<add> done => {
<add> const oldPath = options.output.path;
<add> options.output.path = path.join(
<add> options.output.path,
<add> "cache2"
<add> );
<add> const deprecationTracker = deprecationTracking.start();
<add> webpack(options, err => {
<add> deprecationTracker();
<add> options.output.path = oldPath;
<add> if (err) return done(err);
<add> done();
<add> });
<add> },
<add> testConfig.cachedTimeout || testConfig.timeout || 10000
<add> );
<ide> }
<ide> it(
<ide> testName + " should compile",
<ide> const describeCases = config => {
<ide> run();
<ide> }
<ide> },
<del> config.cache ? 20000 : 60000
<add> testConfig.cachedTimeout ||
<add> testConfig.timeout ||
<add> (config.cache ? 20000 : 60000)
<ide> );
<ide>
<ide> it(
<ide> const describeCases = config => {
<ide>
<ide> const { it: _it, getNumberOfTests } = createLazyTestEnv(
<ide> jasmine.getEnv(),
<del> 10000
<add> testConfig.timeout || 10000
<ide> );
<ide> });
<ide> });
<ide><path>test/cases/large/big-assets/generate-big-asset-loader.js
<add>module.exports = function () {
<add> const options = this.getOptions();
<add> return Buffer.alloc(+options.size);
<add>};
<add>module.exports.raw = true;
<ide><path>test/cases/large/big-assets/index.js
<add>it("should compile fine", () => {
<add> const a = new URL(
<add> "./generate-big-asset-loader.js?size=100000000!",
<add> import.meta.url
<add> );
<add> const b = new URL(
<add> "./generate-big-asset-loader.js?size=200000000!",
<add> import.meta.url
<add> );
<add> const c = new URL(
<add> "./generate-big-asset-loader.js?size=300000000!",
<add> import.meta.url
<add> );
<add> const d = new URL(
<add> "./generate-big-asset-loader.js?size=400000000!",
<add> import.meta.url
<add> );
<add> const e = new URL(
<add> "./generate-big-asset-loader.js?size=500000000!",
<add> import.meta.url
<add> );
<add> const f = new URL(
<add> "./generate-big-asset-loader.js?size=600000000!",
<add> import.meta.url
<add> );
<add>});
<ide><path>test/cases/large/big-assets/test.config.js
<add>module.exports = {
<add> timeout: 120000
<add>};
<ide><path>test/cases/large/big-assets/test.filter.js
<add>module.exports = function (config) {
<add> return !process.env.CI;
<add>};
| 6
|
Javascript
|
Javascript
|
remove the circular dependency
|
f3189ace6b5e31a874df421ac2f74da0e77cb14d
|
<ide><path>lib/_http_agent.js
<ide> // USE OR OTHER DEALINGS IN THE SOFTWARE.
<ide>
<ide> var net = require('net');
<del>var url = require('url');
<ide> var util = require('util');
<ide> var EventEmitter = require('events').EventEmitter;
<del>var ClientRequest = require('_http_client').ClientRequest;
<ide> var debug = util.debuglog('http');
<ide>
<ide> // New Agent code.
<ide> Agent.prototype.destroy = function() {
<ide> });
<ide> };
<ide>
<del>Agent.prototype.request = function(options, cb) {
<del> if (util.isString(options)) {
<del> options = url.parse(options);
<del> }
<del> // don't try to do dns lookups of foo.com:8080, just foo.com
<del> if (options.hostname) {
<del> options.host = options.hostname;
<del> }
<del>
<del> if (options && options.path && / /.test(options.path)) {
<del> // The actual regex is more like /[^A-Za-z0-9\-._~!$&'()*+,;=/:@]/
<del> // with an additional rule for ignoring percentage-escaped characters
<del> // but that's a) hard to capture in a regular expression that performs
<del> // well, and b) possibly too restrictive for real-world usage. That's
<del> // why it only scans for spaces because those are guaranteed to create
<del> // an invalid request.
<del> throw new TypeError('Request path contains unescaped characters.');
<del> } else if (options.protocol && options.protocol !== this.protocol) {
<del> throw new Error('Protocol:' + options.protocol + ' not supported.');
<del> }
<del>
<del> options = util._extend({
<del> agent: this,
<del> keepAlive: this.keepAlive
<del> }, options);
<del>
<del> // if it's false, then make a new one, just like this one.
<del> if (options.agent === false)
<del> options.agent = new this.constructor();
<del>
<del> debug('agent.request', options);
<del> return new ClientRequest(options, cb);
<del>};
<del>
<del>Agent.prototype.get = function(options, cb) {
<del> var req = this.request(options, cb);
<del> req.end();
<del> return req;
<del>};
<del>
<ide> exports.globalAgent = new Agent();
| 1
|
Python
|
Python
|
fix serialization of reverse relationships
|
45d4622f090f8d81a04b4d3e888017419676bbc0
|
<ide><path>rest_framework/serializers.py
<ide> def from_native(self, data):
<ide> if not self._errors:
<ide> return self.restore_object(attrs, instance=getattr(self, 'object', None))
<ide>
<add> def field_to_native(self, obj, field_name):
<add> """
<add> Override default so that we can apply ModelSerializer as a nested
<add> field to relationships.
<add> """
<add> obj = getattr(obj, self.source or field_name)
<add>
<add> # If the object has an "all" method, assume it's a relationship
<add> if is_simple_callable(getattr(obj, 'all', None)):
<add> return [self.to_native(item) for item in obj.all()]
<add>
<add> return self.to_native(obj)
<add>
<ide> @property
<ide> def errors(self):
<ide> """
<ide> class ModelSerializer(Serializer):
<ide> """
<ide> _options_class = ModelSerializerOptions
<ide>
<del> def field_to_native(self, obj, field_name):
<del> """
<del> Override default so that we can apply ModelSerializer as a nested
<del> field to relationships.
<del> """
<del> obj = getattr(obj, self.source or field_name)
<del> if obj.__class__.__name__ in ('RelatedManager', 'ManyRelatedManager'):
<del> return [self.to_native(item) for item in obj.all()]
<del> return self.to_native(obj)
<del>
<ide> def default_fields(self, serialize, obj=None, data=None, nested=False):
<ide> """
<ide> Return all the fields that should be serialized for the model.
<ide><path>rest_framework/tests/models.py
<ide> class Comment(RESTFrameworkModel):
<ide> content = models.CharField(max_length=200)
<ide> created = models.DateTimeField(auto_now_add=True)
<ide>
<add>
<ide> class ActionItem(RESTFrameworkModel):
<ide> title = models.CharField(max_length=200)
<ide> done = models.BooleanField(default=False)
<add>
<add>
<add># Models for reverse relations
<add>class BlogPost(RESTFrameworkModel):
<add> title = models.CharField(max_length=100)
<add>
<add>
<add>class BlogPostComment(RESTFrameworkModel):
<add> text = models.TextField()
<add> blog_post = models.ForeignKey(BlogPost)
<ide><path>rest_framework/tests/serializer.py
<ide> def test_create_overriding_default(self):
<ide> self.assertEquals(len(self.objects.all()), 1)
<ide> self.assertEquals(instance.pk, 1)
<ide> self.assertEquals(instance.text, 'overridden')
<add>
<add>
<add>class ManyRelatedTests(TestCase):
<add> def setUp(self):
<add>
<add> class BlogPostCommentSerializer(serializers.Serializer):
<add> text = serializers.CharField()
<add>
<add> class BlogPostSerializer(serializers.Serializer):
<add> title = serializers.CharField()
<add> comments = BlogPostCommentSerializer(source='blogpostcomment_set')
<add>
<add> self.serializer_class = BlogPostSerializer
<add>
<add> def test_reverse_relations(self):
<add> post = BlogPost.objects.create(title="Test blog post")
<add> post.blogpostcomment_set.create(text="I hate this blog post")
<add> post.blogpostcomment_set.create(text="I love this blog post")
<add>
<add> serializer = self.serializer_class(instance=post)
<add> expected = {
<add> 'title': 'Test blog post',
<add> 'comments': [
<add> {'text': 'I hate this blog post'},
<add> {'text': 'I love this blog post'}
<add> ]
<add> }
<add>
<add> self.assertEqual(serializer.data, expected)
| 3
|
Text
|
Text
|
edit governance.md for minor updates
|
f85b6b512b2c50852df24d569794dfc01b56613e
|
<ide><path>GOVERNANCE.md
<ide> See:
<ide> * Participation in working groups
<ide> * Merging pull requests
<ide>
<del>The TSC can remove inactive collaborators or provide them with _Emeritus_
<add>The TSC can remove inactive collaborators or provide them with _emeritus_
<ide> status. Emeriti may request that the TSC restore them to active status.
<ide>
<ide> ## Technical Steering Committee
<ide> Charter need approval by the OpenJS Foundation Cross-Project Council (CPC).
<ide>
<ide> ### TSC meetings
<ide>
<del>The TSC meets in a voice conference call. Each year, the TSC elects a chair to
<del>run the meetings. The TSC streams its meetings for public viewing on YouTube or
<del>a similar service.
<add>The TSC meets in a video conference call. Each year, the TSC elects a chair to
<add>run the meetings. The TSC streams its meetings for public viewing on YouTube.
<ide>
<ide> The TSC agenda includes issues that are at an impasse. The intention of the
<ide> agenda is not to review or approve all patches. Collaborators review and approve
| 1
|
PHP
|
PHP
|
adjust name of configuration value
|
d80b4e7cb067aa100dd47e1185b6ee84812ad224
|
<ide><path>config/logging.php
<ide> 'channels' => [
<ide> 'stack' => [
<ide> 'driver' => 'stack',
<del> 'lenient' => false,
<ide> 'channels' => ['daily'],
<add> 'ignore_exceptions' => false,
<ide> ],
<ide>
<ide> 'single' => [
| 1
|
Ruby
|
Ruby
|
add platform.variant on linux only
|
244cacf1c4593d47a3d27a46b9a91ade161ae557
|
<ide><path>Library/Homebrew/github_packages.rb
<ide> def upload_bottle(user, token, skopeo, formula_full_name, bottle_hash, dry_run:)
<ide> (tab["built_on"]["glibc_version"] if tab["built_on"].present?) || "2.23"
<ide> end
<ide>
<del> variant = if architecture == "arm64"
<del> "v8"
<del> elsif tab["oldest_cpu_family"]
<del> tab["oldest_cpu_family"]
<del> elsif architecture == "amd64"
<del> if os == "darwin"
<del> Hardware.oldest_cpu(OS::Mac::Version.new(os_version[/macOS ([0-9]+\.[0-9]+)/, 1])).to_s
<del> else
<del> "core2"
<del> end
<del> end
<add> variant = tab["oldest_cpu_family"] || "core2" if os == "linux"
<ide>
<ide> platform_hash = {
<ide> architecture: architecture,
<ide> variant: variant,
<ide> os: os,
<ide> "os.version" => os_version,
<del> }
<add> }.compact
<ide> tar_sha256 = Digest::SHA256.hexdigest(
<ide> Utils.safe_popen_read("gunzip", "--stdout", "--decompress", local_file),
<ide> )
| 1
|
Javascript
|
Javascript
|
improve clarity of ternary tests
|
2a7043fa2327ecb681f306612a96dbf29ec499e7
|
<ide><path>test/ng/parseSpec.js
<ide> describe('parser', function() {
<ide> });
<ide>
<ide> it('should parse ternary', function(){
<del> var f = scope.f = function(){ return true; };
<del> var g = scope.g = function(){ return false; };
<del> var h = scope.h = function(){ return 'asd'; };
<del> var i = scope.i = function(){ return 123; };
<del> var id = scope.id = function(x){ return x; };
<add> var returnTrue = scope.returnTrue = function(){ return true; };
<add> var returnFalse = scope.returnFalse = function(){ return false; };
<add> var returnString = scope.returnString = function(){ return 'asd'; };
<add> var returnInt = scope.returnInt = function(){ return 123; };
<add> var identity = scope.identity = function(x){ return x; };
<ide>
<ide> // Simple.
<ide> expect(scope.$eval('0?0:2')).toEqual(0?0:2);
<ide> describe('parser', function() {
<ide>
<ide> // Precedence with respect to logical operators.
<ide> expect(scope.$eval('0&&1?0:1')).toEqual(0&&1?0:1);
<del> expect(scope.$eval('0&&1?0:1')).toEqual((0&&1)?0:1);
<ide> expect(scope.$eval('1||0?0:0')).toEqual(1||0?0:0);
<del> expect(scope.$eval('1||0?0:0')).toEqual((1||0)?0:0);
<add>
<add> expect(scope.$eval('0?0&&1:2')).toEqual(0?0&&1:2);
<add> expect(scope.$eval('0?1&&1:2')).toEqual(0?1&&1:2);
<add> expect(scope.$eval('0?0||0:1')).toEqual(0?0||0:1);
<add> expect(scope.$eval('0?0||1:2')).toEqual(0?0||1:2);
<add>
<add> expect(scope.$eval('1?0&&1:2')).toEqual(1?0&&1:2);
<add> expect(scope.$eval('1?1&&1:2')).toEqual(1?1&&1:2);
<add> expect(scope.$eval('1?0||0:1')).toEqual(1?0||0:1);
<add> expect(scope.$eval('1?0||1:2')).toEqual(1?0||1:2);
<add>
<add> expect(scope.$eval('0?1:0&&1')).toEqual(0?1:0&&1);
<add> expect(scope.$eval('0?2:1&&1')).toEqual(0?2:1&&1);
<add> expect(scope.$eval('0?1:0||0')).toEqual(0?1:0||0);
<add> expect(scope.$eval('0?2:0||1')).toEqual(0?2:0||1);
<add>
<add> expect(scope.$eval('1?1:0&&1')).toEqual(1?1:0&&1);
<add> expect(scope.$eval('1?2:1&&1')).toEqual(1?2:1&&1);
<add> expect(scope.$eval('1?1:0||0')).toEqual(1?1:0||0);
<add> expect(scope.$eval('1?2:0||1')).toEqual(1?2:0||1);
<ide>
<ide> // Function calls.
<del> expect(scope.$eval('f() ? h() : i()')).toEqual(f() ? h() : i());
<del> expect(scope.$eval('g() ? h() : i()')).toEqual(g() ? h() : i());
<del> expect(scope.$eval('f() ? h() : i()')).toEqual(f() ? h() : i());
<del> expect(scope.$eval('id(g() ? h() : i())')).toEqual(id(g() ? h() : i()));
<add> expect(scope.$eval('returnTrue() ? returnString() : returnInt()')).toEqual(returnTrue() ? returnString() : returnInt());
<add> expect(scope.$eval('returnFalse() ? returnString() : returnInt()')).toEqual(returnFalse() ? returnString() : returnInt());
<add> expect(scope.$eval('returnTrue() ? returnString() : returnInt()')).toEqual(returnTrue() ? returnString() : returnInt());
<add> expect(scope.$eval('identity(returnFalse() ? returnString() : returnInt())')).toEqual(identity(returnFalse() ? returnString() : returnInt()));
<ide> });
<ide>
<ide> it('should parse string', function() {
| 1
|
Javascript
|
Javascript
|
use import statements in test code
|
fac507819f7ab4838f1d8b423d803232be93987d
|
<ide><path>src/adapters/adapter.moment.js
<ide>
<ide> 'use strict';
<ide>
<del>var moment = require('moment');
<del>var adapters = require('../core/core.adapters');
<add>import moment from 'moment';
<add>import adapters from '../core/core.adapters';
<ide>
<del>var FORMATS = {
<add>const FORMATS = {
<ide> datetime: 'MMM D, YYYY, h:mm:ss a',
<ide> millisecond: 'h:mm:ss.SSS a',
<ide> second: 'h:mm:ss a',
<ide><path>src/adapters/index.js
<ide>
<ide> // Built-in moment adapter that we need to keep for backward compatibility
<ide> // https://github.com/chartjs/Chart.js/issues/5542
<del>require('./adapter.moment');
<add>import './adapter.moment';
<ide><path>src/core/core.adapters.js
<ide>
<ide> 'use strict';
<ide>
<del>var helpers = require('../helpers/index');
<add>import helpers from '../helpers';
<ide>
<ide> function abstract() {
<ide> throw new Error(
<ide> DateAdapter.override = function(members) {
<ide> helpers.extend(DateAdapter.prototype, members);
<ide> };
<ide>
<del>module.exports._date = DateAdapter;
<add>export default {
<add> _date: DateAdapter
<add>};
<ide><path>test/fixture.js
<ide>
<ide> 'use strict';
<ide>
<del>var utils = require('./utils');
<add>import utils from './utils';
<ide>
<ide> function readFile(url, callback) {
<ide> var request = new XMLHttpRequest();
<ide> function specsFromFixtures(path) {
<ide> };
<ide> }
<ide>
<del>module.exports = {
<add>export default {
<ide> specs: specsFromFixtures
<ide> };
<del>
<ide><path>test/index.js
<ide> 'use strict';
<ide>
<del>var fixture = require('./fixture');
<del>var Context = require('./context');
<del>var matchers = require('./matchers');
<del>var utils = require('./utils');
<add>import fixture from './fixture';
<add>import Context from './context';
<add>import matchers from './matchers';
<add>import utils from './utils';
<ide>
<ide> (function() {
<ide>
<ide><path>test/matchers.js
<ide> 'use strict';
<ide>
<del>var pixelmatch = require('pixelmatch');
<del>var utils = require('./utils');
<add>import pixelmatch from 'pixelmatch';
<add>import utils from './utils';
<ide>
<ide> function toPercent(value) {
<ide> return Math.round(value * 10000) / 100;
<ide> function toEqualImageData() {
<ide> };
<ide> }
<ide>
<del>module.exports = {
<add>export default {
<ide> toBeCloseToPixel: toBeCloseToPixel,
<ide> toEqualOneOf: toEqualOneOf,
<ide> toBeValidChart: toBeValidChart,
| 6
|
Javascript
|
Javascript
|
fix missing space before parentheses
|
043500fb27ed572f197e81b044518bd159c303e1
|
<ide><path>src/ng/directive/ngPluralize.js
<ide> * other numbers, for example 12, so that instead of showing "12 people are viewing", you can
<ide> * show "a dozen people are viewing".
<ide> *
<del> * You can use a set of closed braces(`{}`) as a placeholder for the number that you want substituted
<add> * You can use a set of closed braces (`{}`) as a placeholder for the number that you want substituted
<ide> * into pluralized strings. In the previous example, Angular will replace `{}` with
<ide> * <span ng-non-bindable>`{{personCount}}`</span>. The closed braces `{}` is a placeholder
<ide> * for <span ng-non-bindable>{{numberExpression}}</span>.
| 1
|
Ruby
|
Ruby
|
ensure message id is present
|
cfb927ce754199e93740e53aee4e6b40acb396c5
|
<ide><path>app/models/action_mailroom/inbound_email.rb
<ide> class ActionMailroom::InboundEmail < ActiveRecord::Base
<ide> has_one_attached :raw_email
<ide> enum status: %i[ pending processing delivered failed bounced ]
<ide>
<add> before_save :generate_missing_message_id
<add>
<ide> class << self
<ide> def create_from_raw_email!(raw_email, **options)
<ide> create! raw_email: raw_email, message_id: extract_message_id(raw_email), **options
<ide> def mail_from_source(source)
<ide> def extract_message_id(raw_email)
<ide> mail_from_source(raw_email.read).message_id
<ide> rescue => e
<del> # TODO: Assign message id if it can't be extracted?
<add> # FIXME: Add logging with "Couldn't extract Message ID, so will generating a new random ID instead"
<ide> end
<ide> end
<ide>
<ide> def mail
<ide> def source
<ide> @source ||= raw_email.download
<ide> end
<add>
<add> private
<add> def generate_missing_message_id
<add> self.message_id ||= Mail::MessageIdField.new.message_id
<add> end
<ide> end
| 1
|
PHP
|
PHP
|
remove alias inspire
|
f663e25b72a7f82b7b19f20230dd6d5bb8792ca4
|
<ide><path>config/app.php
<ide> 'Gate' => Illuminate\Support\Facades\Gate::class,
<ide> 'Hash' => Illuminate\Support\Facades\Hash::class,
<ide> 'Input' => Illuminate\Support\Facades\Input::class,
<del> 'Inspiring' => Illuminate\Foundation\Inspiring::class,
<ide> 'Lang' => Illuminate\Support\Facades\Lang::class,
<ide> 'Log' => Illuminate\Support\Facades\Log::class,
<ide> 'Mail' => Illuminate\Support\Facades\Mail::class,
| 1
|
Text
|
Text
|
add arm64 macos as experimental
|
62a56264f618239479088d59e532828d46adccf0
|
<ide><path>BUILDING.md
<ide> platforms. This is true regardless of entries in the table below.
<ide> | Windows | x64, x86 | Windows Server 2012 (not R2) | Experimental | |
<ide> | Windows | arm64 | >= Windows 10 | Tier 2 (compiling) / Experimental (running) | |
<ide> | macOS | x64 | >= 10.13 | Tier 1 | |
<add>| macOS | arm64 | >= 11 | Experimental | |
<ide> | SmartOS | x64 | >= 18 | Tier 2 | |
<ide> | AIX | ppc64be >=power7 | >= 7.2 TL02 | Tier 2 | |
<ide> | FreeBSD | x64 | >= 11 | Experimental | Downgraded as of Node.js 12 <sup>[7](#fn7)</sup> |
| 1
|
Text
|
Text
|
update api docs for architectures
|
7ed8f4504bc5a64f3c8afb8c2003b0ba92254d3c
|
<ide><path>website/docs/api/architectures.md
<ide> Instead of defining its own `Tok2Vec` instance, a model architecture like
<ide> [Tagger](/api/architectures#tagger) can define a listener as its `tok2vec`
<ide> argument that connects to the shared `tok2vec` component in the pipeline.
<ide>
<del><!-- TODO: return type -->
<del>
<ide> | Name | Description |
<ide> | ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
<ide> | `width` | The width of the vectors produced by the "upstream" [`Tok2Vec`](/api/tok2vec) component. ~~int~~ |
<ide> | `upstream` | A string to identify the "upstream" `Tok2Vec` component to communicate with. The upstream name should either be the wildcard string `"*"`, or the name of the `Tok2Vec` component. You'll almost never have multiple upstream `Tok2Vec` components, so the wildcard string will almost always be fine. ~~str~~ |
<del>| **CREATES** | The model using the architecture. ~~Model~~ |
<add>| **CREATES** | The model using the architecture. ~~Model[List[Doc], List[Floats2d]]~~ |
<ide>
<ide> ### spacy.MultiHashEmbed.v1 {#MultiHashEmbed}
<ide>
<ide> definitions depending on the `Vocab` of the `Doc` object passed in. Vectors from
<ide> pretrained static vectors can also be incorporated into the concatenated
<ide> representation.
<ide>
<del><!-- TODO: model return type -->
<del>
<ide> | Name | Description |
<ide> | ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
<ide> | `width` | The output width. Also used as the width of the embedding tables. Recommended values are between `64` and `300`. ~~int~~ |
<ide> | `rows` | The number of rows for the embedding tables. Can be low, due to the hashing trick. Embeddings for prefix, suffix and word shape use half as many rows. Recommended values are between `2000` and `10000`. ~~int~~ |
<ide> | `also_embed_subwords` | Whether to use the `PREFIX`, `SUFFIX` and `SHAPE` features in the embeddings. If not using these, you may need more rows in your hash embeddings, as there will be increased chance of collisions. ~~bool~~ |
<ide> | `also_use_static_vectors` | Whether to also use static word vectors. Requires a vectors table to be loaded in the [Doc](/api/doc) objects' vocab. ~~bool~~ |
<del>| **CREATES** | The model using the architecture. ~~Model~~ |
<add>| **CREATES** | The model using the architecture. ~~Model[List[Doc], List[Floats2d]]~~ |
<ide>
<ide> ### spacy.CharacterEmbed.v1 {#CharacterEmbed}
<ide>
<ide> concatenated. A hash-embedded vector of the `NORM` of the word is also
<ide> concatenated on, and the result is then passed through a feed-forward network to
<ide> construct a single vector to represent the information.
<ide>
<del><!-- TODO: model return type -->
<del>
<ide> | Name | Description |
<ide> | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
<ide> | `width` | The width of the output vector and the `NORM` hash embedding. ~~int~~ |
<ide> | `rows` | The number of rows in the `NORM` hash embedding table. ~~int~~ |
<ide> | `nM` | The dimensionality of the character embeddings. Recommended values are between `16` and `64`. ~~int~~ |
<ide> | `nC` | The number of UTF-8 bytes to embed per word. Recommended values are between `3` and `8`, although it may depend on the length of words in the language. ~~int~~ |
<del>| **CREATES** | The model using the architecture. ~~Model~~ |
<add>| **CREATES** | The model using the architecture. ~~Model[List[Doc], List[Floats2d]]~~ |
<ide>
<ide> ### spacy.MaxoutWindowEncoder.v1 {#MaxoutWindowEncoder}
<ide>
<ide> Embed [`Doc`](/api/doc) objects with their vocab's vectors table, applying a
<ide> learned linear projection to control the dimensionality. See the documentation
<ide> on [static vectors](/usage/embeddings-transformers#static-vectors) for details.
<ide>
<del><!-- TODO: document argument descriptions -->
<del>
<ide> | Name | Description |
<ide> | ----------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
<del>| `nO` | Defaults to `None`. ~~Optional[int]~~ |
<del>| `nM` | Defaults to `None`. ~~Optional[int]~~ |
<add>| `nO` | The output width of the layer, after the linear projection. ~~Optional[int]~~ |
<add>| `nM` | The width of the static vectors. ~~Optional[int]~~ |
<ide> | `dropout` | Optional dropout rate. If set, it's applied per dimension over the whole batch. Defaults to `None`. ~~Optional[float]~~ |
<ide> | `init_W` | The [initialization function](https://thinc.ai/docs/api-initializers). Defaults to [`glorot_uniform_init`](https://thinc.ai/docs/api-initializers#glorot_uniform_init). ~~Callable[[Ops, Tuple[int, ...]]], FloatsXd]~~ |
<ide> | `key_attr` | Defaults to `"ORTH"`. ~~str~~ |
<ide> architectures into your training config.
<ide> > stride = 96
<ide> > ```
<ide>
<del><!-- TODO: description -->
<add>Load and wrap a transformer model from the Huggingface transformers library.
<add>You can any transformer that has pretrained weights and a PyTorch
<add>implementation. The `name` variable is passed through to the underlying
<add>library, so it can be either a string or a path. If it's a string, the
<add>pretrained weights will be downloaded via the transformers library if they are
<add>not already available locally.
<add>
<add>In order to support longer documents, the `TransformerModel` layer allows you
<add>to pass in a `get_spans` function that will divide up the `Doc` objects before
<add>passing them through the transformer. Your spans are allowed to overlap or
<add>exclude tokens.
<add>
<add>This layer outputs a `FullTransformerBatch` dataclass. In order to plug the
<add>layer into most architectures, you'll probably need to map the raw transformer
<add>output to token-aligned vectors using a layer such as `trfs2arrays`.
<add>
<ide>
<ide> | Name | Description |
<ide> | ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
<ide> specific data and challenge.
<ide> Stacked ensemble of a bag-of-words model and a neural network model. The neural
<ide> network has an internal CNN Tok2Vec layer and uses attention.
<ide>
<del><!-- TODO: model return type -->
<del>
<ide> | Name | Description |
<ide> | -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
<ide> | `exclusive_classes` | Whether or not categories are mutually exclusive. ~~bool~~ |
<ide> network has an internal CNN Tok2Vec layer and uses attention.
<ide> | `ngram_size` | Determines the maximum length of the n-grams in the BOW model. For instance, `ngram_size=3`would give unigram, trigram and bigram features. ~~int~~ |
<ide> | `dropout` | The dropout rate. ~~float~~ |
<ide> | `nO` | Output dimension, determined by the number of different labels. If not set, the [`TextCategorizer`](/api/textcategorizer) component will set it when `begin_training` is called. ~~Optional[int]~~ |
<del>| **CREATES** | The model using the architecture. ~~Model~~ |
<add>| **CREATES** | The model using the architecture. ~~Model[List[Doc], Floats2d]~~ |
<ide>
<ide> ### spacy.TextCatCNN.v1 {#TextCatCNN}
<ide>
<ide> A neural network model where token vectors are calculated using a CNN. The
<ide> vectors are mean pooled and used as features in a feed-forward network. This
<ide> architecture is usually less accurate than the ensemble, but runs faster.
<ide>
<del><!-- TODO: model return type -->
<del>
<ide> | Name | Description |
<ide> | ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
<ide> | `exclusive_classes` | Whether or not categories are mutually exclusive. ~~bool~~ |
<ide> | `tok2vec` | The [`tok2vec`](#tok2vec) layer of the model. ~~Model~~ |
<ide> | `nO` | Output dimension, determined by the number of different labels. If not set, the [`TextCategorizer`](/api/textcategorizer) component will set it when `begin_training` is called. ~~Optional[int]~~ |
<del>| **CREATES** | The model using the architecture. ~~Model~~ |
<add>| **CREATES** | The model using the architecture. ~~Model[List[Doc], Floats2d]~~ |
<ide>
<ide> ### spacy.TextCatBOW.v1 {#TextCatBOW}
<ide>
<ide> architecture is usually less accurate than the ensemble, but runs faster.
<ide> An ngram "bag-of-words" model. This architecture should run much faster than the
<ide> others, but may not be as accurate, especially if texts are short.
<ide>
<del><!-- TODO: model return type -->
<del>
<ide> | Name | Description |
<ide> | ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
<ide> | `exclusive_classes` | Whether or not categories are mutually exclusive. ~~bool~~ |
<ide> | `ngram_size` | Determines the maximum length of the n-grams in the BOW model. For instance, `ngram_size=3`would give unigram, trigram and bigram features. ~~int~~ |
<ide> | `no_output_layer` | Whether or not to add an output layer to the model (`Softmax` activation if `exclusive_classes` is `True`, else `Logistic`. ~~bool~~ |
<ide> | `nO` | Output dimension, determined by the number of different labels. If not set, the [`TextCategorizer`](/api/textcategorizer) component will set it when `begin_training` is called. ~~Optional[int]~~ |
<del>| **CREATES** | The model using the architecture. ~~Model~~ |
<add>| **CREATES** | The model using the architecture. ~~Model[List[Doc], Floats2d]~~ |
<ide>
<ide> ## Entity linking architectures {#entitylinker source="spacy/ml/models/entity_linker.py"}
<ide>
<ide> into the "real world". This requires 3 main components:
<ide> The `EntityLinker` model architecture is a Thinc `Model` with a
<ide> [`Linear`](https://thinc.ai/api-layers#linear) output layer.
<ide>
<del><!-- TODO: model return type -->
<del>
<ide> | Name | Description |
<ide> | ----------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
<ide> | `tok2vec` | The [`tok2vec`](#tok2vec) layer of the model. ~~Model~~ |
<ide> | `nO` | Output dimension, determined by the length of the vectors encoding each entity in the KB. If the `nO` dimension is not set, the entity linking component will set it when `begin_training` is called. ~~Optional[int]~~ |
<del>| **CREATES** | The model using the architecture. ~~Model~~ |
<add>| **CREATES** | The model using the architecture. ~~Model[List[Doc], Floats2d]~~ |
<ide>
<ide> ### spacy.EmptyKB.v1 {#EmptyKB}
<ide>
| 1
|
Javascript
|
Javascript
|
add text destructuring to example
|
774757d628cac1157a36c48204fc4d76facb6c5b
|
<ide><path>website/src/react-native/index.js
<ide> var App = React.createClass({
<ide> {`// Android
<ide>
<ide> var React = require('react-native');
<del>var { DrawerLayoutAndroid, ProgressBarAndroid } = React;
<add>var { DrawerLayoutAndroid, ProgressBarAndroid, Text } = React;
<ide>
<ide> var App = React.createClass({
<ide> render: function() {
| 1
|
Javascript
|
Javascript
|
treat pointer events like mouse events,
|
e06f428f6ed99e0fafb2e21c456eafc570e3e5ba
|
<ide><path>src/event.js
<ide> define([
<ide>
<ide> var
<ide> rkeyEvent = /^key/,
<del> rmouseEvent = /^(?:mouse|contextmenu)|click/,
<add> rmouseEvent = /^(?:mouse|pointer|contextmenu)|click/,
<ide> rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
<ide> rtypenamespace = /^([^.]*)(?:\.(.+)|)$/;
<ide>
<ide> jQuery.Event.prototype = {
<ide> // Support: Chrome 15+
<ide> jQuery.each({
<ide> mouseenter: "mouseover",
<del> mouseleave: "mouseout"
<add> mouseleave: "mouseout",
<add> pointerenter: "pointerover",
<add> pointerleave: "pointerout"
<ide> }, function( orig, fix ) {
<ide> jQuery.event.special[ orig ] = {
<ide> delegateType: fix,
| 1
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.