rbbt-rest 1.3.7 → 1.3.8

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2a1e8ea5906421691ba0ed838b8636c39cf94835
4
- data.tar.gz: 74c068a5b593a8443bc2a03c1eca0f27028319f2
3
+ metadata.gz: af2d0738024e2f1576ee464174c75e69bff9e565
4
+ data.tar.gz: f8b5daa03aad2d4f9f0686fb0dc77864a691d173
5
5
  SHA512:
6
- metadata.gz: 895f70b43a2e15cf3b2ed3f41f66261ae7b2811aded4db5d88613ef9e9cd851b12c669cb9e61b25a6631a653e978b71a7cc073dae45ff4d5ae9ae15c3e2f24d7
7
- data.tar.gz: 4c74347a06c8e6d57da78ad2ed49820ee4518555bc4dc7c76afdc54a2f4eae041b3b30759cee59d2ee7b3bf03d84acf4ba828dbe0240a151b8847704e04c78d0
6
+ metadata.gz: 80f04a7411ff1e2d08f77c5edb4c966615409ba6c66f0a793cb766efaebeb313478f4954dacda49869a2ea0ecae465e4af55773780a58a570fcdb0997aae1849
7
+ data.tar.gz: c874aceb9421927804e172ffd46d2e6ab7e1f8e60a31aeb51d1d6cb4db268e3416bd61fe0bfc75b540892331e85b561e6638b9ce015797f20a3993d7c1ad034b
@@ -2,11 +2,19 @@ class WorkflowRESTClient
2
2
  def self.fix_hash(hash, fix_values = false)
3
3
  fixed = {}
4
4
  hash.each do |key, value|
5
- fixed[key.to_sym] = case
6
- when Hash === value
5
+ fixed[key.to_sym] = case value
6
+ when TrueClass
7
+ value
8
+ when FalseClass
9
+ value
10
+ when Hash
7
11
  fix_hash(value)
8
- when (fix_values and String === value)
12
+ when (fix_values and String )
9
13
  value.to_sym
14
+ when IO
15
+ value.read
16
+ when TSV::Dumper
17
+ value.stream.read
10
18
  else
11
19
  value
12
20
  end
@@ -49,7 +49,7 @@ class WorkflowRESTClient
49
49
  #{{{ MANAGEMENT
50
50
 
51
51
  def init_job(cache_type = :asynchronous)
52
- @name = WorkflowRESTClient.post_jobname(File.join(base_url, task.to_s), inputs.merge(:jobname => @name, :_cache_type => cache_type))
52
+ @name ||= WorkflowRESTClient.post_jobname(File.join(base_url, task.to_s), inputs.merge(:jobname => @name, :_cache_type => cache_type))
53
53
  @url = File.join(base_url, task.to_s, @name)
54
54
  nil
55
55
  end
@@ -108,11 +108,11 @@ class WorkflowRESTClient
108
108
 
109
109
  def run(noload = false)
110
110
  return exec_job if @is_exec
111
- init_job(:synchronous)
111
+ init_job(:synchronous)
112
112
  noload ? @name : self.load
113
113
  end
114
114
 
115
- def exec
115
+ def exec(*args)
116
116
  exec_job
117
117
  end
118
118
 
@@ -122,18 +122,18 @@ class WorkflowRESTClient
122
122
  end
123
123
 
124
124
  def recursive_clean
125
- init_job unless url
126
125
  begin
127
- WorkflowRESTClient.get_raw(url, :_update => :recursive_clean) unless @is_exec
126
+ inputs[:_update] = :recursive_clean
128
127
  rescue Exception
129
128
  end
130
129
  self
131
130
  end
132
131
 
133
132
  def clean
134
- init_job unless url
135
133
  begin
136
- WorkflowRESTClient.get_raw(url, :_update => :clean) unless @is_exec
134
+ ddd inputs
135
+ inputs[:_update] = :clean
136
+ ddd inputs
137
137
  rescue Exception
138
138
  end
139
139
  self
@@ -140,6 +140,13 @@ module RbbtRESTHelpers
140
140
  text.split(/\r?\n/).collect{|l| l.strip}
141
141
  when text =~ /\|/
142
142
  text.split(/\|/).collect{|l| l.strip}
143
+ when Hash
144
+ io = text[:tempfile].open
145
+ class << io
146
+ attr_accessor :filename
147
+ end
148
+ io.filename = text[:filename]
149
+ io
143
150
  else
144
151
  text.split(/,/).collect{|l| l.strip}
145
152
  end
@@ -89,6 +89,8 @@ module WorkflowRESTHelpers
89
89
  when :binary
90
90
  content_type "application/octet-stream"
91
91
  halt 200, result.to_s
92
+ when :jobname
93
+ halt 200, nil
92
94
  else
93
95
  raise "Unsupported format: #{ format }"
94
96
  end
@@ -156,21 +158,33 @@ module WorkflowRESTHelpers
156
158
  when :synchronous, :sync
157
159
  job.clean if update == :reload
158
160
  begin
159
- job.run(false) unless File.exists? job.info_file
161
+ job.run unless File.exists? job.info_file
160
162
  job_url = to(File.join("/", workflow.to_s, task, job.name))
161
163
  job_url += "?_format=#{@format}" if @format
162
- halt 200, job.name if format === :jobname
164
+ halt 200, job.name if format == :jobname
163
165
  redirect job_url
164
166
  rescue
167
+ Log.exception $!
165
168
  halt 500, $!.message
166
169
  end
167
170
  when :asynchronous, :async, nil
168
171
  job.clean if update == :reload
169
- job.fork unless File.exists? job.info_file
170
- job_url = to(File.join("/", workflow.to_s, task, job.name))
171
- job_url += "?_format=#{@format}" if @format
172
- halt 200, job.name if format === :jobname
173
- redirect job_url
172
+
173
+ begin
174
+ job.fork unless File.exists? job.info_file
175
+
176
+ job_url = to(File.join("/", workflow.to_s, task, job.name))
177
+ job_url += "?_format=#{@format}" if @format
178
+ #halt 200, job.name if format == :jobname
179
+ if format == :jobname
180
+ content_type :text
181
+ job.name
182
+ else
183
+ redirect job_url
184
+ end
185
+ rescue Exception
186
+ Log.exception $!
187
+ end
174
188
  else
175
189
  raise "Unsupported execution_type: #{ execution_type }"
176
190
  end
@@ -3,11 +3,11 @@
3
3
  %dd.job_control
4
4
  %ul
5
5
  %li
6
- %a(href="/#{[workflow, task, jobname] * "/"}?_update=clean") clean
6
+ %a(href="/#{[workflow.to_s, task, jobname] * "/"}?_update=clean") clean
7
7
  %li
8
- %a(href="/#{[workflow, task, jobname, "info"] * "/"}") info
8
+ %a(href="/#{[workflow.to_s, task, jobname, "info"] * "/"}") info
9
9
  %li
10
- %a(href="/#{[workflow, task, jobname] * "/"}?_format=raw") raw
10
+ %a(href="/#{[workflow.to_s, task, jobname] * "/"}?_format=raw") raw
11
11
 
12
12
  - if job.files.any?
13
13
  %dt Files
@@ -15,4 +15,4 @@
15
15
  %ul
16
16
  - job.files.each do |file|
17
17
  %li
18
- %a(href="/#{[workflow, task, jobname, "file", file] * "/"}")= file
18
+ %a(href="/#{[workflow.to_s, task, jobname, "file", file] * "/"}")= file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbbt-rest
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.7
4
+ version: 1.3.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-25 00:00:00.000000000 Z
11
+ date: 2014-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake