Sha256: 4e1a3f28b626db9345492e9b42c447abb2cd19d101e8b6b076a37eefcf74596e

Contents?: true

Size: 552 Bytes

Versions: 9

Compression:

Stored size: 552 Bytes

Contents

module Licensee
  class Project
    class Readme < LicenseFile
      SCORES = {
        /\AREADME\z/i                    => 1.0,
        /\AREADME\.(md|markdown|txt)\z/i => 0.9
      }.freeze

      CONTENT_REGEX = /^#+ Licen[sc]e$(.*?)(?=#+|\z)/im

      def self.name_score(filename)
        SCORES.each do |pattern, score|
          return score if pattern =~ filename
        end
        0.0
      end

      def self.license_content(content)
        match = CONTENT_REGEX.match(content)
        match[1].strip if match
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
licensee-8.5.0 lib/licensee/project_files/readme.rb
licensee-8.4.0 lib/licensee/project_files/readme.rb
licensee-8.3.1 lib/licensee/project_files/readme.rb
licensee-8.3.0 lib/licensee/project_files/readme.rb
licensee-8.2.0 lib/licensee/project_files/readme.rb
licensee-8.1.0 lib/licensee/project_files/readme.rb
licensee-8.0.0 lib/licensee/project_files/readme.rb
licensee-7.0.1 lib/licensee/project_files/readme.rb
licensee-7.0.0 lib/licensee/project_files/readme.rb