bibliothecary 1.1.0 → 1.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ec4d295bd9a1f06e2ed647bc765ca1edf0f31e9d
4
- data.tar.gz: a160b8a6a6ac9c2906786f8c4a5aebed556489b4
3
+ metadata.gz: 2cb2459a1a23ab026d88c3914037be5605a6105e
4
+ data.tar.gz: c608876219f4fc438b8cfc9e2ab5e90558f2e0da
5
5
  SHA512:
6
- metadata.gz: 9e81044b368f8c8e33e8081b10374ac4dc0e2de41dd7cc86d55046b6d79f65ec6eb6243ded40ef97fd899863e58fd0620d5c45bdcb8566072578a47c27be31d2
7
- data.tar.gz: 0f2c53b851a8b0029d781b9b2db982c6eefc27182747f51cd49fc8f21f599e89ed103f3cacc5a455146cfd189ba25696ffac63dc057b09def1c3584393a19561
6
+ metadata.gz: 09236de8f35df1cce5a4f137d282ce5b4b3cbfb57808760600752ea79d9e65fd49bdd3645c2463ee1e03d2cf3aa2004649bde7e0a14fdd2a83f5d03b3aaab6e7
7
+ data.tar.gz: 88a52f790799d60c37b0406bb8079ae3d8749938596fd395c432eae0e8026a23027d43238dd1f757bd05700048a48270bda1abede280e74ed6f6fa99243bf492
@@ -18,20 +18,22 @@ module Bibliothecary
18
18
 
19
19
  def self.analyse(folder_path, file_list)
20
20
  [analyse_cargo_toml(folder_path, file_list),
21
- analyse_cargo_lock(folder_path, file_list)]
21
+ analyse_cargo_lock(folder_path, file_list)].flatten
22
22
  end
23
23
 
24
24
  def self.analyse_cargo_toml(folder_path, file_list)
25
- path = file_list.find{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/Cargo\.toml$/) }
26
- return unless path
25
+ paths = file_list.select{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/Cargo\.toml$/) }
26
+ return unless paths.any?
27
27
 
28
- manifest = TOML.load_file(path)
28
+ paths.map do |path|
29
+ manifest = TOML.load_file(path)
29
30
 
30
- {
31
- platform: PLATFORM_NAME,
32
- path: path,
33
- dependencies: parse_manifest(manifest)
34
- }
31
+ {
32
+ platform: PLATFORM_NAME,
33
+ path: path,
34
+ dependencies: parse_manifest(manifest)
35
+ }
36
+ end
35
37
  end
36
38
 
37
39
  def self.parse_manifest(manifest)
@@ -45,16 +47,18 @@ module Bibliothecary
45
47
  end
46
48
 
47
49
  def self.analyse_cargo_lock(folder_path, file_list)
48
- path = file_list.find{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/Cargo\.lock$/) }
49
- return unless path
50
+ paths = file_list.select{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/Cargo\.lock$/) }
51
+ return unless paths.any?
50
52
 
51
- manifest = TOML.load_file(path)
53
+ paths.map do |path|
54
+ manifest = TOML.load_file(path)
52
55
 
53
- {
54
- platform: PLATFORM_NAME,
55
- path: path,
56
- dependencies: parse_lockfile(manifest)
57
- }
56
+ {
57
+ platform: PLATFORM_NAME,
58
+ path: path,
59
+ dependencies: parse_lockfile(manifest)
60
+ }
61
+ end
58
62
  end
59
63
 
60
64
  def self.parse_lockfile(manifest)
@@ -34,7 +34,7 @@ module Bibliothecary
34
34
  analyse_podspec(folder_path, file_list),
35
35
  analyse_podfile_lock(folder_path, file_list),
36
36
  analyse_podspec_json(folder_path, file_list)
37
- ]
37
+ ].flatten
38
38
  end
39
39
 
40
40
  def self.analyse_podfile(folder_path, file_list)
@@ -51,29 +51,33 @@ module Bibliothecary
51
51
  end
52
52
 
53
53
  def self.analyse_podspec(folder_path, file_list)
54
- path = file_list.find{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/^[A-Za-z0-9_-]+\.podspec$/) }
55
- return unless path
54
+ paths = file_list.select{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/^[A-Za-z0-9_-]+\.podspec$/) }
55
+ return unless paths.any?
56
56
 
57
- manifest = Gemnasium::Parser.send(:podspec, File.open(path).read)
57
+ paths.map do |path|
58
+ manifest = Gemnasium::Parser.send(:podspec, File.open(path).read)
58
59
 
59
- {
60
- platform: PLATFORM_NAME,
61
- path: path,
62
- dependencies: parse_manifest(manifest)
63
- }
60
+ {
61
+ platform: PLATFORM_NAME,
62
+ path: path,
63
+ dependencies: parse_manifest(manifest)
64
+ }
65
+ end
64
66
  end
65
67
 
66
68
  def self.analyse_podspec_json(folder_path, file_list)
67
- path = file_list.find{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/^[A-Za-z0-9_-]+\.podspec.json$/) }
68
- return unless path
69
+ paths = file_list.select{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/^[A-Za-z0-9_-]+\.podspec.json$/) }
70
+ return unless paths.any?
69
71
 
