Class: LicenseFinder::PossibleLicenseFile
- Inherits:
-
Object
- Object
- LicenseFinder::PossibleLicenseFile
- Defined in:
- lib/license_finder/package_utils/possible_license_file.rb
Instance Method Summary collapse
-
#initialize(path, options = {}) ⇒ PossibleLicenseFile
constructor
A new instance of PossibleLicenseFile.
- #license ⇒ Object
- #path ⇒ Object
- #text ⇒ Object
Constructor Details
#initialize(path, options = {}) ⇒ PossibleLicenseFile
Returns a new instance of PossibleLicenseFile.
5 6 7 8 9 10 11 12 |
# File 'lib/license_finder/package_utils/possible_license_file.rb', line 5 def initialize(path, = {}) if !path.is_a?(Zip::Entry) @path = Pathname(path) else @zip_entry = path end @logger = [:logger] end |
Instance Method Details
#license ⇒ Object
18 19 20 |
# File 'lib/license_finder/package_utils/possible_license_file.rb', line 18 def license License.find_by_text(text) end |
#path ⇒ Object
14 15 16 |
# File 'lib/license_finder/package_utils/possible_license_file.rb', line 14 def path @path.to_s end |
#text ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/license_finder/package_utils/possible_license_file.rb', line 22 def text if @zip_entry @zip_entry.get_input_stream.read elsif @path.exist? @text ||= (@path.respond_to?(:binread) ? @path.binread : @path.read) else @logger.info('ERROR', "#{@path} does not exists", color: :red) '' end end |