forked from librariesio/libraries.io
-
Notifications
You must be signed in to change notification settings - Fork 2
/
homebrew.rb
62 lines (54 loc) · 1.6 KB
/
homebrew.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
module PackageManager
class Homebrew < Base
HAS_VERSIONS = true
HAS_DEPENDENCIES = true
BIBLIOTHECARY_PLANNED = true
SECURITY_PLANNED = false
URL = 'http://brew.sh/'
COLOR = '#555555'
def self.package_link(project, version = nil)
"http://formulae.brew.sh/formula/#{project.name}"
end
def self.install_instructions(project, version = nil)
"brew install #{project.name}"
end
def self.project_names
get("https://formulae.brew.sh/api/formula.json").map{|project| project['name'] }.uniq
end
def self.recent_names
rss = SimpleRSS.parse(get_raw('http://formulae.brew.sh/feed.atom'))
rss.entries.map{ |entry| entry.link.split('/')[-1] }.map{|e| e.split('@').first }.uniq
end
def self.project(name)
get("https://formulae.brew.sh/api/formula/#{name}.json")
end
def self.mapping(project)
{
:name => project['formula'],
:description => project['description'],
:homepage => project['homepage'],
:repository_url => repo_fallback('', project['homepage']),
:version => project['version'],
:dependencies => project['dependencies']
}
end
def self.versions(project)
[
{
number: project['version']
}
]
end
def self.dependencies(name, version, project)
return nil unless version == project[:version]
project[:dependencies].map do |dependency|
{
project_name: dependency,
requirements: '*',
kind: 'runtime',
platform: self.name.demodulize
}
end
end
end
end