Sha256: 920c6d1c4e7a66b3797b8a7254121964a1f26558fc14b2e6844592c6bdc6bb79

Contents?: true

Size: 1.51 KB

Versions: 16

Compression:

Stored size: 1.51 KB

Contents

if ENV['CONTRACTS'] != 'false'
  require 'contracts'
  require 'hamster'

  module Contracts
    class IsA
      def self.[](val)
        @lookup ||= {}
        @lookup[val] ||= new(val)
      end

      def initialize(val)
        @val = val
      end

      def valid?(val)
        val.is_a? @val.constantize
      end
    end

    VectorOf = Contracts::CollectionOf::Factory.new(::Hamster::Vector)
    ResourceList = Contracts::ArrayOf[IsA['Middleman::Sitemap::Resource']]
  end
else
  module Contracts
    def self.included(base)
      base.extend self
    end

    # rubocop:disable MethodName
    def Contract(*)
    end

    class Callable
      def self.[](*)
      end
    end

    class Bool
    end

    class Num
    end

    class Pos
    end

    class Neg
    end

    class Any
    end

    class None
    end

    class Or < Callable
    end

    class Xor < Callable
    end

    class And < Callable
    end

    class Not < Callable
    end

    class RespondTo < Callable
    end

    class Send < Callable
    end

    class Exactly < Callable
    end

    class ArrayOf < Callable
    end

    class ResourceList < Callable
    end

    class Args < Callable
    end

    class HashOf < Callable
    end

    class Bool
    end

    class Maybe < Callable
    end

    class IsA < Callable
    end

    class SetOf < Callable
    end

    class Frozen < Callable
    end

    class VectorOf < Callable
    end
  end
end

module Contracts
  PATH_MATCHER = Or[String, RespondTo[:match], RespondTo[:call], RespondTo[:to_s]]
end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
middleman-core-with-external-sources-watch-fix-4.1.10 lib/middleman-core/contracts.rb
middleman-core-with-external-sources-watch-fix-4.1.0 lib/middleman-core/contracts.rb
middleman-core-4.1.14 lib/middleman-core/contracts.rb
middleman-core-4.1.13 lib/middleman-core/contracts.rb
middleman-core-4.1.12 lib/middleman-core/contracts.rb
middleman-core-4.1.11 lib/middleman-core/contracts.rb
middleman-core-4.1.10 lib/middleman-core/contracts.rb
middleman-core-4.1.9 lib/middleman-core/contracts.rb
middleman-core-4.1.8 lib/middleman-core/contracts.rb
middleman-core-4.1.7 lib/middleman-core/contracts.rb
middleman-core-4.1.6 lib/middleman-core/contracts.rb
middleman-core-4.1.5 lib/middleman-core/contracts.rb
middleman-core-4.1.3 lib/middleman-core/contracts.rb
middleman-core-4.1.2 lib/middleman-core/contracts.rb
middleman-core-4.1.1 lib/middleman-core/contracts.rb
middleman-core-4.1.0 lib/middleman-core/contracts.rb