marshal-md 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 850fa2bae403ca2746a23669fb64fa5e973382c129059ee3fc34558b087a2f19
4
+ data.tar.gz: '0629489b93629f8482810a86c531bd6cedb762afd67f832fafd9995db32d9d74'
5
+ SHA512:
6
+ metadata.gz: 7b838189a18a72980b67269d42a9ca370782a83310b7710df36a770f9835538048e1a2812c41073d0b805c9f938667d5e618b2eff685a96f25c4465592766e3d
7
+ data.tar.gz: d2bd6363ba5ad25ac96d013242cb0d16cf4ed70238d02a2e98bf51e3ccfc16a67b6f835f91a5392c42db226b81bdbba0587e64b807124ef25e12ef834802ff55
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 twokidsCarl
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,148 @@
1
+ # marshal-md
2
+
3
+ Human-readable Ruby Marshal alternative. Serializes Ruby objects to Markdown format with full round-trip fidelity.
4
+
5
+ ## Why?
6
+
7
+ Ruby's `Marshal.dump` produces opaque binary. `marshal-md` produces readable, diff-friendly text while maintaining the same API and behavior.
8
+
9
+ ```
10
+ Marshal.dump({name: "Alice", age: 30})
11
+ # => "\x04\b{\a:\tname\"\nAlice:\bage\x1Ei\x23"
12
+
13
+ MarshalMd.dump({name: "Alice", age: 30})
14
+ # => {name: "Alice", age: 30} (Hash)
15
+ ```
16
+
17
+ ## Install
18
+
19
+ ```ruby
20
+ gem "marshal-md"
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ API is symmetric with Ruby's `Marshal`:
26
+
27
+ ```ruby
28
+ require "marshal-md"
29
+
30
+ # Dump
31
+ md = MarshalMd.dump(obj) # => Markdown string
32
+ MarshalMd.dump(obj, io) # write to IO
33
+
34
+ # Load
35
+ obj = MarshalMd.load(md) # from string
36
+ obj = MarshalMd.load(io) # from IO
37
+ ```
38
+
39
+ ## Format
40
+
41
+ ### Scalars
42
+
43
+ ```
44
+ 42 (Integer)
45
+ 3.14 (Float)
46
+ "hello world" (String)
47
+ true (Boolean)
48
+ nil (NilClass)
49
+ :foo (Symbol)
50
+ ```
51
+
52
+ ### Collections
53
+
54
+ ```
55
+ [1, "two", 3.0] (Array)
56
+ {name: "Alice", age: 30} (Hash)
57
+ 1..10 (Range)
58
+ /^\d+$/ (Regexp)
59
+ 2026-04-03 10:30:00.000000 +0800 (Time)
60
+ ```
61
+
62
+ ### Objects
63
+
64
+ ```
65
+ #<Email> (Email)
66
+ @subject: "URGENT: Server down"
67
+ @body: "Database connection pool exhausted"
68
+ @priority: "high"
69
+ ```
70
+
71
+ ### Nested structures
72
+
73
+ ```
74
+ #<User> (User)
75
+ @name: "Alice"
76
+ @scores: [85, 92, 78] (Array)
77
+ @address:
78
+ #<Address> (Address)
79
+ @city: "Tokyo"
80
+ @zip: "100-0001"
81
+ ```
82
+
83
+ ### References and circular references
84
+
85
+ ```
86
+ &obj_1 [1, 2, 3] (Array)
87
+ *obj_1 (ref)
88
+ ```
89
+
90
+ Circular:
91
+ ```
92
+ &obj_1 (Array)
93
+ 1 (Integer)
94
+ *obj_1 (ref)
95
+ ```
96
+
97
+ ### Binary data
98
+
99
+ ```
100
+ base64:iVBORw0KGgo... (String, ASCII-8BIT, 4096 bytes)
101
+ ```
102
+
103
+ ## Monkey-patch mode
104
+
105
+ Drop-in replacement for `Marshal`:
106
+
107
+ ```ruby
108
+ require "marshal-md/patch"
109
+
110
+ Marshal.dump(obj) # => Markdown (not binary)
111
+ Marshal.load(md) # auto-detects format
112
+
113
+ # Binary still available
114
+ Marshal.binary_dump(obj)
115
+ Marshal.binary_load(data)
116
+ ```
117
+
118
+ Format detection: binary Marshal starts with `\x04\x08`. Everything else is treated as Markdown.
119
+
120
+ ## Compatibility
121
+
122
+ Passes the CRuby official `Marshal` test suite (52 tests, 464 assertions).
123
+
124
+ Supported types:
125
+ - All primitives: Integer, Float, String, Symbol, true, false, nil
126
+ - Collections: Array, Hash, Range, Regexp, Time, Struct
127
+ - Numeric: Complex, Rational
128
+ - Custom objects: instance variables, `marshal_dump`/`marshal_load`, `_dump`/`_load`
129
+ - Subclassed built-in types
130
+ - Module extensions (`extend`, `prepend`)
131
+ - Shared and circular references
132
+ - Class/Module references
133
+
134
+ Unsupported (same as `Marshal`):
135
+ - Proc / Lambda
136
+ - IO / File
137
+ - Thread / Fiber
138
+ - Binding
139
+ - Method / UnboundMethod
140
+
141
+ ## Requirements
142
+
143
+ - Ruby >= 2.5
144
+ - Zero runtime dependencies
145
+
146
+ ## License
147
+
148
+ MIT