Class: Bibliothecary::Parsers::Julia

Inherits:
Object
  • Object
show all
Includes:
Analyser
Defined in:
lib/bibliothecary/parsers/julia.rb

Class Method Summary collapse

Methods included from Analyser

create_analysis, create_error_analysis, included

Class Method Details

.mappingObject



8
9
10
11
12
13
14
15
# File 'lib/bibliothecary/parsers/julia.rb', line 8

def self.mapping
  {
    match_filename("REQUIRE", case_insensitive: true) => {
      kind: "manifest",
      parser: :parse_require,
    },
  }
end

.parse_require(file_contents, options: {}) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/bibliothecary/parsers/julia.rb', line 19

def self.parse_require(file_contents, options: {})
  deps = []
  file_contents.split("\n").each do |line|
    next if line.match(/^#/) || line.empty?

    split = line.split(/\s/)
    if line.match(/^@/)
      name = split[1]
      reqs = split[2, split.length].join(" ")
    else
      name = split[0]
      reqs = split[1, split.length].join(" ")
    end
    reqs = "*" if reqs.empty?
    next if name.empty?

    deps << Dependency.new(
      name: name,
      requirement: reqs,
      type: "runtime",
      source: options.fetch(:filename, nil)
    )
  end
  deps
end