Skip to content

Commit 2723a7c

Browse files
committed
Merge branch 'rubocop'
2 parents af4cccb + 767f1a8 commit 2723a7c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+710
-549
lines changed

.rubocop.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
Gemspec/RequiredRubyVersion:
2+
Enabled: false
3+
4+
Layout/LineLength:
5+
Enabled: false
6+
7+
Metrics/ClassLength:
8+
Enabled: false
9+
Metrics/MethodLength:
10+
Enabled: false
11+
Metrics/BlockLength:
12+
Enabled: false
13+
Metrics/CyclomaticComplexity:
14+
Enabled: false
15+
Metrics/PerceivedComplexity:
16+
Enabled: false
17+
Metrics/AbcSize:
18+
Enabled: false
19+
20+
Style/Documentation:
21+
Enabled: false
22+
23+
AllCops:
24+
NewCops: enable
25+
Exclude:
26+
- example/**/*
27+
- lib/junoser/parser.rb
28+
- tmp/rule.rb

Gemfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1+
# frozen_string_literal: true
2+
13
source 'https://rubygems.org'
24

35
# Specify your gem's dependencies in junoser.gemspec
46
gemspec
7+
8+
group :development do
9+
gem 'bundler', '~> 2.0'
10+
gem 'nokogiri'
11+
gem 'rake', '~> 13.0'
12+
gem 'rubocop'
13+
gem 'test-unit'
14+
end

Gemfile.lock

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,45 @@ PATH
77
GEM
88
remote: https://rubygems.org/
99
specs:
10+
ast (2.4.3)
11+
json (2.15.0)
12+
language_server-protocol (3.17.0.5)
13+
lint_roller (1.1.0)
1014
mini_portile2 (2.8.9)
1115
nokogiri (1.18.10)
1216
mini_portile2 (~> 2.8.2)
1317
racc (~> 1.4)
18+
parallel (1.27.0)
19+
parser (3.3.9.0)
20+
ast (~> 2.4.1)
21+
racc
1422
parslet (2.0.0)
1523
power_assert (2.0.5)
24+
prism (1.5.1)
1625
racc (1.8.1)
26+
rainbow (3.1.1)
1727
rake (13.3.0)
28+
regexp_parser (2.11.3)
29+
rubocop (1.81.1)
30+
json (~> 2.3)
31+
language_server-protocol (~> 3.17.0.2)
32+
lint_roller (~> 1.1.0)
33+
parallel (~> 1.10)
34+
parser (>= 3.3.0.2)
35+
rainbow (>= 2.2.2, < 4.0)
36+
regexp_parser (>= 2.9.3, < 3.0)
37+
rubocop-ast (>= 1.47.1, < 2.0)
38+
ruby-progressbar (~> 1.7)
39+
unicode-display_width (>= 2.4.0, < 4.0)
40+
rubocop-ast (1.47.1)
41+
parser (>= 3.3.7.2)
42+
prism (~> 1.4)
43+
ruby-progressbar (1.13.0)
1844
test-unit (3.7.0)
1945
power_assert
46+
unicode-display_width (3.2.0)
47+
unicode-emoji (~> 4.1)
48+
unicode-emoji (4.1.0)
2049

2150
PLATFORMS
2251
ruby
@@ -26,6 +55,7 @@ DEPENDENCIES
2655
junoser!
2756
nokogiri
2857
rake (~> 13.0)
58+
rubocop
2959
test-unit
3060

3161
BUNDLED WITH

Rakefile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'bundler/gem_tasks'
24
require 'junoser/development'
35
require 'nokogiri'
@@ -9,9 +11,9 @@ rule_path = File.join(__dir__, 'tmp/rule.rb')
911
ruby_parser_path = File.join(__dir__, 'lib/junoser/parser.rb')
1012
js_parser_path = File.join(__dir__, 'tmp/junos.js')
1113

12-
def open_files(input, output, &block)
13-
i = open(input)
14-
o = open(output, 'w')
14+
def open_files(input, output)
15+
i = File.open(input)
16+
o = File.open(output, 'w')
1517

1618
yield i, o
1719

@@ -71,6 +73,7 @@ namespace :rule do
7173
task :tree, [:path] do |_, args|
7274
if args.path
7375
raise "File not found: #{args.path}" unless File.exist?(args.path)
76+
7477
Junoser::RuleTree::Parser.new(File.read(args.path)).print
7578
else
7679
Junoser::RuleTree::Parser.new($stdin.read).print

bin/console

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
23

3-
require "bundler/setup"
4-
require "junoser"
4+
require 'bundler/setup'
5+
require 'junoser'
56

