zon-rb 0.3.1 → 0.3.3
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 +4 -0
- data/lib/zon/hasher.rb +9 -2
- data/lib/zon/lexer.rb +8 -0
- data/lib/zon/parser.rb +6 -2
- data/lib/zon/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c423818245cd12dc36a6bda5fce1666d7f85dbdbcf891196f4d9ecbc92342aaf
|
|
4
|
+
data.tar.gz: 167b2356621a36abe2a5730725262eddd303ce596fdf01377d618f829f040f0e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4d5244cb30e7591f86e2764518c1768b3d5bb25536c75bc35992066a8966aef109e9e7a1e0129440f3e9bcd662847d1890402470aa6b3d7754afd559531aecc8
|
|
7
|
+
data.tar.gz: dde0161c7d0bd6d8d5e1107bf49841fbb9f16fb4a27149dda42dc0f1999b2e835830ea18506083d751327263f802738a450d51cb4dd1b95d999ff58e762b92c1
|
data/CHANGELOG.md
CHANGED
data/lib/zon/hasher.rb
CHANGED
|
@@ -33,7 +33,7 @@ module Zon
|
|
|
33
33
|
class Hasher
|
|
34
34
|
attr_reader :paths, :total_size, :digest
|
|
35
35
|
|
|
36
|
-
def initialize(package_path, manifest_name: "build.zig.zon")
|
|
36
|
+
def initialize(package_path, manifest_name: "build.zig.zon", debug: false)
|
|
37
37
|
# Make sure we have a valid path to work with
|
|
38
38
|
@package_path = package_path
|
|
39
39
|
raise ArgumentError, "not a directory '#{@package_path}'" if not Dir.exist? @package_path
|
|
@@ -47,6 +47,7 @@ module Zon
|
|
|
47
47
|
raise ArgumentError, "no 'version' field in ZON manifest '#{manifest_path}'" if not @manifest.key? :version
|
|
48
48
|
raise ArgumentError, "no 'fingerprint' field in ZON manifest '#{manifest_path}'" if not @manifest.key? :fingerprint
|
|
49
49
|
|
|
50
|
+
@debug = debug
|
|
50
51
|
@paths = []
|
|
51
52
|
@results = {}
|
|
52
53
|
@total_size = 0
|
|
@@ -58,7 +59,11 @@ module Zon
|
|
|
58
59
|
if File.directory? full_path
|
|
59
60
|
f = Find.find(full_path)
|
|
60
61
|
f.each do |p|
|
|
61
|
-
|
|
62
|
+
# TODO: it seems like when "" is used as path, hidden folders
|
|
63
|
+
# like .git are not considered but hidden files like .gitignore
|
|
64
|
+
# are. Make this more robust by removing all hidden folders that
|
|
65
|
+
# are not explicitely listed in the manifest.
|
|
66
|
+
next if File.directory? p or p.include? ".git/"
|
|
62
67
|
|
|
63
68
|
pstr = p.delete_prefix(@package_path)[1..]
|
|
64
69
|
@paths.append(pstr) if not @paths.include? pstr
|
|
@@ -87,6 +92,8 @@ module Zon
|
|
|
87
92
|
# Hash all files individually
|
|
88
93
|
@paths.each do |str|
|
|
89
94
|
@results[str] = Zon::Zig::Hasher::hash_file(@package_path, str)
|
|
95
|
+
|
|
96
|
+
puts "file: #{@results[str][:digest]}: #{str}" if @debug
|
|
90
97
|
end
|
|
91
98
|
|
|
92
99
|
sha2 = Digest::SHA2.new
|
data/lib/zon/lexer.rb
CHANGED
|
@@ -9,6 +9,7 @@ module Zon
|
|
|
9
9
|
RBRACE = 5
|
|
10
10
|
EQUALS = 6
|
|
11
11
|
COMMA = 7
|
|
12
|
+
LITERAL2 = 8
|
|
12
13
|
end
|
|
13
14
|
|
|
14
15
|
class Token
|
|
@@ -98,6 +99,8 @@ module Zon
|
|
|
98
99
|
y << Token.new(TokenType::NUMBER, token_str)
|
|
99
100
|
elsif self.is_literal? token_str
|
|
100
101
|
y << Token.new(TokenType::LITERAL, token_str)
|
|
102
|
+
elsif self.is_at_literal? token_str
|
|
103
|
+
y << Token.new(TokenType::LITERAL2, token_str)
|
|
101
104
|
else
|
|
102
105
|
raise "Unknown token '#{token_str}' at index #{idx}"
|
|
103
106
|
end
|
|
@@ -110,6 +113,11 @@ module Zon
|
|
|
110
113
|
!!(token_str =~ literal_regex)
|
|
111
114
|
end
|
|
112
115
|
|
|
116
|
+
def self.is_at_literal?(token_str)
|
|
117
|
+
literal_regex = /\.@\"[^"]+\"/
|
|
118
|
+
!!(token_str =~ literal_regex)
|
|
119
|
+
end
|
|
120
|
+
|
|
113
121
|
def self.is_number?(token_str)
|
|
114
122
|
number_regex = /\A
|
|
115
123
|
[+-]? # optional sign
|
data/lib/zon/parser.rb
CHANGED
|
@@ -32,7 +32,7 @@ module Zon
|
|
|
32
32
|
|
|
33
33
|
v = self.parse
|
|
34
34
|
|
|
35
|
-
if v.is_a? Symbol and self.next_token? Lexer::TokenType::EQUALS
|
|
35
|
+
if (v.is_a? Symbol or v.is_a? String) and self.next_token? Lexer::TokenType::EQUALS
|
|
36
36
|
# This is a Zon struct, i.e. translate it to a Ruby hash
|
|
37
37
|
k = v
|
|
38
38
|
self.next_equals # skip equals
|
|
@@ -93,7 +93,9 @@ module Zon
|
|
|
93
93
|
|
|
94
94
|
if @curr and @curr.type == Lexer::TokenType::LITERAL
|
|
95
95
|
@curr.value[1..].to_sym # create sym from string without the '.'
|
|
96
|
-
elsif
|
|
96
|
+
elsif @curr and @curr.type == Lexer::TokenType::LITERAL2
|
|
97
|
+
@curr.value[3..-2]
|
|
98
|
+
else
|
|
97
99
|
raise "Expected literal token but got '#{@curr.value}'"
|
|
98
100
|
end
|
|
99
101
|
end
|
|
@@ -107,6 +109,8 @@ module Zon
|
|
|
107
109
|
|
|
108
110
|
if @curr.type == Lexer::TokenType::LITERAL
|
|
109
111
|
value = @curr.value[1..].to_sym
|
|
112
|
+
elsif @curr.type == Lexer::TokenType::LITERAL2
|
|
113
|
+
value = @curr.value[3..-2]
|
|
110
114
|
elsif @curr.type == Lexer::TokenType::STRING
|
|
111
115
|
value = @curr.value[1..-2]
|
|
112
116
|
elsif @curr.type == Lexer::TokenType::NUMBER
|
data/lib/zon/version.rb
CHANGED
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.3.
|
|
4
|
+
version: 0.3.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- David P. Sugar
|
|
@@ -32,13 +32,13 @@ files:
|
|
|
32
32
|
- lib/zon/zig.rb
|
|
33
33
|
- lib/zon/zon_grammar.treetop
|
|
34
34
|
- sig/zon.rbs
|
|
35
|
-
homepage: https://
|
|
35
|
+
homepage: https://codeberg.org/r4gus/zon-rb
|
|
36
36
|
licenses:
|
|
37
37
|
- MIT
|
|
38
38
|
metadata:
|
|
39
|
-
homepage_uri: https://
|
|
40
|
-
source_code_uri: https://
|
|
41
|
-
changelog_uri: https://
|
|
39
|
+
homepage_uri: https://codeberg.org/r4gus/zon-rb
|
|
40
|
+
source_code_uri: https://codeberg.org/r4gus/zon-rb
|
|
41
|
+
changelog_uri: https://codeberg.org/r4gus/zon-rb/raw/branch/master/CHANGELOG.md
|
|
42
42
|
rdoc_options: []
|
|
43
43
|
require_paths:
|
|
44
44
|
- lib
|