forked from netlify/staticgen
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrepo_data.rb
More file actions
42 lines (35 loc) · 912 Bytes
/
repo_data.rb
File metadata and controls
42 lines (35 loc) · 912 Bytes
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
require 'github/project'
require 'github/api'
module Github
class RepoData
def initialize(app, extension)
@app = app
@extension = extension
@projects = []
@languages = {}
end
def projects
@projects.sort {|a,b|
b.stars <=> a.stars
}
end
def languages
@languages.keys.sort.uniq { |language| language.downcase }
end
def manipulate_resource_list(resources)
@projects = []
API.bulk do
resources.each do |resource|
next unless resource.path.match /^projects\//
resource.extend Project
resource.repo_data # Trigger a repo fetch
resource.destination_path = resource.path.sub(/^projects\//, '')
@projects << resource
@languages[resource.language] ||= 0
@languages[resource.language] += 1
end
end
resources
end
end
end