bibliothecary 5.0.1 → 5.0.2

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
  SHA1:
3
- metadata.gz: 61ed3368f5f307a5256c24b57a7bcfddaa833a41
4
- data.tar.gz: 0fa900c8b7b74c7f30ba98c3fd54820d6b50ecdd
3
+ metadata.gz: 7a73ecad5bf0a411b2eab208e5da2fe8b9cb8c36
4
+ data.tar.gz: 0869502853eaea04bdaed75aaad6409ae5c03db2
5
5
  SHA512:
6
- metadata.gz: ce6240a075a03278d30d6b4ff9800a60ce0f6188dd890a464b15e0c9ef065aef35c00c8ca2d8716fd0e85fcea655fd3e225f354935856af3799ef8d7ff8d5e4d
7
- data.tar.gz: 8fc043edc61327d02ca0e7caeccec6ef1a81ad595160a9e7c9c67a1660b8e4c4cdf1ee477c4c21dcb54c3e7212fa8429e8e96918249fb49f92da97e5933cb01a
6
+ metadata.gz: 2ae3763a2b36c3496ec8208f12d2315047649a7970d4f55df8842d2f7f1d9016c8d2d86984bc1172642e22eb941b014833416cba107c55dd1e17d89af6ade1e0
7
+ data.tar.gz: 0b6006e9ce5aad4d2a4d5c1d707cd98b5e1d885f2d01c6143d5a03bad60d60c5a50c860e369322c75b14a0a72402d84f143891b60e3ffbf0b5e33efc8a3bf4c8
data/README.md CHANGED
@@ -69,6 +69,8 @@ Bibliothecary.analyse('./')
69
69
  - req*.pip
70
70
  - requirements/*.txt
71
71
  - requirements/*.pip
72
+ - Pipfile
73
+ - Pipfile.lock
72
74
  - Nuget
73
75
  - packages.config
74
76
  - Project.json
@@ -32,7 +32,7 @@ module Bibliothecary
32
32
  def analyse_contents(filename, contents)
33
33
  begin
34
34
  dependencies = parse_file(filename, contents)
35
- if dependencies.any?
35
+ if dependencies && dependencies.any?
36
36
  {
37
37
  platform: platform_name,
38
38
  path: filename,
@@ -12,11 +12,65 @@ module Bibliothecary
12
12
  parse_requirements_txt(contents)
13
13
  elsif filename.match(/setup\.py$/)
14
14
  parse_setup_py(contents)
15
+ elsif filename.match(/^Pipfile$/)
16
+ parse_pipfile(contents)
17
+ elsif filename.match(/^Pipfile\.lock$/)
18
+ parse_pipfile_lock(contents)
15
19
  end
16
20
  end
17
21
 
18
22
  def self.match?(filename)
19
- is_requirements_file(filename) || filename.match(/setup\.py$/)
23
+ is_requirements_file(filename) ||
24
+ filename.match(/setup\.py$/) ||
25
+ filename.match(/Pipfile$/) ||
26
+ filename.match(/Pipfile\.lock$/)
27
+ end
28
+
29
+ def self.parse_pipfile(file_contents)
30
+ manifest = TOML.parse(file_contents)
31
+ map_dependencies(manifest['packages'], 'runtime') + map_dependencies(manifest['dev-packages'], 'develop')
32
+ end
33
+
34
+ def self.map_dependencies(packages, type)
35
+ return [] unless packages
36
+ packages.map do |name, info|
37
+ {
38
+ name: name,
39
+ requirement: map_requirements(info),
40
+ type: type
41
+ }
42
+ end
43
+ end
44
+
45
+ def self.map_requirements(info)
46
+ if info.is_a?(Hash)
47
+ if info['version']
48
+ info['version']
49
+ elsif info['git']
50
+ info['git'] + '#' + info['ref']
51
+ else
52
+ '*'
53
+ end
54
+ else
55
+ info || '*'
56
+ end
57
+ end
58
+
59
+ def self.parse_pipfile_lock(file_contents)
60
+ manifest = JSON.parse(file_contents)
61
+ deps = []
62
+ manifest.each do |group, dependencies|
63
+ next if group == "_meta"
64
+ group = 'runtime' if group == 'default'
65
+ dependencies.each do |name, info|
66
+ deps << {
67
+ name: name,
68
+ requirement: map_requirements(info),
69
+ type: group
70
+ }
71
+ end
72
+ end
73
+ deps
20
74
  end
21
75
 
22
76
  def self.parse_setup_py(manifest)
@@ -1,3 +1,3 @@
1
1
  module Bibliothecary
2
- VERSION = "5.0.1"
2
+ VERSION = "5.0.2"
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: 5.0.1
4
+ version: 5.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Nesbitt
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-02-20 00:00:00.000000000 Z
11
+ date: 2017-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: toml-rb