sinatra-hexacta 1.7.16 → 1.7.18

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 64483d4fcbd91ac280aa50720815045c081afd4f22ac58d51fc68150e61e46f2
4
- data.tar.gz: 94e1904ccbf68d409b765230fc48dca5deb34a5a917bf66404d59db20e7a18db
3
+ metadata.gz: 8c9e3709270cd64bef803f1d381dd05d6336bd4fba3c14f08be4352470179573
4
+ data.tar.gz: a214690224f58528af782cf2e68d81c39d56048f73e83125fbaded3541aacfcf
5
5
  SHA512:
6
- metadata.gz: a3df5a184a1074b267979083c890950052ce24e194ad40a83039633c9e1a23921b193d53ecb33ccb24ec739eb0c924413ebb23aa62b401b4629977a79855606e
7
- data.tar.gz: 1100cc8e9d0f68a4a7f316d00d9e9b713ab4132fa11c97396cca311bb3271072daba556a8abdf8f4adc01a4dd22da0831c9749cf2bd7f41cb1cc706043c7275d
6
+ metadata.gz: f16f135324e926d4b6a874a53fdc6918c2415d561c45310aa653e5ec8e8fdff4d32887a8e58ba15458f92032ce4e4551d373e563e7e3242886869aa9dea4c98b
7
+ data.tar.gz: ff01d5f9e159f0f0f2930a519231ab5f665e2fc47c6c9f8a43735d350ef8a3c9a336b8c5f4c30614c5b95736903bf889c2e8c8e9f10061c34b0ba96a664a7cc6
@@ -10,3 +10,4 @@ require_relative 'generalmailnolink'
10
10
  require_relative 'menu'
11
11
  require_relative 'notification'
12
12
  require_relative 'processmanager'
13
+ require_relative 'report_generator'
@@ -0,0 +1,21 @@
1
+ # encoding: utf-8
2
+ class ReportGenerator
3
+
4
+ def build(report_columns,query)
5
+ workbook = RubyXL::Workbook.new
6
+ worksheet = workbook[0]
7
+
8
+ report_columns.each_with_index do |report_column, i|
9
+ worksheet.add_cell(0, i, report_column.name)
10
+ end
11
+
12
+ query.all.each_with_index do |element, x|
13
+ report_columns.each_with_index do |report_column, y|
14
+ worksheet.add_cell(x+1, y, report_column.value(element))
15
+ end
16
+ end
17
+
18
+ IO.copy_stream(workbook.stream, out)
19
+ end
20
+
21
+ end
@@ -5,61 +5,83 @@ module Sinatra
5
5
 
6
6
  @@scheduler = Rufus::Scheduler.new
7
7
 
8
- def schedule_every(time)
8
+ def check_file_locked?(specific_lock_file=nil)
9
+ return false if specific_lock_file.nil?
10
+ f = File.open("/tmp/#{specific_lock_file}", File::CREAT)
11
+ Timeout::timeout(0.001) { f.flock(File::LOCK_EX) }
12
+ f.flock(File::LOCK_UN)
13
+ false
14
+ rescue
15
+ true
16
+ ensure
17
+ unless f.nil?
18
+ f.close
19
+ end
20
+ end
21
+
22
+ def schedule_every(time,specific_lock_file=nil)
9
23
  @@scheduler.every time do
10
- begin
11
- file_path = "/tmp/schedule.lock";
12
- f = File.open(file_path, "w+")
13
- # if file was previosly locked then flock throw a exception
14
- f.flock(File::LOCK_EX)
15
- ten_minutes = 600
16
- # if the process overcome ten minutes, the timeout api throw a exception
17
- Timeout::timeout(ten_minutes) do
18
24
 
19
- begin
20
- yield
21
- rescue StandardError => error
22
- title = error.message.split(':')[0].gsub('#<','');
23
- message = error.backtrace.join(',');
24
- NotificationSender.instance.send_error(nil,title,message)
25
- end
25
+ unless check_file_locked?(specific_lock_file)
26
+ begin
27
+ file_path = specific_lock_file.nil?? "/tmp/schedule.lock" : "/tmp/#{specific_lock_file}";
28
+ f = File.open(file_path, "w+")
29
+ # if file was previosly locked then flock throw a exception
30
+ f.flock(File::LOCK_EX)
31
+ ten_minutes = 600
32
+ # if the process overcome ten minutes, the timeout api throw a exception
33
+ Timeout::timeout(ten_minutes) do
26
34
 
