sinatra-hexacta 0.9.11 → 1.0.3
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 +4 -4
- data/lib/sinatra/extensions/antiquity.rb +13 -11
- data/lib/sinatra/extensions/init.rb +2 -2
- data/lib/sinatra/extensions/processmanager.rb +15 -12
- data/lib/sinatra/handlers/processes.rb +5 -3
- data/lib/sinatra/views/charts/bar.slim +50 -47
- data/lib/sinatra/views/charts/pie.slim +5 -1
- data/lib/sinatra/views/charts/stacked_bar.slim +2 -2
- metadata +1 -2
- data/lib/sinatra/public/vendors/material-design-iconic-font/fonts/Material-Design-Iconic-Font.eot +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b7b030f298091b86eff87999817b7e167b7f23f70a1cb96cc82571785ab4fecd
|
4
|
+
data.tar.gz: 89f21adaf020ba14de57ef7b890ae23013bf827e96dd2cf5d6e7cc793d8d42ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '04543278f129084cd3c67cc5e7aa83ae5c2ee6ef7e9e5cf730927637629b8151384d0fbdc9800e5bf5ccc8748ea3d8ec88fe762289a782c59162ea2b2fc3fc0c'
|
7
|
+
data.tar.gz: 39ffb8a63ecd557b5700c8b7d8feac27ba97d884e979087fe33e2333bd44990381e2a003c3c2f72e15374d180b8f4f2d06006aa647a13660360250ffbc1d5968
|
@@ -5,16 +5,16 @@ class Antiquity
|
|
5
5
|
@periods = periods.sort { |a,b| a.start_date <=> b.start_date }
|
6
6
|
end
|
7
7
|
|
8
|
-
def days
|
9
|
-
@periods.inject(0) { |total, period| total + period.days }
|
8
|
+
def days(upto_date=Date.today)
|
9
|
+
@periods.inject(0) { |total, period| total + period.days(upto_date) }
|
10
10
|
end
|
11
11
|
|
12
|
-
def months
|
13
|
-
@periods.inject(0) { |total, period| total + period.months }
|
12
|
+
def months(upto_date=Date.today)
|
13
|
+
@periods.inject(0) { |total, period| total + period.months(upto_date) }
|
14
14
|
end
|
15
15
|
|
16
|
-
def years
|
17
|
-
months.divmod(12).first
|
16
|
+
def years(upto_date=Date.today)
|
17
|
+
months(upto_date).divmod(12).first
|
18
18
|
end
|
19
19
|
|
20
20
|
def to_s(upto_date=Date.today)
|
@@ -22,11 +22,13 @@ class Antiquity
|
|
22
22
|
result = ""
|
23
23
|
return result if @periods.empty?
|
24
24
|
if date >= @periods.first.start_date
|
25
|
-
|
26
|
-
|
27
|
-
result +=
|
28
|
-
result += "
|
29
|
-
result += "
|
25
|
+
years_upto_date = years(date)
|
26
|
+
months_upto_date = months(date)
|
27
|
+
result += years_upto_date > 1 ? "#{years_upto_date} años" : "#{years_upto_date} año" unless years_upto_date == 0
|
28
|
+
result += ", " if years_upto_date >= 1 && !(months_upto_date.modulo(12).eql?(0))
|
29
|
+
result += months_upto_date.modulo(12) > 1 ? "#{months_upto_date.modulo(12)} meses" : "#{months_upto_date.modulo(12)} mes" unless months_upto_date.modulo(12) == 0
|
30
|
+
result += "#{(date - @periods.last.start_date).to_i} dias" if months_upto_date.modulo(12) == 0 && years_upto_date == 0 && date > @periods.last.start_date
|
31
|
+
result += "Hoy!" if months_upto_date.modulo(12) == 0 && date == @periods.last.start_date
|
30
32
|
end
|
31
33
|
result += "En unos días..." if date < @periods.first.start_date
|
32
34
|
result
|
@@ -1,11 +1,11 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require_relative 'antiquity'
|
3
3
|
require_relative 'date'
|
4
|
-
require_relative 'generalmail'
|
5
|
-
require_relative 'generalmailnolink'
|
6
4
|
require_relative 'mailbuilder'
|
7
5
|
require_relative 'mailsender'
|
8
6
|
require_relative 'mail'
|
7
|
+
require_relative 'generalmail'
|
8
|
+
require_relative 'generalmailnolink'
|
9
9
|
require_relative 'menu'
|
10
10
|
require_relative 'notification'
|
11
11
|
require_relative 'processmanager'
|
@@ -3,6 +3,7 @@
|
|
3
3
|
class AsyncProcess
|
4
4
|
include SuckerPunch::Job
|
5
5
|
attr_reader :handler
|
6
|
+
attr_reader :user_id
|
6
7
|
end
|
7
8
|
|
8
9
|
class ExampleProcess < AsyncProcess
|
@@ -25,10 +26,10 @@ end
|
|
25
26
|
|
26
27
|
class ProcessHandler
|
27
28
|
|
28
|
-
attr_reader :log, :error, :interrupted, :name, :id, :performed, :total, :clazz
|
29
|
+
attr_reader :log, :error, :interrupted, :name, :id, :performed, :total, :clazz, :user_id
|
29
30
|
attr_accessor :total
|
30
31
|
|
31
|
-
def initialize(id, name, clazz)
|
32
|
+
def initialize(id, name, clazz, user_id)
|
32
33
|
@id = id
|
33
34
|
@total = 0
|
34
35
|
@performed = 0
|
@@ -37,6 +38,7 @@ class ProcessHandler
|
|
37
38
|
@interrupted = false
|
38
39
|
@name = name
|
39
40
|
@clazz = clazz
|
41
|
+
@user_id = user_id
|
40
42
|
end
|
41
43
|
|
42
44
|
def progress
|
@@ -74,21 +76,22 @@ class ProcessManager
|
|
74
76
|
@handlers = []
|
75
77
|
end
|
76
78
|
|
77
|
-
def find(clazz)
|
78
|
-
@handlers.find { |handler| handler.clazz == clazz }
|
79
|
+
def find(clazz,user_id)
|
80
|
+
@handlers.find { |handler| handler.clazz == clazz && handler.user_id == user_id }
|
79
81
|
end
|
80
82
|
|
81
83
|
def run(*args)
|
82
|
-
|
83
|
-
|
84
|
-
|
84
|
+
user_id = args[1][:user_id]
|
85
|
+
clean(args.first.to_s,user_id)
|
86
|
+
if !running?(args.first.to_s,user_id)
|
87
|
+
handler = ProcessHandler.new(rand(1..100000000), args.first.name, args.first.to_s, user_id)
|
85
88
|
clazz = args.first
|
86
89
|
args[0] = handler
|
87
90
|
clazz.perform_async(*args)
|
88
91
|
@handlers << handler
|
89
92
|
handler
|
90
93
|
else
|
91
|
-
find(args.first.to_s)
|
94
|
+
find(args.first.to_s,user_id)
|
92
95
|
end
|
93
96
|
end
|
94
97
|
|
@@ -96,15 +99,15 @@ class ProcessManager
|
|
96
99
|
@handlers -= [handler]
|
97
100
|
end
|
98
101
|
|
99
|
-
def clean(clazz)
|
100
|
-
@handlers.select { |handler| handler.clazz == clazz }.each do |handler|
|
102
|
+
def clean(clazz,user_id)
|
103
|
+
@handlers.select { |handler| handler.clazz == clazz && handler.user_id == user_id }.each do |handler|
|
101
104
|
handler.interrupt
|
102
105
|
self.finish(handler)
|
103
106
|
end
|
104
107
|
end
|
105
108
|
|
106
|
-
def running?(clazz)
|
107
|
-
!@handlers.select { |handler| handler.clazz == clazz }.empty?
|
109
|
+
def running?(clazz,user_id)
|
110
|
+
!@handlers.select { |handler| handler.clazz == clazz && handler.user_id == user_id }.empty?
|
108
111
|
end
|
109
112
|
|
110
113
|
end
|
@@ -7,17 +7,19 @@ module Sinatra
|
|
7
7
|
p "Enabling processes..."
|
8
8
|
|
9
9
|
get '/processes' do
|
10
|
-
return "" if ProcessManager.instance.find(params[:class]).nil?
|
10
|
+
return "" if ProcessManager.instance.find(params[:class],authenticated(User).id).nil?
|
11
11
|
content_type :json
|
12
|
-
|
12
|
+
process = ProcessManager.instance.find(params[:class],authenticated(User).id)
|
13
|
+
return { 'name' => process.name, 'progress' => process.progress }.to_json
|
13
14
|
end
|
14
15
|
|
15
16
|
post '/processes/:clazz' do |clazz|
|
16
|
-
ProcessManager.instance.clean(clazz)
|
17
|
+
ProcessManager.instance.clean(clazz,authenticated(User).id)
|
17
18
|
200
|
18
19
|
end
|
19
20
|
|
20
21
|
post '/process' do
|
22
|
+
params[:user_id] = authenticated(User).id
|
21
23
|
klass = Object.const_get("#{params[:class]}")
|
22
24
|
a_handler = ProcessManager.instance.run(klass,params)
|
23
25
|
a_handler.to_json
|
@@ -1,56 +1,59 @@
|
|
1
|
-
|
1
|
+
-if labels.empty? || series.empty?
|
2
|
+
== empty_alert({ :title => "Sin datos suficientes", :message => "No hay suficientes datos para mostrar esta información."})
|
3
|
+
-else
|
4
|
+
.ct-chart.bar-chart id="#{id}"
|
2
5
|
|
3
|
-
.table-responsive.chart-table
|
4
|
-
|
5
|
-
|
6
|
-
tr
|
7
|
-
-for label in labels
|
8
|
-
th #{label}
|
9
|
-
-for serie in series
|
6
|
+
.table-responsive.chart-table
|
7
|
+
table.table.table-striped
|
8
|
+
tbody
|
10
9
|
tr
|
11
|
-
-for
|
12
|
-
|
10
|
+
-for label in labels
|
11
|
+
th #{label}
|
12
|
+
-for serie in series
|
13
|
+
tr
|
14
|
+
-for element in serie
|
15
|
+
td #{element}
|
13
16
|
|
14
17
|
|
15
|
-
javascript:
|
16
|
-
|
17
|
-
|
18
|
+
javascript:
|
19
|
+
var labels = #{{labels}};
|
20
|
+
var series = #{{series}};
|
18
21
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
22
|
+
var options = {
|
23
|
+
seriesBarDistance: 30,
|
24
|
+
fullWidth: true,
|
25
|
+
chartPadding: {
|
26
|
+
right: 40
|
27
|
+
},
|
28
|
+
height: '300px',
|
29
|
+
showLabel: true,
|
30
|
+
plugins: [
|
31
|
+
Chartist.plugins.legend({
|
32
|
+
legendNames: #{{names}},
|
33
|
+
})
|
34
|
+
]
|
35
|
+
};
|
33
36
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
37
|
+
var responsiveOptions = [
|
38
|
+
['screen and (max-width: 640px)', {
|
39
|
+
seriesBarDistance: 5,
|
40
|
+
axisX: {
|
41
|
+
labelInterpolationFnc: function (value) {
|
42
|
+
return value[0];
|
43
|
+
}
|
40
44
|
}
|
41
|
-
}
|
42
|
-
|
43
|
-
];
|
45
|
+
}]
|
46
|
+
];
|
44
47
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
48
|
+
new Chartist.Bar("##{id}", {
|
49
|
+
labels: labels,
|
50
|
+
series: series
|
51
|
+
},
|
52
|
+
options,
|
53
|
+
responsiveOptions
|
54
|
+
);
|
52
55
|
|
53
|
-
css:
|
54
|
-
|
55
|
-
|
56
|
-
|
56
|
+
css:
|
57
|
+
##{{id}} .ct-bar {
|
58
|
+
stroke-width: #{{100/(labels.count*series.count)}}%
|
59
|
+
}
|
@@ -9,6 +9,10 @@
|
|
9
9
|
tr
|
10
10
|
-for element in serie
|
11
11
|
td #{element}
|
12
|
+
tr
|
13
|
+
-total = [1,serie.reduce(:+)].max
|
14
|
+
-for element in serie
|
15
|
+
td #{(element.to_f*100/total).round(0)}%
|
12
16
|
|
13
17
|
javascript:
|
14
18
|
var labels = #{{labels}};
|
@@ -25,7 +29,7 @@ javascript:
|
|
25
29
|
Chartist.plugins.legend()
|
26
30
|
]
|
27
31
|
}
|
28
|
-
|
32
|
+
);
|
29
33
|
|
30
34
|
css:
|
31
35
|
.pie .ct-legend.ct-legend-inside {
|
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.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marco Zanger
|
@@ -163,7 +163,6 @@ files:
|
|
163
163
|
- lib/sinatra/public/vendors/malihu-custom-scrollbar-plugin/mCSB_buttons.png
|
164
164
|
- lib/sinatra/public/vendors/material-design-iconic-font/css/material-design-iconic-font.css
|
165
165
|
- lib/sinatra/public/vendors/material-design-iconic-font/css/material-design-iconic-font.min.css
|
166
|
-
- lib/sinatra/public/vendors/material-design-iconic-font/fonts/Material-Design-Iconic-Font.eot
|
167
166
|
- lib/sinatra/public/vendors/material-design-iconic-font/fonts/Material-Design-Iconic-Font.svg
|
168
167
|
- lib/sinatra/public/vendors/material-design-iconic-font/fonts/Material-Design-Iconic-Font.ttf
|
169
168
|
- lib/sinatra/public/vendors/material-design-iconic-font/fonts/Material-Design-Iconic-Font.woff
|