Class: Bibliothecary::Parsers::Pub
- Inherits:
-
Object
- Object
- Bibliothecary::Parsers::Pub
show all
- Includes:
- Analyser
- Defined in:
- lib/bibliothecary/parsers/pub.rb
Class Method Summary
collapse
Methods included from Analyser
create_analysis, create_error_analysis, included
Class Method Details
.mapping ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/bibliothecary/parsers/pub.rb', line 10
def self.mapping
{
match_filename("pubspec.yaml", case_insensitive: true) => {
kind: "manifest",
parser: :parse_yaml_manifest,
},
match_filename("pubspec.lock", case_insensitive: true) => {
kind: "lockfile",
parser: :parse_yaml_lockfile,
},
}
end
|
.parse_yaml_lockfile(file_contents, options: {}) ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/bibliothecary/parsers/pub.rb', line 32
def self.parse_yaml_lockfile(file_contents, options: {})
manifest = YAML.load file_contents
dependencies = manifest.fetch("packages", []).map do |name, dep|
Dependency.new(
name: name,
requirement: dep["version"],
type: "runtime",
source: options.fetch(:filename, nil),
platform: platform_name
)
end
ParserResult.new(dependencies: dependencies)
end
|
.parse_yaml_manifest(file_contents, options: {}) ⇒ Object
25
26
27
28
29
30
|
# File 'lib/bibliothecary/parsers/pub.rb', line 25
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, "dev_dependencies", "development", options.fetch(:filename, nil))
ParserResult.new(dependencies: dependencies)
end
|