Module: PivotalTracker
- Defined in:
- lib/pivotal_shell.rb
Overview
fixing pivotal-tracker’s options encoding; it did not work with array filters
Class Method Summary collapse
Class Method Details
.encode_options(options) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/pivotal_shell.rb', line 15 def () return nil if !.is_a?(Hash) || .empty? = [] # remove options which are not filters, and encode them as such [:limit, :offset].each do |o| << "#{CGI.escape(o.to_s)}=#{CGI.escape(.delete(o).to_s)}" if [o] end # assume remaining key-value pairs describe filters, and encode them as such. filters_string = .map do |key, value| "#{CGI.escape(key.to_s)}%3A#{CGI.escape([value].flatten.map{|v| v=v.to_s; v.include?(' ') ? '"'+v+'"' : v}.join(','))}" end << "filter=#{filters_string.join('+')}" unless filters_string.empty? return "?#{.join('&')}" end |