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.5.2 lib/lono/jade/circular.rb
lono-7.5.1 lib/lono/jade/circular.rb
lono-7.5.0 lib/lono/jade/circular.rb
lono-7.4.11 lib/lono/jade/circular.rb
lono-7.4.10 lib/lono/jade/circular.rb
lono-7.4.9 lib/lono/jade/circular.rb
lono-7.4.8 lib/lono/jade/circular.rb
lono-7.4.7 lib/lono/jade/circular.rb
lono-7.4.6 lib/lono/jade/circular.rb
lono-7.4.5 lib/lono/jade/circular.rb
lono-7.4.4 lib/lono/jade/circular.rb
lono-7.4.3 lib/lono/jade/circular.rb
lono-7.4.2 lib/lono/jade/circular.rb
lono-7.4.1 lib/lono/jade/circular.rb
lono-7.4.0 lib/lono/jade/circular.rb
lono-7.3.2 lib/lono/jade/circular.rb
lono-7.3.1 lib/lono/jade/circular.rb
lono-7.3.0 lib/lono/jade/circular.rb
lono-7.2.3 lib/lono/jade/circular.rb
lono-7.2.2 lib/lono/jade/circular.rb