lib/verifier.rb in inqlude-0.7.4 vs lib/verifier.rb in inqlude-0.8.0

- old
+ new

@@ -15,31 +15,42 @@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. class Verifier class Result - attr_accessor :errors, :name + attr_accessor :errors, :warnings, :name def initialize @valid = false + @safe = false @errors = Array.new + @warnings = Array.new end def valid? @errors.empty? end + def has_warnings? + !@warnings.empty? + end + def print_result print "Verify manifest #{@name}..." if valid? puts "ok" else puts "error" @errors.each do |error| puts " #{error}" end end + if has_warnings? + @warnings.each do |warning| + puts " #{warning}" + end + end end end def initialize settings @settings = settings @@ -73,9 +84,20 @@ schema_file = File.expand_path("../../schema/#{schema_name}", __FILE__) errors = JSON::Validator.fully_validate(schema_file, manifest.to_json) errors.each do |error| @result.errors.push "Schema validation error: #{error}" + end + + topics = manifest.topics + if topics.nil? + @result.warnings.push "Warning: missing `topics` attribute" + else + valid_topics = ['API', 'Artwork', 'Bindings', 'Communication', 'Data', 'Desktop', 'Development', 'Graphics', 'Logging', 'Mobile', 'Multimedia', 'Printing', 'QML', 'Scripting', 'Security', 'Text', 'Web', 'Widgets'] + invalid_topics = topics - valid_topics + if !invalid_topics.empty? + @result.errors.push ("Invalid topics " + "'#{invalid_topics.join("', '")}'" + ". Valid topics are " + "'#{valid_topics.join("', '")}'") + end end end @result end