jiraSOAP 0.7.1 → 0.8.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.
Files changed (66) hide show
  1. data/.yardopts +2 -3
  2. data/ChangeLog +15 -0
  3. data/LICENSE.txt +1 -1
  4. data/README.markdown +51 -41
  5. data/Rakefile +57 -0
  6. data/docs/GettingStarted.markdown +36 -0
  7. data/lib/jiraSOAP.rb +7 -4
  8. data/lib/jiraSOAP/api.rb +59 -53
  9. data/lib/jiraSOAP/api/additions.rb +4 -6
  10. data/lib/jiraSOAP/api/attachments.rb +18 -8
  11. data/lib/jiraSOAP/api/avatars.rb +30 -17
  12. data/lib/jiraSOAP/api/comments.rb +16 -11
  13. data/lib/jiraSOAP/api/filters.rb +13 -10
  14. data/lib/jiraSOAP/api/issue_data_types.rb +29 -21
  15. data/lib/jiraSOAP/api/issues.rb +46 -31
  16. data/lib/jiraSOAP/api/project_roles.rb +22 -15
  17. data/lib/jiraSOAP/api/projects.rb +33 -20
  18. data/lib/jiraSOAP/api/schemes.rb +9 -9
  19. data/lib/jiraSOAP/api/server_info.rb +11 -9
  20. data/lib/jiraSOAP/api/users.rb +58 -10
  21. data/lib/jiraSOAP/api/versions.rb +15 -11
  22. data/lib/jiraSOAP/api/worklog.rb +14 -0
  23. data/lib/jiraSOAP/core_extensions.rb +8 -0
  24. data/lib/jiraSOAP/entities.rb +3 -0
  25. data/lib/jiraSOAP/entities/attachment_metadata.rb +28 -9
  26. data/lib/jiraSOAP/entities/avatar.rb +29 -10
  27. data/lib/jiraSOAP/entities/comment.rb +37 -11
  28. data/lib/jiraSOAP/entities/component.rb +1 -1
  29. data/lib/jiraSOAP/entities/custom_field_value.rb +17 -12
  30. data/lib/jiraSOAP/entities/described_entity.rb +9 -5
  31. data/lib/jiraSOAP/entities/dynamic_entity.rb +12 -5
  32. data/lib/jiraSOAP/entities/entity.rb +33 -27
  33. data/lib/jiraSOAP/entities/field.rb +1 -1
  34. data/lib/jiraSOAP/entities/field_value.rb +16 -6
  35. data/lib/jiraSOAP/entities/filter.rb +18 -5
  36. data/lib/jiraSOAP/entities/issue.rb +74 -29
  37. data/lib/jiraSOAP/entities/issue_property.rb +9 -6
  38. data/lib/jiraSOAP/entities/issue_security_scheme.rb +1 -1
  39. data/lib/jiraSOAP/entities/issue_type.rb +9 -4
  40. data/lib/jiraSOAP/entities/named_entity.rb +8 -4
  41. data/lib/jiraSOAP/entities/notification_scheme.rb +1 -1
  42. data/lib/jiraSOAP/entities/permission.rb +14 -6
  43. data/lib/jiraSOAP/entities/permission_mapping.rb +9 -5
  44. data/lib/jiraSOAP/entities/permission_scheme.rb +7 -4
  45. data/lib/jiraSOAP/entities/priority.rb +7 -4
  46. data/lib/jiraSOAP/entities/project.rb +29 -13
  47. data/lib/jiraSOAP/entities/project_role.rb +3 -2
  48. data/lib/jiraSOAP/entities/resolution.rb +1 -1
  49. data/lib/jiraSOAP/entities/scheme.rb +5 -1
  50. data/lib/jiraSOAP/entities/server_configuration.rb +39 -14
  51. data/lib/jiraSOAP/entities/server_info.rb +20 -8
  52. data/lib/jiraSOAP/entities/status.rb +1 -1
  53. data/lib/jiraSOAP/entities/time_info.rb +12 -5
  54. data/lib/jiraSOAP/entities/user.rb +8 -4
  55. data/lib/jiraSOAP/entities/usergroup.rb +15 -0
  56. data/lib/jiraSOAP/entities/username.rb +7 -1
  57. data/lib/jiraSOAP/entities/version.rb +20 -12
  58. data/lib/jiraSOAP/entities/worklog.rb +28 -0
  59. data/lib/jiraSOAP/handsoap_extensions.rb +31 -80
  60. data/lib/jiraSOAP/{JIRAservice.rb → jira_service.rb} +19 -14
  61. data/lib/jiraSOAP/{macruby_bonuses.rb → macruby_extensions.rb} +5 -14
  62. data/lib/jiraSOAP/nokogiri_extensions.rb +68 -0
  63. data/lib/jiraSOAP/url.rb +10 -2
  64. data/lib/jiraSOAP/version.rb +3 -0
  65. metadata +29 -55
  66. data/yard-jiraSOAP.rb +0 -65