70
- manifest = JSON.parse File.open(path).read
72
+ paths.map do |path|
73
+ manifest = JSON.parse File.open(path).read
71
74
 
72
- {
73
- platform: PLATFORM_NAME,
74
- path: path,
75
- dependencies: parse_json_manifest(manifest)
76
- }
75
+ {
76
+ platform: PLATFORM_NAME,
77
+ path: path,
78
+ dependencies: parse_json_manifest(manifest)
79
+ }
80
+ end
77
81
  end
78
82
 
79
83
  def self.analyse_podfile_lock(folder_path, file_list)
@@ -6,13 +6,13 @@ module Bibliothecary
6
6
  PLATFORM_NAME = 'Maven'
7
7
 
8
8
  def self.parse(filename, file_contents)
9
- if filename.match(/^ivy\.xml$/i)
9
+ if filename.match(/ivy\.xml$/i)
10
10
  xml = Ox.parse file_contents
11
11
  parse_ivy_manifest(xml)
12
- elsif filename.match(/^pom\.xml$/i)
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)
15
+ elsif filename.match(/build.gradle$/i)
16
16
  parse_gradle(file_contents)
17
17
  else
18
18
  []
@@ -24,45 +24,52 @@ module Bibliothecary
24
24
  analyse_pom(folder_path, file_list),
25
25
  analyse_ivy(folder_path, file_list),
26
26
  analyse_gradle(folder_path, file_list),
27
- ]
27
+ ].flatten
28
28
  end
29
29
 
30
30
  def self.analyse_pom(folder_path, file_list)
31
- path = file_list.find{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/^pom\.xml$/i) }
32
- return unless path
31
+ paths = file_list.select{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/pom\.xml$/i) }
32
+ return unless paths.any?
33
33
 
34
- manifest = Ox.parse File.open(path).read
34
+ paths.map do |path|
35
+ manifest = Ox.parse File.open(path).read
35
36
 
36
- {
37
- platform: PLATFORM_NAME,
38
- path: path,
39
- dependencies: parse_pom_manifest(manifest)
40
- }
37
+ {
38
+ platform: PLATFORM_NAME,
39
+ path: path,
40
+ dependencies: parse_pom_manifest(manifest)
41
+ }
42
+ end
41
43
  end
42
44
 
43
45
  def self.analyse_ivy(folder_path, file_list)
44
- path = file_list.find{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/^ivy.xml$/i) }
45
- return unless path
46
+ paths = file_list.select{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/ivy\.xml$/i) }
47
+ return unless paths.any?
46
48
 
47
- manifest = Ox.parse File.open(path).read
49
+ paths.map do |path|
50
+ manifest = Ox.parse File.open(path).read
48
51
 
49
- {
50
- platform: PLATFORM_NAME,
51
- path: path,
52
- dependencies: parse_ivy_manifest(manifest)
53
- }
52
+ {
53
+ platform: PLATFORM_NAME,
54
+ path: path,
55
+ dependencies: parse_ivy_manifest(manifest)
56
+ }
57
+ end
54
58
  end
55
59
 
56
60
  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
- }
61
+ paths = file_list.select{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/build\.gradle$/i) }
62
+ return unless paths.any?
63
+
64
+ paths.map do |path|
65
+ manifest = File.open(path).read
66
+
67
+ {
68
+ platform: PLATFORM_NAME,
69
+ path: path,
70
+ dependencies: parse_gradle(manifest)
71
+ }
72
+ end
66
73
  end
67
74
 
68
75
  def self.parse_ivy_manifest(manifest)
@@ -31,71 +31,81 @@ module Bibliothecary
31
31
  analyse_project_lock_json(folder_path, file_list),
32
32
  analyse_packages_config(folder_path, file_list),
33
33
  analyse_nuspec(folder_path, file_list),
34
- analyse_paket_lock(folder_path, file_list)]
34
+ analyse_paket_lock(folder_path, file_list)].flatten
35
35
  end
36
36
 
37
37
  def self.analyse_project_json(folder_path, file_list)
38
- path = file_list.find{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/Project\.json$/) }
39
- return unless path
38
+ paths = file_list.select{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/Project\.json$/i) }
39
+ return unless paths.any?
40
40
 
41
- manifest = JSON.parse File.open(path).read
41
+ paths.map do |path|
42
+ manifest = JSON.parse File.open(path).read
42
43
 
43
- {
44
- platform: PLATFORM_NAME,
45
- path: path,
46
- dependencies: parse_project_json(manifest)
47
- }
44
+ {
45
+ platform: PLATFORM_NAME,
46
+ path: path,
47
+ dependencies: parse_project_json(manifest)
48
+ }
49
+ end
48
50
  end
49
51
 
50
52
  def self.analyse_project_lock_json(folder_path, file_list)
51
- path = file_list.find{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/Project\.lock\.json$/) }
52
- return unless path
53
+ paths = file_list.select{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/Project\.lock\.json$/) }
54
+ return unless paths.any?
53
55
 
