Class: Syntaxer::Printer
- Inherits:
-
Object
- Object
- Syntaxer::Printer
- Defined in:
- lib/syntaxer/printer.rb
Overview
Print system messages
Constant Summary
- NON_EXISTENT_RULE_MESSAGE =
"exec_rule `%s` for language %s not exists. Skip"- @@bar =
nil- @@not_exists_rules =
[]
Class Attribute Summary (collapse)
-
+ (Object) count_of_files
Returns the value of attribute count_of_files.
-
+ (Object) loud
Returns the value of attribute loud.
-
+ (Object) mode
Returns the value of attribute mode.
-
+ (Object) quite
Returns the value of attribute quite.
Class Method Summary (collapse)
- + (Object) print_message(filestatus)
-
+ (Object) print_result(checker)
Print error message for each if file.
- + (Object) setup {|_self| ... }
-
+ (Object) update(*args)
Show progress.
Class Attribute Details
+ (Object) count_of_files
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 |
+ (Object) loud
Returns the value of attribute loud
11 12 13 |
# File 'lib/syntaxer/printer.rb', line 11 def loud @loud end |
+ (Object) mode
Returns the value of attribute mode
11 12 13 |
# File 'lib/syntaxer/printer.rb', line 11 def mode @mode end |
+ (Object) quite
Returns the value of attribute quite
11 12 13 |
# File 'lib/syntaxer/printer.rb', line 11 def quite @quite end |
Class Method Details
+ (Object) print_message(filestatus)
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 |
+ (Object) print_result(checker)
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 |
+ (Object) setup {|_self| ... }
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 |
+ (Object) update(*args)
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 |