Sha256: 63e7f2d924f4123d7e9eaf03c0b1db29a68e5e84f28bd232df4ee83164959aea
Contents?: true
Size: 1.02 KB
Versions: 4
Compression:
Stored size: 1.02 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 attr_reader :install_path def find paths_for_license_files.map do |path| get_file_for_path(path) end end 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
4 entries across 4 versions & 1 rubygems