Sha256: 2c84ceeb46daf5e25eb8a44bd1f6779f0806842688ec777810f926be0cf6794d

Contents?: true

Size: 924 Bytes

Versions: 2

Compression:

Stored size: 924 Bytes

Contents

# frozen_string_literal: true

module Coconductor
  module Projects
    module Project
      DIRS = ['./', './docs/', './.github/'].freeze

      def code_of_conduct
        code_of_conduct_file&.code_of_conduct
      end

      def code_of_conduct_file
        return @code_of_conduct_file if defined? @code_of_conduct_file
        return if files.nil? || files.empty?

        file = find_files do |filename|
          ProjectFiles::CodeOfConductFile.name_score(filename)
        end.first

        return unless file

        content = load_file(file)
        @code_of_conduct_file = begin
          ProjectFiles::CodeOfConductFile.new(content, file)
        end
      end

      private

      def path_relative_to_root(path)
        return path if is_a?(GitProject) || path.nil?

        root = Pathname.new(@dir)
        path = Pathname.new(path)
        path.relative_path_from(root).to_s
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
coconductor-0.10.1 lib/coconductor/projects/project.rb
coconductor-0.10.0 lib/coconductor/projects/project.rb