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
@@ -0,0 +1,28 @@
1
+ ##
2
+ # Contains the data and metadata for a remote worklog.
3
+ class JIRA::Worklog < JIRA::DescribedEntity
4
+
5
+ # @return [String]
6
+ add_attribute :comment, 'comment', :content
7
+
8
+ ##
9
+ # @todo Why does this need to be a DateTime? It should be a Time object
10
+ # so that it can be compatible with Cocoa's NSDate on MacRuby.
11
+ #
12
+ # Needs to be a DateTime.
13
+ #
14
+ # @return [DateTime]
15
+ add_attribute :start_data, 'startDate', :to_date
16
+
17
+ # @return [String]
18
+ add_attribute :time_spent, 'timeSpent', :content
19
+
20
+ # @param [Handsoap::XmlMason::Node] msg
21
+ # @return [Handsoap::XmlMason::Node]
22
+ def soapify_for msg
23
+ msg.add 'comment', @comment
24
+ msg.add 'startDate', @start_date
25
+ msg.add 'timeSpent', @time_spent
26
+ end
27
+
28
+ end
@@ -1,86 +1,37 @@
1
- # Some simple extensions to Handsoap.
2
- module Handsoap
3
-
4
- # @todo check if these methods already exist in Handsoap::Service
5
- # Some extensions to the XML builder to make message building less ugly.
6
- module XmlMason
7
-
8
- # A node in a Nokogiri XML document.
9
- class Node
10
-
11
- # @todo Make this method recursive
12
- # @param [String] node_name
13
- # @param [Array] array
14
- # @param [Hash] options
15
- def add_simple_array(node_name, array = [], options = {})
16
- prefix, name = parse_ns(node_name)
17
- node = append_child Element.new(self, prefix, name, nil, options)
18
- array.each { |element| node.add node_name, element }
19
- end
20
-
21
- # @todo Make this method recursive
22
- # @param [String] node_name
23
- # @param [Array] array
24
- # @param [Hash] options
25
- def add_complex_array(node_name, array = [], options = {})
26
- prefix, name = parse_ns(node_name)
27
- node = append_child Element.new(self, prefix, name, nil, options)
28
- array.each { |element| element.soapify_for node, name }
29
- end
30
-
1
+ ##
2
+ # @todo Push these upstream?
3
+ #
4
+ # Some simple extensions to Handsoap to make building SOAP messages easier.
5
+ class Handsoap::XmlMason::Node
6
+ ##
7
+ # @todo Make this method recursive
8
+ #
9
+ # @param [String] node_name
10
+ # @param [Array] array
11
+ # @param [Hash] options
12
+ def add_simple_array node_name, array = [], options = {}
13
+ prefix, name = parse_ns(node_name)
14
+ node = append_child Handsoap::XmlMason::Element.new(self, prefix, name, nil, options)
15
+ array.each { |element| node.add node_name, element }
31
16
  end
32
17
 
