Skip to content

Commit

Permalink
Minor code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mchf committed Sep 16, 2022
1 parent 10caefe commit 3ca567e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/modules/HttpServerPackages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,19 @@ def main
#
# @param pattern [String] a regex pattern to match, no escaping done
# @return list of matching package names
def by_pattern(pattern)
def by_provides_regexp(pattern)
raise ArgumentError, "Missing search pattern" if pattern.nil? || pattern.empty?

# NOTE: - Resolvable.find takes POSIX regexp, later select uses Ruby regexp
# - Resolvable.find supports regexps only for dependencies, so we need to
# filter result according to package name
Y2Packager::Resolvable.find({ provides_regexp: "^#{pattern}$" }, [:name])
Y2Packager::Resolvable.find({ kind: :package, provides_regexp: "^#{pattern}$" }, [])
.select { |p| p.name =~ /\A#{pattern}\z/ }
.map(&:name)
.uniq
end

publish function: :by_pattern, type: "list <string> (string)"
publish function: :by_provides_regexp, type: "list <string> (string)"

end

Expand Down
2 changes: 1 addition & 1 deletion src/modules/YaPI/HTTPDModules.pm
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@ sub ServerModules {
%modules = ( %modules,
'php' . $php_version => {
summary => __("Provides support for PHP dynamically generated pages"),
packages => ["apache2-mod_php" . YaST::HTTPDPhpModule->Version()],
packages => ["apache2-mod_php" . $php_version],
default => 0,
position => 490
}
Expand Down
2 changes: 1 addition & 1 deletion src/modules/YaST/HTTPDPhpModule.pm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ our %TYPEINFO;
BEGIN { $TYPEINFO{Version} = ["function", "string" ]; }
sub Version {
# when function returns an array, we get reference to it
$l = HttpServerPackages->by_pattern("php[0-9]{1,2}");
$l = HttpServerPackages->by_provides_regexp("php[0-9]{1,2}");

return if(!$l);

Expand Down

0 comments on commit 3ca567e

Please sign in to comment.