Sha256: f6185c6e856c5e0ffff421a178834989c5044eaeb9c65afae1b34d84ed2d63a0
Contents?: true
Size: 1.64 KB
Versions: 12
Compression:
Stored size: 1.64 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) # Output the report again because it may have been obscured by the errors puts "--------------------" 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 Dir.glob("#{plugin_dir}/**/*").each do |pathname| next unless File.file?(pathname) plugin_relative_name = pathname[plugin_dir.length+1, pathname.length] if pathname =~ /\.js\z/ # Check JavaScript report = syntax_check_one_file(plugin, plugin_relative_name) if report == nil check_file_result(plugin, plugin_relative_name, :OK) else puts "**** #{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 end def self.check_file_result(plugin, name, result) line = " #{plugin.plugin_dir}/#{name}: #{result}" @@check_report << line @@check_report << "\n" @@check_ok = false if result == :FAIL @@check_warn = true if result == :WARN puts line end end
Version data entries
12 entries across 12 versions & 1 rubygems