54
- manifest = JSON.parse File.open(path).read
56
+ paths.map do |path|
57
+ manifest = JSON.parse File.open(path).read
55
58
 
56
- {
57
- platform: PLATFORM_NAME,
58
- path: path,
59
- dependencies: parse_project_lock_json(manifest)
60
- }
59
+ {
60
+ platform: PLATFORM_NAME,
61
+ path: path,
62
+ dependencies: parse_project_lock_json(manifest)
63
+ }
64
+ end
61
65
  end
62
66
 
63
67
  def self.analyse_packages_config(folder_path, file_list)
64
- path = file_list.find{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/packages\.config$/) }
65
- return unless path
68
+ paths = file_list.select{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/packages\.config$/) }
69
+ return unless paths.any?
66
70
 
67
- manifest = Ox.parse File.open(path).read
71
+ paths.map do |path|
72
+ manifest = Ox.parse File.open(path).read
68
73
 
69
- {
70
- platform: PLATFORM_NAME,
71
- path: path,
72
- dependencies: parse_packages_config(manifest)
73
- }
74
+ {
75
+ platform: PLATFORM_NAME,
76
+ path: path,
77
+ dependencies: parse_packages_config(manifest)
78
+ }
79
+ end
74
80
  end
75
81
 
76
82
  def self.analyse_nuspec(folder_path, file_list)
77
- path = file_list.find{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/^[A-Za-z0-9_-]+\.nuspec$/) }
78
- return unless path
83
+ paths = file_list.select{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/^[A-Za-z0-9_-]+\.nuspec$/) }
84
+ return unless paths.any?
79
85
 
80
- manifest = Ox.parse File.open(path).read
86
+ paths.map do |path|
87
+ manifest = Ox.parse File.open(path).read
81
88
 
82
- {
83
- platform: PLATFORM_NAME,
84
- path: path,
85
- dependencies: parse_nuspec(manifest)
86
- }
89
+ {
90
+ platform: PLATFORM_NAME,
91
+ path: path,
92
+ dependencies: parse_nuspec(manifest)
93
+ }
94
+ end
87
95
  end
88
96
 
89
97
  def self.analyse_paket_lock(folder_path, file_list)
90
- path = file_list.find{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/paket\.lock$/) }
91
- return unless path
92
-
93
- lines = File.readlines(path)
94
- {
95
- platform: PLATFORM_NAME,
96
- path: path,
97
- dependencies: parse_paket_lock(lines)
98
- }
98
+ paths = file_list.select{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/paket\.lock$/) }
99
+ return unless paths.any?
100
+
101
+ paths.map do |path|
102
+ lines = File.readlines(path)
103
+ {
104
+ platform: PLATFORM_NAME,
105
+ path: path,
106
+ dependencies: parse_paket_lock(lines)
107
+ }
108
+ end
99
109
  end
100
110
 
101
111
  def self.parse_project_json(manifest)
@@ -19,36 +19,40 @@ module Bibliothecary
19
19
 
20
20
  def self.analyse(folder_path, file_list)
21
21
  [analyse_requirements_txt(folder_path, file_list),
22
- analyse_setup_py(folder_path, file_list)]
22
+ analyse_setup_py(folder_path, file_list)].flatten
23
23
  end
24
24
 
25
25
  def self.analyse_requirements_txt(folder_path, file_list)
26
- path = file_list.find do |path|
26
+ paths = file_list.select do |path|
27
27
  p = path.gsub(folder_path, '').gsub(/^\//, '')
28
28
  p.match(/require.*\.(txt|pip)$/) && !path.match(/^node_modules/)
29
29
  end
30
- return unless path
30
+ return unless paths.any?
31
31
 
32
- manifest = File.open(path).read
32
+ paths.map do |path|
33
+ manifest = File.open(path).read
33
34
 
34
- {
35
- platform: PLATFORM_NAME,
36
- path: path,
37
- dependencies: parse_requirements_txt(manifest)
38
- }
35
+ {
36
+ platform: PLATFORM_NAME,
37
+ path: path,
38
+ dependencies: parse_requirements_txt(manifest)
39
+ }
40
+ end
39
41
  end
40
42
 
41
43
  def self.analyse_setup_py(folder_path, file_list)
42
- path = file_list.find{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/setup\.py$/) }
43
- return unless path
44
+ paths = file_list.select{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/setup\.py$/) }
45
+ return unless paths.any?
44
46
 
45
- manifest = File.open(path).read
47
+ paths.map do |path|
48
+ manifest = File.open(path).read
46
49
 
47
- {
48
- platform: PLATFORM_NAME,
49
- path: path,
50
- dependencies: parse_setup_py(manifest)
51
- }
50
+ {
51
+ platform: PLATFORM_NAME,
52
+ path: path,
53
+ dependencies: parse_setup_py(manifest)
54
+ }
55
+ end
52
56
  end
53
57
 
54
58
  def self.parse_setup_py(manifest)
@@ -1,3 +1,3 @@
1
1
  module Bibliothecary
2
- VERSION = "1.1.0"
2
+ VERSION = "1.2.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: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Nesbitt