class PackageValidator
Attributes
Public Class Methods
Source
# File lib/cmd/validate.rb, line 53 def initialize(facts, flavor = nil) @facts = facts @errors = [] if @facts.has_flavors? && flavor.nil? raise FlavorArgumentMsg % @facts.flavors.join("\n- ").to_s elsif @facts.has_flavors? && flavor != false @facts.flavor! flavor end validate end
Source
# File lib/cmd/validate.rb, line 41 def validate(name, method_name) @validations ||= [] @validations << [name, method_name] end
Public Instance Methods
Source
# File lib/cmd/validate.rb, line 65 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
Source
# File lib/cmd/validate.rb, line 113 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.reject do |f| File.exist? f end.map { |f| "#{f.to_s.split('/').last} is missing from this package" }] else ["#{Tty.green}found#{Tty.reset}", nil] end end
Source
# File lib/cmd/validate.rb, line 131 def has_errors? errors.any? { |e| !e[2].nil? } end
Source
# File lib/cmd/validate.rb, line 97 def homepage_present if @facts.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
Source
# File lib/cmd/validate.rb, line 75 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.positive? ["#{Tty.red}error#{Tty.reset}", errors] else ["#{Tty.green}ok#{Tty.reset}", nil] end end end
Source
# File lib/cmd/validate.rb, line 93 def post_update_hooks_ok hook_ok @facts.post :update end
Source
# File lib/cmd/validate.rb, line 125 def validate self.class.validations.each do |validation| errors << [validation[0], *send(validation[1])] end end
Source
# File lib/cmd/validate.rb, line 105 def version_present if @facts.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