Sha256: dd3ee844cacf976e30f7b8048405429b82fef4db4900e0983e4b48a7dc8ceeaa

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 KB

Contents

module CQL
  module Dsl

    %w(names features scenario_outlines uri scenarios).each do |method_name|
      define_method(method_name) { method_name }
    end

    def select what
      @what = what
    end

    def from where
      @from = where
      @data
    end

    def tags *tags
      {'tags'=>tags}
    end

    def with filter
      if filter.has_key? 'tags'
        @data = CQL::MapReduce.find_feature(@data, 'tags'=>filter['tags'])
      end
      @data
    end

    class Query
      include Dsl
      attr_reader :data, :what

      def initialize features, &block
        @data = features
        @data = self.instance_eval(&block)
        key = @what + "-" + @from
        if key=="uri-features"
          @data = CQL::MapReduce.uri(@data)
        elsif key== "names-features"
          @data = CQL::MapReduce.overview(@data)
        elsif key== "names-scenario_outlines"
          @data= CQL::MapReduce.find_child(@data, 'what'=>'scenario_outline')
        elsif key== "names-scenarios"
          @data = CQL::MapReduce.find_child(@data, 'what'=>'scenario')
        end
        @data
      end
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cql-0.0.1 lib/dsl.rb