To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Tag: | Revision:

root / vendor / plugins / redmine_tags / lib / redmine_project_filtering.rb @ 756:18b0f6e6d7a8

History | View | Annotate | Download (492 Bytes)

1 739:b7ac21913927 luis
module RedmineProjectFiltering
2
3
  # transforms a question and a list of custom fields into something that Project.search can process
4
  def self.calculate_tokens(question, custom_fields=nil)
5
    list = []
6
    list << question if question.present?
7
8
    tokens = list.join(' ').scan(%r{((\s|^)"[\s\w]+"(\s|$)|\S+)})
9
    tokens = tokens.collect{ |m| m.first.gsub(%r{(^\s*"\s*|\s*"\s*$)}, '') }
10
11
    # tokens must be at least 2 characters long
12
    tokens.select {|w| w.length > 1 }
13
  end
14
15
end