Class: LicenseFinder::PossibleLicenseFile
- Inherits:
-
Object
- Object
- LicenseFinder::PossibleLicenseFile
- Defined in:
- lib/license_finder/possible_license_file.rb
Instance Method Summary collapse
- #file_name ⇒ Object
- #file_path ⇒ Object
- #full_file_path ⇒ Object
-
#initialize(install_path, file_path) ⇒ PossibleLicenseFile
constructor
A new instance of PossibleLicenseFile.
- #license ⇒ Object
- #text ⇒ Object
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_name ⇒ Object
16 17 18 |
# File 'lib/license_finder/possible_license_file.rb', line 16 def file_name @file_path.basename.to_s end |
#file_path ⇒ Object
8 9 10 |
# File 'lib/license_finder/possible_license_file.rb', line 8 def file_path @file_path.relative_path_from(@install_path).to_s end |
#full_file_path ⇒ Object
12 13 14 |
# File 'lib/license_finder/possible_license_file.rb', line 12 def full_file_path Pathname.new(@file_path).realpath.to_s end |
#license ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/license_finder/possible_license_file.rb', line 24 def license license = License.all.detect do |klass| klass.new(text).matches? end license.pretty_name if license end |
#text ⇒ Object
20 21 22 |
# File 'lib/license_finder/possible_license_file.rb', line 20 def text @text ||= @file_path.send(@file_path.respond_to?(:binread) ? :binread : :read) end |