@@ -1,14 +1,33 @@
1
+ ##
1
2
  # @todo find out what the id value of @owner relates to
3
+ #
2
4
  # Contains a base64 encoded avatar image and metadata about the avatar.
3
5
  class JIRA::Avatar < JIRA::DynamicEntity
4
- add_attributes(
5
- # This seems to be an id ref to some other object
6
- ['owner', :owner, :to_s],
7
- # The place where the avatar is used (e.g. 'project')
8
- ['type', :type, :to_s],
9
- ['contentType', :mime_type, :to_s],
10
- ['base64Data', :base64_data, :to_s],
11
- # Indicates if the image is the system default
12
- ['system', :system, :to_boolean]
13
- )
6
+
7
+ ##
8
+ # This seems to be an id ref to some other object
9
+ #
10
+ # @return [String]
11
+ add_attribute :owner, 'owner', :content
12
+
13
+ ##
14
+ # The place where the avatar is used (e.g. 'project')
15
+ #
16
+ # @return [String]
17
+ add_attribute :type, 'type', :content
18
+
19
+ # @return [String]
20
+ add_attribute :mime_type, 'contentType', :content
21
+ alias_method :content_type, :mime_type
22
+
23
+ # @return [String]
24
+ add_attribute :base64_data, 'base64Data', :content
25
+ alias_method :data, :base64_data
26
+
27
+ ##
28
+ # Indicates if the image is the system default
29
+ #
30
+ # @return [Boolean]
31
+ add_attribute :system, 'system', :to_boolean
32
+
14
33
  end
@@ -1,18 +1,43 @@
1
+ ##
1
2
  # Contains a comment's body and metadata.
2
3
  class JIRA::Comment < JIRA::DynamicEntity
3
- add_attributes(
4
- # A username
5
- ['author', :author, :to_s],
6
- ['body', :body, :to_s],
7
- ['groupLevel', :group_level, :to_s],
8
- ['roleLevel', :role_level, :to_s],
9
- # A username
10
- ['updateAuthor', :update_author, :to_s],
11
- ['created', :create_time, :to_date],
12
- ['updated', :last_updated_time, :to_date]
13
- )
14
4
 
5
+ ##
6
+ # A username
7
+ #
8
+ # @return [String]
9
+ add_attribute :author, 'author', :content
10
+
11
+ # @return [String]
12
+ add_attribute :body, 'body', :content
13
+
14
+ # @return [String]
15
+ add_attribute :group_level, 'groupLevel', :content
16
+
17
+ # @return [String]
18
+ add_attribute :role_level, 'roleLevel', :content
19
+
20
+ ##
21
+ # A username
22
+ #
23
+ # @return [String]
24
+ add_attribute :update_author, 'updateAuthor', :content
25
+
26
+ # @return [Time]
27
+ add_attribute :create_time, 'created', :to_iso_date
28
+
29
+ # @return [Time]
30
+ add_attribute :last_updated_time, 'updated', :to_iso_date
31
+
32
+ ##
33
+ # Add a created comment to an issue
34
+ def add_to issue_key
35
+ raise NotImplementedError, 'Please implement me. :('
36
+ end
37
+
38
+ ##
15
39
  # @todo make this method shorter
