ruote-kit 2.1.10 → 2.1.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. data/.gitignore +2 -0
  2. data/CHANGELOG.txt +10 -0
  3. data/Gemfile +21 -5
  4. data/LICENSE.txt +20 -0
  5. data/README.rdoc +132 -80
  6. data/Rakefile +4 -15
  7. data/TODO.txt +12 -0
  8. data/config.ru +22 -14
  9. data/lib/ruote-kit/application.rb +46 -22
  10. data/lib/ruote-kit/helpers/json_helpers.rb +280 -0
  11. data/lib/ruote-kit/helpers/link_helpers.rb +117 -0
  12. data/lib/ruote-kit/helpers/misc_helpers.rb +35 -0
  13. data/lib/ruote-kit/helpers/pagination_helpers.rb +30 -0
  14. data/lib/ruote-kit/helpers/render_helpers.rb +39 -92
  15. data/lib/ruote-kit/public/_ruote/images/favicon.ico +0 -0
  16. data/lib/ruote-kit/public/_ruote/images/ruote.png +0 -0
  17. data/lib/ruote-kit/public/_ruote/images/ruote_buttons.png +0 -0
  18. data/lib/ruote-kit/public/_ruote/javascripts/jquery-1.4.2.min.js +154 -0
  19. data/lib/ruote-kit/public/_ruote/javascripts/rk.js +40 -0
  20. data/lib/ruote-kit/public/_ruote/javascripts/ruote-fluo-editor.js +548 -0
  21. data/lib/ruote-kit/public/_ruote/javascripts/ruote-fluo.js +32 -1
  22. data/lib/ruote-kit/public/_ruote/stylesheets/reset.css +53 -0
  23. data/lib/ruote-kit/public/_ruote/stylesheets/rk.css +355 -16
  24. data/lib/ruote-kit/public/_ruote/stylesheets/ruote-fluo-editor.css +108 -0
  25. data/lib/ruote-kit/resources/errors.rb +46 -43
  26. data/lib/ruote-kit/resources/expressions.rb +92 -35
  27. data/lib/ruote-kit/resources/participants.rb +53 -0
  28. data/lib/ruote-kit/resources/processes.rb +68 -36
  29. data/lib/ruote-kit/resources/schedules.rb +27 -0
  30. data/lib/ruote-kit/resources/workitems.rb +93 -31
  31. data/lib/ruote-kit/spec/ruote_helpers.rb +25 -16
  32. data/lib/ruote-kit/version.rb +3 -1
  33. data/lib/ruote-kit/views/_pagination.html.haml +38 -0
  34. data/lib/ruote-kit/views/_tree_editor.html.haml +52 -0
  35. data/lib/ruote-kit/views/error.html.haml +69 -0
  36. data/lib/ruote-kit/views/errors.html.haml +28 -12
  37. data/lib/ruote-kit/views/expression.html.haml +161 -30
  38. data/lib/ruote-kit/views/expressions.html.haml +26 -21
  39. data/lib/ruote-kit/views/http_error.html.haml +11 -0
  40. data/lib/ruote-kit/views/index.html.haml +4 -0
  41. data/lib/ruote-kit/views/layout.html.haml +52 -32
  42. data/lib/ruote-kit/views/participants.html.haml +79 -0
  43. data/lib/ruote-kit/views/process.html.haml +109 -42
  44. data/lib/ruote-kit/views/process_launched.html.haml +6 -2
  45. data/lib/ruote-kit/views/processes.html.haml +55 -24
  46. data/lib/ruote-kit/views/processes_new.html.haml +36 -0
  47. data/lib/ruote-kit/views/schedules.html.haml +42 -0
  48. data/lib/ruote-kit/views/workitem.html.haml +83 -29
  49. data/lib/ruote-kit/views/workitems.html.haml +42 -19
  50. data/lib/ruote-kit.rb +17 -88
  51. data/ruote-kit.gemspec +68 -80
  52. data/spec/it_has_an_engine.rb +69 -0
  53. data/spec/resources/errors_spec.rb +198 -270
  54. data/spec/resources/expressions_spec.rb +308 -52
  55. data/spec/resources/index_spec.rb +28 -16
  56. data/spec/resources/participants_spec.rb +102 -0
  57. data/spec/resources/processes_spec.rb +218 -104
  58. data/spec/resources/schedules_spec.rb +97 -0
  59. data/spec/resources/workitems_spec.rb +195 -100
  60. data/spec/ruote-kit_configure_spec.rb +32 -75
  61. data/spec/spec.opts +0 -1
  62. data/spec/spec_helper.rb +31 -92
  63. data/spec/webapp_helpers_spec.rb +309 -0
  64. metadata +87 -152
  65. data/lib/ruote-kit/configuration.rb +0 -83
  66. data/lib/ruote-kit/helpers/engine_helpers.rb +0 -24
  67. data/lib/ruote-kit/helpers/form_helpers.rb +0 -11
  68. data/lib/ruote-kit/helpers/launch_item_parser.rb +0 -59
  69. data/lib/ruote-kit/helpers/navigation_helpers.rb +0 -54
  70. data/lib/ruote-kit/helpers.rb +0 -9
  71. data/lib/ruote-kit/public/_ruote/images/bg.gif +0 -0
  72. data/lib/ruote-kit/public/_ruote/images/bg_button_left.gif +0 -0
  73. data/lib/ruote-kit/public/_ruote/images/bg_button_left_cancel.gif +0 -0
  74. data/lib/ruote-kit/public/_ruote/images/bg_button_left_submit.gif +0 -0
  75. data/lib/ruote-kit/public/_ruote/images/bg_button_right.gif +0 -0
  76. data/lib/ruote-kit/public/_ruote/javascripts/SimplyButtons.js +0 -191
  77. data/lib/ruote-kit/public/_ruote/javascripts/fluo-dial.js +0 -149
  78. data/lib/ruote-kit/public/_ruote/stylesheets/SimplyButtons.css +0 -226
  79. data/lib/ruote-kit/public/_ruote/stylesheets/base.css +0 -336
  80. data/lib/ruote-kit/public/_ruote/stylesheets/style.css +0 -393
  81. data/lib/ruote-kit/views/launch_process.html.haml +0 -19
  82. data/lib/ruote-kit/views/process_failed_to_launch.html.haml +0 -7
  83. data/lib/ruote-kit/views/resource_not_found.html.haml +0 -7
  84. data/spec/helpers/render_helpers_spec.rb +0 -214
  85. data/spec/ruote-kit_spec.rb +0 -4
  86. data/spec/views/expressions.html.haml_spec.rb +0 -31
  87. data/spec/views/launch_process.html.haml_spec.rb +0 -22
  88. data/spec/views/process.html.haml_spec.rb +0 -17
  89. data/spec/views/process_launched.html.haml_spec.rb +0 -16
  90. data/spec/views/processes.html.haml_spec.rb +0 -31
  91. data/spec/views/workitems.html.haml_spec.rb +0 -69
