Sha256: 400c4adfd8e7effed60b7297dfc56ae67159e2272b7726468189dc95571a9a45

Contents?: true

Size: 680 Bytes

Versions: 16

Compression:

Stored size: 680 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
      Pathname.new(@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 = License.all.detect do |klass|
        klass.new(text).matches?
      end

      license.pretty_name if license
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
license_finder-0.9.4-java lib/license_finder/possible_license_file.rb
license_finder-0.9.4 lib/license_finder/possible_license_file.rb
license_finder-0.9.3-java lib/license_finder/possible_license_file.rb
license_finder-0.9.3 lib/license_finder/possible_license_file.rb
license_finder-0.9.2-java lib/license_finder/possible_license_file.rb
license_finder-0.9.2 lib/license_finder/possible_license_file.rb
license_finder-0.9.1-java lib/license_finder/possible_license_file.rb
license_finder-0.9.1 lib/license_finder/possible_license_file.rb
license_finder-0.9.0-java lib/license_finder/possible_license_file.rb
license_finder-0.9.0 lib/license_finder/possible_license_file.rb
license_finder-0.8.2-java lib/license_finder/possible_license_file.rb
license_finder-0.8.2 lib/license_finder/possible_license_file.rb
license_finder-0.8.1-java lib/license_finder/possible_license_file.rb
license_finder-0.8.1 lib/license_finder/possible_license_file.rb
license_finder-0.8.0-java lib/license_finder/possible_license_file.rb
license_finder-0.8.0 lib/license_finder/possible_license_file.rb