bibliothecary 6.3.2 → 6.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e4a0567c8ec55a4efdce0ef3582ffb085587a4efcc50b91e3f3596444629d60c
4
- data.tar.gz: 63c5203b34b171ef99ce8d9beac0e05aabc2fcb202c1125a3184a2968ba6faba
3
+ metadata.gz: 35f76a25c41ad5a990e6c6232536f768015703be873a63c852d70369e3ae9295
4
+ data.tar.gz: 7faa006c8ff306dc560d57324cf9ad8d5798030aab058bb7d513b3a834c9ecc4
5
5
  SHA512:
6
- metadata.gz: 4e68baf27de703a993167504612de962db9ae01b8aa8ab84e2de8556074521076fe7ea27dc0e5596c1188dfd747bb541a31898da5c6ca6f2e40d0af2e7adbd09
7
- data.tar.gz: 25f3d2f9f38bcce1c339851e5b68b1f92f354ecd0b4ea0608f258c69c7a6a0a0376dd4f2e160208c537aa1370aa0298680af6d10c22c4e82c89a14936ed9aa69
6
+ metadata.gz: ecc552df23a5489aa6b430e2626f48b8600032a74a1a8c8f522c3ef9d9b9e39a7e1646d61651374bd50dc26f75ec5c905e638c29c9c7a7ab9670b5adc8792d57
7
+ data.tar.gz: 1a1e7a14eb4e1a75899d3ac319d98367eb9b883d23ea63f312a2405e1076a7d5702fbb35b0755ae864eea2a065fede8ed74749a5a31d7bff31effa835aff60ad
@@ -25,8 +25,8 @@ module Bibliothecary
25
25
  base.extend(ClassMethods)
26
26
  end
27
27
  module ClassMethods
28
- def mapping_entry_match?(regex, details, info)
29
- if info.relative_path.match(regex)
28
+ def mapping_entry_match?(matcher, details, info)
29
+ if matcher.call(info.relative_path)
30
30
  # we only want to load contents if we don't have them already
31
31
  # and there's a content_matcher method to use
32
32
  return true if details[:content_matcher].nil?
@@ -41,8 +41,8 @@ module Bibliothecary
41
41
  end
42
42
 
43
43
  def parse_file(filename, contents)
44
- mapping.each do |regex, details|
45
- if mapping_entry_match?(regex, details, FileInfo.new(nil, filename, contents))
44
+ mapping.each do |matcher, details|
45
+ if mapping_entry_match?(matcher, details, FileInfo.new(nil, filename, contents))
46
46
  begin
47
47
  # The `parser` method should raise an exception if the file is malformed,
48
48
  # should return empty [] if the file is fine but simply doesn't contain
@@ -73,8 +73,8 @@ module Bibliothecary
73
73
  end
74
74
 
75
75
  def match_info?(info)
76
- mapping.any? do |regex, details|
77
- mapping_entry_match?(regex, details, info)
76
+ mapping.any? do |matcher, details|
77
+ mapping_entry_match?(matcher, details, info)
78
78
  end
79
79
  end
80
80
 
@@ -182,8 +182,8 @@ module Bibliothecary
182
182
  end
183
183
 
184
184
  def determine_kind_from_info(info)
185
- mapping.each do |regex, details|
186
- if mapping_entry_match?(regex, details, info)
185
+ mapping.each do |matcher, details|
186
+ if mapping_entry_match?(matcher, details, info)
187
187
  return details[:kind]
188
188
  end
189
189
  end
@@ -197,8 +197,8 @@ module Bibliothecary
197
197
  end
198
198
 
199
199
  def determine_can_have_lockfile_from_info(info)
200
- mapping.each do |regex, details|
201
- if mapping_entry_match?(regex, details, info)
200
+ mapping.each do |matcher, details|
201
+ if mapping_entry_match?(matcher, details, info)
202
202
  return details.fetch(:can_have_lockfile, true)
203
203
  end
204
204
  end
@@ -209,11 +209,39 @@ module Bibliothecary
209
209
  manifest.dependencies.inject([]) do |deps, dep|
