jiraSOAP 0.5.3 → 0.6.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 (46) hide show
  1. data/ChangeLog +22 -0
  2. data/README.markdown +6 -2
  3. data/lib/jiraSOAP.rb +6 -2
  4. data/lib/jiraSOAP/JIRAservice.rb +29 -32
  5. data/lib/jiraSOAP/api.rb +220 -59
  6. data/lib/jiraSOAP/entities.rb +29 -19
  7. data/lib/jiraSOAP/entities/attachment_metadata.rb +27 -0
  8. data/lib/jiraSOAP/entities/avatar.rb +12 -19
  9. data/lib/jiraSOAP/entities/comment.rb +17 -26
  10. data/lib/jiraSOAP/entities/component.rb +5 -0
  11. data/lib/jiraSOAP/entities/custom_field_value.rb +33 -0
  12. data/lib/jiraSOAP/entities/described_entity.rb +7 -0
  13. data/lib/jiraSOAP/entities/dynamic_entity.rb +8 -0
  14. data/lib/jiraSOAP/entities/entity.rb +43 -0
  15. data/lib/jiraSOAP/entities/field.rb +4 -0
  16. data/lib/jiraSOAP/entities/field_value.rb +4 -49
  17. data/lib/jiraSOAP/entities/filter.rb +7 -16
  18. data/lib/jiraSOAP/entities/issue.rb +32 -43
  19. data/lib/jiraSOAP/entities/issue_property.rb +9 -0
  20. data/lib/jiraSOAP/entities/issue_security_scheme.rb +4 -0
  21. data/lib/jiraSOAP/entities/issue_type.rb +8 -0
  22. data/lib/jiraSOAP/entities/named_entity.rb +7 -0
  23. data/lib/jiraSOAP/entities/notification_scheme.rb +4 -0
  24. data/lib/jiraSOAP/entities/permission.rb +12 -0
  25. data/lib/jiraSOAP/entities/permission_mapping.rb +12 -0
  26. data/lib/jiraSOAP/entities/permission_scheme.rb +8 -0
  27. data/lib/jiraSOAP/entities/priority.rb +9 -0
  28. data/lib/jiraSOAP/entities/project.rb +14 -24
  29. data/lib/jiraSOAP/entities/project_role.rb +11 -0
  30. data/lib/jiraSOAP/entities/remote_entity.rb +7 -0
  31. data/lib/jiraSOAP/entities/resolution.rb +4 -0
  32. data/lib/jiraSOAP/entities/scheme.rb +9 -0
  33. data/lib/jiraSOAP/entities/server_configuration.rb +56 -0
  34. data/lib/jiraSOAP/entities/server_info.rb +30 -0
  35. data/lib/jiraSOAP/entities/status.rb +4 -0
  36. data/lib/jiraSOAP/entities/time_info.rb +15 -0
  37. data/lib/jiraSOAP/entities/user.rb +8 -13
  38. data/lib/jiraSOAP/entities/version.rb +8 -16
  39. data/lib/jiraSOAP/handsoap_extensions.rb +29 -42
  40. data/lib/jiraSOAP/url.rb +3 -2
  41. metadata +193 -33
  42. data/lib/jiraSOAP/entities/abstract.rb +0 -93
  43. data/lib/jiraSOAP/entities/attachments.rb +0 -35
  44. data/lib/jiraSOAP/entities/issue_properties.rb +0 -39
  45. data/lib/jiraSOAP/entities/read_only.rb +0 -120
  46. data/lib/jiraSOAP/entities/schemes.rb +0 -25
