zon-rb 0.1.0 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 32686cf609ab53ad187e1ea5eab78453f396642b7a092c60d1104b843f7dd47c
4
- data.tar.gz: e022ce6c1cb840580a105acc23ace93bf42ebca5001af78d31d2bda183e18319
3
+ metadata.gz: a2422c6a081bd6076413277434ed67b585057cba3858faf67b78e4f21efdfa74
4
+ data.tar.gz: e139d7d3da59ab7e82b7daca9267fb6b94c17b3437afbfb7bc21e67ca798682a
5
5
  SHA512:
6
- metadata.gz: 13629fb58006c1ca81cecce5d3bf893f96835e3d927458de00745b0f0c3ccfea40a640d75bfb783c76433be2bcc5b83488c1576325237134f561d286f224e5c5
7
- data.tar.gz: c0968e432df9bb625d9d6d49ad6104b6a0a9d9730180d7ef62a1efcb800e6405996184e39918a63ca45e6abae11b0834854ec365be8f90efc9949349bc7062d0
6
+ metadata.gz: a235b0b85a9d90cd4f7f1a132abb87609f5f7c5575922de790818072ebb1d84e63fee96a62eee3757e57bf6433ca8e9d7ffff037e8ffdc1259d8e582b1b2343b
7
+ data.tar.gz: f5f160c938a43879d6b428cdb0d55ccead5ba9baaa9bf31362137dfe84f6e61a19021890d5bc9d1049e591dac9d55e39f0e1a0c4408a0bdf89ec31cac16b112a
data/CHANGELOG.md CHANGED
@@ -1,4 +1,6 @@
1
- ## [Unreleased]
1
+ ## [0.2.0] - 2025-09-27
2
+
3
+ - Added basic Zig package manifest support.
2
4
 
3
5
  ## [0.1.0] - 2025-09-27
4
6
 
