Class: LicenseFinder::LicenseFiles

Inherits:
Object
  • Object
show all
Defined in:
lib/license_finder/package_utils/license_files.rb

Constant Summary collapse

CANDIDATE_FILE_NAMES =
%w[License Licence COPYING README].freeze
CANDIDATE_PATH_WILDCARD =
"*{#{CANDIDATE_FILE_NAMES.join(',')}}*"

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(install_path) ⇒ LicenseFiles

Returns a new instance of LicenseFiles.



14
15
16
# File 'lib/license_finder/package_utils/license_files.rb', line 14

def initialize(install_path)
  @install_path = install_path ? Pathname(install_path) : nil
end

Class Method Details

.find(install_path, options = {}) ⇒ Object



10
11
12
# File 'lib/license_finder/package_utils/license_files.rb', line 10

def self.find(install_path, options = {})
  new(install_path).find(options)
end

Instance Method Details

#find(options = {}) ⇒ Object



18
19
20
21
22
# File 'lib/license_finder/package_utils/license_files.rb', line 18

def find(options = {})
  paths_of_candidate_files
    .map { |path| PossibleLicenseFile.new(path, options) }
    .reject { |file| file.license.nil? }
end