ios_parser 0.5.0 → 0.5.1

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
- SHA1:
3
- metadata.gz: 181d9adcdc7d222fe6ef05a91624aa1277274371
4
- data.tar.gz: f9a1920092018240b8e67f972e453f5e104b8bd9
2
+ SHA256:
3
+ metadata.gz: 2de99dbf9bae8e78c136f2ae91976e4989dcf1b38ee329184c379a8e23346183
4
+ data.tar.gz: a5a644079df051eb363682d43773b056fe9b0101493494bd6ae4571cf1196920
5
5
  SHA512:
6
- metadata.gz: 4d4cf9efd75f3c563ffa92034dccbc265a5fd70778afb2f970df71641b1a94edc371befcd99e6d7bf989817b8fd1744a4d60b7340415ac7ec4fa4d2e8afd6586
7
- data.tar.gz: 5fa9ebc0c746698ce75afd045d272826e9e48d54c86d4c20ab244e790b10f9255a36795a85331b1675d756fde9ac6b5d221bf0506391cb73a032e246e6ab41f7
6
+ metadata.gz: 58f820e3c067173aa657c137a0da9c2d3da94eb9b6ebe489281ea29a5185ee36c3a3f6bbba7bd1c4e5317845c629dfd6ce05b4a29c704e5bd457de589835be6d
7
+ data.tar.gz: 7df6f8eed3246238da8db8a8d5aa7d19ebd7a45c32c01951615de5314c729b713640192496e04f3fcb8fddcca0c2701d72c51970da4eb9d9a2c55333559c58ac
data/.rubocop.yml CHANGED
@@ -9,6 +9,13 @@ Style/Documentation:
9
9
  Style/CaseEquality:
10
10
  Enabled: false
11
11
 
12
+ Layout/IndentHeredoc:
13
+ EnforcedStyle: unindent
14
+
15
+ Metrics/BlockLength:
16
+ Exclude:
17
+ - 'spec/**/*'
18
+
12
19
  Metrics/ClassLength:
13
20
  Exclude:
14
21
  - 'lib/ios_parser/lexer.rb'
@@ -17,3 +24,16 @@ Metrics/ClassLength:
17
24
  Metrics/ModuleLength:
18
25
  Exclude:
19
26
  - 'spec/**/*'
27
+
28
+ Naming/HeredocDelimiterNaming:
29
+ Exclude:
30
+ - 'spec/**/*'
31
+
32
+ Style/CommentedKeyword:
33
+ Enabled: false
34
+
35
+ Style/SymbolArray:
36
+ Enabled: false
37
+
38
+ Style/YodaCondition:
39
+ Enabled: false
data/.travis.yml CHANGED
@@ -2,8 +2,11 @@ language: ruby
2
2
  rvm:
3
3
  - 2.0.0
4
4
  - 2.1.10
5
- - 2.2.5
6
- - 2.3.1
5
+ - 2.2.10
6
+ - 2.3.7
7
+ - 2.4.4
8
+ - 2.5.1
9
+ - jruby-9.1.16.0
7
10
  matrix:
8
11
  include:
9
12
  - rvm: jruby
data/ios_parser.gemspec CHANGED
@@ -1,4 +1,4 @@
1
- $LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
1
+ $LOAD_PATH.unshift File.expand_path('lib', __dir__)
2
2
  require 'ios_parser/version'
3
3
 
4
4
  Gem::Specification.new do |s|
@@ -13,11 +13,13 @@ Gem::Specification.new do |s|
13
13
  s.files = `git ls-files`.split("\n")
14
14
  s.test_files = `git ls-files -- {spec,features}/*`.split("\n")
15
15
 
16
- unless RUBY_ENGINE == 'jruby'
16
+ if RUBY_PLATFORM == 'java'
17
+ s.platform = 'java'
18
+ else
17
19
  s.extensions << 'ext/ios_parser/c_lexer/extconf.rb'
18
20
  end
19
21
 
