bibliothecary 0.15.2 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/bibliothecary/parsers/maven.rb +37 -3
- 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: bd395c01afca7a8cb452b26c49c134bc56b616fe
|
4
|
+
data.tar.gz: b76a0d88bafece475999daef366beaff3c7b0858
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: baa586094f4e0f698c85f8fe5b895eec4a740ce2385b0bfcc6af21d91883af292ba5b8d9ca1869e5aa53212f589fd71d37ffe265aa4cc0592c153413e76a91e5
|
7
|
+
data.tar.gz: 3a8cfb0239129ae85ade5e6e935696b2d78fa25fbfcede2d6fc51fe8c785ff32c6a2964e8888f5df0a7454a20aabdbbf46f77de8d053ee8d5ec0ed5f38d79a70
|
@@ -12,14 +12,19 @@ module Bibliothecary
|
|
12
12
|
elsif filename.match(/^pom\.xml$/i)
|
13
13
|
xml = Ox.parse file_contents
|
14
14
|
parse_pom_manifest(xml)
|
15
|
+
elsif filename.match(/^build.gradle$/i)
|
16
|
+
parse_gradle(file_contents)
|
15
17
|
else
|
16
18
|
[]
|
17
19
|
end
|
18
20
|
end
|
19
21
|
|
20
22
|
def self.analyse(folder_path, file_list)
|
21
|
-
[
|
22
|
-
|
23
|
+
[
|
24
|
+
analyse_pom(folder_path, file_list),
|
25
|
+
analyse_ivy(folder_path, file_list),
|
26
|
+
analyse_gradle(folder_path, file_list),
|
27
|
+
]
|
23
28
|
end
|
24
29
|
|
25
30
|
def self.analyse_pom(folder_path, file_list)
|
@@ -38,7 +43,7 @@ module Bibliothecary
|
|
38
43
|
def self.analyse_ivy(folder_path, file_list)
|
39
44
|
path = file_list.find{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/^ivy.xml$/i) }
|
40
45
|
return unless path
|
41
|
-
|
46
|
+
|
42
47
|
manifest = Ox.parse File.open(path).read
|
43
48
|
|
44
49
|
{
|
@@ -48,6 +53,18 @@ module Bibliothecary
|
|
48
53
|
}
|
49
54
|
end
|
50
55
|
|
56
|
+
def self.analyse_gradle(folder_path, file_list)
|
57
|
+
path = file_list.find{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/^build.gradle$/i) }
|
58
|
+
return unless path
|
59
|
+
manifest = File.open(path).read
|
60
|
+
|
61
|
+
{
|
62
|
+
platform: PLATFORM_NAME,
|
63
|
+
path: path,
|
64
|
+
dependencies: parse_gradle(manifest)
|
65
|
+
}
|
66
|
+
end
|
67
|
+
|
51
68
|
def self.parse_ivy_manifest(manifest)
|
52
69
|
manifest.dependencies.locate('dependency').map do |dependency|
|
53
70
|
attrs = dependency.attributes
|
@@ -70,6 +87,23 @@ module Bibliothecary
|
|
70
87
|
end
|
71
88
|
end
|
72
89
|
|
90
|
+
def self.parse_gradle(manifest)
|
91
|
+
response = Typhoeus.post("https://gradle-parser.herokuapp.com/parse", body: manifest)
|
92
|
+
json = JSON.parse(response.body)
|
93
|
+
|
94
|
+
return [] unless json['dependencies'] && json['dependencies']['compile']
|
95
|
+
json['dependencies']['compile'].map do |dependency|
|
96
|
+
next unless dependency.split(':').length == 3
|
97
|
+
version = dependency.split(':').last
|
98
|
+
name = dependency.split(':')[0..-2].join(':')
|
99
|
+
{
|
100
|
+
name: name,
|
101
|
+
version: version,
|
102
|
+
type: 'runtime'
|
103
|
+
}
|
104
|
+
end.compact
|
105
|
+
end
|
106
|
+
|
73
107
|
def self.extract_pom_dep_info(manifest, dependency, name)
|
74
108
|
field = dependency.locate(name).first
|
75
109
|
return nil if field.nil?
|