lib/facter/framework/parsers/query_parser.rb in facter-4.1.1 vs lib/facter/framework/parsers/query_parser.rb in facter-4.2.0

- old
+ new

@@ -39,11 +39,11 @@ end def no_user_query(loaded_facts) searched_facts = [] loaded_facts.each do |loaded_fact| - searched_facts << SearchedFact.new(loaded_fact.name, loaded_fact.klass, [], '', loaded_fact.type) + searched_facts << SearchedFact.new(loaded_fact.name, loaded_fact.klass, '', loaded_fact.type) end searched_facts end def search_for_facts(query, loaded_fact_hash) @@ -57,11 +57,11 @@ resolvable_fact_list = get_facts_matching_tokens(query_tokens, query_token_range, loaded_fact_hash) return resolvable_fact_list if resolvable_fact_list.any? end - resolvable_fact_list << SearchedFact.new(query, nil, [], query, :nil) if resolvable_fact_list.empty? + resolvable_fact_list << SearchedFact.new(query, nil, query, :nil) if resolvable_fact_list.empty? resolvable_fact_list end def get_facts_matching_tokens(query_tokens, query_token_range, loaded_fact_hash) @@ -71,11 +71,11 @@ loaded_fact_hash.each do |loaded_fact| query_fact = query_tokens[query_token_range].join('.') next unless found_fact?(loaded_fact.name, query_fact) - searched_fact = construct_loaded_fact(query_tokens, query_token_range, loaded_fact) + searched_fact = construct_loaded_fact(query_tokens, loaded_fact) resolvable_fact_list << searched_fact end @log.debug "List of resolvable facts: #{resolvable_fact_list.inspect}" resolvable_fact_list @@ -91,25 +91,18 @@ return false unless fact_with_wildcard || fact_name.match("^#{processed_equery_fact}($|\\.)") true end - def construct_loaded_fact(query_tokens, query_token_range, loaded_fact) - filter_tokens = construct_filter_tokens(query_tokens, query_token_range) + def construct_loaded_fact(query_tokens, loaded_fact) user_query = @query_list.any? ? query_tokens.join('.') : '' fact_name = loaded_fact.name.to_s klass_name = loaded_fact.klass type = loaded_fact.type - sf = SearchedFact.new(fact_name, klass_name, filter_tokens, user_query, type) + sf = SearchedFact.new(fact_name, klass_name, user_query, type) sf.file = loaded_fact.file sf - end - - def construct_filter_tokens(query_tokens, query_token_range) - query_tokens.drop(query_token_range.size).map do |token| - token =~ /^[0-9]+$/ ? token.to_i : token - end end end end end