40
+ #
16
41
  # @param [Handsoap::XmlMason::Node] msg
17
42
  # @return [Handsoap::XmlMason::Node]
18
43
  def soapify_for(msg)
@@ -23,4 +48,5 @@ class JIRA::Comment < JIRA::DynamicEntity
23
48
  msg.add 'roleLevel', @role_level
24
49
  msg.add 'updateAuthor', @update_author
25
50
  end
51
+
26
52
  end
@@ -1,5 +1,5 @@
1
+ ##
1
2
  # Represents a component name and id only. It does not include the component
2
3
  # lead.
3
4
  class JIRA::Component < JIRA::NamedEntity
4
- add_attributes
5
5
  end
@@ -1,19 +1,23 @@
1
- # @todo see if @key is always nil from the server, maybe we can remove it
2
- # Represents an instance of a custom field (with values). This object is used
3
- # as a member of {JIRA::Issue} objects.
1
+ ##
2
+ # @note There are no API methods that directly create objects of this class,
3
+ # they are only created as an attribute of {JIRA::Issue} objects.
4
+ # @todo See if @key is always nil from the server, maybe we can remove it
4
5
  #
5
- # The structure of this class resembles JIRA::FieldValue, it is different
6
- # in that @values will always be stored as an Array of String objects for
7
- # custom fields and a field value is more flexible. You can expect the classes
8
- # to merge in the near future.
6
+ # Represents an instance of a custom field (with values).
9
7
  class JIRA::CustomFieldValue < JIRA::DynamicEntity
10
- add_attributes(
11
- ['customfieldId', :id, :to_s],
12
- ['key', :key, :to_s],
13
- ['values', :values, :to_ss]
14
- )
15
8
 
9
+ # @return [String]
10
+ add_attribute :id, 'customfieldId', :content
11
+
12
+ # @return [String]
13
+ add_attribute :key, 'key', :content
14
+
15
+ # @return [Array<String>]
16
+ add_attribute :values, 'values', :contents_of_children
17
+
18
+ ##
16
19
  # Generate a SOAP message fragment for the object.
20
+ #
17
21
  # @param [Handsoap::XmlMason::Node] msg SOAP message to add the object to
18
22
  # @param [String] label tag name used in wrapping tags
19
23
  # @return [Handsoap::XmlMason::Element]
@@ -24,4 +28,5 @@ class JIRA::CustomFieldValue < JIRA::DynamicEntity
24
28
  submsg.add_simple_array 'values', @values
25
29
  end
26
30
  end
31
+
27
32
  end
@@ -1,7 +1,11 @@
1
- # @abstract Some named entities have a short description
1
+ ##
2
+ # @abstract A named entity that also has a short description
2
3
  class JIRA::DescribedEntity < JIRA::NamedEntity
3
- add_attributes(
4
- # A short blurb.
5
- ['description', :description, :to_s]
6
- )
4
+
5
+ ##
6
+ # A short blurb
7
+ #
8
+ # @return [String]
9
+ add_attribute :description, 'description', :content
10
+
7
11
  end
@@ -1,8 +1,15 @@
1
+ ##
1
2
  # @abstract Anything that can be configured has an id field.
2
3
  class JIRA::DynamicEntity < JIRA::Entity
3
- add_attributes(
4
- # Usually a numerical value, but sometimes prefixed with a
5
- # string (e.g. '12450' or 'customfield_10000')
6
- ['id', :id, :to_s]
7
- )
4
+
5
+ ##
6
+ # Usually a numerical value, but sometimes prefixed with a string
7
+ #
8
+ # @example
9
+ # '12450'
10
+ # 'customfield_10000'
11
+ #
12
+ # @return [String]
13
+ add_attribute :id, 'id', :content
14
+
8
15
  end
@@ -1,24 +1,42 @@
1
+ ##
1
2
  # @abstract The base class for all JIRA objects that can given by the server.
