Sha256: c55db2ce6dbd3624b70cf4560f6db932f85dba07c5df6a9c8bbb160e8160a59c

Contents?: true

Size: 681 Bytes

Versions: 1

Compression:

Stored size: 681 Bytes

Contents

module LicenseFinder
  class PossibleLicenseFile
    def initialize(install_path, file_path)
      @install_path = Pathname.new(install_path)
      @file_path = Pathname.new(file_path)
    end

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

    def full_file_path
      @file_path.realpath.to_s
    end

    def file_name
      @file_path.basename.to_s
    end

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

    def license
      license = LicenseFinder::License.all.detect do |klass|
        klass.new(text).matches?
      end

      license && license.pretty_name
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
license_finder-0.5.0 lib/license_finder/possible_license_file.rb