debian-mirror-gitlab/app/finders/packages/package_file_finder.rb
2020-08-09 17:41:57 +05:30

36 lines
613 B
Ruby

# frozen_string_literal: true
class Packages::PackageFileFinder
attr_reader :package, :file_name, :params
def initialize(package, file_name, params = {})
@package = package
@file_name = file_name
@params = params
end
def execute
package_files.last
end
def execute!
package_files.last!
end
private
def package_files
files = package.package_files
files = by_file_name(files)
files
end
def by_file_name(files)
if params[:with_file_name_like]
files.with_file_name_like(file_name)
else
files.with_file_name(file_name)
end
end
end