Class: LicenseFinder::PossibleLicenseFile

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

Instance Method Summary collapse

Constructor Details

#initialize(path, options = {}) ⇒ PossibleLicenseFile

Returns a new instance of PossibleLicenseFile.



5
6
7
8
# File 'lib/license_finder/package_utils/possible_license_file.rb', line 5

def initialize(path, options = {})
  @path = Pathname(path)
  @logger = options[:logger]
end

Instance Method Details

#licenseObject



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

def license
  License.find_by_text(text)
end

#pathObject



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

def path
  @path.to_s
end

#textObject



18
19
20
21
22
23
24
25
# File 'lib/license_finder/package_utils/possible_license_file.rb', line 18

def text
  if @path.exist?
    @text ||= (@path.respond_to?(:binread) ? @path.binread : @path.read)
  else
    @logger.info('ERROR', "#{@path} does not exists", color: :red)
    ''
  end
end