@@ -0,0 +1,280 @@
1
+
2
+ # license is MIT, see LICENSE.txt
3
+
4
+ module RuoteKit
5
+ module Helpers
6
+
7
+ # Helpers for JSON rendering
8
+ #
9
+ module JsonHelpers
10
+
11
+ def json(resource, *args)
12
+
13
+ object = respond_to?("json_#{resource}") ?
14
+ send("json_#{resource}", *args) : nil
15
+
16
+ Rufus::Json.encode(
17
+ 'links' => links(resource), resource.to_s => object || args.first
18
+ )
19
+ end
20
+
21
+ #def json_exception(code, exception)
22
+ # { 'code' => code, 'exception' => { 'message' => exception.message } }
23
+ #end
24
+
25
+ def json_processes
26
+
27
+ @processes.map { |p| json_process(p) }
28
+ end
29
+
30
+ def json_process(process=@process)
31
+
32
+ detailed = (@process != nil)
33
+
34
+ process.as_h(detailed).merge('links' => [
35
+ hlink('processes', process.wfid, :rel => 'self'),
36
+ hlink('processes', process.wfid, :rel => '#process'),
37
+ hlink('expressions', process.wfid, :rel => '#process_expressions'),
38
+ hlink('workitems', process.wfid, :rel => '#process_workitems'),
39
+ hlink('errors', process.wfid, :rel => '#process_errors'),
40
+ hlink('schedules', process.wfid, :rel => '#process_schedules')
41
+ ])
42
+ end
43
+
44
+ def json_expressions
45
+
46
+ @process.expressions.map { |e| json_expression(e) }
47
+ end
48
+
49
+ def json_expression(expression=@expression)
50
+
51
+ detailed = (@expression != nil)
52
+
53
+ links = [
54
+ hlink('expressions', expression.fei.sid, :rel => 'self'),
55
+ hlink('processes', expression.fei.wfid, :rel => '#process'),
56
+ hlink('expressions', expression.fei.wfid, :rel => '#process_expressions')
57
+ ]
58
+ links << hlink(
59
+ 'expressions', expression.parent.fei.sid, 'parent'
60
+ ) if expression.parent
61
+
62
+ expression.as_h(detailed).merge('links' => links)
63
+ end
64
+
65
+ def json_workitems
66
+
67
+ @workitems.map { |w| json_workitem(w) }
68
+ end
69
+
70
+ def json_workitem(workitem=@workitem)
71
+
72
+ detailed = (@workitem != nil)
73
+
74
+ links = [
75
+ hlink('expressions', workitem.fei.sid, :rel => 'self'),
76
+ hlink('processes', workitem.fei.wfid, :rel => '#process'),
77
+ hlink('expressions', workitem.fei.wfid, :rel => '#process_expressions'),
78
+ hlink('errors', workitem.fei.wfid, :rel => '#process_errors')
79
+ ]
80
+
81
+ workitem.as_h(detailed).merge('links' => links)
82
+ end
83
+
84
+ def json_errors
85
+
86
+ @errors.collect { |e| json_error(e) }
87
+ end
88
+
89
+ def json_error(error=@error)
90
+
91
+ fei = error.fei
92
+ wfid = fei.wfid
93
+
94
+ error.to_h.merge('links' => [
95
+ hlink('errors', fei.sid, :rel => 'self'),
96
+ hlink('errors', wfid, :rel => '#process_errors'),
97
+ hlink('processes', wfid, :rel => '#process')
98
+ ])
99
+ end
100
+
101
+ def json_participants
102
+
103
+ @participants.collect { |pa|
104
+ pa.as_h.merge('links' => [ hlink('participants', :rel => 'self') ])
105
+ }
106
+ end
107
+
108
+ def json_schedules
109
+
110
+ @schedules.each do |sched|
111
+
112
+ owner_fei = sched.delete('owner')
113
+ target_fei = sched.delete('target')
114
+
115
+ sched['owner'] = owner_fei.to_h
116
+ sched['target'] = target_fei.to_h
117
+
118
+ sched['links'] = [
119
+ hlink('expressions', owner_fei.sid, :rel => '#schedule_owner'),
120
+ hlink('expressions', target_fei.sid, :rel => '#schedule_target')
121
+ ]
122
+ end
123
+
124
+ @schedules
125
+ end
126
+
127
+ def json_http_error(err)
128
+
129
+ { 'code' => err[0], 'message' => err[1], 'cause' => err[2].to_s }
130
+ end
131
+
132
+ def links(resource)
133
+
134
+ result = [
135
+ hlink(:rel => '#root'),
136
+ hlink('processes', :rel => '#processes'),
137
+ hlink('workitems', :rel => '#workitems'),
138
+ hlink('errors', :rel => '#errors'),
139
+ hlink('participants', :rel => '#participants'),
140
+ hlink('schedules', :rel => '#schedules'),
141
+ hlink('history', :rel => '#history'),
142
+ hlink(request.fullpath, :rel => 'self')
143
+ ]
144
+
145
+ if @skip # pagination is active
146
+
147
+ result << hlink(resource.to_s, :rel => 'all')
148
+
149
+ lim = @limit || settings.limit
150
+ las = (@count / lim) * lim
151
+ pre = [ 0, @skip - lim ].max
152
+ nex = [ @skip + lim, las ].min
153
+
154
+ result << hlink(
155
+ resource.to_s,
156
+ :skip => 0, :limit => lim, :rel => 'first')
157
+ result << hlink(
158
+ resource.to_s,
159
+ :skip => las, :limit => lim, :rel => 'last')
160
+ result << hlink(
161
+ resource.to_s,
162
+ :skip => pre, :limit => lim, :rel => 'previous')
163
+ result << hlink(
164
+ resource.to_s,
165
+ :skip => nex, :limit => lim, :rel => 'next')
166
+ end
167
+
168
+ result
169
+ end
170
+ end
171
+ end
172
+ end
173
+
174
+ module Ruote
175
+
176
+ #
177
+ # Re-opening to provide an as_h method
178
+ #
179
+ class ProcessStatus
180
+
181
+ def as_h(detailed=true)
182
+
183
+ h = {}
184
+
185
+ #h['expressions'] = @expressions.collect { |e| e.fei.to_h }
186
+ #h['errors'] = @errors.collect { |e| e.to_h }
187
+
188
+ h['type'] = 'process'
189
+ h['detailed'] = detailed
190
+ h['expressions'] = @expressions.size
191
+ h['errors'] = @errors.size
192
+ h['stored_workitems'] = @stored_workitems.size
193
+ h['workitems'] = workitems.size
194
+
195
+ properties = %w[
196
+ wfid
197
+ definition_name definition_revision
198
+ current_tree
199
+ launched_time
200
+ last_active
201
+ tags
202
+ ]
203
+
204
+ properties += %w[
205
+ original_tree
206
+ variables
207
+ ] if detailed
208
+
209
+ properties.each { |m|
210
+ h[m] = self.send(m)
211
+ }
212
+
213
+ h
214
+ end
215
+ end
216
+
217
+ #
218
+ # Re-opening to provide an as_h method
219
+ #
220
+ class Workitem
221
+
222
+ def as_h(detailed=true)
223
+
224
+ r = {}
225
+
226
+ r['id'] = fei.sid
227
+ r['fei'] = fei.sid
228
+ r['wfid'] = fei.wfid
229
+ r['type'] = 'workitem'
230
+ r['participant_name'] = participant_name
231
+
232
+ r['fields'] = h.fields
233
+
234
+ r['put_at'] = h.put_at
235
+
236
+ r
237
+ end
238
+ end
239
+
240
+ #
241
+ # Re-opening to provide an as_h method
242
+ #
243
+ class ParticipantEntry
244
+
245
+ def as_h(detailed=true)
246
+
247
+ { 'regex' => @regex, 'classname' => @classname, 'options' => @options }
248
+ end
249
+ end
250
+
251
+ module Exp
252
+
253
+ #
254
+ # Re-opening to provide an as_h method
255
+ #
256
+ class FlowExpression
257
+
258
+ def as_h(detailed=true)
259
+
260
+ r = {}
261
+
262
+ r['fei'] = fei.sid
263
+ r['parent'] = h.parent_id ? parent_id.sid : nil
264
+ r['name'] = h.name
265
+ r['class'] = self.class.name
266
+
267
+ if detailed
268
+ r['variables'] = variables
269
+ r['applied_workitem'] = h.applied_workitem['fields']
270
+ r['tree'] = tree
271
+ r['original_tree'] = original_tree
272
+ r['timeout_schedule_id'] = h.timeout_schedule_id
273
+ end
274
+
275
+ r
276
+ end
277
+ end
278
+ end
279
+ end
280
+
@@ -0,0 +1,117 @@
1
+
2
+ # license is MIT, see LICENSE.txt
3
+
4
+ module RuoteKit
5
+ module Helpers
6
+
7
+ # Helpers about links
8
+ #
9
+ module LinkHelpers
10
+
11
+ # Computing the href for the "as_json" link at the bottom of each page
12
+ #
13
+ def as_json
14
+
15
+ href = request.path + '.json'
16
+
17
+ if request.query_string.length > 0
18
+ href = "#{href}?#{request.query_string}"
19
+ end
20
+
21
+ href
22
+ end
23
+
24
+ # Determining { 'href' => 'x', 'rel' => 'y', ... } and co
25
+ #
26
+ def hlink(*args)
27
+
28
+ query = args.last.is_a?(Hash) ? args.pop : {}
29
+ query = query.reject { |k, v| k == :text }
30
+
31
+ args = args.collect { |arg| arg.to_s }
32
+
33
+ if args.last == 'head'
34
+ args.pop
35
+ query[:skip] = 0
36
+ query[:limit] = settings.limit
37
+ end
38
+
39
+ rel = query.delete(:rel) || compute_rel(args)
40
+ title = query.delete(:title)
41
+
42
+ query = query.inject({}) { |h, (k, v)| h[k.to_s] = v; h }
43
+ query = query.keys.sort.collect { |k| "#{k}=#{query[k]}" }.join('&')
44
+ query = "?#{query}" if query.length > 0
45
+
46
+ if args.empty? or ( ! args.first.match(/^\/\_ruote/))
47
+ args.unshift('/_ruote')
48
+ end
49
+ href = args.join('/')
50
+
51
+ href = "#{href}#{query}"
52
+
53
+ result = {
54
+ 'href' => href,
55
+ 'rel' => rel.match(/^#/) ?
56
+ "http://ruote.rubyforge.org/rels.html#{rel}" : rel,
57
+ }
58
+
59
+ if title
60
+ result['title'] = title == true ? href : title
61
+ end
62
+
63
+ result
64
+ end
65
+
66
+ # Returns an <a href="x" rel="y">z</a>, uses #hlink.
67
+ #
68
+ def alink(*args)
69
+
70
+ args << {} unless args.last.is_a?(Hash)
71
+ args.last[:title] = true
72
+
73
+ opts = args.last
74
+
75
+ hl = hlink(*args)
76
+
77
+ attributes = %w[ href rel title ].inject([]) { |a, att|
78
+ if val = hl[att]
79
+ a << "#{att}=\"#{val}\""
80
+ end
81
+ a
82
+ }.join(' ')
83
+
84
+ "<a #{attributes}>#{opts[:text] || hl['href']}</a>"
85
+ end
86
+
87
+ protected
88
+
89
+ def compute_rel(args)
90
+
91
+ wfid, fei = if ( ! args[1])
92
+ [ false, false ]
93
+ elsif args[1].index('!')
94
+ [ false, true ]
95
+ else
96
+ [ true, false ]
97
+ end
98
+
99
+ case args.first
100
+ when 'processes'
101
+ wfid ? '#process' : '#processes'
102
+ when 'expressions'
103
+ fei ? '#expression' : '#process_expressions'
104
+ when 'errors'
105
+ fei ? '#error' : '#process_errors'
106
+ when 'workitems'
107
+ fei ? '#workitem' : '#process_workitems'
108
+ when 'schedules'
109
+ wfid ? '#process_schedules' : '#schedules'
110
+ else
111
+ ''
112
+ end
113
+ end
114
+ end
115
+ end
116
+ end
117
+
@@ -0,0 +1,35 @@
1
+
2
+ # license is MIT, see LICENSE.txt
3
+
4
+ module RuoteKit
5
+ module Helpers
6
+
7
+ module MiscHelpers
8
+
9
+ def respond_with(template)
10
+
11
+ respond_to do |format|
12
+ format.html { haml(template) }
13
+ format.json { json(template) }
14
+ end
15
+ end
16
+
17
+ def sample_process
18
+ %{
19
+ Ruote.process_definition :name => 'test', :revision => '0.1' do
20
+ sequence do
21
+ alice :task => 'clean car'
22
+ bob :task => 'sell car'
23
+ end
24
+ end
25
+ }.strip
26
+ end
27
+
28
+ def sample_process_tree
29
+
30
+ Rufus::Json.encode(Ruote::Parser.parse(sample_process))
31
+ end
32
+ end
33
+ end
34
+ end
35
+
@@ -0,0 +1,30 @@
1
+
2
+ # license is MIT, see LICENSE.txt
3
+
4
+ module RuoteKit
5
+ module Helpers
6
+
7
+ # Pagination stuff
8
+ #
9
+ module PaginationHelpers
10
+
11
+ # Prerequesite : a @count var with the number of records (processes,
12
+ # workitems, errors or schedules) found.
13
+ #
14
+ def paginate
15
+
16
+ @skip = (params[:skip] || 0).to_i
17
+ @limit = (params[:limit] || settings.limit).to_i
18
+
19
+ #@skip = 0 if @skip < 0
20
+ #@skip = @count - @limit if @skip >= @count
21
+ if @skip <= 0
22
+ @skip = 0
23
+ elsif @skip >= @count
24
+ @skip = @count - @limit
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+
@@ -1,96 +1,47 @@
1
+
2
+ # license is MIT, see LICENSE.txt
3
+
1
4
  module RuoteKit
2
5
  module Helpers
6
+
3
7
  # Helpers for rendering stuff
8
+ #
4
9
  module RenderHelpers
5
10
 
6
- def json( resource, object )
7
- if respond_to?( "json_#{resource}" )
8
- object = send( "json_#{resource}", object )
9
- end
10
-
11
- Rufus::Json.encode( {
12
- "links" => links( resource ),
13
- resource.to_s => object
14
- } )
15
- end
16
-
17
- def json_processes( processes )
18
- processes.map { |p| json_process( p ) }
19
- end
20
-
21
- def json_process( process )
22
- links = [
23
- link( "/_ruote/processes/#{process.wfid}", '#process' ),
24
- link( "/_ruote/expressions/#{process.wfid}", '#expressions' ),
25
- link( "/_ruote/workitems/#{process.wfid}", '#workitems' )
26
- ]
27
-
28
- process.to_h.merge( 'links' => links )
29
- end
30
-
31
- def json_expression( expression )
32
- links = [
33
- link( "/_ruote/processes/#{expression.fei.wfid}", '#process' ),
34
- link( "/_ruote/expressions/#{expression.fei.wfid}", '#expressions' )
35
- ]
36
-
37
- if expression.parent
38
- links << link( "/_ruote/expressions/#{expression.fei.wfid}/#{expression.parent.fei.expid}", 'parent' )
39
- end
40
-
41
- expression.to_h.merge( 'links' => links )
42
- end
43
-
44
- def json_expressions( expressions )
45
- expressions.map { |e| json_expression( e ) }
46
- end
47
-
48
- def json_workitems( workitems )
49
- workitems.map { |w| json_workitem( w ) }
50
- end
51
-
52
- def json_workitem( workitem )
11
+ def pluralize(number, word)
53
12
 
54
- links = [
55
- link( "/_ruote/processes/#{workitem.fei.wfid}", '#process' ),
56
- link( "/_ruote/expressions/#{workitem.fei.wfid}", '#expressions' ),
57
- link( "/_ruote/errors/#{workitem.fei.wfid}", '#errors' )
58
- ]
59
-
60
- workitem.to_h.merge( 'links' => links )
61
- end
13
+ word << 's' if number > 1
62
14
 
63
- def json_errors( errors )
64
- errors.collect { |e| json_error( e, false ) }
15
+ return [ number, word ].join(' ')
65
16
  end
66
17
 
67
- def json_error( error )
68
- error.to_h.merge( 'links' => links )
69
- end
18
+ # Escaping HTML, rack style.
19
+ #
20
+ def h(s)
70
21
 
71
- def links( resource )
72
- [
73
- link( '/_ruote', '#root' ),
74
- link( '/_ruote/processes', '#processes' ),
75
- link( '/_ruote/workitems', '#workitems' ),
76
- link( '/_ruote/errors', '#errors' ),
77
- link( '/_ruote/history', '#history' ),
78
- link( request.fullpath, 'self' )
79
- ]
22
+ Rack::Utils.escape_html(s)
80
23
  end
81
24
 
82
- def link( href, rel )
83
- {
84
- 'href' => href,
85
- 'rel' => rel.match(/^#/) ? "http://ruote.rubyforge.org/rels.html#{rel}" : rel
86
- }
87
- end
25
+ # Used by #http_error
26
+ #
27
+ HTTP_CODES = {
28
+ 400 => 'bad request',
29
+ 404 => 'resource not found'
30
+ }
88
31
 
89
- # Easy 404
32
+ # HTTP errors
90
33
  #
91
- def resource_not_found
34
+ def http_error(code, cause=nil)
92
35
 
93
- status 404
36
+ @code = code
37
+ @message = HTTP_CODES[code]
38
+ @cause = cause
39
+
40
+ @trace = if cause
41
+ [ cause.message ] + cause.backtrace
42
+ else
43
+ nil
44
+ end
94
45
 
95
46
  @format = if m = @format.to_s.match(/^[^\/]+\/([^;]+)/)
96
47
  m[1].to_sym
@@ -99,31 +50,27 @@ module RuoteKit
99
50
  end
100
51
  # freaking sinata-respond_to 0.4.0... (or is that it ?)
101
52
 
102
- respond_to do |format|
103
- format.html { haml :resource_not_found }
104
- format.json { Rufus::Json.encode( { "error" => { "code" => 404, "message" => "Resource not found" } } ) }
105
- end
106
- end
53
+ status(@code)
107
54
 
108
- # Easy 503
109
- def workitems_not_available
110
- status 503
111
55
  respond_to do |format|
112
- format.html { haml :workitems_not_available }
113
- format.json { Rufus::Json.encode( { "error" => { "code" => 503, "messages" => "Workitems not available" } } ) }
56
+ format.html { haml :http_error }
57
+ format.json { json(:http_error, [ @code, @message, @cause ]) }
114
58
  end
115
59
  end
116
60
 
117
61
  # Extract the process tree
118
- def process_tree( object )
62
+ #
63
+ def process_tree(object)
64
+
119
65
  case object
120
66
  when Ruote::Workitem
121
- process = engine.process( object.fei.wfid )
122
- Rufus::Json.encode( process.current_tree )
67
+ process = RuoteKit.engine.process(object.fei.wfid)
68
+ Rufus::Json.encode(process.current_tree)
123
69
  when Ruote::ProcessStatus
124
- Rufus::Json.encode( object.current_tree )
70
+ Rufus::Json.encode(object.current_tree)
125
71
  end
126
72
  end
127
73
  end
128
74
  end
129
75
  end
76
+