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.
- data/.gitignore +2 -0
- data/CHANGELOG.txt +10 -0
- data/Gemfile +21 -5
- data/LICENSE.txt +20 -0
- data/README.rdoc +132 -80
- data/Rakefile +4 -15
- data/TODO.txt +12 -0
- data/config.ru +22 -14
- data/lib/ruote-kit/application.rb +46 -22
- data/lib/ruote-kit/helpers/json_helpers.rb +280 -0
- data/lib/ruote-kit/helpers/link_helpers.rb +117 -0
- data/lib/ruote-kit/helpers/misc_helpers.rb +35 -0
- data/lib/ruote-kit/helpers/pagination_helpers.rb +30 -0
- data/lib/ruote-kit/helpers/render_helpers.rb +39 -92
- data/lib/ruote-kit/public/_ruote/images/favicon.ico +0 -0
- data/lib/ruote-kit/public/_ruote/images/ruote.png +0 -0
- data/lib/ruote-kit/public/_ruote/images/ruote_buttons.png +0 -0
- data/lib/ruote-kit/public/_ruote/javascripts/jquery-1.4.2.min.js +154 -0
- data/lib/ruote-kit/public/_ruote/javascripts/rk.js +40 -0
- data/lib/ruote-kit/public/_ruote/javascripts/ruote-fluo-editor.js +548 -0
- data/lib/ruote-kit/public/_ruote/javascripts/ruote-fluo.js +32 -1
- data/lib/ruote-kit/public/_ruote/stylesheets/reset.css +53 -0
- data/lib/ruote-kit/public/_ruote/stylesheets/rk.css +355 -16
- data/lib/ruote-kit/public/_ruote/stylesheets/ruote-fluo-editor.css +108 -0
- data/lib/ruote-kit/resources/errors.rb +46 -43
- data/lib/ruote-kit/resources/expressions.rb +92 -35
- data/lib/ruote-kit/resources/participants.rb +53 -0
- data/lib/ruote-kit/resources/processes.rb +68 -36
- data/lib/ruote-kit/resources/schedules.rb +27 -0
- data/lib/ruote-kit/resources/workitems.rb +93 -31
- data/lib/ruote-kit/spec/ruote_helpers.rb +25 -16
- data/lib/ruote-kit/version.rb +3 -1
- data/lib/ruote-kit/views/_pagination.html.haml +38 -0
- data/lib/ruote-kit/views/_tree_editor.html.haml +52 -0
- data/lib/ruote-kit/views/error.html.haml +69 -0
- data/lib/ruote-kit/views/errors.html.haml +28 -12
- data/lib/ruote-kit/views/expression.html.haml +161 -30
- data/lib/ruote-kit/views/expressions.html.haml +26 -21
- data/lib/ruote-kit/views/http_error.html.haml +11 -0
- data/lib/ruote-kit/views/index.html.haml +4 -0
- data/lib/ruote-kit/views/layout.html.haml +52 -32
- data/lib/ruote-kit/views/participants.html.haml +79 -0
- data/lib/ruote-kit/views/process.html.haml +109 -42
- data/lib/ruote-kit/views/process_launched.html.haml +6 -2
- data/lib/ruote-kit/views/processes.html.haml +55 -24
- data/lib/ruote-kit/views/processes_new.html.haml +36 -0
- data/lib/ruote-kit/views/schedules.html.haml +42 -0
- data/lib/ruote-kit/views/workitem.html.haml +83 -29
- data/lib/ruote-kit/views/workitems.html.haml +42 -19
- data/lib/ruote-kit.rb +17 -88
- data/ruote-kit.gemspec +68 -80
- data/spec/it_has_an_engine.rb +69 -0
- data/spec/resources/errors_spec.rb +198 -270
- data/spec/resources/expressions_spec.rb +308 -52
- data/spec/resources/index_spec.rb +28 -16
- data/spec/resources/participants_spec.rb +102 -0
- data/spec/resources/processes_spec.rb +218 -104
- data/spec/resources/schedules_spec.rb +97 -0
- data/spec/resources/workitems_spec.rb +195 -100
- data/spec/ruote-kit_configure_spec.rb +32 -75
- data/spec/spec.opts +0 -1
- data/spec/spec_helper.rb +31 -92
- data/spec/webapp_helpers_spec.rb +309 -0
- metadata +87 -152
- data/lib/ruote-kit/configuration.rb +0 -83
- data/lib/ruote-kit/helpers/engine_helpers.rb +0 -24
- data/lib/ruote-kit/helpers/form_helpers.rb +0 -11
- data/lib/ruote-kit/helpers/launch_item_parser.rb +0 -59
- data/lib/ruote-kit/helpers/navigation_helpers.rb +0 -54
- data/lib/ruote-kit/helpers.rb +0 -9
- data/lib/ruote-kit/public/_ruote/images/bg.gif +0 -0
- data/lib/ruote-kit/public/_ruote/images/bg_button_left.gif +0 -0
- data/lib/ruote-kit/public/_ruote/images/bg_button_left_cancel.gif +0 -0
- data/lib/ruote-kit/public/_ruote/images/bg_button_left_submit.gif +0 -0
- data/lib/ruote-kit/public/_ruote/images/bg_button_right.gif +0 -0
- data/lib/ruote-kit/public/_ruote/javascripts/SimplyButtons.js +0 -191
- data/lib/ruote-kit/public/_ruote/javascripts/fluo-dial.js +0 -149
- data/lib/ruote-kit/public/_ruote/stylesheets/SimplyButtons.css +0 -226
- data/lib/ruote-kit/public/_ruote/stylesheets/base.css +0 -336
- data/lib/ruote-kit/public/_ruote/stylesheets/style.css +0 -393
- data/lib/ruote-kit/views/launch_process.html.haml +0 -19
- data/lib/ruote-kit/views/process_failed_to_launch.html.haml +0 -7
- data/lib/ruote-kit/views/resource_not_found.html.haml +0 -7
- data/spec/helpers/render_helpers_spec.rb +0 -214
- data/spec/ruote-kit_spec.rb +0 -4
- data/spec/views/expressions.html.haml_spec.rb +0 -31
- data/spec/views/launch_process.html.haml_spec.rb +0 -22
- data/spec/views/process.html.haml_spec.rb +0 -17
- data/spec/views/process_launched.html.haml_spec.rb +0 -16
- data/spec/views/processes.html.haml_spec.rb +0 -31
- data/spec/views/workitems.html.haml_spec.rb +0 -69
@@ -1,55 +1,112 @@
|
|
1
|
+
|
2
|
+
# license is MIT, see LICENSE.txt
|
3
|
+
|
1
4
|
class RuoteKit::Application
|
2
5
|
|
3
|
-
get
|
4
|
-
|
5
|
-
|
6
|
-
|
6
|
+
get '/_ruote/expressions/:id' do
|
7
|
+
|
8
|
+
@process, @expression, fei = fetch_pe
|
9
|
+
|
10
|
+
return http_error(404) unless @process
|
11
|
+
|
12
|
+
if fei
|
13
|
+
|
14
|
+
return http_error(404) unless @expression
|
15
|
+
|
16
|
+
respond_with :expression
|
17
|
+
else
|
18
|
+
|
19
|
+
respond_with :expressions
|
7
20
|
end
|
8
21
|
end
|
9
22
|
|
10
|
-
|
11
|
-
@process = engine.process( params[:wfid] )
|
23
|
+
delete '/_ruote/expressions/:id' do
|
12
24
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
25
|
+
process, expression, fei = fetch_pe
|
26
|
+
|
27
|
+
return http_error(404) unless expression
|
28
|
+
|
29
|
+
if params[:_kill]
|
30
|
+
RuoteKit.engine.kill_expression(expression.fei)
|
18
31
|
else
|
19
|
-
|
32
|
+
RuoteKit.engine.cancel_expression(expression.fei)
|
33
|
+
end
|
34
|
+
|
35
|
+
respond_to do |format|
|
36
|
+
format.html { redirect "/_ruote/expressions/#{expression.fei.wfid}" }
|
37
|
+
format.json { json :status, :ok }
|
20
38
|
end
|
21
39
|
end
|
22
40
|
|
23
|
-
|
24
|
-
@process = engine.process( params[:wfid] )
|
41
|
+
put '/_ruote/expressions/:id' do
|
25
42
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
43
|
+
process, expression, fei = fetch_pe
|
44
|
+
|
45
|
+
return http_error(404) unless expression
|
46
|
+
|
47
|
+
info = begin
|
48
|
+
fetch_re_apply_info
|
49
|
+
rescue Rufus::Json::ParserError => pe
|
50
|
+
return http_error(400, pe)
|
51
|
+
end
|
52
|
+
|
53
|
+
#puts '-' * 80
|
54
|
+
#p params
|
55
|
+
#p info
|
56
|
+
#puts '-' * 80
|
57
|
+
|
58
|
+
options = {}
|
59
|
+
options[:fields] = info.fields if info.fields
|
60
|
+
options[:tree] = info.tree if info.tree
|
61
|
+
|
62
|
+
RuoteKit.engine.re_apply(expression.fei, options)
|
63
|
+
|
64
|
+
respond_to do |format|
|
65
|
+
format.html { redirect "/_ruote/expressions/#{expression.fei.wfid}" }
|
66
|
+
format.json { json :status, :ok }
|
33
67
|
end
|
34
68
|
end
|
35
69
|
|
36
|
-
|
37
|
-
process = engine.process( params[:wfid] )
|
70
|
+
protected
|
38
71
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
72
|
+
def fetch_pe
|
73
|
+
|
74
|
+
fei = params[:id].split('!')
|
75
|
+
wfid = fei.last
|
76
|
+
|
77
|
+
process = RuoteKit.engine.process(wfid)
|
78
|
+
|
79
|
+
expression = process ?
|
80
|
+
process.expressions.detect { |exp| exp.fei.sid == params[:id] } :
|
81
|
+
nil
|
82
|
+
|
83
|
+
fei = (fei.length > 1)
|
84
|
+
|
85
|
+
[ process, expression, fei ]
|
86
|
+
end
|
87
|
+
|
88
|
+
def fetch_re_apply_info
|
89
|
+
|
90
|
+
if request.content_type == 'application/json' then
|
91
|
+
|
92
|
+
data = Rufus::Json.decode(request.body.read)
|
93
|
+
if exp = data['expression']; data = exp; end
|
94
|
+
|
95
|
+
OpenStruct.new(data)
|
45
96
|
|
46
|
-
respond_to do |format|
|
47
|
-
format.html { redirect "/_ruote/expressions/#{params[:wfid]}" }
|
48
|
-
format.json { json( :status, :ok ) }
|
49
|
-
end
|
50
97
|
else
|
51
|
-
|
98
|
+
|
99
|
+
o = OpenStruct.new
|
100
|
+
|
101
|
+
if fields = params[:fields]
|
102
|
+
o.fields = Rufus::Json.decode(fields)
|
103
|
+
end
|
104
|
+
if tree = params[:tree]
|
105
|
+
o.tree = Rufus::Json.decode(tree)
|
106
|
+
end
|
107
|
+
|
108
|
+
o
|
52
109
|
end
|
53
110
|
end
|
54
|
-
|
55
111
|
end
|
112
|
+
|
@@ -0,0 +1,53 @@
|
|
1
|
+
|
2
|
+
# license is MIT, see LICENSE.txt
|
3
|
+
|
4
|
+
class RuoteKit::Application
|
5
|
+
|
6
|
+
get '/_ruote/participants/?' do
|
7
|
+
|
8
|
+
@participants = RuoteKit.engine.participant_list
|
9
|
+
|
10
|
+
respond_with :participants
|
11
|
+
end
|
12
|
+
|
13
|
+
put '/_ruote/participants/?' do
|
14
|
+
|
15
|
+
list = []
|
16
|
+
|
17
|
+
if request.content_type.match(/\/json/)
|
18
|
+
|
19
|
+
list = Rufus::Json.decode(request.body.read)
|
20
|
+
list = list['participants'] if list.is_a?(Hash)
|
21
|
+
|
22
|
+
else
|
23
|
+
|
24
|
+
index = 0
|
25
|
+
|
26
|
+
loop do
|
27
|
+
|
28
|
+
break unless params["regex_#{index}"]
|
29
|
+
|
30
|
+
list << {
|
31
|
+
'regex' => params["regex_#{index}"],
|
32
|
+
'classname' => params["classname_#{index}"],
|
33
|
+
'options' => Rufus::Json.decode(params["options_#{index}"])
|
34
|
+
}
|
35
|
+
index = index + 1
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
RuoteKit.engine.participant_list = list
|
40
|
+
|
41
|
+
respond_to do |format|
|
42
|
+
|
43
|
+
format.html do
|
44
|
+
redirect '/_ruote/participants'
|
45
|
+
end
|
46
|
+
format.json do
|
47
|
+
@participants = RuoteKit.engine.participant_list
|
48
|
+
json :participants
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
@@ -1,59 +1,91 @@
|
|
1
|
+
|
2
|
+
# license is MIT, see LICENSE.txt
|
3
|
+
|
4
|
+
|
1
5
|
class RuoteKit::Application
|
2
6
|
|
3
|
-
get
|
4
|
-
@processes = engine.processes
|
7
|
+
get '/_ruote/processes/?' do
|
5
8
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
9
|
+
@count = RuoteKit.engine.processes(:count => true)
|
10
|
+
paginate
|
11
|
+
|
12
|
+
@processes = RuoteKit.engine.processes(
|
13
|
+
:descending => true, :skip => @skip, :limit => @limit)
|
14
|
+
|
15
|
+
respond_with :processes
|
10
16
|
end
|
11
17
|
|
12
|
-
get
|
13
|
-
|
18
|
+
get '/_ruote/processes/new' do
|
19
|
+
|
20
|
+
haml :processes_new
|
14
21
|
end
|
15
22
|
|
16
|
-
get
|
23
|
+
get '/_ruote/processes/:wfid' do
|
17
24
|
|
18
|
-
@process = engine.process(
|
25
|
+
@process = RuoteKit.engine.process(params[:wfid])
|
19
26
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
format.json { json( :process, @process ) }
|
24
|
-
end
|
25
|
-
else
|
26
|
-
resource_not_found
|
27
|
-
end
|
27
|
+
return http_error(404) unless @process
|
28
|
+
|
29
|
+
respond_with :process
|
28
30
|
end
|
29
31
|
|
30
|
-
post
|
31
|
-
|
32
|
+
post '/_ruote/processes' do
|
33
|
+
|
34
|
+
begin
|
35
|
+
|
36
|
+
@info = fetch_launch_info
|
37
|
+
|
38
|
+
@wfid = RuoteKit.engine.launch(
|
39
|
+
@info.definition, @info.fields || {}, @info.variables || {})
|
40
|
+
|
41
|
+
rescue Exception => e
|
42
|
+
return http_error(400, e)
|
43
|
+
end
|
44
|
+
|
45
|
+
status 201 # created
|
32
46
|
|
33
47
|
respond_to do |format|
|
34
|
-
|
35
|
-
|
36
|
-
rescue ArgumentError => @error
|
37
|
-
status 422
|
38
|
-
format.html { haml :process_failed_to_launch }
|
39
|
-
format.json { { "error" => { "code" => 422, "message" => @error.message } }.to_json }
|
40
|
-
else
|
41
|
-
format.html { haml :process_launched }
|
42
|
-
format.json { json( :launched, @wfid ) }
|
43
|
-
end
|
48
|
+
format.html { haml :process_launched }
|
49
|
+
format.json { json :launched, @wfid }
|
44
50
|
end
|
45
51
|
end
|
46
52
|
|
47
|
-
delete
|
48
|
-
|
49
|
-
|
53
|
+
delete '/_ruote/processes/:wfid' do
|
54
|
+
|
55
|
+
if params[:_kill] == '1'
|
56
|
+
RuoteKit.engine.kill_process(params[:wfid])
|
50
57
|
else
|
51
|
-
engine.cancel_process(
|
58
|
+
RuoteKit.engine.cancel_process(params[:wfid])
|
52
59
|
end
|
53
60
|
|
54
61
|
respond_to do |format|
|
55
|
-
format.html { redirect
|
56
|
-
format.json { json
|
62
|
+
format.html { redirect '/_ruote/processes' }
|
63
|
+
format.json { json :status, :ok }
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
protected
|
68
|
+
|
69
|
+
def fetch_launch_info
|
70
|
+
|
71
|
+
if request.content_type == 'application/json' then
|
72
|
+
|
73
|
+
OpenStruct.new(Rufus::Json.decode(request.body.read))
|
74
|
+
|
75
|
+
else
|
76
|
+
|
77
|
+
info = OpenStruct.new('definition' => params[:definition])
|
78
|
+
|
79
|
+
fields = params[:fields] || ''
|
80
|
+
fields = '{}' if fields.empty?
|
81
|
+
info.fields = Rufus::Json.decode(fields)
|
82
|
+
|
83
|
+
vars = params[:variables] || ''
|
84
|
+
vars = '{}' if vars.empty?
|
85
|
+
info.variables = Rufus::Json.decode(vars)
|
86
|
+
|
87
|
+
info
|
57
88
|
end
|
58
89
|
end
|
59
90
|
end
|
91
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
|
2
|
+
# license is MIT, see LICENSE.txt
|
3
|
+
|
4
|
+
class RuoteKit::Application
|
5
|
+
|
6
|
+
get '/_ruote/schedules/?' do
|
7
|
+
|
8
|
+
@count = RuoteKit.engine.processes(:count => true)
|
9
|
+
paginate
|
10
|
+
|
11
|
+
@schedules = RuoteKit.engine.schedules(:skip => @skip, :limit => @limit)
|
12
|
+
|
13
|
+
respond_with :schedules
|
14
|
+
end
|
15
|
+
|
16
|
+
get '/_ruote/schedules/:wfid' do
|
17
|
+
|
18
|
+
@schedules = RuoteKit.engine.schedules(params[:wfid])
|
19
|
+
|
20
|
+
@count = @schedules.size
|
21
|
+
@skip = 0
|
22
|
+
@limit = @count
|
23
|
+
|
24
|
+
respond_with :schedules
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
@@ -1,65 +1,127 @@
|
|
1
|
+
|
2
|
+
# license is MIT, see LICENSE.txt
|
3
|
+
|
1
4
|
class RuoteKit::Application
|
2
5
|
|
3
|
-
get
|
6
|
+
get '/_ruote/workitems/?' do
|
4
7
|
|
5
8
|
query = params.inject({}) { |h, (k, v)|
|
6
9
|
h[k] = (Rufus::Json.decode(v) rescue v)
|
7
10
|
h
|
8
11
|
}
|
9
12
|
|
10
|
-
@
|
13
|
+
@count = RuoteKit.engine.storage_participant.query(:count => true)
|
11
14
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
+
if (query.keys - %w[ limit skip ]).empty?
|
16
|
+
paginate
|
17
|
+
else
|
18
|
+
@skip = 0
|
19
|
+
@limit = @count
|
15
20
|
end
|
16
|
-
end
|
17
21
|
|
18
|
-
|
19
|
-
|
20
|
-
@workitems = find_workitems( params[:wfid] )
|
22
|
+
query['skip'] = @skip
|
23
|
+
query['limit'] = @limit
|
21
24
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
end
|
25
|
+
@workitems = RuoteKit.engine.storage_participant.query(query)
|
26
|
+
|
27
|
+
respond_with :workitems
|
26
28
|
end
|
27
29
|
|
28
|
-
get
|
29
|
-
|
30
|
+
get '/_ruote/workitems/:id' do
|
31
|
+
|
32
|
+
@workitem, @workitems, @wfid = fetch_wi
|
33
|
+
|
34
|
+
return http_error(404) if @workitem.nil? && @workitems.nil?
|
30
35
|
|
31
36
|
if @workitem
|
32
|
-
|
33
|
-
format.html { haml :workitem }
|
34
|
-
format.json { json( :workitem, @workitem ) }
|
35
|
-
end
|
37
|
+
respond_with :workitem
|
36
38
|
else
|
37
|
-
|
39
|
+
respond_with :workitems
|
38
40
|
end
|
39
41
|
end
|
40
42
|
|
41
|
-
put
|
42
|
-
workitem = find_workitem( params[:wfid], params[:expid] )
|
43
|
+
put '/_ruote/workitems/:id' do
|
43
44
|
|
44
|
-
|
45
|
+
@workitem, _, _ = fetch_wi
|
45
46
|
|
46
|
-
|
47
|
+
return http_error(404) unless @workitem
|
48
|
+
|
49
|
+
options = begin
|
50
|
+
field_updates_and_proceed_from_put
|
51
|
+
rescue Rufus::Json::ParserError => pe
|
52
|
+
return http_error(400, pe)
|
53
|
+
end
|
47
54
|
|
48
55
|
unless options[:fields].empty?
|
49
|
-
workitem.fields = options[:fields]
|
50
|
-
storage_participant.update(
|
56
|
+
@workitem.fields = options[:fields]
|
57
|
+
RuoteKit.engine.storage_participant.update(@workitem)
|
51
58
|
end
|
52
59
|
|
53
60
|
if options[:proceed]
|
54
|
-
storage_participant.reply(
|
61
|
+
RuoteKit.engine.storage_participant.reply(@workitem)
|
55
62
|
end
|
56
63
|
|
57
64
|
respond_to do |format|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
65
|
+
|
66
|
+
format.html do
|
67
|
+
redirect(options[:proceed] ?
|
68
|
+
"/_ruote/workitems/#{@workitem.fei.wfid}" :
|
69
|
+
"/_ruote/workitems/#{@workitem.fei.sid}")
|
70
|
+
end
|
71
|
+
format.json do
|
72
|
+
json :workitem
|
73
|
+
end
|
62
74
|
end
|
63
75
|
end
|
64
76
|
|
77
|
+
protected
|
78
|
+
|
79
|
+
def fetch_wi
|
80
|
+
|
81
|
+
fei = params[:id].split('!')
|
82
|
+
wfid = fei.last
|
83
|
+
|
84
|
+
workitem = nil
|
85
|
+
workitems = nil
|
86
|
+
|
87
|
+
wis = RuoteKit.engine.storage_participant.by_wfid(wfid)
|
88
|
+
|
89
|
+
if fei.length > 1
|
90
|
+
workitem = wis.find { |wi| wi.fei.sid == params[:id] }
|
91
|
+
else
|
92
|
+
workitems = wis
|
93
|
+
end
|
94
|
+
|
95
|
+
[ workitem, workitems, wfid ]
|
96
|
+
end
|
97
|
+
|
98
|
+
def field_updates_and_proceed_from_put
|
99
|
+
|
100
|
+
options = { :fields => {}, :proceed => false }
|
101
|
+
|
102
|
+
if request.content_type == 'application/json'
|
103
|
+
|
104
|
+
data = Rufus::Json.decode(env['rack.input'].read)
|
105
|
+
if wi = data['workitem']; data = wi; end
|
106
|
+
|
107
|
+
unless data['fields'].nil? || data['fields'].empty?
|
108
|
+
options[:fields] = data['fields']
|
109
|
+
end
|
110
|
+
unless data['_proceed'].nil? || data['_proceed'].empty?
|
111
|
+
options[:proceed] = data['_proceed']
|
112
|
+
end
|
113
|
+
|
114
|
+
else
|
115
|
+
|
116
|
+
unless params['fields'].nil? || params['fields'].empty?
|
117
|
+
options[:fields] = Rufus::Json.decode(params[:fields])
|
118
|
+
end
|
119
|
+
unless params[:_proceed].nil? || params[:_proceed].empty?
|
120
|
+
options[:proceed] = params[:_proceed]
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
options
|
125
|
+
end
|
65
126
|
end
|
127
|
+
|
@@ -1,9 +1,15 @@
|
|
1
|
+
|
2
|
+
# license is MIT, see LICENSE.txt
|
3
|
+
|
1
4
|
module RuoteKit
|
2
5
|
module Spec
|
6
|
+
|
3
7
|
module RuoteHelpers
|
4
8
|
|
5
9
|
# Launch a dummy process and return the wfid
|
6
|
-
|
10
|
+
#
|
11
|
+
def launch_test_process(&block)
|
12
|
+
|
7
13
|
pdef = if block_given?
|
8
14
|
yield
|
9
15
|
else
|
@@ -14,34 +20,37 @@ module RuoteKit
|
|
14
20
|
end
|
15
21
|
end
|
16
22
|
|
17
|
-
wfid = RuoteKit.engine.launch(
|
18
|
-
|
19
|
-
# Wait for the process list to populate
|
20
|
-
sleep 0.1 while RuoteKit.engine.process( wfid ).nil?
|
23
|
+
wfid = RuoteKit.engine.launch(pdef)
|
21
24
|
|
22
|
-
#
|
23
|
-
|
24
|
-
|
25
|
+
# give the engine some time to run the process
|
26
|
+
# (remember it does it asynchronously)
|
27
|
+
sleep(0.350)
|
25
28
|
|
26
29
|
wfid
|
27
30
|
end
|
28
31
|
|
29
|
-
def noisy(
|
30
|
-
RuoteKit.engine.
|
32
|
+
def noisy(on = true)
|
33
|
+
RuoteKit.engine.noisy = on
|
31
34
|
end
|
32
35
|
|
33
|
-
def
|
34
|
-
RuoteKit.
|
36
|
+
def engine
|
37
|
+
RuoteKit.engine
|
35
38
|
end
|
36
39
|
|
37
|
-
def
|
38
|
-
|
40
|
+
def storage_participant
|
41
|
+
RuoteKit.engine.storage_participant
|
39
42
|
end
|
40
43
|
|
41
|
-
def
|
42
|
-
|
44
|
+
def find_workitem(wfid, expid)
|
45
|
+
RuoteKit.engine.storage_participant.by_wfid(wfid).first { |wi|
|
46
|
+
wi.fei.expid == expid
|
47
|
+
}
|
43
48
|
end
|
44
49
|
|
50
|
+
def wait_for(wfid)
|
51
|
+
RuoteKit.engine.wait_for(wfid)
|
52
|
+
end
|
45
53
|
end
|
46
54
|
end
|
47
55
|
end
|
56
|
+
|
data/lib/ruote-kit/version.rb
CHANGED
@@ -0,0 +1,38 @@
|
|
1
|
+
|
2
|
+
#pagination
|
3
|
+
|
4
|
+
- res = request.path.split('/')[2]
|
5
|
+
|
6
|
+
- if @skip
|
7
|
+
|
8
|
+
- lim = @limit || settings.limit
|
9
|
+
|
10
|
+
- @skip = 0 if @skip < 0
|
11
|
+
- @skip = @count - lim if @skip >= @count
|
12
|
+
|
13
|
+
= (@count > 0) ? @skip + 1 : 0
|
14
|
+
to
|
15
|
+
= [ @skip + @limit, @count ].min
|
16
|
+
of
|
17
|
+
= @count
|
18
|
+
= res
|
19
|
+
|
20
|
+
- las = ((@count / lim.to_f).ceil - 1) * lim
|
21
|
+
- pre = [ 0, @skip - lim ].max
|
22
|
+
- nex = [ @skip + lim, las ].min
|
23
|
+
|
24
|
+
%a.pagination{ :href => request.path, :rel => 'all' } all
|
25
|
+
- if @skip > 0
|
26
|
+
%a.pagination{ :href => "#{request.path}?limit=#{lim}&skip=0", :rel => 'first' } first
|
27
|
+
- if @skip > 0 && pre != 0
|
28
|
+
%a.pagination{ :href => "#{request.path}?limit=#{lim}&skip=#{pre}", :rel => 'previous' } previous
|
29
|
+
- if nex != las
|
30
|
+
%a.pagination{ :href => "#{request.path}?limit=#{lim}&skip=#{nex}", :rel => 'next' } next
|
31
|
+
- if las > 0 && @skip < las
|
32
|
+
%a.pagination{ :href => "#{request.path}?limit=#{lim}&skip=#{las}", :rel => 'last' } last
|
33
|
+
|
34
|
+
- else
|
35
|
+
|
36
|
+
- if resources = instance_variable_get("@#{res}")
|
37
|
+
= "#{resources.size} #{res}"
|
38
|
+
|
@@ -0,0 +1,52 @@
|
|
1
|
+
|
2
|
+
#overlay
|
3
|
+
#editor
|
4
|
+
%canvas#efluo
|
5
|
+
#fluo_editor
|
6
|
+
%a.ruote_button.ruote_go_button{ :title => 'close and use that definition', :href => '', :onclick => 'hideEditor(true); return false;' }
|
7
|
+
%a.ruote_button.ruote_cross_button{ :title => 'close', :href => '', :onclick => 'hideEditor(false); return false;' }
|
8
|
+
|
9
|
+
:javascript
|
10
|
+
|
11
|
+
$('textarea.variables').hide();
|
12
|
+
|
13
|
+
$('#overlay').hide();
|
14
|
+
$('#editor').hide();
|
15
|
+
|
16
|
+
function initEditor () {
|
17
|
+
|
18
|
+
var tree = tree || #{sample_process_tree};
|
19
|
+
var def = $('#tree')[0].value;
|
20
|
+
if (def.match(/\s*\[/)) tree = JSON.parse(def);
|
21
|
+
|
22
|
+
FluoEditor.renderFlow('fluo_editor', tree);
|
23
|
+
Fluo.renderFlow('efluo', tree);
|
24
|
+
Fluo.crop('efluo');
|
25
|
+
|
26
|
+
$('#fluo_editor')[0].onChange = function (tree) {
|
27
|
+
Fluo.renderFlow('efluo', tree);
|
28
|
+
Fluo.crop('efluo');
|
29
|
+
}
|
30
|
+
$('#fluo_editor')[0].onOver = function (expid) {
|
31
|
+
Fluo.highlight('efluo', expid);
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
35
|
+
function showEditor () {
|
36
|
+
|
37
|
+
initEditor();
|
38
|
+
|
39
|
+
document.getElementById('overlay').style.height =
|
40
|
+
'' + window.outerHeight + 'px';
|
41
|
+
|
42
|
+
$('#overlay').slideDown(function () { $('#editor').show(); });
|
43
|
+
}
|
44
|
+
|
45
|
+
function hideEditor (use) {
|
46
|
+
|
47
|
+
$('#editor').hide();
|
48
|
+
$('#overlay').hide();
|
49
|
+
|
50
|
+
if (use) $('#tree')[0].value = FluoEditor.asJson('fluo_editor');
|
51
|
+
}
|
52
|
+
|