Sha256: 0f9ffcd0de993e712f14dd6dea13fd64e4c5bf3c4c2938dd5adffe939a86e01f
Contents?: true
Size: 1.23 KB
Versions: 26
Compression:
Stored size: 1.23 KB
Contents
require "semantic/semantic" module Extension module Models class NpmPackage include SmartProperties include Comparable property :name property :version property :scripts, accepts: Hash, default: -> { {} } property :dependencies, accepts: Hash, default: -> { {} } property :dev_dependencies, accepts: Hash, default: -> { {} } def initialize(**config) super(**config.select { |property_name, _| self.class.properties.key?(property_name) }) end def self.parse(io) ShopifyCLI::Result.call { JSON.parse(io.read) } .then(&ShopifyCLI::TransformDataStructure.new(underscore_keys: true, symbolize_keys: true, shallow: true)) .then { |specification| new(**specification) } .unwrap { |error| raise "Failed to parse NPM package specification: #{error}" } end def <=>(other) return nil unless name == other.name Semantic::Version.new(version) <=> Semantic::Version.new(other.version) end def script?(name) scripts.key?(name) end def dependency?(name) dependencies.key?(name) end def dev_dependency?(name) dev_dependencies.key?(name) end end end end
Version data entries
26 entries across 26 versions & 1 rubygems