bibliothecary 0.16.1 → 1.0.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
  SHA1:
3
- metadata.gz: de1940656b44b6c53f74eb08e5f160d833b11753
4
- data.tar.gz: f4b22eed1d035067ecc66b41695af2f4e4ae539b
3
+ metadata.gz: 050d965039bd2789e308a39c49e5953b5538e884
4
+ data.tar.gz: 92ef43654d7ed7200aa4df4e0ba8c3d2523a05e7
5
5
  SHA512:
6
- metadata.gz: d0f7ca90566c5af1e53c1f6ca6b9001d67f33a92ebb805fa4379e82c6f4fa3021a4afca0a8337a44d6c2be9323e3e379324b9f2a1df9edfd97a40eb8852e11fe
7
- data.tar.gz: 6781c0d7e096b1db79cc1b1f6a3e7555feb8cc97535eb5835076ababf496551ebea1bf4e2f49d59f1d10ded6752ef702b5a371e729864a40a9a1a1b6dfdd3c21
6
+ metadata.gz: 4e67f9fd1301362f6cbdd0a6fd76fc2750bab93ffc65cd5a118549e63a4b305664c08ca0f243c3bdcf1b7a56a1585529d54803292c2ceb0b40e499d60d93a3ef
7
+ data.tar.gz: 2d96d66780426198e4bf76078a955c2b5980e13b84dd01294a089a9bee5609bcf845dfe72530f19e2d7ea0fb229e5ecf69f7a7933b9bab4b663afe9d99dbded1
@@ -12,7 +12,7 @@ module Bibliothecary
12
12
  end
13
13
 
14
14
  def self.package_managers
15
- Bibliothecary::Parsers.constants.map{|c| Bibliothecary::Parsers.const_get(c) }
15
+ Bibliothecary::Parsers.constants.map{|c| Bibliothecary::Parsers.const_get(c) }.sort_by{|c| c.to_s.downcase }
16
16
  end
17
17
 
18
18
  def self.ignored_files
@@ -7,9 +7,9 @@ module Bibliothecary
7
7
 
8
8
  def self.parse(filename, file_contents)
9
9
  toml = TOML.parse(file_contents)
10
- if filename.match(/^Cargo\.toml$/)
10
+ if filename.match(/Cargo\.toml$/)
11
11
  parse_manifest(toml)
12
- elsif filename.match(/^Cargo\.lock$/)
12
+ elsif filename.match(/Cargo\.lock$/)
13
13
  parse_lockfile(toml)
14
14
  else
15
15
  []
@@ -22,7 +22,7 @@ module Bibliothecary
22
22
  end
23
23
 
24
24
  def self.analyse_cargo_toml(folder_path, file_list)
25
- path = file_list.find{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/^Cargo\.toml$/) }
25
+ path = file_list.find{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/Cargo\.toml$/) }
26
26
  return unless path
27
27
 
28
28
  manifest = TOML.load_file(path)
@@ -45,7 +45,7 @@ module Bibliothecary
45
45
  end
46
46
 
47
47
  def self.analyse_cargo_lock(folder_path, file_list)
48
- path = file_list.find{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/^Cargo\.lock$/) }
48
+ path = file_list.find{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/Cargo\.lock$/) }
49
49
  return unless path
50
50
 
51
51
  manifest = TOML.load_file(path)
@@ -1,4 +1,3 @@
1
- # REQUIRE
2
1
  module Bibliothecary
3
2
  module Parsers
4
3
  class Julia
@@ -1,8 +1,3 @@
1
- # packages.config
2
- # Project.json
3
- # Project.lock.json
4
- # *.nuspec
5
-
6
1
  require 'ox'
7
2
  require 'json'
8
3
 
@@ -24,6 +19,8 @@ module Bibliothecary
24
19
  elsif filename.match(/^[A-Za-z0-9_-]+\.nuspec$/)
25
20
  xml = Ox.parse file_contents
26
21
  parse_nuspec(xml)