@@ -0,0 +1,9 @@
1
+ # @abstract A common base for most issue properties; core issue properties
2
+ # have an icon to go with them to help identify properties of issues more
3
+ # quickly.
4
+ class JIRA::IssueProperty < JIRA::DescribedEntity
5
+ add_attributes({ 'icon' => [:icon=, :to_url] })
6
+
7
+ # @return [URL] NSURL on MacRuby and a URI::HTTP object on CRuby
8
+ attr_accessor :icon
9
+ end
@@ -0,0 +1,4 @@
1
+ # Basic metadata about a project's issue security scheme.
2
+ class JIRA::IssueSecurityScheme < JIRA::Scheme
3
+ add_attributes({})
4
+ end
@@ -0,0 +1,8 @@
1
+ # Contains all the metadata for an issue type.
2
+ class JIRA::IssueType < JIRA::IssueProperty
3
+ add_attributes({ 'subTask' => [:subtask=, :to_boolean] })
4
+
5
+ # @return [boolean] true if the issue type is also a subtask
6
+ attr_accessor :subtask
7
+ alias_method :subtask?, :subtask
8
+ end
@@ -0,0 +1,7 @@
1
+ # @abstract Most dynamic entities also have a name
2
+ class JIRA::NamedEntity < JIRA::DynamicEntity
3
+ add_attributes({ 'name' => [:name=, :to_s] })
4
+
5
+ # @return [String] a plain language name
6
+ attr_accessor :name
7
+ end
@@ -0,0 +1,4 @@
1
+ # Basic metadata about a project's notification scheme.
2
+ class JIRA::NotificationScheme < JIRA::Scheme
3
+ add_attributes({})
4
+ end
@@ -0,0 +1,12 @@
1
+ class JIRA::Permission < JIRA::Entity
2
+ add_attributes({
3
+ 'name' => [:name=, :to_s],
4
+ 'permission' => [:permission=, :to_i]
5
+ })
6
+
7
+ # @return [String] the permission type
8
+ attr_accessor :name
9
+
10
+ # @return [Fixnum] a unique id number
11
+ attr_accessor :permission
12
+ end
@@ -0,0 +1,12 @@
1
+ class JIRA::PermissionMapping < JIRA::Entity
2
+ @attributes = {
3
+ 'permission' => [:permission=, :to_object, JIRA::Permission],
4
+ 'permission' => [:permission=, :to_objects, JIRA::Permission]
5
+ }
6
+
7
+ # @return [JIRA::Permission]
8
+ attr_accessor :permission
9
+
10
+ # @return [[JIRA::RemoteEntity]]
11
+ attr_accessor :remote_entities
12
+ end
@@ -0,0 +1,8 @@
1
+ # @todo complete this class
2
+ # Includes a mapping of project specific permission settings.
3
+ class JIRA::PermissionScheme < JIRA::Scheme
4
+ add_attributes({})
5
+
6
+ # @return [nil]
7
+ attr_accessor :permission_mappings
8
+ end
@@ -0,0 +1,9 @@
1
+ # Contains all the metadata for a priority level.
2
+ class JIRA::Priority < JIRA::IssueProperty
3
+ add_attributes({ 'color' => [:color=, :to_hex_string] })
4
+
5
+ # @return [Array(String,String,String)] the RGB components as a triple
6
+ attr_accessor :color
7
+ alias_method :colour, :color
8
+ alias_method :colour=, :color=
9
+ end
@@ -1,19 +1,26 @@
1
- module JIRA
2
-
3
1
  # Contains the data and metadata about a project and its configuration.
4
- class Project < JIRA::DescribedEntity
2
+ class JIRA::Project < JIRA::DescribedEntity
3
+ add_attributes({
4
+ 'key' => [:key=, :to_s],
5
+ 'lead' => [:lead_username=, :to_s],
6
+ 'issueSecurityScheme' => [:issue_security_scheme=, :to_object, JIRA::IssueSecurityScheme],
7
+ 'notificationScheme' => [:notification_scheme=, :to_object, JIRA::NotificationScheme],
8
+ 'permissionScheme' => [:permission_scheme=, :to_object, JIRA::PermissionScheme],
9
+ 'url' => [:jira_url=, :to_url],
10
+ 'projectUrl' => [:project_url=, :to_url]
11
+ })
5
12
 
6
13
  # @return [String]
7
14
  attr_accessor :key
8
15
 
9
16
  # @return [URL]
10
- attr_accessor :url
17
+ attr_accessor :jira_url
11
18
 
12
19
  # @return [URL]
13
20
  attr_accessor :project_url
14
21
 
15
22
  # @return [String]
16
- attr_accessor :lead
23
+ attr_accessor :lead_username
17
24
 
18
25
  # @return [JIRA::IssueSecurityScheme]
19
26
  attr_accessor :issue_security_scheme
@@ -24,21 +31,6 @@ class Project < JIRA::DescribedEntity
24
31
  # @return [JIRA::PermissionScheme]
25
32
  attr_accessor :permission_scheme
26
33
 
27
- # @param [Handsoap::XmlQueryFront::NokogiriDriver] frag
28
- def initialize_with_xml_fragment(frag)
29
- super frag
30
- @key, @lead,
31
- @issue_security_scheme, @notification_scheme, @permission_scheme,
32
- @url, @project_url =
33
- frag.nodes( ['key', :to_s],
34
- ['lead', :to_s],
35
- ['issueSecurityScheme', :to_object, JIRA::IssueSecurityScheme],
36
- ['notificationScheme', :to_object, JIRA::NotificationScheme],
37
- ['permissionScheme', :to_object, JIRA::PermissionScheme],
38
- ['url', :to_url],
39
- ['projectUrl', :to_url] )
40
- end
41
-
42
34
  # @todo make this method shorter
