bibliothecary 2.0.1 → 3.0.0

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: df928a14f1d95ce614e9ad3a69910c4462c686ee
4
- data.tar.gz: 70880ea6b8b72b06ef26cd3099fdd3bea9daaede
3
+ metadata.gz: 60ded5383ce5a7bada9d7b788054561d3650bfa1
4
+ data.tar.gz: d3e9d85d474bc948e058c32247dbf9f4437eb460
5
5
  SHA512:
6
- metadata.gz: 21780d58424b33bb4d7065409609f698950547bc58ef91a9e4ba5ea70d7ffbe5ba6941116defef6c25afd886ed39a4c78345962e92901e0de74482daeac017bb
7
- data.tar.gz: 923a3f492f389dcba55e81786984fa10f31d4cdc3e77807db39e44e06f7e81229aef63dada3b588646c609d6ac951082d8aac98e3e6b16303cda8b68b8e9e5a1
6
+ metadata.gz: dfc6d270640ef048b4a89e97721215c569313e12604ac7ef060d7d1159a44c90dc79808887f5e9e93a9a81c09a791fd70d5bd302822a7ac1c94d8d9dc5cca998
7
+ data.tar.gz: 485ce2afbb07fd363656eaecd59bd35fe6706a350d0ad754813f1d7ae732ad152bfe69eacc027741b7dabc78e2ab814ffd675a0a6199852715fa53ec0594f0d0
@@ -10,15 +10,14 @@ module Bibliothecary
10
10
 
11
11
  def analyse(folder_path, file_list)
12
12
  file_list.map do |path|
