Sha256: 60451d2d528456b39e23c633685582a1c9df600bb8259b3d1eba3f168a5d144e

Contents?: true

Size: 1.45 KB

Versions: 21

Compression:

Stored size: 1.45 KB

Contents

module Inch
  class Config
    class Evaluation
      def initialize(language)
        @language = language
        @criteria_blocks = {}
      end

      def update(&block)
        instance_eval(&block)
      end

      def grade(symbol, &block)
        ::Inch::Evaluation::Grade.grade(symbol, &block)
      end

      def priority(symbol, &block)
        ::Inch::Evaluation::PriorityRange.priority_range(symbol, &block)
      end

      def schema(constant_name, &block)
        @criteria_blocks[constant_name.to_s] = Criteria.new(&block)
      end

      def criteria_for(constant_name)
        @criteria_blocks[constant_name.to_s] ||
          raise("No criteria for #{constant_name}")
      end

      # An Criteria describes how important certain parts of the docs are
      # for the associated Object
      class Criteria
        extend Utils::ReadWriteMethods

        rw_methods %w(
          docstring
          parameters
          return_type
          return_description
          code_example_single
          code_example_multi
          unconsidered_tag
        )

        attr_reader :object

        def initialize(&block)
          @block = block
        end

        def evaluate(object)
          @object = object
          instance_eval(&@block)
          # we are "deleting" the block/Proc here because it can't be
          # serialized by Marshal
          # TODO: find a nicer way to achieve this
          @block = nil
        end
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
inch-0.9.0.rc1 lib/inch/config/evaluation.rb
inch-0.8.0 lib/inch/config/evaluation.rb
inch-0.8.0.rc2 lib/inch/config/evaluation.rb
inch-0.8.0.rc1 lib/inch/config/evaluation.rb
inch-0.7.1 lib/inch/config/evaluation.rb
inch-0.7.0 lib/inch/config/evaluation.rb
inch-0.6.4 lib/inch/config/evaluation.rb
inch-0.6.3 lib/inch/config/evaluation.rb
inch-0.6.2 lib/inch/config/evaluation.rb
inch-0.6.1 lib/inch/config/evaluation.rb
inch-0.6.0 lib/inch/config/evaluation.rb
inch-0.6.0.rc6 lib/inch/config/evaluation.rb
inch-0.6.0.rc5 lib/inch/config/evaluation.rb
inch-0.6.0.rc4 lib/inch/config/evaluation.rb
inch-0.6.0.rc3 lib/inch/config/evaluation.rb
inch-0.6.0.rc2 lib/inch/config/evaluation.rb
inch-0.6.0.rc1 lib/inch/config/evaluation.rb
inch-0.5.10 lib/inch/config/evaluation.rb
inch-0.5.9 lib/inch/config/evaluation.rb
inch-0.5.8 lib/inch/config/evaluation.rb