43
35
  # @todo encode the schemes
44
36
  # @param [Handsoap::XmlMason::Node] msg
@@ -47,11 +39,9 @@ class Project < JIRA::DescribedEntity
47
39
  msg.add 'id', @id
48
40
  msg.add 'name', @name
49
41
  msg.add 'key', @key
50
- msg.add 'url', @url
42
+ msg.add 'url', @jira_url
51
43
  msg.add 'projectUrl', @project_url
52
- msg.add 'lead', @lead
44
+ msg.add 'lead', @lead_username
53
45
  msg.add 'description', @description
54
46
  end
55
47
  end
56
-
57
- end
@@ -0,0 +1,11 @@
1
+ # Only a name, description and id.
2
+ class JIRA::ProjectRole < JIRA::DescribedEntity
3
+ add_attributes({})
4
+
5
+ # @param [Handsoap::XmlMason::Node] msg the node where to add self
6
+ def soapify_for msg
7
+ msg.add 'id', @id
8
+ msg.add 'name', @name
9
+ msg.add 'description', @description
10
+ end
11
+ end
@@ -0,0 +1,7 @@
1
+ # This is just a @name, JIRA::User should inherit from this class
2
+ class JIRA::RemoteEntity < JIRA::Entity
3
+ add_attributes({ 'name' => [:name=, :to_s] })
4
+
5
+ # @return [String]
6
+ attr_accessor :name
7
+ end
@@ -0,0 +1,4 @@
1
+ # Contains all the metadata for a resolution.
2
+ class JIRA::Resolution < JIRA::IssueProperty
3
+ add_attributes({})
4
+ end
@@ -0,0 +1,9 @@
1
+ # @abstract
2
+ # Schemes used by the server.
3
+ class JIRA::Scheme < JIRA::DescribedEntity
4
+ add_attributes({})
5
+
6
+ # Child classes need to be careful when encoding the scheme type to XML.
7
+ # @return [Class]
8
+ alias_method :type, :class
9
+ end
@@ -0,0 +1,56 @@
1
+ # A simple structure that is used by {RemoteAPI#get_server_configuration}.
2
+ class JIRA::ServerConfiguration < JIRA::Entity
3
+ add_attributes({
4
+ 'allowExternalUserManagement' => [:external_user_management_allowed=, :to_boolean],
5
+ 'allowAttachments' => [:attachments_allowed=, :to_boolean],
6
+ 'allowIssueLinking' => [:issue_linking_allowed=, :to_boolean],
7
+ 'allowSubTasks' => [:subtasks_allowed=, :to_boolean],
8
+ 'allowTimeTracking' => [:time_tracking_allowed=, :to_boolean],
9
+ 'allowUnassignedIssues' => [:unassigned_issues_allowed=, :to_boolean],
10
+ 'allowVoting' => [:voting_allowed=, :to_boolean],
11
+ 'allowWatching' => [:watching_allowed=, :to_boolean],
12
+ 'timeTrackingDaysPerWeek' => [:time_tracking_days_per_week=, :to_i],
13
+ 'timeTrackingHoursPerDay' => [:time_tracking_hours_per_day=, :to_i],
14
+
15
+ # in case we are using a version of JIRA that misspells 'management'
16
+ 'allowExternalUserManagment' => [:external_user_management_allowed=, :to_boolean]
17
+ })
18
+
19
+ # @return [boolean]
20
+ attr_accessor :attachments_allowed
21
+ alias_method :attachments_allowed?, :attachments_allowed
22
+
23
+ # @return [boolean]
24
+ attr_accessor :external_user_management_allowed
25
+ alias_method :external_user_management_allowed?, :external_user_management_allowed
26
+
27
+ # @return [boolean]
28
+ attr_accessor :issue_linking_allowed
29
+ alias_method :issue_linking_allowed?, :issue_linking_allowed
30
+
31
+ # @return [boolean]
32
+ attr_accessor :subtasks_allowed
33
+ alias_method :subtasks_allowed?, :subtasks_allowed
34
+
35
+ # @return [boolean]
36
+ attr_accessor :time_tracking_allowed
37
+ alias_method :time_tracking_allowed?, :time_tracking_allowed
38
+
39
+ # @return [boolean]
40
+ attr_accessor :unassigned_issues_allowed
41
+ alias_method :unassigned_issues_allowed?, :unassigned_issues_allowed
42
+
43
+ # @return [boolean]
44
+ attr_accessor :voting_allowed
45
+ alias_method :voting_allowed?, :voting_allowed
46
+
47
+ # @return [boolean]
48
+ attr_accessor :watching_allowed
49
+ alias_method :watching_allowed?, :watching_allowed
50
+
51
+ # @return [Fixnum]
52
+ attr_accessor :time_tracking_days_per_week
53
+
54
+ # @return [Fixnum]
55
+ attr_accessor :time_tracking_hours_per_day
56
+ end
@@ -0,0 +1,30 @@
1
+ # Only contains basic information about the endpoint server and only used
2
+ # by {RemoteAPI#get_server_info}.
3
+ class JIRA::ServerInfo < JIRA::Entity
4
+ add_attributes({
5
+ 'baseUrl' => [:base_url=, :to_url],
6
+ 'buildDate' => [:build_date=, :to_date],
7
+ 'buildNumber' => [:build_number=, :to_i],
8
+ 'edition' => [:edition=, :to_s],
9
+ 'version' => [:version=, :to_s],
10
+ 'serverTime' => [:server_time=, :to_object, JIRA::TimeInfo]
11
+ })
12
+
13
+ # @return [URL]
14
+ attr_accessor :base_url
15
+
16
+ # @return [Time]
17
+ attr_accessor :build_date
18
+
19
+ # @return [Fixnum]
20
+ attr_accessor :build_number
21
+
22
+ # @return [String]
23
+ attr_accessor :edition
24
+
25
+ # @return [String]
26
+ attr_accessor :version
27
+
28
+ # @return [JIRA::TimeInfo]
29
+ attr_accessor :server_time
30
+ end
@@ -0,0 +1,4 @@
1
+ # Contains all the metadata for an issue's status.
2
+ class JIRA::Status < JIRA::IssueProperty
3
+ add_attributes({})
4
+ end
@@ -0,0 +1,15 @@
1
+ # Simple structure for a time and time zone; only used by JIRA::ServerInfo
2
+ # objects, which themselves are only created when {RemoteAPI#get_server_info}
3
+ # is called.
4
+ class JIRA::TimeInfo < JIRA::Entity
5
+ add_attributes({
6
+ 'serverTime' => [:server_time=, :to_date_string],
7
+ 'timeZoneId' => [:timezone=, :to_s]
8
+ })
9
+
10
+ # @return [Time]
11
+ attr_accessor :server_time
12
+
13
+ # @return [String] in the form of 'America/Toronto'
14
+ attr_accessor :timezone
15
+ end
@@ -1,8 +1,11 @@
1
- module JIRA
2
-
3
- # Contains the basic information about a user. The only things missing here
4
- # are the permissions and login statistics.
5
- class User < JIRA::Entity
1
+ # Contains only the basic information about a user. The only things missing here
2
+ # are the permissions and login statistics, but these are not given in the API.
3
+ class JIRA::User < JIRA::Entity
4
+ add_attributes({
5
+ 'name' => [:username=, :to_s],
6
+ 'fullname' => [:full_name=, :to_s],
7
+ 'email' => [:email_address=, :to_s]
8
+ })
6
9
 
