Skip to content

Commit 3d5f102

Browse files
author
Ben Miller
authored
Merge pull request #9 from stevekeay/ruby3
Fix to be compatible with ruby3.x as well as ruby2.x
2 parents 0e6542f + 55b94e6 commit 3d5f102

File tree

5 files changed

+20
-4
lines changed

5 files changed

+20
-4
lines changed

ios_parser.gemspec

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ Gem::Specification.new do |s|
1919
s.extensions << 'ext/ios_parser/c_lexer/extconf.rb'
2020
end
2121

22+
s.required_ruby_version = '>=2.0'
23+
2224
s.add_development_dependency 'rake-compiler', '~>0.9'
2325
s.add_development_dependency 'rspec', '~>3.2'
2426
s.add_development_dependency 'rubocop', '~> 0.54' if RUBY_VERSION > '2.1'

lib/ios_parser/ios.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def command(parent = nil, document = nil)
4646
indent: @indent
4747
}
4848

49-
Command.new(opts).tap do |cmd|
49+
Command.new(**opts).tap do |cmd|
5050
cmd.commands = subsections(cmd)
5151
end
5252
end

lib/ios_parser/ios/command.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def inspect
6464

6565
def to_s(dedent: false)
6666
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
6868
end
6969

7070
def to_hash
@@ -92,7 +92,7 @@ def from_hash(hash, parent = nil)
9292
hash[:commands].each_index do |i|
9393
hash[:commands][i] = from_hash(hash[:commands][i])
9494
end
95-
new(hash)
95+
new(**hash)
9696
end
9797
end
9898
end # class Command

lib/ios_parser/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module IOSParser
22
class << self
33
def version
4-
'0.7.1'
4+
'0.8.0'
55
end
66
end
77
end

spec/lib/ios_parser_spec.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,20 @@
33

44
describe IOSParser do
55
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+
620
context 'indented region' do
721
let(:input) { <<-END.unindent }
822
policy-map mypolicy_in

0 commit comments

Comments
 (0)