Sha256: eb1a9fee42901b2b6f1e26dbf5f79b1ca04784eea6151b524b58925260f78809
Contents?: true
Size: 979 Bytes
Versions: 12
Compression:
Stored size: 979 Bytes
Contents
module LicenseFinder class PossibleLicenseFiles LICENSE_FILE_NAMES = %w(LICENSE License Licence COPYING README Readme ReadMe) 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
12 entries across 12 versions & 1 rubygems