jiraSOAP 0.7.1 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
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
data/.yardopts CHANGED
@@ -1,10 +1,9 @@
1
1
  --protected
2
- --private
3
2
  --no-cache
4
3
  --markup markdown
5
4
  --readme README.markdown
6
- --load './yard-jiraSOAP.rb'
7
5
  lib/**/*.rb
8
6
  -
9
- LICENSE.txt
7
+ docs/GettingStarted.markdown
10
8
  ChangeLog
9
+ LICENSE.txt
data/ChangeLog CHANGED
@@ -1,4 +1,19 @@
1
+ Version 0.8.0
2
+
3
+ * Deprecated the #get_ from methods that start with #get_
4
+ * Alias #login to #log_in and #logout to #log_out
5
+ * Added RemoteAPI#permission_to_edit_comment?
6
+ * Added UserGroup and related RemoteAPI methods
7
+ * Added RemoteAPI#add_worklog
8
+ * Various documentation updates and tweaks
9
+
10
+ * Removed handsoap parsing abstraction (roflscale for parsing)
11
+ * Removed the YARD plugin in favour of YARD 0.7 DSL documenting stuff
12
+
13
+ * FIx setting the assignee during Issue creation
14
+
1
15
  Version 0.7.1
16
+
2
17
  * Remove AOT compiled files from gem
3
18
 
4
19
  Version 0.7
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2010 Mark Rada
1
+ Copyright (c) 2010-2011 Marketcircle Inc.
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.markdown CHANGED
@@ -1,74 +1,85 @@
1
- jiraSOAP - Ruby interface to the JIRA SOAP API
2
- ==============================================
1
+ # jiraSOAP - Ruby interface to the JIRA SOAP API
3
2
 
