bibliothecary 6.3.0 → 6.3.1

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
  SHA256:
3
- metadata.gz: 4beec9dee5f3223d4f87b7b1132cc069dc7e5d845492c94d7f7e32ffa865e53b
4
- data.tar.gz: d63c47bd039937d9d9aeedac65930efd230edeb60c0107c2470a71c87bd08a0c
3
+ metadata.gz: ba88fac4e7fbc938bf270504f1b41787f314105f237bb1e4e080e5ad82379aef
4
+ data.tar.gz: 28de14e318ae6684074ac38e8a7b2f1fb57fa83d21a97e7908d6afe110bb5d22
5
5
  SHA512:
6
- metadata.gz: d2153d34b8a178fd5149ead8c9497d6444c89dd6d39b03bd4581aca72042d7a746020ff4f0a0da17bc7a7a9f35c8484ceb5f360a5a0a76c7611401e6f7f45344
7
- data.tar.gz: 78e365f170d21c0f8c46e42041916950f423526e74795b75c1db3c9d86f6acb701db99e649dc0d8dcfe81471047ee6776b291088e351e95fb4701123d2fec184
6
+ metadata.gz: a07ec3aeb787fe83e7a4d415f83b5aeefe1649eb590a320a48a90053b26b5bf215e6649799bc5792e9e20e5e6fc920bddd0f43c3e8f08111d34baf2695f64ed9
7
+ data.tar.gz: 3da7fe10d6c6e036091a82e84a1cbfa80ef9ee58f37289629fe8076b1c49da38a7dc40d03dfe7b56b3e1a12327dc714bf220576a2ca6b072ab66a7934bf06c0d
@@ -0,0 +1 @@
1
+ 2.5.1
@@ -1,7 +1,7 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 2.4.2
4
- - 2.5.0
4
+ - 2.5.1
5
5
  cache: bundler
6
6
  before_install:
7
7
  - gem update --system
data/README.md CHANGED
@@ -3,9 +3,6 @@
3
3
  Dependency manifest parsing library for https://libraries.io
4
4
 