13
- file_contents = File.open(path).read
14
13
  filename = path.gsub(folder_path, '').gsub(/^\//, '')
15
- analyse_file(filename, file_contents, path)
14
+ analyse_file(filename, path)
16
15
  end.compact
17
16
  end
18
17
 
19
- def analyse_file(filename, file_contents, path)
18
+ def analyse_file(filename, path)
20
19
  begin
21
- dependencies = parse(filename, file_contents)
20
+ dependencies = parse(filename, path)
22
21
  if dependencies.any?
23
22
  {
24
23
  platform: platform_name,
@@ -5,8 +5,9 @@ module Bibliothecary
5
5
  class Bower
6
6
  include Bibliothecary::Analyser
7
7
 
8
- def self.parse(filename, file_contents)
8
+ def self.parse(filename, path)
9
9
  if filename.match(/^bower\.json$/)
10
+ file_contents = File.open(path).read
10
11
  json = JSON.parse(file_contents)
11
12
  parse_manifest(json)
12
13
  else
@@ -5,11 +5,13 @@ module Bibliothecary
5
5
  class Cargo
6
6
  include Bibliothecary::Analyser
7
7
 
8
- def self.parse(filename, file_contents)
8
+ def self.parse(filename, path)
9
9
  if filename.match(/Cargo\.toml$/)
10
+ file_contents = File.open(path).read
10
11
  toml = TOML.parse(file_contents)
11
12
  parse_manifest(toml)
12
13
  elsif filename.match(/Cargo\.lock$/)
14
+ file_contents = File.open(path).read
13
15
  toml = TOML.parse(file_contents)
14
16
  parse_lockfile(toml)
15
17
  else
@@ -3,12 +3,15 @@ module Bibliothecary
3
3
  class Carthage
4
4
  include Bibliothecary::Analyser
5
5
 
6
- def self.parse(filename, file_contents)
6
+ def self.parse(filename, path)
7
7
  if filename.match(/^Cartfile$/)
8
+ file_contents = File.open(path).read
8
9
  parse_cartfile(file_contents)
9
10
  elsif filename.match(/^Cartfile\.private$/)
11
+ file_contents = File.open(path).read
10
12
  parse_cartfile_private(file_contents)
11
13
  elsif filename.match(/^Cartfile\.resolved$/)
14
+ file_contents = File.open(path).read
12
15
  parse_cartfile_resolved(file_contents)
13
16
  else
14
17
  []
@@ -6,8 +6,9 @@ module Bibliothecary
6
6
  class Clojars
7
7
  include Bibliothecary::Analyser
8
8
 
9
- def self.parse(filename, file_contents)
9
+ def self.parse(filename, path)
10
10
  if filename.match(/^project\.clj$/)
11
+ file_contents = File.open(path).read
11
12
  parse_manifest(file_contents)
12
13
  else
13
14
  []
@@ -9,17 +9,21 @@ module Bibliothecary
9
9
  NAME_VERSION = '(?! )(.*?)(?: \(([^-]*)(?:-(.*))?\))?'.freeze
10
10
  NAME_VERSION_4 = /^ {4}#{NAME_VERSION}$/
11
11
 
12
- def self.parse(filename, file_contents)
12
+ def self.parse(filename, path)
13
13
  if filename.match(/^Podfile$/)
14
+ file_contents = File.open(path).read
14
15
  manifest = Gemnasium::Parser.send(:podfile, file_contents)
15
16
  parse_manifest(manifest)
16
17
  elsif filename.match(/^[A-Za-z0-9_-]+\.podspec$/)
18
+ file_contents = File.open(path).read
17
19
  manifest = Gemnasium::Parser.send(:podspec, file_contents)
18
20
  parse_manifest(manifest)
19
21
  elsif filename.match(/^Podfile\.lock$/)
22
+ file_contents = File.open(path).read
20
23
  manifest = YAML.load file_contents
21
24
  parse_podfile_lock(manifest)
22
25
  elsif filename.match(/^[A-Za-z0-9_-]+\.podspec.json$/)
26
+ file_contents = File.open(path).read
23
27
  json = JSON.parse(file_contents)
24
28
  parse_json_manifest(json)
25
29
  else
@@ -6,11 +6,13 @@ module Bibliothecary
6
6
  class CPAN
7
7
  include Bibliothecary::Analyser
8
8
 
9
- def self.parse(filename, file_contents)
9
+ def self.parse(filename, path)
10
10
  if filename.match(/^META\.json$/i)
11
+ file_contents = File.open(path).read
11
12
  json = JSON.parse file_contents
12
13
  parse_json_manifest(json)
13
14
  elsif filename.match(/^META\.yml$/i)
15
+ file_contents = File.open(path).read
14
16
  yaml = YAML.load file_contents
15
17
  parse_yaml_manifest(yaml)
16
18
  else
@@ -7,8 +7,9 @@ module Bibliothecary
7
7
 
8
8
  REQUIRE_REGEXP = /([a-zA-Z0-9\-_\.]+)\s?\(?([><=\s\d\.,]+)?\)?/
9
9
 
10
- def self.parse(filename, file_contents)
10
+ def self.parse(filename, path)
11
11
  if filename.match(/^DESCRIPTION$/i)
12
+ file_contents = File.open(path).read
12
13
  control = DebControl::ControlFileBase.parse(file_contents)
13
14
  parse_description(control)
14
15
  else
@@ -6,11 +6,13 @@ module Bibliothecary
6
6
  class Dub
7
7
  include Bibliothecary::Analyser
8
8
 
9
- def self.parse(filename, file_contents)
9
+ def self.parse(filename, path)
10
10
  if filename.match(/^dub\.json$/)
11
+ file_contents = File.open(path).read
11
12
  json = JSON.parse(file_contents)
12
13
  parse_manifest(json)
13
14
  elsif filename.match(/^dub\.sdl$/)
15
+ file_contents = File.open(path).read
14
16
  parse_sdl_manifest(file_contents)
15
17
  else
16
18
  []
@@ -5,11 +5,13 @@ module Bibliothecary
5
5
  class Elm
6
6
  include Bibliothecary::Analyser
7
7
 
8
- def self.parse(filename, file_contents)
8
+ def self.parse(filename, path)
9
9
  if filename.match(/^elm-package\.json$|^elm_dependencies\.json$/)
10
+ file_contents = File.open(path).read
10
11
  json = JSON.parse file_contents
11
12
  parse_json_manifest(json)
12
13
  elsif filename.match(/^elm-stuff\/exact-dependencies\.json$/)
14
+ file_contents = File.open(path).read
13
15
  json = JSON.parse file_contents
14
16
  parse_json_lock(json)
15
17
  else
@@ -6,17 +6,21 @@ module Bibliothecary
6
6
  class Go
7
7
  include Bibliothecary::Analyser
8
8
 
9
- def self.parse(filename, file_contents)
9
+ def self.parse(filename, path)
10
10
  if filename.match(/^glide\.yaml$/)
11
+ file_contents = File.open(path).read
11
12
  yaml = YAML.load file_contents
12
13
  parse_glide_yaml(yaml)
13
14
  elsif filename.match(/^glide\.lock$/)
15
+ file_contents = File.open(path).read
14
16
  yaml = YAML.load file_contents
15
17
  parse_glide_lockfile(yaml)
16
18
  elsif filename.match(/^Godeps\/Godeps\.json$/)
19
+ file_contents = File.open(path).read
17
20
  json = JSON.parse file_contents
18
21
  parse_godep_json(json)
19
22
  elsif filename.match(/^vendor\/manifest$/)
23
+ file_contents = File.open(path).read
20
24
  json = JSON.parse file_contents
21
25
  parse_gb_manifest(json)
22
26
  else
@@ -5,10 +5,12 @@ module Bibliothecary
5
5
  class Hex
6
6
  include Bibliothecary::Analyser
7
7
 
8
- def self.parse(filename, file_contents)
8
+ def self.parse(filename, path)
9
9
  if filename.match(/^mix\.exs$/)
10
+ file_contents = File.open(path).read
10
11
  parse_mix(file_contents)
11
12
  elsif filename.match(/^mix\.lock$/)
13
+ file_contents = File.open(path).read
12
14
  parse_mix_lock(file_contents)
13
15
  else
14
16
  []
@@ -3,8 +3,9 @@ module Bibliothecary
3
3
  class Julia
4
4
  include Bibliothecary::Analyser
5
5
 
6
- def self.parse(filename, file_contents)
6
+ def self.parse(filename, path)
7
7
  if filename.match(/^REQUIRE$/i)
8
+ file_contents = File.open(path).read
8
9
  parse_require(file_contents)
9
10
  else
10
11
  []
@@ -5,14 +5,17 @@ module Bibliothecary
5
5
  class Maven
6
6
  include Bibliothecary::Analyser
7
7
 
8
- def self.parse(filename, file_contents)
8
+ def self.parse(filename, path)
9
9
  if filename.match(/ivy\.xml$/i)
10
+ file_contents = File.open(path).read
10
11
  xml = Ox.parse file_contents
11
12
  parse_ivy_manifest(xml)
12
13
  elsif filename.match(/pom\.xml$/i)
14
+ file_contents = File.open(path).read
13
15
  xml = Ox.parse file_contents
14
16
  parse_pom_manifest(xml)
15
17
  elsif filename.match(/build.gradle$/i)
18
+ file_contents = File.open(path).read
16
19
  parse_gradle(file_contents)
17
20
  else
18
21
  []
@@ -5,8 +5,9 @@ module Bibliothecary
5
5
  class Meteor
6
6
  include Bibliothecary::Analyser
7
7
 
8
- def self.parse(filename, file_contents)
8
+ def self.parse(filename, path)
9
9
  if filename.match(/^versions\.json$/)
10
+ file_contents = File.open(path).read
10
11
  json = JSON.parse(file_contents)
11
12
  parse_manifest(json)
12
13
  else
@@ -5,11 +5,13 @@ module Bibliothecary
5
5
  class NPM
6
6
  include Bibliothecary::Analyser
7
7
 
8
- def self.parse(filename, file_contents)
8
+ def self.parse(filename, path)
9
9
  if filename.match(/package\.json$/)
10
+ file_contents = File.open(path).read
10
11
  json = JSON.parse(file_contents)
11
12
  parse_manifest(json)
12
13
  elsif filename.match(/npm-shrinkwrap\.json$/)
14
+ file_contents = File.open(path).read
13
15
  json = JSON.parse(file_contents)
14
16
  parse_shrinkwrap(json)
15
17
  else
@@ -6,20 +6,25 @@ module Bibliothecary
6
6
  class Nuget
7
7
  include Bibliothecary::Analyser
8
8
 
9
- def self.parse(filename, file_contents)
9
+ def self.parse(filename, path)
10
10
  if filename.match(/Project\.json$/)
11
+ file_contents = File.open(path).read
11
12
  json = JSON.parse file_contents
12
13
  parse_project_json(json)
13
14
  elsif filename.match(/Project\.lock\.json$/)
15
+ file_contents = File.open(path).read
14
16
  json = JSON.parse file_contents
15
17
  parse_project_lock_json(json)
16
18
  elsif filename.match(/packages\.config$/)
19
+ file_contents = File.open(path).read
17
20
  xml = Ox.parse file_contents
18
21
  parse_packages_config(xml)
19
22
  elsif filename.match(/^[A-Za-z0-9_-]+\.nuspec$/)
23
+ file_contents = File.open(path).read
20
24
  xml = Ox.parse file_contents
21
25
  parse_nuspec(xml)
22
26
  elsif filename.match(/paket\.lock$/)
27
+ file_contents = File.open(path).read
23
28
  parse_paket_lock(file_contents.split("\n"))
24
29
  else
25
30
  []
@@ -5,11 +5,13 @@ module Bibliothecary
5
5
  class Packagist
6
6
  include Bibliothecary::Analyser
7
7
 
8
- def self.parse(filename, file_contents)
8
+ def self.parse(filename, path)
9
9
  if filename.match(/^composer\.json$/)
10
+ file_contents = File.open(path).read
10
11
  json = JSON.parse(file_contents)
11
12
  parse_manifest(json)
12
13
  elsif filename.match(/^composer\.lock$/)
14
+ file_contents = File.open(path).read
13
15
  json = JSON.parse(file_contents)
14
16
  parse_lockfile(json)
15
17
  else
@@ -5,11 +5,13 @@ module Bibliothecary
5
5
  class Pub
6
6
  include Bibliothecary::Analyser
7
7
 
8
- def self.parse(filename, file_contents)
8
+ def self.parse(filename, path)
9
9
  if filename.match(/^pubspec\.yaml$/i)
10
+ file_contents = File.open(path).read
10
11
  yaml = YAML.load file_contents
11
12
  parse_yaml_manifest(yaml)
12
13
  elsif filename.match(/^pubspec\.lock$/i)
14
+ file_contents = File.open(path).read
13
15
  yaml = YAML.load file_contents
14
16
  parse_yaml_lockfile(yaml)
15
17
  else
@@ -7,11 +7,13 @@ module Bibliothecary
7
7
  REQUIRE_REGEXP = /([a-zA-Z0-9]+[a-zA-Z0-9\-_\.]+)([><=\d\.,]+)?/
8
8
  REQUIREMENTS_REGEXP = /^#{REQUIRE_REGEXP}/
9
9
 
10
- def self.parse(filename, file_contents)
10
+ def self.parse(filename, path)
11
11
  is_valid_requirements_file = is_requirements_file(filename)
12
12
  if is_valid_requirements_file
13
+ file_contents = File.open(path).read
13
14
  parse_requirements_txt(file_contents)
14
15
  elsif filename.match(/setup\.py$/)
16
+ file_contents = File.open(path).read
15
17
  parse_setup_py(file_contents)
16
18
  else
17
19
  []
@@ -8,14 +8,17 @@ module Bibliothecary
8
8
  NAME_VERSION = '(?! )(.*?)(?: \(([^-]*)(?:-(.*))?\))?'.freeze
9
9
  NAME_VERSION_4 = /^ {4}#{NAME_VERSION}$/
10
10
 
11
- def self.parse(filename, file_contents)
11
+ def self.parse(filename, path)
12
12
  if filename.match(/^Gemfile$|^gems\.rb$/)
13
+ file_contents = File.open(path).read
13
14
  manifest = Gemnasium::Parser.send(:gemfile, file_contents)
14
15
  parse_manifest(manifest)
15
16
  elsif filename.match(/[A-Za-z0-9_-]+\.gemspec$/)
17
+ file_contents = File.open(path).read
16
18
  manifest = Gemnasium::Parser.send(:gemspec, file_contents)
17
19
  parse_manifest(manifest)
18
20
  elsif filename.match(/^Gemfile\.lock$|^gems\.locked$/)
21
+ file_contents = File.open(path).read
19
22
  parse_gemfile_lock(file_contents)
20
23
  else
21
24
  []
@@ -5,11 +5,13 @@ module Bibliothecary
5
5
  class Shard
6
6
  include Bibliothecary::Analyser
7
7
 
8
- def self.parse(filename, file_contents)
8
+ def self.parse(filename, path)
9
9
  if filename.match(/^shard\.yml$/i)
10
+ file_contents = File.open(path).read
10
11
  yaml = YAML.load file_contents
11
12
  parse_yaml_manifest(yaml)
12
13
  elsif filename.match(/^shard\.lock$/i)
14
+ file_contents = File.open(path).read
13
15
  yaml = YAML.load file_contents
14
16
  parse_yaml_lockfile(yaml)
15
17
  else
@@ -3,8 +3,9 @@ module Bibliothecary
3
3
  class Swift
4
4
  include Bibliothecary::Analyser
5
5
 
6
- def self.parse(filename, file_contents)
6
+ def self.parse(filename, path)
7
7
  if filename.match(/^Package\.swift$/i)
8
+ file_contents = File.open(path).read
8
9
  parse_package_swift(file_contents)
9
10
  else
10
11
  []
@@ -1,3 +1,3 @@
1
1
  module Bibliothecary
2
- VERSION = "2.0.1"
2
+ VERSION = "3.0.0"
3
3
  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: 2.0.1
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Nesbitt