psych-pure 0.1.4 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -1
- data/lib/psych/pure/version.rb +1 -1
- data/lib/psych/pure.rb +35 -7
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3b495922e35ffc07633da357273f8df93cc949fff0582eb5d6bf6d05c1e3ea19
|
|
4
|
+
data.tar.gz: 4a42f95af624a0712a49ea6dddd3ab5d0e382f65fb48a4d5a6e8fcbdf0195f39
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fd5c511ad9ba206d9d7f012a80cb0924c07f3b9b0b0e860d296404ec7b4a39a5bc5cd1391ae207e213ba4b19d197dc341550bab944a4c384164e30021fdde9d0
|
|
7
|
+
data.tar.gz: 92bbc9e614dbd526792c45dca5cb1e5b38e463f2def07e47bc8b419f97236dce6823ef6b2303036a8db59c755e463e34a47254052b36688a3eb9824062043830
|
data/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.2.0] - 2025-11-11
|
|
10
|
+
|
|
11
|
+
- Add `sequence_indent` option to `Psych::Pure.dump` to control whether sequence elements contained within mapping elements are indented.
|
|
12
|
+
- Properly handle mutation methods on loaded objects that mutate in place.
|
|
13
|
+
|
|
9
14
|
## [0.1.4] - 2025-11-10
|
|
10
15
|
|
|
11
16
|
- Fix up comment handling preceding sequence elements.
|
|
@@ -37,7 +42,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
|
|
|
37
42
|
|
|
38
43
|
- 🎉 Initial release. 🎉
|
|
39
44
|
|
|
40
|
-
[unreleased]: https://github.com/kddnewton/psych-pure/compare/v0.
|
|
45
|
+
[unreleased]: https://github.com/kddnewton/psych-pure/compare/v0.2.0...HEAD
|
|
46
|
+
[0.2.0]: https://github.com/kddnewton/psych-pure/compare/v0.1.4...v0.2.0
|
|
47
|
+
[0.1.4]: https://github.com/kddnewton/psych-pure/compare/v0.1.3...v0.1.4
|
|
41
48
|
[0.1.3]: https://github.com/kddnewton/psych-pure/compare/v0.1.2...v0.1.3
|
|
42
49
|
[0.1.2]: https://github.com/kddnewton/psych-pure/compare/v0.1.1...v0.1.2
|
|
43
50
|
[0.1.1]: https://github.com/kddnewton/psych-pure/compare/v0.1.0...v0.1.1
|
data/lib/psych/pure/version.rb
CHANGED
data/lib/psych/pure.rb
CHANGED
|
@@ -201,15 +201,37 @@ module Psych
|
|
|
201
201
|
# rely on the source formatting, and need to format it ourselves.
|
|
202
202
|
attr_reader :dirty
|
|
203
203
|
|
|
204
|
-
def initialize(object, psych_node
|
|
204
|
+
def initialize(object, psych_node)
|
|
205
205
|
super(object)
|
|
206
206
|
@psych_node = psych_node
|
|
207
|
-
@dirty =
|
|
207
|
+
@dirty = false
|
|
208
208
|
end
|
|
209
209
|
|
|
210
|
-
def
|
|
211
|
-
|
|
212
|
-
@
|
|
210
|
+
def initialize_clone(obj, freeze: nil)
|
|
211
|
+
super
|
|
212
|
+
@psych_node = obj.psych_node.dup
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
def initialize_dup(obj)
|
|
216
|
+
super
|
|
217
|
+
@psych_node = obj.psych_node.dup
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
# Effectively implement the same method_missing as SimpleDelegator, but
|
|
221
|
+
# additionally track whether or not the object has been mutated.
|
|
222
|
+
ruby2_keywords def method_missing(name, *args, &block)
|
|
223
|
+
takes_block = false
|
|
224
|
+
target = self.__getobj__ { takes_block = true }
|
|
225
|
+
|
|
226
|
+
if !takes_block && target_respond_to?(target, name, false)
|
|
227
|
+
previous = target.dup
|
|
228
|
+
result = target.__send__(name, *args, &block)
|
|
229
|
+
|
|
230
|
+
@dirty = true unless previous.eql?(target)
|
|
231
|
+
result
|
|
232
|
+
else
|
|
233
|
+
super(name, *args, &block)
|
|
234
|
+
end
|
|
213
235
|
end
|
|
214
236
|
end
|
|
215
237
|
|
|
@@ -3559,8 +3581,9 @@ module Psych
|
|
|
3559
3581
|
# The visitor is responsible for walking the tree and generating the YAML
|
|
3560
3582
|
# output.
|
|
3561
3583
|
class Visitor
|
|
3562
|
-
def initialize(q)
|
|
3584
|
+
def initialize(q, sequence_indent: false)
|
|
3563
3585
|
@q = q
|
|
3586
|
+
@sequence_indent = sequence_indent
|
|
3564
3587
|
end
|
|
3565
3588
|
|
|
3566
3589
|
# Visit an AliasNode.
|
|
@@ -3777,6 +3800,11 @@ module Psych
|
|
|
3777
3800
|
elsif inlined || value.anchor || value.tag || value.value.empty?
|
|
3778
3801
|
@q.text(" ")
|
|
3779
3802
|
@q.nest(2) { visit(value) }
|
|
3803
|
+
elsif @sequence_indent
|
|
3804
|
+
@q.nest(2) do
|
|
3805
|
+
@q.breakable
|
|
3806
|
+
visit(value)
|
|
3807
|
+
end
|
|
3780
3808
|
else
|
|
3781
3809
|
@q.breakable
|
|
3782
3810
|
visit(value)
|
|
@@ -4006,7 +4034,7 @@ module Psych
|
|
|
4006
4034
|
q.text(" ")
|
|
4007
4035
|
end
|
|
4008
4036
|
|
|
4009
|
-
node.accept(Visitor.new(q))
|
|
4037
|
+
node.accept(Visitor.new(q, sequence_indent: @options.fetch(:sequence_indent, false)))
|
|
4010
4038
|
q.breakable
|
|
4011
4039
|
q.current_group.break
|
|
4012
4040
|
q.flush
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: psych-pure
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Kevin Newton
|
|
@@ -113,7 +113,7 @@ licenses:
|
|
|
113
113
|
- MIT
|
|
114
114
|
metadata:
|
|
115
115
|
bug_tracker_uri: https://github.com/kddnewton/psych-pure/issues
|
|
116
|
-
changelog_uri: https://github.com/kddnewton/psych-pure/blob/v0.
|
|
116
|
+
changelog_uri: https://github.com/kddnewton/psych-pure/blob/v0.2.0/CHANGELOG.md
|
|
117
117
|
source_code_uri: https://github.com/kddnewton/psych-pure
|
|
118
118
|
rubygems_mfa_required: 'true'
|
|
119
119
|
post_install_message:
|