bibliothecary 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -2
  3. data/Gemfile +0 -2
  4. data/bibliothecary.gemspec +1 -1
  5. data/lib/bibliothecary.rb +5 -20
  6. data/lib/bibliothecary/parsers/bower.rb +46 -0
  7. data/lib/bibliothecary/parsers/cargo.rb +71 -0
  8. data/lib/bibliothecary/{carthage.rb → parsers/carthage.rb} +0 -0
  9. data/lib/bibliothecary/{clojars.rb → parsers/clojars.rb} +0 -0
  10. data/lib/bibliothecary/parsers/cocoapods.rb +98 -0
  11. data/lib/bibliothecary/parsers/cpan.rb +73 -0
  12. data/lib/bibliothecary/{dub.rb → parsers/dub.rb} +0 -0
  13. data/lib/bibliothecary/{elm.rb → parsers/elm.rb} +0 -0
  14. data/lib/bibliothecary/{go.rb → parsers/go.rb} +0 -0
  15. data/lib/bibliothecary/{hex.rb → parsers/hex.rb} +0 -0
  16. data/lib/bibliothecary/{julia.rb → parsers/julia.rb} +0 -0
  17. data/lib/bibliothecary/{maven.rb → parsers/maven.rb} +0 -0
  18. data/lib/bibliothecary/parsers/meteor.rb +45 -0
  19. data/lib/bibliothecary/parsers/npm.rb +76 -0
  20. data/lib/bibliothecary/{nuget.rb → parsers/nuget.rb} +0 -0
  21. data/lib/bibliothecary/parsers/packagist.rb +76 -0
  22. data/lib/bibliothecary/parsers/pub.rb +78 -0
  23. data/lib/bibliothecary/{pypi.rb → parsers/pypi.rb} +0 -0
  24. data/lib/bibliothecary/parsers/rubygems.rb +96 -0
  25. data/lib/bibliothecary/version.rb +1 -1
  26. metadata +22 -22
  27. data/lib/bibliothecary/bower.rb +0 -33
  28. data/lib/bibliothecary/cargo.rb +0 -56
  29. data/lib/bibliothecary/cocoapods.rb +0 -78
  30. data/lib/bibliothecary/cpan.rb +0 -57
  31. data/lib/bibliothecary/meteor.rb +0 -32
  32. data/lib/bibliothecary/npm.rb +0 -61
  33. data/lib/bibliothecary/packagist.rb +0 -61
  34. data/lib/bibliothecary/pub.rb +0 -63
  35. data/lib/bibliothecary/rubygems.rb +0 -79
