ios_parser 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: abbb84cb462b8506f141ce88c1333f8f25e8bc9f31e5bc166d2f76f275044529
4
- data.tar.gz: 7ed4f70c4396caae3d84df7dc17176b5a4c1e1f4eede31cdf63af8d34c61285f
2
+ SHA1:
3
+ metadata.gz: fe5cc7498b4d04b861b4225eebb71c7dad2e9cb2
4
+ data.tar.gz: 3b6b573d4fe0592b5d750e422da096b38270478b
5
5
  SHA512:
6
- metadata.gz: 209623e73042e19dd5bb9108f3aee56ab357e2b84ad388f028e1055cf90eee73fc9040c448e6e394729880a3690abc38e2c945371dac73a7004db3bab78180a2
7
- data.tar.gz: dc1b41a7d3e821d9bfdb2ce9e4b6cad8012396b2ba3ed1e39b56eecc7582870e829e8cb512ebca9a68ffb281c13aab1c5c7d6af48c53cec9ede3bbcc58078bb5
6
+ metadata.gz: df6ee8b1f39f13c32f856568b086f66a2893c971cd2ac994c21c45be1a07c3afe0c265740b9976f57fca636876b25a15f4329f1ff726b32c4e9761e82274f357
7
+ data.tar.gz: '02698a983bfca376a4f86ae6698aa34cabe251eb8d4b8769b1b21871184633ddcccd0e48baad56ff28c934529c109f83704125e4cb11bc06843b2d0b73d59fa4'
@@ -87,6 +87,33 @@ int is_certificate(LexInfo *lex) {
87
87
  return 1;
88
88
  }
89
89
 
90
+ int is_authentication_banner_begin(LexInfo *lex) {
91
+ VALUE authentication_ary, authentication, banner_ary, banner;
92
+ int token_count = RARRAY_LEN(lex->tokens);
93
+ int authentication_pos = token_count -2;
94
+ int banner_pos = token_count - 1;
95
+
96
+ if (banner_pos < 0) { return 0; }
97
+
98
+ banner_ary = rb_ary_entry(lex->tokens, banner_pos);
99
+ banner = TOKEN_VALUE(banner_ary);
100
+ if (TYPE(banner) != T_STRING) { return 0; }
101
+
102
+ StringValue(banner);
103
+ if (RSTRING_LEN(banner) != CMD_LEN("banner")) { return 0; }
104
+ if (0 != strncmp(RSTRING_PTR(banner), "banner", 6)) { return 0; }
105
+
106
+ authentication_ary = rb_ary_entry(lex->tokens, authentication_pos);
107
+ authentication = TOKEN_VALUE(authentication_ary);
108
+ if (TYPE(authentication) != T_STRING) { return 0; }
109
+
110
+ StringValue(authentication);
111
+ if (RSTRING_LEN(authentication) != CMD_LEN("authentication")) { return 0; }
112
+ if (0 != strncmp(RSTRING_PTR(authentication), "authentication", 14)) { return 0; }
113
+
114
+ return 1;
115
+ }
116
+
90
117
  int is_banner_begin(LexInfo *lex) {
91
118
  VALUE banner_ary, banner;
92
119
  int token_count = RARRAY_LEN(lex->tokens);
@@ -94,6 +121,8 @@ int is_banner_begin(LexInfo *lex) {
94
121
 
95
122
  if (banner_pos < 0) { return 0; }
96
123
 
124
+ if (is_authentication_banner_begin(lex)) { return 1; }
125
+
97
126
  banner_ary = rb_ary_entry(lex->tokens, banner_pos);
98
127
  banner = TOKEN_VALUE(banner_ary);
99
128
  if (TYPE(banner) != T_STRING) { return 0; }
@@ -113,7 +113,10 @@ module IOSParser
113
113
  end
114
114
 
115
115
  def banner_begin?
116
- tokens[-2] && tokens[-2].value == 'banner'
116
+ tokens[-2] && (
117
+ tokens[-2].value == 'banner' ||
118
+ tokens[-2..-1].map(&:value) == %w[authentication banner]
119
+ )
117
120
  end
118
121
 
119
122
  def banner
@@ -1,7 +1,7 @@
1
1
  module IOSParser
2
2
  class << self
3
3
  def version
4
- '0.6.0'
4
+ '0.7.0'
5
5
  end
6
6
  end
7
7
  end
@@ -137,6 +137,29 @@ END
137
137
  it { expect(subject_pure.map(&:value)).to eq output }
138
138
  end
139
139
 
140
+ context 'aaa authentication banner' do
141
+ let(:input) { <<END.unindent }
142
+ aaa authentication banner ^C
143
+ xyz
144
+ ^C
145
+ aaa blah
146
+ END
147
+
148
+ let(:output) do
149
+ ['aaa', 'authentication', 'banner',
150
+ :BANNER_BEGIN, "xyz\n", :BANNER_END, :EOL,
151
+ 'aaa', 'blah', :EOL]
152
+ end
153
+
154
+ it 'lexes (c lexer)' do
155
+ expect(subject.map(&:value)).to eq output
156
+ end
157
+
158
+ it 'lexes (ruby lexer)' do
159
+ expect(subject_pure.map(&:value)).to eq output
160
+ end
161
+ end
162
+
140
163
  context 'decimal number' do
141
164
  let(:input) { 'boson levels at 93.2' }
142
165
  let(:output) { ['boson', 'levels', 'at', 93.2] }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ios_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Miller
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-07 00:00:00.000000000 Z
11
+ date: 2019-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler
@@ -111,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
111
  version: '0'
112
112
  requirements: []
113
113
  rubyforge_project:
114
- rubygems_version: 2.7.3
114
+ rubygems_version: 2.5.2.3
115
115
  signing_key:
116
116
  specification_version: 4
117
117
  summary: convert network switch and router config files to structured data