5
5
  [![Build Status](https://travis-ci.org/librariesio/bibliothecary.svg?branch=master)](https://travis-ci.org/librariesio/bibliothecary)
6
- [![Code Climate](https://img.shields.io/codeclimate/github/librariesio/bibliothecary.svg?style=flat)](https://codeclimate.com/github/librariesio/bibliothecary)
7
- [![Test Coverage](https://img.shields.io/codeclimate/coverage/github/librariesio/bibliothecary.svg?style=flat)](https://codeclimate.com/github/librariesio/bibliothecary)
8
- [![Code Climate](https://img.shields.io/codeclimate/issues/github/librariesio/bibliothecary.svg)](https://codeclimate.com/github/librariesio/bibliothecary/issues)
9
6
  [![license](https://img.shields.io/github/license/librariesio/bibliothecary.svg)](https://github.com/librariesio/bibliothecary/blob/master/LICENSE.txt)
10
7
 
11
8
  ## Installation
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_dependency "toml-rb", "~> 1.0"
22
22
  spec.add_dependency "librariesio-gem-parser"
23
- spec.add_dependency "ox"
23
+ spec.add_dependency "ox", ">= 2.8.1"
24
24
  spec.add_dependency "typhoeus"
25
25
  spec.add_dependency "deb_control"
26
26
  spec.add_dependency "sdl4r"
@@ -29,4 +29,6 @@ Gem::Specification.new do |spec|
29
29
  spec.add_development_dependency "bundler", "~> 1.11"
30
30
  spec.add_development_dependency "rake", "~> 12.0"
31
31
  spec.add_development_dependency "rspec", "~> 3.0"
32
+ spec.add_development_dependency "webmock"
33
+ spec.add_development_dependency "vcr"
32
34
  end
@@ -41,13 +41,56 @@ module Bibliothecary
41
41
  end
42
42
  end
43
43
 
44
+ def set_related_paths_field(by_dirname_dest, by_dirname_source)
45
+ by_dirname_dest.each do |dirname, analyses|
46
+ analyses.each do |analysis|
47
+ source_analyses = by_dirname_source[dirname].map { |source_analysis| source_analysis[:path] }
48
+ analysis[:related_paths] = source_analyses.sort
49
+ end
50
+ end
51
+ end
52
+
53
+ def add_related_paths(analyses)
54
+ analyses.each do |analysis|
55
+ analysis[:related_paths] = []
56
+ end
57
+
58
+ # associate manifests and lockfiles in the same directory;
59
+
60
+ # note that right now we're in the context of a single
61
+ # package manager, so manifest and lockfile in the
62
+ # same directory is considered proof that they are
63
+ # matched.
64
+
65
+ by_dirname = {
66
+ "manifest" => Hash.new { |h, k| h[k] = [] },
67
+ "lockfile" => Hash.new { |h, k| h[k] = [] }
68
+ }
69
+
70
+ analyses.each do |analysis|
71
+ dirname = File.dirname(analysis[:path])
72
+ by_dirname[analysis[:kind]][dirname].push(analysis)
73
+ end
74
+
75
+ by_dirname["manifest"].each do |_, manifests|
76
+ manifests.delete_if { |manifest| !determine_can_have_lockfile(manifest[:path]) }
77
+ end
78
+
79
+ set_related_paths_field(by_dirname["manifest"], by_dirname["lockfile"])
80
+ set_related_paths_field(by_dirname["lockfile"], by_dirname["manifest"])
81
+ end
82
+
44
83
  def analyse(folder_path, file_list)
45
- file_list.map do |path|
84
+ analyses = file_list.map do |path|
46
85
  filename = path.gsub(folder_path, '').gsub(/^\//, '')
47
86
  next unless match?(filename)
48
87
  contents = File.open(path).read
49
88
  analyse_contents(filename, contents)
50
89
  end.compact
90
+
91
+ add_related_paths(analyses)
92
+
93
+ analyses
51
94
  end
52
95
 
53
96
  def analyse_contents(filename, contents)
@@ -60,8 +103,8 @@ module Bibliothecary
60
103
  kind: determine_kind(filename)
61
104
  }
62
105
  end
63
- rescue
64
- nil
106
+ # rescue
107
+ # nil
65
108
  end
66
109
 
67
110
  def determine_kind(filename)
@@ -73,6 +116,15 @@ module Bibliothecary
73
116
  return []
74
117
  end
75
118
 
119
+ def determine_can_have_lockfile(filename)
120
+ mapping.each do |regex, details|
121
+ if filename.match(regex)
122
+ return details.fetch(:can_have_lockfile, true)
123
+ end
124
+ end
125
+ return true
126
+ end
127
+
76
128
  def parse_ruby_manifest(manifest)
77
129
  manifest.dependencies.inject([]) do |deps, dep|
78
130
  deps.push({
@@ -17,7 +17,8 @@ module Bibliothecary
17
17
  },
18
18
  /(^[A-Za-z0-9_-]+\.podspec$|.*\/[A-Za-z0-9_-]+\.podspec$)/ => {
19
19
  kind: 'manifest',
20
- parser: :parse_podspec
20
+ parser: :parse_podspec,
21
+ can_have_lockfile: false
21
22
  },
22
23
  /(^Podfile\.lock$|.*\/Podfile\.lock$)/ => {
23
24
  kind: 'lockfile',
@@ -25,7 +26,8 @@ module Bibliothecary
25
26
  },
26
27
  /(^[A-Za-z0-9_-]+\.podspec.json$|.*\/[A-Za-z0-9_-]+\.podspec.json$)/ => {
27
28
  kind: 'manifest',
28
- parser: :parse_json_manifest
29
+ parser: :parse_json_manifest,
30
+ can_have_lockfile: false
29
31
  }
30
32
  }
31
33
  end
@@ -6,21 +6,34 @@ module Bibliothecary
6
6
  def self.mapping
7
7
  {
8
8
  /^REQUIRE$|.*\/REQUIRE$/i => {
9
- kind: 'manifest',
9
+ kind: "manifest",
10
10
  parser: :parse_require
11
11
  }
12
12
  }
13
13
  end
14
14
 
15
15
  def self.parse_require(manifest)
16
- manifest.split("\n").map do |line|
17
- match = line.split(/\s/)
18
- {
19
- name: match[0],
20
- requirement: match[1] || '*',
21
- type: 'runtime'
16
+ deps = []
17
+ manifest.split("\n").each do |line|
18
+ next if line.match(/^#/) || line.empty?
19
+ split = line.split(/\s/)
20
+ if line.match(/^@/)
21
+ name = split[1]
22
+ reqs = split[2, split.length].join(" ")
23
+ else
24
+ name = split[0]
25
+ reqs = split[1, split.length].join(" ")
26
+ end
27
+ reqs = "*" if reqs.empty?
28
+ next if name.empty?
29
+
30
+ deps << {
31
+ name: name,
32
+ requirement: reqs,
33
+ type: "runtime"
22
34
  }
23
35
  end
36
+ deps
24
37
  end
25
38
  end
26
39
  end
@@ -11,11 +11,13 @@ module Bibliothecary
11
11
  {
12
12
  /.*require[^\/]*(\/)?[^\/]*\.(txt|pip)$/ => {
13
13
  kind: 'manifest',
14
- parser: :parse_requirements_txt
14
+ parser: :parse_requirements_txt,
15
+ can_have_lockfile: false
15
16
  },
16
17
  /^setup\.py$|.*\/setup.py$/ => {
17
18
  kind: 'manifest',
18
- parser: :parse_setup_py
19
+ parser: :parse_setup_py,
20
+ can_have_lockfile: false
19
21
  },
20
22
  /^Pipfile$|.*\/Pipfile$/ => {
21
23
  kind: 'manifest',
@@ -16,7 +16,8 @@ module Bibliothecary
16
16
  },
17
17
  /^[A-Za-z0-9_-]+\.gemspec$|.*\/[A-Za-z0-9_-]+\.gemspec$/ => {
18
18
  kind: 'manifest',
19
- parser: :parse_gemspec
19
+ parser: :parse_gemspec,
20
+ can_have_lockfile: false
20
21
  },
21
22
  /^Gemfile\.lock$|^gems\.locked$|.*\/gems\.locked$|.*\/Gemfile\.lock$/ => {
22
23
  kind: 'lockfile',
@@ -1,3 +1,3 @@
1
1
  module Bibliothecary
2
- VERSION = "6.3.0"
2
+ VERSION = "6.3.1"
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: 6.3.0
4
+ version: 6.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Nesbitt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-29 00:00:00.000000000 Z
11
+ date: 2018-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: toml-rb
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: 2.8.1
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: 2.8.1
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: typhoeus
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -150,6 +150,34 @@ dependencies:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
152
  version: '3.0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: webmock
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: vcr
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
153
181
  description:
154
182
  email:
155
183
  - andrewnez@gmail.com
@@ -168,6 +196,7 @@ files:
168
196
  - ".gitignore"
169
197
  - ".rspec"
170
198
  - ".rubocop.yml"
199
+ - ".ruby-version"
171
200
  - ".travis.yml"
172
201
  - CODE_OF_CONDUCT.md
173
202
  - Gemfile
@@ -229,7 +258,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
229
258
  version: '0'
230
259
  requirements: []
231
260
  rubyforge_project:
232
- rubygems_version: 2.7.3
261
+ rubygems_version: 2.7.6
233
262
  signing_key:
234
263
  specification_version: 4
235
264
  summary: Find and parse manifests