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
@@ -1,55 +1,122 @@
1
+
2
+ - # under the MIT license, see LICENSE.txt
3
+
1
4
  - @_uses_fluo = true
2
5
 
3
- %h2
6
+ %h1
7
+ process
4
8
  = @process.wfid
5
- (#{@process.definition_name})
6
-
7
- .options
8
- %ul.nolist
9
- /
10
- %li.b5
11
- %form{ :method => 'post' }
12
- %input{ :type => 'hidden', :name => '_method', :value => 'put' }
13
- = button "Pause", 'force-block'
14
- %span.description PUT /_ruote/processes/#{@process.wfid}?_pause=1
15
- %li.b5
9
+
10
+ %canvas#fluo
11
+
12
+ %table.details
13
+ %tr
14
+ %td
15
+ name
16
+ %td
17
+ &= @process.definition_name
18
+ &= @process.definition_revision
19
+ %tr
20
+ %td
21
+ position
22
+ %td
23
+ - @process.position.each do |pos|
24
+ - text = "#{pos[1]} #{pos[2]['task']}"
25
+ - expid = pos.first.split('!').first
26
+ %span{ :onmouseover => "Fluo.highlight('fluo', '#{expid}');", :onmouseout => "Fluo.highlight('fluo');" }
27
+ - if @process.stored_workitems.find { |wi| wi.fei.sid == pos.first }
28
+ = alink(:workitems, pos.first, :text => text)
29
+ - else
30
+ = text
31
+ %tr
32
+ %td
33
+ expressions
34
+ %td
35
+ = alink(:expressions, @process.wfid, :text => @process.expressions.size)
36
+ %tr
37
+ %td
38
+ workitems
39
+ %td
40
+ #{@process.workitems.size} out,
41
+ - text = "#{@process.stored_workitems.size} in storage participant"
42
+ - if @process.stored_workitems.size > 0
43
+ = alink(:workitems, @process.wfid, :text => text)
44
+ - else
45
+ = text
46
+ %tr
47
+ %td
48
+ errors
49
+ %td
50
+ - if @process.errors.size > 0
51
+ = alink(:errors, @process.wfid, :text => @process.errors.size)
52
+ - else
53
+ 0
54
+ %tr
55
+ %td
56
+ launch time
57
+ %td
58
+ = Time.parse(@process.launched_time).localtime.strftime('%Y/%m/%d %H:%M:%S')
59
+ %tr
60
+ %td
61
+ last active
62
+ %td
63
+ = Time.parse(@process.last_active).localtime.strftime('%Y/%m/%d %H:%M:%S')
64
+ %tr
65
+ %td
66
+ tags
67
+ %td
68
+ &= @process.tags.collect { |ta| ta.first }.join(', ')
69
+
70
+ %tr
71
+ %td.no_border{ :colspan => 2 }
72
+  
73
+
74
+ %tr
75
+ %td
76
+ cancel expression
77
+ %td
16
78
  %form{ :method => 'post' }
17
79
  %input{ :type => 'hidden', :name => '_method', :value => 'delete' }
18
- = button "Cancel", "cancel force-block"
80
+ %input{ :type => 'submit', :value => 'cancel', :onclick => 'return confirm("really ?");' }
19
81
  %span.description DELETE /_ruote/processes/#{@process.wfid}
20
- %li.b5
82
+ %tr
83
+ %td
84
+ kill expression
85
+ %td
21
86
  %form{ :method => 'post' }
22
87
  %input{ :type => 'hidden', :name => '_method', :value => 'delete' }
23
88
  %input{ :type => 'hidden', :name => '_kill', :value => '1' }
24
- = button "Kill", "cancel force-block"
89
+ %input{ :type => 'submit', :value => 'kill', :onclick => 'return confirm("really ?");' }
25
90
  %span.description DELETE /_ruote/processes/#{@process.wfid}?_kill=1
26
-
27
- %ul.nolist
28
- %li wfid: #{@process.wfid}
29
- %li launch: #{@process.launched_time}
30
- /%li paused:
31
- %li: tags: #{@process.all_tags.keys.join(', ')}
32
- %li
33
- expressions:
34
- %a{ :href => "/_ruote/expressions/#{@process.wfid}" } GET /_ruote/expressions/#{@process.wfid}
35
- %li
36
- workitems:
37
- %a{ :href => "/_ruote/workitems/#{@process.wfid}" } GET /_ruote/workitems/#{@process.wfid}
38
- %li errors: #{@process.errors.size}
39
-
40
- %ul
41
- %li TODO
42
- %li Branches
43
- %li Process variables
44
- %li Scheduled jobs
45
- %li Active expression
46
- %li Tree
47
-
48
- %p  
49
-
50
- %canvas#fluo
91
+ %tr
92
+ %td
93
+ expressions
94
+ %td
95
+ GET
96
+ = alink(:expressions, @process.wfid)
97
+ %tr
98
+ %td
99
+ workitems
100
+ %td
101
+ GET
102
+ = alink(:workitems, @process.wfid)
103
+ %tr
104
+ %td
105
+ errors
106
+ %td
107
+ GET
108
+ = alink(:errors, @process.wfid)
109
+ %tr
110
+ %td
111
+ schedules
112
+ %td
113
+ GET
114
+ = alink(:schedules, @process.wfid)
51
115
 
52
116
  :javascript
53
- var proc_rep = #{process_tree( @process )};
54
- Fluo.renderFlow( 'fluo', proc_rep );
117
+
118
+ var proc_rep = #{process_tree(@process)};
119
+ Fluo.renderFlow('fluo', proc_rep);
55
120
  Fluo.crop('fluo');
121
+ Fluo.resizeForMaxWidth('fluo', $('body').width() / 2.1);
122
+
@@ -1,6 +1,10 @@
1
- %h2 Process launched
1
+
2
+ - # under the MIT license, see LICENSE.txt
3
+
4
+ %h1 process launched
2
5
 
3
6
  .flash
4
7
  .message
5
8
  .notice
6
- %p Your process has been launched. #{ link_to "GET /_ruote/processes/#{@wfid}", "/_ruote/processes/#{@wfid}" }
9
+ %p process #{alink(:processes, @wfid)} has been launched.
10
+
@@ -1,27 +1,58 @@
1
- %h2 Processes
2
1
 
3
- .flash
4
- .message
5
- - if @processes.empty?
6
- .warn
7
- %p No processes are currently running
8
- - else
9
- .notice
10
- %p Currently running #{@processes.size} processes
2
+ - # under the MIT license, see LICENSE.txt
3
+
4
+ %h1 processes
5
+
6
+ = haml :_pagination, :layout => false
7
+
8
+ %table.list
9
+ %thead
10
+ %td
11
+ wfid
12
+ %td
13
+ name
14
+ %td
15
+ position
16
+ %td
17
+ tags
18
+ %td
19
+ launched
20
+ %td
21
+ last active
22
+ %td
23
+ exps
24
+ %td
25
+ errs
26
+ %td
27
+ wis
11
28
 
12
- %ul.nested_list
13
29
  - @processes.each do |process|
14
- %li
15
- = link_to process
16
- %ul.nested_details
17
- %li wfid: #{process.wfid}
18
- %li process: #{process.definition_name} (#{process.definition_revision})
19
- %li launched: #{process.launched_time}
20
- %li tags: #{process.all_tags.keys.join(', ')}
21
- %li
22
- expressions:
23
- %a{ :href => "/_ruote/expressions/#{process.wfid}" } GET /_ruote/expressions/#{process.wfid}
24
- %li
25
- workitems:
26
- %a{ :href => "/_ruote/workitems/#{process.wfid}" } GET /_ruote/workitems/#{process.wfid}
27
- %li errors: #{process.errors.size}
30
+ %tr
31
+ %td
32
+ = alink(:processes, process.wfid, :text => process.wfid)
33
+ %td
34
+ &= process.definition_name
35
+ &= process.definition_revision
36
+ %td
37
+ - process.position.each do |pos|
38
+ - stored_wi = process.stored_workitems.find { |wi| wi.fei.sid == pos[0] }
39
+ - text = "#{pos[1]} #{pos[2]['task']}"
40
+ - if stored_wi
41
+ = alink(:workitems, stored_wi.fei.sid, :text => text)
42
+ - else
43
+ &= text
44
+ %td
45
+ &= process.tags.collect { |ta| ta.first }.join(', ')
46
+ %td
47
+ = Time.parse(process.launched_time).localtime.strftime('%Y/%m/%d %H:%M:%S')
48
+ %td
49
+ = Time.parse(process.last_active).localtime.strftime('%Y/%m/%d %H:%M:%S')
50
+ %td.right{ :title => 'expressions' }
51
+ = alink(:expressions, process.wfid, :text => process.expressions.size)
52
+ %td.right{ :title => 'errors' }
53
+ - if process.errors.size > 0
54
+ = alink(:errors, process.wfid, :text => process.errors.size)
55
+ %td.right{ :title => 'workitems' }
56
+ - if process.stored_workitems.size > 0
57
+ = alink(:workitems, process.wfid, :text => process.stored_workitems.size)
58
+
@@ -0,0 +1,36 @@
1
+
2
+ - # under the MIT license, see LICENSE.txt
3
+
4
+ - @_uses_fluo = true
5
+
6
+
7
+ %h1 launch process
8
+
9
+ %form{ :method => 'POST', :action => '/_ruote/processes', :enctype => 'multipart/form-data', :accept_charset => 'UTF-8' }
10
+
11
+ %input{ :type => 'hidden', :name => '_snowman', :value => '☃' }
12
+
13
+ %div
14
+ %label
15
+ process definition
16
+ %a.ruote_button.ruote_go_button{ :title => 'open process definition editor', :href => '', :onclick => 'showEditor(); return false;' }
17
+
18
+ %textarea#tree{ :name => 'definition', :cols => 80, :rows => 10 } #{sample_process}
19
+
20
+ %div
21
+ %label
22
+ workitem fields
23
+ %textarea{ :name => 'fields', :cols => 80, :rows => 3 }
24
+
25
+ %div
26
+ %label.togglable{ :onclick => 'Rk.toggle(this, $("textarea.variables")[0], "(process variables)", "process variables");' }
27
+ (process variables)
28
+ %textarea.variables{ :name => 'variables', :cols => 80, :rows => 3 }
29
+
30
+ %div
31
+ %input{ :type => 'submit', 'value' => 'launch' }
32
+ or
33
+ %a{ :href => '/_ruote/processes' } cancel
34
+
35
+ = haml :_tree_editor, :layout => false
36
+
@@ -0,0 +1,42 @@
1
+
2
+ - # under the MIT license, see LICENSE.txt
3
+
4
+ %h1 schedules
5
+
6
+ = haml :_pagination, :layout => false
7
+
8
+ %table.list
9
+
10
+ %thead
11
+ %td
12
+ owner / [ target ]
13
+ %td
14
+ process schedules
15
+ %td
16
+ type
17
+ %td
18
+ put at
19
+ %td
20
+ original
21
+ %td
22
+ at
23
+
24
+ - @schedules.each do |schedule|
25
+ %tr
26
+ %td
27
+ %div
28
+ = alink(:expressions, schedule['owner'].sid)
29
+ - if schedule['owner'] != schedule['target']
30
+ %div
31
+ = alink(:expressions, schedule['target'].sid)
32
+ %td
33
+ = alink(:schedules, schedule['owner'].wfid)
34
+ %td
35
+ &= schedule['type']
36
+ %td
37
+ = Time.parse(schedule['put_at']).localtime.strftime('%Y/%m/%d %H:%M:%S')
38
+ %td
39
+ &= schedule['original']
40
+ %td
41
+ = Time.parse(schedule['at']).localtime.strftime('%Y/%m/%d %H:%M:%S')
42
+
@@ -1,39 +1,93 @@
1
+
2
+ - # under the MIT license, see LICENSE.txt
3
+
1
4
  - @_uses_fluo = true
2
5
 
3
- %h2 Workitem #{@workitem.fei.wfid}/#{@workitem.fei.expid}
6
+ %h1
7
+ workitem
8
+ = @workitem.fei.sid
4
9
 
5
- %ul.nolist
6
- %li fei: #{@workitem.fei.to_s}
7
- %li participant: #{@workitem.participant_name}
8
- %li dispatched: #{@workitem.dispatch_at}
9
- %li last modified: #{@workitem.h.put_at}
10
- %li process: #{link_to engine.process( @workitem.fei.wfid) }
11
- %li expressions:
12
- %li workitems of this process: #{link_to "GET /_ruote/workitems/#{@workitem.fei.wfid}", "/_ruote/workitems/#{@workitem.fei.wfid}" }
10
+ %canvas#fluo
13
11
 
14
- %p  
12
+ %form{ :method => 'POST', :enctype => 'multipart/form-data', :accept_charset => 'UTF-8' }
15
13
 
16
- %form.form{ :method => 'post' }
17
14
  %input{ :type => 'hidden', :name => '_method', :value => 'put' }
18
- %input{ :type => 'hidden', :name => '_procced', :value => '1' }
19
- .group
20
- %label.label{ :for => "fields" } Fields
21
- %textarea.text_area{ :name => "fields", :cols => 80, :rows => 10 }
22
- = Rufus::Json.encode(@workitem.fields)
23
- %span.description The current workitem fields in JSON format
24
- .group
25
- %input{ :type => 'checkbox', :name => '_proceed', :value => '1' }
26
- %label{ :for => '_proceed' } Proceed the workflow (_proceed=1)
27
- %br
28
- %span.description Check to let the workflow proceed, leave unchecked to just update workitem fields
29
- .group.navform
30
- %input.submit{ :type => 'submit', :value => "PUT /_ruote/workitems/#{@workitem.fei.wfid}/#{@workitem.fei.expid}" }
31
-
32
- %p  
15
+ %input{ :type => 'hidden', :name => '_snowman', :value => '☃' }
33
16
 
34
- %canvas#fluo
17
+ %table.details
18
+ %tr
19
+ %td
20
+ participant
21
+ %td
22
+ &= @workitem.participant_name
23
+ %tr
24
+ %td
25
+ dispatched at
26
+ %td
27
+ - if @workitem.dispatched_at
28
+ = Time.parse(@workitem.dispatched_at).localtime.strftime('%Y/%m/%d %H:%M:%S')
29
+ %tr
30
+ %td
31
+ last modified
32
+ %td
33
+ = Time.parse(@workitem.h.put_at).localtime.strftime('%Y/%m/%d %H:%M:%S')
34
+
35
+ %tr
36
+ %td.no_border{ :colspan => 2 }
37
+  
38
+
39
+ %tr
40
+ %td
41
+ process
42
+ %td
43
+ GET
44
+ = alink(:processes, @workitem.fei.wfid)
45
+ %tr
46
+ %td
47
+ expression
48
+ %td
49
+ GET
50
+ = alink(:expressions, @workitem.fei.sid)
51
+ %tr
52
+ %td
53
+ other workitems
54
+ %td
55
+ GET
56
+ = alink(:workitems, @workitem.fei.wfid)
57
+
58
+ %tr
59
+ %td.no_border{ :colspan => 2 }
60
+  
61
+
62
+ %tr
63
+ %td
64
+ params
65
+ %td
66
+ - fields = @workitem.fields.dup
67
+ - params = fields.delete('params') || {}
68
+ - params.delete('ref')
69
+ - fields.delete('dispatched_at')
70
+ &= Rufus::Json.encode(params)[1..-2]
71
+ %tr
72
+ %td
73
+ fields
74
+ %td.no_padding
75
+ %textarea{ :name => "fields", :cols => 80, :rows => 10 } #{Rufus::Json.pretty_encode(@workitem.fields)}
76
+ %tr
77
+ %td
78
+ proceed ?
79
+ %td
80
+ %input{ :type => 'checkbox', :name => '_proceed' }
81
+ %tr
82
+ %td
83
+ %td
84
+ %input{ :type => 'submit', :value => "PUT /_ruote/workitems/#{@workitem.fei.sid}" }
35
85
 
36
86
  :javascript
37
- var proc_rep = #{process_tree( @workitem )};
38
- Fluo.renderFlow( 'fluo', proc_rep, { 'workitems' : ['#{@workitem.fei.expid}'] } );
87
+
88
+ var proc_rep = #{process_tree(@workitem)};
89
+
90
+ Fluo.renderFlow('fluo', proc_rep, { 'workitems' : ['#{@workitem.fei.expid}'] });
39
91
  Fluo.crop('fluo');
92
+ Fluo.resizeForMaxWidth('fluo', $('body').width() / 2.1);
93
+
@@ -1,23 +1,46 @@
1
- %h2 Workitems
2
1
 
3
- .flash
4
- .message
5
- - if @workitems.empty?
6
- .warn
7
- %p No workitems are currently available #{ @wfid ? "for #{@wfid}" : '' }
8
- - else
9
- .notice
10
- %p #{ pluralize(@workitems.size, 'workitem') } available #{ @wfid ? "for #{@wfid}" : '' }
2
+ - # under the MIT license, see LICENSE.txt
11
3
 
12
- - if @participants
13
- .notice
14
- %p Filtered for participant(s): #{@participants.join(', ')}
4
+ %h1
5
+ workitems
6
+ = @wfid ? "for #{@wfid}" : ''
7
+
8
+ = haml :_pagination, :layout => false
9
+
10
+ %table.list
11
+
12
+ %thead
13
+ %td
14
+ id
15
+ %td
16
+ process
17
+ %td
18
+ participant
19
+ %td
20
+ params
21
+ %td
22
+ dispatched at
23
+ %td
24
+ fields
15
25
 
16
- %ul.nested_list
17
26
  - @workitems.each do |wi|
18
- %li
19
- = link_to wi
20
- %ul.nested_details
21
- %li fei: #{wi.fei.to_s}
22
- %li participant: #{wi.participant_name}
23
- %li dispath time: TODO
27
+ %tr
28
+ %td
29
+ = alink(:workitems, wi.fei.sid, :text => wi.fei.sid)
30
+ %td
31
+ = alink(:processes, wi.wfid, :text => wi.wfid)
32
+ %td
33
+ &= wi.participant_name
34
+ %td
35
+ - params = (wi.fields['params'] || {}).dup
36
+ - params.delete('ref')
37
+ &= Rufus::Json.encode(params)[1..-2]
38
+ %td
39
+ - if wi.dispatched_at
40
+ = Time.parse(wi.dispatched_at).localtime.strftime('%Y/%m/%d %H:%M:%S')
41
+ %td
42
+ - fields = wi.fields.dup
43
+ - fields.delete('params')
44
+ - fields.delete('dispatched_at')
45
+ = Rufus::Json.encode(fields)[1..-2][0, 28]
46
+
data/lib/ruote-kit.rb CHANGED
@@ -1,109 +1,38 @@
1
+
2
+ # license is MIT, see LICENSE.txt
3
+
4
+ require 'ostruct'
5
+
1
6
  require 'rufus-json'
2
7
  require 'ruote'
3
8
  require 'ruote/part/storage_participant'
4
9
  require 'ruote-kit/version'
5
10
 
11
+
6
12
  module RuoteKit
7
13
 
8
- autoload :Configuration, "ruote-kit/configuration"
9
- autoload :Application, "ruote-kit/application"
10
- autoload :Helpers, "ruote-kit/helpers"
14
+ autoload :Application, 'ruote-kit/application'
11
15
 
12
16
  class << self
13
- # The instance of ruote
14
- attr_accessor :engine
15
17
 
16
- # The instance of our worker, if used
17
- attr_accessor :worker
18
+ attr_accessor :engine
18
19
 
19
20
  def env
20
- @env ||= (
21
- if defined?( Rails )
22
- Rails.env
23
- else
24
- ENV['RACK_ENV'] || 'development'
25
- end
26
- )
27
- end
28
-
29
- # Yields a RuoteKit::Configuration instance and then immediately starts
30
- # the engine.
31
- def configure
32
- yield configuration if block_given?
33
-
34
- run_engine!
35
- end
36
- alias run! configure
37
-
38
- def shutdown!( purge_engine = false )
39
- shutdown_engine( purge_engine )
40
- end
41
-
42
- def configuration
43
- @configuration ||= Configuration.new
44
- end
45
-
46
- # Ensure the engine is running
47
- def ensure_engine!
48
- run_engine! if self.engine.nil?
49
- end
50
-
51
- # Runs an engine, and starts a threaded workers if #configuration allows
52
- # it
53
- def run_engine!
54
-
55
- return unless configuration.run_engine
56
-
57
- storage = configuration.storage_instance
58
-
59
- self.engine = Ruote::Engine.new( configuration.run_worker ? self.worker = Ruote::Worker.new(storage) : storage )
60
-
61
- configuration.do_participant_registration
62
-
63
- @storage_participant = nil
64
- end
65
-
66
- # Run a single worker. By default this method will block indefinitely,
67
- # unless +run_in_thread+ is set to true
68
- def run_worker!( run_in_thread = false )
69
- self.worker = Ruote::Worker.new( configuration.storage_instance )
70
- run_in_thread ? self.worker.run_in_thread : self.worker.run
71
- end
72
-
73
- def shutdown_engine( purge = false )
74
-
75
- return if self.engine.nil?
76
-
77
- self.engine.shutdown
78
-
79
- if purge
80
- self.engine.context.keys.each do |k|
81
- s = self.engine.context[k]
82
- s.purge if s.respond_to?(:purge)
83
- end
84
- end
85
-
86
- self.engine = nil
87
-
88
- shutdown_worker! if configuration.run_worker
89
- end
90
-
91
- def shutdown_worker!
92
- self.worker.shutdown if self.worker
93
- self.worker = nil
21
+ @env ||= defined?(Rails) ? Rails.env : ENV['RACK_ENV'] || 'development'
94
22
  end
95
23
 
96
24
  def storage_participant
97
- return nil if self.engine.nil?
98
- @storage_participant ||= Ruote::StorageParticipant.new(self.engine)
25
+ engine.storage_participant
99
26
  end
100
27
 
101
- # resets the configuration
102
- #
103
- # mainly used in tests
104
- def reset_configuration!
105
- @configuration = nil
28
+ def run_worker (storage)
29
+ RuoteKit.engine = Ruote::Engine.new(
30
+ Ruote::Worker.new(storage), :join => true)
106
31
  end
107
32
 
33
+ def bind_engine (storage)
34
+ RuoteKit.engine = Ruote::Engine.new(storage)
35
+ end
108
36
  end
109
37
  end
38
+