-
Notifications
You must be signed in to change notification settings - Fork 205
/
sourcerank_helper.rb
66 lines (62 loc) · 2.7 KB
/
sourcerank_helper.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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
63
64
65
66
module SourcerankHelper
def source_rank_badge_class(value)
if value > 0
'alert-success'
elsif value < 0
'alert-danger'
else
'alert-warning'
end
end
def source_rank_titles
{
basic_info_present: 'Basic info present?',
repository_present: 'Source repository present?',
readme_present: 'Readme present?',
license_present: 'License present?',
versions_present: 'Has multiple versions?',
follows_semver: 'Follows SemVer?',
recent_release: 'Recent release?',
not_brand_new: 'Not brand new?',
is_deprecated: 'Deprecated?',
is_unmaintained: 'Unmaintained?',
is_removed: 'Removed?',
any_outdated_dependencies: 'Outdated dependencies?',
one_point_oh: '1.0.0 or greater?',
all_prereleases: 'Prerelease?',
stars: 'Stars',
dependent_projects: 'Dependent Projects',
dependent_repositories: 'Dependent Repositories',
contributors: 'Contributors',
subscribers: 'Libraries.io subscribers',
recently_pushed: 'Recently pushed?'
}
end
def source_rank_explainations
{
basic_info_present: 'Description, homepage/repository link and keywords present?',
versions_present: 'Has the project had more than one release?',
follows_semver: 'Every version has a valid SemVer number',
recent_release: 'Within the past 6 months?',
not_brand_new: 'Existed for at least 6 months',
is_deprecated: 'Marked as deprecated by the maintainer',
is_unmaintained: 'Marked as unmaintained by the maintainer',
is_removed: 'Removed from the package manager',
all_prereleases: 'All versions are prerelease',
any_outdated_dependencies: 'At least one dependency is behind the latest version',
stars: 'Logarithmic scale',
dependent_projects: 'Logarithmic scale times two',
dependent_repositories: 'Logarithmic scale',
contributors: 'Logarithmic scale divided by two',
subscribers: 'Logarithmic scale divided by two',
recently_pushed: 'Pushed to within the past 6 months?'
}
end
def negative_factors
[:is_removed, :is_unmaintained, :is_deprecated, :any_outdated_dependencies, :all_prereleases]
end
def skip_showing_if_zero?(key, value)
return false unless negative_factors.include?(key)
value == 0
end
end