forked from librariesio/libraries.io
-
Notifications
You must be signed in to change notification settings - Fork 2
/
haxelib.rb
69 lines (60 loc) · 1.91 KB
/
haxelib.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
67
68
69
module PackageManager
class Haxelib < Base
HAS_VERSIONS = true
HAS_DEPENDENCIES = true
BIBLIOTHECARY_SUPPORT = true
URL = 'https://lib.haxe.org'
COLOR = '#df7900'
def self.package_link(project, version = nil)
"https://lib.haxe.org/p/#{project.name}/#{version}"
end
def self.download_url(name, version = nil)
"https://lib.haxe.org/p/#{name}/#{version}/download/"
end
def self.install_instructions(project, version = nil)
"haxelib install #{project.name} #{version}"
end
def self.project_names
get_html("https://lib.haxe.org/all/").css('.project-list tbody th').map{|th| th.css('a').first.try(:text) }
end
def self.recent_names
u = 'https://lib.haxe.org/rss/'
titles = SimpleRSS.parse(get_raw(u)).items.map(&:title)
titles.map { |t| t.split(' ').first }.uniq
end
def self.project(name)
get_json("http://haxelib-json.herokuapp.com/package/#{name}")
end
def self.mapping(project)
{
name: project['name'],
keywords_array: project['info']['tags'],
description: project['info']['desc'],
licenses: project['info']['license'],
repository_url: repo_fallback(project['info']['website'], '')
}
end
def self.versions(project)
project['info']['versions'].map do |version|
{
:number => version['name'],
:published_at => version['date']
}
end
end
def self.dependencies(name, version, _project)
json = get_json("https://lib.haxe.org/p/#{name}/#{version}/raw-files/haxelib.json")
return [] unless json['dependencies']
json['dependencies'].map do |dep_name, dep_version|
{
project_name: dep_name,
requirements: dep_version.empty? ? '*' : dep_version,
kind: 'runtime',
platform: self.name.demodulize
}
end
rescue
[]
end
end
end