Class: Syntaxer::Printer
- Inherits:
-
Object
- Object
- Syntaxer::Printer
- Defined in:
- lib/syntaxer/printer.rb
Overview
Print system messages
Constant Summary collapse
- NON_EXISTENT_RULE_MESSAGE =
"exec_rule `%s` for language %s not exists. Skip"
- @@bar =
nil
- @@not_exists_rules =
[]
Class Attribute Summary collapse
-
.count_of_files ⇒ Object
Returns the value of attribute count_of_files.
-
.loud ⇒ Object
Returns the value of attribute loud.
-
.mode ⇒ Object
Returns the value of attribute mode.
-
.quite ⇒ Object
Returns the value of attribute quite.
Class Method Summary collapse
- .print_message(filestatus) ⇒ Object
-
.print_result(checker) ⇒ Object
Print error message for each if file.
- .setup {|_self| ... } ⇒ Object
-
.update(*args) ⇒ Object
Show progress.
Class Attribute Details
.count_of_files ⇒ Object
Returns the value of attribute count_of_files.
11 12 13 |
# File 'lib/syntaxer/printer.rb', line 11 def count_of_files @count_of_files end |
.loud ⇒ Object
Returns the value of attribute loud.
11 12 13 |
# File 'lib/syntaxer/printer.rb', line 11 def loud @loud end |
.mode ⇒ Object
Returns the value of attribute mode.
11 12 13 |
# File 'lib/syntaxer/printer.rb', line 11 def mode @mode end |
.quite ⇒ Object
Returns the value of attribute quite.
11 12 13 |
# File 'lib/syntaxer/printer.rb', line 11 def quite @quite end |
Class Method Details
.print_message(filestatus) ⇒ Object
60 61 62 63 64 65 66 67 68 69 |
# File 'lib/syntaxer/printer.rb', line 60 def filestatus return if @quite puts "\n" print filestatus.file_name puts " OK".color(:green) if filestatus.status == :ok && @loud puts "\nErrors:".color(:red) if filestatus.status == :failed filestatus.errors.each do |error| puts "\t #{error}".color(:red) end end |
.print_result(checker) ⇒ Object
Print error message for each if file
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/syntaxer/printer.rb', line 40 def print_result checker return if @quite puts "\n" puts "Syntax OK".color(:green) if checker.error_files.empty? && $stdmyout.string.empty? @loud ? (files = checker.all_files) : (files = checker.error_files) files.each do |file| (file) end unless @@not_exists_rules.empty? puts "\n" @@not_exists_rules.each do |rule| puts (NON_EXISTENT_RULE_MESSAGE % [rule.executor, rule.name]).color(:yellow) end end $stderr.puts("\nErrors:"+"\n\t"+$stdmyout.string.color(:red)) unless $stdmyout.string.empty? end |
.setup {|_self| ... } ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/syntaxer/printer.rb', line 13 def setup &block yield self if block_given? if @mode == :hook @@bar = Syntaxer::ProgressBar.new else @@bar = ::ProgressBar.new(@count_of_files, :bar, :counter) end end |
.update(*args) ⇒ Object
Show progress
26 27 28 29 30 31 32 33 34 |
# File 'lib/syntaxer/printer.rb', line 26 def update *args #not_exists_rule = nil, file_status = (status=true;) args = args.first @@not_exists_rules << args[:rule] if args.include?(:rule) && !@@not_exists_rules.include?(args[:rule]) return if @quite if args.include?(:file_status) @mode == :hook ? @@bar.increment!(args[:file_status]) : @@bar.increment! end true end |