bibliothecary 7.3.2 → 7.3.5

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
  SHA256:
3
- metadata.gz: 5dece4dd0ba501561d36353606c81211a31727e01168effc7bbfdf0dc9ceec19
4
- data.tar.gz: 4aa63636cf6e4697e9c35c2965f7cfe16bbe82f408d28f37c10fed678a1e893f
3
+ metadata.gz: c3e4510e233cc6052a908e31f4d60498481c2b940448a2727e8cf89f28fae9b6
4
+ data.tar.gz: fe1fe8895bfae3b445b8c36de74a0285e9121a6fa49fde52bc481bc78d3b8931
5
5
  SHA512:
6
- metadata.gz: 0e3aa9619424e7ddc658a61779463d92a21ce7c80b364c61da52c4e05ae82f00aa3e792385f3552dbf5be0a240a4ae5cdee1b413b6b5412ffc2c038cd69a82c9
7
- data.tar.gz: df88033afb288b0dcff8babb62eccda691aebc74aa1f19f209c6407c6cdddab4caf39420b23d012c51540988f7f7ffc9a81aa562724cf0dfe5eb6465e3801524
6
+ metadata.gz: 203d1b6888ea667b5f0cf661f7282239d1736f70547c734fb890e0f58ac43d429e4193bda6977a88ca880a2d7cfbd5c1989442f171e27aa6d583932d83898109
7
+ data.tar.gz: 2fbf1aaee7ba11983db23d163b57d32e2ba195fc2fa1dad71447becba40c3eafabb9a8834a2e5a12a24d42b46424cafc32837ad8c9157478734e1d17c8d9a98d
data/.gitignore CHANGED
@@ -7,3 +7,4 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ *.gem
data/README.md CHANGED
@@ -62,6 +62,7 @@ All available config options are in: https://github.com/librariesio/bibliothecar
62
62
  - pom.xml
63
63
  - ivy.xml
64
64
  - build.gradle
65
+ - gradle-dependencies-q.txt
65
66
  - RubyGems
66
67
  - Gemfile
67
68
  - Gemfile.lock
@@ -25,6 +25,10 @@ module Bibliothecary
25
25
  base.extend(ClassMethods)
26
26
  end
27
27
  module ClassMethods
28
+ def generic?
29
+ platform_name == "generic"
30
+ end
31
+
28
32
  def mapping_entry_match?(matcher, details, info)
29
33
  if matcher.call(info.relative_path)
30
34
  # we only want to load contents if we don't have them already
@@ -119,13 +123,32 @@ module Bibliothecary
119
123
  end
120
124
  alias analyze_contents analyse_contents
121
125
 
126
+ def dependencies_to_analysis(info, kind, dependencies)
127
+ dependencies = dependencies || [] # work around any legacy parsers that return nil
128
+ if generic?
129
+ analyses = []
130
+ grouped = dependencies.group_by { |dep| dep[:platform] }
131
+ all_analyses = grouped.keys.map do |platform|
132
+ deplatformed_dependencies = grouped[platform].map { |d| d.delete(:platform); d }
133
+ Bibliothecary::Analyser::create_analysis(platform, info.relative_path, kind, deplatformed_dependencies)
134
+ end
135
+ # this is to avoid a larger refactor for the time being. The larger refactor
136
+ # needs to make analyse_contents return multiple analysis, or add another
137
+ # method that can return multiple and deprecate analyse_contents, perhaps.
138
+ raise "File contains zero or multiple platforms, currently must have exactly one" if all_analyses.length != 1
139
+ all_analyses.first
140
+ else
141
+ Bibliothecary::Analyser::create_analysis(platform_name, info.relative_path, kind, dependencies)
142
+ end
143
+ end
144
+
122
145
  def analyse_contents_from_info(info)
123
146
  # If your Parser needs to return multiple responses for one file, please override this method
124
147
  # For example see conda.rb
125
148
  kind = determine_kind_from_info(info)
