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
- #files_from_cloc_analysis ⇒ Object
- #get_module(path) ⇒ Object
- #get_patch_module(patch) ⇒ Object
- #ignore_file?(path) ⇒ Boolean
- #read_options(source, source_options, db) ⇒ Object
Instance Method Details
#files_from_cloc_analysis ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/diggit/developers_activity/activity_extractor/modules.rb', line 44 def files_from_cloc_analysis release_files = Set.new cloc_source = @db.db['cloc-file'].find_one({ source: @source }) cloc_source["cloc"].each do |cloc_file| release_files << cloc_file["path"] end release_files end |
#get_module(path) ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/diggit/developers_activity/activity_extractor/modules.rb', line 28 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
39 40 41 42 |
# File 'lib/diggit/developers_activity/activity_extractor/modules.rb', line 39 def get_patch_module(patch) file = patch.delta.old_file[:path] get_module(file) end |
#ignore_file?(path) ⇒ Boolean
24 25 26 |
# File 'lib/diggit/developers_activity/activity_extractor/modules.rb', line 24 def ignore_file?(path) !@release_files.include?(path) || (@file_filter =~ path).nil? end |
#read_options(source, source_options, db) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/diggit/developers_activity/activity_extractor/modules.rb', line 15 def (source, , db) @source = source @db = db @release_files = files_from_cloc_analysis @modules_regexp = .key?(MODULES_REGEXP) ? [MODULES_REGEXP].map { |m| Regexp.new m } : [] @file_filter = Regexp.new [FILE_FILTER] @file_filter ||= // end |