@@ -1,57 +0,0 @@
1
- require 'yaml'
2
- require 'json'
3
-
4
- module Bibliothecary
5
- class CPAN
6
- def self.analyse(folder_path, file_list)
7
- [analyse_json(folder_path, file_list),
8
- analyse_yaml(folder_path, file_list)]
9
- end
10
-
11
- def self.analyse_json(folder_path, file_list)
12
- path = file_list.find{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/^META\.json$/i) }
13
- return unless path
14
-
15
- manifest = JSON.parse File.open(path).read
16
-
17
- {
18
- platform: 'cpan',
19
- path: path,
20
- dependencies: parse_json_manifest(manifest)
21
- }
22
- end
23
-
24
- def self.analyse_yaml(folder_path, file_list)
25
- path = file_list.find{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/^META\.yml$/i) }
26
- return unless path
27
-
28
- manifest = YAML.load File.open(path).read
29
-
30
- {
31
- platform: 'cpan',
32
- path: path,
33
- dependencies: parse_yaml_manifest(manifest)
34
- }
35
- end
36
-
37
- def self.parse_json_manifest(manifest)
38
- manifest['prereqs'].map do |group, deps|
39
- map_dependencies(deps, 'requires', 'runtime')
40
- end.flatten
41
- end
42
-
43
- def self.parse_yaml_manifest(manifest)
44
- map_dependencies(manifest, 'requires', 'runtime')
45
- end
46
-
47
- def self.map_dependencies(hash, key, type)
48
- hash.fetch(key,[]).map do |name, requirement|
49
- {
50
- name: name,
51
- requirement: requirement,
52
- type: type
53
- }
54
- end
55
- end
56
- end
57
- end
@@ -1,32 +0,0 @@
1
- require 'json'
2
-
3
- module Bibliothecary
4
- class Meteor
5
- def self.analyse(folder_path, file_list)
6
- path = file_list.find{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/^versions\.json$/) }
7
- return unless path
8
-
9
- manifest = JSON.parse File.open(path).read
10
-
11
- {
12
- platform: 'meteor',
13
- path: path,
14
- dependencies: parse_manifest(manifest)
15
- }
16
- end
17
-
18
- def self.parse_manifest(manifest)
19
- map_dependencies(manifest, 'dependencies', 'runtime')
20
- end
21
-
22
- def self.map_dependencies(hash, key, type)
23
- hash.fetch(key,[]).map do |name, requirement|
24
- {
25
- name: name,
26
- requirement: requirement,
27
- type: type
28
- }
29
- end
30
- end
31
- end
32
- end
@@ -1,61 +0,0 @@
1
- require 'json'
2
-
3
- module Bibliothecary
4
- class NPM
5
- def self.analyse(folder_path, file_list)
6
- [analyse_package_json(folder_path, file_list),
7
- analyse_shrinkwrap(folder_path, file_list)]
8
- end
9
-
10
- def self.analyse_package_json(folder_path, file_list)
11
- path = file_list.find{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/^package\.json$/) }
12
- return unless path
13
-
14
- manifest = JSON.parse File.open(path).read
15
-
16
- {
17
- platform: 'npm',
18
- path: path,
19
- dependencies: parse_manifest(manifest)
20
- }
21
- end
22
-
23
- def self.analyse_shrinkwrap(folder_path, file_list)
24
- path = file_list.find{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/^npm-shrinkwrap\.json$/) }
25
- return unless path
26
-
27
- manifest = JSON.parse File.open(path).read
28
-
29
- {
30
- platform: 'npm',
31
- path: path,
32
- dependencies: parse_shrinkwrap(manifest)
33
- }
34
- end
35
-
36
- def self.parse_shrinkwrap(manifest)
37
- manifest.fetch('dependencies',[]).map do |name, requirement|
38
- {
39
- name: name,
40
- requirement: requirement["version"],
41
- type: 'runtime'
42
- }
43
- end
44
- end
45
-
46
- def self.parse_manifest(manifest)
47
- map_dependencies(manifest, 'dependencies', 'runtime') +
48
- map_dependencies(manifest, 'devDependencies', 'development')
49
- end
50
-
51
- def self.map_dependencies(hash, key, type)
52
- hash.fetch(key,[]).map do |name, requirement|
53
- {
54
- name: name,
55
- requirement: requirement,
56
- type: type
57
- }
58
- end
59
- end
60
- end
61
- end
@@ -1,61 +0,0 @@
1
- require 'json'
2
-
3
- module Bibliothecary
4
- class Packagist
5
- def self.analyse(folder_path, file_list)
6
- [analyse_composer_json(folder_path, file_list),
7
- analyse_composer_lock(folder_path, file_list)]
8
- end
9
-
10
- def self.analyse_composer_json(folder_path, file_list)
11
- path = file_list.find{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/^composer\.json$/) }
12
- return unless path
13
-
14
- manifest = JSON.parse File.open(path).read
15
-
16
- {
17
- platform: 'Packagist',
18
- path: path,
19
- dependencies: parse_manifest(manifest)
20
- }
21
- end
22
-
23
- def self.analyse_composer_lock(folder_path, file_list)
24
- path = file_list.find{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/^composer\.lock$/) }
25
- return unless path
26
-
27
- manifest = JSON.parse File.open(path).read
28
-
29
- {
30
- platform: 'Packagist',
31
- path: path,
32
- dependencies: parse_lockfile(manifest)
33
- }
34
- end
35
-
36
- def self.parse_lockfile(manifest)
37
- manifest.fetch('packages',[]).map do |dependency|
38
- {
39
- name: dependency["name"],
40
- requirement: dependency["version"],
41
- type: 'runtime'
42
- }
43
- end
44
- end
45
-
46
- def self.parse_manifest(manifest)
47
- map_dependencies(manifest, 'require', 'runtime') +
48
- map_dependencies(manifest, 'require-dev', 'development')
49
- end
50
-
51
- def self.map_dependencies(hash, key, type)
52
- hash.fetch(key,[]).map do |name, requirement|
53
- {
54
- name: name,
55
- requirement: requirement,
56
- type: type
57
- }
58
- end
59
- end
60
- end
61
- end
@@ -1,63 +0,0 @@
1
- require 'yaml'
2
-
3
- module Bibliothecary
4
- class Pub
5
- def self.analyse(folder_path, file_list)
6
- [
7
- analyse_yaml(folder_path, file_list),
8
- analyse_lockfile(folder_path, file_list)
9
- ]
10
- end
11
-
12
- def self.analyse_yaml(folder_path, file_list)
13
- path = file_list.find{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/^pubspec\.yaml$/i) }
14
- return unless path
15
-
16
- manifest = YAML.load File.open(path).read
17
-
18
- {
19
- platform: 'Pub',
20
- path: path,
21
- dependencies: parse_yaml_manifest(manifest)
22
- }
23
- end
24
-
25
- def self.analyse_lockfile(folder_path, file_list)
26
- path = file_list.find{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/^pubspec\.lock$/i) }
27
- return unless path
28
-
29
- manifest = YAML.load File.open(path).read
30
-
31
- {
32
- platform: 'Pub',
33
- path: path,
34
- dependencies: parse_yaml_manifest(manifest)
35
- }
36
- end
37
-
38
- def self.parse_yaml_manifest(manifest)
39
- map_dependencies(manifest, 'dependencies', 'runtime') +
40
- map_dependencies(manifest, 'dev_dependencies', 'development')
41
- end
42
-
43
- def self.parse_yaml_lockfile(manifest)
44
- manifest.fetch('packages', []).map do |name, dep|
45
- {
46
- name: name,
47
- requirement: dep['version'],
48
- type: type
49
- }
50
- end
51
- end
52
-
53
- def self.map_dependencies(hash, key, type)
54
- hash.fetch(key,[]).map do |name, requirement|
55
- {
56
- name: name,
57
- requirement: requirement,
58
- type: type
59
- }
60
- end
61
- end
62
- end
63
- end
@@ -1,79 +0,0 @@
1
- require 'gemnasium/parser'
2
-
3
- module Bibliothecary
4
- class Rubygems
5
- NAME_VERSION = '(?! )(.*?)(?: \(([^-]*)(?:-(.*))?\))?'.freeze
6
- NAME_VERSION_4 = /^ {4}#{NAME_VERSION}$/
7
-
8
- def self.analyse(folder_path, file_list)
9
- [
10
- analyse_gemfile(folder_path, file_list),
11
- analyse_gemspec(folder_path, file_list),
12
- analyse_gemfile_lock(folder_path, file_list)
13
- ]
14
- end
15
-
16
- def self.analyse_gemfile(folder_path, file_list)
17
- path = file_list.find{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/^Gemfile$|^gems\.rb$/) }
18
- return unless path
19
-
20
- manifest = Gemnasium::Parser.send(:gemfile, File.open(path).read)
21
-
22
- {
23
- platform: 'Rubygems',
24
- path: path,
25
- dependencies: parse_manifest(manifest)
26
- }
27
- end
28
-
29
- def self.analyse_gemspec(folder_path, file_list)
30
- path = file_list.find{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/^[A-Za-z0-9_-]+\.gemspec$/) }
31
- return unless path
32
-
33
- manifest = Gemnasium::Parser.send(:gemspec, File.open(path).read)
34
-
35
- {
36
- platform: 'Rubygems',
37
- path: path,
38
- dependencies: parse_manifest(manifest)
39
- }
40
- end
41
-
42
- def self.analyse_gemfile_lock(folder_path, file_list)
43
- path = file_list.find{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/^Gemfile\.lock$|^gems\.locked$/) }
44
- return unless path
45
-
46
- manifest = File.open(path).read
47
-
48
- {
49
- platform: 'Rubygems',
50
- path: path,
51
- dependencies: parse_gemfile_lock(manifest)
52
- }
53
- end
54
-
55
- def self.parse_gemfile_lock(manifest)
56
- manifest.split("\n").map do |line|
57
- match = line.match(NAME_VERSION_4)
58
- next unless match
59
- name = match[1]
60
- version = match[2].gsub(/\(|\)/,'')
61
- {
62
- name: name,
63
- requirement: version,
64
- type: 'runtime'
65
- }
66
- end.compact
67
- end
68
-
69
- def self.parse_manifest(manifest)
70
- manifest.dependencies.inject([]) do |deps, dep|
71
- deps.push({
72
- name: dep.name,
73
- requirement: dep.requirement.to_s,
74
- type: dep.type
75
- })
76
- end.uniq
77
- end
78
- end
79
- end