210
210
  deps.push({
211
211
  name: dep.name,
212
- requirement: dep.requirement.to_s,
212
+ requirement: dep
213
+ .requirement
214
+ .requirements
215
+ .sort_by(&:last)
216
+ .map { |op, version| "#{op} #{version}" }
217
+ .join(", "),
213
218
  type: dep.type
214
219
  })
215
220
  end.uniq
216
221
  end
222
+
223
+ def match_filename(filename, case_insensitive: false)
224
+ if case_insensitive
225
+ lambda { |path| path.downcase == filename.downcase || path.downcase.end_with?("/" + filename.downcase) }
226
+ else
227
+ lambda { |path| path == filename || path.end_with?("/" + filename) }
228
+ end
229
+ end
230
+
231
+ def match_filenames(*filenames)
232
+ lambda do |path|
233
+ filenames.any? { |f| path == f } ||
234
+ filenames.any? { |f| path.end_with?("/" + f) }
235
+ end
236
+ end
237
+
238
+ def match_extension(filename, case_insensitive: false)
239
+ if case_insensitive
240
+ lambda { |path| path.downcase.end_with?(filename.downcase) }
241
+ else
242
+ lambda { |path| path.end_with?(filename) }
243
+ end
244
+ end
217
245
  end
218
246
  end
219
247
  end
@@ -7,7 +7,7 @@ module Bibliothecary
7
7
 
8
8
  def self.mapping
