Class: Spellr::Check
- Inherits:
-
Object
- Object
- Spellr::Check
- Defined in:
- lib/spellr/check.rb
Instance Attribute Summary collapse
-
#files ⇒ Object
readonly
Returns the value of attribute files.
-
#reporter ⇒ Object
readonly
Returns the value of attribute reporter.
Instance Method Summary collapse
- #check ⇒ Object
-
#check_parallel ⇒ Object
rubocop:disable Metrics/MethodLength.
- #exit_code ⇒ Object
-
#initialize(files: [], reporter: Spellr.config.reporter) ⇒ Check
constructor
A new instance of Check.
Constructor Details
#initialize(files: [], reporter: Spellr.config.reporter) ⇒ Check
Returns a new instance of Check.
28 29 30 31 32 |
# File 'lib/spellr/check.rb', line 28 def initialize(files: [], reporter: Spellr.config.reporter) @files = files @main_reporter = @reporter = reporter end |
Instance Attribute Details
#files ⇒ Object (readonly)
Returns the value of attribute files.
22 23 24 |
# File 'lib/spellr/check.rb', line 22 def files @files end |
#reporter ⇒ Object (readonly)
Returns the value of attribute reporter.
22 23 24 |
# File 'lib/spellr/check.rb', line 22 def reporter @reporter end |
Instance Method Details
#check ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/spellr/check.rb', line 34 def check return check_parallel if reporter.parallel? files.each do |file| check_and_count_file(file) end reporter.finish end |
#check_parallel ⇒ Object
rubocop:disable Metrics/MethodLength
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/spellr/check.rb', line 44 def check_parallel # rubocop:disable Metrics/MethodLength acc_reporter = @reporter Parallel.each(files, finish: ->(_, _, result) { acc_reporter.output << result }) do |file| @reporter = acc_reporter.class.new(Spellr::OutputStubbed.new) check_and_count_file(file) reporter.output end @reporter = acc_reporter reporter.finish end |
#exit_code ⇒ Object
24 25 26 |
# File 'lib/spellr/check.rb', line 24 def exit_code reporter.exit_code end |