dms-parser 0.5.0 → 0.5.1

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +78 -6
  3. data/bin/dms-encoder +22 -3
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8c14f1d20d52d7187a1d070cd97a73489c7ecf26d33f36e1b7caec2800e5ebf7
4
- data.tar.gz: c23cd13f0f751281b72245f2ae5c4193b705c44ffc7154208146d2af06535bfd
3
+ metadata.gz: 9ff6c29cfa7778eda9199a9b532ea2af36616977b1f4d839c39b7a6816e61b9c
4
+ data.tar.gz: '0049b496c4f68647eaf9078bdba8e165b67d049e51c194f9119142bc5e3e9769'
5
5
  SHA512:
6
- metadata.gz: e54215e05be86f064095579e879b0a45518b2b221dfea42d0c2314bce3f45863ba2be8098f460ebd82acd5e1387339b280ddb7718271f3f3fd0e61c42fec2999
7
- data.tar.gz: aa9925ba49da2e63580c171a6d08f91db92ad5b4a6a5623fcca75ac8a26ef21102935ebed7323069f16cc3d03f01493f98a4cc5636fb7625ed492d402c7523a5
6
+ metadata.gz: 5be4558f18b436cd0d5c943bc829b98547a724e5c10a214238f4fcadf24c4b24c3e3812b6b0f2b12912f08981e29c394d79d8208fa009151374271c473fa95f6
7
+ data.tar.gz: 491cab0c32eaa8d224ded077cafddd7f4d7fbefd4a50ce6a9e6000594058c40da8020798706e24ceb70ec0ad3fea982f7374dd45f471f4c88c9237ae1c8df15f
data/README.md CHANGED
@@ -7,16 +7,88 @@ multi-line heredocs, and front-matter metadata.
7
7
 
8
8
  Two gems live in this repo, both with the same Ruby API and value shape:
9
9
 
