summaryrefslogtreecommitdiff
path: root/lib/psych/visitors/yaml_tree.rb
AgeCommit message (Collapse)Author
2021-05-19Implement YAML.safe_dump to make safe_load more usable.Jean Boussier
In case where Psych is used as a two way serializers, e.g. to serialize some cache or config, it is preferable to have the same restrictions on both load and dump. Otherwise you might dump and persist some objects payloads that you later won't be able to read.
2021-02-07feat: allow scalars and sequences to be styled when dumpedJeremy Ebler
2020-12-23[ruby/psych] Optimize cache with `compare_by_identity`Marc-Andre Lafortune
Using `compare_by_identity` gives a 4x performance boost on cache hits. Benchmark in https://github.com/JuanitoFatas/fast-ruby/issues/189
2020-07-16Remove private_iv_getCharles Oliver Nutter
The only remaining use of this function was to get the internal message object from an exception's hidden `mesg` instance variable to allow it to be dumped wiithout converting to a string. As discussed in #103, this exposes internal implementation details of CRuby, and ultimately does not provide any real utility to the user since they can't directly inspect this hidden variable. The test change here is to reflect CRuby behavior that denies equality if the internal message objects do not match, as is the case after the exception has been loaded and now has a simple String value. The impact to users is that exceptions with special hidden message objects will convert those objects to String during marshaling through YAML. I believe this only affects NameError and its descendants, since users can't set this field directly on their own exception types. Fixes #103.
2019-01-16Dump Hash ivars before elementsAaron Patterson
When the Hash is revived, the ivars will be set before elements. This is for the case when the hash setter depends on ivars set on the hash.
2019-01-09Round trip exception backtracesAaron Patterson
This commit allows exception backtraces to round trip
2019-01-09Refactor exception dumpingAaron Patterson
2019-01-09Dumping the backtrace never worked, so remove itAaron Patterson
Dumping the backtrace for exceptions never worked, so lets remove it.
2017-11-29Revert "Double quote stings that contain single quotes only"SHIBATA Hiroshi
2017-07-21Double quote stings that contain single quotes onlyWolfgang Teuber
Fixes #324
2017-06-30Merge branch 'master' into frozenSHIBATA Hiroshi
2017-06-29Support enumerator objectsAaron Patterson
Fixes #277
2017-06-29Rely on encoding tags to determine if string should be dumped as binaryAaron Patterson
If a string is tagged as binary, then we should dump it as binary. Fixes #278
2017-06-19make frozen_string_literal: trueSHIBATA Hiroshi
2017-06-16Merge pull request #158 from laserlemon/delegatorsSHIBATA Hiroshi
Enable YAML serialization of Ruby delegators
2017-03-27Fixed gabage linesSHIBATA Hiroshi
2017-03-27Removed to_yaml support on YAMLTreeSHIBATA Hiroshi
2017-03-27Removed override methodSHIBATA Hiroshi
2017-03-27Remove to_yaml_propatiesSHIBATA Hiroshi
2017-03-07Removed annotation for syck/rubytypes.rbSHIBATA Hiroshi
2016-06-24Merge pull request #270 from tenderlove/issue-11988SHIBATA Hiroshi
Support YAML 1.2 Core Schema
2016-02-23avoid extra calls to eliminate "\n" from Base64SHIBATA Hiroshi
ref. https://github.com/ruby/ruby/commit/778bbac8ac2ae50f0987c4888f7158296ee5bbdd
2016-02-23Temporary disabled to frozen literal string.SHIBATA Hiroshi
ref. https://github.com/ruby/ruby/commit/3e92b635fb5422207b7bbdc924e292e51e21f040
2016-02-09Support YAML 1.2 Core Schema. Addressed https://bugs.ruby-lang.org/issues/11988SHIBATA Hiroshi
2015-11-14Fixes line_width: -1 handling #254Gleb Mazovetskiy
libyaml understands -1 as unlimited: https://github.com/tenderlove/psych/blob/master/ext/psych/yaml/yaml.h#L1864 Raises on other negative values.
2015-08-27removed Ruby 1.9 supportSHIBATA Hiroshi
2015-07-10Fix omap to be !!omap instead of !omapJoseph Bisch
Fixes #241
2015-02-06* ext/psych/lib/psych/visitors/yaml_tree.rb: register nodes whenAaron Patterson
dumping objects with custom coders. [ruby-core:66215] [Bug #10496] * test/psych/test_coder.rb: test for fix
2015-01-17Fix anchorNobuyoshi Nakada
Anchors like `\Z` are not valid inside character class. Use negative-lookahead instead.
2015-01-15Only dump ivars for subclasses of String, not for String.Joe Eli McIlvain
With cf0dd2b93f1552a3c452a0bfa0e996f441d5e27e, fixes #217.
2015-01-15Only dump ivars for subclasses of Hash, not for Hash.Joe Eli McIlvain
Fixes #216. Fixes part of #217.
2015-01-13Fix block chomping and add more testsJakub Jirutka
When no [chomping indicator][1] is specified for a folded or literal block, then YAML parser should preserve the final line break (i.e. the string should end with \n). This implies that when dumping a string *without* the trailing newline to YAML, we should specify the stripping indicator (-). [1]: http://yaml.org/spec/1.2/2009-07-21/spec.html#id2593651
2015-01-12Preset @line_width in YAMLTree#initialize for better performanceJakub Jirutka
2015-01-12Use appropriate style for serialized stringsJakub Jirutka
When psych parses YAML with string in the folded style as: a: > some inline content and serializes it back to YAML, then it renders the string in the literal style instead: a: | some inline content This patch fixes this behaviour. When a string doesn't contain newlines (blank line at the end is ignored) and it's not necessary to be quoted, then it will use plain style or folded style according to its length and the `line_width` option. # line_width = 100 a: some inline content # line_width = 11 a: > some inline content This change was originally proposed by @Iazel.
2015-01-12Remove unnnecessary 'str' variable in YAMLTree#visit_StringJakub Jirutka
2015-01-08Merge branch 'master' into jirutka-patch-1Aaron Patterson
* master: (21 commits) * ext/psych/lib/psych/visitors/to_ruby.rb: call `allocate` on hash subclasses. Fixes github.com/tenderlove/psych/issues/196 * ext/psych/lib/psych/visitors/to_ruby.rb: revive hashes with ivars removed isolate task removed isolate plugin added minitest dependency into gemspec added install task into travis added ruby-head env bumping version to 2.0.8 fixed build error caused by trunk changes bumping version to 2.0.7 merging from ruby trunk backport r48512 from ruby/ruby trunk. Add changelog for 2a4d9568f7d5d19c00231cf48eb855cc45ec3394 backport r48214 from ruby/ruby trunk. Allow dumping any BasicObject that defines #marshal_dump or #marshal_load bumping version * ext/psych/lib/psych/visitors/yaml_tree.rb: fix NameError dumping and loading. Fixes GH #85. Thanks @brentdax for the patch! * test/psych/test_exception.rb: test for fix * ext/psych/lib/psych/scalar_scanner.rb: fix loading strings that look like integers but have a newline. Fixes GH #189 * test/psych/test_string.rb: test for fix * ext/psych/lib/psych/visitors/to_ruby.rb: merge keys with a hash should merge the hash in to the parent. * test/psych/test_merge_keys.rb: test for change. Fixes GH #202 * ext/psych/lib/psych/visitors/to_ruby.rb: quoted "<<" strings should not be treated as merge keys. * ext/psych/lib/psych/visitors/yaml_tree.rb: hashes with keys containing "<<" should roundtrip. * test/psych/test_merge_keys.rb: test for change. Fixes GH #203 ... Conflicts: lib/psych/visitors/yaml_tree.rb
2015-01-08* ext/psych/lib/psych/visitors/to_ruby.rb: revive hashes with ivarsAaron Patterson
* ext/psych/lib/psych/visitors/yaml_tree.rb: dump hashes with ivars. Fixes github.com/psych/issues/43 * test/psych/test_hash.rb: test for change fixes #43
2014-09-17Allow dumping any BasicObject that defines #marshal_dump or #marshal_loadSean Griffin
Additionally, it is assumed that these objects will have implemented `respond_to?` and `class`, (e.g. SimpleDelegator). These assumptions are reasonably inline with the assumptions of `Marshal` in regards to `BasicObject`s.
2014-08-29* ext/psych/lib/psych/visitors/yaml_tree.rb: fix NameError dumping andAaron Patterson
loading. Fixes GH #85. Thanks @brentdax for the patch! * test/psych/test_exception.rb: test for fix fixes #85
2014-08-29* ext/psych/lib/psych/visitors/to_ruby.rb: quoted "<<" stringsAaron Patterson
should not be treated as merge keys. * ext/psych/lib/psych/visitors/yaml_tree.rb: hashes with keys containing "<<" should roundtrip. * test/psych/test_merge_keys.rb: test for change. Fixes GH #203 fixes #203
2014-08-16Don't quote scalar values beginning with non-ASCII characterJakub Jirutka
2014-08-06Retain reference to target in Registrar so a GC run can't confuse ongoing ↵Mark J. Titorenko
serialization.
2014-06-05* ext/psych/lib/psych/visitors/yaml_tree.rb: dump empty symbols with aAaron Patterson
tag so that they can be parsed on input. [Bug #9873] [ruby-core:62825] * test/psych/test_symbol.rb: test for change
2014-02-28 * ext/psych/lib/psych/visitors/yaml_tree.rb: support dumping EncodingAaron Patterson
objects. * ext/psych/lib/psych/visitors/to_ruby.rb: support loading Encoding objects. * test/psych/test_encoding.rb: add test * ext/psych/lib/psych.rb: add version
2014-01-08* ext/psych/lib/psych/visitors/yaml_tree.rb: dumping strings withAaron Patterson
quotes should not have changed. [ruby-core:59316] [Bug #9300] * ext/psych/lib/psych.rb: fixed missing require. * test/psych/test_string.rb: test
2013-11-26Enable YAML serialization of Ruby delegators and simple delegatorsSteve Richert
2013-11-26fix support for negative years.Aaron Patterson
Fixes #168
2013-10-29* ext/psych/lib/psych/visitors/yaml_tree.rb: make less garbage whenAaron Patterson
testing if a string is binary.
2013-10-29* ext/psych/lib/psych/visitors/yaml_tree.rb: string subclasses shouldAaron Patterson
not be considered to be binary. Fixes Psych / GH 166 https://github.com/tenderlove/psych/issues/166 * test/psych/test_string.rb: test for fix Fixes #166
2013-09-05* ext/psych/lib/psych/visitors/yaml_tree.rb: use double quotes whenAaron Patterson
strings start with special characters. [Fixes GH-157] https://github.com/tenderlove/psych/issues/157 * test/psych/test_string.rb: test for change. Fixes #157