27
- end
28
- ensure
29
- unless f.nil?
30
- f.flock(File::LOCK_UN)
31
- f.close
35
+ begin
36
+ yield
37
+ rescue StandardError => error
38
+ title = error.message.split(':')[0].gsub('#<','');
39
+ message = error.backtrace.join(',');
40
+ NotificationSender.instance.send_error(nil,title,message)
41
+ end
42
+
43
+ end
44
+ ensure
45
+ unless f.nil?
46
+ f.flock(File::LOCK_UN)
47
+ f.close
48
+ end
32
49
  end
33
50
  end
51
+
34
52
  end
35
53
  end
36
54
 
37
- def schedule_at(cron_expression)
55
+ def schedule_at(cron_expression,specific_lock_file=nil)
38
56
  @@scheduler.cron cron_expression do
39
- begin
40
- file_path = "/tmp/schedule.lock";
41
- f = File.open(file_path, "w+")
42
- # if file was previosly locked then flock throw a exception
43
- f.flock(File::LOCK_EX)
44
- ten_minutes = 600
45
- # if the process overcome ten minutes, the timeout api throw a exception
46
- Timeout::timeout(ten_minutes) do
47
57
 
48
- begin
49
- yield
50
- rescue error
51
- title = error.message.split(':')[0].gsub('#<','');
52
- message = error.backtrace.join(',');
53
- NotificationSender.instance.send_error(nil,title,message)
54
- end
58
+ unless check_file_locked?(specific_lock_file)
59
+ begin
60
+ file_path = specific_lock_file.nil?? "/tmp/schedule.lock" : "/tmp/#{specific_lock_file}";
61
+ f = File.open(file_path, "w+")
62
+ # if file was previosly locked then flock throw a exception
63
+ f.flock(File::LOCK_EX)
64
+ ten_minutes = 600
65
+ # if the process overcome ten minutes, the timeout api throw a exception
66
+ Timeout::timeout(ten_minutes) do
55
67
 
56
- end
57
- ensure
58
- unless f.nil?
59
- f.flock(File::LOCK_UN)
60
- f.close
68
+ begin
69
+ yield
70
+ rescue error
71
+ title = error.message.split(':')[0].gsub('#<','');
72
+ message = error.backtrace.join(',');
73
+ NotificationSender.instance.send_error(nil,title,message)
74
+ end
75
+
76
+ end
77
+ ensure
78
+ unless f.nil?
79
+ f.flock(File::LOCK_UN)
80
+ f.close
81
+ end
61
82
  end
62
83
  end
84
+
63
85
  end
64
86
  end
65
87
  end
@@ -76,6 +76,7 @@ function update_html_elements() {
76
76
  }
77
77
  $('body').append('<div aria-labelledby="error" class="modal bounceIn animated" id="error-modal" role="dialog" tabindex="-1"><div class="modal-dialog modal-sm" style="min-width:150px !Important;"><div class="modal-content"><div class="modal-body p-20 text-center"><i class="zmdi zmdi-hc-3x zmdi-alert-polygon c-red"></i></div><div class="modal-footer" style="text-align: center !Important;"><div class="f-900 c-gray">' + error.responseText + '</div></div></div></div></div>');
78
78
  $('#error-modal').modal('show');
79
+ $(this).find(':submit').attr("disabled",false);
79
80
  }
80
81
  });
81
82
  });
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: 1.7.16
4
+ version: 1.7.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marco Zanger
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: 0.3.1
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubyXL
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 3.4.25
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 3.4.25
83
97
  description: A gem to support general functionality accross all apps
84
98
  email: mzanger@hexacta.com
85
99
  executables: []
@@ -98,6 +112,7 @@ files:
98
112
  - lib/sinatra/extensions/menu.rb
99
113
  - lib/sinatra/extensions/notification.rb
100
114
  - lib/sinatra/extensions/processmanager.rb
115
+ - lib/sinatra/extensions/report_generator.rb
101
116
  - lib/sinatra/handlers/constants.rb
102
117
  - lib/sinatra/handlers/cross_origin.rb
103
118
  - lib/sinatra/handlers/errors.rb