20
- s.add_development_dependency 'rspec', '~>3.2'
21
- s.add_development_dependency 'rubocop', '~>0.37'
22
22
  s.add_development_dependency 'rake-compiler', '~>0.9'
23
+ s.add_development_dependency 'rspec', '~>3.2'
24
+ s.add_development_dependency 'rubocop', '~> 0.54' if RUBY_VERSION > '2.1'
23
25
  end
@@ -4,7 +4,8 @@ require_relative 'queryable'
4
4
  module IOSParser
5
5
  class IOS
6
6
  class Command
7
- include Queryable, Enumerable
7
+ include Enumerable
8
+ include Queryable
8
9
  attr_accessor :args, :commands, :parent, :pos, :document
9
10
 
10
11
  def initialize(args: [], commands: [],
@@ -5,7 +5,8 @@ require_relative 'command'
5
5
  module IOSParser
6
6
  class IOS
7
7
  class Document
8
- include Queryable, Enumerable
8
+ include Enumerable
9
+ include Queryable
9
10
  attr_accessor :commands, :parent, :source
10
11
 
11
12
  def initialize(source)
@@ -131,12 +131,12 @@ module IOSParser
131
131
  end
132
132
  end
133
133
 
134
- def compare_string_or_case(a, b)
135
- case a
134
+ def compare_string_or_case(a_object, b_object)
135
+ case a_object
136
136
  when String
137
- a == b.to_s
137
+ a_object == b_object.to_s
138
138
  else
139
- a === b
139
+ a_object === b_object
140
140
  end
141
141
  end
142
142
 
@@ -184,7 +184,7 @@ module IOSParser
184
184
  alias not not_all
185
185
 
186
186
  def none(expressions, command)
187
- !expressions.any? { |expr| all([expr], command) }
187
+ expressions.none? { |expr| all([expr], command) }
188
188
  end
189
189
 
190
190
  def depth(expr, command)
@@ -2,7 +2,10 @@ require_relative 'ios/document'
2
2
 
3
3
  module IOSParser
4
4
  class IOS
5
- attr_accessor :lexer, :tokens, :source, :document
5
+ attr_accessor :document
6
+ attr_accessor :lexer
7
+ attr_accessor :source
8
+ attr_writer :tokens
6
9
 
7
10
  def initialize(parent: nil, lexer: IOSParser::Lexer.new)
8
11
  @document = Document.new(nil)
@@ -133,8 +133,8 @@ module IOSParser
133
133
  end
134
134
  end
135
135
 
136
- def banner_garbage?(i)
137
- tokens[i].last == :BANNER_END && tokens[i + 1].last == 'C'
136
+ def banner_garbage?(pos)
137
+ tokens[pos].last == :BANNER_END && tokens[pos + 1].last == 'C'
138
138
  end
139
139
 
140
140
  def certificate_begin?
@@ -1,7 +1,7 @@
1
1
  module IOSParser
2
2
  class << self
3
3
  def version
4
- '0.5.0'
4
+ '0.5.1'
5
5
  end
6
6
  end
7
7
  end
data/lib/ios_parser.rb CHANGED
@@ -12,7 +12,7 @@ module IOSParser
12
12
  end
13
13
  rescue LoadError
14
14
  require 'ios_parser/lexer'
15
- return PureLexer
15
+ PureLexer
16
16
  end
17
17
 
18
18
  Lexer = lexer
@@ -4,16 +4,16 @@ require 'ios_parser'
4
4
  module IOSParser
5
5
  class IOS
6
6
  describe Queryable do
7
- let(:input) { <<-END }
8
- policy-map mypolicy_in
9
- class some_service
10
- police 300000000 1000000 exceed-action policed-dscp-transmit
11
- set dscp cs1
12
- class my_service
13
- police 600000000 1000000 exceed-action policed-dscp-transmit
14
- set dscp cs2
15
- command_with_no_args
16
- END
7
+ let(:input) { <<-END.unindent }
8
+ policy-map mypolicy_in
9
+ class some_service
10
+ police 300000000 1000000 exceed-action policed-dscp-transmit
11
+ set dscp cs1
12
+ class my_service
13
+ police 600000000 1000000 exceed-action policed-dscp-transmit
14
+ set dscp cs2
15
+ command_with_no_args
16
+ END
17
17
 
18
18
  let(:expectation) { 'set dscp cs1' }
19
19
  let(:parsed) { IOSParser.parse(input) }
@@ -5,36 +5,36 @@ require 'ios_parser/lexer'
5
5
  module IOSParser
6
6
  describe IOS do
7
7
  context 'indented region' do
8
- let(:input) { <<-END }
9
- policy-map mypolicy_in
10
- class myservice_service
11
- police 300000000 1000000 exceed-action policed-dscp-transmit
12
- set dscp cs1
13
- class other_service
14
- police 600000000 1000000 exceed-action policed-dscp-transmit
15
- set dscp cs2
16
- command_with_no_args
17
- END
8
+ let(:input) { <<-END.unindent }
9
+ policy-map mypolicy_in
10
+ class myservice_service
11
+ police 300000000 1000000 exceed-action policed-dscp-transmit
12
+ set dscp cs1
13
+ class other_service
14
+ police 600000000 1000000 exceed-action policed-dscp-transmit
15
+ set dscp cs2
16
+ command_with_no_args
17
+ END
18
18
 
19
19
  let(:output) do
20
20
  {
21
21
  commands:
22
22
  [{ args: ['policy-map', 'mypolicy_in'],
23
23
  commands:
24
- [{ args: %w(class myservice_service),
24
+ [{ args: %w[class myservice_service],
25
25
  commands: [{ args: ['police', 300_000_000, 1_000_000,
26
26
  'exceed-action',
27
27
  'policed-dscp-transmit'],
28
- commands: [{ args: %w(set dscp cs1),
28
+ commands: [{ args: %w[set dscp cs1],
29
29
  commands: [], pos: 114 }],
30
30
  pos: 50 }],
31
31
  pos: 24 },
32
32
 
33
- { args: %w(class other_service),
33
+ { args: %w[class other_service],
34
34
  commands: [{ args: ['police', 600_000_000, 1_000_000,
35
35
  'exceed-action',
36
36
  'policed-dscp-transmit'],
37
- commands: [{ args: %w(set dscp cs2),
37
+ commands: [{ args: %w[set dscp cs2],
38
38
  commands: [], pos: 214 },
39
39
  { args: ['command_with_no_args'],
40
40
  commands: [], pos: 230 }],
@@ -58,9 +58,9 @@ END
58
58
 
59
59
  it('can be searched by an exact command') do
60
60
  expect(subject.find_all(name: 'set').map(&:to_hash))
61
- .to eq [{ args: %w(set dscp cs1),
61
+ .to eq [{ args: %w[set dscp cs1],
62
62
  commands: [], pos: 114 },
63
- { args: %w(set dscp cs2),
63
+ { args: %w[set dscp cs2],
64
64
  commands: [], pos: 214 }]
65
65
  end
66
66
 
@@ -73,7 +73,7 @@ END
73
73
  let(:expectation) { [output[:commands][0][:commands][1]] }
74
74
 
75
75
  context 'with an array of strings' do
76
- let(:starts_with) { %w(class other_service) }
76
+ let(:starts_with) { %w[class other_service] }
77
77
  it { result }
78
78
  end
79
79
 
@@ -91,7 +91,7 @@ END
91
91
  let(:expectation) do
92
92
  [{ args: ['police', 300_000_000, 1_000_000, 'exceed-action',
93
93
  'policed-dscp-transmit'],
94
- commands: [{ args: %w(set dscp cs1),
94
+ commands: [{ args: %w[set dscp cs1],
95
95
  commands: [], pos: 114 }],
96
96
  pos: 50 }]
97
97
  end
@@ -114,7 +114,7 @@ END
114
114
  .find('policy-map').find('class').find('police')
115
115
  .find('set')
116
116
  .to_hash)
117
- .to eq(args: %w(set dscp cs1),
117
+ .to eq(args: %w[set dscp cs1],
118
118
  commands: [], pos: 114)
119
119
  end
120
120
  end # context 'nested search'
@@ -123,19 +123,19 @@ END
123
123
  it 'is evaluated for each matching command' do
124
124
  ary = []
125
125
  subject.find_all('class') { |cmd| ary << cmd.args[1] }
126
- expect(ary).to eq %w(myservice_service other_service)
126
+ expect(ary).to eq %w[myservice_service other_service]
127
127
  end
128
128
  end # context 'pass a block'
129
129
  end # end context 'indented region'
130
130
 
131
131
  context '2950' do
132
- let(:input) { <<END }
133
- hostname myswitch1
134
- vlan 3
135
- name MyVlanName
136
- interface FastEthernet0/1
137
- speed 100
138
- END
132
+ let(:input) { <<-END.unindent }
133
+ hostname myswitch1
134
+ vlan 3
135
+ name MyVlanName
136
+ interface FastEthernet0/1
137
+ speed 100
138
+ END
139
139
 
140
140
  let(:output) { klass.new.call(input) }
141
141
 
@@ -152,8 +152,8 @@ END
152
152
  end
153
153
 
154
154
  it('parses snmp commands') do
155
- snmp_command = <<-END
156
- snmp-server group my_group v3 auth read my_ro
155
+ snmp_command = <<-END.unindent
156
+ snmp-server group my_group v3 auth read my_ro
157
157
  END
158
158
  result = klass.new.call(snmp_command)
159
159
  expect(result[0].name).to eq 'snmp-server'
@@ -176,14 +176,14 @@ snmp-server group my_group v3 auth read my_ro
176
176
  end
177
177
 
178
178
  it('parses a banner') do
179
- banner_text = <<-END
179
+ banner_text = <<-END.unindent
180
180
 
181
181
 
182
- Lorem ipsum dolor sit amet, consectetur adipiscing elit,
183
- sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
182
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit,
183
+ sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
184
184
 
185
185
 
186
- END
186
+ END
187
187
  banner_command = "banner exec ^C\n#{banner_text}^C\n"
188
188
 
189
189
  result = klass.new.call(banner_command)
@@ -195,44 +195,44 @@ END
195
195
  end
196
196
 
197
197
  it('parses a crypto trustpoint section') do
198
- text = <<END
199
- crypto pki trustpoint TP-self-signed-0123456789
200
- enrollment selfsigned
201
- subject-name cn=IOS-Self-Signed-Certificate-1234567890
202
- revocation-check none
203
- rsakeypair TP-self-signed-2345678901
204
- END
198
+ text = <<-END.unindent
199
+ crypto pki trustpoint TP-self-signed-0123456789
200
+ enrollment selfsigned
201
+ subject-name cn=IOS-Self-Signed-Certificate-1234567890
202
+ revocation-check none
203
+ rsakeypair TP-self-signed-2345678901
204
+ END
205
205
  result = klass.new.call(text)
206
206
  expect(result).not_to be_nil
207
207
  end
208
208
 
209
209
  it('parses a crypto certificate section') do
210
210
  sp = ' '
211
- text = <<END
212
- crypto pki certificate chain TP-self-signed-1234567890
213
- certificate self-signed 01
214
- FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF#{sp}
215
- EEEEEEEE EEEEEEEE EEEEEEEE EEEEEEEE EEEEEEEE EEEEEEEE EEEEEEEE EEEEEEEE#{sp}
216
- DDDDDDDD DDDDDDDD DDDDDDDD DDDDDDDD DDDDDDDD DDDDDDDD DDDDDDDD DDDDDDDD#{sp}
217
- CCCCCCCC CCCCCCCC
218
- quit
211
+ text = <<-END.unindent
212
+ crypto pki certificate chain TP-self-signed-1234567890
213
+ certificate self-signed 01
214
+ FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF#{sp}
215
+ EEEEEEEE EEEEEEEE EEEEEEEE EEEEEEEE EEEEEEEE EEEEEEEE EEEEEEEE EEEEEEEE#{sp}
216
+ DDDDDDDD DDDDDDDD DDDDDDDD DDDDDDDD DDDDDDDD DDDDDDDD DDDDDDDD DDDDDDDD#{sp}
217
+ CCCCCCCC CCCCCCCC
218
+ quit
219
219
 
220
- END
220
+ END
221
221
 
222
222
  result = klass.new.call(text)
223
223
  expect(result).not_to be_nil
224
224
  end
225
225
 
226
226
  it('parses an MST configuration section') do
227
- text = <<END
228
- spanning-tree mst configuration
229
- name MyMSTConfig
230
- revision 1
231
- instance 1 vlan 1-59, 4000
232
- instance 2 vlan 90-99
233
- instance 3 vlan 100-1500
234
- instance 4 vlan 2000-3500, 4000
235
- END
227
+ text = <<-END.unindent
228
+ spanning-tree mst configuration
229
+ name MyMSTConfig
230
+ revision 1
231
+ instance 1 vlan 1-59, 4000
232
+ instance 2 vlan 90-99
233
+ instance 3 vlan 100-1500
234
+ instance 4 vlan 2000-3500, 4000
235
+ END
236
236
 
237
237
  result = klass.new.call(text)
238
238
  expect(result).not_to be_nil
@@ -240,12 +240,12 @@ END
240
240
  end # context '2950'
241
241
 
242
242
  it('finds various ip route formats') do
243
- text = <<END
244
- ip route 10.0.0.1 255.255.255.255 Null0
245
- ip route 9.9.9.199 255.255.255.255 42.42.42.142 name PONIES
246
- ip route vrf Mgmt-intf 0.0.0.0 0.0.0.0 9.9.9.199
247
- ip route 0.0.0.0/0 11.11.0.111 120
248
- END
243
+ text = <<-END.unindent
244
+ ip route 10.0.0.1 255.255.255.255 Null0
245
+ ip route 9.9.9.199 255.255.255.255 42.42.42.142 name PONIES
246
+ ip route vrf Mgmt-intf 0.0.0.0 0.0.0.0 9.9.9.199
247
+ ip route 0.0.0.0/0 11.11.0.111 120
248
+ END
249
249
 
250
250
  result = klass.new.call(text)
251
251
 
@@ -275,11 +275,11 @@ END
275
275
 
276
276
  describe '#to_s' do
277
277
  subject { klass.new.call(input) }
278
- let(:police2) { <<END }
278
+ let(:police2) { <<-END }
279
279
  police 600000000 1000000 exceed-action policed-dscp-transmit
280
280
  set dscp cs2
281
281
  command_with_no_args
282
- END
282
+ END
283
283
 
284
284
  it('returns the string form of the original command(s)') do
285
285
  expect(subject.to_s).to eq input
@@ -12,14 +12,14 @@ module IOSParser
12
12
  end
13
13
 
14
14
  context 'indented region' do
15
- let(:input) { <<-END }
16
- policy-map mypolicy_in
17
- class myservice_service
18
- police 300000000 1000000 exceed-action policed-dscp-transmit
19
- set dscp cs1
20
- class other_service
21
- police 600000000 1000000 exceed-action policed-dscp-transmit
22
- set dscp cs2
15
+ let(:input) { <<-END.unindent }
16
+ policy-map mypolicy_in
17
+ class myservice_service
18
+ police 300000000 1000000 exceed-action policed-dscp-transmit
19
+ set dscp cs1
20
+ class other_service
21
+ police 600000000 1000000 exceed-action policed-dscp-transmit
22
+ set dscp cs2
23
23
  END
24
24
 
25
25
  let(:output) do
@@ -50,16 +50,16 @@ END
50
50
 
51
51
  context 'ASR indented regions' do
52
52
  context 'indented region' do
53
- let(:input) { <<-END }
54
- router static
55
- vrf MGMT
56
- address-family ipv4 unicast
57
- 0.0.0.0/0 1.2.3.4
58
- !
59
- !
60
- !
61
- router ospf 12345
62
- nsr
53
+ let(:input) { <<-END.unindent }
54
+ router static
55
+ vrf MGMT
56
+ address-family ipv4 unicast
57
+ 0.0.0.0/0 1.2.3.4
58
+ !
59
+ !
60
+ !
61
+ router ospf 12345
62
+ nsr
63
63
  END
64
64
 
65
65
  let(:expectation) do
@@ -87,12 +87,12 @@ END
87
87
 
88
88
  context 'banners' do
89
89
  let(:input) do
90
- <<-END
91
- banner foobar ^
92
- asdf 1234 9786 asdf
93
- line 2
94
- line 3
95
- ^
90
+ <<-END.unindent
91
+ banner foobar ^
92
+ asdf 1234 9786 asdf
93
+ line 2
94
+ line 3
95
+ ^
96
96
  END
97
97
  end
98
98
 
@@ -144,14 +144,14 @@ END
144
144
 
145
145
  context 'cryptographic certificate' do
146
146
  let(:input) do
147
- <<END
148
- crypto pki certificate chain TP-self-signed-0123456789
149
- certificate self-signed 01
150
- FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF
151
- EEEEEEEE EEEEEEEE EEEEEEEE EEEEEEEE EEEEEEEE EEEEEEEE EEEEEEEE EEEEEEEE
152
- DDDDDDDD DDDDDDDD DDDDDDDD DDDDDDDD DDDDDDDD DDDDDDDD DDDDDDDD DDDDDDDD AAAA
153
- quit
154
- !
147
+ <<END.unindent
148
+ crypto pki certificate chain TP-self-signed-0123456789
149
+ certificate self-signed 01
150
+ FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF
151
+ EEEEEEEE EEEEEEEE EEEEEEEE EEEEEEEE EEEEEEEE EEEEEEEE EEEEEEEE EEEEEEEE
152
+ DDDDDDDD DDDDDDDD DDDDDDDD DDDDDDDD DDDDDDDD DDDDDDDD DDDDDDDD DDDDDDDD AAAA
153
+ quit
154
+ !
155
155
  END
156
156
  end
157
157
 
@@ -193,11 +193,11 @@ END
193
193
  end
194
194
 
195
195
  context 'quoted octothorpe' do
196
- let(:input) { <<-EOS }
197
- vlan 1
198
- name "a #"
199
- vlan 2
200
- name d
196
+ let(:input) { <<-EOS.unindent }
197
+ vlan 1
198
+ name "a #"
199
+ vlan 2
200
+ name d
201
201
  EOS
202
202
 
203
203
  let(:output) do
@@ -231,10 +231,10 @@ vlan 2
231
231
 
232
232
  context 'partial dedent' do
233
233
  let(:input) do
234
- <<END
235
- class-map match-any foobar
236
- description blahblahblah
237
- match access-group fred
234
+ <<END.unindent
235
+ class-map match-any foobar
236
+ description blahblahblah
237
+ match access-group fred
238
238
  END
239
239
  end
240
240
 
@@ -4,36 +4,36 @@ require 'ios_parser'
4
4
  describe IOSParser do
5
5
  describe '.parse' do
6
6
  context 'indented region' do
7
- let(:input) { <<-END }
8
- policy-map mypolicy_in
9
- class myservice_service
10
- police 300000000 1000000 exceed-action policed-dscp-transmit
11
- set dscp cs1
12
- class other_service
13
- police 600000000 1000000 exceed-action policed-dscp-transmit
14
- set dscp cs2
15
- command_with_no_args
16
- END
7
+ let(:input) { <<-END.unindent }
8
+ policy-map mypolicy_in
9
+ class myservice_service
10
+ police 300000000 1000000 exceed-action policed-dscp-transmit
11
+ set dscp cs1
12
+ class other_service
13
+ police 600000000 1000000 exceed-action policed-dscp-transmit
14
+ set dscp cs2
15
+ command_with_no_args
16
+ END
17
17
 
18
18
  let(:output) do
19
19
  {
20
20
  commands:
21
21
  [{ args: ['policy-map', 'mypolicy_in'],
22
22
  commands:
23
- [{ args: %w(class myservice_service),
23
+ [{ args: %w[class myservice_service],
24
24
  commands: [{ args: ['police', 300_000_000, 1_000_000,
25
25
  'exceed-action',
26
26
  'policed-dscp-transmit'],
27
- commands: [{ args: %w(set dscp cs1),
27
+ commands: [{ args: %w[set dscp cs1],
28
28
  commands: [], pos: 114 }],
29
29
  pos: 50 }],
30
30
  pos: 24 },
31
31
 
32
- { args: %w(class other_service),
32
+ { args: %w[class other_service],
33
33
  commands: [{ args: ['police', 600_000_000, 1_000_000,
34
34
  'exceed-action',
35
35
  'policed-dscp-transmit'],
36
- commands: [{ args: %w(set dscp cs2),
36
+ commands: [{ args: %w[set dscp cs2],
37
37
  commands: [], pos: 214 },
38
38
  { args: ['command_with_no_args'],
39
39
  commands: [], pos: 230 }],
@@ -53,11 +53,11 @@ END
53
53
 
54
54
  context 'partial outdent' do
55
55
  let(:input) do
56
- <<END
57
- class-map match-any foobar
58
- description blah blah blah
59
- match access-group fred
60
- END
56
+ <<-END.unindent
57
+ class-map match-any foobar
58
+ description blah blah blah
59
+ match access-group fred
60
+ END
61
61
  end
62
62
 
63
63
  let(:output) do
@@ -68,7 +68,7 @@ END
68
68
  args: ['class-map', 'match-any', 'foobar'],
69
69
  commands: [
70
70
  {
71
- args: %w(description blah blah blah),
71
+ args: %w[description blah blah blah],
72
72
  commands: [],
73
73
  pos: 29
74
74
  },
data/spec/spec_helper.rb CHANGED
@@ -7,3 +7,13 @@ end
7
7
  def text_fixture(name)
8
8
  File.read(File.expand_path(__dir__ + "/../fixtures/#{name}.txt"))
9
9
  end
10
+
11
+ class String
12
+ def unindent
13
+ indent = split("\n")
14
+ .reject { |line| line.strip.empty? }
15
+ .map { |line| line.index(/[^\s]/) }
16
+ .compact.min || 0
17
+ gsub(/^[[:blank:]]{#{indent}}/, '')
18
+ end
19
+ end
metadata CHANGED
@@ -1,57 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ios_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Miller
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-26 00:00:00.000000000 Z
11
+ date: 2018-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rspec
14
+ name: rake-compiler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '3.2'
19
+ version: '0.9'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '3.2'
26
+ version: '0.9'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rubocop
28
+ name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.37'
33
+ version: '3.2'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0.37'
40
+ version: '3.2'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rake-compiler
42
+ name: rubocop
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0.9'
47
+ version: '0.54'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0.9'
54
+ version: '0.54'
55
55
  description:
56
56
  email: bjmllr@gmail.com
57
57
  executables: []
@@ -110,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
110
110
  version: '0'
111
111
  requirements: []
112
112
  rubyforge_project:
113
- rubygems_version: 2.5.2
113
+ rubygems_version: 2.7.3
114
114
  signing_key:
115
115
  specification_version: 4
116
116
  summary: convert network switch and router config files to structured data