Sha256: fe615ad55228d58d992086b6746d722963722e54e9a905f162126751e3113fae

Contents?: true

Size: 1.33 KB

Versions: 12

Compression:

Stored size: 1.33 KB

Contents

# frozen_string_literal: true

# Released under the MIT License.
# Copyright, 2024, by Samuel Williams.

def initialize(context)
	super
	
	require 'bake/modernize/license'
end

# Extract changes from a repository and generate a list of contributors.
# @parameter root [String] The root directory of the repository.
# @parameter paths [Array(String)] The paths to extract changes from.
def extract(root:, paths:)
	authorship = Bake::Modernize::License::Authorship.new
	
	authorship.extract(root)
	
	modifications = []
	
	paths.each do |path|
		authorship.paths[path].each do |modification|
			modification = modification.to_h
			
			if modification[:path] != path
				modification[:original_path] = modification[:path]
				modification[:path] = path
			end
			
			modifications << modification
		end
	end
	
	modifications.sort_by!{|modification| modification[:time]}
	
	return modifications
end

# Map the changes to a new path.
# @parameter input [Array(Hash)] The list of changes.
# @parameter original_path [String] The original path of the changes.
# @parameter path [String] The path that now contains the content of the original changes.
def map(original_path, path, input:)
	input.each do |modification|
		if modification[:path] == original_path
			modification[:original_path] = modification[:path]
			modification[:path] = path
		end
	end
	
	return input
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
bake-modernize-0.29.0 bake/modernize/contributors.rb
bake-modernize-0.28.0 bake/modernize/contributors.rb
bake-modernize-0.27.3 bake/modernize/contributors.rb
bake-modernize-0.27.2 bake/modernize/contributors.rb
bake-modernize-0.27.1 bake/modernize/contributors.rb
bake-modernize-0.27.0 bake/modernize/contributors.rb
bake-modernize-0.26.0 bake/modernize/contributors.rb
bake-modernize-0.25.0 bake/modernize/contributors.rb
bake-modernize-0.24.0 bake/modernize/contributors.rb
bake-modernize-0.23.0 bake/modernize/contributors.rb
bake-modernize-0.22.0 bake/modernize/contributors.rb
bake-modernize-0.21.0 bake/modernize/contributors.rb