Class: LicenseFinder::PossibleLicenseFile

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

Instance Method Summary collapse

Constructor Details

#initialize(install_path, file_path) ⇒ PossibleLicenseFile

Returns a new instance of PossibleLicenseFile.



3
4
5
6
# File 'lib/license_finder/possible_license_file.rb', line 3

def initialize(install_path, file_path)
  @install_path = Pathname.new(install_path)
  @file_path = Pathname.new(file_path)
end

Instance Method Details

#file_pathObject

Unused, except in tests, but might be useful if LF ever reports the locations of all the files it searched.



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

def file_path
  @file_path.relative_path_from(@install_path).to_s
end

#licenseObject



18
19
20
# File 'lib/license_finder/possible_license_file.rb', line 18

def license
  License.find_by_text(text)
end

#textObject



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

def text
  @text ||= @file_path.send(@file_path.respond_to?(:binread) ? :binread : :read)
end