data/README.md CHANGED
@@ -1,25 +1,31 @@
1
1
  # Zig Object Notation (ZON) for Ruby
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/zon-rb.svg?icon=si%3Arubygems)](https://badge.fury.io/rb/zon-rb)
4
+
3
5
  The [Zig](https://ziglang.org/) Object Notation (ZON) is a file format primarily used within the Zig ecosystem. For example, ZON is used for the Zig package [manifest](https://github.com/ziglang/zig/blob/b7ab62540963d80f68d0e9ee7ce18520fb173487/doc/build.zig.zon.md).
4
6
 
5
7
  ## Installation
6
8
 
7
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
8
-
9
9
  Install the gem and add to the application's Gemfile by executing:
10
10
 
11
11
  ```bash
12
- bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
12
+ bundle add zon-rb
13
13
  ```
14
14
 
15
15
  If bundler is not being used to manage dependencies, install the gem by executing:
16
16
 
17
17
  ```bash
18
- gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
18
+ gem install zon-rb
19
19
  ```
20
20
 
21
21
  ## Usage
22
22
 
23
+ To use this Gem you have to require it:
24
+
25
+ ```ruby
26
+ require "zon"
27
+ ```
28
+
23
29
  To parse ZON data into a Ruby object, one can use the `Zon::parse` method. The method expects either a `String` or `IO` (`File`) object as its argument.
24
30
 
25
31
  ```irb
@@ -94,6 +100,20 @@ irb(main):010> Zon::serialize(255, {:ibase => 2})
94
100
  => "0b11111111"
95
101
  ```
96
102
 
103
+ ### Zig Manifest
104
+
105
+ `Zon::Zig::Manifest` provides you with an abstraction for your `build.zig.zon`. It will also validate your Zig package [manifest](https://github.com/ziglang/zig/blob/b7ab62540963d80f68d0e9ee7ce18520fb173487/doc/build.zig.zon.md) and raise an exception if one of the required fields is missing.
106
+
107
+ ```ruby
108
+ o = Zon::parse(File.open("../PassKeeZ/build.zig.zon"))
109
+ manifest = Zon::Zig::Manifest.new o
110
+
111
+ # Use:
112
+ # manifest.name
113
+ # manifest.version
114
+ # ...
115
+ ```
116
+
97
117
  ## Development
98
118
 
99
119
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
data/lib/zon/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Zon
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
data/lib/zon/zig.rb ADDED
@@ -0,0 +1,79 @@
1
+ module Zon
2
+
3
+ ##
4
+ # Everything related specifically to the Zig programming language.
5
+ module Zig
6
+
7
+ ##
8
+ # An abstraction of the Zig package manifest.
9
+ #
10
+ # Every Zig package should have a +build.zig.zon+ in
11
+ # its package root, the manifest. Like a manifest in
12
+ # Ruby, it is used to describe the package and specify
13
+ # required dependencies.
14
+ class Manifest
15
+ def initialize(zon)
16
+ raise "Missing '.name'" if not zon[:name]
17
+ raise "Missing '.version'" if not zon[:version]
18
+ raise "Missing '.fingerprint'" if not zon[:fingerprint]
19
+
20
+ if zon[:dependencies]
21
+ zon[:dependencies].each do |key, value|
22
+ if value[:url]
23
+ raise "Missing '.hash' for dependency '#{key}'" if not value[:hash]
24
+ elsif not value[:path]
25
+ raise "Expected either '.url' or '.path' for dependency '#{key}'" if not value[:hash]
26
+ end
27
+ end
28
+ end
29
+
30
+ @zon = zon
31
+ end
32
+
33
+ ##
34
+ # Get the '.name' field of the manifest.
35
+ def name
36
+ @zon[:name]
37
+ end
38
+
39
+ ##
40
+ # Get the '.version' field of the manifest.
41
+ def version
42
+ @zon[:version]
43
+ end
44
+
45
+ ##
46
+ # Get the '.fingerprint' field of the manifest.
47
+ def fingerprint
48
+ @zon[:fingerprint]
49
+ end
50
+
51
+ ##
52
+ # Get the '.dependencies' field of the manifest.
53
+ #
54
+ # This will return nil if the '.dependencies' field does not exist.
55
+ def dependencies
56
+ @zon[:dependencies]
57
+ end
58
+
59
+ ##
60
+ # Get the '.paths' field of the manifest.
61
+ #
62
+ # This will return nil if the '.paths' field does not exist.
63
+ def paths
64
+ @zon[:paths]
65
+ end
66
+
67
+ ##
68
+ # Get the '.minimum_zig_version' field of the manifest.
69
+ #
70
+ # This will return nil if the '.minimum_zig_version' field does not exist.
71
+ def minimum_zig_version
72
+ @zon[:minimum_zig_version]
73
+ end
74
+
75
+ end
76
+
77
+ end
78
+
79
+ end
data/lib/zon.rb CHANGED
@@ -4,6 +4,7 @@ require_relative "zon/version"
4
4
  require_relative "zon/lexer"
5
5
  require_relative "zon/parser"
6
6
  require_relative "zon/serializer"
7
+ require_relative "zon/zig"
7
8
 
8
9
  ##
9
10
  # Zig Object Notation (ZON) de-/serializer.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zon-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David P. Sugar
@@ -9,8 +9,8 @@ bindir: exe
9
9
  cert_chain: []
10
10
  date: 2025-09-27 00:00:00.000000000 Z
11
11
  dependencies: []
12
- description: This gem allows you to translate ZON data into Ruby objects and vice
13
- versa.
12
+ description: This gem allows you to translate Zig Object Notation (ZON) data into
13
+ Ruby objects and vice versa.
14
14
  email:
15
15
  - david@thesugar.de
16
16
  executables: []
@@ -28,6 +28,7 @@ files:
28
28
  - lib/zon/parser.rb
29
29
  - lib/zon/serializer.rb
30
30
  - lib/zon/version.rb
31
+ - lib/zon/zig.rb
31
32
  - lib/zon/zon_grammar.treetop
32
33
  - sig/zon.rbs
33
34
  homepage: https://github.com/r4gus/zon-rb