Sha256: eb948cf7a49d88d0d54c84190d92bb56c0ead2023ece65207d811a75dd328427

Contents?: true

Size: 653 Bytes

Versions: 22

Compression:

Stored size: 653 Bytes

Contents

class Lono::Jade
  module Circular
    def check_for_circular_dependency!
      circular = circular_dependency?
      return unless circular

      puts "ERROR: jade circular dependency detected".color(:red)
      puts "circular dependency: #{parent_names.join(" => ")}"
      exit 1
    end

    def circular_dependency?
      parent_names.uniq.size != parent_names.size
    end

    def parent_names
      names = [self.name] # include initial jade name to detect circular dependency earlier
      parent = registry.parent
      while parent
        names << parent.name
        parent = parent.registry.parent
      end
      names
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
lono-7.2.1 lib/lono/jade/circular.rb
lono-7.2.0 lib/lono/jade/circular.rb