Sha256: a12198abac6b3baaac4d50aa5644cda1f99f87b07b8c62b945cb512f477f46ba

Contents?: true

Size: 1018 Bytes

Versions: 9

Compression:

Stored size: 1018 Bytes

Contents

class YouTrack::Parser::ProjectsParser < YouTrack::Parser::Base
  def parse_assignees(login, full_name)
    return {} unless login && full_name
    login["sub"]     = [login["sub"]] if login["sub"].is_a?(Hash)
    full_name["sub"] = [full_name["sub"]] if full_name["sub"].is_a?(Hash)
    login["sub"].each_with_index.inject({}) do |hash, (user,i)|
      hash[user["value"]] = full_name["sub"][i]["value"]
      hash
    end
  end

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

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

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

    results
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
you_track-0.4.8 lib/you_track/parser/projects_parser.rb
you_track-0.4.7 lib/you_track/parser/projects_parser.rb
you_track-0.4.6 lib/you_track/parser/projects_parser.rb
you_track-0.4.5 lib/you_track/parser/projects_parser.rb
you_track-0.4.4 lib/you_track/parser/projects_parser.rb
you_track-0.4.2 lib/you_track/parser/projects_parser.rb
you_track-0.4.1 lib/you_track/parser/projects_parser.rb
you_track-0.4.0 lib/you_track/parser/projects_parser.rb
you_track-0.3.0 lib/you_track/parser/projects_parser.rb