ios_parser 0.6.0 → 0.7.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 +5 -5
- data/ext/ios_parser/c_lexer/lexer.c +29 -0
- data/lib/ios_parser/lexer.rb +4 -1
- data/lib/ios_parser/version.rb +1 -1
- data/spec/lib/ios_parser/lexer_spec.rb +23 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: fe5cc7498b4d04b861b4225eebb71c7dad2e9cb2
|
4
|
+
data.tar.gz: 3b6b573d4fe0592b5d750e422da096b38270478b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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; }
|
data/lib/ios_parser/lexer.rb
CHANGED
@@ -113,7 +113,10 @@ module IOSParser
|
|
113
113
|
end
|
114
114
|
|
115
115
|
def banner_begin?
|
116
|
-
tokens[-2] &&
|
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
|
data/lib/ios_parser/version.rb
CHANGED
@@ -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.
|
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-
|
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.
|
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
|