junoser 0.4.3 → 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: e2a12a2f333461d8fa3fac8446e159180758be7e42a7f5f20fd537a1b43aa8d7
4
- data.tar.gz: 559deb9e18b0decf0770ad5c6c4c4f39f4e142238b15c58a7bbd07e90f10fb53
3
+ metadata.gz: 8e5143d4a1cd52517e76888edab70ba8938e66b98e8869bcf9de3e5963860cee
4
+ data.tar.gz: be817dc008cd1f482c01e1d577314d72d90f436f582388db43df967dcd9599dd
5
5
  SHA512:
6
- metadata.gz: ccea46701226315660767308ac13e2df613ce936277462c7c9712c95b68a6203d8f45a8a35cbc56633a09134be9915d1b60e1e62b46a74f722341b44d5c2ddff
7
- data.tar.gz: 472c7756ec33f8c973051a6a0d8a63f8f563e9ca79b883439c50a27224546267561869b22ef70ec576b3d81793dcd6f8c4dbe7b8f972bbafe09baeb997c5c642
6
+ metadata.gz: e579496b46fb6297e69909d20dc77f3851a75b10eec1c545530bab725b1953491bfab82d950183e3c99adcb0cd7655e23fcea8d74c5607acd3188ad37fda1edf
7
+ data.tar.gz: 2ce8eeff3c0af7927c4318e6ace521be67d5ccc3a479e72a2e1a460731785b7622eead33d53bdecf0ab3dabcee507252660675b3421d5231b0f66e2343177eed
@@ -9,7 +9,7 @@ jobs:
9
9
  strategy:
10
10
  fail-fast: false
11
11
  matrix:
12
- ruby-version: ['3.0', '2.7', '2.6']
12
+ ruby-version: ['3.1', '3.0', '2.7']
13
13
  os: [ubuntu-latest]
14
14
  experimental: [false]
15
15
  include:
data/CHANGELOG.md CHANGED
@@ -1,3 +1,25 @@
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
+
9
+ ## [0.4.5] - 2022-04-27
10
+
11
+ ### Fixed
12
+
13
+ * Ignore "replace:" tag in structured form
14
+
15
+
16
+ ## [0.4.4] - 2022-02-26
17
+
18
+ ### Fixed
19
+
20
+ * "snmp name" instead of "snmp system-name"
21
+
22
+
1
23
  ## [0.4.3] - 2021-09-28
2
24
 
3
25
  ### Fixed
data/Gemfile.lock CHANGED
@@ -1,21 +1,21 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- junoser (0.4.3)
4
+ junoser (0.4.6)
5
5
  parslet
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- mini_portile2 (2.6.1)
11
- nokogiri (1.12.5)
12
- mini_portile2 (~> 2.6.1)
10
+ mini_portile2 (2.8.0)
11
+ nokogiri (1.13.6)
12
+ mini_portile2 (~> 2.8.0)
13
13
  racc (~> 1.4)
14
14
  parslet (2.0.0)
15
- power_assert (2.0.0)
16
- racc (1.5.2)
17
- rake (13.0.3)
18
- test-unit (3.4.4)
15
+ power_assert (2.0.1)
16
+ racc (1.6.0)
17
+ rake (13.0.6)
18
+ test-unit (3.5.3)
19
19
  power_assert
20
20
 
21
21
  PLATFORMS
@@ -29,4 +29,4 @@ DEPENDENCIES
29
29
  test-unit
30
30
 
31
31
  BUNDLED WITH
32
- 2.2.16
32
+ 2.3.13
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2015-2021 Shintaro Kojima
3
+ Copyright (c) 2015-2022 Shintaro Kojima
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -103,4 +103,4 @@ Or send a pull request to fix.
103
103
 
104
104
  ## Copyright and License
105
105
 
106
- Copyright (c) 2015-2021 Shintaro Kojima. Code released under the [MIT license](LICENSE.txt).
106
+ Copyright (c) 2015-2022 Shintaro Kojima. Code released under the [MIT license](LICENSE.txt).
@@ -59,12 +59,16 @@ module Junoser
59
59
  current_statement = ''
60
60
 
61
61
  current_stack.each do |stack|
62
+ stack.gsub! 'replace: ', ''
63
+
62
64
  if stack.gsub!('inactive: ', '')
63
65
  statements << "deactivate #{current_statement}#{stack}"
64
66
  end
65
67
  current_statement << "#{stack} "
66
68
  end
67
69
 
70
+ str.gsub! 'replace: ', ''
71
+
68
72
  if str.gsub!('inactive: ', '')
69
73
  statements << "deactivate #{current_statement}#{str}"
70
74
  end
@@ -168,6 +168,8 @@ module Junoser
168
168
  str.gsub! 'policy | Define a policy context from this zone', 'from-zone | Define a policy context from this zone'
169
169
  # "to-zone-name | Destination zone" -> "to-zone | Destination zone"
170
170
  str.gsub! 'to-zone-name | Destination zone', 'to-zone | Destination zone'
171
+ # "system-name | System name override" -> "name | System name override"
172
+ str.gsub! 'system-name | System name override', 'name | System name override'
171
173
 
172
174
  fix_route_filter(str)
173
175
 
@@ -8746,7 +8746,7 @@ module Junoser
8746
8746
  ).as(:oneline),
8747
8747
  b(str("snmp"),
8748
8748
  c(
8749
- a(str("system-name"), arg),
8749
+ a(str("name"), quote | arg),
8750
8750
  a(str("description"), quote | arg),
8751
8751
  a(str("location"), quote | arg),
8752
8752
  a(str("contact"), quote | arg),
@@ -14289,7 +14289,7 @@ module Junoser
14289
14289
  b(str("suppress-tlv-advertisement"),
14290
14290
  (str("MANAGEMENT_ADDRESS") | str("SYSTEM_CAPABILITIES") | str("SYSTEM_DESCRIPTION") | str("SYSTEM_NAME") | str("PORT_DESCRIPTION") | str("PORT_ID") | str("CHASSIS_ID"))
14291
14291
  ),
14292
- a(str("system-name"), arg),
14292
+ a(str("name"), quote | arg),
14293
14293
  a(str("system-description"), arg),
14294
14294
  a(str("chassis-id"), arg),
14295
14295
  b(str("chassis-id-type"),
@@ -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,6 +220,17 @@ 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
+ # Fix .xsd: "snmp system-name" should be "snmp name"
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
+
223
234
  str
224
235
  end
225
236
 
@@ -1,3 +1,3 @@
1
1
  module Junoser
2
- VERSION = "0.4.3"
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.3
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: 2021-09-27 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.