Sha256: abb42c9f826801fa389f437a7402a15d7d05364d2ad9645143114c83d5039767

Contents?: true

Size: 745 Bytes

Versions: 1

Compression:

Stored size: 745 Bytes

Contents

module Coconductor
  module ProjectFiles
    class CodeOfConductFile < Coconductor::ProjectFiles::ProjectFile
      include Licensee::ContentHelper

      EXTENSIONS = %w[md markdown txt].freeze
      EXT_REGEX = /\.#{Regexp.union(EXTENSIONS)}/i
      BASENAME_REGEX = /(citizen[_-])?code[_-]of[_-]conduct/i
      # LANG_REGEX must contain extension to avoid matching .md as the lang
      LANG_REGEX = /(\.(?<lang>[a-z]{2}(-[a-z]{2})?)#{EXT_REGEX})?/i
      FILENAME_REGEX = /#{BASENAME_REGEX}#{LANG_REGEX}#{EXT_REGEX}?/i

      def self.name_score(filename)
        filename =~ /\A#{FILENAME_REGEX}/ ? 1.0 : 0.0
      end

      def possible_matchers
        [Matchers::Exact, Matchers::FieldAware, Matchers::Dice]
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
coconductor-0.2.0 lib/coconductor/project_files/code_of_conduct_file.rb