Class: Homebrew::ResourceAuditor
- Inherits:
-
Object
- Object
- Homebrew::ResourceAuditor
- Defined in:
- Library/Homebrew/dev-cmd/audit.rb
Instance Attribute Summary collapse
-
#checksum ⇒ Object
readonly
Returns the value of attribute checksum.
-
#mirrors ⇒ Object
readonly
Returns the value of attribute mirrors.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#owner ⇒ Object
readonly
Returns the value of attribute owner.
-
#problems ⇒ Object
readonly
Returns the value of attribute problems.
-
#spec_name ⇒ Object
readonly
Returns the value of attribute spec_name.
-
#specs ⇒ Object
readonly
Returns the value of attribute specs.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
-
#using ⇒ Object
readonly
Returns the value of attribute using.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Class Method Summary collapse
Instance Method Summary collapse
- #audit ⇒ Object
- #audit_download_strategy ⇒ Object
- #audit_urls ⇒ Object
- #audit_version ⇒ Object
-
#initialize(resource, spec_name, options = {}) ⇒ ResourceAuditor
constructor
A new instance of ResourceAuditor.
- #problem(text) ⇒ Object
Constructor Details
#initialize(resource, spec_name, options = {}) ⇒ ResourceAuditor
Returns a new instance of ResourceAuditor.
1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 |
# File 'Library/Homebrew/dev-cmd/audit.rb', line 1042 def initialize(resource, spec_name, = {}) @name = resource.name @version = resource.version @checksum = resource.checksum @url = resource.url @mirrors = resource.mirrors @using = resource.using @specs = resource.specs @owner = resource.owner @spec_name = spec_name @online = [:online] @strict = [:strict] @problems = [] end |
Instance Attribute Details
#checksum ⇒ Object (readonly)
Returns the value of attribute checksum
1040 1041 1042 |
# File 'Library/Homebrew/dev-cmd/audit.rb', line 1040 def checksum @checksum end |
#mirrors ⇒ Object (readonly)
Returns the value of attribute mirrors
1040 1041 1042 |
# File 'Library/Homebrew/dev-cmd/audit.rb', line 1040 def mirrors @mirrors end |
#name ⇒ Object (readonly)
Returns the value of attribute name
1040 1041 1042 |
# File 'Library/Homebrew/dev-cmd/audit.rb', line 1040 def name @name end |
#owner ⇒ Object (readonly)
Returns the value of attribute owner
1040 1041 1042 |
# File 'Library/Homebrew/dev-cmd/audit.rb', line 1040 def owner @owner end |
#problems ⇒ Object (readonly)
Returns the value of attribute problems
1040 1041 1042 |
# File 'Library/Homebrew/dev-cmd/audit.rb', line 1040 def problems @problems end |
#spec_name ⇒ Object (readonly)
Returns the value of attribute spec_name
1040 1041 1042 |
# File 'Library/Homebrew/dev-cmd/audit.rb', line 1040 def spec_name @spec_name end |
#specs ⇒ Object (readonly)
Returns the value of attribute specs
1040 1041 1042 |
# File 'Library/Homebrew/dev-cmd/audit.rb', line 1040 def specs @specs end |
#url ⇒ Object (readonly)
Returns the value of attribute url
1040 1041 1042 |
# File 'Library/Homebrew/dev-cmd/audit.rb', line 1040 def url @url end |
#using ⇒ Object (readonly)
Returns the value of attribute using
1040 1041 1042 |
# File 'Library/Homebrew/dev-cmd/audit.rb', line 1040 def using @using end |
#version ⇒ Object (readonly)
Returns the value of attribute version
1040 1041 1042 |
# File 'Library/Homebrew/dev-cmd/audit.rb', line 1040 def version @version end |
Class Method Details
.curl_openssl_and_deps ⇒ Object
1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 |
# File 'Library/Homebrew/dev-cmd/audit.rb', line 1106 def self.curl_openssl_and_deps @curl_openssl_and_deps ||= begin formulae_names = ["curl", "openssl"] formulae_names += formulae_names.flat_map do |f| Formula[f].recursive_dependencies.map(&:name) end formulae_names.uniq rescue FormulaUnavailableError [] end end |
Instance Method Details
#audit ⇒ Object
1057 1058 1059 1060 1061 1062 |
# File 'Library/Homebrew/dev-cmd/audit.rb', line 1057 def audit audit_version audit_download_strategy audit_urls self end |
#audit_download_strategy ⇒ Object
1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 |
# File 'Library/Homebrew/dev-cmd/audit.rb', line 1076 def audit_download_strategy url_strategy = DownloadStrategyDetector.detect(url) if (using == :git || url_strategy == GitDownloadStrategy) && specs[:tag] && !specs[:revision] problem "Git should specify :revision when a :tag is specified." end return unless using if using == :cvs mod = specs[:module] problem "Redundant :module value in URL" if mod == name if url.match?(%r{:[^/]+$}) mod = url.split(":").last if mod == name problem "Redundant CVS module appended to URL" else problem "Specify CVS module as `:module => \"#{mod}\"` instead of appending it to the URL" end end end return unless url_strategy == DownloadStrategyDetector.detect("", using) problem "Redundant :using value in URL" end |
#audit_urls ⇒ Object
1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 |
# File 'Library/Homebrew/dev-cmd/audit.rb', line 1118 def audit_urls return unless @online urls = [url] + mirrors urls.each do |url| next if !@strict && mirrors.include?(url) strategy = DownloadStrategyDetector.detect(url, using) if strategy <= CurlDownloadStrategy && !url.start_with?("file") # A `brew mirror`'ed URL is usually not yet reachable at the time of # pull request. next if url.match?(%r{^https://dl.bintray.com/homebrew/mirror/}) if http_content_problem = curl_check_http_content(url) problem http_content_problem end elsif strategy <= GitDownloadStrategy problem "The URL #{url} is not a valid git URL" unless Utils::Git.remote_exists? url elsif strategy <= SubversionDownloadStrategy next unless DevelopmentTools.subversion_handles_most_https_certificates? next unless Utils::Svn.available? problem "The URL #{url} is not a valid svn URL" unless Utils::Svn.remote_exists? url end end end |
#audit_version ⇒ Object
1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 |
# File 'Library/Homebrew/dev-cmd/audit.rb', line 1064 def audit_version if version.nil? problem "missing version" elsif !version.detected_from_url? version_text = version version_url = Version.detect(url, **specs) if version_url.to_s == version_text.to_s && version.instance_of?(Version) problem "version #{version_text} is redundant with version scanned from URL" end end end |
#problem(text) ⇒ Object
1145 1146 1147 |
# File 'Library/Homebrew/dev-cmd/audit.rb', line 1145 def problem(text) @problems << text end |