Sha256: 7d0094e44ebd40e5db05b42be3ec4a1dabfd19a2135bb00b0ca8e2874b10a042

Contents?: true

Size: 1.72 KB

Versions: 14

Compression:

Stored size: 1.72 KB

Contents

module Distil
  module ErrorReporter
    
    @@warning_count=0
    @@error_count=0
    @@ignore_warnings= false
    @@total_warning_count=0
    @@total_error_count=0
    
    def ignore_warnings
      @@ignore_warnings
    end
    
    def ignore_warnings=(ignore)
      @@ignore_warnings=ignore
    end
    
    def total_error_count
      @@total_error_count
    end
    
    def total_warning_count
      @@total_warning_count
    end
    
    def has_errors?
      @@error_count > 0
    end

    def has_warnings?
      @@warning_count > 0
    end

    def self.error(message, file=nil, line_number=nil)
      @@error_count+=1

      case when file && line_number
        puts "#{file}:#{line_number}: error: #{message}"
      when file
        puts "#{file}: error: #{message}"
      else
        puts "error: #{message}"
      end
    end
    
    def error(message, file=nil, line_number=nil)
      ErrorReporter.error(message, file, line_number)
    end

    def self.warning(message, file=nil, line_number=nil)
      @@warning_count+=1
      return if (@@ignore_warnings)
      case when file && line_number
        puts "#{file}:#{line_number}: warning: #{message}"
      when file
        puts "#{file}: warning: #{message}"
      else
        puts "warning: #{message}"
      end
    end

    def warning(message, file=nil, line_number=nil)
      ErrorReporter.warning(message, file, line_number)
    end
    
    def report
      puts "\n" if (@@error_count>0 || @@warning_count>0)
      puts "#{@@error_count} error(s), #{@@warning_count} warning(s)#{ignore_warnings ? " ignored" : ""}"
      @@total_error_count += @@error_count
      @@total_warning_count += @@warning_count
      @@error_count=0
      @@warning_count=0
    end
    
  end
  
end


Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
distil-0.14.5.a lib/distil/error-reporter.rb
distil-0.14.4 lib/distil/error-reporter.rb
distil-0.14.3 lib/distil/error-reporter.rb
distil-0.14.2 lib/distil/error-reporter.rb
distil-0.14.2.a lib/distil/error-reporter.rb
distil-0.14.1 lib/distil/error-reporter.rb
distil-0.14.1.a lib/distil/error-reporter.rb
distil-0.14.0 lib/distil/error-reporter.rb
distil-0.14.0.i lib/distil/error-reporter.rb
distil-0.14.0.h lib/distil/error-reporter.rb
distil-0.14.0.g lib/distil/error-reporter.rb
distil-0.14.0.d lib/distil/error-reporter.rb
distil-0.14.0.c lib/distil/error-reporter.rb
distil-0.14.0.b lib/distil/error-reporter.rb