Sha256: 833be630766b637e03dffd95fe6dde04a76dd66d0de287396543dca8c0e01c56

Contents?: true

Size: 1.73 KB

Versions: 1

Compression:

Stored size: 1.73 KB

Contents

module PluginTool

  def self.check_plugins(plugins)
    init_syntax_checking
    @@check_report = ''
    @@check_ok = true
    @@check_warn = false
    plugins.each { |p| check_plugin(p) }
    if @@check_warn || !(@@check_ok)
      puts "\nFILES WITH ERRORS"
      puts @@check_report
    end
    # Output the verdict
    puts
    if @@check_ok && !@@check_warn
      puts "PASSED"
    elsif @@check_warn
      puts "PASSED WITH WARNINGS"
    else
      puts "FAILED"
      exit 1
    end
  end

  def self.check_plugin(plugin)
    plugin_dir = plugin.plugin_dir
    STDOUT.write(plugin.name+" ")
    Dir.glob("#{plugin_dir}/**/*").each do |pathname|
      next unless File.file?(pathname)
      next if plugin.exclude_files_from_syntax_check.include?(pathname)
      plugin_relative_name = pathname[plugin_dir.length+1, pathname.length]
      if pathname =~ /\.(js|hsvt)\z/i
        STDOUT.write("."); STDOUT.flush
        # Check JavaScript
        report = syntax_check_one_file(plugin, plugin_relative_name)
        if report == nil
          check_file_result(plugin, plugin_relative_name, :OK)
        else
          puts "\n**** #{plugin_relative_name} has errors:\n#{report}\n"
          check_file_result(plugin, plugin_relative_name, (plugin_relative_name =~ /\Ajs\//) ? :FAIL : :WARN)
        end
      else
        # TODO: Checks for other file types, including the plugin.json
        check_file_result(plugin, plugin_relative_name, :OK)        
      end
    end
    STDOUT.write("\n"); STDOUT.flush
  end
  
  def self.check_file_result(plugin, name, result)
    unless result == :OK
      @@check_report << "  #{plugin.plugin_dir}/#{name}: #{result}\n"
    end
    @@check_ok = false if result == :FAIL
    @@check_warn = true if result == :WARN
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
haplo-2.1.0-java lib/check.rb