Class: Puree::Project

Inherits:
Resource show all
Defined in:
lib/puree/project.rb

Overview

Project resource

Instance Attribute Summary

Attributes inherited from Resource

#response

Instance Method Summary collapse

Methods inherited from Resource

#content, #created, #get, #modified, #set_content, #uuid

Constructor Details

#initialize(endpoint: nil, username: nil, password: nil, basic_auth: nil) ⇒ Project

Returns a new instance of Project.

Parameters:

  • endpoint (String) (defaults to: nil)
  • optional

    username [String]

  • optional

    password [String]

  • optional

    basic_auth [Boolean]



11
12
13
14
15
16
17
18
# File 'lib/puree/project.rb', line 11

def initialize(endpoint: nil, username: nil, password: nil, basic_auth: nil)
  super(api: :project,
        endpoint: endpoint,
        username: username,
        password: password,
        bleeding: false,
        basic_auth: basic_auth)
end

Instance Method Details

#acronymString

Acronym

Returns:

  • (String)


25
26
27
28
# File 'lib/puree/project.rb', line 25

def acronym
  path = '/acronym'
  xpath_query_for_single_value path
end

#descriptionString

Description

Returns:

  • (String)


33
34
35
36
# File 'lib/puree/project.rb', line 33

def description
  path = '/description/localizedString'
  xpath_query_for_single_value path
end

#metadataHash

All metadata

Returns:

  • (Hash)


169
170
171
172
173
174
175
176
177
178
179
180
181
182
# File 'lib/puree/project.rb', line 169

def 
  o = super
  o['acronym'] = acronym
  o['description'] = description
  o['organisation'] = organisation
  o['owner'] = owner
  o['person'] = person
  o['status'] = status
  o['temporal'] = temporal
  o['title'] = title
  o['type'] = type
  o['url'] = url
  o
end

#organisationArray<Hash>

Organisation

Returns:

  • (Array<Hash>)


41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/puree/project.rb', line 41

def organisation
  path = '/organisations/association/organisation'
  xpath_result = xpath_query path
  data = []
  xpath_result.each do |i|
    o = {}
    o['uuid'] = i.xpath('@uuid').text.strip
    o['name'] = i.xpath('name/localizedString').text.strip
    o['type'] = i.xpath('typeClassification/term/localizedString').text.strip
    data << o
  end
  data
end

#ownerHash

Owner

Returns:

  • (Hash)


58
59
60
61
62
63
64
65
66
# File 'lib/puree/project.rb', line 58

def owner
  path = '/owner'
  xpath_result =  xpath_query path
  o = {}
  o['uuid'] = xpath_result.xpath('@uuid').text.strip
  o['name'] = xpath_result.xpath('name/localizedString').text.strip
  o['type'] = xpath_result.xpath('typeClassification/term/localizedString').text.strip
  o
end

#personArray<Hash>

Person (internal, external, other)

Returns:

  • (Array<Hash>)


71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/puree/project.rb', line 71

def person
  data = {}
  # internal
  path = '/persons/participantAssociation'
  xpath_result = xpath_query path
  internal = []
  external = []
  other = []

  xpath_result.each do |i|
    o = {}
    name = {}
    name['first'] = i.xpath('person/name/firstName').text.strip
    name['last'] = i.xpath('person/name/lastName').text.strip
    o['name'] = name
    o['role'] = i.xpath('personRole/term/localizedString').text.strip

    uuid_internal = i.at_xpath('person/@uuid')
    uuid_external = i.at_xpath('externalPerson/@uuid')
    if uuid_internal
      o['uuid'] = uuid_internal
      internal << o
    elsif uuid_external
      o['uuid'] = uuid_external
      external << o
    else
      other << o
      o['uuid'] = ''
    end
  end
  data['internal'] = internal
  data['external'] = external
  data['other'] = other
  data
end

#statusString

Status

Returns:

  • (String)


110
111
112
113
# File 'lib/puree/project.rb', line 110

def status
  path = '/status/term/localizedString'
  xpath_query_for_single_value path
end

#temporalHash

Temporal, expected and actual start and end dates as UTC datetime.

Returns:

  • (Hash)


118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/puree/project.rb', line 118

def temporal
  o = {}
  o['expected'] = {}
  o['actual'] = {}

  path = '/expectedStartDate'
  xpath_result =  xpath_query path
  o['expected']['start'] = xpath_result.text.strip

  path = '/expectedEndDate'
  xpath_result =  xpath_query path
  o['expected']['end'] = xpath_result.text.strip

  path = '/startFinishDate/startDate'
  xpath_result =  xpath_query path
  o['actual']['start'] = xpath_result.text.strip

  path = '/startFinishDate/endDate'
  xpath_result =  xpath_query path
  o['actual']['end'] = xpath_result.text.strip

  o
end

#titleString

Title

Returns:

  • (String)


145
146
147
148
# File 'lib/puree/project.rb', line 145

def title
  path = '/title/localizedString'
  xpath_query_for_single_value path
end

#typeString

Type

Returns:

  • (String)


153
154
155
156
# File 'lib/puree/project.rb', line 153

def type
  path = '/typeClassification/term/localizedString'
  xpath_query_for_single_value path
end

#urlString

URL

Returns:

  • (String)


161
162
163
164
# File 'lib/puree/project.rb', line 161

def url
  path = '/projectURL'
  xpath_query_for_single_value path
end