Sha256: 5ba1fd83afb0ceed843dbad5858ff04742efea2eccfa8cca92086b1b1e6063e4

Contents?: true

Size: 1.51 KB

Versions: 20

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

20 entries across 20 versions & 2 rubygems

Version Path
middleman-core-4.5.1 lib/middleman-core/contracts.rb
middleman-core-4.5.0 lib/middleman-core/contracts.rb
middleman-core-4.4.3 lib/middleman-core/contracts.rb
middleman-core-4.4.2 lib/middleman-core/contracts.rb
middleman-core-4.4.0 lib/middleman-core/contracts.rb
middleman-core-4.3.11 lib/middleman-core/contracts.rb
middleman-core-4.3.10 lib/middleman-core/contracts.rb
middleman-core-4.3.8 lib/middleman-core/contracts.rb
middleman-core-4.3.7 lib/middleman-core/contracts.rb
files.com-1.0.55 docs/vendor/bundle/ruby/2.5.0/gems/middleman-core-4.3.3/lib/middleman-core/contracts.rb
middleman-core-4.3.6 lib/middleman-core/contracts.rb
middleman-core-4.3.5 lib/middleman-core/contracts.rb
middleman-core-4.3.4 lib/middleman-core/contracts.rb
middleman-core-4.3.3 lib/middleman-core/contracts.rb
middleman-core-4.3.2 lib/middleman-core/contracts.rb
middleman-core-4.3.1 lib/middleman-core/contracts.rb
middleman-core-4.3.0 lib/middleman-core/contracts.rb
middleman-core-4.3.0.rc.1 lib/middleman-core/contracts.rb
middleman-core-4.2.1 lib/middleman-core/contracts.rb
middleman-core-4.2.0 lib/middleman-core/contracts.rb