Sha256: f551c2539a27d7501e63d4c2c6f2c065e84882281e4c24e5299ae4adeddd1f83
Contents?: true
Size: 1.1 KB
Versions: 7
Compression:
Stored size: 1.1 KB
Contents
require 'json' module Bibliothecary module Parsers class Elm include Bibliothecary::Analyser def self.mapping { /^elm-package\.json$|^elm_dependencies\.json$/ => { kind: 'manifest', parser: :parse_json_manifest }, /^elm-stuff\/exact-dependencies\.json$/ => { kind: 'lockfile', parser: :parse_json_lock } } end def self.parse_json_manifest(file_contents) manifest = JSON.parse file_contents map_dependencies(manifest, 'dependencies', 'runtime') end def self.parse_json_lock(file_contents) manifest = JSON.parse file_contents manifest.map do |name, requirement| { name: name, requirement: requirement, type: 'runtime' } end end def self.map_dependencies(hash, key, type) hash.fetch(key,[]).map do |name, requirement| { name: name, requirement: requirement, type: type } end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems