Class: Mutx::Support::FilesCleanner
- Inherits:
-
Object
- Object
- Mutx::Support::FilesCleanner
- Defined in:
- lib/mutx/support/files_cleanner.rb
Class Method Summary collapse
- .all_console_output_reports ⇒ Object
- .all_mutx_reports ⇒ Object
- .clear_mutx_log ⇒ Object
- .clear_sidekiq_log ⇒ Object
-
.delete_all_console_output_files ⇒ Boolean
Deletes all mutx execution output files.
-
.delete_all_mutx_reports ⇒ Boolean
Deletes all mutx html reports files.
- .delete_console_output_for(result_id) ⇒ Object
-
.delete_console_outputs_files ⇒ Boolean
Deletes mutx execution output files.
-
.delete_file(file_name) ⇒ Object
Returns true if delete fiven file_name.
- .delete_html_report_for(result_id) ⇒ Object
-
.delete_mutx_folder ⇒ Boolean
Deletes mutx folder.
-
.delete_mutx_reports ⇒ Object
Deletes all mutx html reports.
- .delete_mutx_reports_dir ⇒ Object
- .delete_report_which_has(text) ⇒ Object
-
.start! ⇒ Object
Delete all mutx_reports html files.
Class Method Details
.all_console_output_reports ⇒ Object
103 104 105 106 107 |
# File 'lib/mutx/support/files_cleanner.rb', line 103 def self.all_console_output_reports Dir["#{Dir.pwd}/mutx/temp/*.*"].select do |file| !file.scan(/mutx_co_\d+\.out/).empty? end end |
.all_mutx_reports ⇒ Object
57 58 59 60 61 |
# File 'lib/mutx/support/files_cleanner.rb', line 57 def self.all_mutx_reports Dir["#{Dir.pwd}/mutx/temp/*.*"].select do |file| !file.scan(/mutx_report_\d+\.html/).empty? end end |
.clear_mutx_log ⇒ Object
124 125 126 127 128 129 130 |
# File 'lib/mutx/support/files_cleanner.rb', line 124 def self.clear_mutx_log mutx_log_file_path = "#{Dir.pwd}/mutx/logs/mutx.log" if File.exist? mutx_log_file_path File.delete(mutx_log_file_path) File.open(mutx_log_file_path, "a+"){} end end |
.clear_sidekiq_log ⇒ Object
116 117 118 119 120 121 122 |
# File 'lib/mutx/support/files_cleanner.rb', line 116 def self.clear_sidekiq_log sidekiq_file_path = "#{Dir.pwd}/mutx/sidekiq_log" if File.exist? sidekiq_file_path File.delete(sidekiq_file_path) File.open(sidekiq_file_path, "a+"){} end end |
.delete_all_console_output_files ⇒ Boolean
Deletes all mutx execution output files
97 98 99 100 101 |
# File 'lib/mutx/support/files_cleanner.rb', line 97 def self.delete_all_console_output_files not all_console_output_reports.each do |file| delete_file(file) end.empty? end |
.delete_all_mutx_reports ⇒ Boolean
Deletes all mutx html reports files
76 77 78 79 80 81 |
# File 'lib/mutx/support/files_cleanner.rb', line 76 def self.delete_all_mutx_reports not all_mutx_reports.each do |file| self.delete_file(file) end.empty? end |
.delete_console_output_for(result_id) ⇒ Object
109 110 111 112 113 114 |
# File 'lib/mutx/support/files_cleanner.rb', line 109 def self.delete_console_output_for result_id file=all_console_output_reports.select do |file| file.include? result_id end.first delete_file(file) if file end |
.delete_console_outputs_files ⇒ Boolean
Deletes mutx execution output files
85 86 87 88 89 90 91 92 93 |
# File 'lib/mutx/support/files_cleanner.rb', line 85 def self.delete_console_outputs_files (Mutx::Support::Git.reset_hard and Mutx::Support::Git.pull) if Mutx::Support::Configuration.use_git? begin self.delete_all_console_output_files true rescue false end end |
.delete_file(file_name) ⇒ Object
Returns true if delete fiven file_name
20 21 22 23 24 25 26 |
# File 'lib/mutx/support/files_cleanner.rb', line 20 def self.delete_file file_name begin File.delete("#{file_name}") and true rescue false end end |
.delete_html_report_for(result_id) ⇒ Object
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/mutx/support/files_cleanner.rb', line 46 def self.delete_html_report_for result_id file = all_mutx_reports.select do |file| file.include? result_id end.first if file delete_file(file) and true else false end end |
.delete_mutx_folder ⇒ Boolean
Deletes mutx folder. Used by ‘bye command’
134 135 136 137 138 139 140 141 142 |
# File 'lib/mutx/support/files_cleanner.rb', line 134 def self.delete_mutx_folder begin location = "#{Dir.pwd}/mutx" FileUtils.rm_rf(location) true rescue false end end |
.delete_mutx_reports ⇒ Object
Deletes all mutx html reports
64 65 66 67 68 69 70 71 72 |
# File 'lib/mutx/support/files_cleanner.rb', line 64 def self.delete_mutx_reports # Get all html report files (Mutx::Support::Git.reset_hard and Mutx::Support::Git.pull) if Mutx::Support::Configuration.use_git? begin self.delete_all_mutx_reports rescue false end end |
.delete_mutx_reports_dir ⇒ Object
28 29 30 31 32 |
# File 'lib/mutx/support/files_cleanner.rb', line 28 def self.delete_mutx_reports_dir location = "#{Dir.pwd}/mutx/mutx_reports" FileUtils.rm_rf(location) Dir.mkdir(location) end |
.delete_report_which_has(text) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/mutx/support/files_cleanner.rb', line 34 def self.delete_report_which_has text text = text.to_s if text.respond_to? :to_s report = all_mutx_reports.select do |file| file.include? text end.first if delete_file(report) Mutx::Support::Log.debug "Execution files(id=#{result.id}) cleanned" and true else false end end |
.start! ⇒ Object
Delete all mutx_reports html files
9 10 11 12 13 14 15 16 |
# File 'lib/mutx/support/files_cleanner.rb', line 9 def self.start! begin self.delete_mutx_reports_dir rescue false end end |