Skip to content

Commit 9ed7593

Browse files
committed
Provide the same interface to access output_file as rubycritic
1 parent c7b3257 commit 9ed7593

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

lib/skunk/cli/options.rb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@ def parse
2020
self
2121
end
2222

23-
# :reek:NilCheck
24-
def output_stream
25-
output_filename = @argv_options.output_filename
26-
output_filename.nil? ? $stdout : File.open(output_filename, "w")
27-
end
28-
2923
# :reek:NilCheck
3024
def to_h
3125
file_hash = file_options.to_h

lib/skunk/cli/options/argv.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class Options
99
# Extends RubyCritic::Cli::Options::Argv to parse a subset of the
1010
# parameters accepted by RubyCritic
1111
class Argv < RubyCritic::Cli::Options::Argv
12-
attr_reader :output_filename
12+
attr_accessor :output_filename
1313

1414
def parse # rubocop:disable Metrics/MethodLength
1515
parser.new do |opts|
@@ -22,7 +22,7 @@ def parse # rubocop:disable Metrics/MethodLength
2222
end
2323

2424
opts.on("-o", "--out FILE", "Output report to file") do |filename|
25-
@output_filename = filename
25+
self.output_filename = filename
2626
end
2727

2828
opts.on_tail("-v", "--version", "Show gem's version") do
@@ -34,6 +34,10 @@ def parse # rubocop:disable Metrics/MethodLength
3434
end
3535
end.parse!(@argv)
3636
end
37+
38+
def to_h
39+
super.merge({ output_filename: output_filename })
40+
end
3741
end
3842
end
3943
end

0 commit comments

Comments
 (0)