7
10
  # @return [String]
8
11
  attr_accessor :username
@@ -12,12 +15,4 @@ class User < JIRA::Entity
12
15
 
13
16
  # @return [String]
14
17
  attr_accessor :email_address
15
-
16
- # @param [Handsoap::XmlQueryFront::NokogiriDriver] frag
17
- def initialize_with_xml_fragment(frag)
18
- @username, @full_name, @email_address =
19
- frag.nodes ['name', :to_s], ['fullname', :to_s], ['email', :to_s]
20
- end
21
- end
22
-
23
18
  end
@@ -1,9 +1,13 @@
1
- module JIRA
2
-
1
+ # @todo find out why we don't get a description for this object
3
2
  # Represents a version for a project. The description field is never
4
3
  # included when you retrieve versions from the server.
5
- # @todo find out why we don't get a description for this object
6
- class Version < JIRA::NamedEntity
4
+ class JIRA::Version < JIRA::NamedEntity
5
+ add_attributes({
6
+ 'sequence' => [:sequence=, :to_i],
7
+ 'released' => [:released=, :to_boolean],
8
+ 'archived' => [:archived=, :to_boolean],
9
+ 'releaseDate' => [:release_date=, :to_date]
10
+ })
7
11
 
8
12
  # @return [Fixnum]
9
13
  attr_accessor :sequence
@@ -19,16 +23,6 @@ class Version < JIRA::NamedEntity
19
23
  # @return [Time]
20
24
  attr_accessor :release_date
21
25
 
