rbbt-views 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -27,6 +27,10 @@ class RbbtRestClient
27
27
  attr_accessor :remote_name
28
28
  attr_accessor :original_name
29
29
  attr_accessor :remote_export
30
+
31
+ def remote_name
32
+ URI.escape(@remote_name)
33
+ end
30
34
  end
31
35
 
32
36
  step.original_name = name || "RestClient"
@@ -49,13 +53,13 @@ class RbbtRestClient
49
53
  def load
50
54
  case task.result_type.to_sym
51
55
  when :string
52
- RestClient.get(File.join(task.url, task.name.to_s, @remote_name) + "?_format=raw")
56
+ RestClient.get(File.join(task.url, task.name.to_s, remote_name) + "?_format=raw")
53
57
  when :tsv
54
- TSV.open(StringIO.new(RestClient.get(File.join(task.url, task.name.to_s, @remote_name) + "?_format=raw")))
58
+ TSV.open(StringIO.new(RestClient.get(File.join(task.url, task.name.to_s, remote_name) + "?_format=raw")))
55
59
  when :annotations
56
- Annotated.load_tsv(TSV.open(StringIO.new(RestClient.get(File.join(task.url, task.name.to_s, @remote_name) + "?_format=raw"))))
60
+ Annotated.load_tsv(TSV.open(StringIO.new(RestClient.get(File.join(task.url, task.name.to_s, remote_name) + "?_format=raw"))))
57
61
  else
58
- res = JSON.parse(RestClient.get(File.join(task.url, task.name.to_s, @remote_name) + "?_format=json"))
62
+ res = JSON.parse(RestClient.get(File.join(task.url, task.name.to_s, remote_name) + "?_format=json"))
59
63
  res = TSV.setup(res) if task.result_type.to_sym == :tsv
60
64
  res
61
65
  end
@@ -63,27 +67,22 @@ class RbbtRestClient
63
67
 
64
68
  def exec
65
69
  input_hash = Misc.zip2hash(task.inputs, @inputs)
66
- input_str = input_hash.collect{|k,v|
67
- [k,
68
- Array === v ? v.dup.collect{|vv| CGI.escape(vv.to_s)} * "," : CGI.escape(v.to_s)
69
- ] * "="
70
- } * "&"
71
70
 
72
71
  case remote_export.to_s
73
72
  when "exec"
74
73
  url = File.join(task.url, task.name.to_s)
75
74
  if task.result_type.to_sym == :string
76
- res = RestClient.post(url, input_hash.merge(:_format => :raw))
75
+ res = RestClient.post(url, Misc.hash2GET_params(input_hash.merge(:_format => :raw)))
77
76
  res
78
77
  else
79
- res = RestClient.post(url, input_hash.merge(:_format => :json))
78
+ res = RestClient.post(url, Misc.hash2GET_params(input_hash.merge(:_format => :json)))
80
79
  JSON.parse(res)
81
80
  end
82
81
  when "synchronous"
83
- @remote_name = RestClient.post(File.join(task.url, task.name.to_s), input_hash.merge(:_format => :json, :jobname => original_name))
82
+ @remote_name = RestClient.post(File.join(task.url, task.name.to_s), Misc.hash2GET_params(input_hash.merge(:_format => :json, :jobname => original_name)))
84
83
  self.load
85
84
  when "asynchronous"
86
- @remote_name = RestClient.post(File.join(task.url, task.name.to_s), input_hash.merge(:_format => :json, :jobname => original_name))
85
+ @remote_name = RestClient.post(File.join(task.url, task.name.to_s), Misc.hash2GET_params(input_hash.merge(:_format => :json, :jobname => original_name)))
87
86
  while not done?
88
87
  sleep 10
89
88
  end
@@ -97,16 +96,15 @@ class RbbtRestClient
97
96
 
98
97
  def fork
99
98
  input_hash = Misc.zip2hash(task.inputs, @inputs)
100
- input_str = input_hash.collect{|p| p * "="} * "&"
101
99
 
102
100
  case remote_export.to_s
103
101
  when "exec"
