Class: Diggit::DevelopersActivity::Analyses::MonthsActivityAnalysis
- Inherits:
-
ActivityAnalysis
- Object
- Analysis
- ActivityAnalysis
- Diggit::DevelopersActivity::Analyses::MonthsActivityAnalysis
show all
- Defined in:
- lib/diggit/developers_activity/analyses/months_activity_analysis.rb
Instance Method Summary
collapse
#load_options, #source_options
#extract_developers_activity
Constructor Details
Returns a new instance of MonthsActivityAnalysis.
17
18
19
20
21
22
|
# File 'lib/diggit/developers_activity/analyses/months_activity_analysis.rb', line 17
def initialize(*args)
super(*args)
= @options.key?() ? @options[].to_sym : :before
= @options.key?() ? @options[].to_i : 12
end
|
Instance Method Details
#clean ⇒ Object
29
30
31
32
|
# File 'lib/diggit/developers_activity/analyses/months_activity_analysis.rb', line 29
def clean
@addons[:db].db[MONTHS_BEFORE_COL].remove({ project: @source }) unless == :after
@addons[:db].db[MONTHS_AFTER_COL].remove({ project: @source }) unless == :before
end
|
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
# File 'lib/diggit/developers_activity/analyses/months_activity_analysis.rb', line 64
def
Renames.clear
r_0 = @repo.lookup(source_options["cloc-commit-id"])
r_last = @repo.lookup(source_options["R_last"])
t_0 = r_0.author[:time]
walker = Rugged::Walker.new(@repo)
walker.sorting(Rugged::SORT_DATE | Rugged::SORT_REVERSE)
walker.push(r_last)
t_next_month = t_0 + MONTH_SECONDS
month_num = 1
commits = []
walker.each do |commit|
t = commit.author[:time]
next if t < t_0
Renames.(commit, false)
commits << commit if commit.parents.size == 1
if t > t_next_month
puts "Month #{month_num}, #{commits.size} commits"
m = .(@source, commits, month_num)
@addons[:db].db[MONTHS_AFTER_COL].insert(m) unless m.empty?
month_num += 1
t_next_month += MONTH_SECONDS
commits = []
end
break if month_num >
end
end
|
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/diggit/developers_activity/analyses/months_activity_analysis.rb', line 34
def
Renames.clear
r_0 = @repo.lookup(source_options["cloc-commit-id"])
t_first = @repo.lookup(source_options["R_first"]).author[:time]
t_0 = r_0.author[:time]
walker = Rugged::Walker.new(@repo)
walker.sorting(Rugged::SORT_DATE)
walker.push(r_0)
t_previous_month = t_0 - MONTH_SECONDS
month_num = 1
commits = []
walker.each do |commit|
t = commit.author[:time]
Renames.(commit, true)
commits << commit if commit.parents.size == 1
if t < t_previous_month || t < t_first
puts "Month #{month_num}, #{commits.size} commits"
m = (@source, commits, month_num)
@addons[:db].db[MONTHS_BEFORE_COL].insert(m) unless m.empty?
month_num += 1
t_previous_month -= MONTH_SECONDS
commits = []
end
break if t < t_first || month_num >
end
end
|
#run ⇒ Object
24
25
26
27
|
# File 'lib/diggit/developers_activity/analyses/months_activity_analysis.rb', line 24
def run
unless == :after
unless == :before
end
|