improvement: separate checking information from processing

Signed-off-by: Dominik Richter <dominik.richter@gmail.com>
This commit is contained in:
Dominik Richter 2015-06-10 17:53:25 +02:00
parent 3013bdcc46
commit 9f02a88e54
2 changed files with 11 additions and 10 deletions

View file

@ -34,8 +34,16 @@ module Vulcano
})
end
def incomplete?
@dict['name'].nil? || @dict['version'].nil? || @dict['summary'].nil? || @dict['maintainer'].nil? || @dict['copryight'].nil?
def valid?
is_valid = true
err = lambda{|msg| @log.error msg; is_valid = false }
warn = lambda{|msg| @log.warn msg; is_valid = false }
err.("Missing profile name in vmetadata.rb") if @dict['name'].nil?
err.("Missing profile version in vmetadata.rb") if @dict['version'].nil?
err.("Missing summary in vmetadata.rb") if @dict['summary'].nil?
warn.("Missing maintainer in vmetadata.rb") if @dict['maintainer'].nil?
warn.("Missing copyright in vmetadata.rb") if @dict['copyright'].nil?
is_valid
end
def method_missing sth, *args
@ -51,13 +59,6 @@ module Vulcano
end
res = Metadata.new(log)
res.instance_eval(File::read(dpath))
log.error "Missing profile name in vmetadata.rb" if res.dict['name'].nil?
log.error "Missing profile version in vmetadata.rb" if res.dict['version'].nil?
log.error "Missing summary in vmetadata.rb" if res.dict['summary'].nil?
log.warn "Missing maintainer in vmetadata.rb" if res.dict['maintainer'].nil?
log.warn "Missing copyright in vmetadata.rb" if res.dict['copyright'].nil?
return res
end
end

View file

@ -31,7 +31,7 @@ module Vulcano
end
md = Metadata.for_path(path)
@log.ok "vmetadata.rb" unless md.nil? or md.incomplete?
@log.ok "vmetadata.rb" unless md.nil? or !md.valid?
specs = Dir["#{path}/spec/*_spec.rb"]
if specs.empty?