Skip to content

Commit 767f1a8

Browse files
committed
refactor: lint
1 parent 39d90e4 commit 767f1a8

Some content is hidden

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

47 files changed

+652
-547
lines changed

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

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 & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +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"
31-
spec.add_development_dependency "rubocop"
28+
spec.metadata['rubygems_mfa_required'] = 'true'
3229
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)

lib/junoser/development.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 'underscorable'
24
require 'junoser/xsd/parsable'
35
require 'junoser/ruler'

lib/junoser/display.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/display/set'
24
require 'junoser/display/structure'
35

0 commit comments

Comments
 (0)