bibliothecary 0.7.1 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bibliothecary/parsers/go.rb +110 -2
- data/lib/bibliothecary/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2bf997b419a25c7d6e3a2f23fd6bdd5b16c3edeb
|
4
|
+
data.tar.gz: b99a4b00d12ca3c30eb82a5a0ad7df992f0f423d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b01ba6870320e12bb21b3a8a9922f0ed0bf53a2f02051593275b710890f0d976af36deac58b28696a62d3a7f4acab1b1b2d92479f97d2e2c4987175e4c1bc1c2
|
7
|
+
data.tar.gz: 68e6a5101f3d5a1130717146b52f0d417a9dcbe89b11257c9b7f4778b7abe677e1e078db8fbf5843f4fb87f0ec53aecd26ac49aa3f02eea17f12a4418eafc4d7
|
@@ -1,2 +1,110 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require 'yaml'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module Bibliothecary
|
5
|
+
module Parsers
|
6
|
+
class Go
|
7
|
+
PLATFORM_NAME = 'go'
|
8
|
+
|
9
|
+
def self.parse(filename, file_contents)
|
10
|
+
if filename.match(/^glide\.yaml$/)
|
11
|
+
yaml = YAML.load file_contents
|
12
|
+
parse_glide_yaml(yaml)
|
13
|
+
elsif filename.match(/^glide\.lock$/)
|
14
|
+
yaml = YAML.load file_contents
|
15
|
+
parse_glide_lockfile(yaml)
|
16
|
+
elsif filename.match(/^Godeps\/Godeps\.json$/)
|
17
|
+
json = JSON.parse file_contents
|
18
|
+
parse_godep_json(json)
|
19
|
+
else
|
20
|
+
[]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.analyse(folder_path, file_list)
|
25
|
+
[analyse_glide_yaml(folder_path, file_list),
|
26
|
+
analyse_glide_lockfile(folder_path, file_list),
|
27
|
+
analyse_godep_json(folder_path, file_list)]
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.analyse_godep_json(folder_path, file_list)
|
31
|
+
path = file_list.find{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/^Godeps\/Godeps\.json$/) }
|
32
|
+
return unless path
|
33
|
+
|
34
|
+
manifest = JSON.parse File.open(path).read
|
35
|
+
|
36
|
+
{
|
37
|
+
platform: PLATFORM_NAME,
|
38
|
+
path: path,
|
39
|
+
dependencies: parse_godep_json(manifest)
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.analyse_glide_yaml(folder_path, file_list)
|
44
|
+
path = file_list.find{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/^glide\.yaml$/) }
|
45
|
+
return unless path
|
46
|
+
|
47
|
+
manifest = YAML.load File.open(path).read
|
48
|
+
|
49
|
+
{
|
50
|
+
platform: PLATFORM_NAME,
|
51
|
+
path: path,
|
52
|
+
dependencies: parse_glide_yaml(manifest)
|
53
|
+
}
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.analyse_glide_lockfile(folder_path, file_list)
|
57
|
+
path = file_list.find{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/^glide\.lock$/) }
|
58
|
+
return unless path
|
59
|
+
|
60
|
+
manifest = YAML.load File.open(path).read
|
61
|
+
|
62
|
+
{
|
63
|
+
platform: PLATFORM_NAME,
|
64
|
+
path: path,
|
65
|
+
dependencies: parse_glide_lockfile(manifest)
|
66
|
+
}
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.parse_godep_json(manifest)
|
70
|
+
manifest.fetch('Deps',[]).map do |dependency|
|
71
|
+
p dependency
|
72
|
+
{
|
73
|
+
name: dependency['ImportPath'],
|
74
|
+
requirement: dependency['Rev'],
|
75
|
+
type: 'runtime'
|
76
|
+
}
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def self.parse_glide_yaml(manifest)
|
81
|
+
manifest.fetch('import',[]).map do |dependency|
|
82
|
+
p dependency
|
83
|
+
{
|
84
|
+
name: dependency['package'],
|
85
|
+
requirement: dependency['version'] || '*',
|
86
|
+
type: 'runtime'
|
87
|
+
}
|
88
|
+
end + manifest.fetch('devImports',[]).map do |dependency|
|
89
|
+
p dependency
|
90
|
+
{
|
91
|
+
name: dependency['package'],
|
92
|
+
requirement: dependency['version'] || '*',
|
93
|
+
type: 'development'
|
94
|
+
}
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def self.parse_glide_lockfile(manifest)
|
99
|
+
manifest.fetch('imports',[]).map do |dependency|
|
100
|
+
p dependency
|
101
|
+
{
|
102
|
+
name: dependency['name'],
|
103
|
+
requirement: dependency['version'] || '*',
|
104
|
+
type: 'runtime'
|
105
|
+
}
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|