jiraSOAP 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,772 +0,0 @@
1
- module JIRA
2
-
3
- # Represents a priority level. Straightforward.
4
- class Priority
5
- # @return [String]
6
- attr_accessor :id
7
- # @return [String]
8
- attr_accessor :name
9
- # @return [String] is a hex value
10
- attr_accessor :color
11
- # @return [URL] A NSURL on MacRuby and a URI::HTTP object in CRuby
12
- attr_accessor :icon
13
- # @return [String]
14
- attr_accessor :description
15
-
16
- # Factory method that takes a fragment of a SOAP response.
17
- # @todo change @color to be some kind of hex Fixnum object
18
- # @param [Handsoap::XmlQueryFront::NokogiriDriver] frag
19
- # @return [JIRA::Priority,nil]
20
- def self.priority_with_xml_fragment(frag)
21
- return if frag.nil?
22
- priority = Priority.new
23
- priority.id = frag.xpath('id').to_s
24
- priority.name = frag.xpath('name').to_s
25
- priority.color = frag.xpath('color').to_s
26
- priority.description = frag.xpath('description').to_s
27
- url = frag.xpath('icon').to_s
28
- priority.icon = URL.new url unless url.nil?
29
- priority
30
- end
31
- end
32
-
33
- # Represents a resolution. Straightforward.
34
- class Resolution
35
- # @return [String]
36
- attr_accessor :id
37
- # @return [String]
38
- attr_accessor :name
39
- # @return [URL] A NSURL on MacRuby and a URI::HTTP object in CRuby
40
- attr_accessor :icon
41
- # @return [String]
42
- attr_accessor :description
43
-
44
- # Factory method that takes a fragment of a SOAP response.
45
- # @param [Handsoap::XmlQueryFront::NokogiriDriver] frag
46
- # @return [JIRA::Resolution,nil]
47
- def self.resolution_with_xml_fragment(frag)
48
- return if frag.nil?
49
- resolution = Resolution.new
50
- resolution.id = frag.xpath('id').to_s
51
- resolution.name = frag.xpath('name').to_s
52
- resolution.description = frag.xpath('description').to_s
53
- url = frag.xpath('icon').to_s
54
- resolution.icon = url unless url.nil?
55
- resolution
56
- end
57
- end
58
-
59
- # Represents a field mapping.
60
- class Field
61
- # @return [String]
62
- attr_accessor :id
63
- # @return [String]
64
- attr_accessor :name
65
-
66
- # Factory method that takes a fragment of a SOAP response.
67
- # @param [Handsoap::XmlQueryFront::NokogiriDriver] frag
68
- # @return [JIRA::Field,nil]
69
- def self.field_with_xml_fragment(frag)
70
- return if frag.nil?
71
- field = Field.new
72
- field.id = frag.xpath('id').to_s
73
- field.name = frag.xpath('name').to_s
74
- field
75
- end
76
- end
77
-
78
- # Represents a custom field with values.
79
- # @todo see if @key is always nil from the server
80
- class CustomField
81
- # @return [String]
82
- attr_accessor :id
83
- # @return [String]
84
- attr_accessor :key
85
- # @return [[String]]
86
- attr_accessor :values
87
-
88
- # Factory method that takes a fragment of a SOAP response.
89
- # @param [Handsoap::XmlQueryFront::NokogiriDriver] frag
90
- # @return [JIRA::CustomField,nil]
91
- def self.custom_field_with_xml_fragment(frag)
92
- return if frag.nil?
93
- custom_field = CustomField.new
94
- custom_field.id = frag.xpath('customfieldId').to_s
95
- custom_field.key = frag.xpath('key').to_s
96
- custom_field.values = frag.xpath('values/*').map { |value| value.to_s }
97
- custom_field
98
- end
99
-
100
- # Generate a SOAP message fragment for the object.
101
- # @param [Handsoap::XmlMason::Node] msg SOAP message to add the object to
102
- # @param [String] label tag name used in wrapping tags
103
- # @return [Handsoap::XmlMason::Element]
104
- def soapify_for(msg, label = 'customFieldValues')
105
- msg.add label do |submsg|
106
- submsg.add 'customfieldId', @id
107
- submsg.add 'key', @key
108
- submsg.add_simple_array 'values', @values
109
- end
110
- end
111
- end
112
-
113
- # Represents and issue type. Straight forward.
114
- class IssueType
115
- # @return [String]
116
- attr_accessor :id
117
- # @return [String]
118
- attr_accessor :name
119
- # @return [URL]
120
- attr_accessor :icon
121
- # @return [String]
122
- attr_accessor :description
123
- # @return [boolean]
124
- attr_accessor :subtask
125
-
126
- # @return [boolean] true if the issue type is a subtask, otherwise false
127
- def subtask?; @subtask; end
128
-
129
- # Factory method that takes a fragment of a SOAP response.
130
- # @param [Handsoap::XmlQueryFront::NokogiriDriver] frag
131
- # @return [JIRA::IssueType,nil]
132
- def self.issue_type_with_xml_fragment(frag)
133
- return if frag.nil?
134
- issue_type = IssueType.new
135
- issue_type.id = frag.xpath('id').to_s
136
- issue_type.name = frag.xpath('name').to_s
137
- issue_type.subtask = frag.xpath('subTask').to_s == 'true'
138
- issue_type.description = frag.xpath('description').to_s
139
- url = frag.xpath('icon').to_s
140
- issue_type.icon = URL.new url unless url.nil?
141
- issue_type
142
- end
143
- end
144
-
145
- # Represents a comment. Straight forward.
146
- class Comment
147
- # @return [String]
148
- attr_accessor :id
149
- # @return [String]
150
- attr_accessor :original_author
151
- # @return [String]
152
- attr_accessor :role_level
153
- # @return [String]
154
- attr_accessor :group_level
155
- # @return [String]
156
- attr_accessor :body
157
- # @return [Time]
158
- attr_accessor :create_date
159
- # @return [Time]
160
- attr_accessor :last_updated
161
- # @return [String]
162
- attr_accessor :update_author
163
-
164
- # Factory method that takes a fragment of a SOAP response.
165
- # @param [Handsoap::XmlQueryFront::NokogiriDriver] frag
166
- # @return [JIRA::Comment,nil]
167
- def self.comment_with_xml_fragment(frag)
168
- return if frag.nil?
169
- comment = Comment.new
170
- comment.id = frag.xpath('id').to_s
171
- comment.original_author = frag.xpath('author').to_s
172
- comment.body = frag.xpath('body').to_s
173
- comment.group_level = frag.xpath('updateAuthor').to_s
174
- comment.role_level = frag.xpath('roleLevel').to_s
175
- comment.update_author = frag.xpath('updateAuthor').to_s
176
- date = frag.xpath('created').to_s
177
- comment.create_date = Time.xmlschema date unless date.nil?
178
- date = frag.xpath('updated').to_s
179
- comment.last_updated = Time.xmlschema date unless date.nil?
180
- comment
181
- end
182
-
183
- # @param [Handsoap::XmlMason::Node] msg
184
- # @return [Handsoap::XmlMason::Node]
185
- def soapify_for(msg)
186
- msg.add 'id', @id
187
- msg.add 'author', @original_author
188
- msg.add 'body', @body
189
- msg.add 'groupLevel', @group_level
190
- msg.add 'roleLevel', @role_level
191
- msg.add 'updateAuthor', @update_author
192
- end
193
- end
194
-
195
- # Represents a status. Straightforward.
196
- class Status
197
- # @return [String]
198
- attr_accessor :id
199
- # @return [String]
200
- attr_accessor :name
201
- # @return [URL]
202
- attr_accessor :icon
203
- # @return [String]
204
- attr_accessor :description
205
-
206
- # Factory method that takes a fragment of a SOAP response.
207
- # @param [Handsoap::XmlQueryFront::NokogiriDriver] frag
208
- # @return [JIRA::Status,nil]
209
- def self.status_with_xml_fragment(frag)
210
- return if frag.nil?
211
- status = Status.new
212
- status.id = frag.xpath('id').to_s
213
- status.name = frag.xpath('name').to_s
214
- status.description = frag.xpath('description').to_s
215
- url = frag.xpath('icon').to_s
216
- status.icon = URL.new url unless url.nil?
217
- status
218
- end
219
- end
220
-
221
- # Represents a version for a project. The description field is never
222
- # included when you retrieve versions from the server.
223
- # @todo find out why we don't get a description for this object
224
- class Version
225
- # @return [String]
226
- attr_accessor :id
227
- # @return [String]
228
- attr_accessor :name
229
- # @return [Fixnum]
230
- attr_accessor :sequence
231
- # @return [boolean]
232
- attr_accessor :released
233
- # @return [boolean]
234
- attr_accessor :archived
235
- # @return [Time]
236
- attr_accessor :release_date
237
-
238
- # @return [boolean] true if the version has been released, otherwise false
239
- def released?; @released; end
240
-
241
- # @return [boolean] true if the version has been archive, otherwise false
242
- def archived?; @archived; end
243
-
244
- # Factory method that takes a fragment of a SOAP response.
245
- # @param [Handsoap::XmlQueryFront::NokogiriDriver] frag
246
- # @return [JIRA::Status,nil]
247
- def self.version_with_xml_fragment(frag)
248
- return if frag.nil?
249
- version = Version.new
250
- version.id = frag.xpath('id').to_s
251
- version.name = frag.xpath('name').to_s
252
- version.sequence = frag.xpath('sequence').to_s.to_i
253
- version.released = frag.xpath('released').to_s == 'true'
254
- version.archived = frag.xpath('archived').to_s == 'true'
255
- date = frag.xpath('releaseDate').to_s
256
- version.release_date = Time.xmlschema date unless date.nil?
257
- version
258
- end
259
-
260
- # @param [Handsoap::XmlMason::Node] msg
261
- # @return [Handsoap::XmlMason::Node]
262
- def soapify_for(msg)
263
- msg.add 'name', @name
264
- msg.add 'sequence', @sequence unless @sequence.nil?
265
- msg.add 'releaseDate', @release_date.xmlschema unless @release_date.nil?
266
- msg.add 'released', @released
267
- end
268
- end
269
-
270
- # Represents a scheme used by the server. Not very useful for the sake of the
271
- # API; a more useful case might be if you wanted to emulate the server's
272
- # behaviour.
273
- class Scheme
274
- # @return [String]
275
- attr_accessor :id
276
- # @return [String]
277
- attr_accessor :name
278
- # @return [String]
279
- attr_accessor :type
280
- # @return [String]
281
- attr_accessor :description
282
-
283
- # Factory method that takes a fragment of a SOAP response.
284
- # @param [Handsoap::XmlQueryFront::NokogiriDriver] frag
285
- # @return [JIRA::Scheme,nil]
286
- def self.scheme_with_xml_fragment(frag)
287
- return if frag.nil?
288
- scheme = Scheme.new
289
- scheme.id = frag.xpath('id').to_s
290
- scheme.name = frag.xpath('name').to_s
291
- scheme.type = frag.xpath('type').to_s
292
- scheme.description = frag.xpath('description').to_s
293
- scheme
294
- end
295
- end
296
-
297
- class PermissionScheme < Scheme
298
- attr_accessor :permission_mappings
299
-
300
- def initialize(frag)
301
- return if frag.nil?
302
- # @todo pain the friggin ass to figure out
303
- end
304
- end
305
-
306
- # Represents a component description for a project. Straightforward.
307
- class Component
308
- # @return [String]
309
- attr_accessor :id
310
- # @return [String]
311
- attr_accessor :name
312
-
313
- # Factory method that takes a fragment of a SOAP response.
314
- # @param [Handsoap::XmlQueryFront::NokogiriDriver] frag
315
- # @return [JIRA::Component,nil]
316
- def self.component_with_xml_fragment(frag)
317
- return if frag.nil?
318
- component = Component.new
319
- component.id = frag.xpath('id').to_s
320
- component.name = frag.xpath('name').to_s
321
- component
322
- end
323
- end
324
-
325
- # Represents a project configuration. NOT straightforward.
326
- # You need to explicitly ask for schemes in order to get them. By
327
- # default, most project fetching methods purposely leave out all
328
- # the scheme information as permission schemes can be very large.
329
- class Project
330
- # @return [String]
331
- attr_accessor :id
332
- # @return [String]
333
- attr_accessor :name
334
- # @return [String]
335
- attr_accessor :key
336
- # @return [URL]
337
- attr_accessor :url
338
- # @return [URL]
339
- attr_accessor :project_url
340
- # @return [String]
341
- attr_accessor :lead
342
- # @return [String]
343
- attr_accessor :description
344
- # @return [JIRA::Scheme]
345
- attr_accessor :issue_security_scheme
346
- # @return [JIRA::Scheme]
347
- attr_accessor :notification_scheme
348
- # @return [JIRA::PermissionScheme]
349
- attr_accessor :permission_scheme
350
-
351
- # Factory method that takes a fragment of a SOAP response.
352
- # @param [Handsoap::XmlQueryFront::NokogiriDriver] frag
353
- # @return [JIRA::Project,nil]
354
- def self.project_with_xml_fragment(frag)
355
- return if frag.nil?
356
- project = Project.new
357
- project.id = frag.xpath('id').to_s
358
- project.name = frag.xpath('name').to_s
359
- project.key = frag.xpath('key').to_s
360
- project.lead = frag.xpath('lead').to_s
361
- project.description = frag.xpath('description').to_s
362
- project.issue_security_scheme =
363
- Scheme.scheme_with_xml_fragment frag.xpath 'issueSecurityScheme'
364
- project.notification_scheme =
365
- Scheme.scheme_with_xml_fragment frag.xpath 'notificationScheme'
366
- project.permission_scheme =
367
- PermissionScheme.scheme_with_xml_fragment frag.xpath 'permissionScheme'
368
- url = frag.xpath('url').to_s
369
- project.url = URL.new url unless url.nil?
370
- url = frag.xpath('projectUrl').to_s
371
- project.project_url = URL.new url unless url.nil?
372
- project
373
- end
374
-
375
- # @todo encode the schemes
376
- # @param [Handsoap::XmlMason::Node] msg
377
- # @return [Handsoap::XmlMason::Node]
378
- def soapify_for(msg)
379
- msg.add 'id', @id
380
- msg.add 'name', @name
381
- msg.add 'key', @key
382
- msg.add 'url', @url
383
- msg.add 'projectUrl', @project_url
384
- msg.add 'lead', @lead
385
- msg.add 'description', @description
386
- end
387
- end
388
-
389
- # Contains a base64 encoded avatar image and some metadata. Straightforward.
390
- class Avatar
391
- # @return [String]
392
- attr_accessor :id
393
- # @return [String]
394
- attr_accessor :owner
395
- # @return [String]
396
- attr_accessor :type
397
- # @return [String]
398
- attr_accessor :content_type
399
- # @return [String]
400
- attr_accessor :base64_data
401
- # @return [boolean] indicates if the image is the system default
402
- attr_accessor :system
403
-
404
- # @return [boolean] true if avatar is the default system avatar, else false
405
- def system?; @system; end
406
-
407
- # Factory method that takes a fragment of a SOAP response.
408
- # @param [Handsoap::XmlQueryFront::NokogiriDriver] frag
409
- # @return [JIRA::Avatar,nil]
410
- def self.avatar_with_xml_fragment(frag)
411
- return if frag.nil?
412
- avatar = Avatar.new
413
- avatar.id = frag.xpath('id').to_s
414
- avatar.owner = frag.xpath('owner').to_s
415
- avatar.system = frag.xpath('system').to_s == 'true'
416
- avatar.type = frag.xpath('type').to_s
417
- avatar.content_type = frag.xpath('contentType').to_s
418
- avatar.base64_data = frag.xpath('base64Data').to_s
419
- avatar
420
- end
421
- end
422
-
423
- # Represents a JIRA issue; easily the most convoluted structure in the API.
424
- # This structure and anything related directly to it will most likely be the
425
- # greatest source of bugs.
426
- #
427
- # The irony of the situation is that this structure is also the most critical
428
- # to have in working order.
429
- #
430
- # Issues with an UNRESOLVED status will have nil for the value of @resolution.
431
- class Issue
432
- # @return [String]
433
- attr_accessor :id
434
- # @return [String]
435
- attr_accessor :key
436
- # @return [String]
437
- attr_accessor :summary
438
- # @return [String]
439
- attr_accessor :description
440
- # @return [String]
441
- attr_accessor :type_id
442
- # @return [Time]
443
- attr_accessor :last_updated
444
- # @return [Fixnum]
445
- attr_accessor :votes
446
- # @return [String]
447
- attr_accessor :status_id
448
- # @return [String]
449
- attr_accessor :assignee_name
450
- # @return [String]
451
- attr_accessor :reporter_name
452
- # @return [String]
453
- attr_accessor :priority_id
454
- # @return [String]
455
- attr_accessor :project_name
456
- # @return [[JIRA::Version]]
457
- attr_accessor :affects_versions
458
- # @return [Time]
459
- attr_accessor :create_date
460
- # @return [Time]
461
- attr_accessor :due_date
462
- # @return [[JIRA::Version]]
463
- attr_accessor :fix_versions
464
- # @return [String]
465
- attr_accessor :resolution_id
466
- # @return [String]
467
- attr_accessor :environment
468
- # @return [[JIRA::Component]]
469
- attr_accessor :components
470
- # @return [[String]]
471
- attr_accessor :attachment_names
472
- # @return [[JIRA::CustomField]]
473
- attr_accessor :custom_field_values
474
-
475
- # Factory method that takes a fragment of a SOAP response.
476
- # @param [Handsoap::XmlQueryFront::NokogiriDriver] frag
477
- # @return [JIRA::Issue,nil]
478
- def self.issue_with_xml_fragment(frag)
479
- return if frag.nil?
480
- issue = Issue.new
481
- issue.affects_versions = frag.xpath('affectsVersions/*').map { |frag|
482
- Version.version_with_xml_fragment frag
483
- }
484
- issue.fix_versions = frag.xpath('fixVersions/*').map { |frag|
485
- Version.version_with_xml_fragment frag
486
- }
487
- issue.components = frag.xpath('components/*').map { |frag|
488
- Component.component_with_xml_fragment frag
489
- }
490
- issue.custom_field_values = frag.xpath('customFieldValues/*').map { |frag|
491
- CustomField.custom_field_with_xml_fragment frag
492
- }
493
- issue.attachment_names = frag.xpath('attachmentNames/*').map { |name|
494
- name.to_s
495
- }
496
- issue.id = frag.xpath('id').to_s
497
- issue.key = frag.xpath('key').to_s
498
- issue.summary = frag.xpath('summary').to_s
499
- issue.description = frag.xpath('description').to_s
500
- issue.type_id = frag.xpath('type').to_s
501
- issue.votes = frag.xpath('votes').to_s.to_i
502
- issue.status_id = frag.xpath('status').to_s
503
- issue.assignee_name = frag.xpath('assignee').to_s
504
- issue.reporter_name = frag.xpath('reporter').to_s
505
- issue.priority_id = frag.xpath('priority').to_s
506
- issue.project_name = frag.xpath('project').to_s
507
- issue.resolution_id = frag.xpath('resolution').to_s
508
- issue.environment = frag.xpath('environment').to_s
509
- date = frag.xpath('updated').to_s
510
- issue.last_updated = Time.xmlschema date unless date.nil?
511
- date = frag.xpath('updated').to_s
512
- issue.create_date = Time.xmlschema date unless date.nil?
513
- date = frag.xpath('updated').to_s
514
- issue.due_date = Time.xmlschema date unless date.nil?
515
- issue
516
- end
517
-
518
- # Generate the SOAP message fragment for an issue. Can you spot the oddities
519
- # and inconsistencies? (hint: there are many).
520
- #
521
- # We don't bother including fields that are ignored. I tried to only
522
- # ignore fields that will never be needed at creation time, but I may have
523
- # messed up.
524
- #
525
- # We don't wrap the whole thing in 'issue' tags for
526
- # {#RemoteAPI#create_issue_with_issue} calls; this is an inconsistency in the
527
- # way jiraSOAP works and may need to be worked around for other {RemoteAPI}
528
- # methods.
529
- #
530
- # Servers only seem to accept issues if components/versions are just ids
531
- # and do not contain the rest of the {JIRA::Component}/{JIRA::Version}
532
- # structure.
533
- #
534
- # To get the automatic assignee we pass '-1' as the value for @assignee.
535
- #
536
- # Passing an environment/due date field with a value of nil causes the
537
- # server to complain about the formatting of the message.
538
- # @param [Handsoap::XmlMason::Node] msg message the node to add the object to
539
- def soapify_for(msg)
540
- #might be going away, since it appears to have no effect at creation time
541
- msg.add 'reporter', @reporter_name unless @reporter.nil?
542
-
543
- msg.add 'priority', @priority_id
544
- msg.add 'type', @type_id
545
- msg.add 'project', @project_name
546
-
547
- msg.add 'summary', @summary
548
- msg.add 'description', @description
549
-
550
- msg.add 'components' do |submsg|
551
- (@components || []).each { |component|
552
- submsg.add 'components' do |component_msg|
553
- component_msg.add 'id', component.id
554
- end
555
- }
556
- end
557
- msg.add 'affectsVersions' do |submsg|
558
- (@affects_versions || []).each { |version|
559
- submsg.add 'affectsVersions' do |version_msg|
560
- version_msg.add 'id', version.id
561
- end
562
- }
563
- end
564
- msg.add 'fixVersions' do |submsg|
565
- (@fix_versions || []).each { |version|
566
- submsg.add 'fixVersions' do |version_msg|
567
- version_msg.add 'id', version.id end
568
- }
569
- end
570
-
571
- msg.add 'assignee', (@assignee_name || '-1')
572
- msg.add_complex_array 'customFieldValues', (@custom_field_values || [])
573
-
574
- msg.add 'environment', @environment unless @environment.nil?
575
- msg.add 'duedate', @due_date.xmlschema unless @due_date.nil?
576
- end
577
- end
578
-
579
- # Contains the basic information about a user. Straightforward.
580
- class User
581
- # @return [String]
582
- attr_accessor :name
583
- # @return [String]
584
- attr_accessor :full_name
585
- # @return [String]
586
- attr_accessor :email
587
-
588
- # Factory method that takes a fragment of a SOAP response.
589
- # @param [Handsoap::XmlQueryFront::NokogiriDriver] frag
590
- # @return [JIRA::User,nil]
591
- def self.user_with_xml_fragment(frag)
592
- return if frag.nil?
593
- user = User.new
594
- user.name = frag.xpath('name').to_s
595
- user.full_name = frag.xpath('fullname').to_s
596
- user.email = frag.xpath('email').to_s
597
- user
598
- end
599
- end
600
-
601
- # A structure that is a bit of a hack. It is essentially just a key-value pair
602
- # that is used mainly by {RemoteAPI#update_issue}.
603
- class FieldValue
604
- # @return [String]
605
- attr_accessor :id
606
- # @return [[String,Time,URL,JIRA::*,nil]] hard to say what the type should be
607
- attr_accessor :values
608
-
609
- # Factory method that gives you a nil value for the given id.
610
- # @param [String] id name of the field for @values
611
- # @return [JIRA::FieldValue] Will always have @values = [nil]
612
- def self.field_value_with_nil_values(id)
613
- fv = FieldValue.new
614
- fv.id = id
615
- fv.values = [nil]
616
- fv
617
- end
618
-
619
- # Generate the SOAP message fragment for a field value.
620
- # @param [Handsoap::XmlMason::Node] message the node to add the object to
621
- # @param [String] label name for the tags that wrap the message
622
- # @return [Handsoap::XmlMason::Element]
623
- def soapify_for(message, label = 'fieldValue')
624
- message.add label do |message|
625
- message.add 'id', @id
626
- message.add_simple_array 'values', @values
627
- end
628
- end
629
- end
630
-
631
- # Only contains the meta-data for an attachment. The URI for an attachment
632
- # appears to be of the form
633
- # $ENDPOINT_URL/secure/attachment/$ATTACHMENT_ID/$ATTACHMENT_FILENAME
634
- class AttachmentMetadata
635
- # @return [String]
636
- attr_accessor :id
637
- # @return [String]
638
- attr_accessor :author
639
- # @return [Time]
640
- attr_accessor :create_date
641
- # @return [String]
642
- attr_accessor :filename
643
- # @return [Fixnum] measured in @todo units
644
- attr_accessor :file_size
645
- # @return [String]
646
- attr_accessor :mime_type
647
-
648
- # Factory method that takes a fragment of a SOAP response.
649
- # @param [Handsoap::XmlQueryFront::NokogiriDriver] frag
650
- # @return [JIRA::Attachment,nil]
651
- def self.attachment_with_xml_fragment(frag)
652
- return if frag.nil?
653
- attachment = AttachmentMetadata.new
654
- attachment.id = frag.xpath('id').to_s
655
- attachment.author = frag.xpath('author').to_s
656
- attachment.filename = frag.xpath('filename').to_s
657
- attachment.file_size = frag.xpath('filesize').to_s.to_i
658
- attachment.mime_type = frag.xpath('mimetype').to_s
659
- date = frag.xpath('created').to_s
660
- attachment.create_date = Time.xmlschema date unless date.nil?
661
- attachment
662
- end
663
- end
664
-
665
- # Only contains basic information about the endpoint server.
666
- # @todo turn attributes back to read-only by not using a factory for init
667
- class ServerInfo
668
- # @return [URL]
669
- attr_accessor :base_url
670
- # @return [Time]
671
- attr_accessor :build_date
672
- # @return [Fixnum]
673
- attr_accessor :build_number
674
- # @return [String]
675
- attr_accessor :edition
676
- # @return [JIRA::TimeInfo]
677
- attr_accessor :server_time
678
- # @return [String]
679
- attr_accessor :version
680
-
681
- # Factory method that takes a fragment of a SOAP response.
682
- # @param [Handsoap::XmlQueryFront::NokogiriDriver] frag
683
- # @return [JIRA::ServerInfo,nil]
684
- def self.server_info_with_xml_fragment(frag)
685
- return if frag.nil?
686
- server_info = ServerInfo.new
687
- server_info.build_number = frag.xpath('buildNumber').to_s.to_i
688
- server_info.edition = frag.xpath('edition').to_s
689
- server_info.version = frag.xpath('version').to_s
690
- date = frag.xpath('buildDate').to_s
691
- server_info.build_date = Time.xmlschema date unless date.nil?
692
- server_info.server_time =
693
- TimeInfo.time_info_with_xml_fragment frag.xpath 'serverTime'
694
- url = frag.xpath('baseUrl').to_s
695
- server_info.base_url = URL.new url unless url.nil?
696
- server_info
697
- end
698
- end
699
-
700
- # Simple structure for a time and time zone; used oddly.
701
- # The only place this structure is used is when #get_server_info is called.
702
- # @todo turn attributes back to read-only by not using a factory for init
703
- class TimeInfo
704
- # @return [Time]
705
- attr_accessor :server_time
706
- # @return [String]
707
- attr_accessor :timezone
708
-
709
- # Factory method that takes a fragment of a SOAP response.
710
- # @param [Handsoap::XmlQueryFront::NokogiriDriver] frag
711
- # @return [JIRA::TimeInfo,nil]
712
- def self.time_info_with_xml_fragment(frag)
713
- return if frag.nil?
714
- time_info = TimeInfo.new
715
- time_info.server_time = Time.parse frag.xpath('serverTime').to_s
716
- time_info.timezone = frag.xpath('timeZoneId').to_s
717
- time_info
718
- end
719
- end
720
-
721
- # Represents a filter
722
- # @todo find out what @project is supposed to be for
723
- class Filter
724
- # @return [String]
725
- attr_accessor :id
726
- # @return [String]
727
- attr_accessor :name
728
- # @return [String]
729
- attr_accessor :author
730
- # @return [String]
731
- attr_accessor :project
732
- # @return [String]
733
- attr_accessor :description
734
- # @return [nil]
735
- attr_accessor :xml
736
-
737
- # Factory method that takes a fragment of a SOAP response.
738
- # @param [Handsoap::XmlQueryFront::NokogiriDriver] frag
739
- # @return [JIRA::Filter,nil]
740
- def self.filter_with_xml_fragment(frag)
741
- return if frag.nil?
742
- filter = Filter.new
743
- filter.id = frag.xpath('id').to_s
744
- filter.name = frag.xpath('name').to_s
745
- filter.author = frag.xpath('author').to_s
746
- filter.project = frag.xpath('project').to_s
747
- filter.description = frag.xpath('description').to_s
748
- filter.xml = frag.xpath('xml').to_s
749
- filter
750
- end
751
- end
752
-
753
- # @todo documentation for this class
754
- # @todo write a boolean accessor macro
755
- class ServerConfiguration
756
- attr_reader :time_tracking_hours_per_day, :time_tracking_hours_per_week
757
-
758
- def watching_allowed?; @watching_allowed; end
759
- def voting_allowed?; @voting_allowed; end
760
- def unassigned_issues_allowed?; @unassigned_issues_allowed; end
761
- def time_tracking_allowed?; @time_tracking_allowed; end
762
- def subtasks_allowed?; @subtasks_allowed; end
763
- def issue_linking_allowed?; @issue_linking_allowed; end
764
- def eternal_user_management_allowed?; @external_user_management; end
765
- def attachments_allowed?; @attachments_allowed; end
766
-
767
- def initialize(frag = nil)
768
- return if frag.nil?
769
- end
770
- end
771
-
772
- end