Class: YouTrack::Parser::IssuesParser

Inherits:
IssueParser show all
Defined in:
lib/you_track/parser/issues_parser.rb

Instance Attribute Summary

Attributes inherited from Base

#raw

Instance Method Summary collapse

Methods inherited from IssueParser

#parse_attachments, #parse_user_fields

Methods inherited from Base

#initialize, #parse_fields

Constructor Details

This class inherits a constructor from YouTrack::Parser::Base

Instance Method Details

#parseObject



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/you_track/parser/issues_parser.rb', line 2

def parse
  return [] if raw["issues"].nil?      # i hate xml
  results = raw["issues"]["issue"].dup # i really hate xml
  results = [results] if results.is_a?(Hash)

  results.each do |result|
    fields = result.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

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

  results
end