Sha256: bcf73d2f791609b726794e5ed367da125975e65c99d7a3431ee38f9dbdfa3380

Contents?: true

Size: 1.03 KB

Versions: 3

Compression:

Stored size: 1.03 KB

Contents

# REQUIRE
module Bibliothecary
  module Parsers
    class Julia
      PLATFORM_NAME = 'julia'

      def self.parse(filename, file_contents)
        if filename.match(/^REQUIRE$/i)
          parse_require(file_contents)
        else
          []
        end
      end

      def self.analyse(folder_path, file_list)
        [analyse_json(folder_path, file_list),
        analyse_yaml(folder_path, file_list)]
      end

      def self.analyse_json(folder_path, file_list)
        path = file_list.find{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/^REQUIRE$/i) }
        return unless path

        manifest = File.open(path).read

        {
          platform: PLATFORM_NAME,
          path: path,
          dependencies: parse_require(manifest)
        }
      end

      def self.parse_require(manifest)
        manifest.split("\n").map do |line|
          match = line.split(/\s/)
          {
            name: match[0],
            requirement: match[1] || '*',
            type: 'runtime'
          }
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bibliothecary-0.13.0 lib/bibliothecary/parsers/julia.rb
bibliothecary-0.12.0 lib/bibliothecary/parsers/julia.rb
bibliothecary-0.11.0 lib/bibliothecary/parsers/julia.rb