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.freeze
BASENAME_REGEX =
/(citizen[_-])?code[_-]of[_-]conduct/i.freeze
LANG_REGEX =

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

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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ProjectFile

#code_of_conduct

Class Method Details

.name_score(filename) ⇒ Object



15
16
17
# File 'lib/coconductor/project_files/code_of_conduct_file.rb', line 15

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

Instance Method Details

#possible_matchersObject



19
20
21
# File 'lib/coconductor/project_files/code_of_conduct_file.rb', line 19

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