Module: Diggit::DevelopersActivity::ActivityExtractor::Modules

Extended by:
Modules
Included in:
Modules
Defined in:
lib/diggit/developers_activity/activity_extractor/modules.rb

Overview

Methods retrieving the module associated to a file.

Constant Summary collapse

MODULES_REGEXP =
"modules"
FILE_FILTER =
"file-filter"

Instance Method Summary collapse

Instance Method Details

#files_as_modulesObject



24
25
26
# File 'lib/diggit/developers_activity/activity_extractor/modules.rb', line 24

def files_as_modules
	@modules_regexp = []
end

#files_from_cloc_analysisObject



48
49
50
51
52
53
54
55
56
# File 'lib/diggit/developers_activity/activity_extractor/modules.rb', line 48

def files_from_cloc_analysis
	release_files = Set.new
	@db['cloc-file'].find({ source: @source.url }).each do |cloc_source|
		cloc_source["cloc"].each do |cloc_file|
			release_files << cloc_file["path"]
		end
	end
	release_files
end

#get_module(path) ⇒ Object



32
33
34
35
36
37
38
39
40
41
# File 'lib/diggit/developers_activity/activity_extractor/modules.rb', line 32

def get_module(path)
	path = Renames.apply(path)

	return nil if ignore_file?(path)
	@modules_regexp.each do |module_regexp|
		return module_regexp.to_s if module_regexp =~ path
	end

	path
end

#get_patch_module(patch) ⇒ Object



43
44
45
46
# File 'lib/diggit/developers_activity/activity_extractor/modules.rb', line 43

def get_patch_module(patch)
	file = patch.delta.old_file[:path]
	get_module(file)
end

#ignore_file?(path) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/diggit/developers_activity/activity_extractor/modules.rb', line 28

def ignore_file?(path)
	!@release_files.include?(path) || (@file_filter =~ path).nil?
end

#read_options(source, src_opt, db) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/diggit/developers_activity/activity_extractor/modules.rb', line 15

def read_options(source, src_opt, db)
	@source = source
	@db = db
	@release_files = files_from_cloc_analysis
	@modules_regexp = src_opt.key?(MODULES_REGEXP) ? src_opt[MODULES_REGEXP].map { |m| Regexp.new m } : []
	@file_filter = Regexp.new src_opt[FILE_FILTER]
	@file_filter ||= //
end