Class: YouTrack::Parser::ProjectsParser

Inherits:
Base
  • Object
show all
Defined in:
lib/you_track/parser/projects_parser.rb

Instance Attribute Summary

Attributes inherited from Base

#raw

Instance Method Summary collapse

Methods inherited from Base

#initialize, #parse_fields

Constructor Details

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

Instance Method Details

#parseObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/you_track/parser/projects_parser.rb', line 17

def parse
  return [] if raw["projects"].nil?
  results = raw["projects"]["project"].dup
  results = [results] if results.is_a?(Hash)
  results.each do |result|
         = result.delete("assigneesLogin")
    full_name = result.delete("assigneesFullName")
    versions  = result.delete("versions")

    result["assignees"] = parse_assignees(, full_name)
    result["versions"]  = parse_versions(versions)
  end

  results
end

#parse_assignees(login, full_name) ⇒ Object



2
3
4
5
6
7
8
9
10
# File 'lib/you_track/parser/projects_parser.rb', line 2

def parse_assignees(, full_name)
  return {} unless  && full_name
  ["sub"]     = [["sub"]] if ["sub"].is_a?(Hash)
  full_name["sub"] = [full_name["sub"]] if full_name["sub"].is_a?(Hash)
  ["sub"].each_with_index.inject({}) do |hash, (user,i)|
    hash[user["value"]] = full_name["sub"][i]["value"]
    hash
  end
end

#parse_versions(versions) ⇒ Object



12
13
14
15
# File 'lib/you_track/parser/projects_parser.rb', line 12

def parse_versions(versions)
  return [] unless versions
  Array(versions.gsub(/(^\[|\]$)/, '').split(', '))
end