ios_parser 0.7.1 → 0.9.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
2
  SHA256:
3
- metadata.gz: 7ca27e440ca7f9a38c976bff002dc996725d77e1ec3fcd12749e119b910ed08d
4
- data.tar.gz: 5c59a60ccdf9c10e5d6fd8841dfb2eac7fae046b3447aa401cc61982210d9b08
3
+ metadata.gz: 1af0b045e17fe043f6309c0d39c47dad8a193890fbac92cdebd7e64363047a71
4
+ data.tar.gz: dd52ebd34d8571a5accf1304007a22cfec3347a3225ec7d5f7ed6495eb7cd6fd
5
5
  SHA512:
6
- metadata.gz: 68394ff82c8d23b91accdd947529e352d09459d1fd6a5747ab4bb3ec7a53863b01cf8079fffb0e3f9b941c443451664e2acd2c4201ba7c06cea5b6bfe4ab584a
7
- data.tar.gz: 33106cf36832dc6d082f278bf5d2a324d03274b37eb496828b29180587e812577b94387bcb9ec6428ed961710da9662c9b24b6b2923fe4f35003e196dcbd95f2
6
+ metadata.gz: ec03dae6277cea48f160fec4613746a06a74dce16d96841eff20569b481a5b9bffccaa425501e95c07b248b60952b9f48a475135735dc02917949511d9064756
7
+ data.tar.gz: 10db031217e4488e390f35a6f071f691c20ba60f8a838879e24f4e29987da18068459367504c95e6d0853949a337e0b890cc9aab60b936c8f7bec9e9fb67fa2b
@@ -0,0 +1,48 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: Ruby
9
+
10
+ on:
11
+ push:
12
+ branches: [ "master" ]
13
+ pull_request:
14
+ branches: [ "master" ]
15
+
16
+ permissions:
17
+ contents: read
18
+
19
+ jobs:
20
+ test:
21
+ runs-on: ubuntu-latest
22
+ strategy:
23
+ matrix:
24
+ ruby-version:
25
+ - '2.0'
26
+ - '2.1'
27
+ - '2.2'
28
+ - '2.3'
29
+ - '2.4'
30
+ - '2.5'
31
+ - '2.6'
32
+ - '2.7'
33
+ - '3.0'
34
+ - '3.1'
35
+ - jruby-9.1.17.0
36
+ - jruby-9.2.21.0
37
+ - jruby-9.3.6.0
38
+
39
+ steps:
40
+ - uses: actions/checkout@v3
41
+ - name: Set up Ruby
42
+ # https://github.com/ruby/setup-ruby#versioning
43
+ uses: ruby/setup-ruby@v1
44
+ with:
45
+ ruby-version: ${{ matrix.ruby-version }}
46
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
47
+ - name: Run tests
48
+ run: bundle exec rake
data/ios_parser.gemspec CHANGED
@@ -19,6 +19,8 @@ Gem::Specification.new do |s|
19
19
  s.extensions << 'ext/ios_parser/c_lexer/extconf.rb'
20
20
  end
21
21
 
22
+ s.required_ruby_version = '>=2.0'
23
+
22
24
  s.add_development_dependency 'rake-compiler', '~>0.9'
23
25
  s.add_development_dependency 'rspec', '~>3.2'
24
26
  s.add_development_dependency 'rubocop', '~> 0.54' if RUBY_VERSION > '2.1'
@@ -21,7 +21,7 @@ module IOSParser
21
21
  end
22
22
 
23
23
  def name
24
- tokens.first.value
24
+ (tokens.first) && tokens.first.value
25
25
  end
26
26
 
27
27
  def ==(other)
@@ -64,7 +64,7 @@ module IOSParser
64
64
 
65
65
  def to_s(dedent: false)
66
66
  indent_opts = { base: dedent ? path.length : 0 }
67
- map { |cmd| "#{cmd.indentation(indent_opts)}#{cmd.line}\n" }.join
67
+ map { |cmd| "#{cmd.indentation(**indent_opts)}#{cmd.line}\n" }.join
68
68
  end
69
69
 
70
70
  def to_hash
@@ -92,7 +92,7 @@ module IOSParser
92
92
  hash[:commands].each_index do |i|
93
93
  hash[:commands][i] = from_hash(hash[:commands][i])
94
94
  end
95
- new(hash)
95
+ new(**hash)
96
96
  end
97
97
  end
98
98
  end # class Command
@@ -46,7 +46,7 @@ module IOSParser
46
46
  indent: @indent
47
47
  }
48
48
 
49
- Command.new(opts).tap do |cmd|
49
+ Command.new(**opts).tap do |cmd|
50
50
  cmd.commands = subsections(cmd)
51
51
  end
52
52
  end
@@ -287,7 +287,8 @@ module IOSParser
287
287
  ('A'..'Z').cover?(char) ||
288
288
  ['-', '+', '$', ':', '/', ',', '(', ')', '|', '*', '#', '=', '<', '>',
289
289
  '!', '"', '&', '@', ';', '%', '~', '{', '}', "'", '?', '[', ']', '_',
290
- '^', '\\', '`'].include?(char)
290
+ '^', '\\', '`'].include?(char) ||
291
+ /[[:graph:]]/.match(char)
291
292
  end
292
293
 
293
294
  def space
@@ -1,7 +1,7 @@
1
1
  module IOSParser
2
2
  class << self
3
3
  def version
4
- '0.7.1'
4
+ '0.9.0'
5
5
  end
6
6
  end
7
7
  end
@@ -0,0 +1,16 @@
1
+ require_relative '../../spec_helper'
2
+ require 'ios_parser'
3
+ require 'ios_parser/lexer'
4
+
5
+ module IOSParser
6
+ describe PureLexer do
7
+ describe '#call' do
8
+ it 'accepts non-whitespace printable characters as words' do
9
+ input = "before emdash – after emdash"
10
+ tokens = PureLexer.new.call(input)
11
+ expect(tokens.map(&:value)).to eq %w[before emdash – after emdash]
12
+ expect(tokens.map(&:col)).to eq [1, 8, 15, 17, 23]
13
+ end
14
+ end
15
+ end
16
+ end
@@ -3,6 +3,20 @@ require 'ios_parser'
3
3
 
4
4
  describe IOSParser do
5
5
  describe '.parse' do
6
+ context 'with blank line at start' do
7
+ it 'parses and extracts sections' do
8
+ parser = IOSParser.parse("\ntest config")
9
+ expect(parser.find_all(name: "test").count).to eq 1
10
+ end
11
+ end
12
+
13
+ context 'with blank line in middle' do
14
+ it 'parses and extracts sections' do
15
+ parser = IOSParser.parse("preamble\n\ntest config")
16
+ expect(parser.find_all(name: "test").count).to eq 1
17
+ end
18
+ end
19
+
6
20
  context 'indented region' do
7
21
  let(:input) { <<-END.unindent }
8
22
  policy-map mypolicy_in
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.7.1
4
+ version: 0.9.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: 2022-01-13 00:00:00.000000000 Z
11
+ date: 2022-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler
@@ -59,9 +59,9 @@ extensions:
59
59
  - ext/ios_parser/c_lexer/extconf.rb
60
60
  extra_rdoc_files: []
61
61
  files:
62
+ - ".github/workflows/ruby.yml"
62
63
  - ".gitignore"
63
64
  - ".rubocop.yml"
64
- - ".travis.yml"
65
65
  - CHANGELOG.md
66
66
  - CODE_OF_CONDUCT.md
67
67
  - Gemfile
@@ -89,6 +89,7 @@ files:
89
89
  - spec/lib/ios_parser/ios/queryable_spec.rb
90
90
  - spec/lib/ios_parser/ios_spec.rb
91
91
  - spec/lib/ios_parser/lexer_spec.rb
92
+ - spec/lib/ios_parser/pure_spec.rb
92
93
  - spec/lib/ios_parser_spec.rb
93
94
  - spec/spec_helper.rb
94
95
  homepage: https://github.com/bjmllr/ios_parser
@@ -103,14 +104,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
103
104
  requirements:
104
105
  - - ">="
105
106
  - !ruby/object:Gem::Version
106
- version: '0'
107
+ version: '2.0'
107
108
  required_rubygems_version: !ruby/object:Gem::Requirement
108
109
  requirements:
109
110
  - - ">="
110
111
  - !ruby/object:Gem::Version
111
112
  version: '0'
112
113
  requirements: []
113
- rubygems_version: 3.1.4
114
+ rubygems_version: 3.3.7
114
115
  signing_key:
115
116
  specification_version: 4
116
117
  summary: convert network switch and router config files to structured data
@@ -118,5 +119,6 @@ test_files:
118
119
  - spec/lib/ios_parser/ios/queryable_spec.rb
119
120
  - spec/lib/ios_parser/ios_spec.rb
120
121
  - spec/lib/ios_parser/lexer_spec.rb
122
+ - spec/lib/ios_parser/pure_spec.rb
121
123
  - spec/lib/ios_parser_spec.rb
122
124
  - spec/spec_helper.rb
data/.travis.yml DELETED
@@ -1,17 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.0.0
4
- - 2.1.10
5
- - 2.2.10
6
- - 2.3.8
7
- - 2.4.5
8
- - 2.5.3
9
- - jruby-9.1.16.0
10
- - jruby-9.2.0.0
11
- matrix:
12
- include:
13
- - rvm: jruby
14
- env: JRUBY_OPTS='-Xcompat.version=2.0'
15
- bundler_args: --without guard
16
- before_install:
17
- - if [ "jruby" != "$TRAVIS_RUBY_VERSION" ]; then gem i rubygems-update -v '<3' && update_rubygems; gem install bundler -v 1.17.3 --without guard; fi