Sha256: b8cd0f16f4e8d1e9623c1c5965c6de3b5bbb80405cce91ce300eab36c2fdc597

Contents?: true

Size: 564 Bytes

Versions: 2

Compression:

Stored size: 564 Bytes

Contents

module Licensee
  class Project
    class Readme < LicenseFile
      SCORES = {
        /\AREADME\z/i                          => 1.0,
        /\AREADME\.(md|markdown|mdown|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

2 entries across 2 versions & 1 rubygems

Version Path
licensee-8.6.1 lib/licensee/project_files/readme.rb
licensee-8.6.0 lib/licensee/project_files/readme.rb