Sha256: 1d3349ffa6aa0a4084452a386ec5079ab2375ef082fd42e91fb1995b2ce0bbc3

Contents?: true

Size: 1002 Bytes

Versions: 9

Compression:

Stored size: 1002 Bytes

Contents

# frozen_string_literal: true

module Nanoc
  module Assertions
    class AssertionFailure < Nanoc::Int::Errors::InternalInconsistency
    end

    module Mixin
      def assert(assertion)
        return unless Nanoc::Core::ContractsSupport.enabled?

        unless assertion.call
          raise AssertionFailure, "assertion failed: #{assertion.class}"
        end
      end
    end

    class Base
      def call
        raise NotImplementedError
      end
    end

    class AllItemRepsHaveCompiledContent < Nanoc::Assertions::Base
      def initialize(compiled_content_cache:, item_reps:)
        @compiled_content_cache = compiled_content_cache
        @item_reps = item_reps
      end

      def call
        @item_reps.all? do |rep|
          @compiled_content_cache[rep]
        end
      end
    end

    class PathIsAbsolute < Nanoc::Assertions::Base
      def initialize(path:)
        @path = path
      end

      def call
        Pathname.new(@path).absolute?
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
nanoc-4.11.9 lib/nanoc/base/assertions.rb
nanoc-4.11.8 lib/nanoc/base/assertions.rb
nanoc-4.11.7 lib/nanoc/base/assertions.rb
nanoc-4.11.6 lib/nanoc/base/assertions.rb
nanoc-4.11.5 lib/nanoc/base/assertions.rb
nanoc-4.11.4 lib/nanoc/base/assertions.rb
nanoc-4.11.3 lib/nanoc/base/assertions.rb
nanoc-4.11.2 lib/nanoc/base/assertions.rb
nanoc-4.11.1 lib/nanoc/base/assertions.rb