Sha256: 62b1bcb7c831bee99e4c83db14748a5a552e5375a429c88e211339d03252e44e
Contents?: true
Size: 1.04 KB
Versions: 2
Compression:
Stored size: 1.04 KB
Contents
module LicenseFinder class PossibleLicenseFiles LICENSE_FILE_NAMES = %w(LICENSE License Licence COPYING README Readme ReadMe) def self.find(install_path) new(install_path).find end def initialize(install_path) @install_path = install_path end def find paths_for_license_files.map do |path| get_file_for_path(path) end end private attr_reader :install_path def paths_for_license_files find_matching_files.map do |path| File.directory?(path) ? paths_for_files_in_license_directory(path) : path end.flatten.uniq end def find_matching_files Dir.glob(File.join(install_path, '**', "*{#{LICENSE_FILE_NAMES.join(',')}}*")) end def paths_for_files_in_license_directory(path) entries_in_directory = Dir::entries(path).reject { |p| p.match(/^(\.){1,2}$/) } entries_in_directory.map { |entry_name| File.join(path, entry_name) } end def get_file_for_path(path) PossibleLicenseFile.new(install_path, path) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
license_finder-1.0.0.0 | lib/license_finder/possible_license_files.rb |
license_finder-1.0.0.0-java | lib/license_finder/possible_license_files.rb |