22
+ elsif filename.match(/paket\.lock$/)
23
+ parse_paket_lock(file_contents.split("\n"))
27
24
  else
28
25
  []
29
26
  end
@@ -33,7 +30,8 @@ module Bibliothecary
33
30
  [analyse_project_json(folder_path, file_list),
34
31
  analyse_project_lock_json(folder_path, file_list),
35
32
  analyse_packages_config(folder_path, file_list),
36
- analyse_nuspec(folder_path, file_list)]
33
+ analyse_nuspec(folder_path, file_list),
34
+ analyse_paket_lock(folder_path, file_list)]
37
35
  end
38
36
 
39
37
  def self.analyse_project_json(folder_path, file_list)
@@ -88,6 +86,18 @@ module Bibliothecary
88
86
  }
89
87
  end
90
88
 
89
+ def self.analyse_paket_lock(folder_path, file_list)
90
+ path = file_list.find{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/paket\.lock$/) }
91
+ return unless path
92
+
93
+ lines = File.readlines(path)
94
+ {
95
+ platform: PLATFORM_NAME,
96
+ path: path,
97
+ dependencies: parse_paket_lock(lines)
98
+ }
99
+ end
100
+
91
101
  def self.parse_project_json(manifest)
92
102
  manifest.fetch('dependencies',[]).map do |name, requirement|
93
103
  {
@@ -128,6 +138,19 @@ module Bibliothecary
128
138
  }
129
139
  end
130
140
  end
141
+
142
+ def self.parse_paket_lock(lines)
143
+ package_version_re = /\s+(?<name>\S+)\s\((?<version>\d+\.\d+[\.\d+[\.\d+]*]*)\)/
144
+ packages = lines.select { |line| package_version_re.match(line) }.map { |line| package_version_re.match(line) }.map do |match|
145
+ {
146
+ name: match[:name].strip,
147
+ version: match[:version],
148
+ type: 'runtime'
149
+ }
150
+ end
151
+ # we only have to enforce uniqueness by name because paket ensures that there is only the single version globally in the project
152
+ packages.uniq {|package| package[:name] }
153
+ end
131
154
  end
132
155
  end
133
156
  end
@@ -7,9 +7,10 @@ module Bibliothecary
7
7
  REQUIREMENTS_REGEXP = /^#{REQUIRE_REGEXP}/
8
8
 
9
9
  def self.parse(filename, file_contents)
10
- if filename.match(/require.*\.(txt|pip)$/) && !filename.match(/^node_modules/)
10
+ is_valid_requirements_file = is_requirements_file(filename)
11
+ if is_valid_requirements_file
11
12
  parse_requirements_txt(file_contents)
12
- elsif filename.match(/^setup\.py$/)
13
+ elsif filename.match(/setup\.py$/)
13
14
  parse_setup_py(file_contents)
14
15
  else
15
16
  []
@@ -38,7 +39,7 @@ module Bibliothecary
38
39
  end
39
40
 
40
41
  def self.analyse_setup_py(folder_path, file_list)
41
- path = file_list.find{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/^setup\.py$/) }
42
+ path = file_list.find{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/setup\.py$/) }
42
43
  return unless path
43
44
 
44
45
  manifest = File.open(path).read
@@ -80,6 +81,15 @@ module Bibliothecary
80
81
  end
81
82
  deps
82
83
  end
84
+
85
+ def self.is_requirements_file(filename)
86
+ is_requirements_file = filename.match(/require.*\.(txt|pip)$/)
87
+ if filename.match(/require.*\.(txt|pip)$/) and !filename.match(/^node_modules/)
88
+ return true
89
+ else
90
+ return false
91
+ end
92
+ end
83
93
  end
84
94
  end
85
95
  end
@@ -1,3 +1,3 @@
1
1
  module Bibliothecary
2
- VERSION = "0.16.1"
2
+ VERSION = "1.0.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: 0.16.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Nesbitt
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-07-10 00:00:00.000000000 Z
11
+ date: 2016-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: toml-rb