bibliothecary 0.13.1 → 0.14.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 +4 -4
- data/lib/bibliothecary/parsers/shard.rb +71 -0
- data/lib/bibliothecary/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 687c305ca930c9357f00bc25c9285b7fe277b2ae
|
4
|
+
data.tar.gz: 42aae84d7863c00e53580efc3c2f92882fec4546
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 733a97827e27d99f5414479f180c8c2d425e23548d832942f3ef6196329eada6edb0893b4d1a5818b3f137b6a71545730f42dc0322505632141ea034fa5e8b3f
|
7
|
+
data.tar.gz: a80d0be71e6898470e76cff823be82a34f13768bf27d4985de6d60d768a23cd45559b8d3269b01d403828432a4fb65fb2e5d5dd08cc35d417cb454c14ea2669f
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module Bibliothecary
|
4
|
+
module Parsers
|
5
|
+
class Shard
|
6
|
+
PLATFORM_NAME = 'shard'
|
7
|
+
|
8
|
+
def self.parse(filename, file_contents)
|
9
|
+
if filename.match(/^shard\.yml$/i)
|
10
|
+
yaml = YAML.load file_contents
|
11
|
+
parse_yaml_manifest(yaml)
|
12
|
+
elsif filename.match(/^shard\.lock$/i)
|
13
|
+
yaml = YAML.load file_contents
|
14
|
+
parse_yaml_lockfile(yaml)
|
15
|
+
else
|
16
|
+
[]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.analyse(folder_path, file_list)
|
21
|
+
[analyse_yaml_manifest(folder_path, file_list),
|
22
|
+
analyse_yaml_lockfile(folder_path, file_list)]
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.analyse_yaml_manifest(folder_path, file_list)
|
26
|
+
path = file_list.find{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/^shard\.yml$/i) }
|
27
|
+
return unless path
|
28
|
+
|
29
|
+
manifest = YAML.load File.open(path).read
|
30
|
+
|
31
|
+
{
|
32
|
+
platform: PLATFORM_NAME,
|
33
|
+
path: path,
|
34
|
+
dependencies: parse_yaml_manifest(manifest)
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.analyse_yaml_lockfile(folder_path, file_list)
|
39
|
+
path = file_list.find{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/^shard\.lock$/i) }
|
40
|
+
return unless path
|
41
|
+
|
42
|
+
manifest = YAML.load File.open(path).read
|
43
|
+
|
44
|
+
{
|
45
|
+
platform: PLATFORM_NAME,
|
46
|
+
path: path,
|
47
|
+
dependencies: parse_yaml_lockfile(manifest)
|
48
|
+
}
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.parse_yaml_lockfile(manifest)
|
52
|
+
map_dependencies(manifest, 'shards', 'runtime')
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.parse_yaml_manifest(manifest)
|
56
|
+
map_dependencies(manifest, 'dependencies', 'runtime') +
|
57
|
+
map_dependencies(manifest, 'development_dependencies', 'runtime')
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.map_dependencies(hash, key, type)
|
61
|
+
hash.fetch(key,[]).map do |name, requirement|
|
62
|
+
{
|
63
|
+
name: name,
|
64
|
+
requirement: requirement['version'] || '*',
|
65
|
+
type: type
|
66
|
+
}
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
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: 0.
|
4
|
+
version: 0.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Nesbitt
|
@@ -190,6 +190,7 @@ files:
|
|
190
190
|
- lib/bibliothecary/parsers/pub.rb
|
191
191
|
- lib/bibliothecary/parsers/pypi.rb
|
192
192
|
- lib/bibliothecary/parsers/rubygems.rb
|
193
|
+
- lib/bibliothecary/parsers/shard.rb
|
193
194
|
- lib/bibliothecary/version.rb
|
194
195
|
- lib/cartfile_parser.rb
|
195
196
|
- lib/sdl_parser.rb
|