Class: IssuesJqlGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/jql_generators/issues_jql_generator.rb

Instance Method Summary collapse

Instance Method Details

#generate(options) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/jql_generators/issues_jql_generator.rb', line 2

def generate(options)
  
  keys = options[:keys].split(',').collect { |k| k.strip }.collect do |key|
    #if it's a specific key
    if !key.match(/(.*)\-(\d+)\.\.(.*)\-(\d+)/).nil?
      raise "The beginning and end ranges (#{$1}, #{$2}) do not match" if $1 != $3
      ($2.to_i..$4.to_i).collect { |id| "#{$1}-#{id}"}
    elsif !key.match(/(.*\-\d+)/).nil?
      $1
    else
      "Unknown key #{key}"
    end
  end

  keys.flatten.collect { |key| "key = \"#{key}\"" } * " or "
end