bibliothecary 0.15.2 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b3b90021e26b8325eef2f946830ad91332e82779
4
- data.tar.gz: fba5691b84d92922afc3ce95014d803895494f43
3
+ metadata.gz: bd395c01afca7a8cb452b26c49c134bc56b616fe
4
+ data.tar.gz: b76a0d88bafece475999daef366beaff3c7b0858
5
5
  SHA512:
6
- metadata.gz: 1b1efb1ed1f030e39b5d7f1a32d93fb5f090ab1e62b5dfb1606a85d19664eb8b8a5f1fcac3000d2fa23fe48b049d98265c32bc03b9629891feb887259a0fa17c
7
- data.tar.gz: b4e50501507bdec9503a5eabb054ca95770cebc303d33aac718a3cdf6018bdfc5898c3cf40e617c98f0ec6f69754e83f3355c268b54c4cec958a58f3f205c10a
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
- [analyse_pom(folder_path, file_list),
22
- analyse_ivy(folder_path, file_list)]
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
- p path
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?
@@ -1,3 +1,3 @@
1
1
  module Bibliothecary
2
- VERSION = "0.15.2"
2
+ VERSION = "0.16.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bibliothecary
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.2
4
+ version: 0.16.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Nesbitt