Sha256: 99987bf8a5cd8a27a4181f4a5786a1e5b0976b53132e6400dd1b46f923b621e6

Contents?: true

Size: 1001 Bytes

Versions: 11

Compression:

Stored size: 1001 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::Int::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

11 entries across 11 versions & 1 rubygems

Version Path
nanoc-4.11.0 lib/nanoc/base/assertions.rb
nanoc-4.10.4 lib/nanoc/base/assertions.rb
nanoc-4.10.3 lib/nanoc/base/assertions.rb
nanoc-4.10.2 lib/nanoc/base/assertions.rb
nanoc-4.10.1 lib/nanoc/base/assertions.rb
nanoc-4.10.0 lib/nanoc/base/assertions.rb
nanoc-4.9.9 lib/nanoc/base/assertions.rb
nanoc-4.9.8 lib/nanoc/base/assertions.rb
nanoc-4.9.7 lib/nanoc/base/assertions.rb
nanoc-4.9.6 lib/nanoc/base/assertions.rb
nanoc-4.9.5 lib/nanoc/base/assertions.rb