2
3
  class JIRA::Entity
3
4
 
4
5
  class << self
5
6
 
6
- # @return [Hash{String=>Array<Symbol,Symbol,Class*>}] used by the
7
- # metaclass for parsing XML
7
+ # @return [Hash{String=>Array(Symbol,Symbol,Class*)}] used for parsing XML
8
8
  attr_accessor :parse
9
9
 
10
- # @param [Array<String,Symbol,Class>] attributes
10
+ ##
11
+ # Define the callback to automatically initialize the build and parse
12
+ # tables when any subclass is defined.
13
+ def inherited subclass
14
+ subclass.parse = @parse.dup
15
+ end
16
+
17
+ ##
18
+ # @todo Add a way to signify if an attribute should not be used in
19
+ # message building, as some attributes should never be included
20
+ # in a SOAP message.
21
+ #
22
+ # Define a single instance attribute on the class including the
23
+ # specification on how to parse the XML output and how to build
24
+ # SOAP messages.
25
+ #
26
+ # Predicate methods will automatically be created if the transformer
27
+ # method is `:to_boolean`.
28
+ #
29
+ # @param [Symbol] name name of the attribute to create
30
+ # @param [String] jira_name name of the XML tag to look for when
31
+ # parsing responses from the server
32
+ # @param [Symbol,Array(Symbol,Class)] transformer either the method
33
+ # name to transform some XML contents, or the method name and the
34
+ # class to build from the attribute
11
35
  # @return [nil]
12
- def add_attributes *attributes
13
- superclass = ancestors[1]
14
- @parse = superclass.parse.dup
15
-
16
- attributes.each { |attribute|
17
- attr_accessor attribute[1]
18
- @parse[attribute[0]] = [:"#{attribute[1]}=", *attribute[2,2]]
19
- alias_method :"#{attribute[1]}?", attribute[1] if attribute[2] == :to_boolean
20
- #" ruby-mode parse fail
21
- }
36
+ def add_attribute name, jira_name, transformer
37
+ attr_accessor name
38
+ alias_method "#{name}?", name if transformer == :to_boolean
39
+ @parse[jira_name] = [:"#{name}=", *transformer]
22
40
  end
23
41
 
24
42
  end
@@ -33,26 +51,14 @@ class JIRA::Entity
33
51
  entity
34
52
  end
35
53
 
36
- # @todo put debug message through the logger
37
- # @todo make this faster by cutting out NokogiriDriver,
38
- # but I will need to add an accessor for @element of the
39
- # driver object and then need to inject the marshaling
40
- # methods into Nokogiri classes
41
- # @param [Handsoap::XmlQueryFront::NokogiriDriver] frag
54
+ # @param [Nokogiri::XML::Element] element
42
55
  def initialize_with_xml frag
43
56
  attributes = self.class.parse
44
57
  frag.children.each { |node|
45
- action = attributes[node.node_name]
58
+ action = attributes[node.name]
46
59
  self.send action[0], (node.send *action[1..-1]) if action
47
60
  #puts "Action is #{action.inspect} for #{node.node_name}"
48
61
  }
49
62
  end
50
63
 
51
- # @todo #soapify_for should become #to_soap and should take only the
52
- # optional argument for wrapper name, otherwise just makes its own
53
- # own node with appropriate subnodes and returns that as a Handsoap
54
- # document
55
- def to_soap node_name = nil
56
- raise NotImplementedError
57
- end
58
64
  end
@@ -1,4 +1,4 @@
1
+ ##
1
2
  # Represents a field mapping.
2
3
  class JIRA::Field < JIRA::NamedEntity
3
- add_attributes
4
4
  end
@@ -1,18 +1,27 @@
1
- # A structure that is a bit of a hack; it is just a key-value pair that
2
- # is used by {RemoteAPI#update_issue}.
1
+ ##
2
+ # This class is a bit of a hack; it is really just a key-value pair and only
3
+ # used with {RemoteAPI#update_issue}.
3
4
  class JIRA::FieldValue
