sinatra-hexacta 0.3.8 → 0.3.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sinatra/extensions/init.rb +1 -0
- data/lib/sinatra/extensions/processmanager.rb +106 -0
- data/lib/sinatra/handlers/init.rb +2 -1
- data/lib/sinatra/handlers/processes.rb +28 -0
- data/lib/sinatra/public/css/app.min.1.css +2 -2
- data/lib/sinatra/views/inputs/date.slim +4 -2
- data/lib/sinatra/views/inputs/input.slim +6 -5
- data/lib/sinatra/views/inputs/multiple_select.slim +3 -2
- data/lib/sinatra/views/inputs/select.slim +4 -3
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e5dcb9cef01c9a77b03a009a9b1a5451fb27889692879645801474efa41fd40
|
4
|
+
data.tar.gz: 8e1e59f37a699d6c4e91e36feec49ec8422e6619662e00815b61a9276e4389ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb94d132e2bc6baa03bc1b9321abc8de50df247ea04767a47cc1d530719a4fc13e4445648b3dc46e1d46b1cf1165d6df26fc247c985a264a05dbfcb92ca5a7c5
|
7
|
+
data.tar.gz: 5f7ad7194685207a41c3ae66327e212dfe199dc898ebb062937274250bfb7c6fe6cd99a96045de14e0805160762eb0eb3a2f6a3d323d055eca674ba3b51fa3df
|
@@ -0,0 +1,106 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
class AsyncProcess
|
4
|
+
include SuckerPunch::Job
|
5
|
+
attr_reader :handler
|
6
|
+
end
|
7
|
+
|
8
|
+
class ExampleProcess < AsyncProcess
|
9
|
+
|
10
|
+
attr_reader :log, :error, :interrupted, :name, :id
|
11
|
+
|
12
|
+
def self.name
|
13
|
+
"THE NAME"
|
14
|
+
end
|
15
|
+
|
16
|
+
def perform(handler, other_params)
|
17
|
+
@handler = handler
|
18
|
+
@handler.total = params[:ids].count
|
19
|
+
# loop
|
20
|
+
# if error @handler.log("error no falta", e.message)
|
21
|
+
# @handler.increase
|
22
|
+
#
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
class ProcessHandler
|
27
|
+
|
28
|
+
attr_reader :log, :error, :interrupted, :name, :id, :performed, :total, :clazz
|
29
|
+
attr_accessor :total
|
30
|
+
|
31
|
+
def initialize(id, name, clazz)
|
32
|
+
@id = id
|
33
|
+
@total = 0
|
34
|
+
@performed = 0
|
35
|
+
@log = []
|
36
|
+
@error = ""
|
37
|
+
@interrupted = false
|
38
|
+
@name = name
|
39
|
+
@clazz = clazz
|
40
|
+
end
|
41
|
+
|
42
|
+
def progress
|
43
|
+
return 0 if @total == 0
|
44
|
+
(@performed.to_f / @total.to_f)*100.0
|
45
|
+
end
|
46
|
+
|
47
|
+
def increase
|
48
|
+
@performed += 1
|
49
|
+
end
|
50
|
+
|
51
|
+
def log(severity, message)
|
52
|
+
@log << "[#{severity}] #{Time.now} #{message}"
|
53
|
+
end
|
54
|
+
|
55
|
+
def interrupt
|
56
|
+
@interrupted = true
|
57
|
+
end
|
58
|
+
|
59
|
+
def running?
|
60
|
+
@total != @performed
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
class ProcessManager
|
65
|
+
include Singleton
|
66
|
+
|
67
|
+
attr_reader :handlers
|
68
|
+
|
69
|
+
def initialize
|
70
|
+
@handlers = []
|
71
|
+
end
|
72
|
+
|
73
|
+
def find(clazz)
|
74
|
+
@handlers.find { |handler| handler.clazz == clazz }
|
75
|
+
end
|
76
|
+
|
77
|
+
def run(*args)
|
78
|
+
clean(args.first.to_s)
|
79
|
+
if !running?(args.first.to_s)
|
80
|
+
handler = ProcessHandler.new(rand(1..100000000), args.first.name, args.first.to_s)
|
81
|
+
clazz = args.first
|
82
|
+
args[0] = handler
|
83
|
+
clazz.perform_async(*args)
|
84
|
+
@handlers << handler
|
85
|
+
handler
|
86
|
+
else
|
87
|
+
find(args.first.to_s)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def finish(handler)
|
92
|
+
@handlers -= [handler]
|
93
|
+
end
|
94
|
+
|
95
|
+
def clean(clazz)
|
96
|
+
@handlers.select { |handler| !handler.running? }.each do |handler|
|
97
|
+
handler.interrupt
|
98
|
+
self.finish(handler)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def running?(clazz)
|
103
|
+
!@handlers.select { |handler| handler.clazz == clazz }.empty?;
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module Sinatra
|
3
|
+
module ProcessesHandler
|
4
|
+
extend Hexacta
|
5
|
+
|
6
|
+
def enable_processes
|
7
|
+
p "Enabling processes..."
|
8
|
+
|
9
|
+
get '/processes' do
|
10
|
+
return "" if ProcessManager.instance.find(params[:class]).nil?
|
11
|
+
content_type :json
|
12
|
+
return { "progress" => ProcessManager.instance.find(params[:class]).progress }.to_json
|
13
|
+
end
|
14
|
+
|
15
|
+
post '/processes/:id' do |id|
|
16
|
+
ProcessManager.instance.interrupt(id)
|
17
|
+
end
|
18
|
+
|
19
|
+
post '/process' do
|
20
|
+
a_handler = ProcessManager.instance.run(params)
|
21
|
+
a_handler.to_json
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
register ProcessesHandler
|
27
|
+
end
|
28
|
+
|
@@ -13860,7 +13860,7 @@ fieldset[disabled] .btn-inverse:active {
|
|
13860
13860
|
*/
|
13861
13861
|
|
13862
13862
|
.m-btn {
|
13863
|
-
z-index:
|
13863
|
+
z-index: 9;
|
13864
13864
|
right: 40px;
|
13865
13865
|
bottom: 40px;
|
13866
13866
|
position: fixed !important;
|
@@ -13905,7 +13905,7 @@ fieldset[disabled] .btn-inverse:active {
|
|
13905
13905
|
border-radius: 20px;
|
13906
13906
|
opacity: 0.6;
|
13907
13907
|
font-size: 8pt;
|
13908
|
-
z-index:
|
13908
|
+
z-index: 9;
|
13909
13909
|
}
|
13910
13910
|
|
13911
13911
|
.left-footer .text {
|
@@ -2,11 +2,13 @@
|
|
2
2
|
- required = false
|
3
3
|
- if !(defined? id) || id.blank?
|
4
4
|
- id = "#{name}_#{rand(1000)}"
|
5
|
+
- unless defined? clazz
|
6
|
+
- clazz = nil
|
5
7
|
|
6
8
|
.form-group.fg-float
|
7
9
|
label #{title}
|
8
10
|
.fg-line
|
9
11
|
-if required
|
10
|
-
input.form-control.date-picker.fg-input id="#{id}" type="text" name="#{name}" required="" value="#{value}"
|
12
|
+
input.form-control.date-picker.fg-input id="#{id}" type="text" name="#{name}" required="" class="#{clazz}" value="#{value}"
|
11
13
|
-else
|
12
|
-
input.form-control.date-picker.fg-input id="#{id}" type="text" name="#{name}" value="#{value}"
|
14
|
+
input.form-control.date-picker.fg-input id="#{id}" type="text" name="#{name}" class="#{clazz}" value="#{value}"
|
@@ -8,22 +8,23 @@
|
|
8
8
|
-onkeyup = ''
|
9
9
|
-unless defined? readonly
|
10
10
|
-readonly = false
|
11
|
-
|
11
|
+
- unless defined? clazz
|
12
|
+
- clazz = nil
|
12
13
|
|
13
14
|
-if required
|
14
15
|
.form-group.has-feedback.has-success
|
15
16
|
label #{title}
|
16
17
|
.fg-line
|
17
18
|
-if readonly
|
18
|
-
input.form-control.fg-input id="#{id}" type="#{type}" placeholder="#{placeholder}" name="#{name}" required="" value="#{value}" onkeyup="#{onkeyup}" readonly=''
|
19
|
+
input.form-control.fg-input id="#{id}" type="#{type}" placeholder="#{placeholder}" name="#{name}" required="" value="#{value}" class="#{clazz}" onkeyup="#{onkeyup}" readonly=''
|
19
20
|
-else
|
20
|
-
input.form-control.fg-input id="#{id}" type="#{type}" placeholder="#{placeholder}" name="#{name}" required="" value="#{value}" onkeyup="#{onkeyup}"
|
21
|
+
input.form-control.fg-input id="#{id}" type="#{type}" placeholder="#{placeholder}" name="#{name}" required="" value="#{value}" class="#{clazz}" onkeyup="#{onkeyup}"
|
21
22
|
|
22
23
|
-else
|
23
24
|
.form-group
|
24
25
|
label #{title}
|
25
26
|
.fg-line
|
26
27
|
-if readonly
|
27
|
-
input.form-control.fg-input id="#{id}" type="#{type}" placeholder="#{placeholder}" name="#{name}" value="#{value}" onkeyup="#{onkeyup}" readonly=''
|
28
|
+
input.form-control.fg-input id="#{id}" type="#{type}" placeholder="#{placeholder}" name="#{name}" value="#{value}" onkeyup="#{onkeyup}" class="#{clazz}" readonly=''
|
28
29
|
-else
|
29
|
-
input.form-control.fg-input id="#{id}" type="#{type}" placeholder="#{placeholder}" name="#{name}" value="#{value}" onkeyup="#{onkeyup}"
|
30
|
+
input.form-control.fg-input id="#{id}" type="#{type}" placeholder="#{placeholder}" name="#{name}" value="#{value}" onkeyup="#{onkeyup}" class="#{clazz}"
|
@@ -4,7 +4,8 @@
|
|
4
4
|
- id = "#{name}_#{rand(1000)}"
|
5
5
|
- unless defined? placeholder
|
6
6
|
- placeholder = "Selecciona..."
|
7
|
-
|
7
|
+
- unless defined? clazz
|
8
|
+
- clazz = nil
|
8
9
|
- unless defined? selected_elements
|
9
10
|
- selected_elements = []
|
10
11
|
- if selected_elements.nil?
|
@@ -14,7 +15,7 @@
|
|
14
15
|
-if required
|
15
16
|
.form-group.has-success
|
16
17
|
label.fg-label #{placeholder}
|
17
|
-
select.chosen id="#{id}" name="#{name}[]" data-placeholder=("#{placeholder}") chosen="" multiple="" style=("display: none;") required=""
|
18
|
+
select.chosen id="#{id}" class="#{clazz}" name="#{name}[]" data-placeholder=("#{placeholder}") chosen="" multiple="" style=("display: none;") required=""
|
18
19
|
-for element in elements
|
19
20
|
-if selected_elements.include?(element[:value].to_s)
|
20
21
|
option value="#{element[:value]}" selected="" #{element[:text]}
|
@@ -6,12 +6,13 @@
|
|
6
6
|
- placeholder = "Selecciona..."
|
7
7
|
- unless defined? chosen
|
8
8
|
- chosen = nil
|
9
|
-
|
9
|
+
- unless defined? clazz
|
10
|
+
- clazz = nil
|
10
11
|
|
11
12
|
-if required
|
12
13
|
.form-group.has-success
|
13
14
|
label #{placeholder}
|
14
|
-
select.chosen.form-control id="#{id}" name="#{name}" data-placeholder=("#{placeholder}") style=("display: none;") required=""
|
15
|
+
select.chosen.form-control id="#{id}" class="#{clazz}" name="#{name}" data-placeholder=("#{placeholder}") style=("display: none;") required=""
|
15
16
|
-for element in elements
|
16
17
|
-if chosen == element[:value]
|
17
18
|
option value="#{element[:value]}" selected="" #{element[:text]}
|
@@ -21,7 +22,7 @@
|
|
21
22
|
-else
|
22
23
|
.form-group
|
23
24
|
label #{placeholder}
|
24
|
-
select.chosen id="#{id}" name="#{name}" data-placeholder=("#{placeholder}") style=("display: none;")
|
25
|
+
select.chosen id="#{id}" class="#{clazz}" name="#{name}" data-placeholder=("#{placeholder}") style=("display: none;")
|
25
26
|
-for element in elements
|
26
27
|
-if chosen == element[:value]
|
27
28
|
option value="#{element[:value]}" selected="" #{element[:text]}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sinatra-hexacta
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marco Zanger
|
@@ -67,10 +67,12 @@ files:
|
|
67
67
|
- lib/sinatra/extensions/mailbuilder.rb
|
68
68
|
- lib/sinatra/extensions/mailsender.rb
|
69
69
|
- lib/sinatra/extensions/notification.rb
|
70
|
+
- lib/sinatra/extensions/processmanager.rb
|
70
71
|
- lib/sinatra/handlers/errors.rb
|
71
72
|
- lib/sinatra/handlers/init.rb
|
72
73
|
- lib/sinatra/handlers/notifications.rb
|
73
74
|
- lib/sinatra/handlers/params.rb
|
75
|
+
- lib/sinatra/handlers/processes.rb
|
74
76
|
- lib/sinatra/handlers/reports.rb
|
75
77
|
- lib/sinatra/helpers/alerts.rb
|
76
78
|
- lib/sinatra/helpers/cas.rb
|