Sha256: cb9009b5e44c3ba9e73eabaf794d3ea3cb64b565506af03884455fcbd28a16c1

Contents?: true

Size: 743 Bytes

Versions: 8

Compression:

Stored size: 743 Bytes

Contents

module GitCompound
  module Worker
    # Worker that checks if unwanted circular dependency exists
    #
    class CircularDependencyChecker < Worker
      def visit_component(component)
        @element = component
        raise_error if circular_dependency_exists?
      end

      def visit_manifest(manifest)
        @element = manifest
        raise_error if circular_dependency_exists?
      end

      private

      def circular_dependency_exists?
        @element.ancestors.include?(@element)
      end

      def raise_error
        name = @element.name
        type = @element.class.name.downcase

        raise CircularDependencyError,
              "Circular dependency detected in #{type} `#{name}`!"
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
git_compound-0.2.2 lib/git_compound/worker/circular_dependency_checker.rb
git_compound-0.2.1 lib/git_compound/worker/circular_dependency_checker.rb
git_compound-0.2.0 lib/git_compound/worker/circular_dependency_checker.rb
git_compound-0.1.2 lib/git_compound/worker/circular_dependency_checker.rb
git_compound-0.1.1 lib/git_compound/worker/circular_dependency_checker.rb
git_compound-0.1.0 lib/git_compound/worker/circular_dependency_checker.rb
git_compound-0.0.10 lib/git_compound/worker/circular_dependency_checker.rb
git_compound-0.0.9 lib/git_compound/worker/circular_dependency_checker.rb