bibliothecary 4.0.4 → 5.0.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/.codeclimate.yml +25 -0
- data/.github/CONTRIBUTING.md +165 -0
- data/.github/ISSUE_TEMPLATE.md +18 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +10 -0
- data/.rubocop.yml +1156 -0
- data/.travis.yml +4 -1
- data/Gemfile +5 -0
- data/README.md +7 -1
- data/bibliothecary.gemspec +1 -1
- data/lib/bibliothecary.rb +16 -2
- data/lib/bibliothecary/analyser.rb +28 -4
- data/lib/bibliothecary/parsers/bower.rb +7 -10
- data/lib/bibliothecary/parsers/cargo.rb +9 -31
- data/lib/bibliothecary/parsers/carthage.rb +13 -34
- data/lib/bibliothecary/parsers/clojars.rb +4 -7
- data/lib/bibliothecary/parsers/cocoapods.rb +19 -30
- data/lib/bibliothecary/parsers/cpan.rb +10 -15
- data/lib/bibliothecary/parsers/cran.rb +7 -10
- data/lib/bibliothecary/parsers/dub.rb +7 -12
- data/lib/bibliothecary/parsers/elm.rb +7 -47
- data/lib/bibliothecary/parsers/go.rb +47 -52
- data/lib/bibliothecary/parsers/hex.rb +5 -14
- data/lib/bibliothecary/parsers/julia.rb +4 -7
- data/lib/bibliothecary/parsers/maven.rb +12 -18
- data/lib/bibliothecary/parsers/meteor.rb +6 -9
- data/lib/bibliothecary/parsers/npm.rb +15 -14
- data/lib/bibliothecary/parsers/nuget.rb +18 -28
- data/lib/bibliothecary/parsers/packagist.rb +9 -14
- data/lib/bibliothecary/parsers/pub.rb +9 -14
- data/lib/bibliothecary/parsers/pypi.rb +8 -10
- data/lib/bibliothecary/parsers/rubygems.rb +16 -23
- data/lib/bibliothecary/parsers/shard.rb +9 -14
- data/lib/bibliothecary/parsers/swift_pm.rb +4 -7
- data/lib/bibliothecary/version.rb +1 -1
- data/lib/sdl_parser.rb +0 -4
- metadata +9 -5
- data/CONTRIBUTING.md +0 -10
@@ -5,60 +5,20 @@ module Bibliothecary
|
|
5
5
|
class Elm
|
6
6
|
include Bibliothecary::Analyser
|
7
7
|
|
8
|
-
def self.
|
9
|
-
if filename.match(/^elm-package\.json$|^elm_dependencies\.json$/)
|
10
|
-
file_contents = File.open(path).read
|
11
|
-
json = JSON.parse file_contents
|
12
|
-
parse_json_manifest(json)
|
13
|
-
elsif filename.match(/^elm-stuff\/exact-dependencies\.json$/)
|
14
|
-
file_contents = File.open(path).read
|
15
|
-
json = JSON.parse file_contents
|
16
|
-
parse_json_lock(json)
|
17
|
-
else
|
18
|
-
[]
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def self.analyse(folder_path, file_list)
|
23
|
-
[analyse_json(folder_path, file_list),
|
24
|
-
analyse_json_lock(folder_path, file_list)]
|
25
|
-
end
|
26
|
-
|
27
|
-
def self.analyse_json(folder_path, file_list)
|
28
|
-
path = file_list.find{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/^elm-package\.json$|^elm_dependencies\.json$/) }
|
29
|
-
return unless path
|
30
|
-
|
31
|
-
manifest = JSON.parse File.open(path).read
|
32
|
-
|
33
|
-
{
|
34
|
-
platform: PLATFORM_NAME,
|
35
|
-
path: path,
|
36
|
-
dependencies: parse_json_manifest(manifest)
|
37
|
-
}
|
38
|
-
rescue
|
39
|
-
[]
|
40
|
-
end
|
41
|
-
|
42
|
-
def self.analyse_json_lock(folder_path, file_list)
|
43
|
-
path = file_list.find{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/^elm-stuff\/exact-dependencies\.json$/) }
|
44
|
-
return unless path
|
45
|
-
|
46
|
-
manifest = JSON.parse File.open(path).read
|
47
|
-
|
8
|
+
def self.mapping
|
48
9
|
{
|
49
|
-
|
50
|
-
|
51
|
-
dependencies: parse_json_lock(manifest)
|
10
|
+
/^elm-package\.json$|^elm_dependencies\.json$/ => :parse_json_manifest,
|
11
|
+
/^elm-stuff\/exact-dependencies\.json$/ => :parse_json_lock
|
52
12
|
}
|
53
|
-
rescue
|
54
|
-
[]
|
55
13
|
end
|
56
14
|
|
57
|
-
def self.parse_json_manifest(
|
15
|
+
def self.parse_json_manifest(file_contents)
|
16
|
+
manifest = JSON.parse file_contents
|
58
17
|
map_dependencies(manifest, 'dependencies', 'runtime')
|
59
18
|
end
|
60
19
|
|
61
|
-
def self.parse_json_lock(
|
20
|
+
def self.parse_json_lock(file_contents)
|
21
|
+
manifest = JSON.parse file_contents
|
62
22
|
manifest.map do |name, requirement|
|
63
23
|
{
|
64
24
|
name: name,
|
@@ -6,70 +6,65 @@ module Bibliothecary
|
|
6
6
|
class Go
|
7
7
|
include Bibliothecary::Analyser
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
parse_glide_yaml
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
json = JSON.parse file_contents
|
21
|
-
parse_godep_json(json)
|
22
|
-
elsif filename.match(/^vendor\/manifest$/)
|
23
|
-
file_contents = File.open(path).read
|
24
|
-
json = JSON.parse file_contents
|
25
|
-
parse_gb_manifest(json)
|
26
|
-
else
|
27
|
-
[]
|
28
|
-
end
|
9
|
+
GPM_REGEXP = /^(.+)\s+(.+)$/
|
10
|
+
|
11
|
+
def self.mapping
|
12
|
+
{
|
13
|
+
/^glide\.yaml$/ => :parse_glide_yaml,
|
14
|
+
/^glide\.lock$/ => :parse_glide_lockfile,
|
15
|
+
/^Godeps\/Godeps\.json$/ => :parse_godep_json,
|
16
|
+
/^Godeps$/i => :parse_gpm,
|
17
|
+
/^vendor\/manifest$/ => :parse_gb_manifest,
|
18
|
+
/^vendor\/vendor.json$/ => :parse_govendor
|
19
|
+
}
|
29
20
|
end
|
30
21
|
|
31
|
-
def self.parse_godep_json(
|
32
|
-
manifest.
|
33
|
-
|
34
|
-
name: dependency['ImportPath'],
|
35
|
-
requirement: dependency['Rev'],
|
36
|
-
type: 'runtime'
|
37
|
-
}
|
38
|
-
end
|
22
|
+
def self.parse_godep_json(file_contents)
|
23
|
+
manifest = JSON.parse file_contents
|
24
|
+
map_dependencies(manifest, 'Deps', 'ImportPath', 'Rev', 'runtime')
|
39
25
|
end
|
40
26
|
|
41
|
-
def self.
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
27
|
+
def self.parse_gpm(file_contents)
|
28
|
+
deps = []
|
29
|
+
file_contents.split("\n").each do |line|
|
30
|
+
match = line.gsub(/(\#(.*))/, '').match(GPM_REGEXP)
|
31
|
+
next unless match
|
32
|
+
deps << {
|
33
|
+
name: match[1].strip,
|
34
|
+
requirement: match[2].strip || '*',
|
46
35
|
type: 'runtime'
|
47
36
|
}
|
48
|
-
end + manifest.fetch('devImports',[]).map do |dependency|
|
49
|
-
{
|
50
|
-
name: dependency['package'],
|
51
|
-
requirement: dependency['version'] || '*',
|
52
|
-
type: 'development'
|
53
|
-
}
|
54
37
|
end
|
38
|
+
deps
|
55
39
|
end
|
56
40
|
|
57
|
-
def self.
|
58
|
-
manifest.
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
41
|
+
def self.parse_govendor(file_contents)
|
42
|
+
manifest = JSON.load file_contents
|
43
|
+
map_dependencies(manifest, 'package', 'path', 'revision', 'runtime')
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.parse_glide_yaml(file_contents)
|
47
|
+
manifest = YAML.load file_contents
|
48
|
+
map_dependencies(manifest, 'import', 'package', 'version', 'runtime') +
|
49
|
+
map_dependencies(manifest, 'devImports', 'package', 'version', 'development')
|
65
50
|
end
|
66
51
|
|
67
|
-
def self.
|
68
|
-
manifest.
|
52
|
+
def self.parse_glide_lockfile(file_contents)
|
53
|
+
manifest = YAML.load file_contents
|
54
|
+
map_dependencies(manifest, 'imports', 'name', 'version', 'runtime')
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.parse_gb_manifest(file_contents)
|
58
|
+
manifest = JSON.parse file_contents
|
59
|
+
map_dependencies(manifest, 'dependencies', 'importpath', 'revision', 'runtime')
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.map_dependencies(manifest, attr_name, dep_attr_name, version_attr_name, type)
|
63
|
+
manifest.fetch(attr_name,[]).map do |dependency|
|
69
64
|
{
|
70
|
-
name: dependency[
|
71
|
-
requirement: dependency['
|
72
|
-
type:
|
65
|
+
name: dependency[dep_attr_name],
|
66
|
+
requirement: dependency[version_attr_name] || '*',
|
67
|
+
type: type
|
73
68
|
}
|
74
69
|
end
|
75
70
|
end
|
@@ -5,16 +5,11 @@ module Bibliothecary
|
|
5
5
|
class Hex
|
6
6
|
include Bibliothecary::Analyser
|
7
7
|
|
8
|
-
def self.
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
file_contents = File.open(path).read
|
14
|
-
parse_mix_lock(file_contents)
|
15
|
-
else
|
16
|
-
[]
|
17
|
-
end
|
8
|
+
def self.mapping
|
9
|
+
{
|
10
|
+
/^mix\.exs$/ => :parse_mix,
|
11
|
+
/^mix\.lock$/ => :parse_mix_lock
|
12
|
+
}
|
18
13
|
end
|
19
14
|
|
20
15
|
def self.parse_mix(manifest)
|
@@ -28,8 +23,6 @@ module Bibliothecary
|
|
28
23
|
type: "runtime"
|
29
24
|
}
|
30
25
|
end
|
31
|
-
rescue
|
32
|
-
[]
|
33
26
|
end
|
34
27
|
|
35
28
|
def self.parse_mix_lock(manifest)
|
@@ -43,8 +36,6 @@ module Bibliothecary
|
|
43
36
|
type: "runtime"
|
44
37
|
}
|
45
38
|
end
|
46
|
-
rescue
|
47
|
-
[]
|
48
39
|
end
|
49
40
|
end
|
50
41
|
end
|
@@ -3,13 +3,10 @@ module Bibliothecary
|
|
3
3
|
class Julia
|
4
4
|
include Bibliothecary::Analyser
|
5
5
|
|
6
|
-
def self.
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
else
|
11
|
-
[]
|
12
|
-
end
|
6
|
+
def self.mapping
|
7
|
+
{
|
8
|
+
/^REQUIRE$/i => :parse_require
|
9
|
+
}
|
13
10
|
end
|
14
11
|
|
15
12
|
def self.parse_require(manifest)
|
@@ -5,24 +5,16 @@ module Bibliothecary
|
|
5
5
|
class Maven
|
6
6
|
include Bibliothecary::Analyser
|
7
7
|
|
8
|
-
def self.
|
9
|
-
|
10
|
-
|
11
|
-
xml
|
12
|
-
|
13
|
-
|
14
|
-
file_contents = File.open(path).read
|
15
|
-
xml = Ox.parse file_contents
|
16
|
-
parse_pom_manifest(xml)
|
17
|
-
elsif filename.match(/build.gradle$/i)
|
18
|
-
file_contents = File.open(path).read
|
19
|
-
parse_gradle(file_contents)
|
20
|
-
else
|
21
|
-
[]
|
22
|
-
end
|
8
|
+
def self.mapping
|
9
|
+
{
|
10
|
+
/ivy\.xml$/i => :parse_ivy_manifest,
|
11
|
+
/pom\.xml$/i => :parse_pom_manifest,
|
12
|
+
/build.gradle$/i => :parse_gradle
|
13
|
+
}
|
23
14
|
end
|
24
15
|
|
25
|
-
def self.parse_ivy_manifest(
|
16
|
+
def self.parse_ivy_manifest(file_contents)
|
17
|
+
manifest = Ox.parse file_contents
|
26
18
|
manifest.dependencies.locate('dependency').map do |dependency|
|
27
19
|
attrs = dependency.attributes
|
28
20
|
{
|
@@ -33,7 +25,8 @@ module Bibliothecary
|
|
33
25
|
end
|
34
26
|
end
|
35
27
|
|
36
|
-
def self.parse_pom_manifest(
|
28
|
+
def self.parse_pom_manifest(file_contents)
|
29
|
+
manifest = Ox.parse file_contents
|
37
30
|
if manifest.respond_to?('project')
|
38
31
|
xml = manifest.project
|
39
32
|
else
|
@@ -70,7 +63,8 @@ module Bibliothecary
|
|
70
63
|
field = dependency.locate(name).first
|
71
64
|
return nil if field.nil?
|
72
65
|
value = field.nodes.first
|
73
|
-
|
66
|
+
match = value.match(/^\$\{(.+)\}/)
|
67
|
+
if match
|
74
68
|
prop_field = xml.properties.locate(match[1]).first
|
75
69
|
if prop_field
|
76
70
|
return prop_field.nodes.first
|
@@ -5,17 +5,14 @@ module Bibliothecary
|
|
5
5
|
class Meteor
|
6
6
|
include Bibliothecary::Analyser
|
7
7
|
|
8
|
-
def self.
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
parse_manifest(json)
|
13
|
-
else
|
14
|
-
[]
|
15
|
-
end
|
8
|
+
def self.mapping
|
9
|
+
{
|
10
|
+
/^versions\.json$/ => :parse_manifest
|
11
|
+
}
|
16
12
|
end
|
17
13
|
|
18
|
-
def self.parse_manifest(
|
14
|
+
def self.parse_manifest(file_contents)
|
15
|
+
manifest = JSON.parse(file_contents)
|
19
16
|
map_dependencies(manifest, 'dependencies', 'runtime')
|
20
17
|
end
|
21
18
|
|
@@ -5,21 +5,16 @@ module Bibliothecary
|
|
5
5
|
class NPM
|
6
6
|
include Bibliothecary::Analyser
|
7
7
|
|
8
|
-
def self.
|
9
|
-
|
10
|
-
|
11
|
-
json
|
12
|
-
|
13
|
-
|
14
|
-
file_contents = File.open(path).read
|
15
|
-
json = JSON.parse(file_contents)
|
16
|
-
parse_shrinkwrap(json)
|
17
|
-
else
|
18
|
-
[]
|
19
|
-
end
|
8
|
+
def self.mapping
|
9
|
+
{
|
10
|
+
/^package\.json$/ => :parse_manifest,
|
11
|
+
/^npm-shrinkwrap\.json$/ => :parse_shrinkwrap,
|
12
|
+
/^yarn\.lock$/ => :parse_yarn_lock
|
13
|
+
}
|
20
14
|
end
|
21
15
|
|
22
|
-
def self.parse_shrinkwrap(
|
16
|
+
def self.parse_shrinkwrap(file_contents)
|
17
|
+
manifest = JSON.parse(file_contents)
|
23
18
|
manifest.fetch('dependencies',[]).map do |name, requirement|
|
24
19
|
{
|
25
20
|
name: name,
|
@@ -29,11 +24,17 @@ module Bibliothecary
|
|
29
24
|
end
|
30
25
|
end
|
31
26
|
|
32
|
-
def self.parse_manifest(
|
27
|
+
def self.parse_manifest(file_contents)
|
28
|
+
manifest = JSON.parse(file_contents)
|
33
29
|
map_dependencies(manifest, 'dependencies', 'runtime') +
|
34
30
|
map_dependencies(manifest, 'devDependencies', 'development')
|
35
31
|
end
|
36
32
|
|
33
|
+
def self.parse_yarn_lock(file_contents)
|
34
|
+
response = Typhoeus.post("https://yarn-parser.herokuapp.com/parse", body: file_contents)
|
35
|
+
JSON.parse(response.body)
|
36
|
+
end
|
37
|
+
|
37
38
|
def self.map_dependencies(hash, key, type)
|
38
39
|
hash.fetch(key,[]).map do |name, requirement|
|
39
40
|
{
|
@@ -6,32 +6,18 @@ module Bibliothecary
|
|
6
6
|
class Nuget
|
7
7
|
include Bibliothecary::Analyser
|
8
8
|
|
9
|
-
def self.
|
10
|
-
|
11
|
-
|
12
|
-
json
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
parse_project_lock_json(json)
|
18
|
-
elsif filename.match(/packages\.config$/)
|
19
|
-
file_contents = File.open(path).read
|
20
|
-
xml = Ox.parse file_contents
|
21
|
-
parse_packages_config(xml)
|
22
|
-
elsif filename.match(/^[A-Za-z0-9_-]+\.nuspec$/)
|
23
|
-
file_contents = File.open(path).read
|
24
|
-
xml = Ox.parse file_contents
|
25
|
-
parse_nuspec(xml)
|
26
|
-
elsif filename.match(/paket\.lock$/)
|
27
|
-
file_contents = File.open(path).read
|
28
|
-
parse_paket_lock(file_contents.split("\n"))
|
29
|
-
else
|
30
|
-
[]
|
31
|
-
end
|
9
|
+
def self.mapping
|
10
|
+
{
|
11
|
+
/Project\.json$/ => :parse_project_json,
|
12
|
+
/Project\.lock\.json$/ => :parse_project_lock_json,
|
13
|
+
/packages\.config$/ => :parse_packages_config,
|
14
|
+
/^[A-Za-z0-9_-]+\.nuspec$/ => :parse_nuspec,
|
15
|
+
/paket\.lock$/ => :parse_paket_lock
|
16
|
+
}
|
32
17
|
end
|
33
18
|
|
34
|
-
def self.parse_project_json(
|
19
|
+
def self.parse_project_json(file_contents)
|
20
|
+
manifest = JSON.parse file_contents
|
35
21
|
manifest.fetch('dependencies',[]).map do |name, requirement|
|
36
22
|
{
|
37
23
|
name: name,
|
@@ -41,7 +27,8 @@ module Bibliothecary
|
|
41
27
|
end
|
42
28
|
end
|
43
29
|
|
44
|
-
def self.parse_project_lock_json(
|
30
|
+
def self.parse_project_lock_json(file_contents)
|
31
|
+
manifest = JSON.parse file_contents
|
45
32
|
manifest.fetch('libraries',[]).map do |name, _requirement|
|
46
33
|
dep = name.split('/')
|
47
34
|
{
|
@@ -52,7 +39,8 @@ module Bibliothecary
|
|
52
39
|
end
|
53
40
|
end
|
54
41
|
|
55
|
-
def self.parse_packages_config(
|
42
|
+
def self.parse_packages_config(file_contents)
|
43
|
+
manifest = Ox.parse file_contents
|
56
44
|
manifest.packages.locate('package').map do |dependency|
|
57
45
|
{
|
58
46
|
name: dependency.id,
|
@@ -62,7 +50,8 @@ module Bibliothecary
|
|
62
50
|
end
|
63
51
|
end
|
64
52
|
|
65
|
-
def self.parse_nuspec(
|
53
|
+
def self.parse_nuspec(file_contents)
|
54
|
+
manifest = Ox.parse file_contents
|
66
55
|
manifest.package.metadata.dependencies.locate('dependency').map do |dependency|
|
67
56
|
{
|
68
57
|
name: dependency.id,
|
@@ -72,7 +61,8 @@ module Bibliothecary
|
|
72
61
|
end
|
73
62
|
end
|
74
63
|
|
75
|
-
def self.parse_paket_lock(
|
64
|
+
def self.parse_paket_lock(file_contents)
|
65
|
+
lines = file_contents.split("\n")
|
76
66
|
package_version_re = /\s+(?<name>\S+)\s\((?<version>\d+\.\d+[\.\d+[\.\d+]*]*)\)/
|
77
67
|
packages = lines.select { |line| package_version_re.match(line) }.map { |line| package_version_re.match(line) }.map do |match|
|
78
68
|
{
|