Class: Bake::Modernize::License::SkipList

Inherits:
Object
  • Object
show all
Defined in:
lib/bake/modernize/license.rb

Overview

Represents revisions to skip when analyzing authorship.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(revisions = []) ⇒ SkipList

Create a new skip list with the given revisions.



31
32
33
# File 'lib/bake/modernize/license.rb', line 31

def initialize(revisions = [])
	@revisions = Set.new(revisions)
end

Class Method Details

.for(root) ⇒ Object

Load the skip list from a directory.



18
19
20
21
22
23
24
25
26
# File 'lib/bake/modernize/license.rb', line 18

def self.for(root)
	full_path = File.join(root, GIT_BLAME_IGNORE_REVS)
	
	if File.exist?(full_path)
		skip_list = self.new
		skip_list.extract(full_path)
		return skip_list
	end
end

Instance Method Details

#extract(path) ⇒ Object

Extract the revisions from the given path.



36
37
38
39
40
41
42
43
44
45
# File 'lib/bake/modernize/license.rb', line 36

def extract(path)
	File.open(path, 'r') do |file|
		file.each_line do |line|
			# Skip empty lines and comments
			next if line =~ /^\s*(#|$)/
			# Parse line
			@revisions << line.strip
		end
	end
end

#ignore?(commit) ⇒ Boolean

Check if the given commit should be ignored.

Returns:

  • (Boolean)


48
49
50
# File 'lib/bake/modernize/license.rb', line 48

def ignore?(commit)
	@revisions.include?(commit.oid)
end