Sha256: 732d497e3d250c8ab27fc135f3dab18c26bc38780ddcaf02e8e8ffe52bdd4119

Contents?: true

Size: 1.09 KB

Versions: 3

Compression:

Stored size: 1.09 KB

Contents

# frozen_string_literal: true

module Bibliothecary
  module Parsers
    class Julia
      include Bibliothecary::Analyser

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

      add_multi_parser(Bibliothecary::MultiParsers::DependenciesCSV)

      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
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bibliothecary-12.1.2 lib/bibliothecary/parsers/julia.rb
bibliothecary-12.1.1 lib/bibliothecary/parsers/julia.rb
bibliothecary-12.1.0 lib/bibliothecary/parsers/julia.rb