class PackageValidator
Attributes
validations[RW]
errors[RW]
Public Class Methods
new(facts, flavor=nil)
click to toggle source
# File lib/cmd/validate.rb, line 47 def initialize facts, flavor=nil @facts = facts @errors = [] if @facts.has_flavors? && flavor.nil? raise RuntimeError.new(FlavorArgumentMsg % @facts.flavors.join("\n- ")) elsif @facts.has_flavors? && flavor != false @facts.flavor! flavor end validate end
validate(name, method_name)
click to toggle source
# File lib/cmd/validate.rb, line 35 def validate name, method_name @validations ||= [] @validations << [name, method_name] end
Public Instance Methods
check_hooks(hook_cmd)
click to toggle source
# File lib/cmd/validate.rb, line 58 def check_hooks hook_cmd hook_cmd.map do |cmd| if !File.exist? cmd "#{cmd} cannot be found" elsif !File.executable? cmd "#{cmd} is not executable" end end.compact end
config_files_present()
click to toggle source
# File lib/cmd/validate.rb, line 106 def config_files_present if @facts.config_files.empty? ["#{Tty.red}missing#{Tty.reset}", ['Add config_files see manual for more information']] elsif @facts.config_files.any?{|f| !File.exist? f} ["#{Tty.red}error#{Tty.reset}", @facts.config_files.select{|f| !File.exist? f}.map{|f| "#{f.to_s.split("/").last} is missing from this package"}] else ["#{Tty.green}found#{Tty.reset}", nil] end end
has_errors?()
click to toggle source
# File lib/cmd/validate.rb, line 122 def has_errors? errors.any?{|e| !e[2].nil? } end
homepage_present()
click to toggle source
# File lib/cmd/validate.rb, line 90 def homepage_present if @facts.has_key? 'homepage' ["#{Tty.green}found#{Tty.reset}", nil] else ["#{Tty.red}missing#{Tty.reset}", ['adding a homepage improves the credibility', 'of your package']] end end
hook_ok(config_files)
click to toggle source
# File lib/cmd/validate.rb, line 68 def hook_ok config_files hook_cmd = config_files if hook_cmd.empty? ["#{Tty.green}skipped#{Tty.reset}", nil] else errors = check_hooks hook_cmd if errors.length > 0 ["#{Tty.red}error#{Tty.reset}", errors] else ["#{Tty.green}ok#{Tty.reset}", nil] end end end
post_update_hooks_ok()
click to toggle source
# File lib/cmd/validate.rb, line 86 def post_update_hooks_ok hook_ok @facts.post :update end
setup_ok()
click to toggle source
# File lib/cmd/validate.rb, line 82 def setup_ok hook_ok @facts.setup_files end
validate()
click to toggle source
# File lib/cmd/validate.rb, line 116 def validate self.class.validations.each do |validation| errors << [validation[0], *send(validation[1])] end end
version_present()
click to toggle source
# File lib/cmd/validate.rb, line 98 def version_present if @facts.has_key? 'version' ["#{Tty.green}found#{Tty.reset}", nil] else ["#{Tty.red}missing#{Tty.reset}", ['adding a version to the manifest improves', 'a future update experince']] end end