67
# You can add fixtures and/or initialization code here to make experimenting
78
# with your gem easier. You can also use a different console, if you like.
@@ -10,5 +11,5 @@ require "junoser"
1011
# require "pry"
1112
# Pry.start
1213

13-
require "irb"
14+
require 'irb'
1415
IRB.start

exe/junoser

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
23

4+
require 'English'
35
require 'optparse'
46
require 'pathname'
57

6-
$: << File.expand_path('../../lib', Pathname.new(__FILE__).realpath)
8+
$LOAD_PATH << File.expand_path('../../lib', Pathname.new(__FILE__).realpath)
79

810
require 'junoser'
911

10-
1112
command = nil
1213
opts = OptionParser.new do |opts|
1314
opts.banner = 'junoser: an juniper configuration parser'
@@ -41,11 +42,11 @@ opts.parse!
4142

4243
case command
4344
when :check
44-
abort unless Junoser::Cli.commit_check($<)
45+
abort unless Junoser::Cli.commit_check($DEFAULT_INPUT)
4546
when :display_set
46-
puts Junoser::Cli.display_set($<)
47+
puts Junoser::Cli.display_set($DEFAULT_INPUT)
4748
when :struct
48-
puts Junoser::Cli.struct($<)
49+
puts Junoser::Cli.struct($DEFAULT_INPUT)
4950
else
5051
puts opts
5152
abort

exe/junoser-squash

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
3+
4+
require 'English'
25
require 'optparse'
36
require 'pathname'
47

5-
$: << File.expand_path('../../lib', Pathname.new(__FILE__).realpath)
8+
$LOAD_PATH << File.expand_path('../../lib', Pathname.new(__FILE__).realpath)
69
require 'junoser/squash'
710

811
command = :squash
@@ -17,9 +20,9 @@ opts = OptionParser.new do |opts|
1720
end
1821
opts.parse!
1922
case command
20-
when :squash
21-
puts Junoser::Squash.new($<).transform
22-
else
23-
puts opts
24-
abort
23+
when :squash
24+
puts Junoser::Squash.new($DEFAULT_INPUT).transform
25+
else
26+
puts opts
27+
abort
2528
end

junoser.gemspec

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,29 @@
1-
# coding: utf-8
2-
lib = File.expand_path('../lib', __FILE__)
1+
# frozen_string_literal: true
2+
3+
lib = File.expand_path('lib', __dir__)
34
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
45
require 'junoser/version'
56

67
Gem::Specification.new do |spec|
7-
spec.name = "junoser"
8+
spec.name = 'junoser'
89
spec.version = Junoser::VERSION
9-
spec.authors = ["Shintaro Kojima"]
10-
spec.email = ["[email protected]"]
10+
spec.authors = ['Shintaro Kojima']
11+
spec.email = ['[email protected]']
1112

12-
spec.summary = %q{PEG parser for JUNOS configuration.}
13-
spec.description = %q{PEG parser to vefiry and translate into different formats for JUNOS configuration.}
14-
spec.homepage = "https://github.com/codeout/junoser"
13+
spec.summary = 'PEG parser for JUNOS configuration.'
14+
spec.description = 'PEG parser to vefiry and translate into different formats for JUNOS configuration.'
15+
spec.homepage = 'https://github.com/codeout/junoser'
1516

1617
# Specify which files should be added to the gem when it is released.
1718
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
18-
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
19+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
1920
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|example)/}) }
2021
end
21-
spec.bindir = "exe"
22+
spec.bindir = 'exe'
2223
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23-
spec.require_paths = ["lib"]
24+
spec.require_paths = ['lib']
2425

25-
spec.add_dependency "parslet"
26+
spec.add_dependency 'parslet'
2627

27-
spec.add_development_dependency "bundler", "~> 2.0"
28-
spec.add_development_dependency "rake", "~> 13.0"
29-
spec.add_development_dependency "nokogiri"
30-
spec.add_development_dependency "test-unit"
28+
spec.metadata['rubygems_mfa_required'] = 'true'
3129
end

lib/junoser.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'junoser/cli'
24
require 'junoser/display'
35
require 'junoser/parser'

lib/junoser/cli.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
# frozen_string_literal: true
2+
13
require 'parslet'
24
require 'junoser/display'
35
require 'junoser/input'
46
require 'junoser/parser'
57

6-
78
module Junoser
89
module Cli
910
class << self
@@ -37,7 +38,6 @@ def struct(io_or_string)
3738
end
3839
end
3940

40-
4141
private
4242

4343
def commit_check_structured(config)

0 commit comments

Comments
 (0)