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



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

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

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

rubocop:disable Lint/UnusedMethodArgument



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

def self.parse_require(file_contents, options: {}) # rubocop:disable Lint/UnusedMethodArgument
  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 << {
      name: name,
      requirement: reqs,
      type: "runtime",
    }
  end
  deps
end