Sha256: db8a27f2b67077bbfe2c5768f1a8fe1cd7759af224357c4ecc64c9cc317fc418

Contents?: true

Size: 962 Bytes

Versions: 9

Compression:

Stored size: 962 Bytes

Contents

require "json"

module Bibliothecary
  module Parsers
    class Elm
      include Bibliothecary::Analyser
      extend Bibliothecary::MultiParsers::JSONRuntime

      def self.mapping
        {
          match_filenames("elm-package.json", "elm_dependencies.json") => {
            kind: "manifest",
            parser: :parse_json_runtime_manifest,
          },
          match_filename("elm-stuff/exact-dependencies.json") => {
            kind: "lockfile",
            parser: :parse_json_lock,
          },
        }
      end

      add_multi_parser(Bibliothecary::MultiParsers::DependenciesCSV)

      def self.parse_json_lock(file_contents, options: {}) # rubocop:disable Lint/UnusedMethodArgument
        manifest = JSON.parse file_contents
        manifest.map do |name, requirement|
          Dependency.new(
            name: name,
            requirement: requirement,
            type: "runtime",
          )
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
bibliothecary-12.0.0 lib/bibliothecary/parsers/elm.rb
bibliothecary-11.0.1 lib/bibliothecary/parsers/elm.rb
bibliothecary-11.0.0 lib/bibliothecary/parsers/elm.rb
bibliothecary-10.2.4 lib/bibliothecary/parsers/elm.rb
bibliothecary-10.2.3 lib/bibliothecary/parsers/elm.rb
bibliothecary-10.2.2 lib/bibliothecary/parsers/elm.rb
bibliothecary-10.2.0 lib/bibliothecary/parsers/elm.rb
bibliothecary-10.1.0 lib/bibliothecary/parsers/elm.rb
bibliothecary-10.0.0 lib/bibliothecary/parsers/elm.rb