Class: LicenseFinder::LicenseFiles

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

Constant Summary collapse

CANDIDATE_FILE_NAMES =
%w(LICENSE License Licence COPYING README Readme ReadMe)
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.



12
13
14
# File 'lib/license_finder/packages/license_files.rb', line 12

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

Class Method Details

.find(install_path) ⇒ Object



8
9
10
# File 'lib/license_finder/packages/license_files.rb', line 8

def self.find(install_path)
  new(install_path).find
end

Instance Method Details

#findObject



16
17
18
19
20
# File 'lib/license_finder/packages/license_files.rb', line 16

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