Sha256: da9a4794d94983ded995e9054336273e62345e41d7ba29c191e87fecd0e16865

Contents?: true

Size: 745 Bytes

Versions: 21

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::Dice, Matchers::FieldAware]
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
coconductor-0.9.2 lib/coconductor/project_files/code_of_conduct_file.rb
coconductor-0.9.1 lib/coconductor/project_files/code_of_conduct_file.rb
coconductor-0.9.0 lib/coconductor/project_files/code_of_conduct_file.rb
coconductor-0.8.3 lib/coconductor/project_files/code_of_conduct_file.rb
coconductor-0.8.2 lib/coconductor/project_files/code_of_conduct_file.rb
coconductor-0.8.1 lib/coconductor/project_files/code_of_conduct_file.rb
coconductor-0.8.0 lib/coconductor/project_files/code_of_conduct_file.rb
coconductor-0.7.0 lib/coconductor/project_files/code_of_conduct_file.rb
coconductor-0.6.2 lib/coconductor/project_files/code_of_conduct_file.rb
coconductor-0.6.1 lib/coconductor/project_files/code_of_conduct_file.rb
coconductor-0.6.0 lib/coconductor/project_files/code_of_conduct_file.rb
coconductor-0.5.6 lib/coconductor/project_files/code_of_conduct_file.rb
coconductor-0.5.5 lib/coconductor/project_files/code_of_conduct_file.rb
coconductor-0.5.4 lib/coconductor/project_files/code_of_conduct_file.rb
coconductor-0.5.3 lib/coconductor/project_files/code_of_conduct_file.rb
coconductor-0.5.2 lib/coconductor/project_files/code_of_conduct_file.rb
coconductor-0.5.1 lib/coconductor/project_files/code_of_conduct_file.rb
coconductor-0.5.0 lib/coconductor/project_files/code_of_conduct_file.rb
coconductor-0.4.0 lib/coconductor/project_files/code_of_conduct_file.rb
coconductor-0.3.1 lib/coconductor/project_files/code_of_conduct_file.rb