10
- | gem | implementation | when to use |
11
- | ------ | ------------------------------------ | ------------------------------------ |
12
- | `dms` | pure Ruby | portable; no C toolchain required |
13
- | `dms-c`| C extension wrapping the dms-c decoder | hot paths; ~2× faster than pure Ruby |
10
+ | gem | implementation | when to use |
11
+ | ------------ | ----------------------------------------- | ------------------------------------ |
12
+ | `dms-parser` | pure Ruby (`require "dms"`) | portable; no C toolchain required |
13
+ | `dms-c` | C extension wrapping the dms-c decoder | hot paths; ~2× faster than pure Ruby |
14
+
15
+ > **Gem naming.** The plain `dms` name on RubyGems is taken by an unrelated
16
+ > project, so the pure-Ruby gem ships as `dms-parser`. The require path is
17
+ > still `"dms"` (the install command and the `require` line don't match —
18
+ > a one-time gotcha when adding the dependency).
19
+
20
+ ## What DMS looks like
21
+
22
+ A medium-size tier-0 document, exercising every feature you'd touch in a
23
+ real config — front matter, comments (line + trailing), nested tables,
24
+ list-of-tables with the `+` marker, flow forms, distinct types, and a
25
+ heredoc with a trim modifier:
26
+
27
+ ```dms
28
+ +++
29
+ title: "DMS feature tour"
30
+ version: "1.0.0"
31
+ updated: 2026-04-24T09:30:00-04:00
32
+ +++
33
+
34
+ # Hash and // line comments both work.
35
+ // Bare keys allow full Unicode; quoted keys take any string.
36
+
37
+ database:
38
+ host: "db.internal"
39
+ port: 5432 # bumped after the LB change
40
+ pool: { size: 10, idle_timeout_s: 30 } # flow table
41
+
42
+ servers:
43
+ + name: "web1"
44
+ disks:
45
+ + mount: "/"
46
+ size_gb: 100
47
+ + mount: "/var"
48
+ size_gb: 500
49
+ + name: "web2"
50
+
51
+ regions: ["us-east-1", "eu-west-1", "ap-south-1"]
52
+
53
+ sql: """SQL _trim("\n", ">")
54
+ SELECT id, email
55
+ FROM users
56
+ WHERE active = true
57
+ SQL
58
+ ```
59
+
60
+ Tier 1 layers structured decorators on top of the value tree. Sigils bind
61
+ to families published by a dialect; here is `dms+html` carrying an HTML
62
+ fragment as a DMS document:
63
+
64
+ ```dms
65
+ +++
66
+ _dms_tier: 1
67
+ _dms_imports:
68
+ + dialect: "html"
69
+ version: "1.0.0"
70
+ +++
71
+
72
+ + |html(lang: "en")
73
+ + |head
74
+ + |title "DMS feature tour"
75
+ + |meta(charset: "UTF-8")
76
+ + |body(class: "main")
77
+ + |h1 "Welcome to DMS"
78
+ + |p(class: "lede")
79
+ + "Click "
80
+ + |a(href: "/spec.html") "here"
81
+ + " to read the spec."
82
+ ```
83
+
84
+ Full feature tour, format comparison, and dialect index on the
85
+ **[DMS website](https://flo-labs.gitlab.io/pub/dms-webpage/)**.
14
86
 
15
87
  ## Install
16
88
 
17
89
  ```sh
18
- gem install dms # pure Ruby
19
- gem install dms-c # native (C) extension, same API
90
+ gem install dms-parser # pure Ruby
91
+ gem install dms-c # native (C) extension, same API (not yet published)
20
92
  ```
21
93
 
22
94
  ## Usage
data/bin/dms-encoder CHANGED
@@ -5,10 +5,22 @@
5
5
  # Reads DMS source from stdin, writes tagged JSON to stdout.
6
6
 
7
7
  $LOAD_PATH.unshift(File.expand_path("../lib", __dir__))
8
+ $LOAD_PATH.unshift(File.expand_path("../dms-c/lib", __dir__))
8
9
 
9
10
  require "json"
10
11
  require "dms"
11
12
 
13
+ # Feature-detect the native dms-c gem for tier-1 acceleration.
14
+ # Falls back silently to pure-Ruby Dms::Tier1 if unavailable or
15
+ # if the build hasn't been compiled yet.
16
+ DMS_C_AVAILABLE =
17
+ begin
18
+ require "dms_c"
19
+ DmsC.respond_to?(:decode_t1_to_json)
20
+ rescue LoadError
21
+ false
22
+ end
23
+
12
24
  # Force UTF-8 output: tagged JSON uses ensure_ascii=False equivalent
13
25
  # (we write raw UTF-8) so stdout must accept it. Disable CRLF translation.
14
26
  $stdout.set_encoding("UTF-8")
@@ -188,9 +200,16 @@ end
188
200
  begin
189
201
  # Tier-1 decode path: parse with decorator awareness, emit wrapper JSON.
190
202
  if tier_flag == 1
191
- doc_t1 = Dms::Tier1.parse(src)
192
- out = Dms::Tier1.emit_t1_json(doc_t1, method(:tag))
193
- $stdout.write(JSON.pretty_generate(out, indent: " ") + "\n")
203
+ if DMS_C_AVAILABLE
204
+ # Native path: dms-c tier1.c returns ready-to-print JSON; pretty-print it.
205
+ raw_hash = DmsC.decode_t1(src)
206
+ $stdout.write(JSON.pretty_generate(raw_hash, indent: " ") + "\n")
207
+ else
208
+ # Pure-Ruby fallback.
209
+ doc_t1 = Dms::Tier1.parse(src)
210
+ out = Dms::Tier1.emit_t1_json(doc_t1, method(:tag))
211
+ $stdout.write(JSON.pretty_generate(out, indent: " ") + "\n")
212
+ end
194
213
  exit 0
195
214
  end
196
215
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dms-parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Filip Lopes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-05-05 00:00:00.000000000 Z
11
+ date: 2026-05-06 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Ruby parser for DMS, a data syntax with strong typing, ordered maps,
14
14
  multi-line heredocs, and front-matter metadata.