22
- # @param [Handsoap::XmlQueryFront::NokogiriDriver] frag
23
- def initialize_with_xml_fragment(frag)
24
- super frag
25
- @sequence, @released, @archived, @release_date =
26
- frag.nodes( ['sequence', :to_i],
27
- ['released', :to_boolean],
28
- ['archived', :to_boolean],
29
- ['releaseDate', :to_date] )
30
- end
31
-
32
26
  # @todo make this method shorter
33
27
  # @param [Handsoap::XmlMason::Node] msg
34
28
  # @return [Handsoap::XmlMason::Node]
@@ -40,5 +34,3 @@ class Version < JIRA::NamedEntity
40
34
  msg.add 'released', @released unless @released.nil?
41
35
  end
42
36
  end
43
-
44
- end
@@ -1,10 +1,12 @@
1
1
  # Some simple extensions to Handsoap.
2
2
  module Handsoap
3
- # Some simple extensions to XmlMason. Currently, this only includes methods to
4
- # make it easier to build SOAP messages that contain arrays.
3
+
4
+ # Some extensions to the XML builder to make message building less ugly.
5
5
  module XmlMason
6
- # Represents a node in an XML document used for SOAP message creation.
6
+
7
+ # A node in a Nokogiri XML document.
7
8
  class Node
9
+
8
10
  # @todo Make this method recursive
9
11
  # @param [String] node_name
10
12
  # @param [Array] array
@@ -24,32 +26,34 @@ module XmlMason
24
26
  node = append_child Element.new(self, prefix, name, nil, options)
25
27
  array.each { |element| element.soapify_for node, name }
26
28
  end
29
+
27
30
  end
31
+
28
32
  end
29
33
 
30
- # Some simple extensions to make initialization of JIRA objects cleaner.
34
+
35
+ # These are simple extensions to the existing class provided by Handsoap.
31
36
  module XmlQueryFront
32
- # Represents a node in an XML document used when parsing SOAP responses.
33
- # This class is extended for use with jiraSOAP.
34
- class NokogiriDriver
35
37
 
36
- # @param [Array] *attributes pairs or triplets, the first element is the
37
- # attribute you want, the second element is the method to send to the
38
- # result, and the third element is the argument to that method (if needed)
39
- # @return [[Objects]]
40
- def nodes(*attributes)
41
- attributes.map { |attr|
42
- self.xpath(attr.shift).send *attr
43
- }
44
- end
38
+ # Simple extensions on the existing Handsoap class to make parsing easier.
39
+ class NokogiriDriver
45
40
 
41
+ # Parses non-strict date strings into Time objects.
46
42
  # @return [Time]
47
- def to_string_date
43
+ def to_date_string
48
44
  temp = self.to_s
49
45
  return unless temp
50
46
  Time.new temp
51
47
  end
52
48
 
49
+ # This is a bit naive, but should be sufficient for its purpose.
50
+ # @return [String]
51
+ def to_hex_string
52
+ temp = self.to_s
53
+ return unless temp
54
+ temp.match(/#(..)(..)(..)/).captures
55
+ end
56
+
53
57
  # @return [URL]
54
58
  def to_url
55
59
  temp = self.to_s
@@ -57,39 +61,22 @@ module XmlQueryFront
57
61
  URL.new temp
58
62
  end
59
63
 
64
+ # Returns the node's children to an array of strings.
60
65
  # @return [[String]]
61
66
  def to_ss
62
- self.map { |val| val.to_s }
67
+ children.map { |val| val.to_s }
63
68
  end
64
- end
65
69
 
66
- # Simple additions to help expedite parsing XML.
67
- class NodeSelection
68
- # @return [URL]
69
- def to_url
70
- self.first.to_url if self.any?
71
- end
72
-
73
- # @return [Time]
74
- def to_string_date
75
- self.first.to_string_date
76
- end
77
-
78
- # @return [[String]]
79
- def to_ss
80
- self.map { |val| val.to_s }
70
+ # @param [Class] klass the object you want to make
71
+ # @return [Object] an instance of klass
72
+ def to_object klass
73
+ klass.new_with_xml self
81
74
  end
82
75
 
83
76
  # @param [Class] klass the object you want an array of
84
77
  # @return [Array] an array of klass objects
85
- def to_objects(klass)
86
- self.map { |frag| klass.new_with_xml_fragment frag }
87
- end
88
-
89
- # @param [Class] klass the object you want to make
90
- # @return [Object] an instance of klass
91
- def to_object(klass)
92
- klass.new_with_xml_fragment self.first if self.any?
78
+ def to_objects klass
79
+ children.map { |node| klass.new_with_xml node }
93
80
  end
94
81
  end
95
82
  end