myexperiment-rest 0.3.0 → 0.3.2

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.
data/CHANGES CHANGED
@@ -1,5 +1,14 @@
1
1
  = Changes log for the MyExperiment via REST Gem
2
2
 
3
+ == Version 0.3.2
4
+ * Updated to libxml-ruby 2.2.2
5
+
6
+
7
+ == Version 0.3.1
8
+ * Renamed xml_uri to content_uri
9
+ * added simple session cookie authentication
10
+
11
+
3
12
  == Version 0.3.0
4
13
  * Added User class to acquire myExperiment's user resource
5
14
  * Added a constants.rb file
data/README CHANGED
@@ -1,7 +1,7 @@
1
1
  = MyExperiment Interaction via REST
2
2
 
3
3
  Authors:: Konstantinos Karasavvas
4
- Gem Version:: 0.3.0
4
+ Gem Version:: 0.3.2
5
5
  Contact:: mailto:kostas.karasavvas@nbic.nl
6
6
  Licence:: MIT (See LICENCE or http://www.opensource.org/licenses/mit-license)
7
7
  Copyright:: (c) 2010 Netherlands Bioinformatics Centre, The Netherlands
data/Rakefile CHANGED
@@ -7,7 +7,7 @@ require 'rdoc/task'
7
7
 
8
8
  spec = Gem::Specification.new do |s|
9
9
  s.name = 'myexperiment-rest'
10
- s.version = '0.3.0'
10
+ s.version = '0.3.2'
11
11
  s.extra_rdoc_files = ['README', 'LICENSE', 'CHANGES']
12
12
  s.summary = 'This is a simple library to access data on myExperiment via its REST API.'
13
13
  s.description = 'This is a simple library to access data on myExperiment via its REST API. Currently supports a subset of the workflow information available.'
@@ -18,7 +18,7 @@ spec = Gem::Specification.new do |s|
18
18
  s.require_path = "lib"
19
19
  s.bindir = "bin"
20
20
  s.add_dependency 'rest-client', '~> 1.6.3'
21
- s.add_dependency 'libxml-ruby', '~> 2.0.9'
21
+ s.add_dependency 'libxml-ruby', '~> 2.2.2'
22
22
  end
23
23
 
24
24
  Gem::PackageTask.new(spec) do |p|
@@ -10,7 +10,7 @@ wkf = Workflow.from_uri(my_exp_workflow)
10
10
 
11
11
 
12
12
  # general
13
- puts wkf.xml_uri
13
+ puts wkf.content_uri
14
14
  puts wkf.title
15
15
  puts wkf.description
16
16
  puts wkf.uploader_uri
@@ -72,6 +72,8 @@
72
72
 
73
73
  <li><a href="./MyExperimentREST/MyExperimentWorkflow.html">MyExperimentREST::MyExperimentWorkflow</a></li>
74
74
 
75
+ <li><a href="./MyExperimentREST/SessionCookie.html">MyExperimentREST::SessionCookie</a></li>
76
+
75
77
  <li><a href="./MyExperimentREST/Urls.html">MyExperimentREST::Urls</a></li>
76
78
 
77
79
  <li><a href="./MyExperimentREST/User.html">MyExperimentREST::User</a></li>
@@ -90,6 +92,18 @@
90
92
 
91
93
  <h1>Changes log for the MyExperiment via REST Gem</h1>
92
94
 
95
+ <h2>Version 0.3.2</h2>
96
+ <ul><li>
97
+ <p>Updated to libxml-ruby 2.2.2</p>
98
+ </li></ul>
99
+
100
+ <h2>Version 0.3.1</h2>
101
+ <ul><li>
102
+ <p>Renamed xml_uri to content_uri</p>
103
+ </li><li>
104
+ <p>added simple session cookie authentication</p>
105
+ </li></ul>
106
+
93
107
  <h2>Version 0.3.0</h2>
94
108
  <ul><li>
95
109
  <p>Added User class to acquire myExperiment’s user resource</p>
@@ -72,6 +72,8 @@
72
72
 
73
73
  <li><a href="./MyExperimentREST/MyExperimentWorkflow.html">MyExperimentREST::MyExperimentWorkflow</a></li>
74
74
 
75
+ <li><a href="./MyExperimentREST/SessionCookie.html">MyExperimentREST::SessionCookie</a></li>
76
+
75
77
  <li><a href="./MyExperimentREST/Urls.html">MyExperimentREST::Urls</a></li>
76
78
 
77
79
  <li><a href="./MyExperimentREST/User.html">MyExperimentREST::User</a></li>
@@ -43,6 +43,9 @@
43
43
  <li><a href="./lib/myexperiment-rest/user_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
44
44
  class="thickbox" title="lib/myexperiment-rest/user.rb">lib/myexperiment-rest/user.rb</a></li>
45
45
 
46
+ <li><a href="./lib/myexperiment-rest/authentication_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
47
+ class="thickbox" title="lib/myexperiment-rest/authentication.rb">lib/myexperiment-rest/authentication.rb</a></li>
48
+
46
49
  <li><a href="./lib/myexperiment-rest/constants_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
47
50
  class="thickbox" title="lib/myexperiment-rest/constants.rb">lib/myexperiment-rest/constants.rb</a></li>
48
51
 
@@ -72,6 +75,8 @@
72
75
 
73
76
  <li><span class="type">CLASS</span> <a href="MyExperimentREST/MyExperimentWorkflow.html">MyExperimentREST::MyExperimentWorkflow</a></li>
74
77
 
78
+ <li><span class="type">CLASS</span> <a href="MyExperimentREST/SessionCookie.html">MyExperimentREST::SessionCookie</a></li>
79
+
75
80
  <li><span class="type">CLASS</span> <a href="MyExperimentREST/User.html">MyExperimentREST::User</a></li>
76
81
 
77
82
  <li><span class="type">CLASS</span> <a href="MyExperimentREST/Workflow.html">MyExperimentREST::Workflow</a></li>
@@ -135,6 +140,8 @@
135
140
 
136
141
  <li><a href="./MyExperimentREST/MyExperimentWorkflow.html">MyExperimentREST::MyExperimentWorkflow</a></li>
137
142
 
143
+ <li><a href="./MyExperimentREST/SessionCookie.html">MyExperimentREST::SessionCookie</a></li>
144
+
138
145
  <li><a href="./MyExperimentREST/Urls.html">MyExperimentREST::Urls</a></li>
139
146
 
140
147
  <li><a href="./MyExperimentREST/User.html">MyExperimentREST::User</a></li>
@@ -154,6 +161,8 @@
154
161
 
155
162
  <div id="description" class="description">
156
163
 
164
+ <p>require ‘rest_client’</p>
165
+
157
166
  </div><!-- description -->
158
167
 
159
168
 
@@ -192,18 +201,27 @@ currently are <tt>WORKFLOW_URL</tt>“+ and <tt>USER_URL</tt>.</p>
192
201
 
193
202
  <div class="method-source-code" id="get_myexperiment_data-source">
194
203
  <pre>
195
- <span class="ruby-comment"># File lib/myexperiment-rest.rb, line 14</span>
204
+ <span class="ruby-comment"># File lib/myexperiment-rest.rb, line 15</span>
196
205
  <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">get_myexperiment_data</span>(<span class="ruby-identifier">resource_url</span>, <span class="ruby-identifier">params</span>)
197
206
  <span class="ruby-keyword">case</span> <span class="ruby-identifier">resource_url</span>
198
207
 
199
208
  <span class="ruby-keyword">when</span> <span class="ruby-constant">Urls</span><span class="ruby-operator">::</span><span class="ruby-constant">WORKFLOW_URL</span>
200
209
  <span class="ruby-keyword">begin</span>
201
210
  <span class="ruby-comment"># Get workflow resource information -- if version is empty it returns the current version</span>
202
- <span class="ruby-identifier">response</span> = <span class="ruby-constant">RestClient</span>.<span class="ruby-identifier">get</span>(<span class="ruby-node">&quot;#{Urls::MYEXPERIMENT_URL}/#{Urls::WORKFLOW_URL}&quot;</span>,
203
- {<span class="ruby-value">:params</span> =<span class="ruby-operator">&gt;</span> {<span class="ruby-string">'id'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-node">&quot;#{params[:id]}&quot;</span>,
204
- <span class="ruby-string">'version'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-node">&quot;#{params[:version]}&quot;</span>,
205
- <span class="ruby-string">'elements'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">'title,description,content-uri,components,uploader'</span>} } )
206
- <span class="ruby-identifier">response</span>
211
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">params</span>[<span class="ruby-value">:session_cookie</span>].<span class="ruby-identifier">empty?</span>
212
+ <span class="ruby-identifier">response</span> = <span class="ruby-constant">RestClient</span>.<span class="ruby-identifier">get</span>(<span class="ruby-node">&quot;#{Urls::MYEXPERIMENT_URL}/#{Urls::WORKFLOW_URL}&quot;</span>,
213
+ {<span class="ruby-value">:params</span> =<span class="ruby-operator">&gt;</span> {<span class="ruby-string">'id'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-node">&quot;#{params[:id]}&quot;</span>,
214
+ <span class="ruby-string">'version'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-node">&quot;#{params[:version]}&quot;</span>,
215
+ <span class="ruby-string">'elements'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">'title,description,content-uri,components,uploader'</span>} } )
216
+ <span class="ruby-identifier">response</span>
217
+ <span class="ruby-keyword">else</span> <span class="ruby-comment"># TODO: reduce repetition.. if else only for the cookie key-value pair!!</span>
218
+ <span class="ruby-identifier">response</span> = <span class="ruby-constant">RestClient</span>.<span class="ruby-identifier">get</span>(<span class="ruby-node">&quot;#{Urls::MYEXPERIMENT_URL}/#{Urls::WORKFLOW_URL}&quot;</span>,
219
+ {<span class="ruby-value">:params</span> =<span class="ruby-operator">&gt;</span> {<span class="ruby-string">'id'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-node">&quot;#{params[:id]}&quot;</span>,
220
+ <span class="ruby-string">'version'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-node">&quot;#{params[:version]}&quot;</span>,
221
+ <span class="ruby-string">'elements'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">'title,description,content-uri,components,uploader'</span>},
222
+ <span class="ruby-value">:cookies</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">params</span>[<span class="ruby-value">:session_cookie</span>] } )
223
+ <span class="ruby-identifier">response</span>
224
+ <span class="ruby-keyword">end</span>
207
225
  <span class="ruby-keyword">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
208
226
  <span class="ruby-identifier">raise</span> <span class="ruby-string">&quot;REST call to acquire workflow resource failed!\n&quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">e</span>
209
227
  <span class="ruby-keyword">end</span>
@@ -116,6 +116,8 @@
116
116
 
117
117
  <li><a href="../MyExperimentREST/MyExperimentWorkflow.html">MyExperimentREST::MyExperimentWorkflow</a></li>
118
118
 
119
+ <li><a href="../MyExperimentREST/SessionCookie.html">MyExperimentREST::SessionCookie</a></li>
120
+
119
121
  <li><a href="../MyExperimentREST/Urls.html">MyExperimentREST::Urls</a></li>
120
122
 
121
123
  <li><a href="../MyExperimentREST/User.html">MyExperimentREST::User</a></li>
@@ -227,7 +229,7 @@ descriptions and examples. The last two are lists.</p>
227
229
 
228
230
  <div class="method-source-code" id="from_xml-source">
229
231
  <pre>
230
- <span class="ruby-comment"># File lib/myexperiment-rest/workflow.rb, line 115</span>
232
+ <span class="ruby-comment"># File lib/myexperiment-rest/workflow.rb, line 113</span>
231
233
  <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">from_xml</span>(<span class="ruby-identifier">xml_node</span>)
232
234
  <span class="ruby-identifier">name</span> = <span class="ruby-string">''</span>
233
235
  <span class="ruby-identifier">descriptions</span> = []
@@ -283,7 +285,7 @@ descriptions and examples. The last two are lists.</p>
283
285
 
284
286
  <div class="method-source-code" id="new-source">
285
287
  <pre>
286
- <span class="ruby-comment"># File lib/myexperiment-rest/workflow.rb, line 109</span>
288
+ <span class="ruby-comment"># File lib/myexperiment-rest/workflow.rb, line 107</span>
287
289
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">attributes</span>)
288
290
  <span class="ruby-ivar">@name</span> = <span class="ruby-identifier">attributes</span>[<span class="ruby-value">:name</span>]
289
291
  <span class="ruby-ivar">@descriptions</span> = <span class="ruby-identifier">attributes</span>[<span class="ruby-value">:descriptions</span>]
@@ -116,6 +116,8 @@
116
116
 
117
117
  <li><a href="../MyExperimentREST/MyExperimentWorkflow.html">MyExperimentREST::MyExperimentWorkflow</a></li>
118
118
 
119
+ <li><a href="../MyExperimentREST/SessionCookie.html">MyExperimentREST::SessionCookie</a></li>
120
+
119
121
  <li><a href="../MyExperimentREST/Urls.html">MyExperimentREST::Urls</a></li>
120
122
 
121
123
  <li><a href="../MyExperimentREST/User.html">MyExperimentREST::User</a></li>
@@ -116,6 +116,8 @@
116
116
 
117
117
  <li><a href="../MyExperimentREST/MyExperimentWorkflow.html">MyExperimentREST::MyExperimentWorkflow</a></li>
118
118
 
119
+ <li><a href="../MyExperimentREST/SessionCookie.html">MyExperimentREST::SessionCookie</a></li>
120
+
119
121
  <li><a href="../MyExperimentREST/Urls.html">MyExperimentREST::Urls</a></li>
120
122
 
121
123
  <li><a href="../MyExperimentREST/User.html">MyExperimentREST::User</a></li>
@@ -136,14 +138,10 @@
136
138
  <div id="description" class="description">
137
139
 
138
140
  <p>Contains all available information about a workflow: <em><a
139
- href="MyExperimentWorkflow.html#attribute-i-xml_uri">xml_uri</a></em>,
141
+ href="MyExperimentWorkflow.html#attribute-i-content_uri">content_uri</a></em>,
140
142
  <em>title</em>, <em>description</em>,<em>inputs</em>, <em>outputs</em> and
141
143
  <em><a
142
- href="MyExperimentWorkflow.html#attribute-i-uploader_uri">uploader_uri</a></em>.
143
- The <em><a
144
- href="MyExperimentWorkflow.html#attribute-i-xml_uri">xml_uri</a></em>
145
- specifies the XML description on myExperiment and not the XML of the
146
- workflow itself.</p>
144
+ href="MyExperimentWorkflow.html#attribute-i-uploader_uri">uploader_uri</a></em>.</p>
147
145
 
148
146
  </div><!-- description -->
149
147
 
@@ -161,6 +159,21 @@ workflow itself.</p>
161
159
  <h3 class="section-header">Attributes</h3>
162
160
 
163
161
 
162
+ <div id="content_uri-attribute-method" class="method-detail">
163
+ <a name="content_uri"></a>
164
+
165
+ <div class="method-heading attribute-method-heading">
166
+ <span class="method-name">content_uri</span><span
167
+ class="attribute-access-type">[R]</span>
168
+ </div>
169
+
170
+ <div class="method-description">
171
+
172
+
173
+
174
+ </div>
175
+ </div>
176
+
164
177
  <div id="description-attribute-method" class="method-detail">
165
178
  <a name="description"></a>
166
179
 
@@ -233,21 +246,6 @@ workflow itself.</p>
233
246
 
234
247
 
235
248
 
236
- </div>
237
- </div>
238
-
239
- <div id="xml_uri-attribute-method" class="method-detail">
240
- <a name="xml_uri"></a>
241
-
242
- <div class="method-heading attribute-method-heading">
243
- <span class="method-name">xml_uri</span><span
244
- class="attribute-access-type">[R]</span>
245
- </div>
246
-
247
- <div class="method-description">
248
-
249
-
250
-
251
249
  </div>
252
250
  </div>
253
251
 
@@ -279,9 +277,9 @@ workflow itself.</p>
279
277
 
280
278
  <div class="method-source-code" id="new-source">
281
279
  <pre>
282
- <span class="ruby-comment"># File lib/myexperiment-rest/workflow.rb, line 61</span>
280
+ <span class="ruby-comment"># File lib/myexperiment-rest/workflow.rb, line 59</span>
283
281
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">attributes</span>)
284
- <span class="ruby-ivar">@xml_uri</span> = <span class="ruby-identifier">attributes</span>[<span class="ruby-value">:xml_uri</span>]
282
+ <span class="ruby-ivar">@content_uri</span> = <span class="ruby-identifier">attributes</span>[<span class="ruby-value">:content_uri</span>]
285
283
  <span class="ruby-ivar">@title</span> = <span class="ruby-identifier">attributes</span>[<span class="ruby-value">:title</span>]
286
284
  <span class="ruby-ivar">@description</span> = <span class="ruby-identifier">attributes</span>[<span class="ruby-value">:description</span>]
287
285
  <span class="ruby-ivar">@inputs</span> = <span class="ruby-identifier">attributes</span>[<span class="ruby-value">:inputs</span>]
@@ -318,7 +316,7 @@ href="MyExperimentWorkflow.html">MyExperimentWorkflow</a></em> object</p>
318
316
 
319
317
  <div class="method-source-code" id="parse-source">
320
318
  <pre>
321
- <span class="ruby-comment"># File lib/myexperiment-rest/workflow.rb, line 71</span>
319
+ <span class="ruby-comment"># File lib/myexperiment-rest/workflow.rb, line 69</span>
322
320
  <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">xml</span>)
323
321
 
324
322
  <span class="ruby-identifier">wkf_inputs</span> = []
@@ -335,7 +333,7 @@ href="MyExperimentWorkflow.html">MyExperimentWorkflow</a></em> object</p>
335
333
  <span class="ruby-keyword">end</span>
336
334
 
337
335
 
338
- <span class="ruby-identifier">new</span>(<span class="ruby-value">:xml_uri</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">doc</span>.<span class="ruby-identifier">find_first</span>(<span class="ruby-string">&quot;/workflow/content-uri&quot;</span>).<span class="ruby-identifier">content</span>,
336
+ <span class="ruby-identifier">new</span>(<span class="ruby-value">:content_uri</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">doc</span>.<span class="ruby-identifier">find_first</span>(<span class="ruby-string">&quot;/workflow/content-uri&quot;</span>).<span class="ruby-identifier">content</span>,
339
337
  <span class="ruby-value">:title</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">doc</span>.<span class="ruby-identifier">find_first</span>(<span class="ruby-string">&quot;/workflow/title&quot;</span>).<span class="ruby-identifier">content</span>,
340
338
  <span class="ruby-value">:description</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">doc</span>.<span class="ruby-identifier">find_first</span>(<span class="ruby-string">&quot;/workflow/description&quot;</span>).<span class="ruby-identifier">content</span>,
341
339
  <span class="ruby-value">:inputs</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">wkf_inputs</span>,
@@ -0,0 +1,216 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
+ <head>
6
+ <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
7
+
8
+ <title>Class: MyExperimentREST::SessionCookie</title>
9
+
10
+ <link rel="stylesheet" href="../rdoc.css" type="text/css" media="screen" />
11
+
12
+ <script src="../js/jquery.js" type="text/javascript" charset="utf-8"></script>
13
+ <script src="../js/thickbox-compressed.js" type="text/javascript" charset="utf-8"></script>
14
+ <script src="../js/quicksearch.js" type="text/javascript" charset="utf-8"></script>
15
+ <script src="../js/darkfish.js" type="text/javascript" charset="utf-8"></script>
16
+
17
+ </head>
18
+ <body id="top" class="class">
19
+
20
+ <div id="metadata">
21
+ <div id="home-metadata">
22
+ <div id="home-section" class="section">
23
+ <h3 class="section-header">
24
+ <a href="../index.html">Home</a>
25
+ <a href="../index.html#classes">Classes</a>
26
+ <a href="../index.html#methods">Methods</a>
27
+ </h3>
28
+ </div>
29
+ </div>
30
+
31
+ <div id="file-metadata">
32
+ <div id="file-list-section" class="section">
33
+ <h3 class="section-header">In Files</h3>
34
+ <div class="section-body">
35
+ <ul>
36
+
37
+ <li><a href="../lib/myexperiment-rest/authentication_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
38
+ class="thickbox" title="lib/myexperiment-rest/authentication.rb">lib/myexperiment-rest/authentication.rb</a></li>
39
+
40
+ </ul>
41
+ </div>
42
+ </div>
43
+
44
+
45
+ </div>
46
+
47
+ <div id="class-metadata">
48
+
49
+ <!-- Parent Class -->
50
+ <div id="parent-class-section" class="section">
51
+ <h3 class="section-header">Parent</h3>
52
+
53
+ <p class="link">Object</p>
54
+
55
+ </div>
56
+
57
+
58
+
59
+
60
+
61
+
62
+
63
+ <!-- Method Quickref -->
64
+ <div id="method-list-section" class="section">
65
+ <h3 class="section-header">Methods</h3>
66
+ <ul class="link-list">
67
+
68
+ <li><a href="#method-c-create_session_cookie">::create_session_cookie</a></li>
69
+
70
+ </ul>
71
+ </div>
72
+
73
+
74
+
75
+ </div>
76
+
77
+ <div id="project-metadata">
78
+
79
+
80
+ <div id="fileindex-section" class="section project-section">
81
+ <h3 class="section-header">Files</h3>
82
+ <ul>
83
+
84
+ <li class="file"><a href="../CHANGES.html">CHANGES</a></li>
85
+
86
+ <li class="file"><a href="../LICENSE.html">LICENSE</a></li>
87
+
88
+ <li class="file"><a href="../README.html">README</a></li>
89
+
90
+ </ul>
91
+ </div>
92
+
93
+
94
+ <div id="classindex-section" class="section project-section">
95
+ <h3 class="section-header">Class/Module Index
96
+ <span class="search-toggle"><img src="../images/find.png"
97
+ height="16" width="16" alt="[+]"
98
+ title="show/hide quicksearch" /></span></h3>
99
+ <form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
100
+ <fieldset>
101
+ <legend>Quicksearch</legend>
102
+ <input type="text" name="quicksearch" value=""
103
+ class="quicksearch-field" />
104
+ </fieldset>
105
+ </form>
106
+
107
+ <ul class="link-list">
108
+
109
+ <li><a href="../MyExperimentREST.html">MyExperimentREST</a></li>
110
+
111
+ <li><a href="../MyExperimentREST/MyExperimentIOData.html">MyExperimentREST::MyExperimentIOData</a></li>
112
+
113
+ <li><a href="../MyExperimentREST/MyExperimentUser.html">MyExperimentREST::MyExperimentUser</a></li>
114
+
115
+ <li><a href="../MyExperimentREST/MyExperimentWorkflow.html">MyExperimentREST::MyExperimentWorkflow</a></li>
116
+
117
+ <li><a href="../MyExperimentREST/SessionCookie.html">MyExperimentREST::SessionCookie</a></li>
118
+
119
+ <li><a href="../MyExperimentREST/Urls.html">MyExperimentREST::Urls</a></li>
120
+
121
+ <li><a href="../MyExperimentREST/User.html">MyExperimentREST::User</a></li>
122
+
123
+ <li><a href="../MyExperimentREST/Workflow.html">MyExperimentREST::Workflow</a></li>
124
+
125
+ </ul>
126
+ <div id="no-class-search-results" style="display: none;">No matching classes.</div>
127
+ </div>
128
+
129
+
130
+ </div>
131
+ </div>
132
+
133
+ <div id="documentation">
134
+ <h1 class="class">MyExperimentREST::SessionCookie</h1>
135
+
136
+ <div id="description" class="description">
137
+
138
+ <p>Connects to myExperiment REST API and creates a session cookie object that
139
+ can be used for basic authentication.</p>
140
+
141
+ </div><!-- description -->
142
+
143
+
144
+ <div id="5Buntitled-5D" class="documentation-section">
145
+
146
+
147
+
148
+
149
+
150
+
151
+
152
+
153
+ <!-- Methods -->
154
+
155
+ <div id="public-class-method-details" class="method-section section">
156
+ <h3 class="section-header">Public Class Methods</h3>
157
+
158
+
159
+ <div id="create_session_cookie-method" class="method-detail ">
160
+ <a name="method-c-create_session_cookie"></a>
161
+
162
+
163
+ <div class="method-heading">
164
+ <span class="method-name">create_session_cookie</span><span
165
+ class="method-args">(username, password)</span>
166
+ <span class="method-click-advice">click to toggle source</span>
167
+ </div>
168
+
169
+
170
+ <div class="method-description">
171
+
172
+ <p>Returns a session cookie as a string.</p>
173
+
174
+
175
+
176
+ <div class="method-source-code" id="create_session_cookie-source">
177
+ <pre>
178
+ <span class="ruby-comment"># File lib/myexperiment-rest/authentication.rb, line 12</span>
179
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">create_session_cookie</span>(<span class="ruby-identifier">username</span>, <span class="ruby-identifier">password</span>)
180
+ <span class="ruby-keyword">begin</span>
181
+ <span class="ruby-comment"># Create a session cookie</span>
182
+ <span class="ruby-identifier">response</span> = <span class="ruby-constant">RestClient</span>.<span class="ruby-identifier">post</span>(<span class="ruby-node">&quot;#{Urls::MYEXPERIMENT_URL}/#{Urls::SESSION_URL}&quot;</span>,
183
+ <span class="ruby-node">&quot;&lt;session&gt;&lt;username&gt;#{username}&lt;/username&gt;&lt;password&gt;#{password}&lt;/password&gt;&lt;/session&gt;&quot;</span>,
184
+ {<span class="ruby-value">:content_type</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">'application/xml'</span>} )
185
+ <span class="ruby-identifier">response</span>.<span class="ruby-identifier">cookies</span>
186
+ <span class="ruby-keyword">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
187
+ <span class="ruby-identifier">raise</span> <span class="ruby-string">&quot;REST call to acquire workflow resource failed!\n&quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">e</span>
188
+ <span class="ruby-keyword">end</span>
189
+
190
+ <span class="ruby-keyword">end</span></pre>
191
+ </div><!-- create_session_cookie-source -->
192
+
193
+ </div>
194
+
195
+
196
+
197
+
198
+ </div><!-- create_session_cookie-method -->
199
+
200
+
201
+ </div><!-- public-class-method-details -->
202
+
203
+ </div><!-- 5Buntitled-5D -->
204
+
205
+
206
+ </div><!-- documentation -->
207
+
208
+ <div id="validator-badges">
209
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
210
+ <p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
211
+ Rdoc Generator</a> 2</small>.</p>
212
+ </div>
213
+
214
+ </body>
215
+ </html>
216
+
@@ -96,6 +96,8 @@
96
96
 
97
97
  <li><a href="../MyExperimentREST/MyExperimentWorkflow.html">MyExperimentREST::MyExperimentWorkflow</a></li>
98
98
 
99
+ <li><a href="../MyExperimentREST/SessionCookie.html">MyExperimentREST::SessionCookie</a></li>
100
+
99
101
  <li><a href="../MyExperimentREST/Urls.html">MyExperimentREST::Urls</a></li>
100
102
 
101
103
  <li><a href="../MyExperimentREST/User.html">MyExperimentREST::User</a></li>
@@ -134,6 +136,11 @@
134
136
  <dd class="description"><p>URL constants</p></dd>
135
137
 
136
138
 
139
+ <dt><a name="SESSION_URL">SESSION_URL</a></dt>
140
+
141
+ <dd class="description"></dd>
142
+
143
+
137
144
  <dt><a name="USER_URL">USER_URL</a></dt>
138
145
 
139
146
  <dd class="description"></dd>
@@ -116,6 +116,8 @@
116
116
 
117
117
  <li><a href="../MyExperimentREST/MyExperimentWorkflow.html">MyExperimentREST::MyExperimentWorkflow</a></li>
118
118
 
119
+ <li><a href="../MyExperimentREST/SessionCookie.html">MyExperimentREST::SessionCookie</a></li>
120
+
119
121
  <li><a href="../MyExperimentREST/Urls.html">MyExperimentREST::Urls</a></li>
120
122
 
121
123
  <li><a href="../MyExperimentREST/User.html">MyExperimentREST::User</a></li>
@@ -116,6 +116,8 @@
116
116
 
117
117
  <li><a href="../MyExperimentREST/MyExperimentWorkflow.html">MyExperimentREST::MyExperimentWorkflow</a></li>
118
118
 
119
+ <li><a href="../MyExperimentREST/SessionCookie.html">MyExperimentREST::SessionCookie</a></li>
120
+
119
121
  <li><a href="../MyExperimentREST/Urls.html">MyExperimentREST::Urls</a></li>
120
122
 
121
123
  <li><a href="../MyExperimentREST/User.html">MyExperimentREST::User</a></li>
@@ -162,7 +164,7 @@ href="MyExperimentWorkflow.html">MyExperimentWorkflow</a></em> object.</p>
162
164
 
163
165
  <div class="method-heading">
164
166
  <span class="method-name">from_id_and_version</span><span
165
- class="method-args">(id, version='')</span>
167
+ class="method-args">(id, version='', session_cookie={})</span>
166
168
  <span class="method-click-advice">click to toggle source</span>
167
169
  </div>
168
170
 
@@ -178,10 +180,10 @@ a myExperiment id and version for that workflow.</p>
178
180
  <div class="method-source-code" id="from_id_and_version-source">
179
181
  <pre>
180
182
  <span class="ruby-comment"># File lib/myexperiment-rest/workflow.rb, line 38</span>
181
- <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">from_id_and_version</span>(<span class="ruby-identifier">id</span>, <span class="ruby-identifier">version</span>=<span class="ruby-string">''</span>)
183
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">from_id_and_version</span>(<span class="ruby-identifier">id</span>, <span class="ruby-identifier">version</span>=<span class="ruby-string">''</span>, <span class="ruby-identifier">session_cookie</span>={})
182
184
 
183
185
  <span class="ruby-comment"># Get workflow resource information</span>
184
- <span class="ruby-identifier">xml</span> = <span class="ruby-constant">MyExperimentREST</span>.<span class="ruby-identifier">get_myexperiment_data</span>(<span class="ruby-constant">Urls</span><span class="ruby-operator">::</span><span class="ruby-constant">WORKFLOW_URL</span>, <span class="ruby-value">:id</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">id</span>, <span class="ruby-value">:version</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">version</span>)
186
+ <span class="ruby-identifier">xml</span> = <span class="ruby-constant">MyExperimentREST</span>.<span class="ruby-identifier">get_myexperiment_data</span>(<span class="ruby-constant">Urls</span><span class="ruby-operator">::</span><span class="ruby-constant">WORKFLOW_URL</span>, <span class="ruby-value">:id</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">id</span>, <span class="ruby-value">:version</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">version</span>, <span class="ruby-value">:session_cookie</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">session_cookie</span>)
185
187
 
186
188
  <span class="ruby-constant">MyExperimentWorkflow</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">xml</span>)
187
189
  <span class="ruby-keyword">end</span></pre>
@@ -201,7 +203,7 @@ a myExperiment id and version for that workflow.</p>
201
203
 
202
204
  <div class="method-heading">
203
205
  <span class="method-name">from_uri</span><span
204
- class="method-args">(uri)</span>
206
+ class="method-args">(uri, session_cookie={})</span>
205
207
  <span class="method-click-advice">click to toggle source</span>
206
208
  </div>
207
209
 
@@ -217,7 +219,7 @@ a URI of the workflow in the repository as a String.</p>
217
219
  <div class="method-source-code" id="from_uri-source">
218
220
  <pre>
219
221
  <span class="ruby-comment"># File lib/myexperiment-rest/workflow.rb, line 11</span>
220
- <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">from_uri</span>(<span class="ruby-identifier">uri</span>)
222
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">from_uri</span>(<span class="ruby-identifier">uri</span>, <span class="ruby-identifier">session_cookie</span>={})
221
223
 
222
224
  <span class="ruby-identifier">workflow_id</span> = <span class="ruby-string">''</span>
223
225
  <span class="ruby-identifier">workflow_version</span> = <span class="ruby-string">''</span>
@@ -237,7 +239,7 @@ a URI of the workflow in the repository as a String.</p>
237
239
  <span class="ruby-keyword">end</span>
238
240
 
239
241
  <span class="ruby-comment"># Get workflow resource information </span>
240
- <span class="ruby-identifier">xml</span> = <span class="ruby-constant">MyExperimentREST</span>.<span class="ruby-identifier">get_myexperiment_data</span>(<span class="ruby-constant">Urls</span><span class="ruby-operator">::</span><span class="ruby-constant">WORKFLOW_URL</span>, <span class="ruby-value">:id</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">workflow_id</span>, <span class="ruby-value">:version</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">workflow_version</span>)
242
+ <span class="ruby-identifier">xml</span> = <span class="ruby-constant">MyExperimentREST</span>.<span class="ruby-identifier">get_myexperiment_data</span>(<span class="ruby-constant">Urls</span><span class="ruby-operator">::</span><span class="ruby-constant">WORKFLOW_URL</span>, <span class="ruby-value">:id</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">workflow_id</span>, <span class="ruby-value">:version</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">workflow_version</span>, <span class="ruby-value">:session_cookie</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">session_cookie</span>)
241
243
 
242
244
  <span class="ruby-constant">MyExperimentWorkflow</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">xml</span>)
243
245
  <span class="ruby-keyword">end</span></pre>
@@ -72,6 +72,8 @@
72
72
 
73
73
  <li><a href="./MyExperimentREST/MyExperimentWorkflow.html">MyExperimentREST::MyExperimentWorkflow</a></li>
74
74
 
75
+ <li><a href="./MyExperimentREST/SessionCookie.html">MyExperimentREST::SessionCookie</a></li>
76
+
75
77
  <li><a href="./MyExperimentREST/Urls.html">MyExperimentREST::Urls</a></li>
76
78
 
77
79
  <li><a href="./MyExperimentREST/User.html">MyExperimentREST::User</a></li>
@@ -94,7 +96,7 @@
94
96
  <p>Konstantinos Karasavvas</p>
95
97
  </td></tr><tr><td class="rdoc-term"><p>Gem Version</p></td>
96
98
  <td>
97
- <p>0.3.0</p>
99
+ <p>0.3.2</p>
98
100
  </td></tr><tr><td class="rdoc-term"><p>Contact</p></td>
99
101
  <td>
100
102
  <p><a href="mailto:kostas.karasavvas@nbic.nl">kostas.karasavvas@nbic.nl</a></p>
@@ -1,8 +1,9 @@
1
- Wed, 28 Sep 2011 12:45:52 +0200
1
+ Mon, 16 Jan 2012 11:48:00 +0100
2
2
  LICENSE Tue, 26 Jul 2011 16:45:34 +0200
3
- lib/myexperiment-rest/constants.rb Wed, 28 Sep 2011 10:04:55 +0200
4
- README Wed, 28 Sep 2011 12:41:40 +0200
3
+ lib/myexperiment-rest/constants.rb Thu, 29 Sep 2011 16:33:55 +0200
4
+ README Mon, 16 Jan 2012 11:47:36 +0100
5
5
  lib/myexperiment-rest/user.rb Wed, 28 Sep 2011 12:11:32 +0200
6
- lib/myexperiment-rest.rb Wed, 28 Sep 2011 12:07:50 +0200
7
- CHANGES Wed, 28 Sep 2011 12:42:24 +0200
8
- lib/myexperiment-rest/workflow.rb Wed, 28 Sep 2011 12:32:43 +0200
6
+ lib/myexperiment-rest.rb Tue, 04 Oct 2011 15:07:41 +0200
7
+ CHANGES Mon, 16 Jan 2012 11:47:22 +0100
8
+ lib/myexperiment-rest/authentication.rb Mon, 03 Oct 2011 12:20:41 +0200
9
+ lib/myexperiment-rest/workflow.rb Mon, 03 Oct 2011 12:44:03 +0200
@@ -29,7 +29,7 @@
29
29
  <p>Konstantinos Karasavvas</p>
30
30
  </td></tr><tr><td class="rdoc-term"><p>Gem Version</p></td>
31
31
  <td>
32
- <p>0.3.0</p>
32
+ <p>0.3.2</p>
33
33
  </td></tr><tr><td class="rdoc-term"><p>Contact</p></td>
34
34
  <td>
35
35
  <p><a href="mailto:kostas.karasavvas@nbic.nl">kostas.karasavvas@nbic.nl</a></p>
@@ -94,6 +94,8 @@ demonstrates how you can use the library: $ get_workflow_data.rb.</p>
94
94
 
95
95
  <li class="class"><a href="MyExperimentREST/MyExperimentWorkflow.html">MyExperimentREST::MyExperimentWorkflow</a></li>
96
96
 
97
+ <li class="class"><a href="MyExperimentREST/SessionCookie.html">MyExperimentREST::SessionCookie</a></li>
98
+
97
99
  <li class="module"><a href="MyExperimentREST/Urls.html">MyExperimentREST::Urls</a></li>
98
100
 
99
101
  <li class="class"><a href="MyExperimentREST/User.html">MyExperimentREST::User</a></li>
@@ -105,22 +107,24 @@ demonstrates how you can use the library: $ get_workflow_data.rb.</p>
105
107
  <h2 id="methods">Methods</h2>
106
108
  <ul>
107
109
 
110
+ <li><a href="MyExperimentREST/SessionCookie.html#method-c-create_session_cookie">::create_session_cookie &mdash; MyExperimentREST::SessionCookie</a></li>
111
+
108
112
  <li><a href="MyExperimentREST/User.html#method-c-from_id">::from_id &mdash; MyExperimentREST::User</a></li>
109
113
 
110
114
  <li><a href="MyExperimentREST/Workflow.html#method-c-from_id_and_version">::from_id_and_version &mdash; MyExperimentREST::Workflow</a></li>
111
115
 
112
- <li><a href="MyExperimentREST/User.html#method-c-from_uri">::from_uri &mdash; MyExperimentREST::User</a></li>
113
-
114
116
  <li><a href="MyExperimentREST/Workflow.html#method-c-from_uri">::from_uri &mdash; MyExperimentREST::Workflow</a></li>
115
117
 
118
+ <li><a href="MyExperimentREST/User.html#method-c-from_uri">::from_uri &mdash; MyExperimentREST::User</a></li>
119
+
116
120
  <li><a href="MyExperimentREST/MyExperimentIOData.html#method-c-from_xml">::from_xml &mdash; MyExperimentREST::MyExperimentIOData</a></li>
117
121
 
118
122
  <li><a href="MyExperimentREST.html#method-c-get_myexperiment_data">::get_myexperiment_data &mdash; MyExperimentREST</a></li>
119
123
 
120
- <li><a href="MyExperimentREST/MyExperimentUser.html#method-c-new">::new &mdash; MyExperimentREST::MyExperimentUser</a></li>
121
-
122
124
  <li><a href="MyExperimentREST/MyExperimentWorkflow.html#method-c-new">::new &mdash; MyExperimentREST::MyExperimentWorkflow</a></li>
123
125
 
126
+ <li><a href="MyExperimentREST/MyExperimentUser.html#method-c-new">::new &mdash; MyExperimentREST::MyExperimentUser</a></li>
127
+
124
128
  <li><a href="MyExperimentREST/MyExperimentIOData.html#method-c-new">::new &mdash; MyExperimentREST::MyExperimentIOData</a></li>
125
129
 
126
130
  <li><a href="MyExperimentREST/MyExperimentUser.html#method-c-parse">::parse &mdash; MyExperimentREST::MyExperimentUser</a></li>
@@ -0,0 +1,54 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4
+
5
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
6
+ <head>
7
+ <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
8
+
9
+ <title>File: authentication.rb [myexperiment-rest Docs]</title>
10
+
11
+ <link type="text/css" media="screen" href="../../rdoc.css" rel="stylesheet" />
12
+
13
+ <script src="../../js/jquery.js" type="text/javascript"
14
+ charset="utf-8"></script>
15
+ <script src="../../js/thickbox-compressed.js" type="text/javascript"
16
+ charset="utf-8"></script>
17
+ <script src="../../js/quicksearch.js" type="text/javascript"
18
+ charset="utf-8"></script>
19
+ <script src="../../js/darkfish.js" type="text/javascript"
20
+ charset="utf-8"></script>
21
+ </head>
22
+
23
+ <body class="file file-popup">
24
+ <div id="metadata">
25
+ <dl>
26
+ <dt class="modified-date">Last Modified</dt>
27
+ <dd class="modified-date">Mon Oct 03 12:20:41 +0200 2011</dd>
28
+
29
+
30
+ <dt class="requires">Requires</dt>
31
+ <dd class="requires">
32
+ <ul>
33
+
34
+ </ul>
35
+ </dd>
36
+
37
+
38
+
39
+ </dl>
40
+ </div>
41
+
42
+ <div id="documentation">
43
+
44
+ <div class="description">
45
+ <h2>Description</h2>
46
+
47
+ <p>require ‘rest_client’</p>
48
+
49
+ </div>
50
+
51
+ </div>
52
+ </body>
53
+ </html>
54
+
@@ -24,7 +24,7 @@
24
24
  <div id="metadata">
25
25
  <dl>
26
26
  <dt class="modified-date">Last Modified</dt>
27
- <dd class="modified-date">Wed Sep 28 10:04:55 +0200 2011</dd>
27
+ <dd class="modified-date">Thu Sep 29 16:33:55 +0200 2011</dd>
28
28
 
29
29
 
30
30
  <dt class="requires">Requires</dt>
@@ -24,7 +24,7 @@
24
24
  <div id="metadata">
25
25
  <dl>
26
26
  <dt class="modified-date">Last Modified</dt>
27
- <dd class="modified-date">Wed Sep 28 12:32:43 +0200 2011</dd>
27
+ <dd class="modified-date">Mon Oct 03 12:44:03 +0200 2011</dd>
28
28
 
29
29
 
30
30
  <dt class="requires">Requires</dt>
@@ -24,7 +24,7 @@
24
24
  <div id="metadata">
25
25
  <dl>
26
26
  <dt class="modified-date">Last Modified</dt>
27
- <dd class="modified-date">Wed Sep 28 12:07:50 +0200 2011</dd>
27
+ <dd class="modified-date">Tue Oct 04 15:07:41 +0200 2011</dd>
28
28
 
29
29
 
30
30
  <dt class="requires">Requires</dt>
@@ -41,6 +41,8 @@
41
41
 
42
42
  <li>myexperiment-rest/user</li>
43
43
 
44
+ <li>myexperiment-rest/authentication</li>
45
+
44
46
  </ul>
45
47
  </dd>
46
48
 
@@ -4,6 +4,7 @@ require 'rest_client'
4
4
  require 'myexperiment-rest/constants'
5
5
  require 'myexperiment-rest/workflow'
6
6
  require 'myexperiment-rest/user'
7
+ require 'myexperiment-rest/authentication'
7
8
 
8
9
 
9
10
  module MyExperimentREST
@@ -17,11 +18,20 @@ module MyExperimentREST
17
18
  when Urls::WORKFLOW_URL
18
19
  begin
19
20
  # Get workflow resource information -- if version is empty it returns the current version
20
- response = RestClient.get("#{Urls::MYEXPERIMENT_URL}/#{Urls::WORKFLOW_URL}",
21
- {:params => {'id' => "#{params[:id]}",
22
- 'version' => "#{params[:version]}",
23
- 'elements' => 'title,description,content-uri,components,uploader'} } )
24
- response
21
+ if params[:session_cookie].empty?
22
+ response = RestClient.get("#{Urls::MYEXPERIMENT_URL}/#{Urls::WORKFLOW_URL}",
23
+ {:params => {'id' => "#{params[:id]}",
24
+ 'version' => "#{params[:version]}",
25
+ 'elements' => 'title,description,content-uri,components,uploader'} } )
26
+ response
27
+ else # TODO: reduce repetition.. if else only for the cookie key-value pair!!
28
+ response = RestClient.get("#{Urls::MYEXPERIMENT_URL}/#{Urls::WORKFLOW_URL}",
29
+ {:params => {'id' => "#{params[:id]}",
30
+ 'version' => "#{params[:version]}",
31
+ 'elements' => 'title,description,content-uri,components,uploader'},
32
+ :cookies => params[:session_cookie] } )
33
+ response
34
+ end
25
35
  rescue Exception => e
26
36
  raise "REST call to acquire workflow resource failed!\n" + e
27
37
  end
@@ -0,0 +1,28 @@
1
+ #require 'rest_client'
2
+
3
+ module MyExperimentREST
4
+
5
+ #
6
+ # Connects to myExperiment REST API and creates a session cookie object that
7
+ # can be used for basic authentication.
8
+ #
9
+ class SessionCookie
10
+
11
+ # Returns a session cookie as a string.
12
+ def self.create_session_cookie(username, password)
13
+ begin
14
+ # Create a session cookie
15
+ response = RestClient.post("#{Urls::MYEXPERIMENT_URL}/#{Urls::SESSION_URL}",
16
+ "<session><username>#{username}</username><password>#{password}</password></session>",
17
+ {:content_type => 'application/xml'} )
18
+ response.cookies
19
+ rescue Exception => e
20
+ raise "REST call to acquire workflow resource failed!\n" + e
21
+ end
22
+
23
+ end
24
+
25
+ end # class SessionCookie
26
+
27
+
28
+ end # module MyExperimentREST
@@ -6,6 +6,7 @@ module MyExperimentREST
6
6
  MYEXPERIMENT_URL = "http://www.myexperiment.org"
7
7
  WORKFLOW_URL = "workflow.xml"
8
8
  USER_URL = "user.xml"
9
+ SESSION_URL = "session/create"
9
10
  end
10
11
 
11
12
  end
@@ -8,7 +8,7 @@ module MyExperimentREST
8
8
  class Workflow
9
9
 
10
10
  # Returns a _MyExperimentWorkflow_ object given a URI of the workflow in the repository as a String.
11
- def self.from_uri(uri)
11
+ def self.from_uri(uri, session_cookie={})
12
12
 
13
13
  workflow_id = ''
14
14
  workflow_version = ''
@@ -28,17 +28,17 @@ module MyExperimentREST
28
28
  end
29
29
 
30
30
  # Get workflow resource information
31
- xml = MyExperimentREST.get_myexperiment_data(Urls::WORKFLOW_URL, :id => workflow_id, :version => workflow_version)
31
+ xml = MyExperimentREST.get_myexperiment_data(Urls::WORKFLOW_URL, :id => workflow_id, :version => workflow_version, :session_cookie => session_cookie)
32
32
 
33
33
  MyExperimentWorkflow.parse(xml)
34
34
  end
35
35
 
36
36
 
37
37
  # Returns a _MyExperimentWorkflow_ object given a myExperiment id and version for that workflow.
38
- def self.from_id_and_version(id, version='')
38
+ def self.from_id_and_version(id, version='', session_cookie={})
39
39
 
40
40
  # Get workflow resource information
41
- xml = MyExperimentREST.get_myexperiment_data(Urls::WORKFLOW_URL, :id => id, :version => version)
41
+ xml = MyExperimentREST.get_myexperiment_data(Urls::WORKFLOW_URL, :id => id, :version => version, :session_cookie => session_cookie)
42
42
 
43
43
  MyExperimentWorkflow.parse(xml)
44
44
  end
@@ -49,17 +49,15 @@ module MyExperimentREST
49
49
 
50
50
 
51
51
  #
52
- # Contains all available information about a workflow: _xml_uri_,
53
- # _title_, _description_,_inputs_, _outputs_ and _uploader_uri_. The _xml_uri_
54
- # specifies the XML description on myExperiment and not the XML of the workflow
55
- # itself.
52
+ # Contains all available information about a workflow: _content_uri_,
53
+ # _title_, _description_,_inputs_, _outputs_ and _uploader_uri_.
56
54
  #
57
55
  class MyExperimentWorkflow
58
56
 
59
- attr_reader(:xml_uri, :title, :description, :inputs, :outputs, :uploader_uri)
57
+ attr_reader(:content_uri, :title, :description, :inputs, :outputs, :uploader_uri)
60
58
 
61
59
  def initialize(attributes)
62
- @xml_uri = attributes[:xml_uri]
60
+ @content_uri = attributes[:content_uri]
63
61
  @title = attributes[:title]
64
62
  @description = attributes[:description]
65
63
  @inputs = attributes[:inputs]
@@ -84,7 +82,7 @@ module MyExperimentREST
84
82
  end
85
83
 
86
84
 
87
- new(:xml_uri => doc.find_first("/workflow/content-uri").content,
85
+ new(:content_uri => doc.find_first("/workflow/content-uri").content,
88
86
  :title => doc.find_first("/workflow/title").content,
89
87
  :description => doc.find_first("/workflow/description").content,
90
88
  :inputs => wkf_inputs,
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: myexperiment-rest
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 0
10
- version: 0.3.0
9
+ - 2
10
+ version: 0.3.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Konstantinos Karasavvas
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-09-28 00:00:00 Z
18
+ date: 2012-01-16 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: rest-client
@@ -41,12 +41,12 @@ dependencies:
41
41
  requirements:
42
42
  - - ~>
43
43
  - !ruby/object:Gem::Version
44
- hash: 29
44
+ hash: 3
45
45
  segments:
46
46
  - 2
47
- - 0
48
- - 9
49
- version: 2.0.9
47
+ - 2
48
+ - 2
49
+ version: 2.2.2
50
50
  type: :runtime
51
51
  version_requirements: *id002
52
52
  description: This is a simple library to access data on myExperiment via its REST API. Currently supports a subset of the workflow information available.
@@ -68,6 +68,7 @@ files:
68
68
  - lib/myexperiment-rest.rb
69
69
  - lib/myexperiment-rest/workflow.rb
70
70
  - lib/myexperiment-rest/user.rb
71
+ - lib/myexperiment-rest/authentication.rb
71
72
  - lib/myexperiment-rest/constants.rb
72
73
  - doc/rdoc/rdoc.css
73
74
  - doc/rdoc/LICENSE.html
@@ -79,6 +80,7 @@ files:
79
80
  - doc/rdoc/MyExperimentREST.html
80
81
  - doc/rdoc/README.html
81
82
  - doc/rdoc/lib/myexperiment-rest/constants_rb.html
83
+ - doc/rdoc/lib/myexperiment-rest/authentication_rb.html
82
84
  - doc/rdoc/lib/myexperiment-rest/user_rb.html
83
85
  - doc/rdoc/lib/myexperiment-rest/workflow_rb.html
84
86
  - doc/rdoc/lib/myexperiment-rest_rb.html
@@ -110,6 +112,7 @@ files:
110
112
  - doc/rdoc/MyExperimentREST/MyExperimentUser.html
111
113
  - doc/rdoc/MyExperimentREST/MyExperimentIOData.html
112
114
  - doc/rdoc/MyExperimentREST/Workflow.html
115
+ - doc/rdoc/MyExperimentREST/SessionCookie.html
113
116
  homepage:
114
117
  licenses: []
115
118