33
- end
34
-
35
-
36
- # These are simple extensions to the existing class provided by Handsoap.
37
- module XmlQueryFront
38
-
39
- # @todo move these extensions straight to the nokogiri layer
40
- # Simple extensions on the existing Handsoap class to make parsing easier.
41
- class NokogiriDriver
42
-
43
- # Parses non-strict date strings into Time objects.
44
- # @return [Time]
45
- def to_date_string
46
- temp = self.to_s
47
- return unless temp
48
- Time.new temp
49
- end
50
-
51
- # This is a bit naive, but should be sufficient for its purpose.
52
- # @return [String]
53
- def to_hex_string
54
- temp = self.to_s
55
- return unless temp
56
- temp.match(/#(..)(..)(..)/).captures
57
- end
58
-
59
- # @return [URI::HTTP,NSURL]
60
- def to_url
61
- temp = self.to_s
62
- return unless temp
63
- JIRA.url_class.send JIRA.url_init_method, temp
64
- end
65
-
66
- # Returns the node's children to an array of strings.
67
- # @return [[String]]
68
- def to_ss
69
- children.map { |val| val.to_s }
70
- end
71
-
72
- # @param [Class] klass the object you want to make
73
- # @return [Object] an instance of klass
74
- def to_object klass
75
- klass.new_with_xml self
76
- end
77
-
78
- # @param [Class] klass the object you want an array of
79
- # @return [Array] an array of klass objects
80
- def to_objects klass
81
- children.map { |node| klass.new_with_xml node }
82
- end
18
+ ##
19
+ # @todo Make this method recursive
20
+ #
21
+ # @param [String] node_name
22
+ # @param [Array] array
23
+ # @param [Hash] options
24
+ def add_complex_array node_name, array = [], options = {}
25
+ prefix, name = parse_ns(node_name)
26
+ node = append_child Handsoap::XmlMason::Element.new(self, prefix, name, nil, options)
27
+ array.each { |element| element.soapify_for node, name }
83
28
  end
84
29
  end
85
30
 
31
+ ##
32
+ # Monkey patch to expose the underlying Nokogiri object as jiraSOAP
33
+ # can parse much faster without the Handsoap layer in between.
34
+ class Handsoap::XmlQueryFront::NokogiriDriver
35
+ # @return [Nokogiri::XML::Element]
36
+ attr_reader :element
86
37
  end
@@ -1,20 +1,19 @@
1
- # @todo consider adding a finalizer that will try to logout
2
- # @note HTTPS is not supported in this version.
1
+ ##
2
+ # @note HTTPS is not supported out of the box in this version.
3
+ #
3
4
  # Interface to the JIRA endpoint server.
4
5
  #
5
6
  # Due to limitations in Handsoap::Service, there can only be one endpoint.
6
7
  # You can have multiple instances of that one endpoint if you would
7
- # like; but if you try to set a differnt endpoint for a new instance you
8
- # will end up messing up any other instances currently being used.
9
- #
10
- # It is best to treat this class as a singleton, but it is not enforced
11
- # in case you want to be able to login as multiple users to the same endpoint.
8
+ # like (different users); but if you try to set a differnt endpoint for a
9
+ # new instance you will end up messing up any other instances currently
10
+ # being used.
12
11
  class JIRA::JIRAService < Handsoap::Service
13
12
  include JIRA::RemoteAPI
14
13
  include JIRA::RemoteAPIAdditions
15
14
 
16
15
  # @return [String]
17
- attr_reader :auth_token
16
+ attr_accessor :auth_token
18
17
 
19
18
  # @return [String]
20
19
  attr_reader :user
@@ -22,7 +21,9 @@ class JIRA::JIRAService < Handsoap::Service
22
21
  # @return [String]
23
22
  attr_reader :endpoint_url
24
23
 
25
- # Initialize and log in.
24
+ ##
25
+ # Initialize _and_ log in. Fancy.
26
+ #
26
27
  # @param [String,URL] url URL for the JIRA server
27
28
  # @param [String] user JIRA user name to login with
28
29
  # @param [String] password
@@ -33,16 +34,18 @@ class JIRA::JIRAService < Handsoap::Service
33
34
  jira
34
35
  end
35
36
 
36
- # @param [String,URI::HTTP,NSURL] endpoint_url for the JIRA server
37
- def initialize endpoint_url
38
- @endpoint_url = endpoint_url.to_s
39
- JIRA::JIRAService.endpoint({
40
- uri:"#{endpoint_url.to_s}/rpc/soap/jirasoapservice-v2",
37
+ # @param [String,URI::HTTP,NSURL] endpoint for the JIRA server
38
+ def initialize endpoint
39
+ @endpoint_url = endpoint.to_s
40
+ self.class.endpoint({
41
+ uri:"#{endpoint_url}/rpc/soap/jirasoapservice-v2",
41
42
  version:2
42
43
  })
43
44
  end
44
45
 
46
+ ##
45
47
  # An extra note for users when things break.
48
+ #
46
49
  # @deprecated This will be removed in v1.0 when the API is stable.
47
50
  # @return [nil]
48
51
  def method_missing method, *args
@@ -55,11 +58,13 @@ class JIRA::JIRAService < Handsoap::Service
55
58
 
56
59
  protected
57
60
 
61
+ ##
58
62
  # Makes sure the correct namespace is set
59
63
  def on_create_document doc
60
64
  doc.alias 'soap', 'http://soap.rpc.jira.atlassian.com'
61
65
  end
62
66
 
67
+ ##
63
68
  # Make sure that the required namespace is added
64
69
  def on_response_document doc
65
70
  doc.add_namespace 'jir', @endpoint_url
@@ -1,23 +1,14 @@
1
- framework 'Foundation'
2
-
1
+ ##
3
2
  # In the case of MacRuby, we extend NSURL to behave enough like a
4
3
  # URI::HTTP object that they can be interchanged.
5
4
  class NSURL
6
-
7
- # We have to override, using {#alias_method} does not work because
8
- # {#to_s} is defined in the base class.
9
- # @return [String]
10
- def to_s
11
- absoluteString
12
- end
13
-
5
+ alias_method :to_s, :absoluteString
6
+ alias_method :inspect, :absoluteString
14
7
  end
15
8
 
16
-
17
- # @todo get a parallel map method for collections
18
9
  module JIRA
19
-
20
10
  @url_class = NSURL
21
11
  @url_init_method = :'URLWithString:'
22
-
23
12
  end
13
+
14
+ # @todo get a parallel map method for collections
@@ -0,0 +1,68 @@
1
+ ##
2
+ # Monkey (Freedom) patches to Nokogiri
3
+ class Nokogiri::XML::Element
4
+
5
+ # @return [Fixnum]
6
+ def to_i
7
+ content.to_i
8
+ end
9
+
10
+ # @return [Time,nil]
11
+ def to_iso_date
12
+ return if (temp = content).empty?
13
+ Time.iso8601 temp
14
+ end
15
+
16
+ ##
17
+ # Parses non-strict date strings into Time objects.
18
+ #
19
+ # @return [Time,nil]
20
+ def to_natural_date
21
+ return if (temp = content).empty?
22
+ Time.new temp
23
+ end
24
+
25
+ ##
26
+ # We assume that the boolean is encoded as as string, because that
27
+ # how JIRA is doing right now, but the XML schema allows a boolean
28
+ # to be encoded as 0/1 numbers instead.
29
+ #
30
+ # @return [Boolean]
31
+ def to_boolean
32
+ content == 'true' # || content == 1
33
+ end
34
+
35
+ # @return [URI::HTTP,NSURL,nil]
36
+ def to_url
37
+ return if (temp = content).empty?
38
+ JIRA.url_class.send JIRA.url_init_method, temp
39
+ end
40
+
41
+ ##
42
+ # This is a bit naive, but should be sufficient for its purpose.
43
+ #
44
+ # @return [Array(String,String,String),nil]
45
+ def to_color_triple
46
+ return if (temp = content).empty?
47
+ temp.match(/#(..)(..)(..)/).captures
48
+ end
49
+ alias_method :to_colour_triple, :to_color_triple
50
+
51
+ ##
52
+ # Ideally this method will return an array of strings, but this
53
+ # may not always be the case.
54
+ def contents_of_children
55
+ children.map { |val| val.content }
56
+ end
57
+
58
+ # @param [Class] klass the JIRA object you want to make
59
+ def children_as_object klass
60
+ klass.new_with_xml self
61
+ end
62
+
63
+ # @param [Class] klass the object you want an array of
64
+ # @return [Array] an array of klass objects
65
+ def children_as_objects klass
66
+ children.map { |node| klass.new_with_xml node }
67
+ end
68
+ end
data/lib/jiraSOAP/url.rb CHANGED
@@ -2,8 +2,16 @@ module JIRA
2
2
 
3
3
  class << self
4
4
 
5
- # Normally this variable is set to URI, but with MacRuby it is
6
- # set to NSURL
5
+ # When running on MacRuby, a URL will be wrapped into an NSURL object;
6
+ # but on all other Ruby implementations you will get a URI::HTTP object.
7
+ # The NSURL class is monkey patched just enough to make NSURL and
8
+ # URI::HTTP interchangeable. If you really want to, you can override
9
+ # the wrapper by changing {JIRA.url_class} and {JIRA.url_init_method}
10
+ # so that:
11
+ #
12
+ # JIRA.url_class.send JIRA.url_init_method, 'http://marketcircle.com'
13
+ #
14
+ # will be working code.
7
15
  # @return [Class,Module]
8
16
  attr_accessor :url_class
9
17
 
@@ -0,0 +1,3 @@
1
+ module JIRA
2
+ VERSION = '0.8.0'
3
+ end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: jiraSOAP
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.7.1
5
+ version: 0.8.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Mark Rada
@@ -10,8 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-02-13 00:00:00 -05:00
14
- default_executable:
13
+ date: 2011-06-11 00:00:00 Z
15
14
  dependencies:
16
15
  - !ruby/object:Gem::Dependency
17
16
  name: nokogiri
@@ -36,25 +35,25 @@ dependencies:
36
35
  type: :runtime
37
36
  version_requirements: *id002
38
37
  - !ruby/object:Gem::Dependency
39
- name: rake
38
+ name: yard
40
39
  prerelease: false
41
40
  requirement: &id003 !ruby/object:Gem::Requirement
42
41
  none: false
43
42
  requirements:
44
43
  - - ~>
45
44
  - !ruby/object:Gem::Version
46
- version: 0.8.7
45
+ version: 0.7.1
47
46
  type: :development
48
47
  version_requirements: *id003
49
48
  - !ruby/object:Gem::Dependency
50
- name: bundler
49
+ name: redcarpet
51
50
  prerelease: false
52
51
  requirement: &id004 !ruby/object:Gem::Requirement
53
52
  none: false
54
53
  requirements:
55
54
  - - ~>
56
55
  - !ruby/object:Gem::Version
57
- version: 1.0.10
56
+ version: "1.15"
58
57
  type: :development
59
58
  version_requirements: *id004
60
59
  - !ruby/object:Gem::Dependency
@@ -63,44 +62,11 @@ dependencies:
63
62
  requirement: &id005 !ruby/object:Gem::Requirement
64
63
  none: false
65
64
  requirements:
66
- - - ~>
65
+ - - ">="
67
66
  - !ruby/object:Gem::Version
68
- version: 2.0.2
67
+ version: 2.2.2
69
68
  type: :development
70
69
  version_requirements: *id005
71
- - !ruby/object:Gem::Dependency
72
- name: reek
73
- prerelease: false
74
- requirement: &id006 !ruby/object:Gem::Requirement
75
- none: false
76
- requirements:
77
- - - ~>
78
- - !ruby/object:Gem::Version
79
- version: 1.2.8
80
- type: :development
81
- version_requirements: *id006
82
- - !ruby/object:Gem::Dependency
83
- name: yard
84
- prerelease: false
85
- requirement: &id007 !ruby/object:Gem::Requirement
86
- none: false
87
- requirements:
88
- - - ~>
89
- - !ruby/object:Gem::Version
90
- version: 0.6.4
91
- type: :development
92
- version_requirements: *id007
93
- - !ruby/object:Gem::Dependency
94
- name: bluecloth
95
- prerelease: false
96
- requirement: &id008 !ruby/object:Gem::Requirement
97
- none: false
98
- requirements:
99
- - - ~>
100
- - !ruby/object:Gem::Version
101
- version: 2.0.10
102
- type: :development
103
- version_requirements: *id008
104
70
  description: Written to run fast and work on Ruby 1.9 as well as MacRuby
105
71
  email:
106
72
  - mrada@marketcircle.com
@@ -109,10 +75,11 @@ executables: []
109
75
  extensions: []
110
76
 
111
77
  extra_rdoc_files:
78
+ - README.markdown
112
79
  - ChangeLog
113
80
  - LICENSE.txt
114
- - README.markdown
115
81
  - .yardopts
82
+ - docs/GettingStarted.markdown
116
83
  files:
117
84
  - lib/jiraSOAP/api/additions.rb
118
85
  - lib/jiraSOAP/api/attachments.rb
@@ -127,7 +94,9 @@ files:
127
94
  - lib/jiraSOAP/api/server_info.rb
128
95
  - lib/jiraSOAP/api/users.rb
129
96
  - lib/jiraSOAP/api/versions.rb
97
+ - lib/jiraSOAP/api/worklog.rb
130
98
  - lib/jiraSOAP/api.rb
99
+ - lib/jiraSOAP/core_extensions.rb
131
100
  - lib/jiraSOAP/entities/attachment_metadata.rb
132
101
  - lib/jiraSOAP/entities/avatar.rb
133
102
  - lib/jiraSOAP/entities/comment.rb
@@ -158,25 +127,29 @@ files:
158
127
  - lib/jiraSOAP/entities/status.rb
159
128
  - lib/jiraSOAP/entities/time_info.rb
160
129
  - lib/jiraSOAP/entities/user.rb
130
+ - lib/jiraSOAP/entities/usergroup.rb
161
131
  - lib/jiraSOAP/entities/username.rb
162
132
  - lib/jiraSOAP/entities/version.rb
133
+ - lib/jiraSOAP/entities/worklog.rb
163
134
  - lib/jiraSOAP/entities.rb
164
135
  - lib/jiraSOAP/handsoap_extensions.rb
165
- - lib/jiraSOAP/JIRAservice.rb
166
- - lib/jiraSOAP/macruby_bonuses.rb
136
+ - lib/jiraSOAP/jira_service.rb
137
+ - lib/jiraSOAP/macruby_extensions.rb
138
+ - lib/jiraSOAP/nokogiri_extensions.rb
167
139
  - lib/jiraSOAP/url.rb
140
+ - lib/jiraSOAP/version.rb
168
141
  - lib/jiraSOAP.rb
169
- - yard-jiraSOAP.rb
142
+ - test/jiraSOAP_test.rb
143
+ - test/test_helper.rb
144
+ - Rakefile
145
+ - README.markdown
170
146
  - ChangeLog
171
147
  - LICENSE.txt
172
- - README.markdown
173
148
  - .yardopts
174
- - test/jiraSOAP_test.rb
175
- - test/test_helper.rb
176
- has_rdoc: true
149
+ - docs/GettingStarted.markdown
177
150
  homepage: http://github.com/Marketcircle/jiraSOAP
178
151
  licenses:
179
- - - MIT
152
+ - MIT
180
153
  post_install_message:
181
154
  rdoc_options: []
182
155
 
@@ -185,22 +158,23 @@ require_paths:
185
158
  required_ruby_version: !ruby/object:Gem::Requirement
186
159
  none: false
187
160
  requirements:
188
- - - ~>
161
+ - - ">="
189
162
  - !ruby/object:Gem::Version
190
- version: 1.9.2
163
+ version: "0"
191
164
  required_rubygems_version: !ruby/object:Gem::Requirement
192
165
  none: false
193
166
  requirements:
194
167
  - - ">="
195
168
  - !ruby/object:Gem::Version
196
- version: 1.3.6
169
+ version: "0"
197
170
  requirements: []
198
171
 
199
172
  rubyforge_project:
200
- rubygems_version: 1.5.2
173
+ rubygems_version: 1.8.5
201
174
  signing_key:
202
175
  specification_version: 3
203
176
  summary: A Ruby client for the JIRA SOAP API
204
177
  test_files:
205
178
  - test/jiraSOAP_test.rb
206
179
  - test/test_helper.rb
180
+ - Rakefile