Class: Bibliothecary::Parsers::Shard
- Inherits:
-
Object
- Object
- Bibliothecary::Parsers::Shard
show all
- Includes:
- Analyser
- Defined in:
- lib/bibliothecary/parsers/shard.rb
Class Method Summary
collapse
Methods included from Analyser
create_analysis, create_error_analysis, included
Class Method Details
.map_dependencies(hash, key, type, source = nil) ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/bibliothecary/parsers/shard.rb', line 36
def self.map_dependencies(hash, key, type, source = nil)
hash.fetch(key, []).map do |name, requirement|
Dependency.new(
name: name,
requirement: requirement["version"],
type: type,
source: source,
platform: platform_name
)
end
end
|
.mapping ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/bibliothecary/parsers/shard.rb', line 10
def self.mapping
{
match_filename("shard.yml", case_insensitive: true) => {
kind: "manifest",
parser: :parse_yaml_manifest,
},
match_filename("shard.lock", case_insensitive: true) => {
kind: "lockfile",
parser: :parse_yaml_lockfile,
},
}
end
|
.parse_yaml_lockfile(file_contents, options: {}) ⇒ Object
23
24
25
26
27
|
# File 'lib/bibliothecary/parsers/shard.rb', line 23
def self.parse_yaml_lockfile(file_contents, options: {})
manifest = YAML.load file_contents
dependencies = map_dependencies(manifest, "shards", "runtime", options.fetch(:filename, nil))
Bibliothecary::ParserResult.new(dependencies: dependencies)
end
|
.parse_yaml_manifest(file_contents, options: {}) ⇒ Object
29
30
31
32
33
34
|
# File 'lib/bibliothecary/parsers/shard.rb', line 29
def self.parse_yaml_manifest(file_contents, options: {})
manifest = YAML.load file_contents
dependencies = map_dependencies(manifest, "dependencies", "runtime", options.fetch(:filename, nil)) +
map_dependencies(manifest, "development_dependencies", "runtime", options.fetch(:filename, nil))
Bibliothecary::ParserResult.new(dependencies: dependencies)
end
|