bibliothecary 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bibliothecary.gemspec +1 -0
- data/lib/bibliothecary/parsers/clojars.rb +51 -1
- data/lib/bibliothecary/parsers/go.rb +0 -4
- data/lib/bibliothecary/parsers/hex.rb +76 -2
- data/lib/bibliothecary/version.rb +1 -1
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eddfd25683329b1ec4fab2722149b748d675665a
|
4
|
+
data.tar.gz: 926c0cd2605b2ac595806600e3041e2f487d7c0e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 60aa852cfd3ba7419db049a61d77a5db16776a05b31b4fbcf6376d58abc08b93d38c53047ac5517e00620aa65bdebc064a2847f57797a28544d922671ca2074c
|
7
|
+
data.tar.gz: 60f66903eea1682d1a0ad3308a3cbf251691852d8ae021d390849f6b53af0a74475b6af292d10e8ff58f56d20a01543d2232170b24929c7a51ca7e1e77e33d56
|
data/bibliothecary.gemspec
CHANGED
@@ -22,6 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_dependency "librariesio-gem-parser"
|
23
23
|
spec.add_dependency "rogdl"
|
24
24
|
spec.add_dependency "ox"
|
25
|
+
spec.add_dependency "typhoeus"
|
25
26
|
|
26
27
|
spec.add_development_dependency "bundler", "~> 1.11"
|
27
28
|
spec.add_development_dependency "rake", "~> 11.0"
|
@@ -1 +1,51 @@
|
|
1
|
-
|
1
|
+
require 'json'
|
2
|
+
require 'typhoeus'
|
3
|
+
|
4
|
+
module Bibliothecary
|
5
|
+
module Parsers
|
6
|
+
class Clojars
|
7
|
+
PLATFORM_NAME = 'clojars'
|
8
|
+
|
9
|
+
def self.parse(filename, file_contents)
|
10
|
+
if filename.match(/^project\.clj$/)
|
11
|
+
parse_manifest(file_contents)
|
12
|
+
else
|
13
|
+
[]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.analyse(folder_path, file_list)
|
18
|
+
[analyse_manifest(folder_path, file_list)]
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.analyse_manifest(folder_path, file_list)
|
22
|
+
path = file_list.find{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/^project\.clj$/) }
|
23
|
+
return unless path
|
24
|
+
|
25
|
+
manifest = JSON.parse File.open(path).read
|
26
|
+
|
27
|
+
{
|
28
|
+
platform: PLATFORM_NAME,
|
29
|
+
path: path,
|
30
|
+
dependencies: parse_json_manifest(manifest)
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.parse_manifest(manifest)
|
35
|
+
response = Typhoeus.post("https://clojars-json.herokuapp.com/project.clj", body: manifest)
|
36
|
+
json = JSON.parse response.body
|
37
|
+
index = json.index("dependencies")
|
38
|
+
|
39
|
+
return [] unless index;
|
40
|
+
dependencies = json[index + 1]
|
41
|
+
dependencies.map do |dependency|
|
42
|
+
{
|
43
|
+
name: dependency[0],
|
44
|
+
version: dependency[1],
|
45
|
+
type: "runtime"
|
46
|
+
}
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -68,7 +68,6 @@ module Bibliothecary
|
|
68
68
|
|
69
69
|
def self.parse_godep_json(manifest)
|
70
70
|
manifest.fetch('Deps',[]).map do |dependency|
|
71
|
-
p dependency
|
72
71
|
{
|
73
72
|
name: dependency['ImportPath'],
|
74
73
|
requirement: dependency['Rev'],
|
@@ -79,14 +78,12 @@ module Bibliothecary
|
|
79
78
|
|
80
79
|
def self.parse_glide_yaml(manifest)
|
81
80
|
manifest.fetch('import',[]).map do |dependency|
|
82
|
-
p dependency
|
83
81
|
{
|
84
82
|
name: dependency['package'],
|
85
83
|
requirement: dependency['version'] || '*',
|
86
84
|
type: 'runtime'
|
87
85
|
}
|
88
86
|
end + manifest.fetch('devImports',[]).map do |dependency|
|
89
|
-
p dependency
|
90
87
|
{
|
91
88
|
name: dependency['package'],
|
92
89
|
requirement: dependency['version'] || '*',
|
@@ -97,7 +94,6 @@ module Bibliothecary
|
|
97
94
|
|
98
95
|
def self.parse_glide_lockfile(manifest)
|
99
96
|
manifest.fetch('imports',[]).map do |dependency|
|
100
|
-
p dependency
|
101
97
|
{
|
102
98
|
name: dependency['name'],
|
103
99
|
requirement: dependency['version'] || '*',
|
@@ -1,2 +1,76 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module Bibliothecary
|
4
|
+
module Parsers
|
5
|
+
class Hex
|
6
|
+
PLATFORM_NAME = 'hex'
|
7
|
+
|
8
|
+
def self.parse(filename, file_contents)
|
9
|
+
if filename.match(/^mix\.exs$/)
|
10
|
+
parse_mix(file_contents)
|
11
|
+
elsif filename.match(/^mix\.lock$/)
|
12
|
+
parse_mix_lock(file_contents)
|
13
|
+
else
|
14
|
+
[]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.analyse(folder_path, file_list)
|
19
|
+
[analyse_mix(folder_path, file_list),
|
20
|
+
analyse_mix_lock(folder_path, file_list)]
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.analyse_mix(folder_path, file_list)
|
24
|
+
path = file_list.find{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/^mix\.exs$/) }
|
25
|
+
return unless path
|
26
|
+
|
27
|
+
manifest = File.open(path).read
|
28
|
+
|
29
|
+
{
|
30
|
+
platform: PLATFORM_NAME,
|
31
|
+
path: path,
|
32
|
+
dependencies: parse_mix(manifest)
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.analyse_mix_lock(folder_path, file_list)
|
37
|
+
path = file_list.find{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/^mix\.lock$/) }
|
38
|
+
return unless path
|
39
|
+
|
40
|
+
manifest = File.open(path).read
|
41
|
+
|
42
|
+
{
|
43
|
+
platform: PLATFORM_NAME,
|
44
|
+
path: path,
|
45
|
+
dependencies: parse_mix_lock(manifest)
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.parse_mix(manifest)
|
50
|
+
response = Typhoeus.post("https://mix-deps-json.herokuapp.com/", body: manifest)
|
51
|
+
json = JSON.parse response.body
|
52
|
+
|
53
|
+
json.map do |name, version|
|
54
|
+
{
|
55
|
+
name: name,
|
56
|
+
version: version,
|
57
|
+
type: "runtime"
|
58
|
+
}
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.parse_mix_lock(manifest)
|
63
|
+
response = Typhoeus.post("https://mix-deps-json.herokuapp.com/lock", body: manifest)
|
64
|
+
json = JSON.parse response.body
|
65
|
+
|
66
|
+
json.map do |name, info|
|
67
|
+
{
|
68
|
+
name: name,
|
69
|
+
version: info['version'],
|
70
|
+
type: "runtime"
|
71
|
+
}
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
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.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Nesbitt
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: typhoeus
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: bundler
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|