4
5
 
5
- # @return [String] the name for regular fields, and the id for custom fields
6
+ ##
7
+ # The name for regular fields, and the id for custom fields
8
+ #
9
+ # @return [String]
6
10
  attr_accessor :field_name
7
11
 
8
- # @return [Array(#to_s)] an array for the values, usually a single
12
+ ##
13
+ # An array for the values, usually only has one object
14
+ #
15
+ # @return [Array<#to_s>]
9
16
  attr_accessor :values
10
17
 
11
18
  # @param [String] field_name
12
19
  # @param [Array] values
13
- def initialize(field_name = nil, values = nil)
20
+ def initialize field_name = nil, values = nil
14
21
  @field_name = field_name
15
- @values = values
22
+ if values
23
+ @values = values.is_a?( ::Array ) ? values : [values]
24
+ end
16
25
  end
17
26
 
18
27
  # @todo soapify properly for custom objects (JIRA module).
@@ -25,4 +34,5 @@ class JIRA::FieldValue
25
34
  message.add_simple_array 'values', @values unless @values.nil?
26
35
  end
27
36
  end
37
+
28
38
  end
@@ -1,8 +1,21 @@
1
+ ##
2
+ # @note You can only read filters from the server, there are no API methods
3
+ # for creating, updating, or deleting filters from the server.
4
+ #
1
5
  # Represents a filter, but does not seem to include the filters JQL query.
2
6
  class JIRA::Filter < JIRA::DescribedEntity
3
- add_attributes(
4
- ['author', :author, :to_s],
5
- ['project', :project_name, :to_s],
6
- ['xml', :xml, :to_s]
7
- )
7
+
8
+ # @return [String]
9
+ add_attribute :author, 'author', :content
10
+
11
+ # @return [String]
12
+ add_attribute :project_name, 'project', :content
13
+
14
+ ##
15
+ # @todo Find out what this is for, perhaps it is the XML form of
16
+ # equivalent JQL query?
17
+ #
18
+ # @return [String]
19
+ add_attribute :xml, 'xml', :content
20
+
8
21
  end
@@ -1,39 +1,82 @@
1
- # @todo add attributes for the comments and the attachment metadata
1
+ ##
2
+ # @note Issues with an UNRESOLVED status will have nil for the value for
3
+ # {#resolution_id}.
4
+ # @todo Add attributes for the comments and the attachment metadata
5
+ #
2
6
  # Contains most of the data and metadata for a JIRA issue, but does
3
7
  # not contain the {JIRA::Comment}s or {JIRA::AttachmentMetadata}.
4
8
  #
5
9
  # This class is easily the most convoluted structure in the API, and will
6
10
  # likely be the greatest source of bugs. The irony of the situation is that
7
11
  # this structure is also the most critical to have in working order.
8
- #
9
- # @note Issues with an UNRESOLVED status will have nil for the value for
10
- # {#resolution_id}.
11
12
  class JIRA::Issue < JIRA::DynamicEntity
12
- add_attributes(
13
- ['key', :key, :to_s],
14
- ['summary', :summary, :to_s],
15
- ['description', :description, :to_s],
16
- ['type', :type_id, :to_s],
17
- ['status', :status_id, :to_s],
18
- ['assignee', :assignee_username, :to_s],
19
- ['reporter', :reporter_username, :to_s],
20
- ['priority', :priority_id, :to_s],
21
- ['project', :project_name, :to_s],
22
- ['resolution', :resolution_id, :to_s],
23
- ['environment', :environment, :to_s],
24
- ['votes', :votes, :to_i],
25
- ['updated', :last_updated_time, :to_date],
26
- ['created', :create_time, :to_date],
27
- # This is actually a Time object with no time resolution.
28
- ['duedate', :due_date, :to_date],
29
- ['affectsVersions', :affects_versions, :to_objects, JIRA::Version],
30
- ['fixVersions', :fix_versions, :to_objects, JIRA::Version],
31
- ['components', :components, :to_objects, JIRA::Component],
32
- ['customFieldValues', :custom_field_values, :to_objects, JIRA::CustomFieldValue],
33
- ['attachmentNames', :attachment_names, :to_ss]
34
- )
35
13
 
