Sha256: f8624eab20ad8c424f4d8a06edcc6fee97c0068503c02adc7ea8dc26893a47b2
Contents?: true
Size: 1.13 KB
Versions: 2
Compression:
Stored size: 1.13 KB
Contents
# Copyright (c) 2020 Jerome Arbez-Gindre # frozen_string_literal: true require 'digest' module DefMastership # DefMastership definition: contains all data of a definition class Definition attr_reader :type, :reference, :lines, :labels, :eref, :iref, :attributes def initialize(match) @type = match[:type] @reference = match[:reference] @lines = [] @labels = Set.new labels = match[:labels] @labels.merge(labels.split(/\s*,\s*/).to_set) if labels @eref = Hash.new([]) @iref = [] @attributes = {} @explicit_checksum = match[:explicit_checksum] end def <<(new_line) @lines << new_line self end def value @lines.join("\n") end def sha256 Digest::SHA2.new(256).hexdigest(value).split(//).last(8).join end def wrong_explicit_checksum @explicit_checksum if @explicit_checksum != sha256 end def add_eref(refname, extrefs) @eref[refname] = extrefs.strip.split(/\s*,\s*/) end def add_iref(ref) @iref << ref end def set_attribute(key, value) @attributes[key] = value end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
defmastership-1.0.7 | lib/defmastership/definition.rb |
defmastership-1.0.6 | lib/defmastership/definition.rb |