Sha256: edcc656bf376747681390e1762f4f11d0ad7dbc7033f6ad141007f29d0cbaa12

Contents?: true

Size: 1.89 KB

Versions: 11

Compression:

Stored size: 1.89 KB

Contents

module TicketHelper

  def format_ticket(ticket)
    "<span class=\"ticket-number\">[##{ticket.number}]</span> <span class=\"ticket-summary\">#{format_with_feature_bolded ticket.summary}</span>".html_safe
  end

  def link_to_ticket(ticket)
    contents = block_given? ? yield : format_ticket(ticket)
    if ticket.project
      link_to contents, ticket.ticket_tracker_ticket_url, target: "_blank", rel: "ticket", "data-number" => ticket.number, "data-project" => ticket.project.slug
    else
      contents
    end
  end

  def format_with_feature_bolded(message)
    feature = (message.match(/^([^\{:]+):/) || [])[1]
    if feature
      message = h(message[feature.length..-1])
      feature = "<b>#{h feature}</b>"
    end
    "#{feature}#{message}".html_safe
  end



  def format_antecedent(antecedent)
    case antecedent.kind
    when "Goldmine"; "Goldmine #{link_to_goldmine_case(antecedent.id)}".html_safe
    when "Errbit"; "Errbit #{link_to_err(antecedent.project, antecedent.id)}".html_safe
    end
  end

  def link_to_goldmine_case(number)
    link_to "##{number}", goldmine_case_number_url(number), target: "_blank"
  end



  MINUTE = 60
  HOUR = MINUTE * 60
  DAY = HOUR * 24

  def format_duration(seconds)
    if seconds < HOUR
      format_duration_with_units(seconds / MINUTE, 'minute')
    elsif seconds < DAY
      format_duration_with_units(seconds / HOUR, 'hour')
    else
      format_duration_with_units(seconds / DAY, 'day')
    end
  end

  def format_duration_with_units(quantity, unit)
    quantity = quantity.floor
    unit << 's' unless quantity == 1
    "#{quantity} #{unit}"
  end

  def class_for_age(seconds)
    if    seconds < 6.hours;        'infant'
    elsif seconds < 2.days;         'child'
    elsif seconds < 7.days;         'adult'
    elsif seconds < 4.weeks;        'senior'
    elsif seconds < 26.weeks;       'old'
    else                            'ancient'
    end
  end

end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
houston-core-0.6.3 app/helpers/ticket_helper.rb
houston-core-0.6.2 app/helpers/ticket_helper.rb
houston-core-0.6.1 app/helpers/ticket_helper.rb
houston-core-0.6.0 app/helpers/ticket_helper.rb
houston-core-0.5.6 app/helpers/ticket_helper.rb
houston-core-0.5.5 app/helpers/ticket_helper.rb
houston-core-0.5.4 app/helpers/ticket_helper.rb
houston-core-0.5.3 app/helpers/ticket_helper.rb
houston-core-0.5.2 app/helpers/ticket_helper.rb
houston-core-0.5.1 app/helpers/ticket_helper.rb
houston-core-0.5.0 app/helpers/ticket_helper.rb