Sha256: 8d23d54a50c6066eb4cc285728c854b9295a8681e1883ad74511b3db3794b149

Contents?: true

Size: 806 Bytes

Versions: 5

Compression:

Stored size: 806 Bytes

Contents

module Prospectus
  ##
  # Define list object that contains items
  class List
    def initialize(params = {})
      @options = params
    end

    def items
      @items ||= []
    end

    def check
      all, good_only = @options.values_at(:all, :good_only)
      items.select do |x|
        match = x.expected == x.actual
        true if all || (!match ^ good_only)
      end
    end
  end

  ##
  # DSL for wrapping eval of list files
  class ListDSL
    def initialize(list, params)
      @list = list
      @options = params
    end

    def item(&block)
      item = Item.new(@options)
      dsl = ItemDSL.new(item, @options)
      dsl.instance_eval(&block)
      @list.items << item
      item.list.items.each do |x|
        x.prefix item.name
        @list.items << x
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
prospectus-0.5.2 lib/prospectus/list.rb
prospectus-0.5.1 lib/prospectus/list.rb
prospectus-0.5.0 lib/prospectus/list.rb
prospectus-0.4.0 lib/prospectus/list.rb
prospectus-0.3.0 lib/prospectus/list.rb