Class: Coconductor::ProjectFiles::CodeOfConductFile

Inherits:
ProjectFile
  • Object
show all
Includes:
Licensee::ContentHelper
Defined in:
lib/coconductor/project_files/code_of_conduct_file.rb

Constant Summary collapse

EXTENSIONS =
%w[md markdown txt].freeze
EXT_REGEX =
/\.#{Regexp.union(EXTENSIONS)}/i
BASENAME_REGEX =
/(citizen[_-])?code[_-]of[_-]conduct/i
LANG_REGEX =

LANG_REGEX must contain extension to avoid matching .md as the lang

/(\.(?<lang>[a-z]{2}(-[a-z]{2})?)#{EXT_REGEX})?/i
FILENAME_REGEX =
/#{BASENAME_REGEX}#{LANG_REGEX}#{EXT_REGEX}?/i

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ProjectFile

#code_of_conduct

Class Method Details

.name_score(filename) ⇒ Object



13
14
15
# File 'lib/coconductor/project_files/code_of_conduct_file.rb', line 13

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

Instance Method Details

#possible_matchersObject



17
18
19
# File 'lib/coconductor/project_files/code_of_conduct_file.rb', line 17

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