junoser 0.4.5 → 0.4.6

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: 713f225a607c33ca8acdd832a0252b217da1c5cfc9d9d5075efee87cde04dff1
4
- data.tar.gz: 98bc62a4a4c37c6f654412807f989d486beb4a813d65db661e94883b34294b76
3
+ metadata.gz: 8e5143d4a1cd52517e76888edab70ba8938e66b98e8869bcf9de3e5963860cee
4
+ data.tar.gz: be817dc008cd1f482c01e1d577314d72d90f436f582388db43df967dcd9599dd
5
5
  SHA512:
6
- metadata.gz: 18c5b6efde1452334353e90676e3375e730fecada9c2b09f173ea40e4f9a6dce54ffe6dc7adfdf65306673f56e86efd50cdbc91a9ed865ae2465f6caddfcdfbc
7
- data.tar.gz: c5d9a62f138d08985959bc5dc48213b311a7ea814750e24e4048d4f0c272a6f16b3d60d33ccf06eed2ac72bfd26a0d24bbc19165aa668e8bc8ace2f1f6976049
6
+ metadata.gz: e579496b46fb6297e69909d20dc77f3851a75b10eec1c545530bab725b1953491bfab82d950183e3c99adcb0cd7655e23fcea8d74c5607acd3188ad37fda1edf
7
+ data.tar.gz: 2ce8eeff3c0af7927c4318e6ace521be67d5ccc3a479e72a2e1a460731785b7622eead33d53bdecf0ab3dabcee507252660675b3421d5231b0f66e2343177eed
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## [0.4.6] - 2022-07-02
2
+
3
+ ### Fixed
4
+
5
+ * Accept quoted strings under "system license keys key"
6
+ * "protocols bgp ... prefix-limit teardown"
7
+
8
+
1
9
  ## [0.4.5] - 2022-04-27
2
10
 
3
11
  ### Fixed
data/Gemfile.lock CHANGED
@@ -1,14 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- junoser (0.4.5)
4
+ junoser (0.4.6)
5
5
  parslet
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
10
  mini_portile2 (2.8.0)
11
- nokogiri (1.13.4)
11
+ nokogiri (1.13.6)
12
12
  mini_portile2 (~> 2.8.0)
13
13
  racc (~> 1.4)
14
14
  parslet (2.0.0)
@@ -29,4 +29,4 @@ DEPENDENCIES
29
29
  test-unit
30
30
 
31
31
  BUNDLED WITH
32
- 2.2.26
32
+ 2.3.13
@@ -63641,7 +63641,7 @@ module Junoser
63641
63641
  rule(:bgpaf_accepted_prefix_limit) do
63642
63642
  c(
63643
63643
  a(str("maximum"), arg),
63644
- b(str("teardown"),
63644
+ b(a(str("teardown"), arg),
63645
63645
  ca(
63646
63646
  b(str("idle-timeout"),
63647
63647
  sc(
@@ -63652,7 +63652,8 @@ module Junoser
63652
63652
  )
63653
63653
  ).as(:oneline)
63654
63654
  )
63655
- )
63655
+ ),
63656
+ str("teardown")
63656
63657
  )
63657
63658
  end
63658
63659
 
@@ -63671,7 +63672,7 @@ module Junoser
63671
63672
  rule(:bgpaf_prefix_limit) do
63672
63673
  c(
63673
63674
  a(str("maximum"), arg),
63674
- b(str("teardown"),
63675
+ b(a(str("teardown"), arg),
63675
63676
  ca(
63676
63677
  b(str("idle-timeout"),
63677
63678
  sc(
@@ -63682,7 +63683,8 @@ module Junoser
63682
63683
  )
63683
63684
  ).as(:oneline)
63684
63685
  )
63685
- )
63686
+ ),
63687
+ str("teardown")
63686
63688
  )
63687
63689
  end
63688
63690
 
@@ -97992,7 +97994,7 @@ module Junoser
97992
97994
  ),
97993
97995
  b(str("keys"),
97994
97996
  c(
97995
- a(str("key"), arg)
97997
+ a(str("key"), quote | arg)
97996
97998
  )
97997
97999
  ),
