Sha256: b4ce74a609cd6311779a5d8dfdeca95505aeb43c57d91841e2af9f699806c37c

Contents?: true

Size: 818 Bytes

Versions: 8

Compression:

Stored size: 818 Bytes

Contents

class YouTrack::Parser::IssueParser < YouTrack::Parser::Base
  def parse_attachments(attachments)
    attachments.inject([]) { |r, a|
      value = a["value"]
      r << {"id" => value["id"], "url" => value["url"], "content" => value["__content__"]}
    }
  end

  def parse
    results = raw["issue"].dup

    fields = results.delete("field")
    standard_fields = fields.select { |k| k["xsi:type"] == "SingleField" }
    fields = fields - standard_fields
    attachments = fields.select { |k| k["xsi:type"] == "AttachmentField" }
    custom_fields = fields - attachments

    results.merge!(parse_fields(standard_fields))
    results["custom_fields"] = parse_fields(custom_fields)
    results["attachments"] = parse_attachments(attachments)
    results["comments"] = results.delete("comment")

    results
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
you_track-0.4.4 lib/you_track/parser/issue_parser.rb
you_track-0.4.2 lib/you_track/parser/issue_parser.rb
you_track-0.4.1 lib/you_track/parser/issue_parser.rb
you_track-0.4.0 lib/you_track/parser/issue_parser.rb
you_track-0.3.0 lib/you_track/parser/issue_parser.rb
you_track-0.2.2 lib/you_track/parser/issue_parser.rb
you_track-0.2.1 lib/you_track/parser/issue_parser.rb
you_track-0.2.0 lib/you_track/parser/issue_parser.rb