Sha256: 5f099dbc8855704aa04d6a43a0db169f8fb54c445b898dbf901f328df02e2801
Contents?: true
Size: 967 Bytes
Versions: 1
Compression:
Stored size: 967 Bytes
Contents
class YouTrack::Parser::IssueParser attr_reader :raw def initialize(raw) @raw = raw end def parse_fields(fields) fields.inject({}) { |r, f| r.merge(f["name"] => f["value"]) } end 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
you_track-0.1.0 | lib/you_track/parser/issue_parser.rb |