104
102
  raise "Cannot export a remote function exported as 'exec'"
105
103
  when "synchronous"
106
- @remote_name = RestClient.post(File.join(task.url, task.name.to_s), input_hash.merge(:_format => :json, :jobname => original_name))
104
+ @remote_name = RestClient.post(File.join(task.url, task.name.to_s), Misc.hash2GET_params(input_hash.merge(:_format => :json, :jobname => original_name)))
107
105
  self
108
106
  when "asynchronous"
109
- @remote_name = RestClient.post(File.join(task.url, task.name.to_s), input_hash.merge(:_format => :json, :jobname => original_name))
107
+ @remote_name = RestClient.post(File.join(task.url, task.name.to_s), Misc.hash2GET_params(input_hash.merge(:_format => :json, :jobname => original_name)))
110
108
  self
111
109
  end
112
110
  end
@@ -3,8 +3,17 @@ require 'rbbt/workflow/rest/client'
3
3
 
4
4
  class TestRestClient < Test::Unit::TestCase
5
5
 
6
+ def test_name_escape
7
+ driver = RbbtRestClient.new 'http://studyexplorer.bioinfo.cnio.es/Sequence', "Sequence"
8
+ job = driver.job(:genes_at_genomic_positions, "Default (escape)", :organism => "Hsa", :positions => %w(1:123123:A))
9
+ assert_equal %w(ENSG00000238009), job.exec.values.flatten
10
+ assert_equal %w(ENSG00000238009), job.run.values.flatten
11
+ job.clean
12
+ end
13
+
14
+
6
15
  def test_client_exec
7
- driver = RbbtRestClient.new 'http://localhost:1984/Sequence'
16
+ driver = RbbtRestClient.new 'http://studyexplorer.bioinfo.cnio.es/Sequence', "Sequence"
8
17
  job = driver.job(:genes_at_genomic_positions, "Default", :organism => "Hsa", :positions => %w(1:123123:A))
9
18
  assert_equal %w(ENSG00000238009), job.exec.values.flatten
10
19
  assert_equal %w(ENSG00000238009), job.run.values.flatten
@@ -12,7 +21,7 @@ class TestRestClient < Test::Unit::TestCase
12
21
  end
13
22
 
14
23
  def test_client_synchronous
15
- driver = RbbtRestClient.new 'http://localhost:1984/Sequence'
24
+ driver = RbbtRestClient.new 'http://studyexplorer.bioinfo.cnio.es/Sequence', "Sequence"
16
25
  job = driver.job(:mutated_isoforms_for_genomic_mutations, "Default", :organism => "Hsa", :mutations => %w(9:140051238:G))
17
26
  assert job.exec.values.flatten.include? "ENSP00000316915:P263P"
18
27
  job.clean
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbbt-views
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-21 00:00:00.000000000 Z
12
+ date: 2013-01-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sinatra
@@ -995,15 +995,14 @@ files:
995
995
  - share/views/public/plugins/tablesorter/themes/green/green.zip
996
996
  - share/views/public/plugins/tablesorter/themes/green/style.css
997
997
  - share/views/public/plugins/wz_jsgraphics.js
998
- - share/views/public/tmp/foo
999
998
  - share/views/result.haml
1000
999
  - share/views/step_error.haml
1001
1000
  - share/views/task_list.haml
1002
1001
  - share/views/user_lists.haml
1003
1002
  - share/views/wait.haml
1004
1003
  - LICENSE
1005
- - test/test_helper.rb
1006
1004
  - test/rbbt/workflow/rest/test_client.rb
1005
+ - test/test_helper.rb
1007
1006
  homepage: http://github.com/mikisvaz/rbbt-views
1008
1007
  licenses: []
1009
1008
  post_install_message:
@@ -1029,5 +1028,5 @@ signing_key:
1029
1028
  specification_version: 3
1030
1029
  summary: Rest and HTML interface
1031
1030
  test_files:
1032
- - test/test_helper.rb
1033
1031
  - test/rbbt/workflow/rest/test_client.rb
1032
+ - test/test_helper.rb
File without changes