14
+ # @return [String]
15
+ add_attribute :key, 'key', :content
16
+
17
+ # @return [String]
18
+ add_attribute :summary, 'summary', :content
19
+
20
+ # @return [String]
21
+ add_attribute :description, 'description', :content
22
+
23
+ # @return [String]
24
+ add_attribute :type_id, 'type', :content
25
+
26
+ # @return [String]
27
+ add_attribute :status_id, 'status', :content
28
+
29
+ # @return [String]
30
+ add_attribute :assignee_username, 'assignee', :content
31
+
32
+ # @return [String]
33
+ add_attribute :reporter_username, 'reporter', :content
34
+
35
+ # @return [String]
36
+ add_attribute :priority_id, 'priority', :content
37
+
38
+ # @return [String]
39
+ add_attribute :project_name, 'project', :content
40
+
41
+ # @return [String]
42
+ add_attribute :resolution_id, 'resolution', :content
43
+
44
+ # @return [String]
45
+ add_attribute :environment, 'environment', :content
46
+
47
+ # @return [Number]
48
+ add_attribute :votes, 'votes', :to_i
49
+
50
+ # @return [Time]
51
+ add_attribute :last_updated_time, 'updated', :to_iso_date
52
+
53
+ # @return [Time]
54
+ add_attribute :create_time, 'created', :to_iso_date
55
+
56
+ ##
57
+ # This is actually a Time object with no time resolution.
58
+ #
59
+ # @return [Time]
60
+ add_attribute :due_date, 'duedate', :to_iso_date
61
+
62
+ # @return [Array<JIRA::Version>]
63
+ add_attribute :affects_versions, 'affectsVersions', [:children_as_objects, JIRA::Version]
64
+
65
+ # @return [Array<JIRA::Version>]
66
+ add_attribute :fix_versions, 'fixVersions', [:children_as_objects, JIRA::Version]
67
+
68
+ # @return [Array<JIRA::Component>]
69
+ add_attribute :components, 'components', [:children_as_objects, JIRA::Component]
70
+
71
+ # @return [Array<JIRA::CustomFieldValue>]
72
+ add_attribute :custom_field_values, 'customFieldValues', [:children_as_objects, JIRA::CustomFieldValue]
73
+
74
+ # @return [Array<String>]
75
+ add_attribute :attachment_names, 'attachmentNames', :contents_of_children
76
+
77
+ ##
36
78
  # @todo see if we can use the simple and complex array builders
79
+ #
37
80
  # Generate the SOAP message fragment for an issue. Can you spot the oddities
38
81
  # and inconsistencies? (hint: there are many).
39
82
  #
@@ -54,8 +97,9 @@ class JIRA::Issue < JIRA::DynamicEntity
54
97
  #
55
98
  # Passing an environment/due date field with a value of nil causes the
56
99
  # server to complain about the formatting of the message.
100
+ #
57
101
  # @param [Handsoap::XmlMason::Node] msg message the node to add the object to
58
- def soapify_for(msg)
102
+ def soapify_for msg
59
103
  # might be going away, since it appears to have no effect at creation time
60
104
  msg.add 'reporter', @reporter_name unless @reporter.nil?
61
105
 
@@ -87,10 +131,11 @@ class JIRA::Issue < JIRA::DynamicEntity
87
131
  }
88
132
  end
89
133
 
90
- msg.add 'assignee', (@assignee_name || '-1')
134
+ msg.add 'assignee', (@assignee_username || '-1')
91
135
  msg.add_complex_array 'customFieldValues', (@custom_field_values || [])
92
136
 
93
137
  msg.add 'environment', @environment unless @environment.nil?
94
138
  msg.add 'duedate', @due_date.xmlschema unless @due_date.nil?
95
139
  end
140
+
96
141
  end