4
- Uses [handsoap](http://wiki.github.com/unwire/handsoap/) to build a client for the JIRA SOAP API that works on MacRuby as well as Ruby 1.9.
3
+ Uses [handsoap](http://wiki.github.com/unwire/handsoap/) to build a
4
+ client for the JIRA SOAP API that works on MacRuby as well as Ruby
5
+ 1.9.
5
6
 
6
- Read the documentation [here](http://rdoc.info/github/Marketcircle/jiraSOAP/master/frames). The meat of the service is in the `RemoteAPI` module.
7
+ You can read the documentation for the
8
+ [latest release](http://rubydoc.info/gems/jiraSOAP/) or
9
+ the
10
+ [HEAD commit](http://rdoc.info/github/Marketcircle/jiraSOAP/master/frames).
11
+ The meat of the service is in the `RemoteAPI` module.
7
12
 
8
13
 
9
- Motivation
10
- ----------
14
+ ## Motivation
11
15
 
12
- The `jira4r` gem already exists, and works well on Ruby 1.8, but is not compatible with Ruby 1.9 or MacRuby due to its dependance on `soap4r`.
16
+ The `jira4r` gem already exists, and works well on Ruby 1.8, but is
17
+ not compatible with Ruby 1.9 or MacRuby due to its dependance on
18
+ `soap4r`.
13
19
 
14
20
 
15
- Goals
16
- -----
21
+ ## Goals
17
22
 
18
23
  Pick up where `jira4r` left off:
19
24
 
20
25
  - Implement the current API; `jira4r` does not implement APIs from JIRA 4.x
26
+ * not including APIs that have been deprecated in JIRA 4.x
21
27
  - More natural interface; not adhering to the API when the API is weird
22
- - Speed; network latency is bad enough
23
- - Excellent documentation, since the documentation given by Atlassian can be terse (the newer APIs are documented)
28
+ - Speed; network latency is bad enough (it would be cool to roflscale)
29
+ - Excellent documentation
24
30
 
25
31
 
26
- Getting Started
27
- ---------------
32
+ ## Getting Started
28
33
 
29
34
  `jiraSOAP` should run on Ruby 1.9.2 and MacRuby 0.8 or newer. It is available through rubygems or you can build from source:
30
35
 
31
- # Using rubygems
32
- sudo gem install jiraSOAP
36
+ ```bash
37
+ # Using rubygems
38
+ gem install jiraSOAP
33
39
 
34
- # Building from source
35
- git clone git://github.com/Marketcircle/jiraSOAP.git
36
- rake build install
40
+ # Building from source
41
+ git clone git://github.com/Marketcircle/jiraSOAP.git
42
+ rake build install
43
+ ```
37
44
 
38
45
  Once installed, you can run a quick demo (making appropriate substitutions):
39
46
 
40
- require 'jiraSOAP'
47
+ ```ruby
48
+ require 'jiraSOAP'
41
49
 
42
- db = JIRA::JIRAService.new 'http://jira.yourSite.com:8080'
43
- db.login 'user', 'password'
50
+ db = JIRA::JIRAService.new 'http://jira.yourSite.com:8080'
51
+ db.login 'user', 'password'
44
52
 
45
- issues = db.get_issues_from_jql_search 'reporter = currentUser()', 100
46
- issues.each { |issue|
47
- #do something...
48
- puts issue.key
49
- }
53
+ issues = db.get_issues_from_jql_search 'reporter = currentUser()', 100
54
+ issues.each { |issue|
55
+ #do something...
56
+ puts issue.key
57
+ }
50
58
 
51
- db.logout
59
+ db.logout
60
+ ```
52
61
 
53
62
 
54
- TODO
55
- ----
63
+ ## TODO
56
64
 
57
65
  - Finish implementing all of the API
58
66
  - Stabilize API
59
67
  - Performance optimizations; there are a number of places that can be optimized
60
- + Using GCD/Threads for parsing arrays of results; a significant speed up for large types and large arrays (ie. creating issues from JQL searches)
68
+ + Using GCD/Threads for parsing arrays of results; a significant
69
+ speed up for large types and large arrays (ie. creating issues from
70
+ JQL searches)
71
+ + Parsing can be done with array indexing instead of hash lookups
72
+ + Use a different web driver backend (net/http is slow under load)
61
73
  - Public test suite
62
74
  + Needs a lot of mock data
75
+ - ActiveRecord inspired conveniences
76
+ + ProjectRole.new( 'test role' ).unique? # => check uniqueness
77
+ + Issue.new( args ).create! # => creates a new issue
78
+ + Issue.with_key( 'JIRA-123' ) # => returns result of issue lookup
79
+ + Issue.new( args ).project # => returns a JIRA::Project
63
80
 
64
81
 
65
- Note on Patches/Pull Requests
66
- -----------------------------
67
-
68
- This project has a tendancy to change drastically between releases as it
69
- is still unstable, so patches may not cleanly apply.
70
-
71
- If you want to help by submitting patches:
82
+ ## Note on Patches/Pull Requests
72
83
 
73
84
  * Fork the project.
74
85
  * Make your feature addition or bug fix.
@@ -80,9 +91,8 @@ If you want to help by submitting patches:
80
91
  * Send me a pull request. Bonus points for topic branches.
81
92
 
82
93
 
83
- License
84
- -------
94
+ ## License
85
95
 
86
- Copyright: [Marketcircle Inc.](http://www.marketcircle.com/), 2010
96
+ Copyright: [Marketcircle Inc.](http://www.marketcircle.com/), 2010-2011
87
97
 
88
- See LICENSE for details.
98
+ See LICENSE.txt for details.
data/Rakefile ADDED
@@ -0,0 +1,57 @@
1
+ require 'rubygems'
2
+
3
+ task :default => :test
4
+
5
+
6
+ ### MACRUBY BONUSES
7
+
8
+ if RUBY_ENGINE == 'macruby' and MACRUBY_REVISION.match(/^git commit/)
9
+ require 'rake/compiletask'
10
+ Rake::CompileTask.new do |t|
11
+ t.files = FileList["lib/**/*.rb"]
12
+ t.verbose = true
13
+ end
14
+
15
+ desc 'Clean MacRuby binaries'
16
+ task :clean do
17
+ FileList["lib/**/*.rbo"].each { |bin| rm bin }
18
+ end
19
+ end
20
+
21
+
22
+ ### GEM STUFF
23
+
24
+ require 'rake/gempackagetask'
25
+ spec = Gem::Specification.load('jiraSOAP.gemspec')
26
+ Rake::GemPackageTask.new(spec) do |pkg|
27
+ pkg.need_zip = false
28
+ pkg.need_tar = true
29
+ end
30
+
31
+ require 'rubygems/dependency_installer'
32
+ desc 'Build the gem and install it'
33
+ task :install => :gem do
34
+ Gem::DependencyInstaller.new.install "pkg/#{spec.file_name}"
35
+ end
36
+
37
+
38
+ ### TESTING
39
+
40
+ require 'rake/testtask'
41
+ Rake::TestTask.new(:test) do |t|
42
+ t.libs << 'test'
43
+ t.pattern = 'test/**/test_*.rb'
44
+ t.ruby_opts = ['-rhelper']
45
+ t.verbose = true
46
+ end
47
+
48
+ desc 'Startup irb with jiraSOAP loaded'
49
+ task :console do
50
+ sh 'irb -Ilib -rubygems -rjiraSOAP'
51
+ end
52
+
53
+
54
+ ### DOCUMENTATION
55
+
56
+ require 'yard'
57
+ YARD::Rake::YardocTask.new
@@ -0,0 +1,36 @@
1
+ Getting Started
2
+ ===============
3
+
4
+ `jiraSOAP` should run on Ruby 1.9.2+ and MacRuby 0.8+. It is available through rubygems or you can build from source:
5
+
6
+ # Using rubygems
7
+ gem install jiraSOAP
8
+
9
+ # Building from source
10
+ git clone git://github.com/Marketcircle/jiraSOAP.git
11
+ rake build install
12
+
13
+ Once installed, you can run a quick demo (making appropriate substitutions):
14
+
15
+ require 'jiraSOAP'
16
+
17
+ The first thing that you need to do is create a JIRAService object:
18
+
19
+ db = JIRA::JIRAService.new 'http://jira.yourSite.com:8080'
20
+
21
+ Then you need to log in (a failed login will raise an exception):
22
+
23
+ db.login 'mrada', 'secret'
24
+
25
+ Once you are logged in, you can start querying the server for information:
26
+
27
+ issues = db.get_issues_from_jql_search 'reporter = currentUser()', 100
28
+ issues.each { |issue|
29
+ #do something...
30
+ puts issue.key
31
+ }
32
+
33
+ Don't forget to log out when you are done:
34
+
35
+ db.logout
36
+
data/lib/jiraSOAP.rb CHANGED
@@ -1,19 +1,22 @@
1
1
  require 'time'
2
2
  require 'uri'
3
+
3
4
  require 'nokogiri'
5
+ require 'jiraSOAP/nokogiri_extensions'
4
6
 
5
7
  require 'handsoap'
6
8
  Handsoap.http_driver = :net_http
9
+ require 'jiraSOAP/handsoap_extensions'
7
10
 
8
11
  require 'jiraSOAP/url'
9
- require 'jiraSOAP/handsoap_extensions'
12
+ require 'jiraSOAP/macruby_extensions' if RUBY_ENGINE == 'macruby'
10
13
 
14
+ ##
11
15
  # All the remote entities as well as the SOAP service client.
12
16
  module JIRA
13
17
  end
14
18
 
19
+ require 'jiraSOAP/version'
15
20
  require 'jiraSOAP/entities'
16
21
  require 'jiraSOAP/api'
17
- require 'jiraSOAP/JIRAservice'
18
-
19
- require 'jiraSOAP/macruby_bonuses' if RUBY_ENGINE == 'macruby'
22
+ require 'jiraSOAP/jira_service'
data/lib/jiraSOAP/api.rb CHANGED
@@ -1,78 +1,77 @@
1
- require 'jiraSOAP/api/users'
1
+ require 'jiraSOAP/api/additions'
2
+ require 'jiraSOAP/api/attachments'
2
3
  require 'jiraSOAP/api/avatars'
3
- require 'jiraSOAP/api/versions'
4
- require 'jiraSOAP/api/projects'
4
+ require 'jiraSOAP/api/comments'
5
+ require 'jiraSOAP/api/filters'
6
+ require 'jiraSOAP/api/issue_data_types'
7
+ require 'jiraSOAP/api/issues'
5
8
  require 'jiraSOAP/api/project_roles'
9
+ require 'jiraSOAP/api/projects'
6
10
  require 'jiraSOAP/api/schemes'
7
- require 'jiraSOAP/api/issues'
8
- require 'jiraSOAP/api/filters'
9
11
  require 'jiraSOAP/api/server_info'
10
- require 'jiraSOAP/api/attachments'
11
- require 'jiraSOAP/api/comments'
12
- require 'jiraSOAP/api/issue_data_types'
13
- require 'jiraSOAP/api/additions'
14
-
15
- module JIRA
12
+ require 'jiraSOAP/api/users'
13
+ require 'jiraSOAP/api/versions'
14
+ require 'jiraSOAP/api/worklog'
16
15
 
16
+ ##
17
+ # @todo progressWorkflowAction and friends
18
+ # @todo monkey patch Array to include a #to_soap method
19
+ #
17
20
  # Contains the API defined by Atlassian for the [JIRA SOAP service](http://docs.atlassian.com/software/jira/docs/api/rpc-jira-plugin/latest/com/atlassian/jira/rpc/soap/JiraSoapService.html).
18
21
  #
19
22
  # There are several cases where this API diverges from the one defined by
20
23
  # Atlassian; most notably, this API tries to be more idomatically Ruby by using
21
24
  # snake case for method names, default values, varargs, etc..
22
- # @todo logging
23
- # @todo progressWorkflowAction and friends [target v0.8]
24
- # @todo get Nokogiri element directly and monkey patch nokogiri directly
25
- # instead of the handsoap wrapper
26
- # @todo remove the get_ prefix from api methods that don't need them
27
- # @todo monkey patch Array to include a #to_soap method
28
- # @todo document how to override the url_class setting
29
- module RemoteAPI
30
-
31
- # XPath constant to get a node containing a response array.
32
- # This could be used for all responses, but is only used in cases where we
33
- # cannot use a more blunt XPath expression.
34
- RESPONSE_XPATH = '/node()[1]/node()[1]/node()[1]/node()[2]'
35
-
25
+ module JIRA::RemoteAPI
36
26
 
37
27
  # @group Logging in/out
38
28
 
39
- # @todo change method name to #login! since we are changing internal state?
29
+ ##
40
30
  # The first method to call; other methods will fail until you are logged in.
31
+ #
41
32
  # @param [String] user JIRA user name to login with
42
33
  # @param [String] password
43
- # @return [Boolean] true if successful
34
+ # @return [String] auth_token if successful, otherwise raises an exception
44
35
  def login username, password
45
- response = build 'login', username, password
46
- @auth_token = response.document.xpath('//loginReturn').first.to_s
47
- @user = user
48
- true
36
+ response = soap_call 'login', username, password
37
+ self.auth_token = response.first.content
38
+ @user = user
39
+ self.auth_token
49
40
  end
41
+ alias_method :log_in, :login
50
42
 
51
- # @todo change method name to #logout! since we are changing internal state?
43
+ ##
52
44
  # You only need to call this to make an explicit logout; normally, a session
53
45
  # will automatically expire after a set time (configured on the server).
54
46
  # @return [Boolean] true if successful, otherwise false
55
47
  def logout
56
- call( 'logout' ).to_boolean
48
+ jira_call( 'logout' ).to_boolean
57
49
  end
50
+ alias_method :log_out, :logout
58
51
 
59
52
  # @endgroup
60
53
 
61
54
 
62
55
  private
63
56
 
57
+ # XPath constant to get a node containing a response data.
58
+ RESPONSE_XPATH = '/node()[1]/node()[1]/node()[1]/node()[2]'.freeze
59
+
60
+ ##
64
61
  # @todo make this method less ugly
65
- # @todo double check the return type
62
+ # @todo handle arrays of strings
63
+ #
66
64
  # A generic method for calling a SOAP method and soapifying all
67
- # the arguments, adapted for usage with jiraSOAP.
68
- # @param [String] method
69
- # @param [Object] *args
65
+ # the arguments.
66
+ #
67
+ # @param [String] method name of the JIRA SOAP API method
68
+ # @param [Object] *args the arguments for the method, excluding the
69
+ # authentication token
70
70
  # @return [Handsoap::Response]
71
71
  def build method, *args
72
72
  invoke "soap:#{method}" do |msg|
73
73
  for i in 0...args.size
74
- arg = args.shift
75
- case arg
74
+ case arg = args.shift
76
75
  when JIRA::Entity
77
76
  msg.add "soap:in#{i}", do |submsg| arg.soapify_for submsg end
78
77
  else
@@ -82,27 +81,34 @@ module RemoteAPI
82
81
  end
83
82
  end
84
83
 
85
- # @todo find a less blunt XPath expression
84
+ # @return [Nokogiri::XML::NodeSet]
85
+ def soap_call method, *args
86
+ response = build method, *args
87
+ response .document.element/RESPONSE_XPATH
88
+ end
89
+
90
+ ##
86
91
  # A simple call, for methods that will return a single object.
92
+ #
87
93
  # @param [String] method
88
94
  # @param [Object] *args
89
- # @return [Handsoap::XmlQueryFront::NodeSelection]
90
- def call method, *args
91
- response = build method, @auth_token, *args
92
- response .document.xpath "//#{method}Return"
95
+ # @return [Nokogiri::XML::Element]
96
+ def jira_call method, *args
97
+ response = soap_call method, self.auth_token, *args
98
+ response.first
93
99
  end
94
100
 
101
+ ##
95
102
  # A more complex form of {#call} that does a little more work for
96
103
  # you when you need to build an array of return values.
97
- # @param [String] method
98
- # @param [Object] *args
99
- # @return [Handsoap::XmlQueryFront::NodeSelection]
100
- def jira_call type, method, *args
101
- response = build method, @auth_token, *args
102
- frags = response.document.xpath("#{RESPONSE_XPATH}/#{method}Return")
103
- frags.map { |frag| type.new_with_xml frag }
104
+ #
105
+ # @param [String] method name of the JIRA SOAP API method
106
+ # @param [Object] *args the arguments for the method, excluding the
107
+ # authentication token
108
+ # @return [Nokogiri::XML::NodeSet]
109
+ def array_jira_call type, method, *args
110
+ response = soap_call method, self.auth_token, *args
111
+ response.xpath("node()").map { |frag| type.new_with_xml(frag) }
104
112
  end
105
113
 
106
114
  end
107
-
108
- end