Changes between Version 2 and Version 3 of XmlRpcPlugin/Ruby
- Timestamp:
- Sep 6, 2016, 6:53:08 PM (8 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
XmlRpcPlugin/Ruby
v2 v3 1 === Using XMLRPC from Ruby === 1 [[PageOutline(2-5,Contents,pullout)]] 2 2 3 You can either use the XMLRPC functionality included in the [http://ruby-doc.org/stdlib/libdoc/xmlrpc/rdoc/index.html Ruby Standard Library] or [/attachment/wiki/XmlRpcPlugin/trac4r.tar.gz download the trac4r library] which does all the trivial stuff for you. 3 = Using XMLRPC from Ruby 4 4 5 please refer to the '''SSL Support''' section if you need one.5 You can either use the XML-RPC functionality included in the [http://ruby-doc.org/stdlib/libdoc/xmlrpc/rdoc/index.html Ruby Standard Library] or [/attachment/wiki/XmlRpcPlugin/trac4r.tar.gz download the trac4r library] which does all the trivial stuff for you. 6 6 7 ==== trac4r Example ==== 7 Please refer to the '''SSL Support''' section if you need one. 8 9 See also: XmlRpcPlugin 10 11 == trac4r Example 12 8 13 This example uses trac4r: 9 {{{ 10 #!ruby 14 {{{#!ruby 11 15 require 'trac4r' 12 # initialize the connection (username and password can be ommitted if not needed, but most of the time you will need them if anonymous doesn't have XMLRPC permissions) 16 # initialize the connection: username and password can be omitted if not needed 17 # most of the time you will need them if anonymous doesn't have XML-RPC permissions 13 18 trac = Trac.new "https://dev.example.com/trac/my_awesome_project", "myusername", "mypassword" 14 19 # get a list of all tickets (as an array of numbers) 15 20 trac.tickets.list :include_closed => true # this is the default anyway 16 21 # get all the tickets 17 # N OTE: the results here are cached, so you can call it as often as you want without producing traffic more than once.22 # Note: the results here are cached, so you can call it as often as you want without producing traffic more than once. 18 23 # use ":cached_results => false" to get the latest version 19 24 trac.tickets.get_all :include_closed => true … … 56 61 Also see the included Documentation in trac4r/doc 57 62 58 If you need to do a custom query do 59 {{{ 60 #!ruby 63 If you need to do a custom query do: 64 {{{#!ruby 61 65 trac.query("system.getAPIVersion") 62 66 }}} 63 The first argument is the method name, all other arguments are directly passed to XMLRPC. 64 For this example of cause you could do `trac.api_version` instead ;) 67 68 The first argument is the method name, all other arguments are directly passed to XML-RPC. 69 For this example of course you could do `trac.api_version` instead. 65 70 66 71 If you have any problems with trac4r you can email me: niklas.cathor (eat) gmail dot com 67 72 68 == == xmlrpc Example ====73 == XML-RPC example 69 74 70 75 An example using XML-RPC directly with Ruby to append to a wiki page: 71 {{{ 72 #!ruby 76 {{{#!ruby 73 77 require 'xmlrpc/client' 74 78 user = "username" … … 83 87 }}} 84 88 85 ==== SSL Support + X509 ==== 89 == SSL Support + X509 90 86 91 The standard ruby xmlrpc client for some reason does not support SSL at all. 87 In order to be able to use the XMLRPC over SSL with both 92 To use the XML-RPC over SSL with both: 88 93 * Client Certificate authentication 89 94 * Basic Authentication 90 One must do as follows. 91 92 in order to proceed, you should have: 95 ...you should have: 93 96 * ca certificate in .pem format 94 97 * personal certificate + RSA key in .p12 format (and its password, of course) … … 102 105 ~/.openssl/certkey.p12 103 106 }}} 104 ===== The Instructions ===== 105 1. apply the patches: 106 1. to the [attachment:"xmlrpc-client.SSL.patch" xmlrpc client] 107 {{{ 107 108 == Installation and Configuration 109 110 1. Apply the patches: 111 1. To the [attachment:"xmlrpc-client.SSL.patch" XML-RPC client]: 112 {{{#!sh 108 113 sudo su - 109 114 cd /usr/lib/ruby/1.8/ 110 115 patch -p0 < /path/to/xmlrpc-client.SSL.patch 111 116 }}} 112 1. to the [attachment:"trac4r-1.2.3.SSL.patch" trac4r gem]113 {{{ 117 1. To the [attachment:"trac4r-1.2.3.SSL.patch" trac4r gem]: 118 {{{#!sh 114 119 sudo su - 115 120 cd /var/lib/gems/1.8/gems/ 116 121 patch -p0 < /path/to/trac4r-1.2.3.SSL.patch 117 122 }}} 118 1. create a .yml file called {{{~/.trac/creds.yml}}} of the following structure:123 1. Create a .yml file called {{{~/.trac/creds.yml}}} of the following structure: 119 124 {{{ 120 125 --- … … 126 131 keypass: yourkeypassword 127 132 }}} 128 * do not forget to chmod the personal files to 600 or 400 129 1. use the data in the code 130 {{{ 131 #!ruby 133 * Do not forget to chmod the personal files to 600 or 400. 134 1. Use the data in the code: 135 {{{#!ruby 132 136 require 'yaml' 133 137 require 'openssl' … … 156 160 }}} 157 161 158 '''N OTE:''' The working environment of the code (trac4r + ssl) is:162 '''Notes:''' The working environment of the code (trac4r + ssl) is: 159 163 * Debian/GNU system: {{{Linux hostname 2.6.26-2-686 #1 SMP Mon Jun 21 05:58:44 UTC 2010 i686 GNU/Linux}}} 160 164 * OpenSSL: {{{OpenSSL 0.9.8g 19 Oct 2007}}}