97998
98000
  c(
data/lib/junoser/ruler.rb CHANGED
@@ -14,7 +14,7 @@ module Junoser
14
14
  str = @rule.read
15
15
  str = remove_comments(str)
16
16
  str = process_reserved_element(str)
17
- str = str.split(/\n/).map { |l| format(process_line(l)) }.join("\n")
17
+ str.split(/\n/).map { |l| format(process_line(l)) }.join("\n")
18
18
  end
19
19
 
20
20
  private
@@ -26,16 +26,16 @@ module Junoser
26
26
  def process_line(str)
27
27
  return str if str =~ /^(.* do|end)$/
28
28
 
29
- str.gsub!(/("[^"]+")/) { "str(#$1)" } # "foo" -> str("foo")
29
+ str.gsub!(/("[^"]+")/) { "str(#{$1})" } # "foo" -> str("foo")
30
30
 
31
- str.gsub!(/^(\s*)arg(\.as\(:\S+\))? \($/) { "#{$1}b(arg#$2," } # arg ( -> b(arg,
32
- str.gsub!(/^(\s*)(str\(\S+\)) ([^ \t\n\r\f\(|,]+)(\.as\(:\S+\))?(,?)$/) { "#{$1}a(#$2, #$3)#$4#$5" } # str("foo") bar -> a(str("foo"), bar)
33
- str.gsub!(/^(\s*)(str\(\S+\)) (enum)?\((.*)\)(,?)$/) { "#{$1}a(#$2, #$3#$4)#$5" } # str("foo") (a | b) -> a(str("foo"), a | b)
31
+ str.gsub!(/^(\s*)arg(\.as\(:\S+\))? \($/) { "#{$1}b(arg#{$2}," } # arg ( -> b(arg,
32
+ str.gsub!(/^(\s*)(str\(\S+\)) ([^ \t\n\r\f(|,]+)(\.as\(:\S+\))?(,?)$/) { "#{$1}a(#{$2}, #{$3})#{$4}#{$5}" } # str("foo") bar -> a(str("foo"), bar)
33
+ str.gsub!(/^(\s*)(str\(\S+\)) (enum)?\((.*)\)(,?)$/) { "#{$1}a(#{$2}, #{$3}#{$4})#{$5}" } # str("foo") (a | b) -> a(str("foo"), a | b)
34
34
 
35
- str.gsub!(/^(\s*)(str\(\S+\)) \($/) { "#{$1}b(#$2," } # str("foo") ( -> b(str("foo"),
36
- str.gsub!(/^(\s*)(enum)?(\(.*\))(\.as\(:\S\))? \($/) { "#{$1}b(#$2#$3#$4," } # (a | b) ( -> b((a | b),
37
- str.gsub!(/^(\s*)(str\(\S+\)) ([^ \t\n\r\f\(|,]+) \($/) { "#{$1}b(a(#$2, #$3)," } # str("foo") bar ( -> b(a(str("foo"), bar),
38
- str.gsub!(/^(\s*)(str\(\S+\)) (enum)?\((.*)\) \($/) { "#{$1}a(#$2, #$3#$4," } # str("foo") (a | b) ( -> a(str("foo"), a | b,
35
+ str.gsub!(/^(\s*)(str\(\S+\)) \($/) { "#{$1}b(#{$2}," } # str("foo") ( -> b(str("foo"),
36
+ str.gsub!(/^(\s*)(enum)?(\(.*\))(\.as\(:\S\))? \($/) { "#{$1}b(#{$2}#{$3}#{$4}," } # (a | b) ( -> b((a | b),
37
+ str.gsub!(/^(\s*)(str\(\S+\)) ([^ \t\n\r\f(|,]+) \($/) { "#{$1}b(a(#{$2}, #{$3})," } # str("foo") bar ( -> b(a(str("foo"), bar),
38
+ str.gsub!(/^(\s*)(str\(\S+\)) (enum)?\((.*)\) \($/) { "#{$1}a(#{$2}, #{$3}#{$4}," } # str("foo") (a | b) ( -> a(str("foo"), a | b,
39
39
 
40
40
  str
41
41
  end
@@ -52,7 +52,7 @@ module Junoser
52
52
  #
53
53
  # Statements can be quoted
54
54
  #
55
- str.gsub!(/("ssh-\S+") arg/) { "#$1 (quote | arg)" }
55
+ str.gsub!(/("ssh-\S+") arg/) { "#{$1} (quote | arg)" }
56
56
  str.gsub! '"message" arg', '"message" (quote | arg)'
57
57
  str.gsub! '"description" arg', '"description" (quote | arg)'
58
58
  str.gsub! '"as-path-prepend" arg', '"as-path-prepend" (quote | arg)'
@@ -63,7 +63,7 @@ module Junoser
63
63
  ' quote | arg'], $1)
64
64
  end
65
65
 
66
- str.gsub!(/^rule\(:regular_expression\) do\s*((?!end).)*\s*end/) do
66
+ str.gsub!(/^rule\(:regular_expression\) do\s.*?\s*end/) do
67
67
  <<~EOS
68
68
  rule(:regular_expression) do
69
69
  (quote | arg).as(:arg)
@@ -99,7 +99,7 @@ module Junoser
99
99
  #
100
100
  # "arg" matches anything so move to the end
101
101
  #
102
- str.gsub!(/arg \| (".*")/) { "#$1 | arg" }
102
+ str.gsub!(/arg \| (".*")/) { "#{$1} | arg" }
103
103
  str.gsub!(/^(\s*)c\(\s*arg,$/) { "#{$1}ca(" }
104
104
  str.gsub!(/(rule\(:control_route_filter_type\) do\s*)s\(\s*arg,/) { "#{$1}b(" }
105
105
  str.gsub!(/(rule\(:control_source_address_filter_type\) do\s*)s\(\s*arg,/) { "#{$1}b(" }
@@ -130,18 +130,18 @@ module Junoser
130
130
  #
131
131
  # "inet",
132
132
  # "inet6"
133
- str.gsub!(/"cspf"(.*\s*.*)"cspf-link"/) { %["cspf-link"#$1"cspf"] }
134
- str.gsub!(/"http"(.*\s*.*)"https"/) { %["https"#$1"http"] }
135
- str.gsub!(/"inet"(.*\s*.*)"inet6"/) { %["inet6"#$1"inet"] }
136
- str.gsub!(/"icmp"(.*\s*.*)"icmp6"/) { %["icmp6"#$1"icmp"] }
137
- str.gsub!(/"icmp"(.*\s*.*)"icmpv6"/) { %["icmpv6"#$1"icmp"] }
138
- str.gsub!(/"snmp"(.*\s*.*)"snmptrap"/) { %["snmptrap"#$1"snmp"] }
139
- str.gsub!(/"ospf"(.*\s*.*)"ospf3"/) { %["ospf3"#$1"ospf"] }
133
+ str.gsub!(/"cspf"(.*\s*.*)"cspf-link"/) { %["cspf-link"#{$1}"cspf"] }
134
+ str.gsub!(/"http"(.*\s*.*)"https"/) { %["https"#{$1}"http"] }
135
+ str.gsub!(/"inet"(.*\s*.*)"inet6"/) { %["inet6"#{$1}"inet"] }
136
+ str.gsub!(/"icmp"(.*\s*.*)"icmp6"/) { %["icmp6"#{$1}"icmp"] }
137
+ str.gsub!(/"icmp"(.*\s*.*)"icmpv6"/) { %["icmpv6"#{$1}"icmp"] }
138
+ str.gsub!(/"snmp"(.*\s*.*)"snmptrap"/) { %["snmptrap"#{$1}"snmp"] }
139
+ str.gsub!(/"ospf"(.*\s*.*)"ospf3"/) { %["ospf3"#{$1}"ospf"] }
140
140
  str.gsub! '"tls1" | "tls11" | "tls12"', '"tls11" | "tls12" | "tls1"'
141
- str.gsub!(/("group1" \| "group2" \| "group5") \| ([^\)]+)/) { "#{$2} | #{$1}"}
141
+ str.gsub!(/("group1" \| "group2" \| "group5") \| ([^)]+)/) { "#{$2} | #{$1}"}
142
142
 
143
143
  %w[ccc ethernet-over-atm tcc vpls bridge].each do |encap|
144
- str.gsub!(/"ethernet"(.*)"ethernet-#{encap}"/) { %["ethernet-#{encap}"#$1"ethernet"] }
144
+ str.gsub!(/"ethernet"(.*)"ethernet-#{encap}"/) { %["ethernet-#{encap}"#{$1}"ethernet"] }
145
145
  end
146
146
 
147
147
  str.gsub!(/^(\s*)"path" arg \(\s*c\(\s*sc\(\s*"abstract",\s*c\(\s*"loose",\s*"loose-link",\s*"strict"\s*\)\s*\)\.as\(:oneline\)/) do
@@ -163,9 +163,9 @@ module Junoser
163
163
  #
164
164
  # Fix .xsd: Elements without "nokeyword" flag
165
165
  #
166
- str.gsub!(/\((.*) \| "name"\)/) { "(#$1 | arg)" }
166
+ str.gsub!(/\((.*) \| "name"\)/) { "(#{$1} | arg)" }
167
167
  str.gsub! '"vlan" ("all" | "vlan-name")', '"vlan" ("all" | arg)'
168
- str.gsub!(/\((.*) \| "vlan-id"\)/) { "(#$1 | arg)" }
168
+ str.gsub!(/\((.*) \| "vlan-id"\)/) { "(#{$1} | arg)" }
169
169
 
170
170
  %w[filename].each do |key|
171
171
  str.gsub! %["#{key}" arg], 'arg'
@@ -220,10 +220,18 @@ module Junoser
220
220
  # Fix .xsd: keywords "dest-nat-rule-match", "src-nat-rule-match", "static-nat-rule-match" are wrong
221
221
  str.gsub!(/"(dest|src|static)-nat-rule-match"/) { '"match"' }
222
222
 
223
- str
224
-
225
223
  # Fix .xsd: "snmp system-name" should be "snmp name"
226
224
  str.gsub! '"system-name" arg', '"name" (quote | arg)'
225
+
226
+ # Fix .xsd: argument of "system license keys key" can be quoted
227
+ str.gsub!(/^(rule\(:license_object\) do.*?"key") arg/m) { "#{$1} (quote | arg)"}
228
+
229
+ # Fix .xsd: "prefix-limit teardown"
230
+ str.gsub!(/^(\s*)"teardown" (\(.*?as\(:oneline\)\s*\)\s*\))/m) do
231
+ "#{$1}\"teardown\" arg #{$2},\n#{$1}\"teardown\""
232
+ end
233
+
234
+ str
227
235
  end
228
236
 
229
237
  def format(str, offset = OFFSET)
@@ -1,3 +1,3 @@
1
1
  module Junoser
2
- VERSION = "0.4.5"
2
+ VERSION = "0.4.6"
3
3
  end
@@ -0,0 +1,21 @@
1
+ # TypeProf 0.21.2
2
+
3
+ # Classes
4
+ module Junoser
5
+ class Ruler
6
+ OFFSET: String
7
+ @rule: untyped
8
+
9
+ def initialize: (untyped input) -> void
10
+ def to_rule: -> String
11
+ def rule: -> untyped
12
+
13
+ private
14
+ def remove_comments: (untyped str) -> untyped
15
+ def process_line: (untyped str) -> untyped
16
+ def process_reserved_element: (untyped str) -> untyped
17
+ def format: (Array[String?] | String str, ?String? offset) -> String?
18
+ def rule_header: -> String
19
+ def rule_footer: -> String
20
+ end
21
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: junoser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.5
4
+ version: 0.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shintaro Kojima
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-04-26 00:00:00.000000000 Z
11
+ date: 2022-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parslet
@@ -137,6 +137,7 @@ files:
137
137
  - lib/junoser/xsd/simple_type.rb
138
138
  - lib/junoser/xsd/union.rb
139
139
  - lib/underscorable.rb
140
+ - sig/junoser/ruler.rbs
140
141
  homepage: https://github.com/codeout/junoser
141
142
  licenses: []
142
143
  metadata: {}
@@ -155,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
155
156
  - !ruby/object:Gem::Version
156
157
  version: '0'
157
158
  requirements: []
158
- rubygems_version: 3.2.22
159
+ rubygems_version: 3.3.7
159
160
  signing_key:
160
161
  specification_version: 4
161
162
  summary: PEG parser for JUNOS configuration.