126
149
  dependencies = parse_file(info.relative_path, info.contents)
127
150
 
128
- Bibliothecary::Analyser::create_analysis(platform_name, info.relative_path, kind, dependencies || [])
151
+ dependencies_to_analysis(info, kind, dependencies)
129
152
  rescue Bibliothecary::FileParsingError => e
130
153
  Bibliothecary::Analyser::create_error_analysis(platform_name, info.relative_path, kind, e.message)
131
154
  end
@@ -0,0 +1,39 @@
1
+ require 'csv'
2
+
3
+ module Bibliothecary
4
+ module Parsers
5
+ class Generic
6
+ include Bibliothecary::Analyser
7
+
8
+ def self.mapping
9
+ {
10
+ match_filename("dependencies.csv") => {
11
+ kind: 'lockfile',
12
+ parser: :parse_lockfile
13
+ }
14
+ }
15
+ end
16
+
17
+ def self.parse_lockfile(file_contents)
18
+ table = CSV.parse(file_contents, headers: true)
19
+
20
+ required_headers = ["platform", "name", "requirement"]
21
+ missing_headers = required_headers - table.headers
22
+ raise "Missing headers #{missing_headers} in CSV" unless missing_headers.empty?
23
+
24
+ table.map.with_index do |row, idx|
25
+ line = idx + 1
26
+ required_headers.each do |h|
27
+ raise "missing field '#{h}' on line #{line}" if row[h].empty?
28
+ end
29
+ {
30
+ platform: row['platform'],
31
+ name: row['name'],
32
+ requirement: row['requirement'],
33
+ type: row.fetch('type', 'runtime'),
34
+ }
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -44,6 +44,10 @@ module Bibliothecary
44
44
  kind: 'manifest',
45
45
  parser: :parse_gradle
46
46
  },
47
+ match_filename("build.gradle.kts", case_insensitive: true) => {
48
+ kind: 'manifest',
49
+ parser: :parse_gradle_kts
50
+ },
47
51
  match_extension(".xml", case_insensitive: true) => {
48
52
  content_matcher: :ivy_report?,
49
53
  kind: 'lockfile',
@@ -223,6 +227,11 @@ module Bibliothecary
223
227
  end.compact
224
228
  end
225
229
 
230
+ def self.parse_gradle_kts(manifest)
231
+ # TODO: the gradle-parser side needs to be implemented for this, coming soon.
232
+ []
233
+ end
234
+
226
235
  def self.gradle_dependency_name(group, name)
227
236
  if group.empty? && name.include?(":")
228
237
  group, name = name.split(":", 2)
@@ -281,7 +290,7 @@ module Bibliothecary
281
290
  non_prop_name = property_name.gsub(".", "/").gsub("project/", "")
282
291
  return "${#{property_name}}" if !xml.respond_to?("properties") && parent_properties.empty? && xml.locate(non_prop_name).empty?
283
292
 
284
- prop_field = xml.properties.locate(property_name).first
293
+ prop_field = xml.properties.locate(property_name).first if xml.respond_to?("properties")
285
294
  parent_prop = parent_properties[property_name]
286
295
  if prop_field
287
296
  prop_field.nodes.first
@@ -1,3 +1,3 @@
1
1
  module Bibliothecary
2
- VERSION = "7.3.2"
2
+ VERSION = "7.3.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bibliothecary
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.3.2
4
+ version: 7.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Nesbitt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-29 00:00:00.000000000 Z
11
+ date: 2022-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tomlrb
@@ -251,6 +251,7 @@ files:
251
251
  - lib/bibliothecary/parsers/cran.rb
252
252
  - lib/bibliothecary/parsers/dub.rb
253
253
  - lib/bibliothecary/parsers/elm.rb
254
+ - lib/bibliothecary/parsers/generic.rb
254
255
  - lib/bibliothecary/parsers/go.rb
255
256
  - lib/bibliothecary/parsers/hackage.rb
256
257
  - lib/bibliothecary/parsers/haxelib.rb