9
9
  {
10
- /(^bower\.json$|.*\/bower\.json$)/ => {
10
+ match_filename("bower.json") => {
11
11
  kind: 'manifest',
12
12
  parser: :parse_manifest
13
13
  }
@@ -7,11 +7,11 @@ module Bibliothecary
7
7
 
8
8
  def self.mapping
9
9
  {
10
- /(^Cargo.toml$|.*\/Cargo.toml$)/ => {
10
+ match_filename("Cargo.toml") => {
11
11
  kind: 'manifest',
12
12
  parser: :parse_manifest
13
13
  },
14
- /(^Cargo\.lock$|.*\/Cargo\.lock$)/ => {
14
+ match_filename("Cargo.lock") => {
15
15
  kind: 'lockfile',
16
16
  parser: :parse_lockfile
17
17
  }
@@ -5,15 +5,15 @@ module Bibliothecary
5
5
 
6
6
  def self.mapping
7
7
  {
8
- /(^Cartfile$|.*\/Cartfile$)/ => {
8
+ match_filename("Cartfile") => {
9
9
  kind: 'manifest',
10
10
  parser: :parse_cartfile
11
11
  },
12
- /(^Cartfile\.private$|.*\/Cartfile\.private$)/ => {
12
+ match_filename("Cartfile.private") => {
13
13
  kind: 'manifest',
14
14
  parser: :parse_cartfile_private
15
15
  },
16
- /(^Cartfile\.resolved$|.*\/Cartfile\.resolved$)/ => {
16
+ match_filename("Cartfile.resolved") => {
17
17
  kind: 'lockfile',
18
18
  parser: :parse_cartfile_resolved
19
19
  }
@@ -8,7 +8,7 @@ module Bibliothecary
8
8
 
9
9
  def self.mapping
10
10
  {
11
- /(^project\.clj$|.*\/project\.clj$)/ => {
11
+ match_filename("project.clj") => {
12
12
  kind: 'manifest',
13
13
  parser: :parse_manifest
14
14
  }
@@ -11,20 +11,20 @@ module Bibliothecary
11
11
 
12
12
  def self.mapping
13
13
  {
14
- /(^Podfile$|.*\/Podfile$)/ => {
14
+ match_filename("Podfile") => {
15
15
  kind: 'manifest',
16
16
  parser: :parse_podfile
17
17
  },
18
- /(^[A-Za-z0-9_-]+\.podspec$|.*\/[A-Za-z0-9_-]+\.podspec$)/ => {
18
+ match_extension(".podspec") => {
19
19
  kind: 'manifest',
20
20
  parser: :parse_podspec,
21
21
  can_have_lockfile: false
22
22
  },
23
- /(^Podfile\.lock$|.*\/Podfile\.lock$)/ => {
23
+ match_filename("Podfile.lock") => {
24
24
  kind: 'lockfile',
25
25
  parser: :parse_podfile_lock
26
26
  },
27
- /(^[A-Za-z0-9_-]+\.podspec.json$|.*\/[A-Za-z0-9_-]+\.podspec.json$)/ => {
27
+ match_extension(".podspec.json") => {
28
28
  kind: 'manifest',
29
29
  parser: :parse_json_manifest,
30
30
  can_have_lockfile: false
@@ -8,11 +8,11 @@ module Bibliothecary
8
8
 
9
9
  def self.mapping
10
10
  {
11
- /(^META\.json$|.*\/META\.json$)/i => {
11
+ match_filename("META.json", case_insensitive: true) => {
12
12
  kind: 'manifest',
13
13
  parser: :parse_json_manifest
14
14
  },
15
- /(^META\.yml$|.*\/META.yml$)/i => {
15
+ match_filename("META.yml", case_insensitive: true) => {
16
16
  kind: 'manifest',
17
17
  parser: :parse_yaml_manifest
18
18
  }
@@ -9,7 +9,7 @@ module Bibliothecary
9
9
 
10
10
  def self.mapping
11
11
  {
12
- /(^DESCRIPTION$|.*\/DESCRIPTION$)/i => {
12
+ match_filename("DESCRIPTION", case_insensitive: true) => {
13
13
  kind: 'manifest',
14
14
  parser: :parse_description
15
15
  }
@@ -8,11 +8,11 @@ module Bibliothecary
8
8
 
9
9
  def self.mapping
10
10
  {
11
- /(^dub\.json$|.*\/dub\.json$)/ => {
11
+ match_filename("dub.json") => {
12
12
  kind: 'manifest',
13
13
  parser: :parse_json_runtime_manifest
14
14
  },
15
- /(^dub\.sdl$|.*\/dub\.sdl$)/ => {
15
+ match_filename("dub.sdl") => {
16
16
  kind: 'manifest',
17
17
  parser: :parse_sdl_manifest
18
18
  }
@@ -7,11 +7,11 @@ module Bibliothecary
7
7
 
8
8
  def self.mapping
9
9
  {
10
- /(^elm-package\.json$|^elm_dependencies\.json$|.*\/elm-package\.json$|.*\/elm_dependencies\.json$)/ => {
10
+ match_filenames("elm-package.json", "elm_dependencies.json") => {
11
11
  kind: 'manifest',
12
12
  parser: :parse_json_runtime_manifest
13
13
  },
14
- /(^elm-stuff\/exact-dependencies\.json$|.*\/elm-stuff\/exact-dependencies\.json$)/ => {
14
+ match_filename("elm-stuff/exact-dependencies.json") => {
15
15
  kind: 'lockfile',
16
16
  parser: :parse_json_lock
17
17
  }
@@ -10,35 +10,35 @@ module Bibliothecary
10
10
 
11
11
  def self.mapping
12
12
  {
13
- /(^glide\.yaml$|.*\/glide\.yaml$)/ => {
13
+ match_filename("glide.yaml") => {
14
14
  kind: 'manifest',
15
15
  parser: :parse_glide_yaml
16
16
  },
17
- /(^glide\.lock$|.*\/glide\.lock$)/ => {
17
+ match_filename("glide.lock") => {
18
18
  kind: 'lockfile',
19
19
  parser: :parse_glide_lockfile
20
20
  },
21
- /(^Godeps\/Godeps\.json$|.*\/Godeps\/Godeps\.json$)/ => {
21
+ match_filename("Godeps/Godeps.json") => {
22
22
  kind: 'manifest',
23
23
  parser: :parse_godep_json
24
24
  },
25
- /(^Godeps$|.*\/Godeps$)/i => {
25
+ match_filename("Godeps", case_insensitive: true) => {
26
26
  kind: 'manifest',
27
27
  parser: :parse_gpm
28
28
  },
29
- /(^vendor\/manifest$|.*\/vendor\/manifest$)/ => {
29
+ match_filename("vendor/manifest") => {
30
30
  kind: 'manifest',
31
31
  parser: :parse_gb_manifest
32
32
  },
33
- /(^vendor\/vendor.json$|.*\/vendor\/vendor.json$)/ => {
33
+ match_filename("vendor/vendor.json") => {
34
34
  kind: 'manifest',
35
35
  parser: :parse_govendor
36
36
  },
37
- /(^Gopkg\.toml$|.*\/Gopkg\.toml$)/ => {
37
+ match_filename("Gopkg.toml") => {
38
38
  kind: 'manifest',
39
39
  parser: :parse_dep_toml
40
40
  },
41
- /(^Gopkg\.lock$|.*\/Gopkg\.lock$)/ => {
41
+ match_filename("Gopkg.lock") => {
42
42
  kind: 'lockfile',
43
43
  parser: :parse_dep_lockfile
44
44
  },
@@ -8,11 +8,11 @@ module Bibliothecary
8
8
 
9
9
  def self.mapping
10
10
  {
11
- /.*\.cabal$/ => {
11
+ match_extension(".cabal") => {
12
12
  kind: 'manifest',
13
13
  parser: :parse_cabal
14
14
  },
15
- /^cabal\.config$|.*\/cabal\.config$/ => {
15
+ match_extension("cabal.config") => {
16
16
  kind: 'lockfile',
17
17
  parser: :parse_cabal_config
18
18
  },
@@ -7,7 +7,7 @@ module Bibliothecary
7
7
 
8
8
  def self.mapping
9
9
  {
10
- /^haxelib\.json$|.*\/haxelib\.json$/ => {
10
+ match_filename("haxelib.json") => {
11
11
  kind: 'manifest',
12
12
  parser: :parse_json_runtime_manifest
13
13
  }
@@ -7,11 +7,11 @@ module Bibliothecary
7
7
 
8
8
  def self.mapping
9
9
  {
10
- /^mix\.exs$|.*\/mix\.exs$/ => {
10
+ match_filename("mix.exs") => {
11
11
  kind: 'manifest',
12
12
  parser: :parse_mix
13
13
  },
14
- /^mix\.lock$|.*\/mix\.lock$/ => {
14
+ match_filename("mix.lock") => {
15
15
  kind: 'lockfile',
16
16
  parser: :parse_mix_lock
17
17
  }
@@ -5,7 +5,7 @@ module Bibliothecary
5
5
 
6
6
  def self.mapping
7
7
  {
8
- /^REQUIRE$|.*\/REQUIRE$/i => {
8
+ match_filename("REQUIRE", case_insensitive: true) => {
9
9
  kind: "manifest",
10
10
  parser: :parse_require
11
11
  }
@@ -13,24 +13,24 @@ module Bibliothecary
13
13
 
14
14
  def self.mapping
15
15
  {
16
- /^ivy\.xml$|.*\/ivy\.xml$/i => {
16
+ match_filename("ivy.xml", case_insensitive: true) => {
17
17
  kind: 'manifest',
18
18
  parser: :parse_ivy_manifest
19
19
  },
20
- /^pom\.xml$|.*\/pom\.xml$/i => {
20
+ match_filename("pom.xml", case_insensitive: true) => {
21
21
  kind: 'manifest',
22
22
  parser: :parse_pom_manifest
23
23
  },
24
- /^build.gradle$|.*\/build.gradle$/i => {
24
+ match_filename("build.gradle", case_insensitive: true) => {
25
25
  kind: 'manifest',
26
26
  parser: :parse_gradle
27
27
  },
28
- /^.+.xml$/i => {
28
+ match_extension(".xml", case_insensitive: true) => {
29
29
  content_matcher: :ivy_report?,
30
30
  kind: 'lockfile',
31
31
  parser: :parse_ivy_report
32
32
  },
33
- /^gradle-dependencies-q\.txt|.*\/gradle-dependencies-q\.txt$/i => {
33
+ match_filename("gradle-dependencies-q.txt", case_insensitive: true) => {
34
34
  kind: 'lockfile',
35
35
  parser: :parse_gradle_resolved
36
36
  }
@@ -7,7 +7,7 @@ module Bibliothecary
7
7
 
8
8
  def self.mapping
9
9
  {
10
- /^versions\.json$|.*\/versions\.json$/ => {
10
+ match_filename("versions.json") => {
11
11
  kind: 'manifest',
12
12
  parser: :parse_json_runtime_manifest
13
13
  }
@@ -7,19 +7,19 @@ module Bibliothecary
7
7
 
8
8
  def self.mapping
9
9
  {
10
- /^package\.json$|.*\/package\.json$/ => {
10
+ match_filename("package.json") => {
11
11
  kind: 'manifest',
12
12
  parser: :parse_manifest
13
13
  },
14
- /^npm-shrinkwrap\.json$|.*\/npm-shrinkwrap\.json$/ => {
14
+ match_filename("npm-shrinkwrap.json") => {
15
15
  kind: 'lockfile',
16
16
  parser: :parse_shrinkwrap
17
17
  },
18
- /^yarn\.lock$|.*\/yarn.lock$/ => {
18
+ match_filename("yarn.lock") => {
19
19
  kind: 'lockfile',
20
20
  parser: :parse_yarn_lock
21
21
  },
22
- /^package-lock\.json$|.*\/package-lock\.json$/ => {
22
+ match_filename("package-lock.json") => {
23
23
  kind: 'lockfile',
24
24
  parser: :parse_package_lock
25
25
  }
@@ -8,27 +8,27 @@ module Bibliothecary
8
8
 
9
9
  def self.mapping
10
10
  {
11
- /(^Project\.json$|.*\/Project\.json$)/ => {
11
+ match_filename("Project.json") => {
12
12
  kind: 'manifest',
13
13
  parser: :parse_json_runtime_manifest
14
14
  },
15
- /(^Project\.lock\.json$|.*\/Project\.lock\.json$)/ => {
15
+ match_filename("Project.lock.json") => {
16
16
  kind: 'lockfile',
17
17
  parser: :parse_project_lock_json
18
18
  },
19
- /(^packages\.config$|.*\/packages\.config$)/ => {
19
+ match_filename("packages.config") => {
20
20
  kind: 'manifest',
21
21
  parser: :parse_packages_config
22
22
  },
23
- /(^[A-Za-z0-9_-]+\.nuspec$|.*\/[A-Za-z0-9_-]+\.nuspec$)/ => {
23
+ match_extension(".nuspec") => {
24
24
  kind: 'manifest',
25
25
  parser: :parse_nuspec
26
26
  },
27
- /(^[A-Za-z0-9_-]+\.csproj$|.*\/[A-Za-z0-9_-]+\.csproj$)/ => {
27
+ match_extension(".csproj") => {
28
28
  kind: 'manifest',
29
29
  parser: :parse_csproj
30
30
  },
31
- /(^paket\.lock$|.*\/paket\.lock$)/ => {
31
+ match_filename("paket.lock") => {
32
32
  kind: 'lockfile',
33
33
  parser: :parse_paket_lock
34
34
  }
@@ -7,11 +7,11 @@ module Bibliothecary
7
7
 
8
8
  def self.mapping
9
9
  {
10
- /^composer\.json$|.*\/composer\.json$/ => {
10
+ match_filename("composer.json") => {
11
11
  kind: 'manifest',
12
12
  parser: :parse_manifest
13
13
  },
14
- /^composer\.lock$|.*\/composer\.lock$/ => {
14
+ match_filename("composer.lock") => {
15
15
  kind: 'lockfile',
16
16
  parser: :parse_lockfile
17
17
  }
@@ -7,11 +7,11 @@ module Bibliothecary
7
7
 
8
8
  def self.mapping
9
9
  {
10
- /^pubspec\.yaml$|.*\/pubspec\.yaml$/i => {
10
+ match_filename("pubspec.yaml", case_insensitive: true) => {
11
11
  kind: 'manifest',
12
12
  parser: :parse_yaml_manifest
13
13
  },
14
- /^pubspec\.lock$|.*\/pubspec\.lock$/i => {
14
+ match_filename("pubspec.lock", case_insensitive: true) => {
15
15
  kind: 'lockfile',
16
16
  parser: :parse_yaml_lockfile
17
17
  }
@@ -6,24 +6,25 @@ module Bibliothecary
6
6
  INSTALL_REGEXP = /install_requires\s*=\s*\[([\s\S]*?)\]/
7
7
  REQUIRE_REGEXP = /([a-zA-Z0-9]+[a-zA-Z0-9\-_\.]+)([><=\w\.,]+)?/
8
8
  REQUIREMENTS_REGEXP = /^#{REQUIRE_REGEXP}/
9
+ MANIFEST_REGEXP = /.*require[^\/]*(\/)?[^\/]*\.(txt|pip)$/
9
10
 
10
11
  def self.mapping
11
12
  {
12
- /.*require[^\/]*(\/)?[^\/]*\.(txt|pip)$/ => {
13
+ lambda { |p| MANIFEST_REGEXP.match(p) } => {
13
14
  kind: 'manifest',
14
15
  parser: :parse_requirements_txt,
15
16
  can_have_lockfile: false
16
17
  },
17
- /^setup\.py$|.*\/setup.py$/ => {
18
+ match_filename("setup.py") => {
18
19
  kind: 'manifest',
19
20
  parser: :parse_setup_py,
20
21
  can_have_lockfile: false
21
22
  },
22
- /^Pipfile$|.*\/Pipfile$/ => {
23
+ match_filename("Pipfile") => {
23
24
  kind: 'manifest',
24
25
  parser: :parse_pipfile
25
26
  },
26
- /^Pipfile\.lock$|.*\/Pipfile\.lock$/ => {
27
+ match_filename("Pipfile.lock") => {
27
28
  kind: 'lockfile',
28
29
  parser: :parse_pipfile_lock
29
30
  }
@@ -10,16 +10,16 @@ module Bibliothecary
10
10
 
11
11
  def self.mapping
12
12
  {
13
- /^Gemfile$|^gems\.rb$|.*\/Gemfile$|.*\/gems\.rb$/ => {
13
+ match_filenames("Gemfile", "gems.rb") => {
14
14
  kind: 'manifest',
15
15
  parser: :parse_gemfile
16
16
  },
17
- /^[A-Za-z0-9_-]+\.gemspec$|.*\/[A-Za-z0-9_-]+\.gemspec$/ => {
17
+ match_extension(".gemspec") => {
18
18
  kind: 'manifest',
19
19
  parser: :parse_gemspec,
20
20
  can_have_lockfile: false
21
21
  },
22
- /^Gemfile\.lock$|^gems\.locked$|.*\/gems\.locked$|.*\/Gemfile\.lock$/ => {
22
+ match_filenames("Gemfile.lock", "gems.locked") => {
23
23
  kind: 'lockfile',
24
24
  parser: :parse_gemfile_lock
25
25
  }
@@ -7,11 +7,11 @@ module Bibliothecary
7
7
 
8
8
  def self.mapping
9
9
  {
10
- /^shard\.yml$|.*\/shard\.yml$/i => {
10
+ match_filename("shard.yml", case_insensitive: true) => {
11
11
  kind: 'manifest',
12
12
  parser: :parse_yaml_manifest
13
13
  },
14
- /^shard\.lock$|.*\/shard\.lock$/i => {
14
+ match_filename("shard.lock", case_insensitive: true) => {
15
15
  kind: 'lockfile',
16
16
  parser: :parse_yaml_lockfile
17
17
  }
@@ -5,7 +5,7 @@ module Bibliothecary
5
5
 
6
6
  def self.mapping
7
7
  {
8
- /^Package\.swift$|.*\/Package\.swift$/i => {
8
+ match_filename("Package.swift", case_insensitive: true) => {
9
9
  kind: 'manifest',
10
10
  parser: :parse_package_swift
11
11
  }
@@ -1,3 +1,3 @@
1
1
  module Bibliothecary
2
- VERSION = "6.3.2"
2
+ VERSION = "6.4.0"
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.2
4
+ version: 6.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Nesbitt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-02 00:00:00.000000000 Z
11
+ date: 2019-04-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: toml-rb