Sha256: 818a9b02a2642506314e007c45e3b86aa6212939e0416efc4929210016f7195a
Contents?: true
Size: 1.96 KB
Versions: 1
Compression:
Stored size: 1.96 KB
Contents
require File.dirname(__FILE__) + "/dsl" module CQL QUERY_VALUES = %w(name uri line description type steps id tags examples) class MapReduce CQL::QUERY_VALUES.each do |property| define_singleton_method(property) do |input| input = [input] if input.class != Array input.map { |a| a[property] } end end %w(all everything complete).each do |method_name| define_singleton_method(method_name){|input|input} end def self.step_lines input input = [input] if input.class != Array steps(input).map do |scen| scen.map { |line| line['keyword'] + line['name'] } end end def self.filter_features input, args if args.has_key?('feature') && args['feature'][0].class == String input = input.find_all { |feature| feature['name'] == args['feature'][0] } elsif args.has_key?('feature') && args['feature'][0].class == Regexp input = input.find_all { |feature| feature['name'] =~ args['feature'][0] } end input = input.find_all { |feature| has_tags feature['tags'], args['tags'] } if args.has_key? 'tags' input end def self.filter_sso input, args results = [] input = filter_features(input, 'feature'=>args['feature']) if args.has_key?('feature') input.each do |feature| feature['elements'].each do |element| results.push element if element['type'] == args['what'] end end results end def self.tag_set input tags = Set.new input.each do |feature| feature['elements'].each do |element| break if element['tags'] == nil element['tags'].each { |tag| tags.add tag['name'] } end end tags.to_a end def self.has_tags given, search return false if given == nil search.count { |tag_for_search| given.map { |t| t["name"] }.include?(tag_for_search) }==search.size end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
cql-0.0.2 | lib/map_reduce.rb |